<div dir="ltr">Daniele,<div>thanks for taking the time to improve MapCache!</div><div><br><div>Just want to inform you that the best way to submit patches is to use GitHub pull requests:</div></div><div><br></div><div><a href="https://help.github.com/articles/using-pull-requests">https://help.github.com/articles/using-pull-requests</a><br>
</div><div><br></div><div style>Thanks again,</div><div style>Umberto</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Feb 1, 2013 at 5:58 PM, Daniele Debernardi <span dir="ltr"><<a href="mailto:daniele@geosar.ch" target="_blank">daniele@geosar.ch</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
after using the apache module mapCache, I had to do some changes to the code to fit best my needs.<br>
I would like to share my considerations on some behavior:<br>
<br>
1) when you request a tile outside the extension of the tileset, you get the error.<br>
with the configuration of the errors as empty_img it returns an empty image but the http response code was annoying, so I changed it<br>
to a response code of 200 and the browser will not log all the errors.<br>
file lib/core.c around line ~600<br>
...<br>
  } else if(ctx->config && ctx->config->reporting == MAPCACHE_REPORT_EMPTY_IMG) {<br>
    response->data = ctx->config->empty_image;<br>
    response->code = 200;    //set response code<br>
    apr_table_set(response-><u></u>headers, "Content-Type", ctx->config->default_image_<u></u>format->mime_type);<br>
    apr_table_set(response-><u></u>headers, "X-Mapcache-Error", msg);<br>
  } else if(ctx->config && ctx->config->reporting == MAPCACHE_REPORT_ERROR_IMG) {<br>
...<br>
<br>
2) configuring the mapcache with a jpeg output format, when I request a tile that is half-in and half-out the extension of<br>
the tileset, the half-out image had a black background, as I use maps with a white background, I changed it using the alpha channel<br>
to determine which part to change to white.<br>
file lib/imageio_jpeg.c around line ~195<br>
...<br>
  rowdata = (JSAMPLE*)malloc(img->w*cinfo.<u></u>input_components*sizeof(<u></u>JSAMPLE));<br>
  for(row=0; row<img->h; row++) {<br>
    JSAMPLE *pixptr = rowdata;<br>
    int col;<br>
    unsigned char *r,*g,*b,*alpha;<br>
    r=&(img->data[2])+row*img-><u></u>stride;<br>
    g=&(img->data[1])+row*img-><u></u>stride;<br>
    b=&(img->data[0])+row*img-><u></u>stride;<br>
    alpha= &(img->data[3])+row*img-><u></u>stride;<br>
    for(col=0; col<img->w; col++) {<br>
      if (*alpha == 255) {<br>
        *(pixptr++) = *r;<br>
        *(pixptr++) = *g;<br>
        *(pixptr++) = *b;<br>
      } else {<br>
        *(pixptr++) = 255;<br>
        *(pixptr++) = 255;<br>
        *(pixptr++) = 255;<br>
      }<br>
      r+=4;<br>
      g+=4;<br>
      b+=4;<br>
      alpha+=4;<br>
    }<br>
    (void) jpeg_write_scanlines(&cinfo, &rowdata, 1);<br>
  }<br>
<br>
...<br>
<br>
<br>
3) requesting images as png to maintain transparency, I had some trouble with the default image format which was JPEG,<br>
this because in the code, the default format is get by dont know what and by default was jpeg.<br>
I suggest to change it to take the default format specified in the mapcache xml configuration.<br>
file lib/core.c around line ~400<br>
...<br>
  if(basemap->raw_image) {<br>
    //remove this line and get image format from configuration xml<br>
    //format = req_map->getmap_format; /* always defined, defaults to JPEG */<br>
<br>
    format = ctx->config->default_image_<u></u>format;<br>
<br>
    response->data = format->write(ctx,basemap-><u></u>raw_image,format);<br>
    if(GC_HAS_ERROR(ctx)) {<br>
      return NULL;<br>
    }<br>
  } else {<br>
...<br>
<br>
<br>
I would like to know what you guys think of my changes.<br>
<br>
Best regards,<br>
Daniele<br>
______________________________<u></u>_________________<br>
mapserver-dev mailing list<br>
<a href="mailto:mapserver-dev@lists.osgeo.org" target="_blank">mapserver-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/mapserver-dev" target="_blank">http://lists.osgeo.org/<u></u>mailman/listinfo/mapserver-dev</a><br>
</blockquote></div><br></div>