[Tilesathome] Projection questions

Frederik Ramm frederik at remote.org
Wed Aug 22 09:57:54 BST 2007


Hi,

> I am trying to figure out what projection t at h should use when  
> producing low-zoom tiles. I implemented a mercator preprocessor  
> into the t at h client which just needs plugging the right formulas  
> into it.

I sincerely hope you're using the Proj4 Perl package for this instead  
of trying to do the projection on your own?

> Currently osmarender uses the lat/lon as YX coordinate system, is  
> that true?

No. Using lat/lon directly would give you an EPSG4326 "projection",  
not a Mercator one. Osmarender uses an approximate Mercator  
projection. It is approximate in two ways:

The first approximation is described on http://wiki.openstreetmap.org/ 
index.php/Osmarender_bug and has to do with the way projection is  
applied.

The second approximation lies in the fact that XSLT does not support  
(or at least, not easily?) trigonometric functions, so Osmarender has  
to use an approximate cosine instead of the real thing; search for  
'name="coslat"' in osmarender.xsl to see what it does.

> That means plotted points are basically mercator projected, as 1  
> degree longitude will always have the same distance, the same with  
> latitude. Or am I on the wrong track here?

Either I am misunderstanding you or you're confused. Mercator  
projection means that latitude and longitude lines form a rectangular  
grid; so yes, in the projected data the number of pixels between two  
lat lines or two lon lines will be constant.

> While longitude is the same, lat is not why that difference? Also  
> why is IFW adding 90 to the latitude here? And where does the  
> number 200k comes from? Is that earth perimeter by 2?

Don't bother, just use the Proj4 library.

> Wikipedia's site uses lan(tan(lat)+sec(lat)) to get to mercator y  
> values. From what I can see on their page they are using degrees  
> for lat input, but I was told that it uses radian by someone on IRC:

Don't bother, just use the Proj4 library.

> OK, after trying out the values Informationfreeway uses as lat/lon  
> with horrible results in osmarender, is what I should be doing here  
> just transforming the lat value into its mercator value? eg the  
> lat=52 would just become lat=61.09 ?

It is helpful to speak of projected values not as latitude and  
longitude values, but as northings and eastings. A Mercator  
projection will typically give you values with (0,0) being the lower  
left corner of the world map.

> Or shouldn't we be doing any transformation at all here?

I think we should have an extra preprocessor (not part of the t at h  
script itself) that takes an OSM XML file, adds "north=..." and  
"east=..." values to each node (using Proj4!), and then change  
Osmarender so that it uses these, if present, instead of its own  
projection.

That would enable people to create nice looking maps with Osmarender  
even if they happen to be some distance away from the Equator - these  
folks will very likely want to use something that is not Mercator.

Bye
Frederik

-- 
Frederik Ramm  ##  eMail frederik at remote.org  ##  N49°00.09' E008°23.33'






More information about the Tilesathome mailing list