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

svn at osgeo.org svn at osgeo.org
Wed Oct 26 06:21:27 EDT 2011


Author: tbonfort
Date: 2011-10-26 03:21:27 -0700 (Wed, 26 Oct 2011)
New Revision: 12699

Modified:
   trunk/mapserver/mapcache/src/configuration.c
   trunk/mapserver/mapcache/src/configuration_xml.c
   trunk/mapserver/mapcache/src/grid.c
Log:
compute grid limits even for grids not included by a tileset (to create correct capabilities doc)


Modified: trunk/mapserver/mapcache/src/configuration.c
===================================================================
--- trunk/mapserver/mapcache/src/configuration.c	2011-10-26 10:14:52 UTC (rev 12698)
+++ trunk/mapserver/mapcache/src/configuration.c	2011-10-26 10:21:27 UTC (rev 12699)
@@ -144,6 +144,7 @@
    
    double wgs84_extent[4]={-180,-90,180,90};
    double google_extent[4]={-20037508.3427892480,-20037508.3427892480,20037508.3427892480,20037508.3427892480};
+   double unitwidth,unitheight;
 
    mapcache_cfg *cfg = (mapcache_cfg*)apr_pcalloc(pool, sizeof(mapcache_cfg));
    cfg->caches = apr_hash_make(pool);
@@ -183,6 +184,11 @@
    for(i=0; i<grid->nlevels; i++) {
       mapcache_grid_level *level = (mapcache_grid_level*)apr_pcalloc(pool,sizeof(mapcache_grid_level));
       level->resolution = wgs84_resolutions[i];
+      unitheight = grid->tile_sy * level->resolution;
+      unitwidth = grid->tile_sx * level->resolution;
+
+      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);
       grid->levels[i] = level;
    }
    mapcache_configuration_add_grid(cfg,grid,"WGS84");
@@ -206,6 +212,11 @@
    for(i=0; i<grid->nlevels; i++) {
       mapcache_grid_level *level = (mapcache_grid_level*)apr_pcalloc(pool,sizeof(mapcache_grid_level));
       level->resolution = google_resolutions[i];
+      unitheight = grid->tile_sy * level->resolution;
+      unitwidth = grid->tile_sx * level->resolution;
+
+      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);
       grid->levels[i] = level;
    }
    mapcache_configuration_add_grid(cfg,grid,"GoogleMapsCompatible");
@@ -229,6 +240,11 @@
    for(i=0; i<grid->nlevels; i++) {
       mapcache_grid_level *level = (mapcache_grid_level*)apr_pcalloc(pool,sizeof(mapcache_grid_level));
       level->resolution = google_resolutions[i];
+      unitheight = grid->tile_sy * level->resolution;
+      unitwidth = grid->tile_sx * level->resolution;
+
+      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);
       grid->levels[i] = level;
    }
    mapcache_configuration_add_grid(cfg,grid,"g");

Modified: trunk/mapserver/mapcache/src/configuration_xml.c
===================================================================
--- trunk/mapserver/mapcache/src/configuration_xml.c	2011-10-26 10:14:52 UTC (rev 12698)
+++ trunk/mapserver/mapcache/src/configuration_xml.c	2011-10-26 10:21:27 UTC (rev 12699)
@@ -204,9 +204,13 @@
       grid->levels = (mapcache_grid_level**)apr_pcalloc(ctx->pool,
             grid->nlevels*sizeof(mapcache_grid_level));
       while(nvalues--) {
-         grid->levels[nvalues] = (mapcache_grid_level*)apr_pcalloc(ctx->pool,
-               sizeof(mapcache_grid_level));
-         grid->levels[nvalues]->resolution = values[nvalues];
+         mapcache_grid_level *level = (mapcache_grid_level*)apr_pcalloc(ctx->pool,sizeof(mapcache_grid_level));
+         level->resolution = values[nvalues];
+         double unitheight = grid->tile_sy * level->resolution;
+         double unitwidth = grid->tile_sx * level->resolution;
+         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);
+         grid->levels[nvalues] = level;
       }
    }
 

Modified: trunk/mapserver/mapcache/src/grid.c
===================================================================
--- trunk/mapserver/mapcache/src/grid.c	2011-10-26 10:14:52 UTC (rev 12698)
+++ trunk/mapserver/mapcache/src/grid.c	2011-10-26 10:21:27 UTC (rev 12699)
@@ -81,8 +81,6 @@
       double unitheight = grid->tile_sy * level->resolution;
       double unitwidth = grid->tile_sx * level->resolution;
 
-      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) - tolerance;
       limits[i][2] = ceil((extent[2] - grid->extent[0]) / unitwidth - epsilon) + tolerance;



More information about the mapserver-commits mailing list