2006-03-31 10:32:02 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
* This file is part of Mapnik (c++ mapping toolkit)
|
2006-01-31 23:09:52 +00:00
|
|
|
*
|
2006-03-31 10:32:02 +00:00
|
|
|
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
|
2006-01-31 23:09:52 +00:00
|
|
|
*
|
2006-03-31 10:32:02 +00:00
|
|
|
* 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,
|
2006-01-31 23:09:52 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2006-03-31 10:32:02 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2006-01-31 23:09:52 +00:00
|
|
|
*
|
2006-03-31 10:32:02 +00:00
|
|
|
* 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
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
2006-01-31 23:09:52 +00:00
|
|
|
//$Id: mapnik_map.cc 17 2005-03-08 23:58:43Z pavlenko $
|
|
|
|
|
2009-03-21 11:22:10 +00:00
|
|
|
// boost
|
2006-01-31 23:09:52 +00:00
|
|
|
#include <boost/python.hpp>
|
|
|
|
#include <boost/python/detail/api_placeholder.hpp>
|
|
|
|
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
|
2006-09-11 09:48:27 +00:00
|
|
|
|
2009-03-21 11:22:10 +00:00
|
|
|
// mapnik
|
2006-10-04 11:22:18 +00:00
|
|
|
#include <mapnik/layer.hpp>
|
|
|
|
#include <mapnik/map.hpp>
|
2009-02-15 19:53:48 +00:00
|
|
|
#include <mapnik/feature_type_style.hpp>
|
2011-03-16 13:32:04 +00:00
|
|
|
#include <mapnik/metawriter_inmem.hpp>
|
2006-01-31 23:09:52 +00:00
|
|
|
|
2009-03-21 11:22:10 +00:00
|
|
|
#include "mapnik_enumeration.hpp"
|
2007-08-01 09:59:23 +00:00
|
|
|
#include "python_optional.hpp"
|
|
|
|
|
2009-01-14 12:10:24 +00:00
|
|
|
using mapnik::color;
|
2006-01-31 23:09:52 +00:00
|
|
|
using mapnik::coord;
|
2009-12-16 20:02:06 +00:00
|
|
|
using mapnik::box2d;
|
|
|
|
using mapnik::layer;
|
2006-01-31 23:09:52 +00:00
|
|
|
using mapnik::Map;
|
|
|
|
|
|
|
|
struct map_pickle_suite : boost::python::pickle_suite
|
|
|
|
{
|
2010-06-02 11:03:30 +00:00
|
|
|
static boost::python::tuple
|
|
|
|
getinitargs(const Map& m)
|
|
|
|
{
|
2010-06-25 15:23:35 +00:00
|
|
|
return boost::python::make_tuple(m.width(),m.height(),m.srs());
|
2010-06-02 11:03:30 +00:00
|
|
|
}
|
2006-01-31 23:09:52 +00:00
|
|
|
|
2010-06-02 11:03:30 +00:00
|
|
|
static boost::python::tuple
|
|
|
|
getstate(const Map& m)
|
|
|
|
{
|
2009-02-15 19:53:48 +00:00
|
|
|
boost::python::list l;
|
2010-06-25 15:23:35 +00:00
|
|
|
for (unsigned i=0;i<m.layer_count();++i)
|
2009-02-15 19:53:48 +00:00
|
|
|
{
|
|
|
|
l.append(m.getLayer(i));
|
|
|
|
}
|
|
|
|
|
|
|
|
boost::python::list s;
|
|
|
|
Map::const_style_iterator it = m.styles().begin();
|
|
|
|
Map::const_style_iterator end = m.styles().end();
|
|
|
|
for (; it != end; ++it)
|
|
|
|
{
|
|
|
|
const std::string & name = it->first;
|
|
|
|
const mapnik::feature_type_style & style = it->second;
|
|
|
|
boost::python::tuple style_pair = boost::python::make_tuple(name,style);
|
|
|
|
s.append(style_pair);
|
|
|
|
}
|
|
|
|
|
2011-05-25 23:48:07 +00:00
|
|
|
return boost::python::make_tuple(m.get_current_extent(),m.background(),l,s,m.base_path());
|
2010-06-02 11:03:30 +00:00
|
|
|
}
|
2006-01-31 23:09:52 +00:00
|
|
|
|
2010-06-02 11:03:30 +00:00
|
|
|
static void
|
|
|
|
setstate (Map& m, boost::python::tuple state)
|
|
|
|
{
|
2009-02-15 19:53:48 +00:00
|
|
|
using namespace boost::python;
|
2011-05-25 23:48:07 +00:00
|
|
|
if (len(state) != 5)
|
2009-02-15 19:53:48 +00:00
|
|
|
{
|
|
|
|
PyErr_SetObject(PyExc_ValueError,
|
2011-05-25 23:48:07 +00:00
|
|
|
("expected 5-item tuple in call to __setstate__; got %s"
|
2010-06-02 11:03:30 +00:00
|
|
|
% state).ptr()
|
|
|
|
);
|
2009-02-15 19:53:48 +00:00
|
|
|
throw_error_already_set();
|
|
|
|
}
|
|
|
|
|
2009-12-16 20:02:06 +00:00
|
|
|
box2d<double> ext = extract<box2d<double> >(state[0]);
|
2010-06-25 15:23:35 +00:00
|
|
|
m.zoom_to_box(ext);
|
2009-02-15 19:53:48 +00:00
|
|
|
if (state[1])
|
|
|
|
{
|
|
|
|
color bg = extract<color>(state[1]);
|
|
|
|
m.set_background(bg);
|
|
|
|
}
|
|
|
|
|
|
|
|
boost::python::list l=extract<boost::python::list>(state[2]);
|
|
|
|
for (int i=0;i<len(l);++i)
|
|
|
|
{
|
2009-12-16 20:02:06 +00:00
|
|
|
m.addLayer(extract<layer>(l[i]));
|
2009-02-15 19:53:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
boost::python::list s=extract<boost::python::list>(state[3]);
|
|
|
|
for (int i=0;i<len(s);++i)
|
|
|
|
{
|
|
|
|
boost::python::tuple style_pair=extract<boost::python::tuple>(s[i]);
|
|
|
|
std::string name = extract<std::string>(style_pair[0]);
|
|
|
|
mapnik::feature_type_style style = extract<mapnik::feature_type_style>(style_pair[1]);
|
2010-08-27 16:16:16 +00:00
|
|
|
m.insert_style(name, style);
|
2009-02-15 19:53:48 +00:00
|
|
|
}
|
2011-05-25 23:48:07 +00:00
|
|
|
|
|
|
|
if (state[4])
|
|
|
|
{
|
|
|
|
std::string base_path = extract<std::string>(state[4]);
|
|
|
|
m.set_base_path(base_path);
|
|
|
|
}
|
2010-06-02 11:03:30 +00:00
|
|
|
}
|
2006-01-31 23:09:52 +00:00
|
|
|
};
|
|
|
|
|
2009-12-16 20:02:06 +00:00
|
|
|
std::vector<layer>& (Map::*layers_nonconst)() = &Map::layers;
|
|
|
|
std::vector<layer> const& (Map::*layers_const)() const = &Map::layers;
|
1. hit_test implementation for geometry objects:
bool hit_test(double x, double y, double tol);
2. added image_view(unsigned x, unsigned y, unsigned width, unsigned height)
allowing to select region from image data e.g (in Python):
im = Image(2048,2048)
view = im.view(0,0,256,256)
save_to_file(filename,type, view)
3. changed envelope method to return vy value in datasource classes
4. features_at_point impl for shape and postgis plug-ins
2006-11-25 11:02:59 +00:00
|
|
|
|
2008-11-18 21:15:46 +00:00
|
|
|
|
|
|
|
mapnik::feature_type_style find_style (mapnik::Map const& m, std::string const& name)
|
|
|
|
{
|
2010-06-02 11:03:30 +00:00
|
|
|
boost::optional<mapnik::feature_type_style const&> style = m.find_style(name);
|
|
|
|
if (!style)
|
|
|
|
{
|
|
|
|
PyErr_SetString(PyExc_KeyError, "Invalid style name");
|
|
|
|
boost::python::throw_error_already_set();
|
|
|
|
}
|
|
|
|
return *style;
|
2008-11-18 21:15:46 +00:00
|
|
|
}
|
|
|
|
|
2010-11-10 18:40:23 +00:00
|
|
|
bool has_metawriter(mapnik::Map const& m)
|
|
|
|
{
|
|
|
|
if (m.metawriters().size() >=1)
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-03-16 13:32:04 +00:00
|
|
|
// returns empty shared_ptr when the metawriter isn't found, or is
|
|
|
|
// of the wrong type. empty pointers make it back to Python as a None.
|
|
|
|
mapnik::metawriter_inmem_ptr find_inmem_metawriter(const mapnik::Map &m, const std::string &name) {
|
|
|
|
mapnik::metawriter_ptr metawriter = m.find_metawriter(name);
|
|
|
|
mapnik::metawriter_inmem_ptr inmem;
|
|
|
|
|
|
|
|
if (metawriter) {
|
|
|
|
inmem = boost::dynamic_pointer_cast<mapnik::metawriter_inmem>(metawriter);
|
|
|
|
}
|
|
|
|
|
|
|
|
return inmem;
|
|
|
|
}
|
|
|
|
|
2010-08-27 16:16:16 +00:00
|
|
|
// TODO - we likely should allow indexing by negative number from python
|
|
|
|
// for now, protect against negative values and kindly throw
|
|
|
|
mapnik::featureset_ptr query_point(mapnik::Map const& m, int index, double x, double y)
|
|
|
|
{
|
|
|
|
if (index < 0){
|
|
|
|
PyErr_SetString(PyExc_IndexError, "Please provide a layer index >= 0");
|
|
|
|
boost::python::throw_error_already_set();
|
|
|
|
}
|
|
|
|
unsigned idx = index;
|
|
|
|
return m.query_point(idx, x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
mapnik::featureset_ptr query_map_point(mapnik::Map const& m, int index, double x, double y)
|
|
|
|
{
|
|
|
|
if (index < 0){
|
|
|
|
PyErr_SetString(PyExc_IndexError, "Please provide a layer index >= 0");
|
|
|
|
boost::python::throw_error_already_set();
|
|
|
|
}
|
|
|
|
unsigned idx = index;
|
|
|
|
return m.query_map_point(idx, x, y);
|
|
|
|
}
|
|
|
|
|
2006-01-31 23:09:52 +00:00
|
|
|
void export_map()
|
|
|
|
{
|
2010-06-02 11:03:30 +00:00
|
|
|
using namespace boost::python;
|
2009-03-21 11:22:10 +00:00
|
|
|
|
2010-06-02 11:03:30 +00:00
|
|
|
// aspect ratio fix modes
|
|
|
|
mapnik::enumeration_<mapnik::aspect_fix_mode_e>("aspect_fix_mode")
|
|
|
|
.value("GROW_BBOX", mapnik::Map::GROW_BBOX)
|
|
|
|
.value("GROW_CANVAS",mapnik::Map::GROW_CANVAS)
|
|
|
|
.value("SHRINK_BBOX",mapnik::Map::SHRINK_BBOX)
|
|
|
|
.value("SHRINK_CANVAS",mapnik::Map::SHRINK_CANVAS)
|
|
|
|
.value("ADJUST_BBOX_WIDTH",mapnik::Map::ADJUST_BBOX_WIDTH)
|
|
|
|
.value("ADJUST_BBOX_HEIGHT",mapnik::Map::ADJUST_BBOX_HEIGHT)
|
|
|
|
.value("ADJUST_CANVAS_WIDTH",mapnik::Map::ADJUST_CANVAS_WIDTH)
|
|
|
|
.value("ADJUST_CANVAS_HEIGHT", mapnik::Map::ADJUST_CANVAS_HEIGHT)
|
|
|
|
;
|
2009-03-21 11:22:10 +00:00
|
|
|
|
2010-06-02 11:03:30 +00:00
|
|
|
python_optional<mapnik::color> ();
|
|
|
|
class_<std::vector<layer> >("Layers")
|
|
|
|
.def(vector_indexing_suite<std::vector<layer> >())
|
|
|
|
;
|
2008-11-17 23:44:50 +00:00
|
|
|
|
2010-06-02 11:03:30 +00:00
|
|
|
class_<Map>("Map","The map object.",init<int,int,optional<std::string const&> >(
|
|
|
|
( arg("width"),arg("height"),arg("srs") ),
|
|
|
|
"Create a Map with a width and height as integers and, optionally,\n"
|
|
|
|
"an srs string either with a Proj.4 epsg code ('+init=epsg:<code>')\n"
|
|
|
|
"or with a Proj.4 literal ('+proj=<literal>').\n"
|
2010-08-10 18:18:31 +00:00
|
|
|
"If no srs is specified the map will default to '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'\n"
|
2010-06-02 11:03:30 +00:00
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
">>> from mapnik import Map\n"
|
|
|
|
">>> m = Map(600,400)\n"
|
|
|
|
">>> m\n"
|
|
|
|
"<mapnik._mapnik.Map object at 0x6a240>\n"
|
|
|
|
">>> m.srs\n"
|
2010-08-10 18:18:31 +00:00
|
|
|
"'+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'\n"
|
2010-06-02 11:03:30 +00:00
|
|
|
))
|
2008-11-17 23:44:50 +00:00
|
|
|
|
2010-06-02 11:03:30 +00:00
|
|
|
.def_pickle(map_pickle_suite()
|
|
|
|
)
|
2008-11-17 23:44:50 +00:00
|
|
|
|
2010-06-02 11:03:30 +00:00
|
|
|
.def("append_style",&Map::insert_style,
|
2010-08-27 16:16:16 +00:00
|
|
|
(arg("style_name"),arg("style_object")),
|
2010-06-02 11:03:30 +00:00
|
|
|
"Insert a Mapnik Style onto the map by appending it.\n"
|
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
">>> sty\n"
|
|
|
|
"<mapnik._mapnik.Style object at 0x6a330>\n"
|
|
|
|
">>> m.append_style('Style Name', sty)\n"
|
|
|
|
"True # style object added to map by name\n"
|
|
|
|
">>> m.append_style('Style Name', sty)\n"
|
|
|
|
"False # you can only append styles with unique names\n"
|
|
|
|
)
|
2009-01-14 04:52:04 +00:00
|
|
|
|
2010-06-02 11:03:30 +00:00
|
|
|
.def("buffered_envelope",
|
|
|
|
&Map::get_buffered_extent,
|
2010-08-27 16:16:16 +00:00
|
|
|
"Get the Box2d() of the Map given\n"
|
2010-06-02 11:03:30 +00:00
|
|
|
"the Map.buffer_size.\n"
|
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
">>> m = Map(600,400)\n"
|
|
|
|
">>> m.envelope()\n"
|
2010-08-27 16:16:16 +00:00
|
|
|
"Box2d(-1.0,-1.0,0.0,0.0)\n"
|
2010-06-02 11:03:30 +00:00
|
|
|
">>> m.buffered_envelope()\n"
|
2010-08-27 16:16:16 +00:00
|
|
|
"Box2d(-1.0,-1.0,0.0,0.0)\n"
|
2010-06-02 11:03:30 +00:00
|
|
|
">>> m.buffer_size = 1\n"
|
|
|
|
">>> m.buffered_envelope()\n"
|
2010-08-27 16:16:16 +00:00
|
|
|
"Box2d(-1.02222222222,-1.02222222222,0.0222222222222,0.0222222222222)\n"
|
2010-06-02 11:03:30 +00:00
|
|
|
)
|
2009-03-30 04:17:03 +00:00
|
|
|
|
2010-06-02 11:03:30 +00:00
|
|
|
.def("envelope",
|
2010-06-25 15:23:35 +00:00
|
|
|
make_function(&Map::get_current_extent,
|
2010-06-02 11:03:30 +00:00
|
|
|
return_value_policy<copy_const_reference>()),
|
2010-08-27 16:16:16 +00:00
|
|
|
"Return the Map Box2d object\n"
|
2010-06-02 11:03:30 +00:00
|
|
|
"and print the string representation\n"
|
|
|
|
"of the current extent of the map.\n"
|
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
">>> m.envelope()\n"
|
2010-08-27 16:16:16 +00:00
|
|
|
"Box2d(-0.185833333333,-0.96,0.189166666667,-0.71)\n"
|
2010-06-02 11:03:30 +00:00
|
|
|
">>> dir(m.envelope())\n"
|
|
|
|
"...'center', 'contains', 'expand_to_include', 'forward',\n"
|
|
|
|
"...'height', 'intersect', 'intersects', 'inverse', 'maxx',\n"
|
|
|
|
"...'maxy', 'minx', 'miny', 'width'\n"
|
|
|
|
)
|
2009-02-02 23:39:20 +00:00
|
|
|
|
2010-06-02 11:03:30 +00:00
|
|
|
.def("find_style",
|
2010-08-27 16:16:16 +00:00
|
|
|
find_style,
|
|
|
|
(arg("style_name")),
|
2010-06-02 11:03:30 +00:00
|
|
|
"Query the Map for a style by name and return\n"
|
|
|
|
"a style object if found or raise KeyError\n"
|
|
|
|
"style if not found.\n"
|
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
">>> m.find_style('Style Name')\n"
|
|
|
|
"<mapnik._mapnik.Style object at 0x654f0>\n"
|
|
|
|
)
|
2010-11-10 18:40:23 +00:00
|
|
|
|
|
|
|
.def("has_metawriter",
|
|
|
|
has_metawriter,
|
|
|
|
"Check if the Map has any active metawriters\n"
|
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
">>> m.has_metawriter()\n"
|
|
|
|
"False\n"
|
|
|
|
)
|
2008-11-17 23:44:50 +00:00
|
|
|
|
2010-06-02 11:03:30 +00:00
|
|
|
.def("pan",&Map::pan,
|
2010-08-27 16:16:16 +00:00
|
|
|
(arg("x"),arg("y")),
|
2010-06-02 11:03:30 +00:00
|
|
|
"Set the Map center at a given x,y location\n"
|
|
|
|
"as integers in the coordinates of the pixmap or map surface.\n"
|
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
">>> m = Map(600,400)\n"
|
|
|
|
">>> m.envelope().center()\n"
|
|
|
|
"Coord(-0.5,-0.5) # default Map center\n"
|
|
|
|
">>> m.pan(-1,-1)\n"
|
|
|
|
">>> m.envelope().center()\n"
|
|
|
|
"Coord(0.00166666666667,-0.835)\n"
|
|
|
|
)
|
2008-11-17 23:44:50 +00:00
|
|
|
|
2010-06-02 11:03:30 +00:00
|
|
|
.def("pan_and_zoom",&Map::pan_and_zoom,
|
2010-08-27 16:16:16 +00:00
|
|
|
(arg("x"),arg("y"),arg("factor")),
|
2010-06-02 11:03:30 +00:00
|
|
|
"Set the Map center at a given x,y location\n"
|
|
|
|
"and zoom factor as a float.\n"
|
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
">>> m = Map(600,400)\n"
|
|
|
|
">>> m.envelope().center()\n"
|
|
|
|
"Coord(-0.5,-0.5) # default Map center\n"
|
|
|
|
">>> m.scale()\n"
|
|
|
|
"-0.0016666666666666668\n"
|
|
|
|
">>> m.pan_and_zoom(-1,-1,0.25)\n"
|
|
|
|
">>> m.scale()\n"
|
|
|
|
"0.00062500000000000001\n"
|
|
|
|
)
|
2008-11-17 23:44:50 +00:00
|
|
|
|
2010-08-27 16:16:16 +00:00
|
|
|
.def("query_map_point",query_map_point,
|
|
|
|
(arg("layer_idx"),arg("pixel_x"),arg("pixel_y")),
|
2010-06-02 11:03:30 +00:00
|
|
|
"Query a Map Layer (by layer index) for features \n"
|
2010-08-27 16:16:16 +00:00
|
|
|
"intersecting the given x,y location in the pixel\n"
|
|
|
|
"coordinates of the rendered map image.\n"
|
|
|
|
"Layer index starts at 0 (first layer in map).\n"
|
2010-06-02 11:03:30 +00:00
|
|
|
"Will return a Mapnik Featureset if successful\n"
|
|
|
|
"otherwise will return None.\n"
|
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
">>> featureset = m.query_map_point(0,200,200)\n"
|
|
|
|
">>> featureset\n"
|
|
|
|
"<mapnik._mapnik.Featureset object at 0x23b0b0>\n"
|
|
|
|
">>> featureset.features\n"
|
|
|
|
">>> [<mapnik.Feature object at 0x3995630>]\n"
|
|
|
|
)
|
2008-11-17 23:44:50 +00:00
|
|
|
|
2010-08-27 16:16:16 +00:00
|
|
|
.def("query_point",query_point,
|
|
|
|
(arg("layer idx"),arg("x"),arg("y")),
|
2010-06-02 11:03:30 +00:00
|
|
|
"Query a Map Layer (by layer index) for features \n"
|
|
|
|
"intersecting the given x,y location in the coordinates\n"
|
|
|
|
"of map projection.\n"
|
2010-08-27 16:16:16 +00:00
|
|
|
"Layer index starts at 0 (first layer in map).\n"
|
2010-06-02 11:03:30 +00:00
|
|
|
"Will return a Mapnik Featureset if successful\n"
|
|
|
|
"otherwise will return None.\n"
|
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
">>> featureset = m.query_point(0,-122,48)\n"
|
|
|
|
">>> featureset\n"
|
|
|
|
"<mapnik._mapnik.Featureset object at 0x23b0b0>\n"
|
|
|
|
">>> featureset.features\n"
|
|
|
|
">>> [<mapnik.Feature object at 0x3995630>]\n"
|
|
|
|
)
|
2009-01-14 04:52:04 +00:00
|
|
|
|
2010-06-02 11:03:30 +00:00
|
|
|
.def("remove_all",&Map::remove_all,
|
|
|
|
"Remove all Mapnik Styles and layers from the Map.\n"
|
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
">>> m.remove_all()\n"
|
|
|
|
)
|
2008-11-17 23:44:50 +00:00
|
|
|
|
2010-06-02 11:03:30 +00:00
|
|
|
.def("remove_style",&Map::remove_style,
|
2010-08-27 16:16:16 +00:00
|
|
|
(arg("style_name")),
|
2010-06-02 11:03:30 +00:00
|
|
|
"Remove a Mapnik Style from the map.\n"
|
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
">>> m.remove_style('Style Name')\n"
|
|
|
|
)
|
2009-01-14 04:52:04 +00:00
|
|
|
|
2010-06-02 11:03:30 +00:00
|
|
|
.def("resize",&Map::resize,
|
2010-08-27 16:16:16 +00:00
|
|
|
(arg("width"),arg("height")),
|
2010-06-02 11:03:30 +00:00
|
|
|
"Resize a Mapnik Map.\n"
|
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
">>> m.resize(64,64)\n"
|
|
|
|
)
|
2008-11-17 23:44:50 +00:00
|
|
|
|
2010-06-02 11:03:30 +00:00
|
|
|
.def("scale", &Map::scale,
|
|
|
|
"Return the Map Scale.\n"
|
|
|
|
"Usage:\n"
|
|
|
|
"\n"
|
|
|
|
">>> m.scale()\n"
|
|
|
|
)
|
2009-03-21 11:22:10 +00:00
|
|
|
|
2010-06-02 11:03:30 +00:00
|
|
|
.def("scale_denominator", &Map::scale_denominator,
|
|
|
|
"Return the Map Scale Denominator.\n"
|
|
|
|
"Usage:\n"
|
|
|
|
"\n"
|
2010-08-27 16:16:16 +00:00
|
|
|
">>> m.scale_denominator()\n"
|
2010-06-02 11:03:30 +00:00
|
|
|
)
|
2009-03-30 04:17:03 +00:00
|
|
|
|
2010-06-02 11:03:30 +00:00
|
|
|
.def("view_transform",&Map::view_transform,
|
2010-08-27 16:16:16 +00:00
|
|
|
"Return the map ViewTransform object\n"
|
|
|
|
"which is used internally to convert between\n"
|
|
|
|
"geographic coordinates and screen coordinates.\n"
|
2010-06-02 11:03:30 +00:00
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
">>> m.view_transform()\n"
|
|
|
|
)
|
2009-03-21 11:22:10 +00:00
|
|
|
|
2010-06-02 11:03:30 +00:00
|
|
|
.def("zoom",&Map::zoom,
|
2010-08-27 16:16:16 +00:00
|
|
|
(arg("factor")),
|
|
|
|
"Zoom in or out by a given factor.\n"
|
|
|
|
"Positive number zooms in, negative number\n"
|
|
|
|
"zooms out.\n"
|
|
|
|
"\n"
|
2010-06-02 11:03:30 +00:00
|
|
|
"Usage:\n"
|
|
|
|
"\n"
|
|
|
|
">>> m.zoom(0.25)\n"
|
|
|
|
)
|
2008-11-17 23:44:50 +00:00
|
|
|
|
2010-06-02 11:03:30 +00:00
|
|
|
.def("zoom_all",&Map::zoom_all,
|
|
|
|
"Set the geographical extent of the map\n"
|
|
|
|
"to the combined extents of all active layers.\n"
|
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
">>> m.zoom_all()\n"
|
|
|
|
)
|
2008-11-17 23:44:50 +00:00
|
|
|
|
2010-06-25 15:23:35 +00:00
|
|
|
.def("zoom_to_box",&Map::zoom_to_box,
|
2010-08-27 16:16:16 +00:00
|
|
|
(arg("Boxd2")),
|
2010-06-02 11:03:30 +00:00
|
|
|
"Set the geographical extent of the map\n"
|
2010-08-27 16:16:16 +00:00
|
|
|
"by specifying a Mapnik Box2d.\n"
|
2010-06-02 11:03:30 +00:00
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
2010-08-27 16:16:16 +00:00
|
|
|
">>> extext = Box2d(-180.0, -90.0, 180.0, 90.0)\n"
|
2010-06-02 11:03:30 +00:00
|
|
|
">>> m.zoom_to_box(extent)\n"
|
2010-07-25 21:14:19 +00:00
|
|
|
)
|
|
|
|
.def("get_metawriter_property", &Map::get_metawriter_property,
|
2010-08-27 16:16:16 +00:00
|
|
|
(arg("name")),
|
2010-08-12 01:42:33 +00:00
|
|
|
"Reads a metawriter property.\n"
|
2010-09-24 17:41:08 +00:00
|
|
|
"These properties are completely user-defined and can be used to"
|
|
|
|
"create filenames, etc.\n"
|
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
">>> map.set_metawriter_property(\"x\", \"10\")\n"
|
|
|
|
">>> map.get_metawriter_property(\"x\")\n"
|
|
|
|
"10\n"
|
2010-07-25 21:14:19 +00:00
|
|
|
)
|
|
|
|
.def("set_metawriter_property", &Map::set_metawriter_property,
|
2010-08-27 16:16:16 +00:00
|
|
|
(arg("name"),arg("value")),
|
2010-08-12 01:42:33 +00:00
|
|
|
"Sets a metawriter property.\n"
|
2010-09-24 17:41:08 +00:00
|
|
|
"These properties are completely user-defined and can be used to"
|
|
|
|
"create filenames, etc.\n"
|
2010-08-12 01:42:33 +00:00
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
">>> map.set_metawriter_property(\"x\", str(x))\n"
|
|
|
|
">>> map.set_metawriter_property(\"y\", str(y))\n"
|
|
|
|
">>> map.set_metawriter_property(\"z\", str(z))\n"
|
|
|
|
"\n"
|
|
|
|
"Use a path like \"[z]/[x]/[y].json\" to create filenames.\n"
|
2010-07-25 21:14:19 +00:00
|
|
|
)
|
2011-03-16 13:32:04 +00:00
|
|
|
.def("find_inmem_metawriter", find_inmem_metawriter,
|
|
|
|
(arg("name")),
|
|
|
|
"Gets an inmem metawriter, or None if no such metawriter "
|
|
|
|
"exists.\n"
|
|
|
|
"Use this after the map has been rendered to retrieve information "
|
|
|
|
"about the hit areas rendered on the map.\n"
|
|
|
|
)
|
2010-07-25 21:14:19 +00:00
|
|
|
|
2010-10-07 19:34:36 +00:00
|
|
|
.def("extra_attributes",&Map::get_extra_attributes,return_value_policy<copy_const_reference>(),"TODO")
|
2009-03-30 04:17:03 +00:00
|
|
|
|
2010-06-02 11:03:30 +00:00
|
|
|
.add_property("aspect_fix_mode",
|
2010-06-25 15:23:35 +00:00
|
|
|
&Map::get_aspect_fix_mode,
|
|
|
|
&Map::set_aspect_fix_mode,
|
2010-08-27 16:16:16 +00:00
|
|
|
// TODO - how to add arg info to properties?
|
|
|
|
//(arg("aspect_fix_mode")),
|
2010-06-02 11:03:30 +00:00
|
|
|
"Get/Set aspect fix mode.\n"
|
|
|
|
"Usage:\n"
|
|
|
|
"\n"
|
|
|
|
">>> m.aspect_fix_mode = aspect_fix_mode.GROW_BBOX\n"
|
|
|
|
)
|
2008-11-17 23:44:50 +00:00
|
|
|
|
2010-06-02 11:03:30 +00:00
|
|
|
.add_property("background",make_function
|
|
|
|
(&Map::background,return_value_policy<copy_const_reference>()),
|
|
|
|
&Map::set_background,
|
|
|
|
"The background color of the map.\n"
|
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
">>> m.background = Color('steelblue')\n"
|
|
|
|
)
|
2011-05-25 23:48:07 +00:00
|
|
|
|
|
|
|
.add_property("base",
|
|
|
|
make_function(&Map::base_path,return_value_policy<copy_const_reference>()),
|
|
|
|
&Map::set_base_path,
|
|
|
|
"The base path of the map where any files using relative \n"
|
|
|
|
"paths will be interpreted as relative to.\n"
|
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
">>> m.base_path = '.'\n"
|
|
|
|
)
|
2008-11-17 23:44:50 +00:00
|
|
|
|
2010-06-02 11:03:30 +00:00
|
|
|
.add_property("buffer_size",
|
|
|
|
&Map::buffer_size,
|
|
|
|
&Map::set_buffer_size,
|
|
|
|
"Get/Set the size of buffer around map in pixels.\n"
|
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
">>> m.buffer_size\n"
|
|
|
|
"0 # zero by default\n"
|
|
|
|
">>> m.buffer_size = 2\n"
|
|
|
|
">>> m.buffer_size\n"
|
|
|
|
"2\n"
|
|
|
|
)
|
2009-01-14 04:52:04 +00:00
|
|
|
|
2010-06-02 11:03:30 +00:00
|
|
|
.add_property("height",
|
2010-06-25 15:23:35 +00:00
|
|
|
&Map::height,
|
|
|
|
&Map::set_height,
|
2010-06-02 11:03:30 +00:00
|
|
|
"Get/Set the height of the map in pixels.\n"
|
|
|
|
"Minimum settable size is 16 pixels.\n"
|
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
">>> m.height\n"
|
|
|
|
"400\n"
|
|
|
|
">>> m.height = 600\n"
|
|
|
|
">>> m.height\n"
|
|
|
|
"600\n"
|
|
|
|
)
|
2008-11-17 23:44:50 +00:00
|
|
|
|
2010-06-02 11:03:30 +00:00
|
|
|
.add_property("layers",make_function
|
|
|
|
(layers_nonconst,return_value_policy<reference_existing_object>()),
|
|
|
|
"The list of map layers.\n"
|
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
">>> m.layers\n"
|
|
|
|
"<mapnik._mapnik.layers object at 0x6d458>"
|
|
|
|
">>> m.layers[0]\n"
|
|
|
|
"<mapnik._mapnik.layer object at 0x5fe130>\n"
|
|
|
|
)
|
2009-01-14 06:12:55 +00:00
|
|
|
|
2011-04-14 02:20:33 +00:00
|
|
|
.add_property("maximum_extent",make_function
|
|
|
|
(&Map::maximum_extent,return_value_policy<copy_const_reference>()),
|
|
|
|
&Map::set_maximum_extent,
|
|
|
|
"The maximum extent of the map.\n"
|
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
">>> m.maximum_extent = Box2d(-180,-90,180,90)\n"
|
|
|
|
)
|
|
|
|
|
2010-06-02 11:03:30 +00:00
|
|
|
.add_property("srs",
|
|
|
|
make_function(&Map::srs,return_value_policy<copy_const_reference>()),
|
|
|
|
&Map::set_srs,
|
|
|
|
"Spatial reference in Proj.4 format.\n"
|
|
|
|
"Either an epsg code or proj literal.\n"
|
|
|
|
"For example, a proj literal:\n"
|
2010-08-10 18:18:31 +00:00
|
|
|
"\t'+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'\n"
|
2010-06-02 11:03:30 +00:00
|
|
|
"and a proj epsg code:\n"
|
|
|
|
"\t'+init=epsg:4326'\n"
|
|
|
|
"\n"
|
|
|
|
"Note: using epsg codes requires the installation of\n"
|
|
|
|
"the Proj.4 'epsg' data file normally found in '/usr/local/share/proj'\n"
|
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
">>> m.srs\n"
|
2010-08-10 18:18:31 +00:00
|
|
|
"'+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs' # The default srs if not initialized with custom srs\n"
|
2010-06-02 11:03:30 +00:00
|
|
|
">>> # set to google mercator with Proj.4 literal\n"
|
|
|
|
"... \n"
|
|
|
|
">>> m.srs = '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs +over'\n"
|
|
|
|
)
|
2008-11-17 23:44:50 +00:00
|
|
|
|
2010-06-02 11:03:30 +00:00
|
|
|
.add_property("width",
|
2010-06-25 15:23:35 +00:00
|
|
|
&Map::width,
|
|
|
|
&Map::set_width,
|
2010-06-02 11:03:30 +00:00
|
|
|
"Get/Set the width of the map in pixels.\n"
|
|
|
|
"Minimum settable size is 16 pixels.\n"
|
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
">>> m.width\n"
|
|
|
|
"600\n"
|
|
|
|
">>> m.width = 800\n"
|
|
|
|
">>> m.width\n"
|
|
|
|
"800\n"
|
|
|
|
)
|
|
|
|
;
|
2006-01-31 23:09:52 +00:00
|
|
|
}
|