[Geoserver-users] GetFeatureInfo search radius

Hello,

We have this Openlayers 4 based application that can use WMS layers. It uses
such via a 2.11.2 Geoserver. It has a search function that creates a
getFeatureInfocall for search hits. The call is created like so:
  var mapView = Viewer.getMap().getView();

  var url = spec.layer.getSource().getGetFeatureInfoUrl(
    spec.feature.getGeometry().getFirstCoordinate(),
    mapView.getResolution(),
    mapView.getProjection(),
    {
      'INFO_FORMAT': 'text/html',
      'feature_count': 1
    }
);

The thing is that it quite often wants to return several features (of the
always one layer being queried) which means it quite often does not return
the right one. The features of the layer do not overlap so it seems
improbably that the getFeatureInfocall would somehow target an exact
intersection between three features (which would likely not return three
features anyway).

Like this call
https://karta.eskilstuna.se/geoserver/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetFeatureInfo&FORMAT=image/png&TRANSPARENT=true&QUERY_LAYERS=sokvyx_fk_ay_esktn&LAYERS=sokvyx_fk_ay_esktn&TILED=true&INFO_FORMAT=text/html&feature_count=12&X=346&Y=237&WIDTH=512&HEIGHT=512&SRS=EPSG:3010&STYLES=&BBOX=150264,6583802.8,150622.4,6584161.2

where I set the feature_count to 12 the features being returned are three,
but why? (We would expect one based on
spec.feature.getGeometry().getFirstCoordinate() )

It happens for polygon layers as well as point layers.

Is there a way to determine and/ or influence the actual search radius of
the getfeatureinfo-request?

--
Sent from: http://osgeo-org.1560.x6.nabble.com/GeoServer-User-f3786390.html

On Fri, Jan 5, 2018 at 2:28 PM, David I <perssond9@anonymised.com> wrote:

Like this call
https://karta.eskilstuna.se/geoserver/wms?SERVICE=WMS&
VERSION=1.1.1&REQUEST=GetFeatureInfo&FORMAT=image/
png&TRANSPARENT=true&QUERY_LAYERS=sokvyx_fk_ay_esktn&
LAYERS=sokvyx_fk_ay_esktn&TILED=true&INFO_FORMAT=text/
html&feature_count=12&X=346&Y=237&WIDTH=512&HEIGHT=512&SRS=
EPSG:3010&STYLES=&BBOX=150264,6583802.8,150622.4,6584161.2

I've downloaded the map and checked what point you're clicking with a
graphic editor, it's exactly at the corner between
3 polygons (added a red circle around the location, x=346&y=237):

!Selezione_055.png|544x476

By clicking that particular intersection point you will probably always get
3 polygons, no matter what the buffer is.

--

Regards,

Andrea Aime

==
GeoServer Professional Services from the experts! Visit http://goo.gl/it488V
for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via di Montramito 3/A
55054 Massarosa (LU)
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

AVVERTENZE AI SENSI DEL D.Lgs. 196/2003

Le informazioni contenute in questo messaggio di posta elettronica e/o
nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il
loro utilizzo è consentito esclusivamente al destinatario del messaggio,
per le finalità indicate nel messaggio stesso. Qualora riceviate questo
messaggio senza esserne il destinatario, Vi preghiamo cortesemente di
darcene notizia via e-mail e di procedere alla distruzione del messaggio
stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso,
divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od
utilizzarlo per finalità diverse, costituisce comportamento contrario ai
principi dettati dal D.Lgs. 196/2003.

The information in this message and/or attachments, is intended solely for
the attention and use of the named addressee(s) and may be confidential or
proprietary in nature or covered by the provisions of privacy act
(Legislative Decree June, 30 2003, no.196 - Italy's New Data Protection
Code).Any use not in accord with its purpose, any disclosure, reproduction,
copying, distribution, or either dissemination, either whole or partial, is
strictly forbidden except previous formal approval of the named
addressee(s). If you are not the intended recipient, please contact
immediately the sender by telephone, fax or e-mail and delete the
information in this message that has been received in error. The sender
does not give any warranty or accept liability as the content, accuracy or
completeness of sent messages and accepts no responsibility for changes
made after they were sent or for other risks which arise as a result of
e-mail transmission, viruses, etc.

On 05-01-18 16:27, Andrea Aime wrote:

I've downloaded the map and checked what point you're clicking with a
graphic editor, it's exactly at the corner between
3 polygons (added a red circle around the location, x=346&y=237):

If I'm correct (looking at the picture), your geoms do not have a fill
style. So clicking IN the polygon (is it?) probably does not return it?

What I often do is give the polygons a fill style there and set
transparency on 1%. This makes that you will still see them as
transparent, but NOW they are returned when you click IN them too.

Regards,

Richard Duivenvoorde

Thanks for your replies.

Geowolf: I see..logically I can understand how "getFirstCoordinate()" might
be a source of this kind of trouble for polygons, since this kind of layer
has shared borders.

However it applies to certain points of an address layer. For instance
https://karta.eskilstuna.se/geoserver/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetFeatureInfo&FORMAT=image%2Fpng&TRANSPARENT=true&QUERY_LAYERS=sokvyx_adresser_adresser&LAYERS=sokvyx_adresser_adresser&TILED=true&INFO_FORMAT=text%2Fhtml&feature_count=12&X=116&Y=335&WIDTH=512&HEIGHT=512&SRS=EPSG%3A3010&STYLES=&BBOX=151339.19999999972%2C6583086%2C152772.79999999973%2C6584519.6
is the result of an URL- construction with a getFeatureInfoUrl that has the
point's real coordinates i.e the point we can pretend we
getFeatureInfo-clicked.

It will return three addresses where the first one's point is 22 meters away
from the above point.

So I was wondering whether the above call generates a pretty generous buffer
or if something else is amiss.

Regards,
David

--
Sent from: http://osgeo-org.1560.x6.nabble.com/GeoServer-User-f3786390.html

On 8 January 2018 at 16:42, David I <perssond9@anonymised.com> wrote:

Thanks for your replies.

Geowolf: I see..logically I can understand how "getFirstCoordinate()" might
be a source of this kind of trouble for polygons, since this kind of layer
has shared borders.

However it applies to certain points of an address layer. For instance
https://karta.eskilstuna.se/geoserver/wms?SERVICE=WMS&
VERSION=1.1.1&REQUEST=GetFeatureInfo&FORMAT=image%
2Fpng&TRANSPARENT=true&QUERY_LAYERS=sokvyx_adresser_
adresser&LAYERS=sokvyx_adresser_adresser&TILED=true&
INFO_FORMAT=text%2Fhtml&feature_count=12&X=116&Y=335&
WIDTH=512&HEIGHT=512&SRS=EPSG%3A3010&STYLES=&BBOX=151339.
19999999972%2C6583086%2C152772.79999999973%2C6584519.6
is the result of an URL- construction with a getFeatureInfoUrl that has the
point's real coordinates i.e the point we can pretend we
getFeatureInfo-clicked.

It will return three addresses where the first one's point is 22 meters
away
from the above point.

Don't forget this is all done in pixel space so even one pixel may be 22
meters or more wide.

So I was wondering whether the above call generates a pretty generous
buffer
or if something else is amiss.

I suspect it uses a 3x3 pixel buffer but I may be wrong and we don't do
that at all anymore.

Ian

On Mon, Jan 8, 2018 at 6:16 PM, Ian Turton <ijturton@anonymised.com> wrote:

So I was wondering whether the above call generates a pretty generous
buffer
or if something else is amiss.

I suspect it uses a 3x3 pixel buffer but I may be wrong and we don't do
that at all anymore.

It's actually a bit more complicated today, when using a text symbolizer
the search radius considers also text height and
eventually offsets off the point center (because this is a visual tool, the
machinery should react to the user clicking the label,
not the user clicking the point, that in the above map is not even visible).

For what you are trying to do GetFeaureInfo seems to be the wrong tool for
the job, it's not meant to give you
the info of a particular feature, but what's in the vicinity of whatever
the user (visually) clicked on the map,
accounting for all symbolizers used.

One thing that you can do is to force a small search radius, e.g:

https://karta.eskilstuna.se/geoserver/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetFeatureInfo&FORMAT=image%2Fpng&TRANSPARENT=true&QUERY_LAYERS=sokvyx_adresser_adresser&LAYERS=sokvyx_adresser_adresser&TILED=true&INFO_FORMAT=text%2Fhtml&feature_count=12&X=116&Y=335&WIDTH=512&HEIGHT=512&SRS=EPSG%3A3010&STYLES=&BBOX=151339.19999999972%2C6583086%2C152772.79999999973%2C6584519.6&buffer=1

(the default search buffer can also be configured at the layer level if you
want)

I'd recommend also looking into GetFeature, there you can use whatever
coordinate you want and
decide on a search radius in actual meters by building a "within distance"
filter (mind, there are some limitations
on those filters if your data is expressed in geographic coordinates,
unless you are using the postgis
geography data type, or oracle).

Hope this helps

Cheers
Andrea

==

GeoServer Professional Services from the experts! Visit http://goo.gl/it488V
for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via di Montramito 3/A
55054 Massarosa (LU)
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

AVVERTENZE AI SENSI DEL D.Lgs. 196/2003

Le informazioni contenute in questo messaggio di posta elettronica e/o
nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il
loro utilizzo è consentito esclusivamente al destinatario del messaggio,
per le finalità indicate nel messaggio stesso. Qualora riceviate questo
messaggio senza esserne il destinatario, Vi preghiamo cortesemente di
darcene notizia via e-mail e di procedere alla distruzione del messaggio
stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso,
divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od
utilizzarlo per finalità diverse, costituisce comportamento contrario ai
principi dettati dal D.Lgs. 196/2003.

The information in this message and/or attachments, is intended solely for
the attention and use of the named addressee(s) and may be confidential or
proprietary in nature or covered by the provisions of privacy act
(Legislative Decree June, 30 2003, no.196 - Italy's New Data Protection
Code).Any use not in accord with its purpose, any disclosure, reproduction,
copying, distribution, or either dissemination, either whole or partial, is
strictly forbidden except previous formal approval of the named
addressee(s). If you are not the intended recipient, please contact
immediately the sender by telephone, fax or e-mail and delete the
information in this message that has been received in error. The sender
does not give any warranty or accept liability as the content, accuracy or
completeness of sent messages and accepts no responsibility for changes
made after they were sent or for other risks which arise as a result of
e-mail transmission, viruses, etc.

Many thanks for your reply, I understand it a bit better now. Thanks to the
others who suggested the use of the buffer vendor option too.

We could use getFeature for both displaying info popups for clicking search
hits as well as for info-clicking layers; there's an established workflow
with freemarker templates however and we want the info popup to look the
same when info-clicking in the map and when clicking a search hit and
getting panned to it. I think buffer=1 shall do for now.

Thanks again!

--
Sent from: http://osgeo-org.1560.x6.nabble.com/GeoServer-User-f3786390.html