[mapserver-commits] r10924 - in trunk/mapserver: . mapscript/php mapscript/swiginc

svn at osgeo.org svn at osgeo.org
Tue Feb 1 23:28:39 EST 2011


Author: sdlime
Date: 2011-02-01 20:28:39 -0800 (Tue, 01 Feb 2011)
New Revision: 10924

Modified:
   trunk/mapserver/mapquery.c
   trunk/mapserver/mapscript/php/mapscript_i.c
   trunk/mapserver/mapscript/swiginc/map.i
   trunk/mapserver/mapserv.c
   trunk/mapserver/mapserver.h
Log:
Changed my mind, I decided to hide the two query saving methods in msSaveQuery() and just extend that function signature.

Modified: trunk/mapserver/mapquery.c
===================================================================
--- trunk/mapserver/mapquery.c	2011-02-02 04:08:35 UTC (rev 10923)
+++ trunk/mapserver/mapquery.c	2011-02-02 04:28:39 UTC (rev 10924)
@@ -178,22 +178,22 @@
 /*
 ** Serialize a query result set to disk.
 */
-int msSaveQueryResults(mapObj *map, char *filename) {
+static int saveQueryResults(mapObj *map, char *filename) {
   FILE *stream;
   int i, j, n=0;
 
   if(!filename) {
-    msSetError(MS_MISCERR, "No filename provided to save query results to.", "msSaveQueryResults()");
+    msSetError(MS_MISCERR, "No filename provided to save query results to.", "saveQueryResults()");
     return MS_FAILURE;
   }
 
   stream = fopen(filename, "w");
   if(!stream) {
-    msSetError(MS_IOERR, "(%s)", "msSaveQueryResults()", filename);
+    msSetError(MS_IOERR, "(%s)", "saveQueryResults()", filename);
     return MS_FAILURE;
   }
 
-  fprintf(stream, "%s - Generated by msSaveQueryResults()\n", MS_QUERY_RESULTS_MAGIC_STRING);
+  fprintf(stream, "%s - Generated by msSaveQuery()\n", MS_QUERY_RESULTS_MAGIC_STRING);
 
   /* count the number of layers with results */
   for(i=0; i<map->numlayers; i++)
@@ -224,7 +224,7 @@
     fread(&j, sizeof(int), 1, stream); /* layer index */
 
     if(j<0 || j>map->numlayers) {
-      msSetError(MS_MISCERR, "Invalid layer index loaded from query file.", "msLoadQueryResults()");
+      msSetError(MS_MISCERR, "Invalid layer index loaded from query file.", "loadQueryResults()");
       return MS_FAILURE;
     }
 
@@ -240,7 +240,7 @@
     GET_LAYER(map, j)->resultcache->results = (resultCacheMemberObj *) malloc(sizeof(resultCacheMemberObj)*GET_LAYER(map, j)->resultcache->numresults);
     if (GET_LAYER(map, j)->resultcache->results == NULL) 
     {
-        msSetError(MS_MEMERR, "%s: %d: Out of memory allocating %u bytes.\n", "msLoadQueryResults()",
+        msSetError(MS_MEMERR, "%s: %d: Out of memory allocating %u bytes.\n", "loadQueryResults()",
                    __FILE__, __LINE__, sizeof(resultCacheMemberObj)*GET_LAYER(map, j)->resultcache->numresults);       
         free(GET_LAYER(map, j)->resultcache);
         GET_LAYER(map, j)->resultcache = NULL;
@@ -260,21 +260,21 @@
 /*
 ** Serialize the parameters necessary to duplicate a query to disk. (TODO: add filter query...)
 */
-int msSaveQueryParams(mapObj *map, char *filename) {
+static int saveQueryParams(mapObj *map, char *filename) {
   FILE *stream;
 
   if(!filename) {
-    msSetError(MS_MISCERR, "No filename provided to save query to.", "msSaveQueryParams()");
+    msSetError(MS_MISCERR, "No filename provided to save query to.", "saveQueryParams()");
     return MS_FAILURE;
   }
 
   stream = fopen(filename, "w");
   if(!stream) {
-    msSetError(MS_IOERR, "(%s)", "msSaveQueryParams()", filename);
+    msSetError(MS_IOERR, "(%s)", "saveQueryParams()", filename);
     return MS_FAILURE;
   }
 
-  fprintf(stream, "%s - Generated by msSaveQueryParms()\n", MS_QUERY_PARAMS_MAGIC_STRING);
+  fprintf(stream, "%s - Generated by msSaveQuery()\n", MS_QUERY_PARAMS_MAGIC_STRING);
 
   fprintf(stream, "%d %d %d %d\n", map->query.mode, map->query.type, map->query.layer, map->query.slayer); /* all queries */
   fprintf(stream, "%.15g %.15g %g %d\n", map->query.point.x, map->query.point.y, map->query.buffer, map->query.maxresults); /* by point */
@@ -390,6 +390,18 @@
 }
 
 /*
+** Save (serialize) a query to disk. There are two methods, one saves the query parameters and the other saves
+** all the shape indexes. Note the latter can be very slow against certain data sources but has a certain usefulness
+** on occation.
+*/
+int msSaveQuery(mapObj *map, char *filename, int results) {
+  if(results)
+    return saveQueryResults(map, filename);
+  else
+    return saveQueryParams(map, filename);
+}
+
+/*
 ** Loads a query file contained either serialized 1) query parameters or 2) query results (e.g. indexes).
 */
 int msLoadQuery(mapObj *map, char *filename) 

Modified: trunk/mapserver/mapscript/php/mapscript_i.c
===================================================================
--- trunk/mapserver/mapscript/php/mapscript_i.c	2011-02-02 04:08:35 UTC (rev 10923)
+++ trunk/mapserver/mapscript/php/mapscript_i.c	2011-02-02 04:28:39 UTC (rev 10924)
@@ -211,10 +211,7 @@
 }
 
 int mapObj_saveQuery(mapObj *self, char *filename, int results) {
-  if(results)
-    return msSaveQueryResults(self, filename);
-  else
-    return msSaveQueryParams(self, filename);
+  return msSaveQuery(self, filename, results);
 }
 int mapObj_loadQuery(mapObj *self, char *filename) {
   return msLoadQuery(self, filename);

Modified: trunk/mapserver/mapscript/swiginc/map.i
===================================================================
--- trunk/mapserver/mapscript/swiginc/map.i	2011-02-02 04:08:35 UTC (rev 10923)
+++ trunk/mapserver/mapscript/swiginc/map.i	2011-02-02 04:28:39 UTC (rev 10924)
@@ -310,10 +310,7 @@
   }
 
   int saveQuery(char *filename, int results=MS_FALSE) {
-    if(results)
-      return msSaveQueryResults(self, filename);
-    else
-      return msSaveQueryParams(self, filename);
+    return msSaveQuery(self, filename, results);
   }
 
   int loadQuery(char *filename)  {

Modified: trunk/mapserver/mapserv.c
===================================================================
--- trunk/mapserver/mapserv.c	2011-02-02 04:08:35 UTC (rev 10923)
+++ trunk/mapserver/mapserv.c	2011-02-02 04:28:39 UTC (rev 10924)
@@ -1853,7 +1853,7 @@
           
         if(mapserv->savequery) {
           snprintf(buffer, sizeof(buffer), "%s%s%s%s", mapserv->map->web.imagepath, mapserv->map->name, mapserv->Id, MS_QUERY_EXTENSION);
-          if((status = msSaveQueryParams(mapserv->map, buffer)) != MS_SUCCESS) return status;
+          if((status = msSaveQuery(mapserv->map, buffer, MS_FALSE)) != MS_SUCCESS) return status;
         }
       }
 

Modified: trunk/mapserver/mapserver.h
===================================================================
--- trunk/mapserver/mapserver.h	2011-02-02 04:08:35 UTC (rev 10923)
+++ trunk/mapserver/mapserver.h	2011-02-02 04:28:39 UTC (rev 10924)
@@ -1805,8 +1805,7 @@
 
 MS_DLL_EXPORT int msInitQuery(queryObj *query); /* in mapquery.c */
 MS_DLL_EXPORT void msFreeQuery(queryObj *query);
-MS_DLL_EXPORT int msSaveQueryResults(mapObj *map, char *filename);
-MS_DLL_EXPORT int msSaveQueryParams(mapObj *map, char *filename);
+MS_DLL_EXPORT int msSaveQuery(mapObj *map, char *filename, int results);
 MS_DLL_EXPORT int msLoadQuery(mapObj *map, char *filename);
 MS_DLL_EXPORT int msExecuteQuery(mapObj *map);
 



More information about the mapserver-commits mailing list