[mapserver-dev] MapCache: improvements/changes
Umberto Nicoletti
umberto.nicoletti at gmail.com
Fri Feb 1 09:26:08 PST 2013
Daniele,
thanks for taking the time to improve MapCache!
Just want to inform you that the best way to submit patches is to use
GitHub pull requests:
https://help.github.com/articles/using-pull-requests
Thanks again,
Umberto
On Fri, Feb 1, 2013 at 5:58 PM, Daniele Debernardi <daniele at geosar.ch>wrote:
> Hi,
> after using the apache module mapCache, I had to do some changes to the
> code to fit best my needs.
> I would like to share my considerations on some behavior:
>
> 1) when you request a tile outside the extension of the tileset, you get
> the error.
> 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
> to a response code of 200 and the browser will not log all the errors.
> file lib/core.c around line ~600
> ...
> } else if(ctx->config && ctx->config->reporting ==
> MAPCACHE_REPORT_EMPTY_IMG) {
> response->data = ctx->config->empty_image;
> response->code = 200; //set response code
> apr_table_set(response->**headers, "Content-Type",
> ctx->config->default_image_**format->mime_type);
> apr_table_set(response->**headers, "X-Mapcache-Error", msg);
> } else if(ctx->config && ctx->config->reporting ==
> MAPCACHE_REPORT_ERROR_IMG) {
> ...
>
> 2) configuring the mapcache with a jpeg output format, when I request a
> tile that is half-in and half-out the extension of
> 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
> to determine which part to change to white.
> file lib/imageio_jpeg.c around line ~195
> ...
> rowdata = (JSAMPLE*)malloc(img->w*cinfo.**input_components*sizeof(**
> JSAMPLE));
> for(row=0; row<img->h; row++) {
> JSAMPLE *pixptr = rowdata;
> int col;
> unsigned char *r,*g,*b,*alpha;
> r=&(img->data[2])+row*img->**stride;
> g=&(img->data[1])+row*img->**stride;
> b=&(img->data[0])+row*img->**stride;
> alpha= &(img->data[3])+row*img->**stride;
> for(col=0; col<img->w; col++) {
> if (*alpha == 255) {
> *(pixptr++) = *r;
> *(pixptr++) = *g;
> *(pixptr++) = *b;
> } else {
> *(pixptr++) = 255;
> *(pixptr++) = 255;
> *(pixptr++) = 255;
> }
> r+=4;
> g+=4;
> b+=4;
> alpha+=4;
> }
> (void) jpeg_write_scanlines(&cinfo, &rowdata, 1);
> }
>
> ...
>
>
> 3) requesting images as png to maintain transparency, I had some trouble
> with the default image format which was JPEG,
> this because in the code, the default format is get by dont know what and
> by default was jpeg.
> I suggest to change it to take the default format specified in the
> mapcache xml configuration.
> file lib/core.c around line ~400
> ...
> if(basemap->raw_image) {
> //remove this line and get image format from configuration xml
> //format = req_map->getmap_format; /* always defined, defaults to JPEG
> */
>
> format = ctx->config->default_image_**format;
>
> response->data = format->write(ctx,basemap->**raw_image,format);
> if(GC_HAS_ERROR(ctx)) {
> return NULL;
> }
> } else {
> ...
>
>
> I would like to know what you guys think of my changes.
>
> Best regards,
> Daniele
> ______________________________**_________________
> mapserver-dev mailing list
> mapserver-dev at lists.osgeo.org
> http://lists.osgeo.org/**mailman/listinfo/mapserver-dev<http://lists.osgeo.org/mailman/listinfo/mapserver-dev>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-dev/attachments/20130201/5c3dcf69/attachment.html>
More information about the mapserver-dev
mailing list