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

svn at osgeo.org svn at osgeo.org
Fri Aug 26 07:22:30 EDT 2011


Author: tbonfort
Date: 2011-08-26 04:22:29 -0700 (Fri, 26 Aug 2011)
New Revision: 12399

Modified:
   trunk/mapserver/mapcache/include/geocache.h
   trunk/mapserver/mapcache/src/image.c
   trunk/mapserver/mapcache/src/tileset.c
Log:
add autoconf checks for geos library
thomas.bonfort | 2011-07-04 16:34:03 +0200 (Mon, 04 Jul 2011)

Modified: trunk/mapserver/mapcache/include/geocache.h
===================================================================
--- trunk/mapserver/mapcache/include/geocache.h	2011-08-26 11:22:24 UTC (rev 12398)
+++ trunk/mapserver/mapcache/include/geocache.h	2011-08-26 11:22:29 UTC (rev 12399)
@@ -900,6 +900,7 @@
 struct geocache_metatile {
    geocache_map map;
    int x,y,z;
+   int metasize_x, metasize_y;
    int ntiles; /**< the number of geocache_metatile::tiles contained in this metatile */
    geocache_tile *tiles; /**< the list of geocache_tile s contained in this metatile */
    void *lock; /**< pointer to opaque structure set by the locking mechanism */

Modified: trunk/mapserver/mapcache/src/image.c
===================================================================
--- trunk/mapserver/mapcache/src/image.c	2011-08-26 11:22:24 UTC (rev 12398)
+++ trunk/mapserver/mapcache/src/image.c	2011-08-26 11:22:29 UTC (rev 12399)
@@ -126,8 +126,8 @@
          return;
       }
       tileimg.stride = metatile->stride;
-      for(i=0;i<mt->map.tileset->metasize_x;i++) {
-         for(j=0;j<mt->map.tileset->metasize_y;j++) {
+      for(i=0;i<mt->metasize_x;i++) {
+         for(j=0;j<mt->metasize_y;j++) {
             sx = mt->map.tileset->metabuffer + i * tileimg.w;
             sy = mt->map.height - (mt->map.tileset->metabuffer + (j+1) * tileimg.w);
             tileimg.data = &(metatile->data[sy*metatile->stride + 4 * sx]);
@@ -135,7 +135,7 @@
                 geocache_image_merge(ctx,&tileimg,mt->map.tileset->watermark);
                 GC_CHECK_ERROR(ctx);
             }
-            mt->tiles[i*mt->map.tileset->metasize_x+j].data =
+            mt->tiles[i*mt->metasize_y+j].data =
                mt->map.tileset->format->write(ctx, &tileimg, mt->map.tileset->format);
             GC_CHECK_ERROR(ctx);
          }

Modified: trunk/mapserver/mapcache/src/tileset.c
===================================================================
--- trunk/mapserver/mapcache/src/tileset.c	2011-08-26 11:22:24 UTC (rev 12398)
+++ trunk/mapserver/mapcache/src/tileset.c	2011-08-26 11:22:29 UTC (rev 12399)
@@ -138,14 +138,9 @@
    geocache_tileset *tileset = tile->tileset;
    geocache_grid *grid = tile->grid_link->grid;
    double res = grid->levels[tile->z]->resolution;
-   double gbuffer,gwidth,gheight;
+   double gbuffer,gwidth,gheight,fullgwidth,fullgheight;
    mt->map.tileset = tileset;
    mt->map.grid_link = tile->grid_link;
-   mt->ntiles = tileset->metasize_x * tileset->metasize_y;
-   mt->tiles = (geocache_tile*)apr_pcalloc(ctx->pool, mt->ntiles * sizeof(geocache_tile));
-   mt->map.width =  tileset->metasize_x * grid->tile_sx + 2 * tileset->metabuffer;
-   mt->map.height =  tileset->metasize_y * grid->tile_sy + 2 * tileset->metabuffer;
-   mt->map.dimensions = tile->dimensions;
    mt->z = tile->z;
    mt->x = tile->x / tileset->metasize_x;
    if(tile->x < 0)
@@ -153,21 +148,43 @@
    mt->y = tile->y / tileset->metasize_y;
    if(tile->y < 0)
       mt->y --;
+   blx = mt->x * tileset->metasize_x;
+   bly = mt->y * tileset->metasize_y;
+  
+   /* adjust the size of the the metatile so it does not extend past the grid limits.
+    * If we don't do this, we end up with cut labels on the edges of the tile grid
+    */
+   if(blx+tileset->metasize_x-1 >= grid->levels[tile->z]->maxx) {
+      mt->metasize_x = grid->levels[tile->z]->maxx - blx;
+   } else {
+      mt->metasize_x = tileset->metasize_x;
+   }
+   if(bly+tileset->metasize_y-1 >= grid->levels[tile->z]->maxy) {
+      mt->metasize_y = grid->levels[tile->z]->maxy - bly;
+   } else {
+      mt->metasize_y = tileset->metasize_y;
+   }
 
+   mt->ntiles = mt->metasize_x * mt->metasize_y;
+   mt->tiles = (geocache_tile*)apr_pcalloc(ctx->pool, mt->ntiles * sizeof(geocache_tile));
+   mt->map.width =  mt->metasize_x * grid->tile_sx + 2 * tileset->metabuffer;
+   mt->map.height =  mt->metasize_y * grid->tile_sy + 2 * tileset->metabuffer;
+   mt->map.dimensions = tile->dimensions;
+
    //tilesize   = self.actualSize()
    gbuffer = res * tileset->metabuffer;
-   gwidth = res * tileset->metasize_x * grid->tile_sx;
-   gheight = res * tileset->metasize_y * grid->tile_sy;
-   mt->map.extent[0] = grid->extent[0] + mt->x * gwidth - gbuffer;
-   mt->map.extent[1] = grid->extent[1] + mt->y * gheight - gbuffer;
+   gwidth = res * mt->metasize_x * grid->tile_sx;
+   gheight = res * mt->metasize_y * grid->tile_sy;
+   fullgwidth = res * tileset->metasize_x * grid->tile_sx;
+   fullgheight = res * tileset->metasize_y * grid->tile_sy;
+   mt->map.extent[0] = grid->extent[0] + mt->x * fullgwidth - gbuffer;
+   mt->map.extent[1] = grid->extent[1] + mt->y * fullgheight - gbuffer;
    mt->map.extent[2] = mt->map.extent[0] + gwidth + 2 * gbuffer;
    mt->map.extent[3] = mt->map.extent[1] + gheight + 2 * gbuffer;
 
-   blx = mt->x * tileset->metasize_x;
-   bly = mt->y * tileset->metasize_y;
-   for(i=0; i<tileset->metasize_x; i++) {
-      for(j=0; j<tileset->metasize_y; j++) {
-         geocache_tile *t = &(mt->tiles[i*tileset->metasize_x+j]);
+   for(i=0; i<mt->metasize_x; i++) {
+      for(j=0; j<mt->metasize_y; j++) {
+         geocache_tile *t = &(mt->tiles[i*mt->metasize_y+j]);
          t->dimensions = tile->dimensions;
          t->grid_link = tile->grid_link;
          t->z = tile->z;



More information about the mapserver-commits mailing list