<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.0.6487.1">
<TITLE>querybyshape after a querybypoint</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<P><FONT SIZE=2 FACE="Arial">Hi everybody,</FONT>
</P>
<BR>
<P><FONT SIZE=2 FACE="Arial">My idea is to do a selection with a shape after select him with querybypoint.</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">So i can query the above layers with this shape and not only with the coordonate of the point.</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">Here is a part of my code of the file ServerMapquery.php, but there is certainly an error in it.</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">Is there somebody that could take a look on it ans help me?</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">Thanks ....</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">......</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial"> public function queryByBbox($layerId, Bbox $bbox) {</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial"> $msMapObj = $this->serverContext->getMapObj();</FONT>
<BR><FONT SIZE=2 FACE="Arial"> $layersInit = $this->serverContext->getMapInfo()->layersInit;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> $msLayer = $layersInit->getMsLayerById($msMapObj, $layerId);</FONT>
<BR><FONT SIZE=2 FACE="Arial"> </FONT>
<BR><FONT SIZE=2 FACE="Arial"> // layer has to be activated for query</FONT>
<BR><FONT SIZE=2 FACE="Arial"> $msLayer->set('status', MS_ON);</FONT>
<BR><FONT SIZE=2 FACE="Arial"> </FONT>
<BR><FONT SIZE=2 FACE="Arial"> if ($bbox->minx == $bbox->maxx && $bbox->miny == $bbox->maxy) {</FONT>
<BR><FONT SIZE=2 FACE="Arial"> $point = ms_newPointObj();</FONT>
<BR><FONT SIZE=2 FACE="Arial"> $point->setXY($bbox->minx, $bbox->miny);</FONT>
<BR><FONT SIZE=2 FACE="Arial"> </FONT>
<BR><FONT SIZE=2 FACE="Arial"> // no tolerance set by default, must be set in mapfile</FONT>
<BR><FONT SIZE=2 FACE="Arial"> $ret = @$msLayer->queryByPoint($point, MS_MULTIPLE, 0);</FONT>
<BR> <FONT SIZE=2 FACE="Arial">$this->log->debug("Query on layer $layerId: " .</FONT>
<BR><FONT SIZE=2 FACE="Arial"> "queryByPoint($point, MS_MULTIPLE, -1)");</FONT>
<BR>
<BR> <FONT SIZE=2 FACE="Arial">$this->serverContext->resetMsErrors();</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial"> if ($ret != MS_SUCCESS || </FONT>
<BR><FONT SIZE=2 FACE="Arial"> $msLayer->getNumResults() == 0) </FONT>
<BR><FONT SIZE=2 FACE="Arial"> return array();</FONT>
<BR>
<BR> <FONT SIZE=2 FACE="Arial">return $this->extractResults($layerId, true);</FONT>
<BR> <FONT SIZE=2 FACE="Arial"> </FONT>
<BR><FONT SIZE=2 FACE="Arial"> $ret = $msLayer->getResult(0); //récupération du premier objet sélectionné</FONT>
<BR> <FONT SIZE=2 FACE="Arial">$indexShapeSel = $ret->getShapeindex(); //si le layer est composé de shapes, on récupère l'index de l'objet sélectionné</FONT></P>
<P><FONT SIZE=2 FACE="Arial"> $shape = @$mslayer->getShape($IndexShapeSel); //on récupère l'objet shape lui même dans le layer</FONT>
<BR><FONT SIZE=2 FACE="Arial"> </FONT>
</P>
<P> <FONT SIZE=2 FACE="Arial">$ret = @$msLayer->queryByShape($shape);</FONT>
<BR><FONT SIZE=2 FACE="Arial"> </FONT>
<BR><FONT SIZE=2 FACE="Arial"> } else {</FONT>
<BR><FONT SIZE=2 FACE="Arial"> $rect = ms_newRectObj();</FONT>
<BR><FONT SIZE=2 FACE="Arial"> $rect->setextent($bbox->minx, $bbox->miny, $bbox->maxx, $bbox->maxy);</FONT>
<BR><FONT SIZE=2 FACE="Arial"> </FONT>
<BR><FONT SIZE=2 FACE="Arial"> $ret = @$msLayer->queryByRect($rect);</FONT>
<BR><FONT SIZE=2 FACE="Arial"> </FONT>
<BR><FONT SIZE=2 FACE="Arial"> $this->log->debug("Query on layer $layerId: queryByRect($rect)"); </FONT>
<BR><FONT SIZE=2 FACE="Arial"> </FONT>
<BR><FONT SIZE=2 FACE="Arial"> }</FONT>
<BR><FONT SIZE=2 FACE="Arial"> </FONT>
<BR><FONT SIZE=2 FACE="Arial"> $this->serverContext->resetMsErrors();</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial"> if ($ret != MS_SUCCESS || </FONT>
<BR><FONT SIZE=2 FACE="Arial"> $msLayer->getNumResults() == 0) </FONT>
<BR><FONT SIZE=2 FACE="Arial"> return array();</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial"> return $this->extractResults($layerId, true);</FONT>
<BR><FONT SIZE=2 FACE="Arial"> }</FONT>
<BR><FONT SIZE=2 FACE="Arial">}</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">?></FONT>
</P>
</BODY>
</HTML>