Ticket #2989 (closed enhancement: fixed)

Opened 4 years ago

Last modified 3 years ago

WMS GetFeatureInfo: provide an option to output geometry

Reported by: bartvde Owned by: dmorissette
Priority: normal Milestone: 5.6 release
Component: WMS Server Version: unspecified
Severity: normal Keywords:
Cc: richard@…, dmorissette, assefa, tomkralidis, sdlime

Description

There has been a lot of discussion in the past about whether or not WMS GetFeatureInfo? should output the geometry or not. Currently Mapserver does not do this by default, but there are situations in which users want to output the geometry for WMS GetFeatureInfo?. So the proposal is to make this configurable using METADATA and to keep the default as is (output no geometry).

A related discussion can be found in ticket:300

I'll attach a patch done by a colleague of mine.

Attachments

mapserver-5.2.0-geomInFeatureinfo.patch Download (2.8 KB) - added by bartvde 4 years ago.
Patch implementing optional GetFeatureInfo? geometry

Change History

Changed 4 years ago by bartvde

Patch implementing optional GetFeatureInfo? geometry

Changed 4 years ago by rduivenvoorde

  • cc richard@… added

Changed 4 years ago by tomkralidis

  • cc dmorissette, assefa, tomkralidis added
  • owner changed from mapserverbugs to tomkralidis

Bart: thanks.

Before we go ahead, I think this is a viable temporary solution until the ticket:300 issues get ironed out. I'm not sure how long that will take, however.

danmo/assefa: are there any objections to applying this patch?

Changed 4 years ago by dmorissette

Hold on... I thought there was already a way to return the geometry in a GML WMS GetFeatureInfo? response. I'll have to check and get back to you.

Changed 4 years ago by tomkralidis

Dan: any update?

Changed 4 years ago by dmorissette

  • cc sdlime added

I had another look at the code, and there is indeed currently no way to include the geometry in GetFeatureInfo? results, and passing the geometryList argument to gmlWriteGeometry() instead of NULL as suggested in the patch would solve this.

However what bugs me is the new WMS/OWS_GEOMETRY_IN_FEATUREINFO metadata. Instead of adding another metadata, could we not find a way to manage this with the existing metadata? WE've already got the gml_include_items, and gml_geometries mechanisms to control some of the stuff... we don't need a third mechanism that doesn't integrate with them.

Perhaps gml_include_items "item1, item2, msGeometry" could do it? Unless we think that some people might want geometries for a given layer in WFS GetFeature? only and not in WMS GetFeatureInfo?, which would be the only reason to require different settings for WMS and WFS.

Changed 4 years ago by dmorissette

FYI I'm working on a patch that will (hopefully) allow controlling the geometry settings separately for WMS and WFS with the existing metadata, just by taking advantage of the namespaces prefix in metadata (WMS_*, WFS_*, OWS_*), let's hope it won't break something else.

Changed 4 years ago by tomkralidis

Dan: any update on this per comment:6? Should I pass this to you/your patch?

Changed 4 years ago by dmorissette

  • owner changed from tomkralidis to dmorissette
  • milestone changed from 6.0 release to 5.6 release

I was about halfway when I got interrupted and then it got shifted down by other priorities as happens too often unfortunately. I'll try to finish it ASAP.

Changed 4 years ago by dmorissette

  • status changed from new to closed
  • resolution set to fixed

I have committed a fix in r9405 that allows one to enable output of geometry in GML2 WMS GetFeatureInfo? if the wms_geometries and wms_geom_type metadata are specified. (ows_* and gml_* metadata prefixes also work for this).

By default, WMS GetFeatureInfo? in GML2 format does not include the geometry. To enable it, add those metadata to your layer(s). e.g. for a point layer

LAYER
  TYPE POINT
  ...
  METADATA
    "ows_geometries" "mygeom"
    "ows_mygeom_type"  "point"
  END
  ...
END

See the docs for gml_geometries and gml_[name]_type in http://mapserver.org/ogc/wfs_server.html. The same rules apply here except that there is no default geometry if *_geometries is not specified.

Changed 4 years ago by dmorissette

Created ticket #3161 to document this new feature.

Changed 4 years ago by tomkralidis

Daniel: looking at this further, earlier behaviour was to output a bounding box of the feature (see msautotest/wxs/expected/wms_get_feature_info_vector.gml). At this point, either no geometry at all is output, or full geometry is output if metadata is set.

I think it is still valuable to output the bounding coordinates, in either case. What do you think?

Changed 4 years ago by dmorissette

Um. Thanks for testing and reporting this issue. I didn't realize the value of the boundingbox by itself, but since it was there before I have no good reason to take it out. I have restored the bbox as the default behavior in r9419, so now we have the following behavior for WMS GetFeatureInfo? in GML2 format:

  • by default, no geometry output, only the bounding box of the feature (<gml:boundedBy>)
  • geometry output can be enabled using gml_geometries and gml_[name]_type metadata as explained earlier
  • the bounding box (and geometry) can be disabled using the "gml_geometries" "none" metadata

Changed 4 years ago by tomkralidis

Daniel: thanks for this. Now I get both the bounding box _and_ the geometry output as default. Tested against msautotest/wxs/wms_simple.map. You'll see a failure on wms_getfeatureinfo130.xml

Changed 4 years ago by dmorissette

  • status changed from closed to reopened
  • resolution fixed deleted

Argh! Not sure how I managed to miss that mistake! Anyway, I fixed things in r9426 so that we really get only the bbox by default.

Upon further testing Tom pointed out that the SRS and coordinates in the output don't match. I see that this is a deeper issue in the pre-existing code, so I'll look at it after beta3. Reopening ticket.

Changed 4 years ago by dmorissette

  • status changed from reopened to closed
  • resolution set to fixed

I have committed a fix in r9455 for the coordinate reprojection problem. msGMLWriteQuery() was not properly keeping track of its output SRS.

Changed 4 years ago by tomkralidis

Tested. Works. Thanks Daniel.

Changed 4 years ago by dmorissette

Phew! Finally! Thanks for all the help Tom.

Changed 4 years ago by bartvde

A question on this one, how would I go about disabling output of geometries for WMS GetFeatureInfo?, but explicitly getting WFS to always output multipolygons?

I used to have:

"GML_GEOMETRY_TYPE"     "multipolygon"
"GML_GEOMETRIES"        "geometry"

I tried changing to:

"WFS_GEOMETRY_TYPE"     "multipolygon"
"WFS_GEOMETRIES"        "geometry"

which gives me no geometry in WMS GetFeatureInfo?, which is okay, but gives me a polygon instead of a multipolygon in WFS output.

Changed 4 years ago by assefa

I think the following patch should fix the issue raised byBart. I do not see any side effect. Could some one confirm it:

Index: mapgml.c =================================================================== --- mapgml.c (revision 9594) +++ mapgml.c (working copy) @@ -1502,7 +1502,7 @@

itemList = msGMLGetItems(lp, "G"); constantList = msGMLGetConstants(lp, "G"); groupList = msGMLGetGroups(lp, "G");

- geometryList = msGMLGetGeometries(lp, "G"); + geometryList = msGMLGetGeometries(lp, "GFO");

if (namespace_prefix) {

layerName = (char *) malloc(strlen(namespace_prefix)+strlen(lp->name)+2);

Changed 4 years ago by assefa

Index: mapgml.c
===================================================================
--- mapgml.c	(revision 9594)
+++ mapgml.c	(working copy)
@@ -1502,7 +1502,7 @@
       itemList = msGMLGetItems(lp, "G");
       constantList = msGMLGetConstants(lp, "G");
       groupList = msGMLGetGroups(lp, "G");
-      geometryList = msGMLGetGeometries(lp, "G");
+      geometryList = msGMLGetGeometries(lp, "GFO");
 
       if (namespace_prefix) {
         layerName = (char *) malloc(strlen(namespace_prefix)+strlen(lp->name)+2);

Changed 4 years ago by assefa

committed last patch in trunk r9619. Bart, can you confirm that it works for you?

Changed 4 years ago by bartvde

There is another related issue with this approach, also the WFS DescribeFeatureType? does not listen to WFS_ metadata, so this is returned:

<element name="msGeometry" type="gml:GeometryPropertyType" minOccurs="0" maxOccurs="1"/>

instead of:

<element name="geometry" type="gml:MultiPolygonPropertyType" minOccurs="0" maxOccurs="1"/>

Changed 4 years ago by bartvde

  • status changed from closed to reopened
  • resolution fixed deleted

Changed 4 years ago by assefa

Fix for DescribeFeatureType? committed in r9621.

Changed 3 years ago by bartvde

  • status changed from reopened to closed
  • resolution set to fixed

Thanks, all seems fine now.

Note: See TracTickets for help on using tickets.