0

I'm creating a Mapbox GL JS web map which pulls GeoJSON layers from GeoServer. I've used the documentation to find my problem lies in the 'GetFeatureInfo' get request URL which follows the following format (though in one line of course):

http://localhost:8080/geoserver/wms?
INFO_FORMAT=application/json&
REQUEST=GetFeatureInfo&
EXCEPTIONS=application/vnd.ogc.se_xml&
SERVICE=WMS&
VERSION=1.1.1&
WIDTH=970&
HEIGHT=485&
X=486&
Y=165&
BBOX=-180,-90,180,90&
LAYERS=CampusMap:dwt-campus-json&
QUERY_LAYERS=CampusMap:dwt-campus-json&
TYPENAME=CampusMap:dwt-campus-json&

My problem is that this link does not work, and when I run it in a browser I receive various WMS error files that are not very helpful. I really just want to be able to get this link to work so I can have this building footprints file load on my basemap and be query-able for future use.

  • please include the contents of one of the error files as they will be helpful to us. – Ian Turton Nov 26 '18 at 16:40
  • Note KVP syntax for WMS is key[=value]& (the ampersand is at the end, not beginning) – nmtoken Nov 26 '18 at 16:40
  • Request is ok, it is just split on several rows for better readability. There does not need to be & after the last key so I would say that & is in between. Bbox covers the whole world which may not be intentional. Typename is not a WMS parameter but probably it is just skipped. I would check the bbox firs. Does GetFeatureInfo work with QGIS? – user30184 Nov 26 '18 at 16:47
  • Ok, I can see that you have taken the example from docs.geoserver.org/stable/en/user/services/wms/reference.html and it is really missing the SRS parameter. That's a bug in documentation. – user30184 Nov 26 '18 at 17:14
  • feel free to fix the docs then – Ian Turton Nov 26 '18 at 17:27
1

You are probably confusing the WMS GetFeatureInfo operation and a WFS GetFeature operation.

Your error is that the request is missing an SRS parameter, (e.g. SRS=epsg:4326&). You also have a typename parameter (which is not a GetFeatureInfo parameter), this isn't causing the problem, but it adds no meaning to the request and will be ignored.

1

The most obvious issue is that you do not have a valid WMS GetFeatureInfo request as there are no SRS or STYLES there, so GeoServer will always throw an error.

However, I suspect you actually want a whole map as JSON in which case you would need a WMS getMap request, something like:

http://localhost:8080/geoserver/wms?
FORMAT=application/json&
REQUEST=GetMap&
EXCEPTIONS=application/vnd.ogc.se_xml&
SERVICE=WMS&
VERSION=1.1.1&
WIDTH=970&HEIGHT=485&X=486&Y=165&BBOX=-180,-90,180,90&
LAYERS=CampusMap:dwt-campus-json&STYLES=

But that will fail because GeoServer doesn't provide GeoJSON as an output format (check the capabilities), so you need to use a service that will send you vector features such as a WFS - try something like:

http://localhost:8080/geoserver/topp/ows?
service=WFS&version=1.0.0
&request=GetFeature
&typeName=topp%3Astates1
&maxFeatures=50
&outputFormat=application%2Fjson

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.