Hmmm... map->query.rect is used to set the searchrect. I wonder how that is 
populated initially. I would have thought it would have taken the map->extent 
in the first place if an extent was not explicitly set. It seems like this 
should be fixed upstream someplace. Your fix is reasonable but should be 
applied before the tolerance unit block.

Steve 

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Gertjan van Oosten
Sent: Thursday, July 17, 2014 7:07 AM
To: [email protected]
Subject: [mapserver-users] WFS GetFeature sometimes returns 'missing' even when 
there are matching features

Hi,

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?

Kind regards,
--
-- Gertjan van Oosten, Principal Consultant, West Consulting B.V.
-- [email protected]     +31 15 2191 600       www.west.nl
_______________________________________________
mapserver-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapserver-users
_______________________________________________
mapserver-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Reply via email to