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

svn at osgeo.org svn at osgeo.org
Fri Aug 26 07:11:35 EDT 2011


Author: tbonfort
Date: 2011-08-26 04:11:35 -0700 (Fri, 26 Aug 2011)
New Revision: 12257

Modified:
   trunk/mapserver/mapcache/configure.in
   trunk/mapserver/mapcache/geocache.xml
   trunk/mapserver/mapcache/include/geocache.h
   trunk/mapserver/mapcache/src/configuration.c
   trunk/mapserver/mapcache/src/image.c
   trunk/mapserver/mapcache/src/service_wmts.c
   trunk/mapserver/mapcache/src/source_gdal.c
Log:
typo
thomas.bonfort | 2011-01-17 14:01:31 +0100 (Mon, 17 Jan 2011)

Modified: trunk/mapserver/mapcache/configure.in
===================================================================
--- trunk/mapserver/mapcache/configure.in	2011-08-26 11:11:28 UTC (rev 12256)
+++ trunk/mapserver/mapcache/configure.in	2011-08-26 11:11:35 UTC (rev 12257)
@@ -402,8 +402,14 @@
 PNG_CHECK
 
 JPEG_CHECK
-GDAL_CHECK
 
+
+# disable gdal building for now
+#GDAL_CHECK
+AC_SUBST(GDAL_ENABLED,$GDAL_ENABLED)
+AC_SUBST(GDAL_INC,$GDAL_CFLAGS)
+AC_SUBST(GDAL_LIB,$GDAL_LIBS)
+
 CURL_CHECK
 
 # Write config.status and the Makefile

Modified: trunk/mapserver/mapcache/geocache.xml
===================================================================
--- trunk/mapserver/mapcache/geocache.xml	2011-08-26 11:11:28 UTC (rev 12256)
+++ trunk/mapserver/mapcache/geocache.xml	2011-08-26 11:11:35 UTC (rev 12257)
@@ -212,6 +212,11 @@
       <compression>best</compression>
    </format>
 
+   <!--
+   <source name="bluemarble" type="gdal">
+      <data>/gro2/data/bluemarble/bluemarble.vrt</data>
+   </source>
+   -->
    <!-- source
 
       the service to query for obtaining images if they are not in the cache
@@ -296,9 +301,9 @@
          the supplied image is read when the configuration is loaded.
          if you make changes to the image, they will NOT be reflected on tiles already
          stored in the cache, nor on newly stored tiles until the server is restarted
-      <watermark>/Users/tbonfort/Documents/terriscope/logo-watermark.png</watermark>
+      <watermark>/home/tbonfort/dev/mod-geocache/static/watermark.png</watermark>
       -->
-
+      
       <!-- format
          (optional) format to use when storing a tile. this should be a format with high
          compression, eg. png with compression "best", as the compression operation is only
@@ -392,7 +397,17 @@
       <metabuffer>10</metabuffer>
    </tileset>
 
+   <!--
+   <tileset name="bluemarble">
+      <source>bluemarble</source>
+      <cache>disk</cache>
+      <metatile>5 5</metatile>
+      <format>PNG</format>
+      <grid>google,WGS84</grid>
+   </tileset>
+   -->
 
+
    <!-- merge_format
       format to use when a client asks for an image that is dynamically created from multiple
       tiles from the cache.

Modified: trunk/mapserver/mapcache/include/geocache.h
===================================================================
--- trunk/mapserver/mapcache/include/geocache.h	2011-08-26 11:11:28 UTC (rev 12256)
+++ trunk/mapserver/mapcache/include/geocache.h	2011-08-26 11:11:35 UTC (rev 12257)
@@ -687,6 +687,7 @@
     double bbox[4]; /**< the bounding box covered by this metatile */
     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 */
+    geocache_image *imdata;
 };
 
 struct geocache_grid {

Modified: trunk/mapserver/mapcache/src/configuration.c
===================================================================
--- trunk/mapserver/mapcache/src/configuration.c	2011-08-26 11:11:28 UTC (rev 12256)
+++ trunk/mapserver/mapcache/src/configuration.c	2011-08-26 11:11:35 UTC (rev 12257)
@@ -703,6 +703,11 @@
          }
          tileset->format = format;
    }
+   if(!tileset->format && tileset->source->type == GEOCACHE_SOURCE_GDAL) {
+      ctx->set_error(ctx,GEOCACHE_PARSE_ERROR, "tileset \"%s\" references a gdal source. <format> tag is missing and mandatory in this case",
+            tileset->name);
+      return;
+   }
    
    /* check we have all we want */
    if(tileset->cache == NULL) {

Modified: trunk/mapserver/mapcache/src/image.c
===================================================================
--- trunk/mapserver/mapcache/src/image.c	2011-08-26 11:11:28 UTC (rev 12256)
+++ trunk/mapserver/mapcache/src/image.c	2011-08-26 11:11:35 UTC (rev 12257)
@@ -105,7 +105,11 @@
       int sx,sy;
       tileimg.w = mt->tile.grid->tile_sx;
       tileimg.h = mt->tile.grid->tile_sy;
-      metatile = geocache_imageio_decode(ctx, mt->tile.data);
+      if(!mt->imdata) {
+         metatile = geocache_imageio_decode(ctx, mt->tile.data);
+      } else {
+         metatile = mt->imdata;
+      }
       if(!metatile) {
          ctx->set_error(ctx, GEOCACHE_IMAGE_ERROR, "failed to load image data from metatile");
          return;

Modified: trunk/mapserver/mapcache/src/service_wmts.c
===================================================================
--- trunk/mapserver/mapcache/src/service_wmts.c	2011-08-26 11:11:28 UTC (rev 12256)
+++ trunk/mapserver/mapcache/src/service_wmts.c	2011-08-26 11:11:35 UTC (rev 12257)
@@ -183,6 +183,7 @@
       }
 
       char *dimensions="";
+      char *dimensionstemplate="";
       if(tileset->dimensions) {
          for(i=0;i<tileset->dimensions->nelts;i++) {
             geocache_dimension *dimension = APR_ARRAY_IDX(tileset->dimensions,i,geocache_dimension*);
@@ -202,6 +203,8 @@
                dimensions = apr_pstrcat(ctx->pool,dimensions,"      <Value>",dimension->values[i],"</Value>\n",NULL);
             }
             dimensions = apr_pstrcat(ctx->pool,dimensions,"    </Dimension>\n",NULL);
+
+            dimensionstemplate = apr_pstrcat(ctx->pool,dimensionstemplate,dimension->name,"/{",dimension->name,"}/",NULL);
          }
       }
       char *tmsets="";
@@ -223,15 +226,18 @@
             "    </ows:WGS84BoundingBox>\n"*/
             "    <ows:Identifier>%s</ows:Identifier>\n"
             "    <Style isDefault=\"true\">\n"
-            "      <ows:Identifier>_null</ows:Identifier>\n"
+            "      <ows:Identifier>default</ows:Identifier>\n"
             "    </Style>\n"
             "%s" /*dimensions*/
             "    <Format>%s</Format>\n"
             "    <TileMatrixSetLink>\n"
             "%s"
             "    </TileMatrixSetLink>\n"
+            "    <ResourceURL format=\"%s\" resourceType=\"tile\"\n"
+            "                 template=\"%s/wmts/default/{TileMatrixSet}/{TileMatrix}/%s{TileRow}/{TileCol}.%s\"/>\n"
             "  </Layer>\n",caps,title,abstract,
-            tileset->name,dimensions,tileset->format->mime_type,tmsets);
+            tileset->name,dimensions,tileset->format->mime_type,tmsets,
+            tileset->format->mime_type,onlineresource,dimensionstemplate,tileset->format->extension);
       layer_index = apr_hash_next(layer_index);
    }
    caps = apr_pstrcat(ctx->pool,caps,"</Contents>\n</Capabilities>\n",NULL);

Modified: trunk/mapserver/mapcache/src/source_gdal.c
===================================================================
--- trunk/mapserver/mapcache/src/source_gdal.c	2011-08-26 11:11:28 UTC (rev 12256)
+++ trunk/mapserver/mapcache/src/source_gdal.c	2011-08-26 11:11:35 UTC (rev 12257)
@@ -27,6 +27,7 @@
 #include "gdal_alg.h"
 #include "cpl_string.h"
 #include "ogr_srs_api.h"
+
 /**
  * \private \memberof geocache_source_gdal
  * \sa geocache_source::render_metatile()
@@ -34,7 +35,7 @@
 void _geocache_source_gdal_render_metatile(geocache_context *ctx, geocache_metatile *tile) {
    geocache_source_gdal *gdal = (geocache_source_gdal*)tile->tile.tileset->source;
    char *srcSRS = "", *dstSRS;        
-   tile->tile.data = geocache_buffer_create(30000,ctx->pool);
+   geocache_buffer *data = geocache_buffer_create(0,ctx->pool);
    GC_CHECK_ERROR(ctx);
    GDALDatasetH  hDataset;
 
@@ -115,7 +116,7 @@
    adfDstGeoTransform[3] = tile->bbox[3];
    adfDstGeoTransform[1] = dfXRes;
    adfDstGeoTransform[5] = -dfYRes;
-   hDstDS = GDALCreate( hDriver, "tempd_gdal_image", tile->tile.grid->tile_sx, tile->tile.grid->tile_sy, 4, GDT_Byte, NULL );
+   hDstDS = GDALCreate( hDriver, "tempd_gdal_image", tile->sx, tile->sy, 4, GDT_Byte, NULL );
 
    /* -------------------------------------------------------------------- */
    /*      Write out the projection definition.                            */
@@ -163,13 +164,45 @@
    if( hGenImgProjArg != NULL )
       GDALDestroyGenImgProjTransformer( hGenImgProjArg );
 
+   if(GDALGetRasterCount(hDstDS) != 4) {
+      ctx->set_error(ctx,GEOCACHE_SOURCE_GDAL_ERROR,"gdal did not create a 4 band image");
+      return;
+   }
+
+   GDALRasterBandH *redband, *greenband, *blueband, *alphaband;
+
+   redband = GDALGetRasterBand(hDstDS,1);
+   greenband = GDALGetRasterBand(hDstDS,2);
+   blueband = GDALGetRasterBand(hDstDS,3);
+   alphaband = GDALGetRasterBand(hDstDS,4);
+
+   unsigned char *rasterdata = apr_palloc(ctx->pool,tile->sx*tile->sy*4);
+   data->buf = rasterdata;
+   data->avail = tile->sx*tile->sy*4;
+   data->size = tile->sx*tile->sy*4;
+
+   GDALRasterIO(redband,GF_Read,0,0,tile->sx,tile->sy,(void*)(rasterdata),tile->sx,tile->sy,GDT_Byte,4,4*tile->sx);
+   GDALRasterIO(greenband,GF_Read,0,0,tile->sx,tile->sy,(void*)(rasterdata+1),tile->sx,tile->sy,GDT_Byte,4,4*tile->sx);
+   GDALRasterIO(blueband,GF_Read,0,0,tile->sx,tile->sy,(void*)(rasterdata+2),tile->sx,tile->sy,GDT_Byte,4,4*tile->sx);
+   if(GDALGetRasterCount(hDataset)==4)
+      GDALRasterIO(alphaband,GF_Read,0,0,tile->sx,tile->sy,(void*)(rasterdata+3),tile->sx,tile->sy,GDT_Byte,4,4*tile->sx);
+   else {
+      unsigned char *alphaptr;
+      int i;
+      for(alphaptr = rasterdata+3, i=0; i<tile->sx*tile->sy; i++, alphaptr+=4) {
+         *alphaptr = 255;
+      }
+   }
+
+   tile->imdata = geocache_image_create(ctx);
+   tile->imdata->w = tile->sx;
+   tile->imdata->h = tile->sy;
+   tile->imdata->stride = tile->sx * 4;
+   tile->imdata->data = rasterdata;
+
+
    GDALClose( hDstDS );
    GDALClose( hDataset);
-   if(!geocache_imageio_is_valid_format(ctx,tile->tile.data)) {
-      char *returned_data = apr_pstrndup(ctx->pool,(char*)tile->tile.data->buf,tile->tile.data->size);
-      ctx->set_error(ctx, GEOCACHE_SOURCE_GDAL_ERROR, "gdal request for tileset %s: %d %d %d returned an unsupported format:\n%s",
-            tile->tile.tileset->name, tile->tile.x, tile->tile.y, tile->tile.z, returned_data);
-   }
 }
 
 /**



More information about the mapserver-commits mailing list