queryByFeatures: VERY URGENT!!!

Daniele Margotti margottid at COMUNE.LUGO.RA.IT
Thu Jun 23 02:15:26 EDT 2005


No, you were right.

I added:
    TOLERANCE 0
    TOLERANCEUNITS PIXELS
to every query layer (they are POLYGON layers), and now - if you check
the examples - the behaviour of Mapserver 4.6.0 is the same of Mapserver
4.4.2.

I have a TOLERANCE > 0 only for POINT and LINE layers, to make them
queryable by mouse point; but for POLYGON layers I need to know if an
element IS OR IS NOT in a particular zone, and not if an element IS NEAR
a zone...

Thank you for your suggestion,
  Daniele


-----Original Message-----
From: Bart van den Eijnden [mailto:BEN at Syncera-ITSolutions.NL] 
Sent: Wednesday, June 22, 2005 2:49 PM
To: margottid at COMUNE.LUGO.RA.IT; MAPSERVER-USERS at LISTS.UMN.EDU
Subject: Re: [UMN_MAPSERVER-USERS] queryByFeatures: VERY URGENT!!!


If I look at the Mapserver code it does not set the default TOLERANCE
for POLYGON layers. So this bug is very likely not related to your
problem. Sorry, I thought maybe you had polyline layers.

You could try with TOLERANCE 0 and TOLERANCEUNITS PIXELS for all your
search layers though but I don't think it will solve your problem.

Best regards,
Bart

Bart van den Eijnden
Syncera IT Solutions
Postbus 270
2600 AG  DELFT

tel.nr.: 015-7512436
email: BEN at Syncera-ITSolutions.nl

>>> Daniele Margotti <margottid at COMUNE.LUGO.RA.IT> 06/22/05 01:40pm >>>
You got the point!

I had TOLERANCE (and TOLERANCEUNITS PIXELS) set only for POINT and LINE
layers.

So, you say I have to put:
    TOLERANCE 0
    TOLERANCEUNITS PIXELS
for *every* POLYGON layer to avoid the problem, am I right?

Or can I set a default tolerance for the entire map, and then specify
TOLERANCE only for layers where I really need it?

Thank you,
   Daniele


-----Original Message-----
From: Bart van den Eijnden [mailto:BEN at Syncera-ITSolutions.NL] 
Sent: Wednesday, June 22, 2005 1:07 PM
To: margottid at COMUNE.LUGO.RA.IT; MAPSERVER-USERS at LISTS.UMN.EDU 
Subject: Re: [UMN_MAPSERVER-USERS] queryByFeatures: VERY URGENT!!!


Hi,

Are all your query layers POLYGONS?

The only thing I could think of, but maybe isn't even related, is the
default tolerance which was added, but this was only added for LINE and
POINT layers.

http://mapserver.gis.umn.edu/bugs/show_bug.cgi?id=1103 

Do you have a TOLERANCE or TOLERANCEUNITS set in your MAP file? Can you
try and experiment with

Best regards,
Bart

Bart van den Eijnden
Syncera IT Solutions
Postbus 270
2600 AG  DELFT

tel.nr.: 015-7512436
email: BEN at Syncera-ITSolutions.nl 

>>> Daniele Margotti <margottid at COMUNE.LUGO.RA.IT> 06/22/05 12:47pm >>>
Ok, I'm able to provide you some examples of the problem.


Mapserver 4.4.2 (no errors)
---------------

This is the right query (layer "Mappali" intersects layer "ZonaE2_1")

http://sit.comune.lugo.ra.it:81/cgi-bin/mapserv442?mode=itemfeaturequery


&map=/dati/sit/Lugo_PRG.map&slayer=Mappali&qstring=E730%20%20%2012%20%20
%2015&qitem=PARTKEY&qlayer=ZonaE2_1&mapext=shapes

These should not return any result (layer "Mappali" doesn't intersect
layers "ZonaE2_2", "ZonaE2_4", "ZonaE2_15"):

http://sit.comune.lugo.ra.it:81/cgi-bin/mapserv442?mode=itemfeaturequery


&map=/dati/sit/Lugo_PRG.map&slayer=Mappali&qstring=E730%20%20%2012%20%20
%2015&qitem=PARTKEY&qlayer=ZonaE2_2&mapext=shapes

http://sit.comune.lugo.ra.it:81/cgi-bin/mapserv442?mode=itemfeaturequery


&map=/dati/sit/Lugo_PRG.map&slayer=Mappali&qstring=E730%20%20%2012%20%20
%2015&qitem=PARTKEY&qlayer=ZonaE2_4&mapext=shapes

http://sit.comune.lugo.ra.it:81/cgi-bin/mapserv442?mode=itemfeaturequery


&map=/dati/sit/Lugo_PRG.map&slayer=Mappali&qstring=E730%20%20%2012%20%20
%2015&qitem=PARTKEY&qlayer=ZonaE2_15&mapext=shapes


Mapserver 4.6.0 (ERRORS!)
---------------
This return TWO results, but layer "Mappali" intersect layers "ZonaE2_1"
ONLY ONE TIME:

http://sit.comune.lugo.ra.it:81/cgi-bin/mapserv460?mode=itemfeaturequery


&map=/dati/sit/Lugo_PRG.map&slayer=Mappali&qstring=E730%20%20%2012%20%20
%2015&qitem=PARTKEY&qlayer=ZonaE2_1&mapext=shapes

These return results, but layer "Mappali" doesn't intersect any of
layers "Zona*":

http://sit.comune.lugo.ra.it:81/cgi-bin/mapserv460?mode=itemfeaturequery


&map=/dati/sit/Lugo_PRG.map&slayer=Mappali&qstring=E730%20%20%2012%20%20
%2015&qitem=PARTKEY&qlayer=ZonaE2_2&mapext=shapes

http://sit.comune.lugo.ra.it:81/cgi-bin/mapserv460?mode=itemfeaturequery


&map=/dati/sit/Lugo_PRG.map&slayer=Mappali&qstring=E730%20%20%2012%20%20
%2015&qitem=PARTKEY&qlayer=ZonaE2_4&mapext=shapes

http://sit.comune.lugo.ra.it:81/cgi-bin/mapserv460?mode=itemfeaturequery


&map=/dati/sit/Lugo_PRG.map&slayer=Mappali&qstring=E730%20%20%2012%20%20
%2015&qitem=PARTKEY&qlayer=ZonaE2_15&mapext=shapes


As you can see, I use the same map, the same qstring and the same
layers: I only change Mapserver version (/cgi-bin/mapserv442 and
/cgi-bin/mapserv460).

How could you explain it, and how can I fix it?

	Daniele


-----Original Message-----
From: UMN MapServer Users List [mailto:MAPSERVER-USERS at LISTS.UMN.EDU] On
Behalf Of Daniele Margotti
Sent: Wednesday, June 22, 2005 8:29 AM
To: MAPSERVER-USERS at LISTS.UMN.EDU 
Subject: Re: [UMN_MAPSERVER-USERS] queryByFeatures: VERY URGENT!!!


Hi Steve,
I only need to extract data when my parcel (from parcel layer) intersect
one or more zone layers, without creating images.

Upgrading to 4.6.0 I noticed that the script returned many wrong results
(plus the right ones). Downgrading to 4.0.1 (or even 4.4.2, in another
non-production PC), the problem disappears.

The problem happens using PHP MapScript functions (both with PHP 4 and
5). If you could tell me the syntax for using feature query capabilities
via CGI (I think it should be FEATUREQUERY, defining a Slayer), I can
check if CGI Mapserver (4.0.1, 4.4.2 and 4.6.0) has the same behaviour
of corresponding Mapscript, and then provide you some query example
(pointing directly on my webserver).

Thank you,
  Daniele


-----Original Message-----
From: Steve Lime [mailto:steve.lime at dnr.state.mn.us] 
Sent: Tuesday, June 21, 2005 7:32 PM
To: margottid at COMUNE.LUGO.RA.IT; MAPSERVER-USERS at lists.umn.edu 
Subject: Re: [UMN_MAPSERVER-USERS] queryByFeatures: VERY URGENT!!!
Importance: High


** High Priority **

Certainly isn't supposed to work that way. How do you know this is
happening - sample images or something. There haven't been many (any)
changes in that code any time recently. I use the feature query
capabilities a lot (via CGI) and have had know troubles...

Steve

>>> Daniele Margotti <margottid at COMUNE.LUGO.RA.IT> 06/21/05 5:00 AM >>>
Hi all,
I noticed a very strange behaviour when I upgraded my system from
Mapserver 4.0.1 to Mapserver 4.6.0.

I have a map with one layer ("Parcels") containing parcels, and many
layers ("Zone-*") with zones, every layer with its own shapefile. I need
to query a parcel (every parcel has ONE AND ONE ONLY unique identifier),
and see which zones overlays that parcel (in other words, I want to
which zones that parcel belongs).

Parcels and zones have very irregular shape forms (i.e., a zone could
surround a parcel without intersecate it: in this case the parcel
DOESN'T BELONG to that zone). A parcel can belongs to one or more zone.

Now, my script.

<?
$Map=ms_newMapObj("/dati/sit/Lugo_PRG.map");
$Parcels=$Map->getLayerByName("Parcels");
for ($l=0; $l < count($map_layer); $l++) {
    $Layer=$Map->getLayerByName($map_layer[$l]);
    if (@$Parcels->queryByAttributes('PARTKEY',$qstring,MS_SINGLE) ==
MS_SUCCESS) {
        if (@$Layer->queryByFeatures($Parcels->index) == MS_SUCCESS) {
            $Risultati=$Layer->getNumResults();
            if($Risultati>0) {
                for ($i=0; $i < $Risultati; $i++) {
                    $QueryResult=$Layer->getResult($i);
                    $Risultato=$QueryResult->shapeindex;
                    $Layer->open();
                    $Shape=$Layer->getShape(0,$Risultato);
                    echo $Shape->values['Zone_name']."<br>";
                    $Layer->close();
                }
            }
        }
    }
}
?>

$map_layer is an array containing the names of the zone layers that I
want to query, $qstring is the unique identifier of the parcel I want to
query.

With Mapserver 4.0.1, the queryByFeatures takes the 'irregular' shape of
my Parcel and looks if it intersects the 'irregular' shape of every
Zone, returning only REAL intersections.

With Mapserver 4.6.0, it seems that queryByFeatures takes the Bounding
Box of the Parcel the looks for intersections with Bounding Boxes of
every Zone, returning positive results EVEN IF SHAPES DO NOT INTERSECT
(but the intersection only happens between bounding boxes)!

Is it normal?
Do I miss something in my script?
Is there a new different way to do what I want to do?
Or should I file a bug?

Thank you,
    Daniele



More information about the mapserver-users mailing list