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

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


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

Added:
   trunk/mapserver/mapcache/src/source_gdal.c
Modified:
   trunk/mapserver/mapcache/Makefile.inc.in
   trunk/mapserver/mapcache/configure
   trunk/mapserver/mapcache/configure.in
   trunk/mapserver/mapcache/include/errors.h
   trunk/mapserver/mapcache/include/geocache.h
   trunk/mapserver/mapcache/src/Makefile
   trunk/mapserver/mapcache/src/configuration.c
   trunk/mapserver/mapcache/src/source_wms.c
Log:
add lock around blank tile creation

fixes #19
thomas.bonfort | 2010-12-17 11:03:52 +0100 (Fri, 17 Dec 2010)

Modified: trunk/mapserver/mapcache/Makefile.inc.in
===================================================================
--- trunk/mapserver/mapcache/Makefile.inc.in	2011-08-26 11:04:45 UTC (rev 12179)
+++ trunk/mapserver/mapcache/Makefile.inc.in	2011-08-26 11:04:53 UTC (rev 12180)
@@ -28,11 +28,16 @@
 FCGI_INC=@FASTCGI_INC@
 FCGI_LIB=@FASTCGI_LIB@
 
-GC_CFLAGS=$(CFLAGS) -I../include $(CURL_CFLAGS) $(XML2_CFLAGS) $(PNG_INC) $(JPEG_INC)
-GC_LIBS=$(CURL_LIBS) $(XML2_LIBS) $(PNG_LIB) $(JPEG_LIB)
+GDAL_INC=@GDAL_INC@
+GDAL_LIB=@GDAL_LIB@
+GDAL_ENABLED=@GDAL_ENABLED@
 
+GC_CFLAGS=$(CFLAGS) -I../include $(CURL_CFLAGS) $(XML2_CFLAGS) $(PNG_INC) $(JPEG_INC) $(GDAL_INC) $(GDAL_ENABLED)
+GC_LIBS=$(CURL_LIBS) $(XML2_LIBS) $(PNG_LIB) $(JPEG_LIB) $(GDAL_LIB)
 
 
+
 OBJS=$(shell find . -regex '^.*\.c$$' -print | grep -v geocache_seed.c | grep -v mod_geocache.c | grep -v fastcgi_geocache.c |sed "s/^\(.*\)\.c$$/\1.o/") 
 LOBJS=$(shell find . -regex '^.*\.c$$' -print | grep -v geocache_seed.c | grep -v mod_geocache.c | grep -v fastcgi_geocache.c | sed "s/^\(.*\)\.c$$/\1.lo/")
 APXS_WCFLAGS=$(shell for flag in $(GC_CFLAGS); do echo "-Wc,$$flag "; done)
+APXS_WLDFLAGS=$(shell for flag in $(GC_LIBS); do echo "-Wl,$$flag "; done)

Modified: trunk/mapserver/mapcache/configure
===================================================================
--- trunk/mapserver/mapcache/configure	2011-08-26 11:04:45 UTC (rev 12179)
+++ trunk/mapserver/mapcache/configure	2011-08-26 11:04:53 UTC (rev 12180)
@@ -750,6 +750,10 @@
 XML2_LIBS
 XML2_CFLAGS
 XML2CONFIG
+GDAL_LIB
+GDAL_INC
+GDAL_ENABLED
+GDAL_CONFIG
 JPEG_LIB
 JPEG_INC
 PNG_LIB
@@ -857,6 +861,7 @@
 with_apr_config
 with_png
 with_jpeg
+with_gdal
 with_xml2_config
 with_curl_config
 '
@@ -1504,6 +1509,7 @@
   --with-apr-config       path to apr-config program
   --with-png=DIR          Specify where PNG is installed
   --with-jpeg=DIR         Specify where JPEG is installed
+  --with-gdal[=PATH]      Include GDAL support (PATH is path to gdal-config)
   --with-xml2-config=/path/to/xml2-config     xml2-config tool location
   --with-curl-config      path to curl-config program
 
@@ -3804,13 +3810,13 @@
 else
   lt_cv_nm_interface="BSD nm"
   echo "int some_variable = 0;" > conftest.$ac_ext
-  (eval echo "\"\$as_me:3807: $ac_compile\"" >&5)
+  (eval echo "\"\$as_me:3813: $ac_compile\"" >&5)
   (eval "$ac_compile" 2>conftest.err)
   cat conftest.err >&5
-  (eval echo "\"\$as_me:3810: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
+  (eval echo "\"\$as_me:3816: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
   (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
   cat conftest.err >&5
-  (eval echo "\"\$as_me:3813: output\"" >&5)
+  (eval echo "\"\$as_me:3819: output\"" >&5)
   cat conftest.out >&5
   if $GREP 'External.*some_variable' conftest.out > /dev/null; then
     lt_cv_nm_interface="MS dumpbin"
@@ -5016,7 +5022,7 @@
   ;;
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 5019 "configure"' > conftest.$ac_ext
+  echo '#line 5025 "configure"' > conftest.$ac_ext
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -6545,11 +6551,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:6548: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:6554: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:6552: \$? = $ac_status" >&5
+   echo "$as_me:6558: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -6884,11 +6890,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:6887: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:6893: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:6891: \$? = $ac_status" >&5
+   echo "$as_me:6897: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -6989,11 +6995,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:6992: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:6998: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:6996: \$? = $ac_status" >&5
+   echo "$as_me:7002: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -7044,11 +7050,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:7047: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:7053: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:7051: \$? = $ac_status" >&5
+   echo "$as_me:7057: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -9428,7 +9434,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 9431 "configure"
+#line 9437 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -9524,7 +9530,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 9527 "configure"
+#line 9533 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -10323,6 +10329,8 @@
 
 
 
+
+
     # Check whether --enable-debug was given.
 if test "${enable_debug+set}" = set; then :
   enableval=$enable_debug;
@@ -11042,6 +11050,113 @@
 
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if GDAL support requested" >&5
+$as_echo_n "checking if GDAL support requested... " >&6; }
+
+
+# Check whether --with-gdal was given.
+if test "${with_gdal+set}" = set; then :
+  withval=$with_gdal;
+fi
+
+
+if test "$with_gdal" = "yes" ; then
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+  if test "`basename xx/$with_gdal`" = "gdal-config" ; then
+    GDAL_CONFIG="$with_gdal"
+  fi
+
+  if test -z "$GDAL_CONFIG" ; then
+    # Extract the first word of "gdal-config", so it can be a program name with args.
+set dummy gdal-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_GDAL_CONFIG+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $GDAL_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_GDAL_CONFIG="$GDAL_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_GDAL_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  test -z "$ac_cv_path_GDAL_CONFIG" && ac_cv_path_GDAL_CONFIG="no"
+  ;;
+esac
+fi
+GDAL_CONFIG=$ac_cv_path_GDAL_CONFIG
+if test -n "$GDAL_CONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GDAL_CONFIG" >&5
+$as_echo "$GDAL_CONFIG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  fi
+
+  if test "$GDAL_CONFIG" = "no" ; then
+    as_fn_error $? "couldn't find gdal-config" "$LINENO" 5
+  fi
+
+  GDAL_ENABLED=-DUSE_GDAL
+
+elif test -n "$with_gdal" -a "$with_gdal" != "no" ; then
+
+  GDAL_CONFIG=$with_gdal
+
+  if test -f "$GDAL_CONFIG" -a -x "$GDAL_CONFIG" ; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, user supplied gdal-config ($GDAL_CONFIG)" >&5
+$as_echo "yes, user supplied gdal-config ($GDAL_CONFIG)" >&6; }
+  else
+    as_fn_error $? "'$GDAL_CONFIG' is not an executable.  Make sure you use --with-gdal=/path/to/gdal-config" "$LINENO" 5
+  fi
+
+  GDAL_ENABLED=-DUSE_GDAL
+
+else
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+fi
+
+
+if test -n "$GDAL_ENABLED" -o "$OGR_ENABLED"; then
+
+  GDAL_LIB=`$GDAL_CONFIG --libs`' '`$GDAL_CONFIG --dep-libs`
+  GDAL_INC=`$GDAL_CONFIG --cflags`
+
+fi
+
+GDAL_ENABLED=$GDAL_ENABLED
+
+GDAL_INC=$GDAL_INC
+
+GDAL_LIB=$GDAL_LIB
+
+
+
+
+
 #PKGCONFIG_CHECK
 
 #CAIRO_CHECK

Modified: trunk/mapserver/mapcache/configure.in
===================================================================
--- trunk/mapserver/mapcache/configure.in	2011-08-26 11:04:45 UTC (rev 12179)
+++ trunk/mapserver/mapcache/configure.in	2011-08-26 11:04:53 UTC (rev 12180)
@@ -422,6 +422,67 @@
     AC_SUBST(JPEG_LIB,$JPEG_LIB)
 ])
 
+
+AC_DEFUN(GDAL_CHECK,[
+AC_MSG_CHECKING(if GDAL support requested)
+
+AC_ARG_WITH(gdal,
+[  --with-gdal[[=PATH]]      Include GDAL support (PATH is path to gdal-config)],,)
+
+if test "$with_gdal" = "yes" ; then
+
+  AC_MSG_RESULT([yes])
+
+  if test "`basename xx/$with_gdal`" = "gdal-config" ; then
+    GDAL_CONFIG="$with_gdal"
+  fi
+
+  if test -z "$GDAL_CONFIG" ; then
+    AC_PATH_PROG(GDAL_CONFIG, gdal-config, no)
+  fi
+
+  if test "$GDAL_CONFIG" = "no" ; then
+    AC_MSG_ERROR([couldn't find gdal-config])
+  fi
+
+  GDAL_ENABLED=-DUSE_GDAL
+
+elif test -n "$with_gdal" -a "$with_gdal" != "no" ; then
+
+  GDAL_CONFIG=$with_gdal
+
+  if test -f "$GDAL_CONFIG" -a -x "$GDAL_CONFIG" ; then
+    AC_MSG_RESULT([yes, user supplied gdal-config ($GDAL_CONFIG)])
+  else
+    AC_MSG_ERROR(['$GDAL_CONFIG' is not an executable.  Make sure you use --with-gdal=/path/to/gdal-config])
+  fi
+
+  GDAL_ENABLED=-DUSE_GDAL
+
+else
+
+  AC_MSG_RESULT([no])
+
+fi
+
+dnl
+dnl GDAL_LIB and GDAL_INC are used for both GDAL and OGR
+dnl
+
+if test -n "$GDAL_ENABLED" -o "$OGR_ENABLED"; then
+
+  GDAL_LIB=`$GDAL_CONFIG --libs`' '`$GDAL_CONFIG --dep-libs`
+  GDAL_INC=`$GDAL_CONFIG --cflags`
+
+fi
+
+AC_SUBST(GDAL_ENABLED,$GDAL_ENABLED)
+AC_SUBST(GDAL_INC,    $GDAL_INC)
+AC_SUBST(GDAL_LIB,    $GDAL_LIB)
+
+
+                     
+])
 DEBUG_CHECK
 
 AC_ARG_ENABLE(module,
@@ -463,7 +524,7 @@
 PNG_CHECK
 
 JPEG_CHECK
-
+GDAL_CHECK
 #PKGCONFIG_CHECK
 
 #CAIRO_CHECK

Modified: trunk/mapserver/mapcache/include/errors.h
===================================================================
--- trunk/mapserver/mapcache/include/errors.h	2011-08-26 11:04:45 UTC (rev 12179)
+++ trunk/mapserver/mapcache/include/errors.h	2011-08-26 11:04:53 UTC (rev 12180)
@@ -25,6 +25,7 @@
 GEOCACHE_HTTP_ERROR,
 GEOCACHE_IMAGE_ERROR,
 GEOCACHE_SOURCE_WMS_ERROR,
+GEOCACHE_SOURCE_GDAL_ERROR,
 GEOCACHE_TILESET_ERROR,
 GEOCACHE_MUTEX_ERROR,
 GEOCACHE_REQUEST_ERROR

Modified: trunk/mapserver/mapcache/include/geocache.h
===================================================================
--- trunk/mapserver/mapcache/include/geocache.h	2011-08-26 11:04:45 UTC (rev 12179)
+++ trunk/mapserver/mapcache/include/geocache.h	2011-08-26 11:04:53 UTC (rev 12180)
@@ -28,6 +28,10 @@
 #include <libxml/tree.h>
 #include "util.h"
 #include "errors.h"
+#ifdef USE_GDAL
+#include <gdal.h>
+#include <cpl_conv.h>
+#endif
 #include <assert.h>
 #include <apr_time.h>
 
@@ -56,6 +60,7 @@
 typedef struct geocache_tile geocache_tile;
 typedef struct geocache_metatile geocache_metatile;
 typedef struct geocache_source_wms geocache_source_wms;
+typedef struct geocache_source_gdal geocache_source_gdal;
 typedef struct geocache_cache_disk geocache_cache_disk;
 typedef struct geocache_request geocache_request;
 typedef struct geocache_service geocache_service;
@@ -182,7 +187,8 @@
 /** @{ */
 
 typedef enum {
-    GEOCACHE_SOURCE_WMS
+    GEOCACHE_SOURCE_WMS,
+    GEOCACHE_SOURCE_GDAL
 } geocache_source_type;
 
 /**\interface geocache_source
@@ -195,13 +201,6 @@
     geocache_source_type type;
     int supports_metatiling;
     /**
-     * \brief get the data for the tile
-     *
-     * sets the geocache_tile::data for the given tile
-     * \deprecated
-     */
-    void (*render_tile)(geocache_context *ctx, geocache_tile * tile);
-    /**
      * \brief get the data for the metatile
      *
      * sets the geocache_metatile::tile::data for the given tile
@@ -222,6 +221,18 @@
     apr_table_t *wms_params; /**< WMS parameters specified in configuration */
 };
 
+#ifdef USE_GDAL
+/**\class geocache_source_gdal
+ * \brief GDAL geocache_source
+ * \implements geocache_source
+ */
+struct geocache_source_gdal {
+    geocache_source source;
+    char *datastr; /**< the gdal source string*/
+    apr_table_t *gdal_params; /**< GDAL parameters specified in configuration */
+    GDALDatasetH *poDataset;
+};
+#endif
 /** @} */
 
 
@@ -496,6 +507,11 @@
 void geocache_source_init(geocache_context *ctx, geocache_source *source);
 
 /**
+ * \memberof geocache_source_gdal
+ */
+geocache_source* geocache_source_gdal_create(geocache_context *ctx);
+
+/**
  * \memberof geocache_source_wms
  */
 geocache_source* geocache_source_wms_create(geocache_context *ctx);

Modified: trunk/mapserver/mapcache/src/Makefile
===================================================================
--- trunk/mapserver/mapcache/src/Makefile	2011-08-26 11:04:45 UTC (rev 12179)
+++ trunk/mapserver/mapcache/src/Makefile	2011-08-26 11:04:53 UTC (rev 12180)
@@ -18,7 +18,7 @@
 mod_geocache.la: mod_geocache.o
 
 mod_geocache.o:  mod_geocache.c $(OBJS)
-	$(APXS) $(APXS_WCFLAGS) $(GC_LIBS) -c mod_geocache.c $(LOBJS)
+	$(APXS) $(APXS_WCFLAGS) $(APXS_WLDFLAGS) -c mod_geocache.c $(LOBJS)
 	
 geocache.fcgi: fastcgi_geocache.c $(OBJS)
 	$(LIBTOOL) --mode=link $(CC) -o geocache.fcgi $(GC_CFLAGS) $(APR_CFLAGS) $(FCGI_INC) fastcgi_geocache.c $(LOBJS) $(GC_LIBS) $(APR_LIBS) $(FCGI_LIB)

Modified: trunk/mapserver/mapcache/src/configuration.c
===================================================================
--- trunk/mapserver/mapcache/src/configuration.c	2011-08-26 11:04:45 UTC (rev 12179)
+++ trunk/mapserver/mapcache/src/configuration.c	2011-08-26 11:04:53 UTC (rev 12180)
@@ -125,6 +125,8 @@
    geocache_source *source = NULL;
    if(!strcmp(type,"wms")) {
       source = geocache_source_wms_create(ctx);
+   } else if(!strcmp(type,"gdal")) {
+      source = geocache_source_gdal_create(ctx);
    } else {
       ctx->set_error(ctx, GEOCACHE_PARSE_ERROR, "unknown source type %s for source \"%s\"", type, name);
       return;

Added: trunk/mapserver/mapcache/src/source_gdal.c
===================================================================
--- trunk/mapserver/mapcache/src/source_gdal.c	                        (rev 0)
+++ trunk/mapserver/mapcache/src/source_gdal.c	2011-08-26 11:04:53 UTC (rev 12180)
@@ -0,0 +1,108 @@
+/*
+ *  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.
+ */
+
+#include "geocache.h"
+#include <libxml/tree.h>
+#include <apr_tables.h>
+#include <apr_strings.h>
+
+#ifdef USE_GDAL
+/**
+ * \private \memberof geocache_source_gdal
+ * \sa geocache_source::render_metatile()
+ */
+void _geocache_source_gdal_render_metatile(geocache_context *ctx, geocache_metatile *tile) {
+   geocache_source_gdal *gdal = (geocache_source_gdal*)tile->tile.tileset->source;
+        
+   tile->tile.data = geocache_buffer_create(30000,ctx->pool);
+   GC_CHECK_ERROR(ctx);
+   
+   if(!geocache_imageio_is_valid_format(ctx,tile->tile.data)) {
+      char *returned_data = apr_pstrndup(ctx->pool,(char*)tile->tile.data->buf,tile->tile.data->size);
+      ctx->set_error(ctx, GEOCACHE_SOURCE_GDAL_ERROR, "gdal request for tileset %s: %d %d %d returned an unsupported format:\n%s",
+            tile->tile.tileset->name, tile->tile.x, tile->tile.y, tile->tile.z, returned_data);
+   }
+}
+
+/**
+ * \private \memberof geocache_source_gdal
+ * \sa geocache_source::configuration_parse()
+ */
+void _geocache_source_gdal_configuration_parse(geocache_context *ctx, xmlNode *xml, geocache_source *source) {
+   xmlNode *cur_node;
+   geocache_source_gdal *src = (geocache_source_gdal*)source;
+   for(cur_node = xml->children; cur_node; cur_node = cur_node->next) {
+      if(cur_node->type != XML_ELEMENT_NODE) continue;
+      if(!xmlStrcmp(cur_node->name, BAD_CAST "data")) {
+         char* value = (char*)xmlNodeGetContent(cur_node);
+         src->datastr = value;
+      } else if(!xmlStrcmp(cur_node->name, BAD_CAST "gdalparams")) {
+         xmlNode *param_node;
+         for(param_node = cur_node->children; param_node; param_node = param_node->next) {
+            char *key,*value;
+            if(param_node->type != XML_ELEMENT_NODE) continue;
+            value = (char*)xmlNodeGetContent(param_node);
+            key = apr_pstrdup(ctx->pool, (char*)param_node->name);
+            apr_table_setn(src->gdal_params, key, value);
+         }
+      }
+   }
+}
+
+/**
+ * \private \memberof geocache_source_gdal
+ * \sa geocache_source::configuration_check()
+ */
+void _geocache_source_gdal_configuration_check(geocache_context *ctx, geocache_source *source) {
+   geocache_source_gdal *src = (geocache_source_gdal*)source;
+   /* check all required parameters are configured */
+   if(!strlen(src->datastr)) {
+      ctx->set_error(ctx, GEOCACHE_SOURCE_GDAL_ERROR, "gdal source %s has no data",source->name);
+      return;
+   }
+   src->poDataset = (GDALDatasetH*)GDALOpen(src->datastr,GA_ReadOnly);
+   if( src->poDataset == NULL ) {
+      ctx->set_error(ctx, GEOCACHE_SOURCE_GDAL_ERROR, "gdalOpen failed on data %s", src->datastr);
+      return;
+   }
+   
+}
+#endif //USE_GDAL
+
+geocache_source* geocache_source_gdal_create(geocache_context *ctx) {
+#ifdef USE_GDAL
+   GDALAllRegister();
+   geocache_source_gdal *source = apr_pcalloc(ctx->pool, sizeof(geocache_source_gdal));
+   if(!source) {
+      ctx->set_error(ctx, GEOCACHE_ALLOC_ERROR, "failed to allocate gdal source");
+      return NULL;
+   }
+   geocache_source_init(ctx, &(source->source));
+   source->source.type = GEOCACHE_SOURCE_GDAL;
+   source->source.supports_metatiling = 1;
+   source->source.render_metatile = _geocache_source_gdal_render_metatile;
+   source->source.configuration_check = _geocache_source_gdal_configuration_check;
+   source->source.configuration_parse = _geocache_source_gdal_configuration_parse;
+   source->gdal_params = apr_table_make(ctx->pool,4);
+   return (geocache_source*)source;
+#else
+   ctx->set_error(ctx, GEOCACHE_SOURCE_GDAL_ERROR, "failed to create gdal source, GDAL support is not compiled in this version");
+   return NULL;
+#endif
+}
+
+
+

Modified: trunk/mapserver/mapcache/src/source_wms.c
===================================================================
--- trunk/mapserver/mapcache/src/source_wms.c	2011-08-26 11:04:45 UTC (rev 12179)
+++ trunk/mapserver/mapcache/src/source_wms.c	2011-08-26 11:04:53 UTC (rev 12180)
@@ -21,27 +21,6 @@
 
 /**
  * \private \memberof geocache_source_wms
- * \sa geocache_source::render_tile()
- */
-void _geocache_source_wms_render_tile(geocache_context *ctx, geocache_tile *tile) {
-   geocache_source_wms *wms = (geocache_source_wms*)tile->tileset->source;
-   apr_table_t *params = apr_table_clone(ctx->pool,wms->wms_default_params);
-   double bbox[4];
-   geocache_tileset_tile_bbox(tile,bbox);
-   apr_table_setn(params,"BBOX",apr_psprintf(ctx->pool,"%f,%f,%f,%f",bbox[0],bbox[1],bbox[2],bbox[3]));
-   apr_table_setn(params,"WIDTH",apr_psprintf(ctx->pool,"%d",tile->sx));
-   apr_table_setn(params,"HEIGHT",apr_psprintf(ctx->pool,"%d",tile->sy));
-   apr_table_setn(params,"FORMAT","image/png");
-   apr_table_setn(params,"SRS",tile->tileset->srs);
-   
-   apr_table_overlap(params,wms->wms_params,0);
-        
-   tile->data = geocache_buffer_create(1000,ctx->pool);
-   geocache_http_request_url_with_params(ctx,wms->url,params,tile->data);
-}
-
-/**
- * \private \memberof geocache_source_wms
  * \sa geocache_source::render_metatile()
  */
 void _geocache_source_wms_render_metatile(geocache_context *ctx, geocache_metatile *tile) {
@@ -116,7 +95,6 @@
    geocache_source_init(ctx, &(source->source));
    source->source.type = GEOCACHE_SOURCE_WMS;
    source->source.supports_metatiling = 1;
-   source->source.render_tile = _geocache_source_wms_render_tile;
    source->source.render_metatile = _geocache_source_wms_render_metatile;
    source->source.configuration_check = _geocache_source_wms_configuration_check;
    source->source.configuration_parse = _geocache_source_wms_configuration_parse;



More information about the mapserver-commits mailing list