[Cartoweb-users] querybyshape after a querybypoint

Caussin David David.Caussin at brucity.be
Thu Aug 25 02:46:05 EDT 2005


Hi everybody,


My idea is to do a selection with a shape after select him with querybypoint.

So i can query the above layers with this shape and not only with the coordonate of the point.

Here is a part of my code of the file ServerMapquery.php, but there is certainly an error in it.

Is there somebody that could take a look on it ans help me?

Thanks ....

......

 public function queryByBbox($layerId, Bbox $bbox) {

        $msMapObj = $this->serverContext->getMapObj();
        $layersInit = $this->serverContext->getMapInfo()->layersInit;
        $msLayer = $layersInit->getMsLayerById($msMapObj, $layerId);
        
        // layer has to be activated for query
        $msLayer->set('status', MS_ON);
        
        if ($bbox->minx == $bbox->maxx && $bbox->miny == $bbox->maxy) {
            $point = ms_newPointObj();
            $point->setXY($bbox->minx, $bbox->miny);
            
            // no tolerance set by default, must be set in mapfile
            $ret = @$msLayer->queryByPoint($point, MS_MULTIPLE, 0);
	$this->log->debug("Query on layer $layerId: " .
                    "queryByPoint($point, MS_MULTIPLE, -1)");
			
	$this->serverContext->resetMsErrors();

        if ($ret != MS_SUCCESS || 
            $msLayer->getNumResults() == 0) 
            return array();
			
			return $this->extractResults($layerId, true);
			 
            $ret = $msLayer->getResult(0); //récupération du premier objet sélectionné
	$indexShapeSel = $ret->getShapeindex(); //si le layer est composé de shapes, on récupère l'index de l'objet sélectionné
            $shape = @$mslayer->getShape($IndexShapeSel); //on récupère l'objet shape lui même dans le layer
            

	$ret = @$msLayer->queryByShape($shape);
            
        } else {
            $rect = ms_newRectObj();
            $rect->setextent($bbox->minx, $bbox->miny, $bbox->maxx, $bbox->maxy);
        
            $ret = @$msLayer->queryByRect($rect);
        
            $this->log->debug("Query on layer $layerId: queryByRect($rect)");        
            
        }
        
        $this->serverContext->resetMsErrors();

        if ($ret != MS_SUCCESS || 
            $msLayer->getNumResults() == 0) 
            return array();

        return $this->extractResults($layerId, true);
    }
}

?>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/cartoweb-users/attachments/20050825/653a226a/attachment.html


More information about the Cartoweb-users mailing list