[mapserver-commits] r9289 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Wed Sep 2 23:24:02 EDT 2009


Author: sdlime
Date: 2009-09-02 23:24:01 -0400 (Wed, 02 Sep 2009)
New Revision: 9289

Modified:
   trunk/mapserver/mapquery.c
   trunk/mapserver/mapserver.h
Log:
Added msInitQuery() and msFreeQuery() functions for managing query encapsulation.

Modified: trunk/mapserver/mapquery.c
===================================================================
--- trunk/mapserver/mapquery.c	2009-09-02 03:16:00 UTC (rev 9288)
+++ trunk/mapserver/mapquery.c	2009-09-03 03:24:01 UTC (rev 9289)
@@ -31,6 +31,38 @@
 
 MS_CVSID("$Id$")
 
+int msInitQuery(queryObj *query)
+{
+  if(!query) return MS_FAILURE;
+
+  query->type = MS_QUERY_IS_NULL; /* nothing defined */
+  query->mode = MS_QUERY_SINGLE;
+
+  query->layer=-1;
+
+  query->point.x = query->point.y = -1;
+  query->rect.minx = query->rect.miny = query->rect.maxx = query->rect.maxy = -1;
+  query->shape = NULL;
+
+  query->index = -1;
+
+  query->item = NULL;
+  query->string = NULL;
+
+  return MS_SUCCESS;
+}
+
+void msFreeQuery(queryObj *query)
+{
+  if(query->shape) {
+    msFreeShape(query->shape);
+    free(query->shape);
+  }
+
+  if(query->item) free(query->item);
+  if(query->string) free(query->string);
+}
+
 /*
 ** msIsLayerQueryable()  returns MS_TRUE/MS_FALSE
 */
@@ -1536,6 +1568,7 @@
   return found;
 }
 
+/* TODO: Rename this msFreeResultSet() or something along those lines... */
 /* msQueryFree()
  *
  * Free layer's query results. If qlayer == -1, all layers will be treated.

Modified: trunk/mapserver/mapserver.h
===================================================================
--- trunk/mapserver/mapserver.h	2009-09-02 03:16:00 UTC (rev 9288)
+++ trunk/mapserver/mapserver.h	2009-09-03 03:24:01 UTC (rev 9289)
@@ -393,7 +393,7 @@
 enum MS_JOIN_TYPE {MS_JOIN_ONE_TO_ONE, MS_JOIN_ONE_TO_MANY};
 
 enum MS_QUERY_MODE {MS_QUERY_SINGLE, MS_QUERY_MULTIPLE};
-enum MS_QUERY_TYPE {MS_QUERY_BY_POINT, MS_QUERY_BY_RECT, MS_QUERY_BY_SHAPE, MS_QUERY_BY_FEATURES, MS_QUERY_BY_OPERATOR};
+enum MS_QUERY_TYPE {MS_QUERY_IS_NULL, MS_QUERY_BY_POINT, MS_QUERY_BY_RECT, MS_QUERY_BY_SHAPE, MS_QUERY_BY_FEATURES, MS_QUERY_BY_OPERATOR};
 
 enum MS_ALIGN_VALUE {MS_ALIGN_LEFT, MS_ALIGN_CENTER, MS_ALIGN_RIGHT}; 
 
@@ -589,11 +589,17 @@
 typedef struct {
   int type; /* MS_QUERY_TYPE */
   int mode; /* MS_QUERY_MODE */
-  int qlayer;
 
+  int layer;
+
   pointObj point; /* by point */
   rectObj rect; /* by rect */
-  shapeObj *shape;
+  shapeObj *shape; /* by shape */
+
+  long index; /* by index */
+
+  char *item; /* by attribute */
+  char *string;
 } queryObj;
 
 /************************************************************************/
@@ -1682,7 +1688,9 @@
 MS_DLL_EXPORT int msIntersectPolygons(shapeObj *p1, shapeObj *p2);
 MS_DLL_EXPORT int msIntersectPolylines(shapeObj *line1, shapeObj *line2);
 
-MS_DLL_EXPORT int msSaveQuery(mapObj *map, char *filename); /* in mapquery.c */
+MS_DLL_EXPORT int msInitQuery(queryObj *query); /* in mapquery.c */
+MS_DLL_EXPORT void msFreeQuery(queryObj *query);
+MS_DLL_EXPORT int msSaveQuery(mapObj *map, char *filename);
 MS_DLL_EXPORT int msLoadQuery(mapObj *map, char *filename);
 MS_DLL_EXPORT int msQueryByIndex(mapObj *map, int qlayer, int tileindex, int shapeindex);
 MS_DLL_EXPORT int msQueryByIndexAdd(mapObj *map, int qlayer, int tileindex, int shapeindex);



More information about the mapserver-commits mailing list