+ reflect mapnik::proj_transform in Python (#117)

This commit is contained in:
Artem Pavlenko 2009-01-13 15:49:26 +00:00
parent 54f4d3bc51
commit fd194e2ba6
2 changed files with 62 additions and 0 deletions

View file

@ -0,0 +1,60 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2009 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
// mapnik
#include <mapnik/proj_transform.hpp>
// boost
#include <boost/python.hpp>
namespace {
mapnik::coord2d forward_transform(mapnik::proj_transform& t, mapnik::coord2d const& c)
{
double x = c.x;
double y = c.y;
double z = 0.0;
t.forward(x,y,z);
return mapnik::coord2d(x,y);
}
mapnik::coord2d backward_transform(mapnik::proj_transform& t, mapnik::coord2d const& c)
{
double x = c.x;
double y = c.y;
double z = 0.0;
t.backward(x,y,z);
return mapnik::coord2d(x,y);
}
}
void export_proj_transform ()
{
using namespace boost::python;
using mapnik::proj_transform;
using mapnik::projection;
class_<proj_transform, boost::noncopyable>("ProjTransform", init< projection const&, projection const& >())
.def("forward", forward_transform)
.def("backward",backward_transform)
;
}

View file

@ -56,6 +56,7 @@ void export_text_symbolizer();
void export_shield_symbolizer(); void export_shield_symbolizer();
void export_font_engine(); void export_font_engine();
void export_projection(); void export_projection();
void export_proj_transform();
#include <mapnik/map.hpp> #include <mapnik/map.hpp>
#include <mapnik/agg_renderer.hpp> #include <mapnik/agg_renderer.hpp>
@ -186,6 +187,7 @@ BOOST_PYTHON_MODULE(_mapnik)
export_shield_symbolizer(); export_shield_symbolizer();
export_font_engine(); export_font_engine();
export_projection(); export_projection();
export_proj_transform();
export_coord(); export_coord();
export_map(); export_map();