0

My issue is that normally, when you want to query a WMS layer, you need to pass width & height of a map, and x,y (in pixels) which describe a point on the map where user clicked.

I want to do this in other way - I want to query this WMS layer with longitude and latitude known before. I assume, that by using some ArcObjects libraries I will be able to convert latitude,longitude and projection to width,height,x,y so that I can use GetFeatureInfo. Can someone please explain how to achieve this?

I'm using ArcObjects SDK 10.1 for .NET.

5

It is simple but you must fool a bit. Feed in your lat/lon or lon/lat depending on your WMS version. Use the point as lower-left corner of BBOX and add some little number for getting the upper-right corner. Ask always for WIDTH=2 and HEIGHT=2 and pixel coordinates 1 and 1. All you need to edit ever is the BBOX. Here comes the request as exploded. I added only 0.01 degrees to BBOX for readability, it should be less to be more accurate. Perhaps 0.0001 or 0.00001 for about 10 or 1 meter resolution, respectively.

http://demo.opengeo.org/geoserver/wms?
bbox=-100.00,35.00,-99.99,35.01&
styles=&
format=jpeg&
request=GetFeatureInfo&
layers=topp:states&
query_layers=topp:states&
width=2&
height=2&
x=1&
y=1

Here is a live link to play with.

http://demo.opengeo.org/geoserver/wms?bbox=-100.00,35.00,-99.99,35.01&styles=&format=jpeg&request=GetFeatureInfo&layers=topp:states&query_layers=topp:states&width=2&height=2&x=1&y=1

  • for my wms server (mapproxy+qgis server), I had to add: version=1.1.1&srs=epsg:4326 – anneb Mar 15 '18 at 22:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.