[mapserver-commits] r12438 - in trunk/mapserver/mapcache: . include src

svn at osgeo.org svn at osgeo.org
Fri Aug 26 07:26:07 EDT 2011


Author: tbonfort
Date: 2011-08-26 04:26:07 -0700 (Fri, 26 Aug 2011)
New Revision: 12438

Added:
   trunk/mapserver/mapcache/src/cache_sqlite.c
Modified:
   trunk/mapserver/mapcache/Makefile.inc.in
   trunk/mapserver/mapcache/configure.in
   trunk/mapserver/mapcache/include/geocache.h
   trunk/mapserver/mapcache/src/cache_disk.c
   trunk/mapserver/mapcache/src/cache_memcache.c
   trunk/mapserver/mapcache/src/configuration.c
Log:
add grid tolerance to avoid pink tiles when specifying a restricted_extent
thomas.bonfort | 2011-08-23 09:34:11 +0200 (Tue, 23 Aug 2011)

Modified: trunk/mapserver/mapcache/Makefile.inc.in
===================================================================
--- trunk/mapserver/mapcache/Makefile.inc.in	2011-08-26 11:26:00 UTC (rev 12437)
+++ trunk/mapserver/mapcache/Makefile.inc.in	2011-08-26 11:26:07 UTC (rev 12438)
@@ -48,9 +48,13 @@
 CAIRO_LIB=@CAIRO_LIB@
 CAIRO_ENABLED=@CAIRO_ENABLED@
 
+SQLITE_INC=@SQLITE_INC@
+SQLITE_LIB=@SQLITE_LIB@
+SQLITE_ENABLED=@SQLITE_ENABLED@
+
 MISC_ENABLED=@MISC_ENABLED@ -DTHREADED_MPM=$(shell $(HTTPD) -V | grep "Server MPM" | grep -q "Prefork"; echo $$?)
 
-INCLUDES=-I../include $(MISC_ENABLED) $(CAIRO_ENABLED) $(CAIRO_INC) $(CURL_CFLAGS) $(PNG_INC) $(JPEG_INC) $(GDAL_INC) $(GEOS_INC) $(APR_INC) $(APU_INC) $(MEMCACHE_ENABLED) $(PCRE_CFLAGS) $(PCRE_ENABLED) $(OGR_ENABLED) $(GEOS_ENABLED)
+INCLUDES=-I../include $(MISC_ENABLED) $(CAIRO_ENABLED) $(CAIRO_INC) $(CURL_CFLAGS) $(PNG_INC) $(JPEG_INC) $(GDAL_INC) $(GEOS_INC) $(APR_INC) $(APU_INC) $(MEMCACHE_ENABLED) $(PCRE_CFLAGS) $(PCRE_ENABLED) $(OGR_ENABLED) $(GEOS_ENABLED) $(SQLITE_ENABLED)
 LIBS=$(CURL_LIBS) $(CAIRO_LIB) $(PNG_LIB) $(JPEG_LIB) $(GDAL_LIB) $(GEOS_LIB) $(APR_LIBS) $(APU_LIBS) $(PCRE_LIBS)
 
 

Modified: trunk/mapserver/mapcache/configure.in
===================================================================
--- trunk/mapserver/mapcache/configure.in	2011-08-26 11:26:00 UTC (rev 12437)
+++ trunk/mapserver/mapcache/configure.in	2011-08-26 11:26:07 UTC (rev 12438)
@@ -162,7 +162,7 @@
             `$PKGCONFIG --silence-errors -- cairo >> /dev/null`
             if test $? -eq 0 ; then
                 AC_MSG_RESULT(found)
-                CAIRO_CONFIG="cairo cairo-png"
+                CAIRO_CONFIG="cairo"
             else
                 AC_MSG_ERROR([cairo support requested, but not found.Try installing the cairo development headers])
             fi
@@ -546,6 +546,66 @@
     AC_SUBST(PNG_LIB,$PNG_LIB)
 ])
 
+AC_DEFUN([SQLITE_CHECK],[
+  AC_ARG_WITH(sqlite,
+              AC_HELP_STRING([--with-sqlite], [path to sqlite-config program]),
+              ,
+              [with_sqlite=yes]
+              )
+    
+    SQLITE_DIR=""
+    if test x"$with_sqlite" != "xyes" -a x"$with_sqlite" != "xno"; then
+      AC_EXPAND_PATH($with_sqlite, SQLITE_DIR)
+    fi
+    SQLITE_LIB=''
+    SQLITE_INC=''  
+    SQLITE_ENABLED=''
+
+    if test -n "$SQLITE_DIR" ; then
+        test -f $SQLITE_DIR/lib/libsqlite3.a -o -f $SQLITE_DIR/lib/libsqlite3.so -o -f $SQLITE_DIR/lib/libsqlite3.sl -o -f $SQLITE_DIR/lib/libsqlite3.dylib && SQLITE_LIBDIR="$SQLITE_DIR/lib"
+        test -f $SQLITE_DIR/lib64/libsqlite.a -o -f $SQLITE_DIR/lib64/libsqlite3.so -o -f $SQLITE_DIR/lib64/libsqlite3.sl -o -f $SQLITE_DIR/libsqlite3.dylib && SQLITE_LIBDIR="$SQLITE_DIR/lib64"
+        test -f $SQLITE_DIR/libsqlite3.a -o -f $SQLITE_DIR/libsqlite3.so -o -f $SQLITE_DIR/libsqlite3.sl -o -f $SQLITE_DIR/libsqlite3.dylib && SQLITE_LIBDIR="$SQLITE_DIR"
+        test -f $SQLITE_DIR/include/sqlite3.h && SQLITE_INCLUDE="$SQLITE_DIR/include"
+        test -f $SQLITE_DIR/include/sqlite/sqlite3.h && SQLITE_INCLUDE="$SQLITE_DIR/include/sqlite"
+        test -f $SQLITE_DIR/lib/sqlite3.h && SQLITE_INCLUDE="$SQLITE_DIR/lib"
+        test -f $SQLITE_DIR/sqlite3.h && SQLITE_INCLUDE="$SQLITE_DIR"
+        
+        if test -n "$SQLITE_LIBDIR" ; then   
+          SQLITE_LIB="-L$SQLITE_LIBDIR -lsqlite3"
+          AC_MSG_RESULT([using libsqlite from $SQLITE_LIB])
+        else
+          AC_MSG_ERROR([cannot find sqlite lib in $SQLITE_DIR])
+        fi
+        
+        if test -n "$SQLITE_INCLUDE" ; then
+          AC_CHECK_HEADER([$SQLITE_INCLUDE/sqlite3.h],SQLITE_INC=-I$SQLITE_INCLUDE,
+            [AC_MSG_ERROR([cannot use sqlite3.h headers from $SQLITE_INCLUDE])])
+        else
+            AC_MSG_ERROR([cannot find sqlite3.h])
+        fi
+        SQLITE_ENABLED="-DUSE_SQLITE"
+     elif test x"$with_sqlite" = "xyes"; then
+    
+      dnl check for sqlite in system locations
+    
+      AC_CHECK_LIB(sqlite3, sqlite3_open, SQLITE_LIB="-lsqlite3",,)
+      AC_CHECK_HEADER([sqlite3.h],,
+            [AC_MSG_ERROR([cannot find sqlite3.h header in system path])])
+      if test -n "$SQLITE_LIB" ; then
+        AC_MSG_RESULT([using libsqlite3 from system libs.])
+        SQLITE_ENABLED="-DUSE_SQLITE"
+      else
+        AC_MSG_ERROR([SQLITE (libsqlite3) library cannot be found. install or reconfigure with --with-sqlite=DIR])
+      fi
+    else
+      AC_MSG_RESULT([sqlite support disabled by request])
+    fi
+    
+    AC_SUBST(SQLITE_INC,$SQLITE_INC)
+    AC_SUBST(SQLITE_LIB,$SQLITE_LIB)
+    AC_SUBST(SQLITE_ENABLED,$SQLITE_ENABLED)
+])
+
 AC_DEFUN([JPEG_CHECK],[
     AC_ARG_WITH(jpeg,
         AC_HELP_STRING([--with-jpeg=DIR],[Specify where JPEG is installed]),
@@ -649,6 +709,7 @@
 
 APR_CHECK
 APU_CHECK
+SQLITE_CHECK
 PKGCONFIG_CHECK
 CAIRO_CHECK
 PNG_CHECK

Modified: trunk/mapserver/mapcache/include/geocache.h
===================================================================
--- trunk/mapserver/mapcache/include/geocache.h	2011-08-26 11:26:00 UTC (rev 12437)
+++ trunk/mapserver/mapcache/include/geocache.h	2011-08-26 11:26:07 UTC (rev 12438)
@@ -311,6 +311,9 @@
 #ifdef USE_MEMCACHE
        ,GEOCACHE_CACHE_MEMCACHE
 #endif
+#ifdef USE_SQLITE
+       ,GEOCACHE_CACHE_SQLITE
+#endif
 } geocache_cache_type;
 
 /** \interface geocache_cache
@@ -346,7 +349,7 @@
     void (*tile_set)(geocache_context *ctx, geocache_tile * tile);
 
     void (*configuration_parse)(geocache_context *ctx, ezxml_t xml, geocache_cache * cache);
-    void (*configuration_check)(geocache_context *ctx, geocache_cache * cache);
+    void (*configuration_post_config)(geocache_context *ctx, geocache_cache * cache, geocache_cfg *config);
 };
 
 /**\class geocache_cache_disk
@@ -359,8 +362,24 @@
     int symlink_blank;
 };
 
+
+#ifdef USE_SQLITE
+/**\class geocache_cache_sqlite
+ * \brief a geocache_cache on a filesytem
+ * \implements geocache_cache
+ */
+typedef struct geocache_cache_sqlite geocache_cache_sqlite;
+struct geocache_cache_sqlite {
+   geocache_cache cache;
+   char *dbdir; 
+};
+/**
+ * \memberof geocache_cache_sqlite
+ */
+geocache_cache* geocache_cache_sqlite_create(geocache_context *ctx);
+#endif
+
 #ifdef USE_MEMCACHE
-
 typedef struct geocache_cache_memcache geocache_cache_memcache;
 /**\class geocache_cache_memcache
  * \brief a geocache_cache on memcached servers
@@ -375,7 +394,6 @@
  * \memberof geocache_cache_memcache
  */
 geocache_cache* geocache_cache_memcache_create(geocache_context *ctx);
-
 #endif
 
 /** @} */
@@ -879,6 +897,7 @@
  */
 geocache_cache* geocache_cache_disk_create(geocache_context *ctx);
 
+
 /** \defgroup tileset Tilesets*/
 /** @{ */
 

Modified: trunk/mapserver/mapcache/src/cache_disk.c
===================================================================
--- trunk/mapserver/mapcache/src/cache_disk.c	2011-08-26 11:26:00 UTC (rev 12437)
+++ trunk/mapserver/mapcache/src/cache_disk.c	2011-08-26 11:26:07 UTC (rev 12438)
@@ -362,7 +362,8 @@
 /**
  * \private \memberof geocache_cache_disk
  */
-static void _geocache_cache_disk_configuration_check(geocache_context *ctx, geocache_cache *cache) {
+static void _geocache_cache_disk_configuration_post_config(geocache_context *ctx, geocache_cache *cache,
+      geocache_cfg *cfg) {
    geocache_cache_disk *dcache = (geocache_cache_disk*)cache;
    /* check all required parameters are configured */
    if(!dcache->base_directory || !strlen(dcache->base_directory)) {
@@ -398,7 +399,7 @@
    cache->cache.tile_get = _geocache_cache_disk_get;
    cache->cache.tile_exists = _geocache_cache_disk_has_tile;
    cache->cache.tile_set = _geocache_cache_disk_set;
-   cache->cache.configuration_check = _geocache_cache_disk_configuration_check;
+   cache->cache.configuration_post_config = _geocache_cache_disk_configuration_post_config;
    cache->cache.configuration_parse = _geocache_cache_disk_configuration_parse;
    return (geocache_cache*)cache;
 }

Modified: trunk/mapserver/mapcache/src/cache_memcache.c
===================================================================
--- trunk/mapserver/mapcache/src/cache_memcache.c	2011-08-26 11:26:00 UTC (rev 12437)
+++ trunk/mapserver/mapcache/src/cache_memcache.c	2011-08-26 11:26:07 UTC (rev 12438)
@@ -205,7 +205,7 @@
          }
          port = iport;
       }
-      if(APR_SUCCESS != apr_memcache_server_create(ctx->pool,host,port,4,5,50,10,&server)) {
+      if(APR_SUCCESS != apr_memcache_server_create(ctx->pool,host,port,4,5,50,10000,&server)) {
          ctx->set_error(ctx,400,"cache %s: failed to create server %s:%d",cache->name,host,port);
          return;
       }
@@ -223,7 +223,8 @@
 /**
  * \private \memberof geocache_cache_memcache
  */
-static void _geocache_cache_memcache_configuration_check(geocache_context *ctx, geocache_cache *cache) {
+static void _geocache_cache_memcache_configuration_post_config(geocache_context *ctx, geocache_cache *cache,
+      geocache_cfg *cfg) {
    geocache_cache_memcache *dcache = (geocache_cache_memcache*)cache;
    if(!dcache->memcache || dcache->memcache->ntotal==0) {
       ctx->set_error(ctx,400,"cache %s has no servers configured");
@@ -246,7 +247,7 @@
    cache->cache.tile_exists = _geocache_cache_memcache_has_tile;
    cache->cache.tile_set = _geocache_cache_memcache_set;
    cache->cache.tile_delete = _geocache_cache_memcache_delete;
-   cache->cache.configuration_check = _geocache_cache_memcache_configuration_check;
+   cache->cache.configuration_post_config = _geocache_cache_memcache_configuration_post_config;
    cache->cache.configuration_parse = _geocache_cache_memcache_configuration_parse;
    return (geocache_cache*)cache;
 }

Added: trunk/mapserver/mapcache/src/cache_sqlite.c
===================================================================
--- trunk/mapserver/mapcache/src/cache_sqlite.c	                        (rev 0)
+++ trunk/mapserver/mapcache/src/cache_sqlite.c	2011-08-26 11:26:07 UTC (rev 12438)
@@ -0,0 +1,249 @@
+/*
+ *  Copyright 2010 Thomas Bonfort
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+#ifdef USE_SQLITE
+
+#include "geocache.h"
+#include <apr_strings.h>
+#include <string.h>
+#include <errno.h>
+
+#include <sqlite3.h>
+
+static char* _get_dbname(geocache_context *ctx, geocache_cache_sqlite *cache,
+      geocache_tileset *tileset, geocache_grid *grid) {
+   return apr_pstrcat(ctx->pool,cache->dbdir,"/",tileset->name,"#",grid->name,".db",NULL);
+}
+
+static const char* _get_tile_dimkey(geocache_context *ctx, geocache_tile *tile) {
+   if(tile->dimensions) {
+      const apr_array_header_t *elts = apr_table_elts(tile->dimensions);
+      int i = elts->nelts;
+      if(i>1) {
+         char *key = "";
+         while(i--) {
+            apr_table_entry_t *entry = &(APR_ARRAY_IDX(elts,i,apr_table_entry_t));
+            if(i) {
+               key = apr_pstrcat(ctx->pool,key,entry->val,"#",NULL);
+            } else {
+               key = apr_pstrcat(ctx->pool,key,entry->val,NULL);
+            }
+         }
+         return key;
+      } else if(i){
+         apr_table_entry_t *entry = &(APR_ARRAY_IDX(elts,0,apr_table_entry_t));
+         return entry->val;
+      } else {
+         return "";
+      }
+   } else {
+      return "";
+   }
+}
+
+
+static sqlite3* _get_conn(geocache_context *ctx, geocache_tile* tile, int readonly) {
+   sqlite3* handle;
+   int flags;
+   if(readonly) {
+      flags = SQLITE_OPEN_READONLY;
+   } else {
+      flags = SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE;
+   }
+   char *dbfile = _get_dbname(ctx,(geocache_cache_sqlite*)tile->tileset->cache,tile->tileset,tile->grid_link->grid);
+   sqlite3_open_v2(dbfile,&handle,flags,NULL);
+   return handle;
+}
+
+
+static int _geocache_cache_sqlite_has_tile(geocache_context *ctx, geocache_tile *tile) {
+   int ret;
+   char *sql;
+   if(tile->dimensions) {
+      sql = "SELECT 1 from tiles where x=? and y=? and z=? and dim=?";
+   } else {
+      sql = "SELECT 1 from tiles where x=? and y=? and z=?";
+   }
+   sqlite3* handle = _get_conn(ctx,tile,0);
+   sqlite3_stmt *stmt;
+   sqlite3_prepare(handle,sql,-1,&stmt,NULL);
+   sqlite3_bind_int(stmt,1,tile->x);
+   sqlite3_bind_int(stmt,2,tile->y);
+   sqlite3_bind_int(stmt,3,tile->z);
+   if(tile->dimensions) {
+      const char *dim = _get_tile_dimkey(ctx,tile);
+      sqlite3_bind_text(stmt,4,dim,-1,SQLITE_STATIC);
+   }
+   if(sqlite3_step(stmt) == SQLITE_DONE) {
+      ret = GEOCACHE_FALSE;
+   } else {
+      ret = GEOCACHE_TRUE;
+   }
+   sqlite3_finalize(stmt);
+   sqlite3_close(handle);
+   return ret;
+}
+
+static void _geocache_cache_sqlite_delete(geocache_context *ctx, geocache_tile *tile) {
+   sqlite3* handle = _get_conn(ctx,tile,0);
+   char *sql;
+   if(tile->dimensions) {
+    sql = "DELETE from tiles where x=? and y=? and z=? and dim=?";
+   } else {
+    sql = "DELETE from tiles where x=? and y=? and z=?";
+   }
+   sqlite3_stmt *stmt;
+   sqlite3_prepare(handle,sql,-1,&stmt,NULL);
+   sqlite3_bind_int(stmt,1,tile->x);
+   sqlite3_bind_int(stmt,2,tile->y);
+   sqlite3_bind_int(stmt,3,tile->z);
+   if(tile->dimensions) {
+      const char* dim = _get_tile_dimkey(ctx,tile);
+      sqlite3_bind_text(stmt,4,dim,-1,SQLITE_STATIC);
+   }
+   sqlite3_step(stmt);
+   sqlite3_finalize(stmt);
+   sqlite3_close(handle);
+}
+
+
+static int _geocache_cache_sqlite_get(geocache_context *ctx, geocache_tile *tile) {
+   sqlite3* handle = _get_conn(ctx,tile,0);
+   sqlite3_stmt *stmt;
+   char *sql;
+   if(tile->dimensions) {
+      sql = "SELECT data from tiles where x=? and y=? and z=? and dim=?";
+   } else {
+      sql = "SELECT data from tiles where x=? and y=? and z=?";
+   }
+   sqlite3_prepare(handle,sql,-1,&stmt,NULL);
+   sqlite3_bind_int(stmt,1,tile->x);
+   sqlite3_bind_int(stmt,2,tile->y);
+   sqlite3_bind_int(stmt,3,tile->z);
+   if(tile->dimensions) {
+      const char* dim = _get_tile_dimkey(ctx,tile);
+      sqlite3_bind_text(stmt,4,dim,-1,SQLITE_STATIC);
+   }
+   if(sqlite3_step(stmt) == SQLITE_DONE) {
+      sqlite3_finalize(stmt);
+      sqlite3_close(handle);
+      return GEOCACHE_CACHE_MISS;
+   } else {
+      const void *blob = sqlite3_column_blob(stmt,0);
+      int size = sqlite3_column_bytes(stmt, 0);
+      tile->data = geocache_buffer_create(size,ctx->pool);
+      memcpy(tile->data->buf, blob,size);
+      tile->data->size = size;
+      sqlite3_finalize(stmt);
+      sqlite3_close(handle);
+      return GEOCACHE_SUCCESS;
+   }
+}
+
+static void _geocache_cache_sqlite_set(geocache_context *ctx, geocache_tile *tile) {
+   sqlite3* handle = _get_conn(ctx,tile,0);
+   sqlite3_stmt *stmt;
+   char *sql;
+   if(tile->dimensions) {
+      sql = "insert into tiles(x,y,z,data,dim) values (?,?,?,?,?)";
+   } else {
+      sql = "insert into tiles(x,y,z,data) values (?,?,?,?)";
+   }
+   sqlite3_prepare(handle, sql,-1,&stmt,NULL);
+   sqlite3_bind_int(stmt,1,tile->x);
+   sqlite3_bind_int(stmt,2,tile->y);
+   sqlite3_bind_int(stmt,3,tile->z);
+   sqlite3_bind_blob(stmt,4,tile->data->buf, tile->data->size,SQLITE_STATIC);
+   if(tile->dimensions) {
+      const char* dim = _get_tile_dimkey(ctx,tile);
+      sqlite3_bind_text(stmt,5,dim,-1,SQLITE_STATIC);
+   }
+   sqlite3_step(stmt);
+   sqlite3_finalize(stmt);
+   sqlite3_close(handle);
+}
+
+static void _geocache_cache_sqlite_configuration_parse(geocache_context *ctx, ezxml_t node, geocache_cache *cache) {
+   ezxml_t cur_node;
+   geocache_cache_sqlite *dcache = (geocache_cache_sqlite*)cache;
+   if ((cur_node = ezxml_child(node,"base")) != NULL) {
+      dcache->dbdir = apr_pstrdup(ctx->pool,cur_node->txt);
+   }
+   if(!dcache->dbdir) {
+      ctx->set_error(ctx,500,"sqlite cache \"%s\" is missing <base> directory",cache->name);
+      return;
+   }
+}
+   
+/**
+ * \private \memberof geocache_cache_sqlite
+ */
+static void _geocache_cache_sqlite_configuration_post_config(geocache_context *ctx,
+      geocache_cache *cache, geocache_cfg *cfg) {
+   sqlite3 *db;
+   char *errmsg;
+
+   apr_hash_index_t *tileindex_index = apr_hash_first(ctx->pool,cfg->tilesets);
+
+   while(tileindex_index) {
+      geocache_tileset *tileset;
+      const void *key; apr_ssize_t keylen;
+      apr_hash_this(tileindex_index,&key,&keylen,(void**)&tileset);
+      if(!strcmp(tileset->cache->name,cache->name)) {
+         int i;
+         for(i=0;i<tileset->grid_links->nelts;i++) {
+            geocache_grid_link *gridlink = APR_ARRAY_IDX(tileset->grid_links,i,geocache_grid_link*);
+            geocache_grid *grid = gridlink->grid;
+            char *dbname = _get_dbname(ctx,(geocache_cache_sqlite*)cache,tileset,grid);
+            sqlite3_open(dbname, &db);
+            sqlite3_exec(db, "create table if not exists tiles(x integer, y integer, z integer, data blob, ctime date, mtime date, atime date)", 0, 0, &errmsg);
+            sqlite3_exec(db, "create index if not exists tilesidx on tiles (x,y,z)", 0, 0, &errmsg);
+            if(tileset->dimensions) {
+               /* the following would return an error if the column already exists, but we ignore it */
+               sqlite3_exec(db, "alter table tiles add column dim text",0, 0, &errmsg);
+               sqlite3_exec(db, "create index if not exists tilesdimidx on tiles (dim)", 0, 0, &errmsg);
+            }
+            sqlite3_close(db);
+         }
+      }
+      tileindex_index = apr_hash_next(tileindex_index);
+   }
+}
+
+/**
+ * \brief creates and initializes a geocache_sqlite_cache
+ */
+geocache_cache* geocache_cache_sqlite_create(geocache_context *ctx) {
+   geocache_cache_sqlite *cache = apr_pcalloc(ctx->pool,sizeof(geocache_cache_sqlite));
+   if(!cache) {
+      ctx->set_error(ctx, 500, "failed to allocate sqlite cache");
+      return NULL;
+   }
+   cache->cache.metadata = apr_table_make(ctx->pool,3);
+   cache->cache.type = GEOCACHE_CACHE_SQLITE;
+   cache->cache.tile_delete = _geocache_cache_sqlite_delete;
+   cache->cache.tile_get = _geocache_cache_sqlite_get;
+   cache->cache.tile_exists = _geocache_cache_sqlite_has_tile;
+   cache->cache.tile_set = _geocache_cache_sqlite_set;
+   cache->cache.configuration_post_config = _geocache_cache_sqlite_configuration_post_config;
+   cache->cache.configuration_parse = _geocache_cache_sqlite_configuration_parse;
+   return (geocache_cache*)cache;
+}
+
+#endif
+
+/* vim: ai ts=3 sts=3 et sw=3
+*/

Modified: trunk/mapserver/mapcache/src/configuration.c
===================================================================
--- trunk/mapserver/mapcache/src/configuration.c	2011-08-26 11:26:00 UTC (rev 12437)
+++ trunk/mapserver/mapcache/src/configuration.c	2011-08-26 11:26:07 UTC (rev 12438)
@@ -578,11 +578,18 @@
    }
    if(!strcmp(type,"disk")) {
       cache = geocache_cache_disk_create(ctx);
+   } else if(!strcmp(type,"sqlite3")) {
+#ifdef USE_SQLITE
+      cache = geocache_cache_sqlite_create(ctx);
+#else
+      ctx->set_error(ctx,400, "failed to add cache \"%s\": sqlite support is not available on this build",name);
+      return;
+#endif
    } else if(!strcmp(type,"memcache")) {
 #ifdef USE_MEMCACHE
       cache = geocache_cache_memcache_create(ctx);
 #else
-      ctx->set_error(ctx,400, "failed to add cache %s: memcache support is not available on this build",name);
+      ctx->set_error(ctx,400, "failed to add cache \"%s\": memcache support is not available on this build",name);
       return;
 #endif
    } else {
@@ -597,8 +604,6 @@
 
    cache->configuration_parse(ctx,node,cache);
    GC_CHECK_ERROR(ctx);
-   cache->configuration_check(ctx,cache);
-   GC_CHECK_ERROR(ctx);
    geocache_configuration_add_cache(config,cache,name);
    return;
 }
@@ -1156,7 +1161,17 @@
       }
    }
 
+   apr_hash_index_t *cachei = apr_hash_first(ctx->pool,config->caches);
+   while(cachei) {
+      geocache_cache *cache;
+      const void *key; apr_ssize_t keylen;
+      apr_hash_this(cachei,&key,&keylen,(void**)&cache);
+      cache->configuration_post_config(ctx,cache,config);
+      if(GC_HAS_ERROR(ctx)) goto cleanup;
+      cachei = apr_hash_next(cachei);
+   }
 
+
 cleanup:
    ezxml_free(doc);
    return;



More information about the mapserver-commits mailing list