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_python.cc 27 2005-03-30 21:45:40Z pavlenko $
|
|
|
|
|
|
|
|
#include <boost/python.hpp>
|
|
|
|
#include <boost/get_pointer.hpp>
|
|
|
|
#include <boost/python/detail/api_placeholder.hpp>
|
2007-09-25 18:47:12 +00:00
|
|
|
#include <boost/python/exception_translator.hpp>
|
2006-01-31 23:09:52 +00:00
|
|
|
|
2008-03-12 00:37:53 +00:00
|
|
|
void register_cairo();
|
2006-01-31 23:09:52 +00:00
|
|
|
void export_color();
|
2006-10-16 13:44:52 +00:00
|
|
|
void export_coord();
|
2006-01-31 23:09:52 +00:00
|
|
|
void export_layer();
|
|
|
|
void export_parameters();
|
|
|
|
void export_envelope();
|
2006-09-11 09:48:27 +00:00
|
|
|
void export_query();
|
2009-01-13 00:56:09 +00:00
|
|
|
void export_geometry();
|
2006-01-31 23:09:52 +00:00
|
|
|
void export_image();
|
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
|
|
|
void export_image_view();
|
2006-01-31 23:09:52 +00:00
|
|
|
void export_map();
|
|
|
|
void export_python();
|
2009-12-16 20:02:06 +00:00
|
|
|
void export_expression();
|
2006-01-31 23:09:52 +00:00
|
|
|
void export_rule();
|
|
|
|
void export_style();
|
|
|
|
void export_stroke();
|
2006-12-06 20:26:59 +00:00
|
|
|
void export_feature();
|
|
|
|
void export_featureset();
|
2006-10-16 13:44:52 +00:00
|
|
|
void export_datasource();
|
2006-01-31 23:09:52 +00:00
|
|
|
void export_datasource_cache();
|
2009-10-19 14:22:11 +00:00
|
|
|
void export_symbolizer();
|
2010-06-06 12:10:28 +00:00
|
|
|
void export_markers_symbolizer();
|
2006-02-25 11:03:30 +00:00
|
|
|
void export_point_symbolizer();
|
|
|
|
void export_line_symbolizer();
|
|
|
|
void export_line_pattern_symbolizer();
|
|
|
|
void export_polygon_symbolizer();
|
|
|
|
void export_polygon_pattern_symbolizer();
|
|
|
|
void export_raster_symbolizer();
|
|
|
|
void export_text_symbolizer();
|
2007-07-02 13:39:08 +00:00
|
|
|
void export_shield_symbolizer();
|
2006-03-19 21:55:59 +00:00
|
|
|
void export_font_engine();
|
2006-10-16 13:44:52 +00:00
|
|
|
void export_projection();
|
2009-01-13 15:49:26 +00:00
|
|
|
void export_proj_transform();
|
2009-03-29 10:26:44 +00:00
|
|
|
void export_view_transform();
|
2010-03-12 13:34:13 +00:00
|
|
|
void export_raster_colorizer();
|
2010-03-18 20:04:35 +00:00
|
|
|
void export_glyph_symbolizer();
|
2011-03-16 13:32:04 +00:00
|
|
|
void export_inmem_metawriter();
|
2006-01-31 23:09:52 +00:00
|
|
|
|
2009-02-12 16:44:04 +00:00
|
|
|
#include <mapnik/version.hpp>
|
2006-10-04 11:22:18 +00:00
|
|
|
#include <mapnik/map.hpp>
|
|
|
|
#include <mapnik/agg_renderer.hpp>
|
2008-03-12 19:14:51 +00:00
|
|
|
#ifdef HAVE_CAIRO
|
2008-03-12 00:37:53 +00:00
|
|
|
#include <mapnik/cairo_renderer.hpp>
|
2008-03-12 19:14:51 +00:00
|
|
|
#endif
|
2006-10-04 11:22:18 +00:00
|
|
|
#include <mapnik/graphics.hpp>
|
2007-12-06 12:14:29 +00:00
|
|
|
#include <mapnik/image_util.hpp>
|
2006-10-04 11:22:18 +00:00
|
|
|
#include <mapnik/load_map.hpp>
|
2007-09-25 18:47:12 +00:00
|
|
|
#include <mapnik/config_error.hpp>
|
2010-11-15 03:30:23 +00:00
|
|
|
#include <mapnik/value_error.hpp>
|
2006-10-04 11:22:18 +00:00
|
|
|
#include <mapnik/save_map.hpp>
|
2006-09-11 09:48:27 +00:00
|
|
|
|
2008-07-30 07:37:48 +00:00
|
|
|
#if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO)
|
2008-03-12 00:37:53 +00:00
|
|
|
#include <pycairo.h>
|
2009-07-28 06:27:10 +00:00
|
|
|
static Pycairo_CAPI_t *Pycairo_CAPI;
|
2008-03-12 19:14:51 +00:00
|
|
|
#endif
|
2006-12-04 20:12:58 +00:00
|
|
|
|
2010-06-10 14:12:35 +00:00
|
|
|
void render(const mapnik::Map& map,mapnik::image_32& image, double scale_factor = 1.0 , unsigned offset_x = 0u , unsigned offset_y = 0u)
|
2006-12-04 20:12:58 +00:00
|
|
|
{
|
2009-01-10 17:57:59 +00:00
|
|
|
Py_BEGIN_ALLOW_THREADS
|
2010-06-02 11:03:30 +00:00
|
|
|
try
|
|
|
|
{
|
2010-06-10 14:12:35 +00:00
|
|
|
mapnik::agg_renderer<mapnik::image_32> ren(map,image,scale_factor,offset_x, offset_y);
|
2010-06-02 11:03:30 +00:00
|
|
|
ren.apply();
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
Py_BLOCK_THREADS
|
|
|
|
throw;
|
|
|
|
}
|
2009-01-10 17:57:59 +00:00
|
|
|
Py_END_ALLOW_THREADS
|
2010-06-02 11:03:30 +00:00
|
|
|
}
|
2006-12-05 15:43:52 +00:00
|
|
|
|
2008-07-30 07:37:48 +00:00
|
|
|
#if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO)
|
2008-03-12 19:14:51 +00:00
|
|
|
|
2009-02-06 00:46:29 +00:00
|
|
|
void render3(const mapnik::Map& map,PycairoSurface* surface, unsigned offset_x = 0, unsigned offset_y = 0)
|
2008-03-12 00:37:53 +00:00
|
|
|
{
|
2009-01-10 23:30:33 +00:00
|
|
|
Py_BEGIN_ALLOW_THREADS
|
2010-06-02 11:03:30 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
Cairo::RefPtr<Cairo::Surface> s(new Cairo::Surface(surface->surface));
|
|
|
|
mapnik::cairo_renderer<Cairo::Surface> ren(map,s,offset_x, offset_y);
|
|
|
|
ren.apply();
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
Py_BLOCK_THREADS
|
|
|
|
throw;
|
|
|
|
}
|
2009-01-10 23:30:33 +00:00
|
|
|
Py_END_ALLOW_THREADS
|
2010-06-02 11:03:30 +00:00
|
|
|
}
|
2008-03-12 00:37:53 +00:00
|
|
|
|
2009-02-06 00:46:29 +00:00
|
|
|
void render4(const mapnik::Map& map,PycairoSurface* surface)
|
|
|
|
{
|
|
|
|
Py_BEGIN_ALLOW_THREADS
|
2010-06-02 11:03:30 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
Cairo::RefPtr<Cairo::Surface> s(new Cairo::Surface(surface->surface));
|
|
|
|
mapnik::cairo_renderer<Cairo::Surface> ren(map,s);
|
|
|
|
ren.apply();
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
Py_BLOCK_THREADS
|
|
|
|
throw;
|
|
|
|
}
|
2009-02-06 00:46:29 +00:00
|
|
|
Py_END_ALLOW_THREADS
|
2010-06-02 11:03:30 +00:00
|
|
|
}
|
2009-02-05 18:09:14 +00:00
|
|
|
|
2009-02-06 00:46:29 +00:00
|
|
|
void render5(const mapnik::Map& map,PycairoContext* context, unsigned offset_x = 0, unsigned offset_y = 0)
|
2008-03-12 00:37:53 +00:00
|
|
|
{
|
2009-01-10 23:30:33 +00:00
|
|
|
Py_BEGIN_ALLOW_THREADS
|
2010-06-02 11:03:30 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
Cairo::RefPtr<Cairo::Context> c(new Cairo::Context(context->ctx));
|
|
|
|
mapnik::cairo_renderer<Cairo::Context> ren(map,c,offset_x, offset_y);
|
|
|
|
ren.apply();
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
Py_BLOCK_THREADS
|
|
|
|
throw;
|
|
|
|
}
|
2009-01-10 23:30:33 +00:00
|
|
|
Py_END_ALLOW_THREADS
|
2010-06-02 11:03:30 +00:00
|
|
|
}
|
2008-03-12 00:37:53 +00:00
|
|
|
|
2009-02-06 00:46:29 +00:00
|
|
|
void render6(const mapnik::Map& map,PycairoContext* context)
|
|
|
|
{
|
|
|
|
Py_BEGIN_ALLOW_THREADS
|
2010-06-02 11:03:30 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
Cairo::RefPtr<Cairo::Context> c(new Cairo::Context(context->ctx));
|
|
|
|
mapnik::cairo_renderer<Cairo::Context> ren(map,c);
|
|
|
|
ren.apply();
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
Py_BLOCK_THREADS
|
|
|
|
throw;
|
|
|
|
}
|
2009-02-06 00:46:29 +00:00
|
|
|
Py_END_ALLOW_THREADS
|
2010-06-02 11:03:30 +00:00
|
|
|
}
|
2009-02-05 18:09:14 +00:00
|
|
|
|
2008-03-12 19:14:51 +00:00
|
|
|
#endif
|
|
|
|
|
2007-12-06 12:14:29 +00:00
|
|
|
void render_tile_to_file(const mapnik::Map& map,
|
|
|
|
unsigned offset_x, unsigned offset_y,
|
|
|
|
unsigned width, unsigned height,
|
|
|
|
const std::string& file,
|
|
|
|
const std::string& format)
|
2006-01-31 23:09:52 +00:00
|
|
|
{
|
2009-12-16 20:02:06 +00:00
|
|
|
mapnik::image_32 image(width,height);
|
2010-06-10 14:12:35 +00:00
|
|
|
render(map,image,1.0,offset_x, offset_y);
|
2008-01-25 14:40:48 +00:00
|
|
|
mapnik::save_to_file(image.data(),file,format);
|
2006-01-31 23:09:52 +00:00
|
|
|
}
|
|
|
|
|
2007-12-06 12:14:29 +00:00
|
|
|
void render_to_file1(const mapnik::Map& map,
|
2010-06-02 11:03:30 +00:00
|
|
|
const std::string& filename,
|
|
|
|
const std::string& format)
|
2006-01-31 23:09:52 +00:00
|
|
|
{
|
2010-01-11 18:55:30 +00:00
|
|
|
if (format == "pdf" || format == "svg" || format =="ps" || format == "ARGB32" || format == "RGB24")
|
|
|
|
{
|
|
|
|
#if defined(HAVE_CAIRO)
|
|
|
|
mapnik::save_to_cairo_file(map,filename,format);
|
|
|
|
#else
|
|
|
|
throw mapnik::ImageWriterException("Cairo backend not available, cannot write to format: " + format);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-06-25 15:23:35 +00:00
|
|
|
mapnik::image_32 image(map.width(),map.height());
|
2010-06-19 14:26:04 +00:00
|
|
|
render(map,image,1.0,0,0);
|
2010-01-11 18:55:30 +00:00
|
|
|
mapnik::save_to_file(image,filename,format);
|
2010-06-02 11:03:30 +00:00
|
|
|
}
|
2006-01-31 23:09:52 +00:00
|
|
|
}
|
|
|
|
|
2010-01-11 18:55:30 +00:00
|
|
|
void render_to_file2(const mapnik::Map& map,const std::string& filename)
|
2007-12-06 12:14:29 +00:00
|
|
|
{
|
2010-01-11 18:55:30 +00:00
|
|
|
std::string format = mapnik::guess_type(filename);
|
|
|
|
if (format == "pdf" || format == "svg" || format =="ps")
|
|
|
|
{
|
|
|
|
#if defined(HAVE_CAIRO)
|
|
|
|
mapnik::save_to_cairo_file(map,filename,format);
|
|
|
|
#else
|
|
|
|
throw mapnik::ImageWriterException("Cairo backend not available, cannot write to format: " + format);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-06-25 15:23:35 +00:00
|
|
|
mapnik::image_32 image(map.width(),map.height());
|
2010-06-19 14:26:04 +00:00
|
|
|
render(map,image,1.0,0,0);
|
2010-01-11 18:55:30 +00:00
|
|
|
mapnik::save_to_file(image,filename);
|
2010-06-02 11:03:30 +00:00
|
|
|
}
|
2007-12-06 12:14:29 +00:00
|
|
|
}
|
2009-07-26 01:15:44 +00:00
|
|
|
|
2010-06-29 21:35:49 +00:00
|
|
|
void render_to_file3(const mapnik::Map& map,
|
|
|
|
const std::string& filename,
|
|
|
|
const std::string& format,
|
|
|
|
double scale_factor = 1.0
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if (format == "pdf" || format == "svg" || format =="ps" || format == "ARGB32" || format == "RGB24")
|
|
|
|
{
|
|
|
|
#if defined(HAVE_CAIRO)
|
|
|
|
mapnik::save_to_cairo_file(map,filename,format);
|
|
|
|
#else
|
|
|
|
throw mapnik::ImageWriterException("Cairo backend not available, cannot write to format: " + format);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mapnik::image_32 image(map.width(),map.height());
|
|
|
|
render(map,image,scale_factor,0,0);
|
|
|
|
mapnik::save_to_file(image,filename,format);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-12-07 15:20:33 +00:00
|
|
|
double scale_denominator(mapnik::Map const &map, bool geographic)
|
|
|
|
{
|
2009-03-30 04:32:23 +00:00
|
|
|
return mapnik::scale_denominator(map, geographic);
|
2006-12-07 15:20:33 +00:00
|
|
|
}
|
|
|
|
|
2010-09-26 12:15:16 +00:00
|
|
|
// http://docs.python.org/c-api/exceptions.html#standard-exceptions
|
2010-11-15 03:30:23 +00:00
|
|
|
void config_error_translator(mapnik::config_error const & ex) {
|
2009-12-06 22:22:56 +00:00
|
|
|
PyErr_SetString(PyExc_RuntimeError, ex.what());
|
2007-09-25 18:47:12 +00:00
|
|
|
}
|
|
|
|
|
2010-11-15 03:30:23 +00:00
|
|
|
void value_error_translator(mapnik::value_error const & ex) {
|
|
|
|
PyErr_SetString(PyExc_ValueError, ex.what());
|
|
|
|
}
|
|
|
|
|
2009-02-12 16:44:04 +00:00
|
|
|
unsigned mapnik_version()
|
|
|
|
{
|
2009-03-30 04:32:23 +00:00
|
|
|
return MAPNIK_VERSION;
|
2009-02-12 16:44:04 +00:00
|
|
|
}
|
|
|
|
|
2009-07-17 20:51:39 +00:00
|
|
|
unsigned mapnik_svn_revision()
|
|
|
|
{
|
|
|
|
#if defined(SVN_REVISION)
|
2010-06-02 11:03:30 +00:00
|
|
|
return SVN_REVISION;
|
2009-07-17 20:51:39 +00:00
|
|
|
#else
|
2010-06-02 11:03:30 +00:00
|
|
|
return 0;
|
2009-07-17 20:51:39 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-06-03 19:50:27 +00:00
|
|
|
// indicator for jpeg read/write support within libmapnik
|
|
|
|
bool has_jpeg()
|
|
|
|
{
|
|
|
|
#if defined(HAVE_JPEG)
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-07-28 06:27:10 +00:00
|
|
|
// indicator for cairo rendering support inside libmapnik
|
2009-05-24 04:25:51 +00:00
|
|
|
bool has_cairo()
|
|
|
|
{
|
2009-07-28 06:27:10 +00:00
|
|
|
#if defined(HAVE_CAIRO)
|
2010-06-02 11:03:30 +00:00
|
|
|
return true;
|
2009-05-24 04:25:51 +00:00
|
|
|
#else
|
2010-06-02 11:03:30 +00:00
|
|
|
return false;
|
2009-05-24 04:25:51 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-07-28 06:27:10 +00:00
|
|
|
// indicator for pycairo support in the python bindings
|
|
|
|
bool has_pycairo()
|
|
|
|
{
|
|
|
|
#if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO)
|
2010-06-02 11:03:30 +00:00
|
|
|
Pycairo_IMPORT;
|
|
|
|
/*!
|
|
|
|
Case where pycairo support has been compiled into
|
|
|
|
mapnik but at runtime the cairo python module
|
|
|
|
is unable to be imported and therefore Pycairo surfaces
|
|
|
|
and contexts cannot be passed to mapnik.render()
|
|
|
|
*/
|
|
|
|
if (Pycairo_CAPI == NULL) return false;
|
|
|
|
return true;
|
2009-07-28 06:27:10 +00:00
|
|
|
#else
|
2010-06-02 11:03:30 +00:00
|
|
|
return false;
|
2009-07-28 06:27:10 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-01 06:24:57 +00:00
|
|
|
BOOST_PYTHON_FUNCTION_OVERLOADS(load_map_overloads, load_map, 2, 3)
|
|
|
|
BOOST_PYTHON_FUNCTION_OVERLOADS(load_map_string_overloads, load_map_string, 2, 4)
|
|
|
|
BOOST_PYTHON_FUNCTION_OVERLOADS(save_map_overloads, save_map, 2, 3)
|
|
|
|
BOOST_PYTHON_FUNCTION_OVERLOADS(save_map_to_string_overloads, save_map_to_string, 1, 2)
|
|
|
|
BOOST_PYTHON_FUNCTION_OVERLOADS(render_overloads, render, 2, 5)
|
2006-10-03 08:44:04 +00:00
|
|
|
|
2010-03-08 11:54:44 +00:00
|
|
|
BOOST_PYTHON_MODULE(_mapnik2)
|
2006-01-31 23:09:52 +00:00
|
|
|
{
|
Tiling patch from Toby allows for a selected pixel region within an extent
to be rendered. This allows for a large extent (larger than can be
rendered into a single image in memory) to be rendered out as tiles.
Since the full extent is used for the placement calculations text
crossing tile boundaries will be consistent.
This method is a little inefficient when a large number of labels need
placed, an improved method would be to cache these placements between
tiles, but the attached is a start.
c++ users should simple call the render method with a start X and Y
coordinate specified,
for (int TileX = 0;TileX < 5;++TileX)
{
for(int TileY = 0;TileY < 5; ++TileY)
{
int TileSize=250;
int StartX = TileX*TileSize;
int StartY = TileY*TileSize;
Image32 buf(TileSize,TileSize);
agg_renderer<Image32> ren(m,buf,StartX,StartY);
ren.apply();
char name[324];
sprintf(name,"tile_%d_%d.png",TileX,TileY);
ImageUtils::save_to_file(name,"png",buf);
}
}
python users should call render_tile_to_file
for y in range(tile_count_y):
for x in range(tile_count_x):
if not os.path.exists("tiles/%d/%d/" % (map_scale, y)):
os.makedirs("tiles/%d/%d/" % (map_scale, y))
render_tile_to_file(m, x*tile_size, y*tile_size, tile_size, tile_size,
'tiles/%d/%d/%d.png' % (map_scale,y,x), 'png')
2006-12-01 09:37:37 +00:00
|
|
|
|
2007-09-25 18:47:12 +00:00
|
|
|
using namespace boost::python;
|
|
|
|
|
2006-10-03 10:02:14 +00:00
|
|
|
using mapnik::load_map;
|
2009-01-15 23:51:07 +00:00
|
|
|
using mapnik::load_map_string;
|
2006-10-03 10:02:14 +00:00
|
|
|
using mapnik::save_map;
|
2009-12-06 22:33:47 +00:00
|
|
|
using mapnik::save_map_to_string;
|
2007-09-25 18:47:12 +00:00
|
|
|
|
2010-11-15 03:30:23 +00:00
|
|
|
register_exception_translator<mapnik::config_error>(&config_error_translator);
|
|
|
|
register_exception_translator<mapnik::value_error>(&value_error_translator);
|
2008-03-12 00:37:53 +00:00
|
|
|
register_cairo();
|
2009-01-13 00:56:09 +00:00
|
|
|
export_query();
|
|
|
|
export_geometry();
|
2006-12-06 20:26:59 +00:00
|
|
|
export_feature();
|
|
|
|
export_featureset();
|
2006-10-16 13:44:52 +00:00
|
|
|
export_datasource();
|
2006-01-31 23:09:52 +00:00
|
|
|
export_parameters();
|
|
|
|
export_color();
|
|
|
|
export_envelope();
|
|
|
|
export_image();
|
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
|
|
|
export_image_view();
|
2009-12-16 20:02:06 +00:00
|
|
|
export_expression();
|
2006-01-31 23:09:52 +00:00
|
|
|
export_rule();
|
|
|
|
export_style();
|
|
|
|
export_layer();
|
|
|
|
export_stroke();
|
|
|
|
export_datasource_cache();
|
2009-10-19 14:22:11 +00:00
|
|
|
export_symbolizer();
|
2010-06-06 12:10:28 +00:00
|
|
|
export_markers_symbolizer();
|
2006-02-25 11:03:30 +00:00
|
|
|
export_point_symbolizer();
|
|
|
|
export_line_symbolizer();
|
|
|
|
export_line_pattern_symbolizer();
|
|
|
|
export_polygon_symbolizer();
|
|
|
|
export_polygon_pattern_symbolizer();
|
|
|
|
export_raster_symbolizer();
|
|
|
|
export_text_symbolizer();
|
2007-07-02 13:39:08 +00:00
|
|
|
export_shield_symbolizer();
|
2006-03-19 21:55:59 +00:00
|
|
|
export_font_engine();
|
2006-10-16 13:44:52 +00:00
|
|
|
export_projection();
|
2009-01-13 15:49:26 +00:00
|
|
|
export_proj_transform();
|
2009-03-29 10:26:44 +00:00
|
|
|
export_view_transform();
|
2006-10-16 13:44:52 +00:00
|
|
|
export_coord();
|
2006-01-31 23:09:52 +00:00
|
|
|
export_map();
|
2010-03-12 13:34:13 +00:00
|
|
|
export_raster_colorizer();
|
2010-03-18 20:04:35 +00:00
|
|
|
export_glyph_symbolizer();
|
2011-03-16 13:32:04 +00:00
|
|
|
export_inmem_metawriter();
|
2008-03-12 00:37:53 +00:00
|
|
|
|
2009-03-30 04:32:23 +00:00
|
|
|
def("render_to_file",&render_to_file1,
|
|
|
|
"\n"
|
2009-04-12 21:36:45 +00:00
|
|
|
"Render Map to file using explicit image type.\n"
|
2009-03-30 04:32:23 +00:00
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
">>> from mapnik import Map, render_to_file, load_map\n"
|
|
|
|
">>> m = Map(256,256)\n"
|
|
|
|
">>> load_map(m,'mapfile.xml')\n"
|
|
|
|
">>> render_to_file(m,'image32bit.png','png')\n"
|
|
|
|
"\n"
|
2009-04-08 00:27:36 +00:00
|
|
|
"8 bit (paletted) PNG can be requested with 'png256':\n"
|
2009-04-12 21:36:45 +00:00
|
|
|
">>> render_to_file(m,'8bit_image.png','png256')\n"
|
|
|
|
"\n"
|
2009-04-08 00:27:36 +00:00
|
|
|
"JPEG quality can be controlled by adding a suffix to\n"
|
|
|
|
"'jpeg' between 0 and 100 (default is 85):\n"
|
|
|
|
">>> render_to_file(m,'top_quality.jpeg','jpeg100')\n"
|
|
|
|
">>> render_to_file(m,'medium_quality.jpeg','jpeg50')\n"
|
2009-03-30 04:32:23 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
def("render_to_file",&render_to_file2,
|
|
|
|
"\n"
|
|
|
|
"Render Map to file (type taken from file extension)\n"
|
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
">>> from mapnik import Map, render_to_file, load_map\n"
|
|
|
|
">>> m = Map(256,256)\n"
|
|
|
|
">>> render_to_file(m,'image.jpeg')\n"
|
|
|
|
"\n"
|
|
|
|
);
|
|
|
|
|
2010-06-29 21:35:49 +00:00
|
|
|
def("render_to_file",&render_to_file3,
|
|
|
|
"\n"
|
|
|
|
"Render Map to file using explicit image type and scale factor.\n"
|
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
">>> from mapnik import Map, render_to_file, load_map\n"
|
|
|
|
">>> m = Map(256,256)\n"
|
|
|
|
">>> scale_factor = 4\n"
|
|
|
|
">>> render_to_file(m,'image.jpeg',scale_factor)\n"
|
|
|
|
"\n"
|
|
|
|
);
|
|
|
|
|
2009-03-30 04:32:23 +00:00
|
|
|
def("render_tile_to_file",&render_tile_to_file,
|
|
|
|
"\n"
|
|
|
|
"TODO\n"
|
|
|
|
"\n"
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2010-06-10 14:12:35 +00:00
|
|
|
def("render", &render, render_overloads(
|
|
|
|
"\n"
|
|
|
|
"Render Map to an AGG image_32 using offsets\n"
|
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
">>> from mapnik import Map, Image, render, load_map\n"
|
|
|
|
">>> m = Map(256,256)\n"
|
|
|
|
">>> load_map(m,'mapfile.xml')\n"
|
|
|
|
">>> im = Image(m.width,m.height)\n"
|
|
|
|
">>> scale_factor=2.0\n"
|
|
|
|
">>> offset = [100,50]\n"
|
|
|
|
">>> render(m,im)\n"
|
|
|
|
">>> render(m,im,scale_factor)\n"
|
|
|
|
">>> render(m,im,scale_factor,offset[0],offset[1])\n"
|
|
|
|
"\n"
|
|
|
|
));
|
|
|
|
|
2008-07-30 07:37:48 +00:00
|
|
|
#if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO)
|
2009-03-30 04:32:23 +00:00
|
|
|
def("render",&render3,
|
|
|
|
"\n"
|
|
|
|
"Render Map to Cairo Surface using offsets\n"
|
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
">>> from mapnik import Map, render, load_map\n"
|
|
|
|
">>> from cairo import SVGSurface\n"
|
|
|
|
">>> m = Map(256,256)\n"
|
|
|
|
">>> load_map(m,'mapfile.xml')\n"
|
|
|
|
">>> surface = SVGSurface('image.svg', m.width, m.height)\n"
|
|
|
|
">>> render(m,surface,1,1)\n"
|
|
|
|
"\n"
|
|
|
|
);
|
|
|
|
|
|
|
|
def("render",&render4,
|
|
|
|
"\n"
|
|
|
|
"Render Map to Cairo Surface\n"
|
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
">>> from mapnik import Map, render, load_map\n"
|
|
|
|
">>> from cairo import SVGSurface\n"
|
|
|
|
">>> m = Map(256,256)\n"
|
|
|
|
">>> load_map(m,'mapfile.xml')\n"
|
|
|
|
">>> surface = SVGSurface('image.svg', m.width, m.height)\n"
|
|
|
|
">>> render(m,surface)\n"
|
|
|
|
"\n"
|
|
|
|
);
|
|
|
|
|
|
|
|
def("render",&render5,
|
|
|
|
"\n"
|
|
|
|
"Render Map to Cairo Context using offsets\n"
|
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
">>> from mapnik import Map, render, load_map\n"
|
|
|
|
">>> from cairo import SVGSurface, Context\n"
|
|
|
|
">>> surface = SVGSurface('image.svg', m.width, m.height)\n"
|
|
|
|
">>> ctx = Context(surface)\n"
|
|
|
|
">>> load_map(m,'mapfile.xml')\n"
|
|
|
|
">>> render(m,context,1,1)\n"
|
|
|
|
"\n"
|
|
|
|
);
|
|
|
|
|
|
|
|
def("render",&render6,
|
|
|
|
"\n"
|
|
|
|
"Render Map to Cairo Context\n"
|
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
">>> from mapnik import Map, render, load_map\n"
|
|
|
|
">>> from cairo import SVGSurface, Context\n"
|
|
|
|
">>> surface = SVGSurface('image.svg', m.width, m.height)\n"
|
|
|
|
">>> ctx = Context(surface)\n"
|
|
|
|
">>> load_map(m,'mapfile.xml')\n"
|
|
|
|
">>> render(m,context)\n"
|
|
|
|
"\n"
|
|
|
|
);
|
2008-03-12 19:14:51 +00:00
|
|
|
#endif
|
2009-03-30 04:32:23 +00:00
|
|
|
|
|
|
|
def("scale_denominator", &scale_denominator,
|
|
|
|
"\n"
|
|
|
|
"Return the Map Scale Denominator.\n"
|
|
|
|
"Also available as Map.scale_denominator()\n"
|
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
"\n"
|
|
|
|
">>> from mapnik import Map, Projection, scale_denominator, load_map\n"
|
|
|
|
">>> m = Map(256,256)\n"
|
|
|
|
">>> load_map(m,'mapfile.xml')\n"
|
|
|
|
">>> scale_denominator(m,Projection(m.srs).geographic)\n"
|
|
|
|
"\n"
|
|
|
|
);
|
|
|
|
|
2010-11-15 03:30:23 +00:00
|
|
|
def("load_map", &load_map, load_map_overloads());
|
2009-03-30 04:32:23 +00:00
|
|
|
|
2010-11-15 03:30:23 +00:00
|
|
|
def("load_map_from_string", &load_map_string, load_map_string_overloads());
|
2009-03-30 04:32:23 +00:00
|
|
|
|
2010-11-15 03:30:23 +00:00
|
|
|
def("save_map", &save_map, save_map_overloads());
|
2009-04-28 21:44:34 +00:00
|
|
|
/*
|
2010-06-02 11:03:30 +00:00
|
|
|
"\n"
|
|
|
|
"Save Map object to XML file\n"
|
|
|
|
"\n"
|
|
|
|
"Usage:\n"
|
|
|
|
">>> from mapnik import Map, load_map, save_map\n"
|
|
|
|
">>> m = Map(256,256)\n"
|
|
|
|
">>> load_map(m,'mapfile_wgs84.xml')\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
|
|
|
">>> m.srs = '+init=espg:3395'\n"
|
|
|
|
">>> save_map(m,'mapfile_mercator.xml')\n"
|
|
|
|
"\n"
|
|
|
|
);
|
2009-04-28 21:44:34 +00:00
|
|
|
*/
|
2009-07-24 06:25:09 +00:00
|
|
|
|
2010-11-15 03:30:23 +00:00
|
|
|
def("save_map_to_string", &save_map_to_string, save_map_to_string_overloads());
|
2009-03-30 04:32:23 +00:00
|
|
|
def("mapnik_version", &mapnik_version,"Get the Mapnik version number");
|
2009-07-17 20:51:39 +00:00
|
|
|
def("mapnik_svn_revision", &mapnik_svn_revision,"Get the Mapnik svn revision");
|
2010-06-03 19:50:27 +00:00
|
|
|
def("has_jpeg", &has_jpeg, "Get jpeg read/write support status");
|
2009-05-24 04:25:51 +00:00
|
|
|
def("has_cairo", &has_cairo, "Get cairo library status");
|
2009-07-28 06:27:10 +00:00
|
|
|
def("has_pycairo", &has_pycairo, "Get pycairo module status");
|
2009-10-19 14:22:11 +00:00
|
|
|
|
2009-12-16 20:02:06 +00:00
|
|
|
register_ptr_to_python<mapnik::expression_ptr>();
|
|
|
|
register_ptr_to_python<mapnik::path_expression_ptr>();
|
2006-01-31 23:09:52 +00:00
|
|
|
}
|