[mapserver-commits] r12173 - trunk/mapserver/mapcache/src

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


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

Modified:
   trunk/mapserver/mapcache/src/cache_disk.c
   trunk/mapserver/mapcache/src/configuration.c
   trunk/mapserver/mapcache/src/fastcgi_geocache.c
   trunk/mapserver/mapcache/src/imageio.c
   trunk/mapserver/mapcache/src/imageio_png.c
   trunk/mapserver/mapcache/src/mod_geocache.c
   trunk/mapserver/mapcache/src/services.c
   trunk/mapserver/mapcache/src/source.c
   trunk/mapserver/mapcache/src/source_wms.c
   trunk/mapserver/mapcache/src/tileset.c
Log:
allow seeder to take in a single zoom level
thomas.bonfort | 2010-12-09 19:03:52 +0100 (Thu, 09 Dec 2010)

Modified: trunk/mapserver/mapcache/src/cache_disk.c
===================================================================
--- trunk/mapserver/mapcache/src/cache_disk.c	2011-08-26 11:04:11 UTC (rev 12172)
+++ trunk/mapserver/mapcache/src/cache_disk.c	2011-08-26 11:04:18 UTC (rev 12173)
@@ -1,8 +1,17 @@
 /*
- * disk_cache.c
+ *  Copyright 2010 Thomas Bonfort
  *
- *  Created on: Oct 10, 2010
- *      Author: tom
+ *  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"

Modified: trunk/mapserver/mapcache/src/configuration.c
===================================================================
--- trunk/mapserver/mapcache/src/configuration.c	2011-08-26 11:04:11 UTC (rev 12172)
+++ trunk/mapserver/mapcache/src/configuration.c	2011-08-26 11:04:18 UTC (rev 12173)
@@ -1,3 +1,19 @@
+/*
+ *  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/parser.h>
 #include <libxml/tree.h>

Modified: trunk/mapserver/mapcache/src/fastcgi_geocache.c
===================================================================
--- trunk/mapserver/mapcache/src/fastcgi_geocache.c	2011-08-26 11:04:11 UTC (rev 12172)
+++ trunk/mapserver/mapcache/src/fastcgi_geocache.c	2011-08-26 11:04:18 UTC (rev 12173)
@@ -35,22 +35,6 @@
    FCGX_Stream *err;
 };
 
-void fcgi_context_set_error(geocache_context *c, geocache_error_code code, char *message, ...) {
-   va_list args;
-   va_start(args,message);
-   c->_errmsg = apr_pvsprintf(c->pool,message,args);
-   c->_errcode = code;
-}
-
-
-int fcgi_context_get_error(geocache_context *c) {
-   return c->_errcode;
-}
-
-char* fcgi_context_get_error_message(geocache_context *c) {
-   return c->_errmsg;
-}
-
 void fcgi_context_log(geocache_context *c, geocache_log_level level, char *message, ...) {
    va_list args;
    va_start(args,message);
@@ -63,8 +47,6 @@
    FCGX_FPrintF(((geocache_context_fcgi_request*)c)->err,"%s\n",apr_pvsprintf(c->pool,message,args));
 }
 
-
-
 void init_fcgi_context(geocache_context_fcgi *ctx) {
    geocache_context_init((geocache_context*)ctx);
    ctx->ctx.log = fcgi_context_log;
@@ -101,8 +83,13 @@
 static geocache_context_fcgi* fcgi_context_create() {
    int ret;
    apr_pool_t *pool;
-   apr_pool_create_core(&pool);
+   if(apr_pool_create_core(&pool) != APR_SUCCESS) {
+      return NULL;
+   }
    geocache_context_fcgi *ctx = apr_pcalloc(pool, sizeof(geocache_context_fcgi));
+   if(!ctx) {
+      return NULL;
+   }
    ctx->ctx.pool = pool;
    init_fcgi_context(ctx);
    ctx->ctx.log(ctx,GEOCACHE_DEBUG,"before mutex");

Modified: trunk/mapserver/mapcache/src/imageio.c
===================================================================
--- trunk/mapserver/mapcache/src/imageio.c	2011-08-26 11:04:11 UTC (rev 12172)
+++ trunk/mapserver/mapcache/src/imageio.c	2011-08-26 11:04:18 UTC (rev 12173)
@@ -22,12 +22,12 @@
 /** @{ */
 
 int geocache_imageio_image_has_alpha(geocache_image *img) {
-   int i,j;
+   size_t i,j;
    unsigned char *ptr, *rptr = img->data;
    for(i=0;i<img->h;i++) {     
       ptr = rptr;
       for(j=0;j<img->w;j++) {
-         if(ptr[3]<255)
+         if(ptr[3]<(unsigned char)255)
             return 1;
          ptr += 4;
       }
@@ -36,8 +36,8 @@
    return 0;
 }
 
-int geocache_imageio_is_valid_format(geocache_context *r, geocache_buffer *buffer) {
-   geocache_image_format_type t = geocache_imageio_header_sniff(r,buffer);
+int geocache_imageio_is_valid_format(geocache_context *ctx, geocache_buffer *buffer) {
+   geocache_image_format_type t = geocache_imageio_header_sniff(ctx,buffer);
    if(t==GC_PNG || t==GC_JPEG) {
       return GEOCACHE_TRUE;
    } else {
@@ -45,7 +45,7 @@
    }
 }
 
-geocache_image_format_type geocache_imageio_header_sniff(geocache_context *r, geocache_buffer *buffer) {
+geocache_image_format_type geocache_imageio_header_sniff(geocache_context *ctx, geocache_buffer *buffer) {
    if(!buffer) {
       return GC_UNKNOWN;
    }
@@ -60,14 +60,14 @@
 
 
 
-geocache_image* geocache_imageio_decode(geocache_context *r, geocache_buffer *buffer) {
-   geocache_image_format_type type = geocache_imageio_header_sniff(r,buffer);
+geocache_image* geocache_imageio_decode(geocache_context *ctx, geocache_buffer *buffer) {
+   geocache_image_format_type type = geocache_imageio_header_sniff(ctx,buffer);
    if(type == GC_PNG) {
-      return _geocache_imageio_png_decode(r,buffer);
+      return _geocache_imageio_png_decode(ctx,buffer);
    } else if(type == GC_JPEG) {
-      return _geocache_imageio_jpeg_decode(r,buffer);
+      return _geocache_imageio_jpeg_decode(ctx,buffer);
    } else {
-      r->set_error(r, GEOCACHE_IMAGE_ERROR, "geocache_imageio_decode: unrecognized image format");
+      ctx->set_error(ctx, GEOCACHE_IMAGE_ERROR, "geocache_imageio_decode: unrecognized image format");
       return NULL;
    }
 }

Modified: trunk/mapserver/mapcache/src/imageio_png.c
===================================================================
--- trunk/mapserver/mapcache/src/imageio_png.c	2011-08-26 11:04:11 UTC (rev 12172)
+++ trunk/mapserver/mapcache/src/imageio_png.c	2011-08-26 11:04:18 UTC (rev 12173)
@@ -103,7 +103,7 @@
       return NULL;
    }
 #endif
-   
+
    png_read_image(png_ptr, row_pointers);
    
    png_read_end(png_ptr,NULL);
@@ -124,7 +124,7 @@
    geocache_buffer *buffer = NULL;
    int compression = ((geocache_image_format_png*)format)->compression_level;
    png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL,NULL,NULL);
-
+   ctx->log(ctx,GEOCACHE_DEBUG,"png no palette");
    if (!png_ptr) {
       ctx->set_error(ctx, GEOCACHE_IMAGE_ERROR, "failed to allocate png_struct structure");
       return NULL;
@@ -1025,11 +1025,6 @@
    png_set_write_fn(png_ptr,buffer, _geocache_imageio_png_write_func, _geocache_imageio_png_flush_func);
 
 
-   if(compression == GEOCACHE_COMPRESSION_BEST)
-      png_set_compression_level (png_ptr, Z_BEST_COMPRESSION);
-   else if(compression == GEOCACHE_COMPRESSION_FAST)
-      png_set_compression_level (png_ptr, Z_BEST_SPEED);
-
    if (numPaletteEntries <= 2)
       sample_depth = 1;
    else if (numPaletteEntries <= 4)
@@ -1044,14 +1039,21 @@
          0, PNG_COMPRESSION_TYPE_DEFAULT,
          PNG_FILTER_TYPE_DEFAULT);
 
+   if(compression == GEOCACHE_COMPRESSION_BEST)
+      png_set_compression_level (png_ptr, Z_BEST_COMPRESSION);
+   else if(compression == GEOCACHE_COMPRESSION_FAST)
+      png_set_compression_level (png_ptr, Z_BEST_SPEED);
+   
    _geocache_imageio_remap_palette(pixels, image->w * image->h, palette, numPaletteEntries,rgb,a,&num_a);
+   
+   ctx->log(ctx,GEOCACHE_DEBUG,"png palette: %d %d\n",numPaletteEntries,num_a);
 
    png_set_PLTE(png_ptr, info_ptr, (png_colorp)(rgb),numPaletteEntries);
    if(num_a)
       png_set_tRNS(png_ptr, info_ptr, a,num_a, NULL);
 
    png_write_info(png_ptr, info_ptr);
-   png_set_packing(png_ptr);
+   //png_set_packing(png_ptr);
 
    for(row=0;row<image->h;row++) {
       unsigned char *rowptr = &(pixels[row*image->w]);

Modified: trunk/mapserver/mapcache/src/mod_geocache.c
===================================================================
--- trunk/mapserver/mapcache/src/mod_geocache.c	2011-08-26 11:04:11 UTC (rev 12172)
+++ trunk/mapserver/mapcache/src/mod_geocache.c	2011-08-26 11:04:18 UTC (rev 12173)
@@ -212,7 +212,6 @@
       tile = request->tiles[0];
    } else {
       /* TODO: individual check on tiles if merging is allowed */
-
       tile = (geocache_tile*)geocache_image_merge_tiles(global_ctx,config->merge_format,request->tiles,request->ntiles);
       if(!tile) {
          ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "tile merging failed to return data");

Modified: trunk/mapserver/mapcache/src/services.c
===================================================================
--- trunk/mapserver/mapcache/src/services.c	2011-08-26 11:04:11 UTC (rev 12172)
+++ trunk/mapserver/mapcache/src/services.c	2011-08-26 11:04:18 UTC (rev 12173)
@@ -1,8 +1,17 @@
 /*
- * services.c
+ *  Copyright 2010 Thomas Bonfort
  *
- *  Created on: Oct 11, 2010
- *      Author: tom
+ *  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"

Modified: trunk/mapserver/mapcache/src/source.c
===================================================================
--- trunk/mapserver/mapcache/src/source.c	2011-08-26 11:04:11 UTC (rev 12172)
+++ trunk/mapserver/mapcache/src/source.c	2011-08-26 11:04:18 UTC (rev 12173)
@@ -1,10 +1,18 @@
 /*
- * source.c
+ *  Copyright 2010 Thomas Bonfort
  *
- *  Created on: Oct 10, 2010
- *      Author: tom
+ *  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"
 
 void geocache_source_init(geocache_context *ctx, geocache_source *source) {

Modified: trunk/mapserver/mapcache/src/source_wms.c
===================================================================
--- trunk/mapserver/mapcache/src/source_wms.c	2011-08-26 11:04:11 UTC (rev 12172)
+++ trunk/mapserver/mapcache/src/source_wms.c	2011-08-26 11:04:18 UTC (rev 12173)
@@ -1,3 +1,19 @@
+/*
+ *  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>
@@ -45,7 +61,7 @@
    GC_CHECK_ERROR(ctx);
    
    if(!geocache_imageio_is_valid_format(ctx,tile->tile.data)) {
-      ctx->set_error(ctx, GEOCACHE_SOURCE_WMS, "wms request failed for tileset %s: %d %d %d returned an unsupported format",
+      ctx->set_error(ctx, GEOCACHE_SOURCE_WMS_ERROR, "wms request failed for tileset %s: %d %d %d returned an unsupported format",
             tile->tile.tileset->name, tile->tile.x, tile->tile.y, tile->tile.z);
    }
 }
@@ -83,10 +99,10 @@
    geocache_source_wms *src = (geocache_source_wms*)source;
    /* check all required parameters are configured */
    if(!strlen(src->url)) {
-      ctx->set_error(ctx, GEOCACHE_SOURCE_WMS, "wms source %s has no url",source->name);
+      ctx->set_error(ctx, GEOCACHE_SOURCE_WMS_ERROR, "wms source %s has no url",source->name);
    }
    if(!apr_table_get(src->wms_params,"LAYERS")) {
-      ctx->set_error(ctx, GEOCACHE_SOURCE_WMS, "wms source %s has no LAYERS", source->name);
+      ctx->set_error(ctx, GEOCACHE_SOURCE_WMS_ERROR, "wms source %s has no LAYERS", source->name);
    }
 }
 

Modified: trunk/mapserver/mapcache/src/tileset.c
===================================================================
--- trunk/mapserver/mapcache/src/tileset.c	2011-08-26 11:04:11 UTC (rev 12172)
+++ trunk/mapserver/mapcache/src/tileset.c	2011-08-26 11:04:18 UTC (rev 12173)
@@ -1,8 +1,17 @@
 /*
- * tileset.c
+ *  Copyright 2010 Thomas Bonfort
  *
- *  Created on: Oct 11, 2010
- *      Author: tom
+ *  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"
@@ -43,8 +52,8 @@
                         % (minx, miny, self.bbox))
                return None
     */
-   tile->x = (int)((bbox[0] - tile->tileset->extent[0]) / (res * tile->tileset->tile_sx));
-   tile->y = (int)((bbox[1] - tile->tileset->extent[1]) / (res * tile->tileset->tile_sy));
+   tile->x = (int)round((bbox[0] - tile->tileset->extent[0]) / (res * tile->tileset->tile_sx));
+   tile->y = (int)round((bbox[1] - tile->tileset->extent[1]) / (res * tile->tileset->tile_sy));
 
    if((fabs(bbox[0] - (tile->x * res * tile->tileset->tile_sx) - tile->tileset->extent[0] ) / res > 1) ||
          (fabs(bbox[1] - (tile->y * res * tile->tileset->tile_sy) - tile->tileset->extent[1] ) / res > 1)) {
@@ -272,7 +281,6 @@
 #endif
          /* this will query the source to create the tiles, and save them to the cache */
          _geocache_tileset_render_metatile(ctx, mt);
-         GC_CHECK_ERROR(ctx);
          
          /* remove the lockfiles */
          ctx->global_lock_aquire(ctx,0);



More information about the mapserver-commits mailing list