Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WFS GetFeature sometimes returns 'missing' even when there are matching features #4976

Closed
gjvoosten opened this issue Aug 22, 2014 · 2 comments
Assignees

Comments

@gjvoosten
Copy link

A WFS GetFeature request like this one:

<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" service="WFS" version="1.1.0" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <wfs:Query typeName="feature:Results_wfs">
    <wfs:PropertyName>FEATURE_ID</wfs:PropertyName>
  </wfs:Query>
</wfs:GetFeature>

sometimes returns 'missing' like so:

<?xml version='1.0' encoding="ISO-8859-1" ?>
<wfs:FeatureCollection
   xmlns:ms="http://mapserver.gis.umn.edu/mapserver"
   xmlns:gml="http://www.opengis.net/gml"
   xmlns:wfs="http://www.opengis.net/wfs"
   xmlns:ogc="http://www.opengis.net/ogc"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://mapserver.gis.umn.edu/mapserver http://localhost/mapserv?SERVICE=WFS&amp;VERSION=1.1.0&amp;REQUEST=DescribeFeatureType&amp;TYPENAME=feature:Results_wfs&amp;OUTPUTFORMAT=text/xml;%20subtype=gml/3.1.1  http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.1.0/wfs.xsd">
   <gml:boundedBy>
      <gml:Null>missing</gml:Null>
   </gml:boundedBy>
</wfs:FeatureCollection>

even when there is a matching feature. This happens with Mapserver 6.4.1 and Oracle 11.2. I've traced it down to the searchrect in msQueryByRect() inside mapquery.c being "empty":

{minx=-1, maxx=-1, miny=-1, maxy=-1}

This is caused by the way the extent is computed:

 msOracleSpatialLayerGetExtent. Using this Sql to retrieve the extent:
 SELECT SDO_GEOM.SDO_CONVEXHULL(link_geo, 0.001000) AS GEOM from (...)

The convex hull is NULL for some features. As the documentation says:

http://docs.oracle.com/cd/E11882_01/appdev.112/e11830/sdo_objgeom.htm#SPATL1114
"The function returns a null value if geom1 is of point type, has
fewer than three points or vertices, or consists of multiple points
all in a straight line."

I indeed have features like that, so in this case no features are returned at all. That is obviously not right. If I add these three lines it works correctly and my features are returned:

--- mapserver-6.4.1/mapquery.c.distrib  2014-01-02 13:41:49.000000000 +0100
+++ mapserver-6.4.1/mapquery.c  2014-07-17 13:58:36.000000000 +0200
@@ -1055,30 +1055,33 @@

     searchrect = map->query.rect;
     if(lp->tolerance > 0) {
       layer_tolerance = lp->tolerance;

       if(lp->toleranceunits == MS_PIXELS)
         tolerance = layer_tolerance * msAdjustExtent(&(map->extent), map->width, map->height);
       else
         tolerance = layer_tolerance * (msInchesPerUnit(lp->toleranceunits,0)/msInchesPerUnit(map->units,0));

       searchrect.minx -= tolerance;
       searchrect.maxx += tolerance;
       searchrect.miny -= tolerance;
       searchrect.maxy += tolerance;
     }
+    if (searchrect.minx == -1 && searchrect.maxx == -1 && searchrect.miny == -1 && searchrect.maxy == -1) {
+      searchrect = map->extent;
+    }

     msRectToPolygon(searchrect, &searchshape);

     /* Raster layers are handled specially. */
     if( lp->type == MS_LAYER_RASTER ) {
       if( msRasterQueryByRect( map, lp, searchrect ) == MS_FAILURE)
         return MS_FAILURE;

       continue;
     }

     /* Paging could have been disabled before */
     paging = msLayerGetPaging(lp);
     msLayerClose(lp); /* reset */
     status = msLayerOpen(lp);

I.e if the query rectangle can't be computed for some reason, fall back to the map extent. I don't know if this is the best fix, but it is the simplest that I could find. Is this the right way to do it?

@sdlime
Copy link
Member

sdlime commented Sep 9, 2014

@gjvoosten, anyway you might be able to try your queries against the 7.0 codebase (git master)?

Steve

@mapserver-bot
Copy link

This is an automated comment

This issue has been closed due to lack of activity. This doesn't mean the issue is invalid, it simply got no attention within the last year. Please reopen with missing/relevant information if still valid.

Typically, issues fall in this state for one of the following reasons:

  • Hard, impossible or not enough information to reproduce
  • Missing test case
  • Lack of a champion with interest and/or funding to address the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants