[Chameleon] QueryByShape

Normand Savard nsavard at mapgears.com
Tue Oct 16 13:46:36 EDT 2007

Mariette wrote:

>Would someone have an example on setting up QUeryByShape. I am attemting to
>use it but cannot get the result to popup in a window, the page simple
>reloads blank.

This is an example where a point is used to select a shape on park layer 
(chameleon map).  This shape is then used to do a queryByShape selection 
on drainage layer.


$map = ms_newMapObj("/ms4w/apps/chameleon/samples/map/chameleon.map");

$srclayer = $map->getLayerByName('park');
$targetlayer = $map->getLayerByName('drainage');

$georef_x =-978456;
$georef_y = 1280409;
$my_point = ms_newpointObj();

//This point is used for the shape selection that will be used to select 
other shapes
if ($srclayer->queryByPoint ($my_point,MS_SINGLE,-8) == MS_SUCCESS) {
        echo("Request queryByPoint, coords : (".$georef_x.", 
        $result = $srclayer->getResult(0);
        $indexShape = $result->shapeindex;

        $shape = $srclayer->getShape(-1, $indexShape);
        echo("Park selected : ".$shape->values["NAME_E"]."</br></br>\n");
        //Park selected shape is used to select drainage shapes
        if ($targetlayer->queryByShape($shape) == MS_SUCCESS) {
                echo("Requeste queryByShape using the selected shape 
                printf("Results : ".$targetlayer->getNumResults()." 
                for ($j=0; $j<$targetlayer->getNumResults(); $j++) {
                        $result = $targetlayer->getResult($j);
                        $indexShape = $result->shapeindex;
                        $shape = $targetlayer->getShape(-1, $indexShape);
                        $nom = $shape->values["NAME"];
                        echo($j.", shapeindex : ".$indexShape.", Name : 
       } else {
                echo("Error last request.</br>\n");
} else {
        print "Error first request.</br>\n";

More information about the Chameleon mailing list