Hexagon Geospatial
MENU

WebGIS

Need a push in the right direction when configuring WebMap, Portal or SDI services? Looking for hints and tips, or just looking for Ideas and information? The WebGIS discussion board is where you start those discussions, connect and share information.
Showing results for 
Search instead for 
Do you mean 
Reply
Highlighted
Contributor
Posts: 36
Registered: ‎09-18-2018
Accepted Solution

WMS getfeatureinfo format application/json

Hi,

 

I wonder if it is possible to add a new format on my wms publish via GeoMedia WebMap.

 

On my WMS getCapabilities I have the following formats for getfeatureinfo:

 

 

<GetFeatureInfo>
<Format>text/xml</Format>
<Format>text/html</Format>
<Format>application/gml+xml; version=3.1</Format>
...

</GetFeatureInfo>

It would be really good if it I could add the JSON format - "application/json"? Is this possible?

 

Thank you.

 

Technical Evangelist
Posts: 515
Registered: ‎09-11-2015

Re: WMS getfeatureinfo format application/json

Hi,

 

I think WebMap cannot do this out of the box, however, it could perhaps be possible somehow by adding a XML to JSON XSL transformation to the service XMLTemplates. But if you can control your client consuming the service, it would perhaps be easier to implement a JavaScript XML to JSON transformation.

 

Pavel

Technical Evangelist
Posts: 989
Registered: ‎09-11-2015

Re: WMS getfeatureinfo format application/json

The main problem is that WebMap's WMS won't understand GetFeatureInfo with format=application/json even if you force it display in the capabilities. One ugly work-around would be to use format=text/html but instead of HTML serve JSON via the XSLT which Pavel mentioned.

 

Much better solution would be to add a custom GetFeatureInfo handler via a custom passthrough pipe which would:

  1. Change the requested format to text/xml instead of application/json
  2. Invoke next pipe (to have GetFeatureInfo processed)
  3. Manipulate the response and return the expected JSON format.

See: https://community.hexagongeospatial.com/t5/Developers-Knowledge-Base/Developing-Custom-Pipes/ta-p/28...

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Contributor
Posts: 36
Registered: ‎09-18-2018

Re: WMS getfeatureinfo format application/json

 

In fact, I am using WebMap for publishing WMS and WFS only. 

 

Yes,

in fact as you said I am doing the transformation on the client side. Knowing that webmap can build OGC WMS it would be nice to have the possibility to allow json format on getfeatureinfo method as it turns things much easy when you want to operate with multiple applications. By the way there Is any in Hexagon Community where I may suggestions improvements for new versions?

 

Thank you.

Staff
Posts: 293
Registered: ‎02-04-2016

Re: WMS getfeatureinfo format application/json

[ Edited ]

Here is our Ideation Guidelines page on everything you need to know about submitting product ideas:

https://community.hexagongeospatial.com/t5/About-the-Community/Ideation-guidelines/ba-p/16696

 

Technical Evangelist
Posts: 989
Registered: ‎09-11-2015

Re: WMS getfeatureinfo format application/json

I decided to write a How-To article on this topic:

https://community.hexagongeospatial.com/t5/WebGIS-Tutorials/How-to-add-application-json-format-to-WM...

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Contributor
Posts: 36
Registered: ‎09-18-2018

Re: WMS getfeatureinfo format application/json

Thank you Jan for this!

Occasional Contributor
Posts: 23
Registered: ‎01-14-2016

Re: WMS getfeatureinfo format application/json

Hi Jan!

 

 

We've got a similar request from our customer. He asks for WMS <GetFeatureInfo> in this format: application/vnd.ogc.gml

 In general: <Format>application/gml+xml; version=3.1</Format>
 
 

Could you pls advise how to manage this?

 

 

Thanks a lot,

Kirill

Technical Evangelist
Posts: 989
Registered: ‎09-11-2015

Re: WMS getfeatureinfo format application/json

Hi Kirill,

 

I don't see much sense requesting this format because WebMap's GetFeatureInfo is already a GML XML file, i.e. text/xml returns GML FeatureCollection.

 

If the customer still needs a WMS to work with this MIME type, then it is only required to create simple pass-through pipe, that will change the application/gml+xml; version=3.1 to text/xml and back internally. Something like this:

 

public IResponseBase GetFeatureInfoHandler(SDIMethodParameters parameters,
     AdditionalParametersCollection additionalParameters,
     IUserContext userContext)
{
   IResponseBase response = null; 
   if (parameters is GetFeatureInfoParameters130 fi130)
   {
      if (fi130.InfoFormat == "application/gml+xml; version=3.1")
      {
         fi130.InfoFormat = "text/xml";         
         response = InvokeOnNextPipe(parameters, additionalParameters, userContext);
         response.MimeType = "application/gml+xml; version=3.1";
       
         return resultResponse;         
      }
   }
 
   response = InvokeOnNextPipe(parameters, additionalParameters, userContext);
   return response;
}
Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Do you need immediate support?
If you encounter a critical issue and need immediate assistance please submit a Service Request through our Support Portal.