[mapserver-commits] r12488 - in trunk/mapserver/mapcache: include
src
svn at osgeo.org
svn at osgeo.org
Fri Aug 26 07:31:13 EDT 2011
Author: tbonfort
Date: 2011-08-26 04:31:13 -0700 (Fri, 26 Aug 2011)
New Revision: 12488
Modified:
trunk/mapserver/mapcache/include/geocache.h
trunk/mapserver/mapcache/src/configuration_xml.c
trunk/mapserver/mapcache/src/geocache_seed.c
trunk/mapserver/mapcache/src/grid.c
Log:
Modified: trunk/mapserver/mapcache/include/geocache.h
===================================================================
--- trunk/mapserver/mapcache/include/geocache.h 2011-08-26 11:31:04 UTC (rev 12487)
+++ trunk/mapserver/mapcache/include/geocache.h 2011-08-26 11:31:13 UTC (rev 12488)
@@ -1262,9 +1262,22 @@
double geocache_grid_get_horizontal_resolution(double *bbox, int width);
double geocache_grid_get_vertical_resolution(double *bbox, int height);
+/**
+ * \brief compute grid level given a resolution
+ * \param grid
+ * \param resolution
+ * \param level
+ */
int geocache_grid_get_level(geocache_context *ctx, geocache_grid *grid, double *resolution, int *level);
-void geocache_grid_compute_limits(const geocache_grid *grid, const double *extent, int **limits);
+/**
+ * \brief precompute min/max x/y values for the given extent
+ * \param grid
+ * \param extent
+ * \param tolerance the number of tiles around the given extent that can be requested without returning an error.
+ */
+void geocache_grid_compute_limits(const geocache_grid *grid, const double *extent, int **limits, int tolerance);
+
/* in util.c */
int geocache_util_extract_int_list(geocache_context *ctx, const char* args, const char *sep, int **numbers,
int *numbers_count);
Modified: trunk/mapserver/mapcache/src/configuration_xml.c
===================================================================
--- trunk/mapserver/mapcache/src/configuration_xml.c 2011-08-26 11:31:04 UTC (rev 12487)
+++ trunk/mapserver/mapcache/src/configuration_xml.c 2011-08-26 11:31:13 UTC (rev 12488)
@@ -483,7 +483,7 @@
for(cur_node = ezxml_child(node,"grid"); cur_node; cur_node = cur_node->next) {
int i;
- char *restrictedExtent = NULL;
+ char *restrictedExtent = NULL, *sTolerance = NULL;
if (tileset->grid_links == NULL) {
tileset->grid_links = apr_array_make(ctx->pool,1,sizeof(geocache_grid_link*));
}
@@ -516,7 +516,20 @@
} else {
extent = grid->extent;
}
- geocache_grid_compute_limits(grid,extent,gridlink->grid_limits);
+
+ int tolerance = 5;
+ sTolerance = (char*)ezxml_attr(cur_node,"tolerance");
+ if(sTolerance) {
+ char *endptr;
+ tolerance = (int)strtol(sTolerance,&endptr,10);
+ if(*endptr != 0 || tolerance < 0) {
+ ctx->set_error(ctx, 400, "failed to parse grid tolerance %s (expecting a positive integer)",
+ sTolerance);
+ return;
+ }
+ }
+
+ geocache_grid_compute_limits(grid,extent,gridlink->grid_limits,tolerance);
/* compute wgs84 bbox if it wasn't supplied already */
if(!havewgs84bbox && !strcasecmp(grid->srs,"EPSG:4326")) {
Modified: trunk/mapserver/mapcache/src/geocache_seed.c
===================================================================
--- trunk/mapserver/mapcache/src/geocache_seed.c 2011-08-26 11:31:04 UTC (rev 12487)
+++ trunk/mapserver/mapcache/src/geocache_seed.c 2011-08-26 11:31:13 UTC (rev 12488)
@@ -647,7 +647,7 @@
if(extent) {
// update the grid limits
- geocache_grid_compute_limits(grid_link->grid,extent,grid_link->grid_limits);
+ geocache_grid_compute_limits(grid_link->grid,extent,grid_link->grid_limits,0);
}
/* adjust our grid limits so they align on the metatile limits
Modified: trunk/mapserver/mapcache/src/grid.c
===================================================================
--- trunk/mapserver/mapcache/src/grid.c 2011-08-26 11:31:04 UTC (rev 12487)
+++ trunk/mapserver/mapcache/src/grid.c 2011-08-26 11:31:13 UTC (rev 12488)
@@ -59,7 +59,8 @@
const char* geocache_grid_get_srs(geocache_context *ctx, geocache_grid *grid) {
return (const char*)grid->srs;
}
-void geocache_grid_compute_limits(const geocache_grid *grid, const double *extent, int **limits) {
+
+void geocache_grid_compute_limits(const geocache_grid *grid, const double *extent, int **limits, int tolerance) {
int i;
double epsilon = 0.0000001;
for(i=0;i<grid->nlevels;i++) {
@@ -70,10 +71,10 @@
level->maxy = ceil((grid->extent[3]-grid->extent[1] - 0.01* unitheight)/unitheight);
level->maxx = ceil((grid->extent[2]-grid->extent[0] - 0.01* unitwidth)/unitwidth);
- limits[i][0] = floor((extent[0] - grid->extent[0]) / unitwidth + epsilon);
- limits[i][2] = ceil((extent[2] - grid->extent[0]) / unitwidth - epsilon);
- limits[i][1] = floor((extent[1] - grid->extent[1]) / unitheight + epsilon);
- limits[i][3] = ceil((extent[3] - grid->extent[1]) / unitheight - epsilon);
+ limits[i][0] = floor((extent[0] - grid->extent[0]) / unitwidth + epsilon) - tolerance;
+ limits[i][2] = ceil((extent[2] - grid->extent[0]) / unitwidth - epsilon) + tolerance;
+ limits[i][1] = floor((extent[1] - grid->extent[1]) / unitheight + epsilon) - tolerance;
+ limits[i][3] = ceil((extent[3] - grid->extent[1]) / unitheight - epsilon) + tolerance;
// to avoid requesting out-of-range tiles
if (limits[i][0] < 0) limits[i][0] = 0;
if (limits[i][2] > level->maxx) limits[i][2] = level->maxx;
More information about the mapserver-commits
mailing list