From 2d47f24a7e7701c91db1ced34bb3a1b8708b217f Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Sun, 25 Jan 2009 19:02:07 +0000 Subject: [PATCH] + added ability to transform Envelopes in addition to Coords in new python ProjTransform, closes #117 --- CHANGELOG | 8 ++++-- bindings/python/mapnik_proj_transform.cpp | 34 ++++++++++++++++++++--- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index b79d44de5..147f81d37 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,8 +14,10 @@ For a complete change history, see the SVN log. Current Version (0.6.0-dev, SVN trunk): --------------------------------------- -- python/mapnik_map.cpp, map.hpp, and map.cpp: Made available the scale_denominator property from the map in c++ and python (r793) +- Python: Made available the scale_denominator property from the map in c++ and python (r793) -- python/mapnik_map.cpp: Added ability to resize map and clear all layers and styles from python (r792) +- Python: Added ability to resize map and clear all layers and styles from python (r793) -- load_map.cpp and save_map.cpp: Added xml serialization for abstract, title, minzoom, maxzoom, and queryable attributes (r787) \ No newline at end of file +- Python: Exposed Proj to/from transformation for projected coordinate systems (r792,r821) (#117) + +- XML: Added xml serialization for abstract, title, minzoom, maxzoom, and queryable attributes (r787) \ No newline at end of file diff --git a/bindings/python/mapnik_proj_transform.cpp b/bindings/python/mapnik_proj_transform.cpp index 4d891a66f..b1bdb87bf 100644 --- a/bindings/python/mapnik_proj_transform.cpp +++ b/bindings/python/mapnik_proj_transform.cpp @@ -28,7 +28,7 @@ namespace { - mapnik::coord2d forward_transform(mapnik::proj_transform& t, mapnik::coord2d const& c) + mapnik::coord2d forward_transform_c(mapnik::proj_transform& t, mapnik::coord2d const& c) { double x = c.x; double y = c.y; @@ -37,7 +37,7 @@ namespace { return mapnik::coord2d(x,y); } - mapnik::coord2d backward_transform(mapnik::proj_transform& t, mapnik::coord2d const& c) + mapnik::coord2d backward_transform_c(mapnik::proj_transform& t, mapnik::coord2d const& c) { double x = c.x; double y = c.y; @@ -45,6 +45,30 @@ namespace { t.backward(x,y,z); return mapnik::coord2d(x,y); } + + mapnik::Envelope forward_transform_env(mapnik::proj_transform& t, mapnik::Envelope const & box) + { + double minx = box.minx(); + double miny = box.miny(); + double maxx = box.maxx(); + double maxy = box.maxy(); + double z = 0.0; + t.forward(minx,miny,z); + t.forward(maxx,maxy,z); + return mapnik::Envelope(minx,miny,maxx,maxy); + } + + mapnik::Envelope backward_transform_env(mapnik::proj_transform& t, mapnik::Envelope const & box) + { + double minx = box.minx(); + double miny = box.miny(); + double maxx = box.maxx(); + double maxy = box.maxy(); + double z = 0.0; + t.backward(minx,miny,z); + t.backward(maxx,maxy,z); + return mapnik::Envelope(minx,miny,maxx,maxy); + } } void export_proj_transform () @@ -53,8 +77,10 @@ void export_proj_transform () using mapnik::proj_transform; using mapnik::projection; class_("ProjTransform", init< projection const&, projection const& >()) - .def("forward", forward_transform) - .def("backward",backward_transform) + .def("forward", forward_transform_c) + .def("backward",backward_transform_c) + .def("forward", forward_transform_env) + .def("backward",backward_transform_env) ; }