On Tue, Nov 8, 2011 at 10:06 PM, Rahkonen Jukka
<[email protected]>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
> </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.
>

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 ;-)
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

-------------------------------------------------------
------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to