[mapserver-commits] r11648 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Thu May 5 00:04:47 EDT 2011


Author: sdlime
Date: 2011-05-04 21:04:47 -0700 (Wed, 04 May 2011)
New Revision: 11648

Modified:
   trunk/mapserver/HISTORY.TXT
   trunk/mapserver/mapquery.c
   trunk/mapserver/mapserver.h
Log:
Removed obsolete msQueryByOperator() function.

Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT	2011-05-05 03:51:06 UTC (rev 11647)
+++ trunk/mapserver/HISTORY.TXT	2011-05-05 04:04:47 UTC (rev 11648)
@@ -15,6 +15,8 @@
 Current Version (SVN trunk): 
 ---------------------------- 
 
+- Removed obsolete msQueryByOperator() function
+
 - Call msLayerClose() before msLayerOpen() in the various query functions (#3692)
 
 - Use full list of epsg codes with inverted axis (#3582)

Modified: trunk/mapserver/mapquery.c
===================================================================
--- trunk/mapserver/mapquery.c	2011-05-05 03:51:06 UTC (rev 11647)
+++ trunk/mapserver/mapquery.c	2011-05-05 04:04:47 UTC (rev 11648)
@@ -52,8 +52,6 @@
   query->shapeindex = query->tileindex = -1;
   query->clear_resultcache = MS_TRUE; /* index queries allow the old results to persist */
 
-  query->op = -1;
-
   query->item = query->str = NULL;
   query->filter = NULL;
 
@@ -101,9 +99,6 @@
   case MS_QUERY_BY_FILTER:
     status = msQueryByFilter(map);
     break;
-  case MS_QUERY_BY_OPERATOR:
-    status = msQueryByOperator(map);
-    break;
   case MS_QUERY_BY_SHAPE:
     status = msQueryByShape(map);
     break;
@@ -306,9 +301,7 @@
   fprintf(stream, "%s\n", (map->query.item)?map->query.item:"NULL"); /* by attribute */
   fprintf(stream, "%s\n", (map->query.str)?map->query.str:"NULL");
 
-  fprintf(stream, "%d\n", map->query.op); /* by operator */
-
-  if(map->query.shape) { /* by shape/by operator */
+  if(map->query.shape) { /* by shape */
     int i, j;
     shapeObj *s = map->query.shape;
 
@@ -362,9 +355,6 @@
       }
       break;
     case 8:
-      if(sscanf(buffer, "%d\n", &map->query.op) != 1) goto parse_error;
-      break;
-    case 9:
       if(sscanf(buffer, "%d\n", &shapetype) != 1) goto parse_error;
 
       if(shapetype != MS_SHAPE_NULL) { /* load the rest of the shape */
@@ -1904,252 +1894,6 @@
   return(MS_FAILURE);
 }
 
-/************************************************************************/
-/*                            msQueryByOperator                         */
-/*                                                                      */
-/*      query using a shape and a valid operator : all queries are      */
-/*      done using geos.                                                */
-/************************************************************************/
-int msQueryByOperator(mapObj *map)
-{
-#ifdef USE_GEOS
-  int start, stop=0, l;
-  shapeObj shape, *qshape=NULL;
-  layerObj *lp;
-  int status;
-  rectObj searchrect;
-     
-  int nclasses = 0;
-  int *classgroup = NULL;
-  double dfValue;
-  double minfeaturesize = -1;
-
-  if(map->query.type != MS_QUERY_BY_OPERATOR) {
-    msSetError(MS_QUERYERR, "The query is not properly defined.", "msQueryByOperator()");
-    return(MS_FAILURE);
-  }
-
-  msInitShape(&shape);
-  qshape = map->query.shape; /* for brevity */
-
-  /* this should not be a necessary test for queries using geos */
-  /*
-    if(selectshape->type != MS_SHAPE_POLYGON) {
-      msSetError(MS_QUERYERR, "Search shape MUST be a polygon.", "msQueryByShape()"); 
-      return(MS_FAILURE);
-    }
-  */
-
-  if(map->query.layer < 0 || map->query.layer >= map->numlayers)
-    start = map->numlayers-1;
-  else
-    start = stop = map->query.layer;
-
-  msComputeBounds(qshape); /* make sure an accurate extent exists */
- 
-  for(l=start; l>=stop; l--) { /* each layer */
-    lp = (GET_LAYER(map, l));
-
-    /* conditions may have changed since this layer last drawn, so set 
-       layer->project true to recheck projection needs (Bug #673) */ 
-    lp->project = MS_TRUE; 
-
-    /* free any previous search results, do it now in case one of the next few tests fail */
-    if(lp->resultcache) {
-      if(lp->resultcache->results) free(lp->resultcache->results);
-      free(lp->resultcache);
-      lp->resultcache = NULL;
-    }
-
-    if(!msIsLayerQueryable(lp)) continue;
-    if(lp->status == MS_OFF) continue;
-    
-    if(map->scaledenom > 0) {
-      if((lp->maxscaledenom > 0) && (map->scaledenom > lp->maxscaledenom)) continue;
-      if((lp->minscaledenom > 0) && (map->scaledenom <= lp->minscaledenom)) continue;
-    }
-
-    if (lp->maxscaledenom <= 0 && lp->minscaledenom <= 0) {
-      if((lp->maxgeowidth > 0) && ((map->extent.maxx - map->extent.minx) > lp->maxgeowidth)) continue;
-      if((lp->mingeowidth > 0) && ((map->extent.maxx - map->extent.minx) < lp->mingeowidth)) continue;
-    }
-
-    /* Raster layers are handled specially. */
-    if( lp->type == MS_LAYER_RASTER ) {
-      if( msRasterQueryByShape(map, lp, qshape) == MS_FAILURE )
-        return MS_FAILURE;
-      continue;
-    }
-    
-    msLayerClose(lp); /* reset */
-    status = msLayerOpen(lp);
-    if(status != MS_SUCCESS) return(MS_FAILURE);
-
-    /* build item list, we want *all* items */
-    status = msLayerWhichItems(lp, MS_TRUE, NULL);
-    if(status != MS_SUCCESS) return(MS_FAILURE);
-
-    /* identify target shapes */
-    if (map->query.op == MS_GEOS_BEYOND)
-      searchrect = map->extent;
-    else
-      searchrect = qshape->bounds;
-
-      
-#ifdef USE_PROJ
-    if(lp->project && msProjectionsDiffer(&(lp->projection), &(map->projection)))
-      msProjectRect(&(map->projection), &(lp->projection), &searchrect); /* project the searchrect to source coords */
-    else
-      lp->project = MS_FALSE;
-#endif
-    status = msLayerWhichShapes(lp, searchrect);
-    if(status == MS_DONE) { /* no overlap */
-      msLayerClose(lp);
-      continue;
-    } else if(status != MS_SUCCESS) {
-      msLayerClose(lp);
-      return(MS_FAILURE);
-    }
-
-    lp->resultcache = (resultCacheObj *)malloc(sizeof(resultCacheObj)); /* allocate and initialize the result cache */
-    MS_CHECK_ALLOC(lp->resultcache, sizeof(resultCacheObj), MS_FAILURE);
-    initResultCache( lp->resultcache);
-
-    classgroup = NULL;
-    if (lp->classgroup && lp->numclasses > 0)
-      classgroup = msAllocateValidClassGroups(lp, &nclasses);
-
-    if (lp->minfeaturesize > 0)
-        minfeaturesize = Pix2LayerGeoref(map, lp, lp->minfeaturesize);
-
-    while((status = msLayerNextShape(lp, &shape)) == MS_SUCCESS) { /* step through the shapes */
-
-      /* Check if the shape size is ok to be drawn */
-      if ( (shape.type == MS_SHAPE_LINE || shape.type == MS_SHAPE_POLYGON) && (minfeaturesize > 0) )
-      {
-          if (msShapeCheckSize(&shape, minfeaturesize) == MS_FALSE)
-          {
-              if( lp->debug >= MS_DEBUGLEVEL_V )
-                  msDebug("msQueryByOperator(): Skipping shape (%d) because LAYER::MINFEATURESIZE is bigger than shape size\n", shape.index);
-              msFreeShape(&shape);
-              continue;      
-          }
-      }
-
-      shape.classindex = msShapeGetClass(lp, map, &shape, classgroup, nclasses);
-      if(!(lp->template) && ((shape.classindex == -1) || (lp->class[shape.classindex]->status == MS_OFF))) { /* not a valid shape */
-        msFreeShape(&shape);
-        continue;
-      }
-
-      if(!(lp->template) && !(lp->class[shape.classindex]->template)) { /* no valid template */
-        msFreeShape(&shape);
-        continue;
-      }
-
-#ifdef USE_PROJ
-      if(lp->project && msProjectionsDiffer(&(lp->projection), &(map->projection)))
-        msProjectShape(&(lp->projection), &(map->projection), &shape);
-      else
-        lp->project = MS_FALSE;
-#endif
-
-      switch(map->query.op) 
-      { 
-        case MS_GEOS_EQUALS:
-          status = msGEOSEquals(&shape, qshape);
-          if (status != MS_TRUE && status != MS_FALSE)
-            status = MS_FALSE;
-          break;
-
-        case MS_GEOS_DISJOINT:
-          status = msGEOSDisjoint(&shape, qshape);
-          if (status != MS_TRUE && status != MS_FALSE)
-            status = MS_FALSE;
-          break;
-
-        case MS_GEOS_TOUCHES:
-          status = msGEOSTouches(&shape, qshape);
-          if (status != MS_TRUE && status != MS_FALSE)
-            status = MS_FALSE;
-          break;
-
-        case MS_GEOS_OVERLAPS:
-          status = msGEOSOverlaps(&shape, qshape);
-          if (status != MS_TRUE && status != MS_FALSE)
-            status = MS_FALSE;
-          break;
-
-        case MS_GEOS_CROSSES:
-          status = msGEOSCrosses(&shape, qshape);
-          if (status != MS_TRUE && status != MS_FALSE)
-            status = MS_FALSE;
-          break;
-
-        case MS_GEOS_INTERSECTS:
-          status = msGEOSIntersects(&shape, qshape);
-          if (status != MS_TRUE && status != MS_FALSE)
-            status = MS_FALSE;
-          break;
-
-        case MS_GEOS_WITHIN:
-          status = msGEOSWithin(&shape, qshape);
-          if (status != MS_TRUE && status != MS_FALSE)
-            status = MS_FALSE;
-          break;
-
-        case MS_GEOS_CONTAINS:
-          status = msGEOSContains(qshape, &shape);
-          if (status != MS_TRUE && status != MS_FALSE)
-            status = MS_FALSE;
-          break;
-
-        /* beyond is opposite of dwithin use in filter encoding see tickets #2105 and #2564 */
-        case MS_GEOS_BEYOND:
-          status = MS_FALSE;
-          dfValue = msGEOSDistance(&shape, qshape);
-          if (dfValue > 0.0)
-            status = MS_TRUE;
-          break;
-
-        /* dwithin is used with filter encoding (#2564) */
-        case MS_GEOS_DWITHIN:
-          status = MS_FALSE;
-          dfValue = msGEOSDistance(&shape, qshape);
-          if (dfValue == 0.0)
-            status = MS_TRUE;
-          break;
-
-        default:
-          msSetError(MS_QUERYERR, "Unknown GEOS Operator.", "msQueryByOperator()"); 
-          return(MS_FAILURE);
-      }
-
-      if(status == MS_TRUE)
-        addResult(lp->resultcache, &shape);
-
-      msFreeShape(&shape);
-    } /* next shape */
-
-    if(status != MS_DONE) return(MS_FAILURE);
-
-    if(lp->resultcache->numresults == 0) msLayerClose(lp); /* no need to keep the layer open */
-  } /* next layer */
-
-  /* was anything found? */
-  for(l=start; l>=stop; l--) {    
-    if(GET_LAYER(map, l)->resultcache && GET_LAYER(map, l)->resultcache->numresults > 0)
-      return(MS_SUCCESS);
-  }
- 
-  msSetError(MS_NOTFOUND, "No matching record(s) found.", "msQueryByOperator()"); 
-  return(MS_FAILURE);
-#else
-  msSetError(MS_GEOSERR, "GEOS support is not available.", "msQueryByOperator()");
-  return(MS_FAILURE);
-#endif
-}
-
 /* msGetQueryResultBounds()
  *
  * Compute the BBOX of all query results, returns the number of layers found

Modified: trunk/mapserver/mapserver.h
===================================================================
--- trunk/mapserver/mapserver.h	2011-05-05 03:51:06 UTC (rev 11647)
+++ trunk/mapserver/mapserver.h	2011-05-05 04:04:47 UTC (rev 11648)
@@ -467,7 +467,7 @@
 #define MS_MULTIPLE 1
 
 enum MS_QUERY_MODE {MS_QUERY_SINGLE, MS_QUERY_MULTIPLE};
-enum MS_QUERY_TYPE {MS_QUERY_IS_NULL, MS_QUERY_BY_POINT, MS_QUERY_BY_RECT, MS_QUERY_BY_SHAPE, MS_QUERY_BY_ATTRIBUTE, MS_QUERY_BY_INDEX, MS_QUERY_BY_OPERATOR, MS_QUERY_BY_FILTER};
+enum MS_QUERY_TYPE {MS_QUERY_IS_NULL, MS_QUERY_BY_POINT, MS_QUERY_BY_RECT, MS_QUERY_BY_SHAPE, MS_QUERY_BY_ATTRIBUTE, MS_QUERY_BY_INDEX, MS_QUERY_BY_FILTER};
 
 enum MS_ALIGN_VALUE {MS_ALIGN_LEFT, MS_ALIGN_CENTER, MS_ALIGN_RIGHT}; 
 
@@ -775,8 +775,6 @@
 
   expressionObj *filter; /* by filter */
 
-  int op; /* by GEOS operator */
-
   int slayer; /* selection layer, used for msQueryByFeatures() (note this is not a query mode per se) */
 } queryObj;
 #endif
@@ -1853,7 +1851,6 @@
 MS_DLL_EXPORT int msQueryByRect(mapObj *map);
 MS_DLL_EXPORT int msQueryByFeatures(mapObj *map);
 MS_DLL_EXPORT int msQueryByShape(mapObj *map);
-MS_DLL_EXPORT int msQueryByOperator(mapObj *map);
 MS_DLL_EXPORT int msQueryByFilter(mapObj *map);
 
 MS_DLL_EXPORT int msGetQueryResultBounds(mapObj *map, rectObj *bounds);



More information about the mapserver-commits mailing list