[mapserver-commits] r12143 - in trunk/mapserver/mapcache: . include
src
svn at osgeo.org
svn at osgeo.org
Fri Aug 26 07:01:31 EDT 2011
Author: tbonfort
Date: 2011-08-26 04:01:31 -0700 (Fri, 26 Aug 2011)
New Revision: 12143
Modified:
trunk/mapserver/mapcache/include/geocache.h
trunk/mapserver/mapcache/mod_geocache.doxyfile
trunk/mapserver/mapcache/src/imageio_png.c
trunk/mapserver/mapcache/src/services.c
trunk/mapserver/mapcache/src/tileset.c
Log:
small optimisation for image blending
fix bug when computing quantized image
thomas.bonfort | 2010-10-26 18:03:47 +0200 (Tue, 26 Oct 2010)
Modified: trunk/mapserver/mapcache/include/geocache.h
===================================================================
--- trunk/mapserver/mapcache/include/geocache.h 2011-08-26 11:01:25 UTC (rev 12142)
+++ trunk/mapserver/mapcache/include/geocache.h 2011-08-26 11:01:31 UTC (rev 12143)
@@ -62,6 +62,7 @@
typedef struct geocache_request geocache_request;
typedef struct geocache_service geocache_service;
typedef struct geocache_service_wms geocache_service_wms;
+typedef struct geocache_service_wmts geocache_service_wmts;
typedef struct geocache_service_tms geocache_service_tms;
typedef struct geocache_server_cfg geocache_server_cfg;
typedef struct geocache_image geocache_image;
@@ -238,10 +239,12 @@
/** \defgroup services Services*/
/** @{ */
-#define GEOCACHE_SERVICES_COUNT 2
+#define GEOCACHE_SERVICES_COUNT 3
-typedef enum {GEOCACHE_SERVICE_WMS=0, GEOCACHE_SERVICE_TMS} geocache_service_type;
+typedef enum {GEOCACHE_SERVICE_WMTS=0, GEOCACHE_SERVICE_TMS, GEOCACHE_SERVICE_WMS} geocache_service_type;
+typedef enum {GEOCACHE_UNIT_UNSET = 0, GEOCACHE_UNIT_METERS, GEOCACHE_UNIT_DEGREES, GEOCACHE_UNIT_FEET} geocache_unit;
+
/** \interface geocache_service
* \brief a standard service (eg WMS, TMS)
*/
@@ -270,6 +273,14 @@
geocache_service service;
};
+/**\class geocache_service_wmts
+ * \brief a WMTS service
+ * \implements geocache_service
+ */
+struct geocache_service_wmts {
+ geocache_service service;
+};
+
/**
* \brief create and initialize a geocache_service_wms
* \memberof geocache_service_wms
@@ -282,6 +293,12 @@
*/
geocache_service* geocache_service_tms_create(apr_pool_t *pool);
+/**
+ * \brief create and initialize a geocache_service_wmts
+ * \memberof geocache_service_wmms
+ */
+geocache_service* geocache_service_wmts_create(apr_pool_t *pool);
+
/** @} */
/** \defgroup image Image Data Handling */
@@ -313,14 +330,17 @@
/**
\brief merge a set of tiles into a single image
\param tiles the list of tiles to merge
+ \param ntiles the number of tiles in the list of tiles
\param format the format to encode the resulting image
+ \param r the context
\returns a new tile with the merged image
*/
geocache_tile* geocache_image_merge_tiles(request_rec *r, geocache_image_format *format, geocache_tile **tiles, int ntiles);
/**
* \brief split the given metatile into tiles
- * @param mt the metatile to split
+ * \param mt the metatile to split
+ * \param r the context
*/
int geocache_image_metatile_split(geocache_metatile *mt, request_rec *r);
@@ -473,6 +493,11 @@
* the SRS of the tileset
*/
char *srs;
+
+ /**
+ * the unit of measure of the tileset
+ */
+ geocache_unit units;
/**
* width of a tile in pixels
@@ -545,6 +570,19 @@
*/
int geocache_tileset_tile_lookup(geocache_tile *tile, double *bbox, request_rec *r);
+/**
+ * compute level for a given resolution
+ *
+ * computes the integer level for the given resolution. the input resolution will be set to the exact
+ * value configured for the tileset, to compensate for rounding errors that could creep in if using
+ * the resolution calculated from input parameters
+ *
+ * \returns GEOCACHE_TILESET_WRONG_RESOLUTION if the given resolution is't configured
+ * \returns GEOCACHE_SUCCESS if the level was found
+ */
+int geocache_tileset_get_level(geocache_tileset *tileset, double *resolution, int *level, request_rec *r);
+
+
int geocache_tileset_tile_get(geocache_tile *tile, request_rec *r);
/**
@@ -586,6 +624,15 @@
/** @{ */
/**
+ * compression strategy to apply
+ */
+typedef enum {
+ GEOCACHE_COMPRESSION_BEST, /**< best but slowest compression*/
+ GEOCACHE_COMPRESSION_FAST, /**< fast compression*/
+ GEOCACHE_COMPRESSION_DEFAULT /**< default compression*/
+} geocache_compression_type;
+
+/**\interface geocache_image_format
* \brief an image format
* \sa geocache_image_format_jpeg
* \sa geocache_image_format_png
@@ -603,16 +650,7 @@
* \ingroup imageio */
/** @{ */
-/**
- * compression strategy to apply
- */
-typedef enum {
- GEOCACHE_COMPRESSION_BEST, /**< best but slowest compression*/
- GEOCACHE_COMPRESSION_FAST, /**< fast compression*/
- GEOCACHE_COMPRESSION_DEFAULT /**< default compression*/
-} geocache_compression_type;
-
-/**
+/**\class geocache_image_format_png
* \brief PNG image format
* \extends geocache_image_format
* \sa geocache_image_format_png_q
@@ -622,7 +660,7 @@
geocache_compression_type compression_level; /**< PNG compression level to apply */
};
-/**
+/**\class geocache_image_format_png_q
* \brief Quantized PNG format
* \extends geocache_image_format_png
*/
@@ -641,7 +679,7 @@
/**
* \brief create a format capable of creating RGBA png
- * \memberof geocache_imageio_png_format
+ * \memberof geocache_image_format_png
* @param pool
* @param name
* @param compression the ZLIB compression to apply
@@ -651,7 +689,7 @@
/**
* \brief create a format capable of creating quantized png
- * \memberof geocache_imageio_png_q_format
+ * \memberof geocache_image_format_png_q
* @param pool
* @param name
* @param compression the ZLIB compression to apply
@@ -666,7 +704,7 @@
* \ingroup imageio */
/** @{ */
-/**
+/**\class geocache_image_format_jpeg
* \brief JPEG image format
* \extends geocache_image_format
*/
Modified: trunk/mapserver/mapcache/mod_geocache.doxyfile
===================================================================
--- trunk/mapserver/mapcache/mod_geocache.doxyfile 2011-08-26 11:01:25 UTC (rev 12142)
+++ trunk/mapserver/mapcache/mod_geocache.doxyfile 2011-08-26 11:01:31 UTC (rev 12143)
@@ -298,7 +298,7 @@
# Private class members and static file members will be hidden unless
# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
-EXTRACT_ALL = YES
+EXTRACT_ALL = NO
# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
# will be included in the documentation.
@@ -308,7 +308,7 @@
# If the EXTRACT_STATIC tag is set to YES all static members of a file
# will be included in the documentation.
-EXTRACT_STATIC = NO
+EXTRACT_STATIC = YES
# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
# defined locally in source files will be included in the documentation.
@@ -337,14 +337,14 @@
# various overviews, but no documentation section is generated.
# This option has no effect if EXTRACT_ALL is enabled.
-HIDE_UNDOC_MEMBERS = NO
+HIDE_UNDOC_MEMBERS = YES
# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
# undocumented classes that are normally visible in the class hierarchy.
# If set to NO (the default) these classes will be included in the various
# overviews. This option has no effect if EXTRACT_ALL is enabled.
-HIDE_UNDOC_CLASSES = NO
+HIDE_UNDOC_CLASSES = YES
# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
# friend (class|struct|union) declarations.
@@ -1458,7 +1458,7 @@
# this option also works with HAVE_DOT disabled, but it is recommended to
# install and use dot, since it yields more powerful graphs.
-CLASS_DIAGRAMS = YES
+CLASS_DIAGRAMS = NO
# You can define message sequence charts within doxygen comments using the \msc
# command. Doxygen will then run the mscgen tool (see
@@ -1480,7 +1480,7 @@
# toolkit from AT&T and Lucent Bell Labs. The other options in this section
# have no effect if this option is set to NO (the default)
-HAVE_DOT = NO
+HAVE_DOT = YES
# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is
# allowed to run in parallel. When set to 0 (the default) doxygen will
Modified: trunk/mapserver/mapcache/src/imageio_png.c
===================================================================
--- trunk/mapserver/mapcache/src/imageio_png.c 2011-08-26 11:01:25 UTC (rev 12142)
+++ trunk/mapserver/mapcache/src/imageio_png.c 2011-08-26 11:01:31 UTC (rev 12143)
@@ -188,6 +188,8 @@
return buffer;
}
+/** \cond DONOTDOCUMENT */
+
/*
* derivations from pngquant and ppmquant
*
@@ -954,6 +956,8 @@
free( (char*) acht );
}
+/** \endcond DONOTDOCUMENT */
+
int _geocache_imageio_remap_palette(unsigned char *pixels, int npixels, rgbaPixel *palette, int numPaletteEntries, rgbPixel *rgb, unsigned char *a, int *num_a) {
int bot_idx, top_idx, x;
int remap[256];
Modified: trunk/mapserver/mapcache/src/services.c
===================================================================
--- trunk/mapserver/mapcache/src/services.c 2011-08-26 11:01:25 UTC (rev 12142)
+++ trunk/mapserver/mapcache/src/services.c 2011-08-26 11:01:31 UTC (rev 12143)
@@ -8,6 +8,7 @@
#include "geocache.h"
#include <http_log.h>
#include <apr_strings.h>
+#include <math.h>
/** \addtogroup services */
/** @{ */
@@ -84,6 +85,91 @@
}
+geocache_request* _geocache_service_wmts_parse_request(request_rec *r, apr_table_t *params, geocache_cfg *config) {
+ char *str = NULL;
+ double scale,res;
+ int tilerow,tilecol;
+ char *endptr;
+ int maxY;
+ double geocache_meters_per_unit[] = {
+ -1, /*GEOCACHE_UNIT_UNSET*/
+ 1.0, /*GEOCACHE_UNIT_METERS*/
+ 111118.752, /*GEOCACHE_UNIT_DEGREES*/
+ 0.3048 /*GEOCACHE_UNIT_FEET*/
+ };
+ geocache_request *request = NULL;
+
+ str = (char*)apr_table_get(params,"SCALE");
+ if(!str)
+ str = (char*)apr_table_get(params,"scale");
+ if(!str) {
+ return NULL;
+ } else {
+ scale = strtod(str,&endptr);
+ if(*endptr != 0) {
+ ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, "received wmts request with invalid scale %s", str);
+ return NULL;
+ }
+ }
+
+ str = (char*)apr_table_get(params,"TILEROW");
+ if(!str)
+ str = (char*)apr_table_get(params,"tilerow");
+ if(!str) {
+ return NULL;
+ } else {
+ tilerow = strtol(str,&endptr,10);
+ if(*endptr != 0) {
+ ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, "received wmts request with invalid tilerow %s", str);
+ return NULL;
+ }
+ }
+
+ str = (char*)apr_table_get(params,"TILECOL");
+ if(!str)
+ str = (char*)apr_table_get(params,"tilecol");
+ if(!str) {
+ return NULL;
+ } else {
+ tilecol = strtol(str,&endptr,10);
+ if(*endptr != 0) {
+ ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, "received wmts request with invalid tilecol %s", str);
+ return NULL;
+ }
+ }
+ str = (char*)apr_table_get(params,"LAYER");
+ if(!str)
+ str = (char*)apr_table_get(params,"layer");
+ if(!str) {
+ ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, "received wmts request with no layer");
+ return NULL;
+ } else {
+ geocache_tileset *tileset = geocache_configuration_get_tileset(config,str);
+ if(!tileset) {
+ ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, "received wmts request with invalid layer %s",str);
+ return NULL;
+ }
+ if(tileset->units == GEOCACHE_UNIT_UNSET) {
+ ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, "received wmts on layer %s that has no unit configured",str);
+ return NULL;
+ }
+ request = (geocache_request*)apr_pcalloc(r->pool,sizeof(geocache_request));
+ request->ntiles = 1;
+ request->tiles = (geocache_tile**)apr_pcalloc(r->pool,sizeof(geocache_tile*));
+ request->tiles[0] = geocache_tileset_tile_create(tileset,r->pool);
+ res = .00028 * scale / geocache_meters_per_unit[tileset->units];
+ if(GEOCACHE_SUCCESS != geocache_tileset_get_level(tileset, &res, &request->tiles[0]->z, r)) {
+ ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r, "received wmts on layer %s with invalid resolution / level", tileset->name);
+ return NULL;
+ }
+
+ maxY = round((tileset->extent[3] - tileset->extent[1])/(res * tileset->tile_sy)) -1;
+ request->tiles[0]->x = tilecol;
+ request->tiles[0]->y = maxY - tilerow;
+ return request;
+ }
+}
+
/**
* \brief parse a TMS request
* \private \memberof geocache_service_tms
@@ -170,6 +256,13 @@
return (geocache_service*)service;
}
+geocache_service* geocache_service_wmts_create(apr_pool_t *pool) {
+ geocache_service_wmts* service = (geocache_service_wmts*)apr_pcalloc(pool, sizeof(geocache_service_wmts));
+ service->service.type = GEOCACHE_SERVICE_WMTS;
+ service->service.parse_request = _geocache_service_wmts_parse_request;
+ return (geocache_service*)service;
+}
+
/** @} */
Modified: trunk/mapserver/mapcache/src/tileset.c
===================================================================
--- trunk/mapserver/mapcache/src/tileset.c 2011-08-26 11:01:25 UTC (rev 12142)
+++ trunk/mapserver/mapcache/src/tileset.c 2011-08-26 11:01:31 UTC (rev 12143)
@@ -16,7 +16,7 @@
return GEOCACHE_MAX(rx,ry);
}
-static int _geocache_tileset_get_level(geocache_tileset *tileset, double *resolution, int *level, request_rec *r) {
+int geocache_tileset_get_level(geocache_tileset *tileset, double *resolution, int *level, request_rec *r) {
double max_diff = *resolution / (double)GEOCACHE_MAX(tileset->tile_sx, tileset->tile_sy);
int i;
for(i=0; i<tileset->levels; i++) {
@@ -38,7 +38,7 @@
static int _geocache_tileset_tile_get_cell(geocache_tile *tile, double *bbox, request_rec *r) {
int ret;
double res = _geocache_tileset_get_resolution(tile->tileset,bbox);
- ret = _geocache_tileset_get_level(tile->tileset,&res,&(tile->z),r);
+ ret = geocache_tileset_get_level(tile->tileset,&res,&(tile->z),r);
if(ret != GEOCACHE_SUCCESS) return ret;
/* TODO: strict mode
if exact and self.extent_type == "strict" and not self.contains((minx, miny), res):
@@ -161,6 +161,7 @@
geocache_tileset* tileset = (geocache_tileset*)apr_pcalloc(pool, sizeof(geocache_tileset));
tileset->metasize_x = tileset->metasize_y = 1;
tileset->metabuffer = 0;
+ tileset->units = GEOCACHE_UNIT_UNSET;
tileset->expires = 0;
tileset->tile_sx = tileset->tile_sy = 256;
tileset->extent[0]=tileset->extent[1]=tileset->extent[2]=tileset->extent[3]=0;
More information about the mapserver-commits
mailing list