[Tilecache] Projecting with a different SRS

Dane Springmeyer blake at hailmail.net
Fri Aug 29 13:52:12 EDT 2008


Tyler, if you are familiar with IRC, you can jump into #mapnik on  
irc.freenode.net.

Comments inline...


On Aug 29, 2008, at 10:16 AM, Tyler Durden wrote:

> Dane,
> Thank very much about the link, was very useful.
> Now I can reproject the map to world mercator with python, but with
> tilecache not.

Good, I'm glad it was helpful. I'm always looking for help writing  
documentation for how to set up those sample scripts so let me know if  
you ever have any writeups :)

So, you can successfully render a 'reprojected' map from your postgis  
data in WGS 84/EPSG:4326.

And I assume the debug output from below is not from that reprojected  
map but now from your tilecache attempt?

>
> I don't know what I must use in openlayers, degrees or meters?

I don't think the units setting will make any difference.

> I have DEBUG=True on mapnik and returns for an example tile:
> scale=0.000793687
> start map processing
> bbox=Envelope(-14.006829872,35.076524128,-12.584542768,36.498811232)

ignore this first bbox, as it is usually just an initial one....

> scale denominator = 2.8346
> start layer processing : a0
> datasource = 0x82fade8
> borrow 0x83369e8
> select asbinary(the_geom) as geom from pt_a0 where the_geom &&
> setSRID('BOX3D(-6.18997144699097
> 0.0003278743998163994,-0.0001258254935607948
> 32.63284683227539)'::box3d,4326)

Okay, so this is pulling from postgis in EPSG:4326. You can copy and  
paste this into a psql interpreter to make sure it is actually  
resulting in a bunch of features...


> ENCODING = UTF8
> return 0x83369e8
> end layer processing
> end map processing
>
> As you can see the latitudes are completely wrong, should be something
> around 40.00000 and not 0.0000xxxx


Well, ya they look a little strange but they seem to be reasonable  
bounds for EPSG:4326, so I'm not sure there is anything wrong with that.

The below has several problems, sorry to say.


>
>
> tilecache.cfg:
> ==========
>
> [map]
> type=MapnikLayer
> mapfile=/home/tyler/projects/maps/tilecache/osm.xml
>
> # Degree
> bbox=-13.803646, 35.279708, 0.920709, 43.888966
> maxResolution=0.012699
> resolutions=0.012699, 0.0063495, 0.00317475, 0.001587375, 0.000793687,
> 0.000396844, 0.000198422, 0.000099211, 0.000049605, 0.000024803
> srs=EPSG:4326
> projection=+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0
> +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs +over
> levels=10
> extension=png
> debug=no
> size=256,256
> metaTile=yes
> metaBuffer=256
>
> In the javascript openlayers parameters:
> { numZoomLevels : 10,
>  projection    : "epsg:4326",
>  maxResolution : 0.012699,
>  resolutions   : [0.012699, 0.0063495, 0.00317475, 0.001587375,
> 0.000793687, 0.000396844, 0.000198422, 0.000099211, 0.000049605,
> 0.000024803 ],
>  maxExtent     : new OpenLayers.Bounds(-13.803646, 35.279708,
> 0.920709, 43.888966) }


If you want your data in EPSG:4326 then all of your bounds, bbox, etc  
need to be in those coordinates, and you DO NOT want to specify  
'projection=+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.  
+x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs +over'  
because you are then mixing your requests to tilecache and mapnik and  
this is NOT GOING TO WORK.

This whole time you have indicated that you want to reproject data  
from mapnik into OpenLayers using Tilecache in EPSG:3395. Now it  
appears that you have a setup that is trying to get data in EPSG:4326.

I would recommend getting it to work in EPSG:4326 first, but you'll  
need to take away that projection line then... and just do away with  
most of your other settings in both the Tilecache config and the  
OpenLayers map options because both have the RIGHT defaults for EPSG: 
4326.

You can find a sample configuration that reads a world_borders  
shapefile in ESPG:4326 here:

http://mapnik-utils.googlecode.com/svn/trunk/tutorials/tilecache/

You should be able to modify fairly easily to point to your OSM xml  
and the postgis datasource within it.

I would try to start with that and get it working first before you try  
to reprojection your data.

Dane



More information about the Tilecache mailing list