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

svn at osgeo.org svn at osgeo.org
Fri Dec 2 16:56:11 EST 2011


Author: assefa
Date: 2011-12-02 13:56:11 -0800 (Fri, 02 Dec 2011)
New Revision: 12836

Modified:
   trunk/mapserver/mapcache/src/ezxml.c
   trunk/mapserver/mapcache/src/fastcgi_mapcache.c
   trunk/mapserver/mapcache/src/grid.c
   trunk/mapserver/mapcache/src/image.c
   trunk/mapserver/mapcache/src/mapcache_seed.c
Log:
windows build (#4106)

Modified: trunk/mapserver/mapcache/src/ezxml.c
===================================================================
--- trunk/mapserver/mapcache/src/ezxml.c	2011-12-02 18:21:48 UTC (rev 12835)
+++ trunk/mapserver/mapcache/src/ezxml.c	2011-12-02 21:56:11 UTC (rev 12836)
@@ -32,6 +32,7 @@
 #include <unistd.h>
 #else
 #define EZXML_NOMMAP 1
+#define snprintf _snprintf
 #endif
 
 #include <sys/types.h>

Modified: trunk/mapserver/mapcache/src/fastcgi_mapcache.c
===================================================================
--- trunk/mapserver/mapcache/src/fastcgi_mapcache.c	2011-12-02 18:21:48 UTC (rev 12835)
+++ trunk/mapserver/mapcache/src/fastcgi_mapcache.c	2011-12-02 21:56:11 UTC (rev 12836)
@@ -112,6 +112,7 @@
       }
    }
    if(response->mtime) {
+     char *datestr;
       char *if_modified_since = getenv("HTTP_IF_MODIFIED_SINCE");
       if(if_modified_since) {
         apr_time_t ims_time;
@@ -125,7 +126,7 @@
             printf("Status: 304 Not Modified\r\n");
         }
       }
-      char *datestr = apr_palloc(ctx->ctx.pool, APR_RFC822_DATE_LEN);
+      datestr = apr_palloc(ctx->ctx.pool, APR_RFC822_DATE_LEN);
       apr_rfc822_date(datestr, response->mtime);
       printf("Last-Modified: %s\r\n", datestr);
    }
@@ -142,6 +143,8 @@
 static void load_config(mapcache_context *ctx, char *filename) {
    apr_file_t *f;
    apr_finfo_t finfo;
+   mapcache_cfg *old_cfg;
+   mapcache_cfg *cfg;
    if((apr_file_open(&f, filename, APR_FOPEN_READ, APR_UREAD | APR_GREAD,
                global_pool)) == APR_SUCCESS) {
       apr_file_info_get(&finfo, APR_FINFO_MTIME, f);
@@ -162,10 +165,10 @@
 
    /* either we have no config, or it has changed */
 
-   mapcache_cfg *old_cfg = ctx->config;
+   old_cfg = ctx->config;
    apr_pool_create(&tmp_config_pool,global_pool);
 
-   mapcache_cfg *cfg = mapcache_configuration_create(tmp_config_pool);
+   cfg = mapcache_configuration_create(tmp_config_pool);
    ctx->config = cfg;
    ctx->pool = tmp_config_pool;
 
@@ -197,8 +200,17 @@
 }
 
 int main(int argc, const char **argv) {
+  mapcache_context_fcgi* globalctx;
+  mapcache_context* ctx;
+   apr_table_t *params;
+   mapcache_request *request = NULL;
+   char *pathInfo;
+   mapcache_http_response *http_response;
+
    (void) signal(SIGTERM,handle_signal);
+#ifndef _WIN32
    (void) signal(SIGUSR1,handle_signal);
+#endif
    apr_initialize();
    atexit(apr_terminate);
    apr_pool_initialize();
@@ -206,8 +218,8 @@
       return 1;
    }
    config_pool = NULL;
-   mapcache_context_fcgi* globalctx = fcgi_context_create();
-   mapcache_context* ctx = (mapcache_context*)globalctx;
+   globalctx = fcgi_context_create();
+   ctx = (mapcache_context*)globalctx;
    
    conffile  = getenv("MAPCACHE_CONFIG_FILE");
    if(!conffile) {
@@ -220,7 +232,7 @@
 #ifdef USE_FASTCGI
    while (FCGI_Accept() >= 0) {
 #endif
-      apr_table_t *params;
+     
       ctx->pool = config_pool;
       if(!ctx->config || ctx->config->autoreload) {
          load_config(ctx,conffile);
@@ -230,8 +242,8 @@
          }
       }
       apr_pool_create(&(ctx->pool),config_pool);
-      mapcache_request *request = NULL;
-      char *pathInfo = getenv("PATH_INFO");
+      request = NULL;
+      pathInfo = getenv("PATH_INFO");
       
 
       params = mapcache_http_parse_param_string(ctx, getenv("QUERY_STRING"));
@@ -241,7 +253,7 @@
          goto cleanup;
       }
       
-      mapcache_http_response *http_response = NULL;
+      http_response = NULL;
       if(request->type == MAPCACHE_REQUEST_GET_CAPABILITIES) {
          mapcache_request_get_capabilities *req = (mapcache_request_get_capabilities*)request;
          char *host = getenv("SERVER_NAME");

Modified: trunk/mapserver/mapcache/src/grid.c
===================================================================
--- trunk/mapserver/mapcache/src/grid.c	2011-12-02 18:21:48 UTC (rev 12835)
+++ trunk/mapserver/mapcache/src/grid.c	2011-12-02 21:56:11 UTC (rev 12836)
@@ -147,10 +147,10 @@
    double res = mapcache_grid_get_resolution(bbox,grid->tile_sx,grid->tile_sy);
    if(MAPCACHE_SUCCESS != mapcache_grid_get_level(ctx, grid, &res, z))
       return MAPCACHE_FAILURE;
-   
-   *x = (int)round((bbox[0] - grid->extent[0]) / (res * grid->tile_sx));
-   *y = (int)round((bbox[1] - grid->extent[1]) / (res * grid->tile_sy));
 
+   *x = (int)(((bbox[0] - grid->extent[0]) / (res * grid->tile_sx)) + 0.5);
+   *y = (int)(((bbox[1] - grid->extent[1]) / (res * grid->tile_sy)) + 0.5);
+
    if((fabs(bbox[0] - (*x * res * grid->tile_sx) - grid->extent[0] ) / res > 1) ||
          (fabs(bbox[1] - (*y * res * grid->tile_sy) - grid->extent[1] ) / res > 1)) {
       return MAPCACHE_FAILURE;

Modified: trunk/mapserver/mapcache/src/image.c
===================================================================
--- trunk/mapserver/mapcache/src/image.c	2011-12-02 18:21:48 UTC (rev 12835)
+++ trunk/mapserver/mapcache/src/image.c	2011-12-02 21:56:11 UTC (rev 12836)
@@ -184,10 +184,10 @@
    unsigned char *dstrowptr = dst->data;
    for(dsty=0; dsty<dst->h; dsty++) {
       int *dstptr = (int*)dstrowptr;
-      int srcy = round((dsty-off_y)/scale_y);
+      int srcy = (int)(((dsty-off_y)/scale_y)+0.5);
       if(srcy >= 0 && srcy < src->h) {
          for(dstx=0; dstx<dst->w;dstx++) {
-            int srcx = round((dstx-off_x)/scale_x);
+	   int srcx = (int)(((dstx-off_x)/scale_x)+0.5);
             if(srcx >= 0 && srcx < src->w) {
                *dstptr = *((int*)&(src->data[srcy*src->stride+srcx*4]));
             }

Modified: trunk/mapserver/mapcache/src/mapcache_seed.c
===================================================================
--- trunk/mapserver/mapcache/src/mapcache_seed.c	2011-12-02 18:21:48 UTC (rev 12835)
+++ trunk/mapserver/mapcache/src/mapcache_seed.c	2011-12-02 21:56:11 UTC (rev 12836)
@@ -32,8 +32,12 @@
 #include <apr_thread_mutex.h>
 #include <apr_getopt.h>
 #include <signal.h>
+
 #include <time.h>
+#ifndef _WIN32
 #include <sys/time.h>
+#endif
+
 #include <apr_time.h>
 #include <apr_queue.h>
 #include <apr_strings.h>
@@ -181,9 +185,9 @@
 
 int lastmsglen = 0;
 void progresslog(int x, int y, int z) {
-
+   char msg[1024];
    if(quiet) return;
-   char msg[1024];
+  
    
    sprintf(msg,"seeding tile %d %d %d",x,y,z);
    if(lastmsglen) {
@@ -200,18 +204,21 @@
    return;
 
    if(queuedtilestot>nthreads) {
+      struct timeval now_t;
+      float duration;
+      float totalduration;
       seededtilestot = queuedtilestot - nthreads;
-      struct timeval now_t;
+
       gettimeofday(&now_t,NULL);
-      float duration = ((now_t.tv_sec-lastlogtime.tv_sec)*1000000+(now_t.tv_usec-lastlogtime.tv_usec))/1000000.0;
-      float totalduration = ((now_t.tv_sec-starttime.tv_sec)*1000000+(now_t.tv_usec-starttime.tv_usec))/1000000.0;
+      duration = ((now_t.tv_sec-lastlogtime.tv_sec)*1000000+(now_t.tv_usec-lastlogtime.tv_usec))/1000000.0;
+      totalduration = ((now_t.tv_sec-starttime.tv_sec)*1000000+(now_t.tv_usec-starttime.tv_usec))/1000000.0;
       if(duration>=5) {
-         int Nx, Ny;
+	int Nx, Ny, Ntot, Ncur, ntilessincelast;
          Nx = (grid_link->grid_limits[z][2]-grid_link->grid_limits[z][0])/tileset->metasize_x;
          Ny = (grid_link->grid_limits[z][3]-grid_link->grid_limits[z][1])/tileset->metasize_y;
-         int Ntot = Nx*Ny;
-         int Ncur = (y-grid_link->grid_limits[z][1])/tileset->metasize_y*Nx+(x-grid_link->grid_limits[z][0]+1)/tileset->metasize_x;
-         int ntilessincelast = seededtilestot-seededtiles;
+         Ntot = Nx*Ny;
+         Ncur = (y-grid_link->grid_limits[z][1])/tileset->metasize_y*Nx+(x-grid_link->grid_limits[z][0]+1)/tileset->metasize_x;
+         ntilessincelast = seededtilestot-seededtiles;
          sprintf(msg,"seeding level %d [%d/%d]: %f metatiles/sec (avg since start: %f)",z,Ncur,Ntot,ntilessincelast/duration,
                seededtilestot/totalduration);
          lastlogtime=now_t;
@@ -326,6 +333,13 @@
 }
 
 void cmd_recurse(mapcache_context *cmd_ctx, mapcache_tile *tile) {
+  cmd action;
+  int i,j;
+  int curx, cury, curz;
+  int minchildx,maxchildx,minchildy,maxchildy;
+  double bboxbl[4],bboxtr[4];
+  double epsilon;
+
    apr_pool_clear(cmd_ctx->pool);
    if(sig_int_received || error_detected) { //stop if we were asked to stop by hitting ctrl-c
       //remove all items from the queue
@@ -334,7 +348,7 @@
       return;
    }
 
-   cmd action = examine_tile(cmd_ctx, tile);
+   action = examine_tile(cmd_ctx, tile);
 
    if(action == MAPCACHE_CMD_SEED || action == MAPCACHE_CMD_DELETE || action == MAPCACHE_CMD_TRANSFER){
       //current x,y,z needs seeding, add it to the queue
@@ -349,10 +363,10 @@
    }
 
    //recurse into our 4 child metatiles
-   int i,j;
-   int curx = tile->x;
-   int cury = tile->y;
-   int curz = tile->z;
+   
+   curx = tile->x;
+   cury = tile->y;
+   curz = tile->z;
    tile->z += 1;
    if(tile->z > maxzoom) {
       tile->z -= 1;
@@ -363,13 +377,13 @@
     * compute the x,y limits of the next zoom level that intersect the
     * current metatile
     */
-   int minchildx,maxchildx,minchildy,maxchildy;
-   double bboxbl[4],bboxtr[4];
+   
+  
    mapcache_grid_get_extent(cmd_ctx, grid_link->grid,
          curx, cury, curz, bboxbl);
    mapcache_grid_get_extent(cmd_ctx, grid_link->grid,
          curx+tileset->metasize_x-1, cury+tileset->metasize_y-1, curz, bboxtr);
-   double epsilon = (bboxbl[2]-bboxbl[0])*0.01;
+   epsilon = (bboxbl[2]-bboxbl[0])*0.01;
    mapcache_grid_get_xy(cmd_ctx,grid_link->grid,
          bboxbl[0] + epsilon,
          bboxbl[1] + epsilon,
@@ -400,12 +414,14 @@
 }
 
 void cmd_thread() {
+     int n;
+  mapcache_tile *tile;
    int z = minzoom;
    int x = grid_link->grid_limits[z][0];
    int y = grid_link->grid_limits[z][1];
    mapcache_context cmd_ctx = ctx;
    apr_pool_create(&cmd_ctx.pool,ctx.pool);
-   mapcache_tile *tile = mapcache_tileset_tile_create(ctx.pool, tileset, grid_link);
+   tile = mapcache_tileset_tile_create(ctx.pool, tileset, grid_link);
    tile->dimensions = dimensions;
    if(seed_mode == MAPCACHE_SEED_DEPTH_FIRST) {
       do {
@@ -427,6 +443,7 @@
             );
    } else {
       while(1) {
+	int action;
          apr_pool_clear(cmd_ctx.pool);
          if(sig_int_received || error_detected) { //stop if we were asked to stop by hitting ctrl-c
             //remove all items from the queue
@@ -437,7 +454,7 @@
          tile->x = x;
          tile->y = y;
          tile->z = z;
-	 int action = examine_tile(&cmd_ctx, tile);
+	 action = examine_tile(&cmd_ctx, tile);
 
          if(action == MAPCACHE_CMD_SEED || MAPCACHE_CMD_TRANSFER) {
             //current x,y,z needs seeding, add it to the queue
@@ -467,7 +484,7 @@
       }
    }
    //instruct rendering threads to stop working
-   int n;
+
    for(n=0;n<nthreads;n++) {
       struct seed_cmd *cmd = malloc(sizeof(struct seed_cmd));
       cmd->command = MAPCACHE_CMD_STOP;
@@ -480,15 +497,17 @@
 }
 
 static void* APR_THREAD_FUNC seed_thread(apr_thread_t *thread, void *data) {
+  mapcache_tile *tile;
    mapcache_context seed_ctx = ctx;
    seed_ctx.log = seed_log;
    apr_pool_create(&seed_ctx.pool,ctx.pool);
-   mapcache_tile *tile = mapcache_tileset_tile_create(ctx.pool, tileset, grid_link);
+   tile = mapcache_tileset_tile_create(ctx.pool, tileset, grid_link);
    tile->dimensions = dimensions;
    while(1) {
+     struct seed_cmd *cmd;
       apr_status_t ret;
       apr_pool_clear(seed_ctx.pool);
-      struct seed_cmd *cmd;
+      
       ret = apr_queue_pop(work_queue, (void**)&cmd);
       if(ret != APR_SUCCESS || cmd->command == MAPCACHE_CMD_STOP) break;
       tile->x = cmd->x;
@@ -579,6 +598,9 @@
     int rv,n;
     const char *old = NULL;
     const char *optarg;
+    apr_table_t *argdimensions;
+    char *dimkey, *dimvalue,*key, *last, *optargcpy;
+    int keyidx;
 
 #ifdef USE_CLIPPERS
     const char *ogr_where = NULL;
@@ -600,9 +622,9 @@
     seededtiles=seededtilestot=queuedtilestot=0;
     gettimeofday(&starttime,NULL);
     lastlogtime=starttime;
-    apr_table_t *argdimensions = apr_table_make(ctx.pool,3);
-    char *dimkey = NULL,*dimvalue = NULL,*key,*last,*optargcpy = NULL;
-    int keyidx;
+    argdimensions = apr_table_make(ctx.pool,3);
+    dimkey = NULL,*dimvalue = NULL,*key,*last,*optargcpy = NULL;
+    
 
     /* parse the all options based on opt_option[] */
     while ((rv = apr_getopt_long(opt, seed_options, &optch, &optarg)) == APR_SUCCESS) {
@@ -719,9 +741,10 @@
     }
 
     if(ogr_datasource) {
+      OGRDataSourceH hDS = NULL;
+       OGRLayerH layer = NULL;
        OGRRegisterAll();
-       OGRDataSourceH hDS = NULL;
-       OGRLayerH layer = NULL;
+       
        hDS = OGROpen( ogr_datasource, FALSE, NULL );
        if( hDS == NULL )
        {
@@ -843,8 +866,9 @@
     if(old) {
        if(strcasecmp(old,"now")) {
           struct tm oldtime;
+	  char *ret;
           memset(&oldtime,0,sizeof(oldtime));
-          char *ret = strptime(old,"%Y/%m/%d %H:%M",&oldtime);
+          ret = strptime(old,"%Y/%m/%d %H:%M",&oldtime);
           if(!ret || *ret){
              return usage(argv[0],"failed to parse time");
           }
@@ -881,9 +905,9 @@
 
     /* validate the supplied dimensions */
     if (!apr_is_empty_array(tileset->dimensions)) {
-
+      int i;
        dimensions = apr_table_make(ctx.pool,3);
-       int i;
+       
        for(i=0;i<tileset->dimensions->nelts;i++) {
           mapcache_dimension *dimension = APR_ARRAY_IDX(tileset->dimensions,i,mapcache_dimension*);
           const char *value;
@@ -928,8 +952,9 @@
 
         if(seededtilestot>0) {
            struct timeval now_t;
+	   float duration;
            gettimeofday(&now_t,NULL);
-           float duration = ((now_t.tv_sec-starttime.tv_sec)*1000000+(now_t.tv_usec-starttime.tv_usec))/1000000.0;
+           duration = ((now_t.tv_sec-starttime.tv_sec)*1000000+(now_t.tv_usec-starttime.tv_usec))/1000000.0;
            printf("\nseeded %d metatiles at %g tiles/sec\n",seededtilestot, seededtilestot/duration);
         }
     }



More information about the mapserver-commits mailing list