+ added ability to transform Envelopes in addition to Coords in new python ProjTransform, closes #117

This commit is contained in:
Dane Springmeyer 2009-01-25 19:02:07 +00:00
parent 6f98c95c1f
commit 2d47f24a7e
2 changed files with 35 additions and 7 deletions

View file

@ -14,8 +14,10 @@ For a complete change history, see the SVN log.
Current Version (0.6.0-dev, SVN trunk): 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) - 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)

View file

@ -28,7 +28,7 @@
namespace { 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 x = c.x;
double y = c.y; double y = c.y;
@ -37,7 +37,7 @@ namespace {
return mapnik::coord2d(x,y); 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 x = c.x;
double y = c.y; double y = c.y;
@ -45,6 +45,30 @@ namespace {
t.backward(x,y,z); t.backward(x,y,z);
return mapnik::coord2d(x,y); return mapnik::coord2d(x,y);
} }
mapnik::Envelope<double> forward_transform_env(mapnik::proj_transform& t, mapnik::Envelope<double> 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<double>(minx,miny,maxx,maxy);
}
mapnik::Envelope<double> backward_transform_env(mapnik::proj_transform& t, mapnik::Envelope<double> 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<double>(minx,miny,maxx,maxy);
}
} }
void export_proj_transform () void export_proj_transform ()
@ -53,8 +77,10 @@ void export_proj_transform ()
using mapnik::proj_transform; using mapnik::proj_transform;
using mapnik::projection; using mapnik::projection;
class_<proj_transform, boost::noncopyable>("ProjTransform", init< projection const&, projection const& >()) class_<proj_transform, boost::noncopyable>("ProjTransform", init< projection const&, projection const& >())
.def("forward", forward_transform) .def("forward", forward_transform_c)
.def("backward",backward_transform) .def("backward",backward_transform_c)
.def("forward", forward_transform_env)
.def("backward",backward_transform_env)
; ;
} }