scaleretinamapnik

High resolution image with Mapnik


I use Mapnik 2.2.0 to render a map from my Java library using the Mapnik JNI. This is working fine with no issues. I am now trying to make the map available in high resolution.

I changed the image size in my code from 256x256 to 512x512. This caused Mapnik to change the effective zoom level, because the scale has changed. For example, when rendering 15/5000/10000, I see a 512x512 image with my zoom 16 styling.

What I want to have is an image of the same coordinates as my original 256x256 image, with the same styling, only 512x512.

I found a possible parameter that could be related:

<Parameter name="scale">2</Parameter>

where 2 should be the factor I need. However it did not have any effect on the rendered image, so I may be looking the wrong direction.


Solution

  • Turns out that the Mapnik JNI renderAgg signature that I was using:

    renderAgg(MapDefinition map, Image image)
    

    sets the scale factor to 1.0. When I changed to this signature:

    renderAgg(MapDefinition map, Image image, double scaleFactor, int offsetX, int offsetY)
    

    The scale factor took effect