queryByFeatures: VERY URGENT!!!

Daniele Margotti margottid at COMUNE.LUGO.RA.IT
Wed Jun 22 02:28:51 EDT 2005


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