Android compute right bbox for WMS getFeatureInfo
Asked Answered
O

1

8

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.

Opia answered 2/7, 2015 at 9:49 Comment(1)
Thanks for Question and i also finding solution till now i can't get any solution ..How to calculate BBOX from region = mMap.getProjection().getVisibleRegion().latLngBounds ? BBOX should be in minx,miny,maxx,maxy.. I also Posted Question stackoverflow.com/questions/32391037/… Thanks In advance.Trencher
O
1

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

Opia answered 3/7, 2015 at 10:51 Comment(1)
Thanks for Question and i also finding solution till now i can't get any solution ..How to calculate BBOX from region = mMap.getProjection().getVisibleRegion().latLngBounds ? BBOX should be in minx,miny,maxx,maxy.. I also Posted Question #32391537 Thanks In advance..Trencher

© 2022 - 2024 — McMap. All rights reserved.