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

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


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

Modified:
   trunk/mapserver/mapcache/src/tileset.c
Log:
add initial support for sqlite caches

Update issue 52
An initial implementation has been checked in, without any kind of error checking.
Configuration simply resides in giving a base directory where the sqlite database
files will be put. There is one database for each tileset/grid combination.
the schema of the "tiles" table is:
{{{
create table if not exists tiles(x integer, y integer, z integer, data blob, ctime date, mtime date, atime date);
create index if not exists tilesidx on tiles (x,y,z);
}}}
the ctime,atime and mtime columns are not used yet.

If the tileset contains dimensions, the schema is expanded with a "dim" column:
{{{
alter table tiles add column dim text;
create index if not exists tilesdimidx on tiles (dim);
}}}

Individual tile dimension values are concatenated together with a # character when inserted and looked up in the table.
thomas.bonfort | 2011-07-12 15:32:51 +0200 (Tue, 12 Jul 2011)

Modified: trunk/mapserver/mapcache/src/tileset.c
===================================================================
--- trunk/mapserver/mapcache/src/tileset.c	2011-08-26 11:22:59 UTC (rev 12405)
+++ trunk/mapserver/mapcache/src/tileset.c	2011-08-26 11:23:04 UTC (rev 12406)
@@ -86,7 +86,8 @@
       double *bbox, int width, int height,
       int ntiles,
       geocache_tile **tiles) {
-   double resolution = geocache_grid_get_resolution(bbox, width, height);
+   double hresolution = geocache_grid_get_resolution(bbox, width, width);
+   double vresolution = geocache_grid_get_resolution(bbox, height, height);
    double tilebbox[4];
    geocache_image *image = geocache_image_create(ctx);
    image->w = width;
@@ -107,15 +108,18 @@
       cairo_surface_t* srcsurface= cairo_image_surface_create_for_data(im->data, CAIRO_FORMAT_ARGB32,
             im->w, im->h,im->stride);
       /*compute the pixel position of top left corner*/
-      double dstminx = floor((tilebbox[0]-bbox[0])/resolution);
-      double dstminy = floor((bbox[3]-tilebbox[3])/resolution);
-      double f = tileresolution/resolution;
-      double dstwidth = ceil(im->w*f);
-      f = dstwidth/(double)im->w;
+      double dstminx = floor((tilebbox[0]-bbox[0])/hresolution);
+      double dstminy = floor((bbox[3]-tilebbox[3])/vresolution);
+      double hf = tileresolution/hresolution;
+      double vf = tileresolution/vresolution;
+      double dstwidth = ceil(im->w*hf);
+      double dstheight = ceil(im->h*vf);
+      hf = dstwidth/(double)im->w;
+      vf = dstheight/(double)im->h;
       cairo_save(cr);
       //cairo_clip(cr);
       cairo_translate (cr, dstminx,dstminy);
-      cairo_scale  (cr, f, f);
+      cairo_scale  (cr, hf, vf);
       cairo_set_source_surface (cr, srcsurface, 0, 0);
       cairo_pattern_set_filter (cairo_get_source (cr), CAIRO_FILTER_NEAREST);
       cairo_paint (cr);



More information about the mapserver-commits mailing list