queryByFeatures: VERY URGENT!!!

Daniele Margotti margottid at COMUNE.LUGO.RA.IT
Tue Jun 21 06:00:08 EDT 2005


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