androidwmsgetfeatureinfoepsg

Android compute right bbox for WMS getFeatureInfo


I'm trying to make a request to my Geoserver to retrieve the features near the tap of a user on the map.

Image

The map takes all the space. Therefore I computed the BBOX in this way:

region = mMap.getProjection().getVisibleRegion().latLngBounds;
double left = region.southwest.longitude;
double top = region.northeast.latitude;
double right = region.northeast.longitude;
double bottom = region.southwest.latitude;

and the width and height are taken as belows:

mMapFragment.getView().getWidth();
mMapFragment.getView().getHeight();

while the X and Y parameter are calculated in the following way:

Point click = mMap.getProjection().toScreenLocation(latLng);

where latLng is the point that came from the event onMapClick(LatLng) (reference here: https://developers.google.com/android/reference/com/google/android/gms/maps/GoogleMap.OnMapClickListener).

The resulting URL that I obtain is:

http://localhost/geoserver/sindot/wms?service=WMS&request=GetFeatureInfo&info_format=application%2Fjson&version=1.1.1&srs=EPSG%3A3857&bbox=1222173.74033,5056403.44084,1222174.11356,5056403.7028&query_layers=sindot:verticale&layers=sindot:verticale&feature_count=3&styles=tabletb3lab&width=2048&height=1262&x=1441&y=503

The problem is that the server returns always an empty response even if I know that there are features there because I can see the spots on the map. What could it be?

Thanks in advance.


Solution

  • It onlytook to add &buffer=10 (or another number according to your needs) to the request.