[Geoserver-users] WFS : Extract only attributes without geometry

Hello,

In fact, thanks to a URL containing point coordinates (Lon/Lat) we would like to extract attributes from a vector layer.

We have tested the WMS GetFeatureInfo. But in this case the URL has to be described thanks to images coordinates (in pixels) and we need to send through the URL the coordinates Longitude/Latitude.
And about the WFS GetFeatureIntersects, we obtained the geometry of the intersected feature (list of coordinates) and these information, unnecessary for us, risk to delay the response time.
So, is it possible, maybe to filter the response given by the WFS GetFeatureIntersects in order to recover the attributes only ?
We are also open for all other solutions.

Thanks a lot in advance for your answers.

Xavier

···

Hi,

Use propertyname list. Geometry is not compulsory attribute (if you do not make it compulsory in the featuretype schema). Try these examples with BBOX filter and propertyname list
This one gives geometries

http://188.64.1.61/cgi-bin/tinyows?service=wfs&version=1.0.0&request=GetFeature&typename=lv:mml_railway&BBOX=246700,6780800,436400,6924000&propertyname=the_geom,sahko&maxfeatures=10<http://188.64.1.61/cgi-bin/tinyows?service=wfs&version=1.0.0&request=GetFeature&typename=lv:mml_railway&BBOX=246700,6780800,436400,6924000&propertyname=sahko&maxfeatures=10>

This one comes without geometries
http://188.64.1.61/cgi-bin/tinyows?service=wfs&version=1.0.0&request=GetFeature&typename=lv:mml_railway&BBOX=246700,6780800,436400,6924000&propertyname=sahko&maxfeatures=10

WSF does offer fine features, it is not just GetFeature for the whole layer. Unfortunately they are very seldomly utilised, perhaps because it is hard to get happy feelings from successful trials by using http POST and painful XML filters following the OGC Filter Encoding standard. Fortunately Geoserver offers nice alternative with CQL filters.

-Jukka Rahkonen

________________________________

________________________________
Lähettäjä: Xavier Chaze [Xavier.Chaze@anonymised.com]
Lähetetty: 8. marraskuuta 2011 18:23
Vastaanottaja: geoserver-users@lists.sourceforge.net
Aihe: [Geoserver-users] WFS : Extract only attributes without geometry

Hello,

In fact, thanks to a URL containing point coordinates (Lon/Lat) we would like to extract attributes from a vector layer.

We have tested the WMS GetFeatureInfo. But in this case the URL has to be described thanks to images coordinates (in pixels) and we need to send through the URL the coordinates Longitude/Latitude.
And about the WFS GetFeatureIntersects, we obtained the geometry of the intersected feature (list of coordinates) and these information, unnecessary for us, risk to delay the response time.
So, is it possible, maybe to filter the response given by the WFS GetFeatureIntersects in order to recover the attributes only ?
We are also open for all other solutions.

Thanks a lot in advance for your answers.

Xavier

Hi,

This is a rather long message but I hope it entertains some people even I am not sure if it can be used for anything useful. However, this is a trick originally discovered by a new Mapserver user who did not bother to read too much documents or standards.
The steps in the trick are these:
- Make both WIDTH and HEIGHTH in the GetFeatureInfo request into 1
- Use always X=1 and Y=1
So far everything is totally controlled and GetFeatureInfo is made with the only pixel we have. After this I am not so sure about who has the control.

- Make a very little BBOX
In the following example the BBOX corners are
-105.022856,42.47970388 and
-105.022855,42.47970389

Only the last digit of both coordinates is increased by one. Mapserver has a nice bug here which makes the use of the trick pretty simple because it accepts same coordinates for both corners of a BBOX. This makes affectively BBOX into a point!. Geoserver does not accept this but gives an error
      Internal error occurred
Points of LinearRing do not form a closed linestring
</ServiceException></ServiceExceptionReport>

This error comes also if the corners are very little different, for example with this BBOX
BBOX=-105.02285686876569,42.47970388741691,-105.02285686876568,42.47970388741692&
That's probably due to internal accuracy in calculations.

So finally here is a full GetFeatureInfo request that should work against all Geoserver standard installations and find Wyoming

http://localhost:8080/geoserver/wms?
REQUEST=GetFeatureInfo&
SERVICE=WMS&
VERSION=1.1.1&
WIDTH=1&
HEIGHT=1&
LAYERS=topp:states&
QUERY_LAYERS=topp:states&
x=1&
y=1&
TRANSPARENT=TRUE&
FORMAT=image/png&
BBOX=-105.022856,42.47970388741691,-105.02285,42.47970388741692&
SRS=EPSG:4326&
STYLES=

I do not know what point Geoserver is quering when the BBOX is big. This request find Illinois even it is not even close to the BBOX

http://localhost:8080/geoserver/wms?
REQUEST=GetFeatureInfo&
SERVICE=WMS&
VERSION=1.1.1&
WIDTH=1&
HEIGHT=1&
LAYERS=topp%3Astates&
QUERY_LAYERS=topp%3Astates&
x=1&
y=1&
TRANSPARENT=TRUE&
FORMAT=image%2Fpng&
BBOX=-110.09376959353222,38.07638932483682,-105.05437741859839,41.95200030033059&
SRS=EPSG:4326&
STYLES=

I have a slight feeling that this relaxed GetFeatureInfo request could be useful for some purposes. For example a mobile client could capture GPS coordinates from the internal GPS receiver and insert that value into a prepared GetFeatureInfo request template and get back an answer to a question "What is here". WFS does that better but text/plain or text/html answer might suit better for the mobile client for showing the result. I have a strong feeling that it would not work in a reliable way with all the WMS server brands.

Regards,

-Jukka Rahkonen-

________________________________
Lähettäjä: Xavier Chaze [Xavier.Chaze@anonymised.com]
Lähetetty: 8. marraskuuta 2011 18:23
Vastaanottaja: geoserver-users@lists.sourceforge.net
Aihe: [Geoserver-users] WFS : Extract only attributes without geometry

Hello,

In fact, thanks to a URL containing point coordinates (Lon/Lat) we would like to extract attributes from a vector layer.

We have tested the WMS GetFeatureInfo. But in this case the URL has to be described thanks to images coordinates (in pixels) and we need to send through the URL the coordinates Longitude/Latitude.
And about the WFS GetFeatureIntersects, we obtained the geometry of the intersected feature (list of coordinates) and these information, unnecessary for us, risk to delay the response time.
So, is it possible, maybe to filter the response given by the WFS GetFeatureIntersects in order to recover the attributes only ?
We are also open for all other solutions.

Thanks a lot in advance for your answers.

Xavier

On Tue, Nov 8, 2011 at 10:06 PM, Rahkonen Jukka <Jukka.Rahkonen@anonymised.com> wrote:

Hi,

This is a rather long message but I hope it entertains some people even I am not sure if it can be used for anything useful. However, this is a trick originally discovered by a new Mapserver user who did not bother to read too much documents or standards.
The steps in the trick are these:

  • Make both WIDTH and HEIGHTH in the GetFeatureInfo request into 1

  • Use always X=1 and Y=1
    So far everything is totally controlled and GetFeatureInfo is made with the only pixel we have. After this I am not so sure about who has the control.

  • Make a very little BBOX
    In the following example the BBOX corners are
    -105.022856,42.47970388 and
    -105.022855,42.47970389

Only the last digit of both coordinates is increased by one. Mapserver has a nice bug here which makes the use of the trick pretty simple because it accepts same coordinates for both corners of a BBOX. This makes affectively BBOX into a point!. Geoserver does not accept this but gives an error
Internal error occurred
Points of LinearRing do not form a closed linestring

This error comes also if the corners are very little different, for example with this BBOX
BBOX=-105.02285686876569,42.47970388741691,-105.02285686876568,42.47970388741692&
That’s probably due to internal accuracy in calculations.

It’s due to IEEE floating point representation of doubles:
http://en.wikipedia.org/wiki/Double_precision_floating-point_format

When parsing -105.02285686876568 in java you actually get -105.02285686876569.
If you look at the above page it says the number of significant digits in double precision
floating points representation is only 16, the above number has 18 instead.
When you go beyond 16 you face implementation dependent behavior.

So finally here is a full GetFeatureInfo request that should work against all Geoserver standard installations and find Wyoming

http://localhost:8080/geoserver/wms?
REQUEST=GetFeatureInfo&
SERVICE=WMS&
VERSION=1.1.1&
WIDTH=1&
HEIGHT=1&
LAYERS=topp:states&
QUERY_LAYERS=topp:states&
x=1&
y=1&
TRANSPARENT=TRUE&
FORMAT=image/png&
BBOX=-105.022856,42.47970388741691,-105.02285,42.47970388741692&
SRS=EPSG:4326&
STYLES=

I do not know what point Geoserver is quering when the BBOX is big. This request find Illinois even it is not even close to the BBOX

http://localhost:8080/geoserver/wms?
REQUEST=GetFeatureInfo&
SERVICE=WMS&
VERSION=1.1.1&
WIDTH=1&
HEIGHT=1&
LAYERS=topp%3Astates&
QUERY_LAYERS=topp%3Astates&
x=1&
y=1&
TRANSPARENT=TRUE&
FORMAT=image%2Fpng&
BBOX=-110.09376959353222,38.07638932483682,-105.05437741859839,41.95200030033059&
SRS=EPSG:4326&
STYLES=

GetFeatureInfo is not about query a point, it’s about query a pixel in the map.
So GeoServer always query at the very least the entire pixel you indicated.
However by default you get an expansion of that that includes the size of the lines in the SLD,
size of the points and so on, since you should get back what you saw you clicked (of course
expanding based on the sld is still suboptimal, but makes it easier to get a positive result
when you click those 10px round point markers on a map :wink:
To accomodate for the less than accurate positioning of a normal human being the automatically
determined buffer is never less than 3 pixels, so with the above map you actually query
a range of 15 degrees (since the bbox is 5 degrees large)

If you try the following, forcing the buffer to 1, it should work (setting it to 0 won’t work, that will make
GeoServer compute the buffer automatically).

http://localhost:8080/geoserver/wms?REQUEST=GetFeatureInfo&SERVICE=WMS&VERSION=1.1.1&WIDTH=1&HEIGHT=1&LAYERS=topp%3Astates&QUERY_LAYERS=topp%3Astates&x=1&y=1&TRANSPARENT=TRUE&FORMAT=image%2Fpng&BBOX=-110.09376959353222,38.07638932483682,-105.05437741859839,41.95200030033059&SRS=EPSG:4326&STYLES=&buffer=1

Returns Colorado, which is at least in the area you identified with the bbox.

I have a slight feeling that this relaxed GetFeatureInfo request could be useful for some purposes. For example a mobile client could capture GPS coordinates from the internal GPS receiver and insert that value into a prepared GetFeatureInfo request template and get back an answer to a question “What is here”. WFS does that better but text/plain or text/html answer might suit better for the mobile client for showing the result. I have a strong feeling that it would not work in a reliable way with all the WMS server brands.

A better way that might work across WMS impleementations is probably to consider a large map and put the point you want to query in its top left corner instead,
e.g., keep on using x=1 and y= 1 but use width and height a few hundred pixels large.

Cheers
Andrea

Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 962313

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf