[mapserver-users] PHP mapscript shapefile query with multiple filters

Steve Lime sdlime at gmail.com
Tue Jul 5 11:29:37 EDT 2011


What version? What happens if you close the layer between calls to queries?

Steve

Sent from my iPad

On Jul 4, 2011, at 11:15 AM, "Charlie Allgrove" <charlie.allgrove at connectionservices.com> wrote:

> Hi
> 
>  
> 
> I have a shapefile containing almost 250k points in 3 cols (lat/long/sitetype).
> 
> I need to use PHP mapscript to query that file to tell me how many points of a given type are present in a given rectangle.
> 
>  
> 
> The script will either tell me the number of points in rectangle, OR points of a given type, but never both...
> 
> Unfortunately I'm not at liberty to post the datafile anywhere, but the gist of the PHP is here:
> 
>  
> 
> <snip>
> 
> $lstrMapPath = "/path/to/shapefile";
> 
> $lstrOutput = "";
> 
>  
> 
> $lobjMap = ms_newMapObj($lstrMapPath);
> 
>  
> 
> $lobjLayer = $lobjMap->getLayerByName("layer1");
> 
> if(!$lobjLayer) {
> 
>                 exit; // errors handled elsewhere
> 
> }
> 
>  
> 
> $lobjLayer->open();
> 
> /* THIS WORKS */
> 
> @$lobjLayer->queryByRect($lobjRect);
> 
> $lintCount = $lobjLayer->getNumResults();
> 
>    
> 
> /* THIS ALSO WORKS - BUT NOT IF THE queryByRect() is enabled above */
> 
> /*
> 
> @$lobjLayer->queryByAttributes('sitetype','8',MS_MULTIPLE);
> 
> $lintCount = $lobjLayer->getNumResults();
> 
> */
> 
> $lstrOutput = "layer".$k.":".$lintCount;
> 
> $lobjLayer->close();
> 
>  
> 
> echo $lstrOutput;
> 
>  
> 
> </snip>
> 
>  
> 
> Any pointers would be gratefully received!
> 
>  
> 
> Cheers
> 
>  
> 
> Charlie
> 
>  
> 
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20110705/c7d47a54/attachment.html


More information about the mapserver-users mailing list