Hi all.
I've got a web map editor using Leaflet.draw where users draw some stuff in a EPSG:3857 view.
My data is then saved as lat/long to a PostGIS database in EPSG:4326.
I'm trying to rotate and then render (using Mapnik) this data, but when I do, things come out skewed. I feel like I must be misunderstanding a piece of the projection pie.
For reference, here's what the users draw, and what I render if I do not rotate:
Here's what I would like to see (simply rotated in GIMP, proportions stay correct):
but here's what I get instead (code shown below):
(notice that some of the shapes are no longer square).
I'm using the Python Mapnik bindings and here's the relevant code snippet:
m = mapnik2.Map(1000,1000)
m.srs = "+init=epsg:3857"
sql = '(SELECT ST_Rotate(geom,radians(%d),(select centroid from map where id=%d) as newgeom FROM polygons WHERE map_id =%d) as data' % (map.orientation,
map.id,
map.id)
layer = mapnik2.Layer('Buildings')
layer.srs = "+init=epsg:4326"
layer.datasource = mapnik2.PostGIS(table=sql,geometry_field="newgeom",extent_from_subquery=True,st_prefix=True,srid=4326)
I'm operating at a fairly high latitude here (52 N), so I'm guessing that it has something to do with the fact that EPSG:3857 doesn't have the same scale N/S as it does E/W at that location, but I just can't seem to figure out how to go about getting the result I want.
Can anyone give me a hint in the right direction?
daniel