[mapserver-users] QuerybyPoint blues

Antti.Roppola at brs.gov.au Antti.Roppola at brs.gov.au
Tue Oct 1 20:28:14 EDT 2002


Hi Tom,

I have got queries on polygons and lines working OK (but not points).
Here are the relevant chunks of code.

	LAYER
	  NAME "Roads"
	  TYPE LINE
	  STATUS OFF
	  DATA roads
	  CLASS
	    NAME "Roads"
	    COLOR 255 0 0 
	    TEMPLATE "dummy" # doesn't exist
	  END
	  METADATA
	    "DESCRIPTION" "DCW roads"
	    ## The following are not the same as GMap
	    "QUERY_FIELDS_ITEM" "FORMATION"
	    "QUERY_FIELDS_DESC" "Road Formation Code"
	  END
	END

<HTML>
<?php
	if($click_x && $mode=="query") {	## Did someone make a query?
			## Convert image click location into map coordinates
		list($ClickMapX,$ClickMapY)=click2map($click_x,$click_y,$extent,$map)
		$pointQuery=ms_newPointObj();
		$pointQuery->setXY($ClickMapX,$ClickMapY);
		@map->queryByPoint($pointQuery, MS_MULTIPLE, -1);
		$img = $map->drawQuery();
		QueryResults($pointQuery, $map);	## This function is a hack from the same in Gmap
	}
?>
</HTML>

The QueryResults function is as from GMap (I have not gotten around to
writing my own and it works well enough), though I did add some debug
stuff so I could see what it was doing. In the function, find the line;
	"$numResults = $oLayer->getNumResults();
and insert the following line after it:

	if ($debug) { printf("Debug: Layer: %s Results: %s<BR>\n", $iLayer, $numResults); }

If you set $debug at the start of the function, this will show you if the
query is actually finding anything for each layer.

Cheers,

Antti




More information about the mapserver-users mailing list