Discussion:
[Geoserver-users] GetFeatureInfo JSON issues
Mark Prins
2017-05-23 08:47:28 UTC
Permalink
Hello,
I'm trying to perform a GetFetureInfo request over several raster layers to build some charts. I'm setting de INFO_FORMAT parameter to application/json and I'm getting
{"type":"FeatureCollection","totalFeatures":"unknown","features":[
{"type":"Feature","id":"","geometry":null,"properties":{"GRAY_INDEX":11735}},
{"type":"Feature","id":"","geometry":null,"properties":{"GRAY_INDEX":11399}},
{"type":"Feature","id":"","geometry":null,"properties":{"GRAY_INDEX":10563}},
{"type":"Feature","id":"","geometry":null,"properties":{"GRAY_INDEX":14560}},
{"type":"Feature","id":"","geometry":null,"properties":{"GRAY_INDEX":15902}},
{"type":"Feature","id":"","geometry":null,"properties":{"GRAY_INDEX":16138}}
],"crs":null}
How can I get the ID of each feature?
I don't think pixels have an id or a geometry, they are not actually
features

It would be great to have the layer name there to identify the requested
layer and the returned value..

but you already now the layer because you have just requested data from
it?...

Just like if the INFO_FORMAT is application/vnd.ogc.gml

the gml does not provide the layername and if you look closely does not
provide a fid or a geometry, so the behaviour is the same for both types
of response.
<?xml version="1.0" encoding="UTF-8"?><wfs:FeatureCollection xmlns="http://www.opengis.net/wfs" xmlns:wfs="http://www.opengis.net/wfs" xmlns:TELEDETEKZIOA="http://geoserver.hazi.eus/satimagery" xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://geo.hazi.eus/schemas/wfs/1.0.0/WFS-basic.xsd"><gml:boundedBy><gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#25830"><gml:coordinates xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts=" ">-1,-1 0,0</gml:coordinates></gml:Box></gml:boundedBy><gml:featureMember><TELEDETEKZIOA:S2A_20170512T111302456Z_NDVI fid=""><TELEDETEKZIOA:GRAY_INDEX>11735.0</TELEDETEKZIOA:GRAY_INDEX></TELEDETEKZIOA:S2A_20170512T111302456Z_NDVI></gml:featureMember><gml:featureMember><TELEDETEKZIOA:S2A_20170509T110556093Z_NDVI fid=""><TELEDETEKZIOA:GRAY_INDEX>11399.0</TELEDETEKZIOA:GRAY_INDEX></TELEDETEKZIOA:S2A_20170509T110556093Z_NDVI></gml:featureMember><gml:featureMember><TELEDETEKZIOA:S2A_20170502T110937275Z_NDVI fid=""><TELEDETEKZIOA:GRAY_INDEX>10563.0</TELEDETEKZIOA:GRAY_INDEX></TELEDETEKZIOA:S2A_20170502T110937275Z_NDVI></gml:featureMember><gml:featureMember><TELEDETEKZIOA:S2A_20170429T110525766Z_NDVI fid=""><TELEDETEKZIOA:GRAY_INDEX>14560.0</TELEDETEKZIOA:GRAY_INDEX></TELEDETEKZIOA:S2A_20170429T110525766Z_NDVI></gml:featureMember><gml:featureMember><TELEDETEKZIOA:S2A_20170422T111300457Z_NDVI fid=""><TELEDETEKZIOA:GRAY_INDEX>15902.0</TELEDETEKZIOA:GRAY_INDEX></TELEDETEKZIOA:S2A_20170422T111300457Z_NDVI></gml:featureMember><gml:featureMember><TELEDETEKZIOA:S2A_20170419T110601310Z_NDVI fid=""><TELEDETEKZIOA:GRAY_INDEX>16138.0</TELEDETEKZIOA:GRAY_INDEX></TELEDETEKZIOA:S2A_20170419T110601310Z_NDVI></gml:featureMember></wfs:FeatureCollection>
I've made a test with Freemarker templates but it doesn't change anything in the response. Templates are for text/html only or do they work with other INFO_FORMAT values?
Thanks in advance
Regards,
Agur bero bat,
David Alda Fernández de Lezea
Área de Sistemas de Información Geográfica, Planificación Territorial y Forestal Informazio Geografikoen Sistemak, Lurralde eta Baso Antolaketaren Arloa.
T 945 003 240 - M 627 923 170 - F 945 003 290
Hazi | Granja Modelo de Arkaute s/n | 01192 Arkaute - Araba
********************* LEGE OHARRA ******************* AVISOLEGAL ******************* DISCLAIMER *****************************
Mezu hau pertsonala eta isilpekoa da eta baimenik gabeko erabilera debekatua dago legalki. Jasotzailea ez bazara ezabatu mezua, bidali eta kontserbatu gabe.
Este mensaje es personal y confidencial y su uso no autorizado está prohibido legalmente. Si usted no es el destinatario, proceda a borrarlo, sin reenviarlo ni conservarlo.
This message is personal and confidential, unauthorised use is legally prohibited. If you are not the intended recipient, delete it without resending or backing it.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Geoserver-users mailing list
https://lists.sourceforge.net/lists/listinfo/geoserver-users
David Alda Fernandez de Lezea
2017-05-23 09:29:09 UTC
Permalink
Hi Mark,

Thanks for your response.

OK, pixels don't have an ID but I meant to identify the response with the request. The example was with 4 layers, but the idea is that it can be 'n' layers requested so I get 'n' values in the same response so I need a way to match the value and the layer requested.

This is the response in json format

{"type":"Feature","id":"","geometry":null,"properties":{"GRAY_INDEX":11735}}
{"type":"Feature","id":"","geometry":null,"properties":{"GRAY_INDEX":15902}}
{"type":"Feature","id":"","geometry":null,"properties":{"GRAY_INDEX":16547}}

In this response I can't match the value with layer directly. There's no way.


But, if I do the same request, talking about more than 1 layer in the same request, but using application/vnd.ogc.gml I get a GML file in which I have the value linked to the layer name:

<gml:featureMember>
<TELEDETEKZIOA:S2A_20170512T111302456Z_NDVI fid="">
<TELEDETEKZIOA:GRAY_INDEX>11735.0</TELEDETEKZIOA:GRAY_INDEX>
</TELEDETEKZIOA:S2A_20170512T111302456Z_NDVI>
</gml:featureMember>
<gml:featureMember>
<TELEDETEKZIOA:S2A_20170422T111300457Z_NDVI fid="">
<TELEDETEKZIOA:GRAY_INDEX>15902.0</TELEDETEKZIOA:GRAY_INDEX>
</TELEDETEKZIOA:S2A_20170422T111300457Z_NDVI>
</gml:featureMember>

So in each featureMember I get a tag with the Workspace:Layername. That's why I was asking..

Thanks.


Agur bero bat,


David Alda Fernández de Lezea
Área de Sistemas de Información Geográfica, Planificación Territorial y Forestal Informazio Geografikoen Sistemak, Lurralde eta Baso Antolaketaren Arloa.
***@hazi.eus | www.hazi.eus
T 945 003 240 – M 627 923 170 – F 945 003 290
Hazi | Granja Modelo de Arkaute s/n | 01192 Arkaute – Araba
 
*********************  LEGE OHARRA   *******************   AVISOLEGAL   *******************   DISCLAIMER   *****************************
Mezu hau pertsonala eta isilpekoa da eta baimenik gabeko erabilera debekatua dago legalki. Jasotzailea ez bazara ezabatu mezua, bidali eta kontserbatu gabe.
Este mensaje es personal y confidencial y su uso no autorizado está prohibido legalmente. Si usted no es el destinatario, proceda a borrarlo, sin reenviarlo ni conservarlo.
This message is personal and confidential, unauthorised use is legally prohibited. If you are not the intended recipient, delete it without resending or backing it.


-----Mensaje original-----
De: Mark Prins [mailto:***@gmail.com]
Enviado el: martes, 23 de mayo de 2017 10:47
Para: geoserver-***@lists.sourceforge.net
Asunto: Re: [Geoserver-users] GetFeatureInfo JSON issues
Hello,
I'm trying to perform a GetFetureInfo request over several raster
layers to build some charts. I'm setting de INFO_FORMAT parameter to
application/json and I'm getting
{"type":"FeatureCollection","totalFeatures":"unknown","features":[
{"type":"Feature","id":"","geometry":null,"properties":{"GRAY_INDEX":11735}},
{"type":"Feature","id":"","geometry":null,"properties":{"GRAY_INDEX":11399}},
{"type":"Feature","id":"","geometry":null,"properties":{"GRAY_INDEX":10563}},
{"type":"Feature","id":"","geometry":null,"properties":{"GRAY_INDEX":14560}},
{"type":"Feature","id":"","geometry":null,"properties":{"GRAY_INDEX":15902}},
{"type":"Feature","id":"","geometry":null,"properties":{"GRAY_INDEX":1
6138}}
],"crs":null}
How can I get the ID of each feature?
I don't think pixels have an id or a geometry, they are not actually features

It would be great to have the layer name there to identify the requested layer and the returned value..

but you already now the layer because you have just requested data from it?...

Just like if the INFO_FORMAT is application/vnd.ogc.gml

the gml does not provide the layername and if you look closely does not provide a fid or a geometry, so the behaviour is the same for both types of response.
<?xml version="1.0" encoding="UTF-8"?><wfs:FeatureCollection
xmlns="http://www.opengis.net/wfs"
xmlns:wfs="http://www.opengis.net/wfs"
xmlns:TELEDETEKZIOA="http://geoserver.hazi.eus/satimagery"
xmlns:gml="http://www.opengis.net/gml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wfs
http://geo.hazi.eus/schemas/wfs/1.0.0/WFS-basic.xsd"><gml:boundedBy><g
ml:Box
srsName="http://www.opengis.net/gml/srs/epsg.xml#25830"><gml:coordinat
es xmlns:gml="http://www.opengis.net/gml" decimal="." cs="," ts="
">-1,-1
0,0</gml:coordinates></gml:Box></gml:boundedBy><gml:featureMember><TEL
EDETEKZIOA:S2A_20170512T111302456Z_NDVI
fid=""><TELEDETEKZIOA:GRAY_INDEX>11735.0</TELEDETEKZIOA:GRAY_INDEX></T
ELEDETEKZIOA:S2A_20170512T111302456Z_NDVI></gml:featureMember><gml:fea
tureMember><TELEDETEKZIOA:S2A_20170509T110556093Z_NDVI
fid=""><TELEDETEKZIOA:GRAY_INDEX>11399.0</TELEDETEKZIOA:GRAY_INDEX></T
ELEDETEKZIOA:S2A_20170509T110556093Z_NDVI></gml:featureMember><gml:fea
tureMember><TELEDETEKZIOA:S2A_20170502T110937275Z_NDVI
fid=""><TELEDETEKZIOA:GRAY_INDEX>10563.0</TELEDETEKZIOA:GRAY_INDEX></T
ELEDETEKZIOA:S2A_20170502T110937275Z_NDVI></gml:featureMember><gml:fea
tureMember><TELEDETEKZIOA:S2A_20170429T110525766Z_NDVI
fid=""><TELEDETEKZIOA:GRAY_INDEX>14560.0</TELEDETEKZIOA:GRAY_INDEX></T
ELEDETEKZIOA:S2A_20170429T110525766Z_NDVI></gml:featureMember><gml:fea
tureMember><TELEDETEKZIOA:S2A_20170422T111300457Z_NDVI
fid=""><TELEDETEKZIOA:GRAY_INDEX>15902.0</TELEDETEKZIOA:GRAY_INDEX></T
ELEDETEKZIOA:S2A_20170422T111300457Z_NDVI></gml:featureMember><gml:fea
tureMember><TELEDETEKZIOA:S2A_20170419T110601310Z_NDVI
fid=""><TELEDETEKZIOA:GRAY_INDEX>16138.0</TELEDETEKZIOA:GRAY_INDEX></T
ELEDETEKZIOA:S2A_20170419T110601310Z_NDVI></gml:featureMember></wfs:Fe
atureCollection>
I've made a test with Freemarker templates but it doesn't change anything in the response. Templates are for text/html only or do they work with other INFO_FORMAT values?
Thanks in advance
Regards,
Agur bero bat,
David Alda Fernández de Lezea
Área de Sistemas de Información Geográfica, Planificación Territorial y Forestal Informazio Geografikoen Sistemak, Lurralde eta Baso Antolaketaren Arloa.
T 945 003 240 - M 627 923 170 - F 945 003 290 Hazi | Granja Modelo de
Arkaute s/n | 01192 Arkaute - Araba
********************* LEGE OHARRA ******************* AVISOLEGAL ******************* DISCLAIMER *****************************
Mezu hau pertsonala eta isilpekoa da eta baimenik gabeko erabilera debekatua dago legalki. Jasotzailea ez bazara ezabatu mezua, bidali eta kontserbatu gabe.
Este mensaje es personal y confidencial y su uso no autorizado está prohibido legalmente. Si usted no es el destinatario, proceda a borrarlo, sin reenviarlo ni conservarlo.
This message is personal and confidential, unauthorised use is legally prohibited. If you are not the intended recipient, delete it without resending or backing it.
----------------------------------------------------------------------
-------- Check out the vibrant tech community on one of the world's
most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Geoserver-users mailing list
https://lists.sourceforge.net/lists/listinfo/geoserver-users
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________
Geoserver-users mailing list
Geoserver-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users
David Alda Fernandez de Lezea
2017-05-26 10:31:21 UTC
Permalink
Hi Andrea,

Thanks for your response. I thought it could a bit more simple, just like changing some config o using a custom template.

Thanks, I'll try to figure out another workaround..

Regards,

Agur bero bat,



David Alda Fernández de Lezea
Área de Sistemas de Información Geográfica, Planificación Territorial y Forestal Informazio Geografikoen Sistemak, Lurralde eta Baso Antolaketaren Arloa.
***@hazi.eus | www.hazi.eus
T 945 003 240 – M 627 923 170 – F 945 003 290
Hazi | Granja Modelo de Arkaute s/n | 01192 Arkaute – Araba
 
*********************  LEGE OHARRA   *******************   AVISOLEGAL   *******************   DISCLAIMER   *****************************
Mezu hau pertsonala eta isilpekoa da eta baimenik gabeko erabilera debekatua dago legalki. Jasotzailea ez bazara ezabatu mezua, bidali eta kontserbatu gabe.
Este mensaje es personal y confidencial y su uso no autorizado está prohibido legalmente. Si usted no es el destinatario, proceda a borrarlo, sin reenviarlo ni conservarlo.
This message is personal and confidential, unauthorised use is legally prohibited. If you are not the intended recipient, delete it without resending or backing it.

De: ***@gmail.com [mailto:***@gmail.com] En nombre de Andrea Aime
Enviado el: viernes, 26 de mayo de 2017 11:07
Para: David Alda Fernandez de Lezea
CC: geoserver-***@lists.sourceforge.net
Asunto: Re: [Geoserver-users] GetFeatureInfo JSON issues

On Fri, May 26, 2017 at 10:51 AM, David Alda Fernandez de Lezea <***@hazi.eus> wrote:
Any ideas on how to get the layername in JSON getfeatureinfo response?

The only way I can think of is to add the layer name as an attribute of the features being generated... it will look a bit ridicolous in other formats (duplicated info) but I don't believe geojson has even the notion of a layer name otherwise.
An alternative could be to add a vendor extension to the GeoJSON and stick the layer name in the Feature object (as far as I can tell, GeoJSON demands certain attributes to be there, but does not restrict implementors to have only those).

In any case, it would be a code change.

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.

-------------------------------------------------------

Loading...