Generate WMS GetFeatureInfo URL manually

2k views Asked by At

I am going to use wms getfeatureinfo to get information of a layer without any library. In fact, I am using Android and could not find anything to do that for me, so I have to get the information from a manually generated URL. I have seen WMS refrence and could find requiered parameters to request from geoserver. Here is the refrence.

I tried to build an example url for a feature that is located in position of 7547018.12374 -3645681.16486 in ESPG 3857 My layer name is Hazard:point_4326 and I set the bbox and height and width as bbox=-2.002637639E7,-2.00489661E7,2.002637639E7,2.00489661E7&width=767&height=768, but It gives me no features were found I think the problem is with setting bbox. Here is the url that I used

http://151.80.201.170/geoserver/Hazard/wms?request=GetFeatureInfo&service=WMS&version=1.1.1&layers=Hazard:point_4326&styles=&srs=EPSG%3A3875&format=image%2Fpng&bbox=-2.002637639E7,-2.00489661E7,2.002637639E7,2.00489661E7&width=767&height=768&query_layers=Hazard:point_4326&info_format=text%2Fplain&feature_count=50&x=0&y=0&exceptions=application%2Fvnd.ogc.se_xml

and this is working openlayer url

Can you please help me find out where I am doing wrong? Thank you so much.

1

There are 1 answers

1
halil On BEST ANSWER

The problem is as you said with the bounding box. You can not define your upper corner and your lower corner the same. Lower corner as it is said must be lower.

If you are looking for original layer data on only 1 point; you can use GetFeatureInfo of Geoserver WMS. However, you should be careful to define your inputs (Bounding box, width, height, x, y). Width and height and x y should be as small as possible. E.g. 1,1,0,0 in order. As for bounding box, you need the frequency of your original data, I mean difference between cells (in terms of lon, lat). If difference between your cells are 0.2 each, and the point you want to query is on Point(2.4,3.6); then you bounding box should look like this:

&bbox=2.3,3.5,2.5,3.7&width=1&height=1&x=0&y=0

If you are looking for all or some rectangular area of original data then you should have a look at my answer posted here.