MapScript Spatial Query Help

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

MapScript Spatial Query Help

Pearson, Gregory

I’m stuck and I don’t know where to go from here. I need to search a layer by latitude/longitude, but I don’t see this available in the API. How is this done? What I want to do is take an address, geocode it to produce the lat/long coordinate, and use it to query my shape file. I feel I may be missing a step.

 

Greg

Reply | Threaded
Open this post in threaded view
|

Re: MapScript Spatial Query Help

Fawcett, David (MNIT)
Message
I assume that you are looking for the layerObj method queryByPoint().  I don't have an example for you though.
 
David.
 
 
 
queryByPoint( mapObj map, pointObj point, int mode, float buffer ) : int
 
Query layer at point location specified in georeferenced map coordinates (i.e. not pixels). The query is performed on all the shapes that are part of a CLASS that contains a TEMPLATE value or that match any class in a layer that contains a LAYER TEMPLATE value. Mode is MS_SINGLE or MS_MULTIPLE depending on number of results you want. Passing buffer <=0 defaults to tolerances set in the map file (in pixels) but you can use a constant buffer (specified in ground units) instead. Returns MS_SUCCESS if shapes were found or MS_FAILURE if nothing was found or if some other error happened.
 
 
 
 
 
-----Original Message-----
From: UMN MapServer Users List [mailto:[hidden email]] On Behalf Of Pearson, Gregory
Sent: Friday, February 22, 2008 1:07 PM
To: [hidden email]
Subject: [UMN_MAPSERVER-USERS] MapScript Spatial Query Help

I’m stuck and I don’t know where to go from here. I need to search a layer by latitude/longitude, but I don’t see this available in the API. How is this done? What I want to do is take an address, geocode it to produce the lat/long coordinate, and use it to query my shape file. I feel I may be missing a step.

 

Greg

Reply | Threaded
Open this post in threaded view
|

Re: MapScript Spatial Query Help

Pearson, Gregory
Message

David, I am using that object and method and it works fine if I supply coordinates provided by MapServer based on a click point. To test, I setup a demo with my map. When I click on the image, the query results are produced and I am given the image and map coordinates. When I plug the map coordinates into another test application – built with MapScript using the layerObj – I get the same results.

 

But when I supply geocoded lat/long values (from geocoder.us) for a feature I know exists in my map, I don’t get any results. That tells me there is a difference between the coordinate systems. Or, there is something that I haven’t considered.

 


From: UMN MapServer Users List [mailto:[hidden email]] On Behalf Of Fawcett, David
Sent: Friday, February 22, 2008 2:16 PM
To: [hidden email]
Subject: Re: [UMN_MAPSERVER-USERS] MapScript Spatial Query Help

 

I assume that you are looking for the layerObj method queryByPoint().  I don't have an example for you though.

 

David.

 

 

 

queryByPoint( mapObj map, pointObj point, int mode, float buffer ) : int

 

Query layer at point location specified in georeferenced map coordinates (i.e. not pixels). The query is performed on all the shapes that are part of a CLASS that contains a TEMPLATE value or that match any class in a layer that contains a LAYER TEMPLATE value. Mode is MS_SINGLE or MS_MULTIPLE depending on number of results you want. Passing buffer <=0 defaults to tolerances set in the map file (in pixels) but you can use a constant buffer (specified in ground units) instead. Returns MS_SUCCESS if shapes were found or MS_FAILURE if nothing was found or if some other error happened.

 

 

 

 

 

-----Original Message-----
From: UMN MapServer Users List [mailto:[hidden email]] On Behalf Of Pearson, Gregory
Sent: Friday, February 22, 2008 1:07 PM
To: [hidden email]
Subject: [UMN_MAPSERVER-USERS] MapScript Spatial Query Help

I’m stuck and I don’t know where to go from here. I need to search a layer by latitude/longitude, but I don’t see this available in the API. How is this done? What I want to do is take an address, geocode it to produce the lat/long coordinate, and use it to query my shape file. I feel I may be missing a step.

 

Greg