[GIS] WMS GetFeatureInfo not returning all coordinates of geometry

geoservergetfeatureinfowms

I have some geoserver layers created from PostGIS tables. I load them on map using OpenLayers and use WMS GetFeatureInfo to get features on mouse click.

I have observed that GetFeatureInfo request optimizes the returned Geometries by merging vertices which are very close. However, for editing, I need to get all the vertices.

Is there a way to tell WMS GetFeatureInfo to retrieve all vertices?

Here is a sample request I am sending:

http://localhost:8080/geoserver/MyWorkSpace/wms
  ?LAYERS=MyLayer
  &QUERY_LAYERS=MyLayer
  &STYLES=MyLayer_Style
  &SERVICE=WMS
  &VERSION=1.1.1
  &REQUEST=GetFeatureInfo
  &BBOX=10064619.024143,2730298.878509,10064682.024975,2730340.381427
  &FEATURE_COUNT=10
  &HEIGHT=556&WIDTH=844
  &INFO_FORMAT=application/vnd.ogc.gml
  &SRS=EPSG:900913
  &X=302
  &Y=265

As commented by user30184, I could use WFS. But it appears that WFS does not take pixel coordinates as input. So I will have to translate the pixel to coordinates, which can be done.
However, in that case how can I consider style of the layer. For example, for a point layer with large radius, user might not be able to select the points even if clicking inside the point. Am I missing something?

Best Answer

Is there a way to tell WMS GetFeatureInfo to retrieve all vertices?

No

As @user30184 mentions in their comment:

GetFeatureInfo is not planned for returning geometries in their original accuracy but mainly to answer to question "What is here on a map".

A WMS is by design a way of presenting a representation of a set of data as a map (often you get different representations of the same data as you zoom in or out). A GetFeatureInfo request acts on the map representations, that what the X,Y (or I,J) coordinates are in the request.

I could use WFS... However, in that case how can I consider style of the layer.

A WFS gives you all the raw (vector) data, and once you have this you can style it any way you like.

A WFS does take an optional bounding box parameter so as you say:

... I will have to translate the pixel to coordinates, which can be done.

As @user30184 also mentions and which you considered, you could obtain the the Feature identifier (FID) from the WMS GetFeatureInfo request then do a WFS GetFeature request specifying the featureID parameter, or if your service supports it, by using a GetFeatureById stored procedure.

You can check which stored query you have with a request like:

http://localhost:8080/geoserver/MyWorkSpace/wms?SERVICE=WFS&request=ListStoredQueries&version=2.0.0&

Which would give a response like:

<wfs:ListStoredQueriesResponse 
 xsi:schemaLocation="http://www.opengis.net/wfs/2.0 .../schemas/wfs/2.0/wfs.xsd">
  <wfs:StoredQuery 
    id="urn:ogc:def:query:OGC-WFS::GetFeatureById">
    <wfs:Title xml:lang="en">Get feature by identifier</wfs:Title>
    <wfs:ReturnFeatureType/>
  </wfs:StoredQuery>
</wfs:ListStoredQueriesResponse>

Another option would be to create your own Stored Query

Related Question