[OSM-dev] mod_tile in other projections?

Kai Krueger kakrueger at gmail.com
Fri Aug 16 08:50:28 UTC 2013


Hi,

There were a couple of issues with the projection code in mod_tile and
renderd which I have now hopefully fixed.

Renderd was calculating the projected coordinates wrongly for the Y
axis. This wasn't noticeable for the standard projection, as its bounds
are symmetric around zero. This bug is now fixed.

In Mod_tile you couldn't configure the aspect ratio of the tile layer,
and so the aspect ratio of 2x1 was considered out of bounds and returned
404 without getting the requests to renderd. In renderd.conf you can now
specify "ASPECTX" and "ASPECTY" which mod_tile will read to configure
that correct bounds checks.

Finally you need prj-bound_y1 = 1400000. The ratio of projected x
coodinates to projected y coordinates need to be integer, as otherwise
the projected coordiates that mod_tile / renderd assume and what mapnik
actually renders are different and you get projection missmatches at the
metatile boundaries.

I have now checked in the changes and the parameters for the BNG projection.

I think everything is working, but I couldn't get OpenLayers to do the
expected thing in the BNG projection and the tile numbers it requests
don't quite match up. So I couldn't verify that things do work. So
please let me know if anything else is broken,

Kai


On 08/15/2013 05:23 AM, Jason Lee wrote:
> Hi,
> I downloaded the latest mod_tile source code with the projections
> support and manually added a BNG projection config in "gen_tile.cpp" as
> follows:-
> 
> ======================
>     else if (strcmp(srs, "+proj=tmerc +lat_0=49 +lon_0=-2
> +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36
> +units=m +no_defs") == 0) {
>         syslog(LOG_DEBUG, "Using bng projection settings");
>         prj = (struct projectionconfig *)malloc(sizeof(struct
> projectionconfig));
>         prj->bound_x0 = 0.0;
>         prj->bound_y0 = 0.0;
>         prj->bound_x1 = 700000.0;
>         prj->bound_y1 = 1300000.0;
>         prj->aspect_x = 1;
>         prj->aspect_y = 2;
>   }
> ======================
> 
> This doesn't give me the expected map when I view the top tile 0/0/0.png
> it just shows the bottom southwest tip of GB.
> 
> I am trying to replicate the same top map tiles as OSM-GB project's
> given here:-
> http://lgosmgb2.nottingham.ac.uk:8080/geoserver/gwc/service/tms/1.0.0/OSM-GB:__all__@EPSG:27700@png/0/0/0.png
> http://lgosmgb2.nottingham.ac.uk:8080/geoserver/gwc/service/tms/1.0.0/OSM-GB:__all__@EPSG:27700@png/0/0/1.png
> 
> ..but my mod_tile returns a 404 for tile 0/0/1.png - is it because it
> always expects 1 top tile at zoom 0?
> 
> 
> On 2 April 2013 12:36, Jason Lee <jaslee.st at gmail.com
> <mailto:jaslee.st at gmail.com>> wrote:
> 
>     Kai and all other respondents,
>     This is great response to my query and I will definitely continue to
>     look into using the latest mod_tile/renderd code to work - in my
>     specific case - with British National Grid projection, 27700.
> 
>     Jason
> 
> 
>     On 26 March 2013 04:44, Kai Krueger <kakrueger at gmail.com
>     <mailto:kakrueger at gmail.com>> wrote:
> 
>         On 03/07/2013 08:36 AM, Jason Lee wrote:
> 
>             Hi all,
>             It might seem an odd question but I'll give it a shot -
>             would mod_tile/renderd support the dynamic generation of map
>             tiles in a map projection other than web mercator? If not,
>             then would it be possible/how difficult would it be to
>             modify the code to support it?
> 
>         In case you are still interested, I have now refactored the code
>         a bit to make it easier to support different projections.
>         Supporting new projections now should be as simple as adding 6
>         numbers, (the boundaries in projected coordinates and the map
>         aspect ratio). For the moment you still need to recompile
>         renderd after changing / adding those numbers, but in the future
>         that might change.
> 
>         At the moment it supports spherical mercator and plate carree
>         out of the box and they can be mixed in the same rendering
>         server. You configure those by changing the srs of the mapnik
>         style sheet to the appropriate values.
> 
>         Also it is now possible to configure the size of the tiles in
>         renderd.conf and it is no longer hard coded to be 256 px. (You
>         still need to change the mapnik stylesheet for the appropriate
>         PPI though).
> 
>         Kai
> 
> 
>             The only other thing I can think of is using MapProxy with
>             Mapnik backend but I'm not sure the scalabilty/performance
>             compared to mod_tile.
> 
>             Thanks and regards,
>             Jason
> 
> 
> 
> 




More information about the dev mailing list