Merge branch 'master' into compositing

Conflicts:
	include/mapnik/image_compositing.hpp
	include/mapnik/util/conversions.hpp
	include/mapnik/value.hpp
	src/agg/agg_renderer.cpp
	src/agg/process_line_symbolizer.cpp
	src/agg/process_polygon_symbolizer.cpp
	src/png_reader.cpp
	src/svg_parser.cpp
	utils/svg2png/svg2png.cpp
This commit is contained in:
Artem Pavlenko 2012-05-01 12:35:49 +01:00
commit a72ee4ba66
302 changed files with 5141 additions and 2650 deletions

3
.gitignore vendored
View file

@ -39,7 +39,8 @@ tests/data/sqlite/*index
demo/c++/cairo-demo.pdf
demo/c++/cairo-demo.png
demo/c++/cairo-demo256.png
demo/c++/demo.tif
demo/c++/demo.jpg
demo/c++/demo.png
demo/c++/demo256.png
tests/cpp_tests/*-bin

View file

@ -2,60 +2,60 @@
Mapnik is written by Artem Pavlenko with contributions from:
Andy Allen
AJ Ashton
Matt Amos
Lucio Asnaghi
Justin Bronn
Christopher Brown
Jon Burgess
Toby Collet
Robert Coup
Berteun Damman
Craig de Stigter
Jean-Francois Doyon
David Eastcott
Krzysztof Godlewski
Beau Gunderson
John Hague
Dominic Hargreaves
Aubrey Holland
Tom Hughes
Konstantin Käfer
Mak Kolybabi
Peter Körner
Hermann Kraus
Stella Laurenzo
David Leaver
Carlos López
Dennis Luxen
Tom MacWright
Michal Migurski
Andrii Mishkovskyi
Ben Moores
Dražen Odobašić
Cameron Patrick
Igor Podolskiy
Reid Priedhorsky
Brian Quinion
Marcin Rudowski
Christopher Schmidt
Andreas Schneider
Vincent Schut
Ehud Shabtai
David Siegel
Steve Singer
Paul Smith
Vince Spader
Philipp Spitzer
Dane Springmeyer
Dave Stubbs
River Tarnell
Oliver Tonnhofer
Alberto Valverde
Martijn van Oosterhout
Andreas Volz
Lennard voor den Dag
Shaun Walbridge
Nick Whitelegg
Leslie Wu
* Andy Allen
* AJ Ashton
* Matt Amos
* Lucio Asnaghi
* Justin Bronn
* Christopher Brown
* Jon Burgess
* Toby Collet
* Robert Coup
* Berteun Damman
* Craig de Stigter
* Jean-Francois Doyon
* David Eastcott
* Krzysztof Godlewski
* Beau Gunderson
* John Hague
* Dominic Hargreaves
* Aubrey Holland
* Tom Hughes
* Konstantin Käfer
* Mak Kolybabi
* Peter Körner
* Hermann Kraus
* Stella Laurenzo
* David Leaver
* Carlos López
* Dennis Luxen
* Tom MacWright
* Michal Migurski
* Andrii Mishkovskyi
* Ben Moores
* Dražen Odobašić
* Cameron Patrick
* Igor Podolskiy
* Reid Priedhorsky
* Brian Quinion
* Marcin Rudowski
* Christopher Schmidt
* Andreas Schneider
* Vincent Schut
* Ehud Shabtai
* David Siegel
* Steve Singer
* Paul Smith
* Vince Spader
* Philipp Spitzer
* Dane Springmeyer
* Dave Stubbs
* River Tarnell
* Oliver Tonnhofer
* Alberto Valverde
* Martijn van Oosterhout
* Andreas Volz
* Lennard voor den Dag
* Shaun Walbridge
* Nick Whitelegg
* Leslie Wu

View file

@ -9,7 +9,27 @@ For a complete change history, see the SVN log.
## Mapnik 2.1.0
- Fix Markers rendering so that ellipse height/width units are pixels (previously were unintentially radii)
- PostGIS: Added 'simplify_geometries' option - will trigger ST_Simplify on geometries before returning to Mapnik (#1179)
- Improved error feedback for invalid values passed to map.query_point
- Fixed rendering of thin svg lines (#1129)
- Improved logging/debugging system with release logs and file redirection (#937 and partially #986, #467)
- GDAL: allow setting nodata value on the fly (will override value if nodata is set in data) (#1161)
- GDAL: respect nodata for paletted/colormapped images (#1160)
- PostGIS: Added a new option called 'autodetect_key_field' (by default false) that if true will
trigger autodetection of a given tables' primary key allowing for feature.id() to represent
globally unique ids. This option has no effect if the user has not manually supplied the 'key_field' option. (#804)
- Cairo: Add full rendering support for markers to match AGG renderer functionality (#1071)
- Fix Markers rendering so that ellipse height/width units are pixels (previously were unintentionally radii) (#1134)
- Added 'ignore-placement` attribute to markers-symbolizer (#1135)
- Removed PointDatasource - use more robust MemoryDatasource instead (#1032)
@ -26,6 +46,41 @@ For a complete change history, see the SVN log.
- Added support for justify-alignment=auto. This is the new default. (#1125)
## Mapnik 2.0.1
(Packaged from 5cd3cb2efdaf7e9990a57e8e00b652a81aaa39ae)
- Support for PostGIS 2.0 (#956,#1083)
- Switched back to "libmapnik" and "import mapnik" rather than "mapnik2" (mapnik2 will still work from python) (#941)
- Restored Python 2.5 compatibility (#904)
- Fixed `mapnik-config --version` (#903)
- Cairo: Add full rendering support for markers to match AGG renderer functionality (#1071)
- Fix Markers rendering so that ellipse height/width units are pixels (previously were unintentially radii) (#1134)
- Added 'ignore-placement` attribute to markers-symbolizer (#1135)
- Removed svn_revision info from mapnik-config and python bindings as git is now used
- Removed OGCServer from core - now at https://github.com/mapnik/OGCServer (e7f6267)
- Fixed SQLite open stability across platforms/versions (#854)
- Workaround for boost interprocess compile error with recent gcc versions (#950,#1001,#1082)
- Fix possible memory corruption when using hextree mode for png color reduction (#1087)
- Fixed bug in shield line placement when dx/dy are used to shift the label relative to the placement point (Matt Amos) (#908)
- Fix to avoid modifying a feature if an attribute is requested that does not exist (0f5ab18ed)
- Fixed ability to save to jpeg format from python (7387afd9) (#896)
## Mapnik 2.0.0
- Add minimum-path-length property to text_symbolizer to allow labels to be placed only on lines of a certain length (#865)

View file

@ -18,9 +18,13 @@ uninstall:
python scons/scons.py uninstall
test:
@python tests/visual_tests/test.py
@tests/cpp_tests/font_registration_test
@tests/cpp_tests/params_test
@echo "*** Running visual tests..."
@python tests/visual_tests/test.py -q
@echo "*** Running C++ tests..."
@for FILE in tests/cpp_tests/*-bin; do \
$${FILE}; \
done
@echo "*** Running python tests..."
@python tests/run_tests.py -q
pep8:
@ -30,6 +34,8 @@ pep8:
@pep8 -r --select=W391 -q --filename=*.py `pwd`/tests/ | xargs gsed -i -e :a -e '/^\n*$/{$d;N;ba' -e '}'
grind:
@valgrind --leak-check=full tests/cpp_tests/font_registration_test
@for FILE in tests/cpp_tests/*-bin; do \
valgrind --leak-check=full --log-fd=1 $${FILE} | grep definitely; \
done
.PHONY: clean reset uninstall test install

View file

@ -15,8 +15,6 @@
# 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$
import os
@ -98,7 +96,7 @@ PLUGINS = { # plugins with external dependencies
'rasterlite': {'default':False,'path':'RASTERLITE','inc':['sqlite3.h','rasterlite.h'],'lib':'rasterlite','lang':'C'},
# todo: osm plugin does also depend on libxml2 (but there is a separate check for that)
'osm': {'default':False,'path':None,'inc':'curl/curl.h','lib':'curl','lang':'C'},
'osm': {'default':True,'path':None,'inc':'curl/curl.h','lib':'curl','lang':'C'},
# plugins without external dependencies requiring CheckLibWithHeader...
'shape': {'default':True,'path':None,'inc':None,'lib':None,'lang':'C++'},
@ -244,7 +242,6 @@ else:
LIBDIR_SCHEMA='lib'
def pretty_dep(dep):
pretty = pretty_dep_names.get(dep)
if pretty:
@ -346,6 +343,11 @@ opts.AddVariables(
PathVariable('RASTERLITE_INCLUDES', 'Search path for RASTERLITE include files', '/usr/include/', PathVariable.PathAccept),
PathVariable('RASTERLITE_LIBS', 'Search path for RASTERLITE library files', '/usr/' + LIBDIR_SCHEMA, PathVariable.PathAccept),
# Variables for logging and statistics
BoolVariable('ENABLE_LOG', 'Enable logging, which is enabled by default when building in *debug*', 'False'),
BoolVariable('ENABLE_STATS', 'Enable global statistics during map processing', 'False'),
('DEFAULT_LOG_SEVERITY', 'The default severity of the logger (eg. "info", "debug", "warn", "error", "fatal", "none")', 'error'),
# Other variables
BoolVariable('SHAPE_MEMORY_MAPPED_FILE', 'Utilize memory-mapped files in Shapefile Plugin (higher memory usage, better performance)', 'True'),
('SYSTEM_FONTS','Provide location for python bindings to register fonts (if given aborts installation of bundled DejaVu fonts)',''),
@ -359,7 +361,7 @@ opts.AddVariables(
EnumVariable('THREADING','Set threading support','multi', ['multi','single']),
EnumVariable('XMLPARSER','Set xml parser','libxml2', ['libxml2','ptree']),
('JOBS', 'Set the number of parallel compilations', "1", lambda key, value, env: int(value), int),
BoolVariable('DEMO', 'Compile demo c++ application', 'False'),
BoolVariable('DEMO', 'Compile demo c++ application', 'True'),
BoolVariable('PGSQL2SQLITE', 'Compile and install a utility to convert postgres tables to sqlite', 'False'),
BoolVariable('COLOR_PRINT', 'Print build status information in color', 'True'),
BoolVariable('SAMPLE_INPUT_PLUGINS', 'Compile and install sample plugins', 'False'),
@ -810,6 +812,9 @@ int main()
return False
def boost_regex_has_icu(context):
if env['RUNTIME_LINK'] == 'static':
context.env.Append(LIBS='icui18n')
context.env.Append(LIBS='icudata')
ret = context.TryRun("""
#include <boost/regex/icu.hpp>
@ -1408,9 +1413,39 @@ if not preconfigured:
# Common debugging flags.
# http://lists.fedoraproject.org/pipermail/devel/2010-November/144952.html
debug_flags = '-g -fno-omit-frame-pointer -DDEBUG -DMAPNIK_DEBUG'
ndebug_flags = '-DNDEBUG'
# Enable logging in debug mode (always) and release mode (when specified)
if env['DEFAULT_LOG_SEVERITY']:
severities = ['info', 'debug', 'warn', 'error', 'fatal', 'none']
if env['DEFAULT_LOG_SEVERITY'] not in severities:
color_print(1,"Cannot set default logger severity to '%s', available options are 'info', 'debug', 'warn', 'error', 'fatal', 'none'." % env['DEFAULT_LOG_SEVERITY'])
Exit(1)
else:
log_severity = severities.index(env['DEFAULT_LOG_SEVERITY'])
else:
if env['DEBUG']:
log_severity = 1 # debug
else:
log_severity = 3 # error
log_enabled = ' -DMAPNIK_LOG -DMAPNIK_DEFAULT_LOG_SEVERITY=%d' % log_severity
if env['DEBUG']:
debug_flags += log_enabled
else:
if env['ENABLE_LOG']:
ndebug_flags += log_enabled
# Enable statistics reporting
if env['ENABLE_STATS']:
debug_flags += ' -DMAPNIK_STATS'
ndebug_flags += ' -DMAPNIK_STATS'
# Add rdynamic to allow using statics between application and plugins
# http://stackoverflow.com/questions/8623657/multiple-instances-of-singleton-across-shared-libraries-on-linux
if env['PLATFORM'] != 'Darwin' and env['CXX'] == 'g++':
env.MergeFlags('-rdynamic')
# Customizing the C++ compiler flags depending on:
# (1) the C++ compiler used; and
@ -1696,7 +1731,7 @@ if not HELP_REQUESTED:
# devtools not ready for public
#SConscript('utils/ogrindex/build.py')
#SConscript('utils/svg2png/build.py')
SConscript('utils/svg2png/build.py')
env['LIBS'].remove('boost_program_options%s' % env['BOOST_APPEND'])
else :
color_print(1,"WARNING: Cannot find boost_program_options. 'shapeindex' won't be available")

View file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
// boost
#include <boost/python.hpp>

View file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
// boost
#include <boost/python.hpp>

View file

@ -19,10 +19,11 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
// boost
#include <boost/python.hpp>
#include <boost/python/detail/api_placeholder.hpp>
// stl
#include <sstream>
#include <vector>

View file

@ -20,8 +20,6 @@
*
*****************************************************************************/
//$Id$
#include <boost/python.hpp>
#include <mapnik/datasource_cache.hpp>

View file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id: mapnik_envelope.cc 27 2005-03-30 21:45:40Z pavlenko $
// boost
#include <boost/python.hpp>

View file

@ -19,9 +19,11 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
// boost
#include <boost/python.hpp>
#include <boost/variant.hpp>
// mapnik
#include <mapnik/feature.hpp>
#include <mapnik/expression.hpp>
@ -30,7 +32,6 @@
#include <mapnik/parse_path.hpp>
#include <mapnik/value.hpp>
#include <boost/variant.hpp>
using mapnik::Feature;
using mapnik::expression_ptr;

View file

@ -19,13 +19,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
// boost
#include <boost/python/suite/indexing/indexing_suite.hpp>
//#include <boost/python/suite/indexing/map_indexing_suite.hpp>
#include <boost/python/iterator.hpp>
#include <boost/python/call_method.hpp>
#include <boost/python/tuple.hpp>

View file

@ -19,10 +19,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
// boost
#include <boost/python.hpp>
// mapnik
#include <mapnik/feature.hpp>
#include <mapnik/datasource.hpp>

View file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
#include <boost/python.hpp>
#include <mapnik/font_engine_freetype.hpp>

View file

@ -17,7 +17,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
// boost
#include <boost/python.hpp>

View file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
// boost
#include <boost/python.hpp>

View file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
// boost
#include <boost/python.hpp>

View file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
extern "C"
{

View file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
extern "C"
{

View file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
// boost
#include <boost/python.hpp>

View file

@ -19,8 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id: mapnik_layer.cc 17 2005-03-08 23:58:43Z pavlenko $
// boost
#include <boost/python.hpp>

View file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
#include <boost/python.hpp>

View file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
#include <boost/python.hpp>
#include "mapnik_enumeration.hpp"

View file

@ -0,0 +1,79 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
*
* 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
*
*****************************************************************************/
#include <boost/python.hpp>
#include <mapnik/debug.hpp>
#include <mapnik/utils.hpp>
#include "mapnik_enumeration.hpp"
void export_logger()
{
using mapnik::logger;
using mapnik::singleton;
using mapnik::CreateStatic;
using namespace boost::python;
class_<singleton<logger,CreateStatic>,boost::noncopyable>("Singleton",no_init)
.def("instance",&singleton<logger,CreateStatic>::instance,
return_value_policy<reference_existing_object>())
.staticmethod("instance")
;
enum_<mapnik::logger::severity_type>("severity_type")
.value("Info", logger::info)
.value("Debug", logger::debug)
.value("Warn", logger::warn)
.value("Error", logger::error)
.value("Fatal", logger::fatal)
.value("None", logger::none)
;
class_<logger,bases<singleton<logger,CreateStatic> >,
boost::noncopyable>("logger",no_init)
.def_readonly("Info", logger::info)
.def_readonly("Debug", logger::debug)
.def_readonly("Warn", logger::warn)
.def_readonly("Error", logger::error)
.def_readonly("Fatal", logger::fatal)
.def_readonly("None", logger::none)
.def("get_severity", &logger::get_severity)
.def("set_severity", &logger::set_severity)
.def("get_object_severity", &logger::get_object_severity)
.def("set_object_severity", &logger::set_object_severity)
.def("clear_object_severity", &logger::clear_object_severity)
.def("get_format", &logger::get_format)
.def("set_format", &logger::set_format)
.def("str", &logger::str)
.def("use_file", &logger::use_file)
.def("use_console", &logger::use_console)
.staticmethod("get_severity")
.staticmethod("set_severity")
.staticmethod("get_object_severity")
.staticmethod("set_object_severity")
.staticmethod("clear_object_severity")
.staticmethod("get_format")
.staticmethod("set_format")
.staticmethod("str")
.staticmethod("use_file")
.staticmethod("use_console")
;
}

View file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id: mapnik_map.cc 17 2005-03-08 23:58:43Z pavlenko $
// boost
#include <boost/python.hpp>
@ -118,6 +117,7 @@ struct map_pickle_suite : boost::python::pickle_suite
std::vector<layer>& (Map::*layers_nonconst)() = &Map::layers;
std::vector<layer> const& (Map::*layers_const)() const = &Map::layers;
mapnik::parameters& (Map::*params_nonconst)() = &Map::get_extra_parameters;
boost::optional<mapnik::box2d<double> > const& (Map::*maximum_extent_const)() const = &Map::maximum_extent;
mapnik::feature_type_style find_style(mapnik::Map const& m, std::string const& name)
{
@ -192,6 +192,18 @@ mapnik::Map map_deepcopy(mapnik::Map & m, boost::python::dict memo)
return result;
}
// TODO - find a simplier way to set optional to uninitialized
void set_maximum_extent(mapnik::Map & m, boost::optional<mapnik::box2d<double> > const& box)
{
if (box)
{
m.set_maximum_extent(*box);
}
else
{
m.maximum_extent().reset();
}
}
void export_map()
{
@ -550,8 +562,8 @@ void export_map()
)
.add_property("maximum_extent",make_function
(&Map::maximum_extent,return_value_policy<copy_const_reference>()),
&Map::set_maximum_extent,
(maximum_extent_const,return_value_policy<copy_const_reference>()),
&set_maximum_extent,
"The maximum extent of the map.\n"
"\n"
"Usage:\n"

View file

@ -19,9 +19,9 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
#include <boost/python.hpp>
#include <mapnik/graphics.hpp>
#include <mapnik/image_util.hpp>
#include <mapnik/markers_symbolizer.hpp>
@ -124,5 +124,15 @@ void export_markers_symbolizer()
&markers_symbolizer::get_height,
&markers_symbolizer::set_height,
"Set/get the marker height")
.add_property("fill",
make_function(&markers_symbolizer::get_fill,
return_value_policy<copy_const_reference>()),
&markers_symbolizer::set_fill,
"Set/get the marker fill color")
.add_property("stroke",
make_function(&markers_symbolizer::get_stroke,
return_value_policy<copy_const_reference>()),
&markers_symbolizer::set_stroke,
"Set/get the marker stroke (outline)")
;
}

View file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
// boost
#include <boost/python.hpp>

View file

@ -25,6 +25,7 @@
#include <boost/make_shared.hpp>
// mapnik
#include <mapnik/debug.hpp>
#include <mapnik/params.hpp>
#include <mapnik/unicode.hpp>
#include <mapnik/value.hpp>
@ -102,7 +103,7 @@ struct parameters_pickle_suite : boost::python::pickle_suite
}
else
{
std::clog << "could not unpickle key: " << key << "\n";
MAPNIK_LOG_DEBUG(bindings) << "parameters_pickle_suite: Could not unpickle key=" << key;
}
}
}

View file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
#include <boost/python.hpp>
#include "mapnik_enumeration.hpp"

View file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
#include <boost/python.hpp>
#include <mapnik/image_util.hpp>

View file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
#include <boost/python.hpp>
#include "mapnik_enumeration.hpp"

View file

@ -19,10 +19,10 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
// mapnik
#include <mapnik/proj_transform.hpp>
// boost
#include <boost/python.hpp>

View file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
// boost
#include <boost/python.hpp>

View file

@ -67,6 +67,7 @@ void export_view_transform();
void export_raster_colorizer();
void export_inmem_metawriter();
void export_label_collision_detector();
void export_logger();
#include <mapnik/version.hpp>
#include <mapnik/value_error.hpp>
@ -386,6 +387,7 @@ BOOST_PYTHON_MODULE(_mapnik)
export_raster_colorizer();
export_inmem_metawriter();
export_label_collision_detector();
export_logger();
def("render_grid",&render_grid,
( arg("map"),

View file

@ -19,11 +19,14 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
// boost
#include <boost/python.hpp>
// mapnik
#include <mapnik/query.hpp>
#include <mapnik/box2d.hpp>
using mapnik::query;
using mapnik::box2d;

View file

@ -19,10 +19,12 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
// boost
#include <boost/python.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
// mapnik
#include <mapnik/raster_colorizer.hpp>
using mapnik::raster_colorizer;

View file

@ -19,9 +19,11 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
// boost
#include <boost/python.hpp>
// mapnik
#include <mapnik/raster_symbolizer.hpp>
using mapnik::raster_symbolizer;

View file

@ -19,13 +19,14 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
// boost
#include <boost/python.hpp>
#include <boost/python/implicit.hpp>
#include <boost/python/detail/api_placeholder.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
// mapnik
#include <mapnik/rule.hpp>
#include <mapnik/expression.hpp>
#include <mapnik/expression_string.hpp>

View file

@ -20,9 +20,11 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
// boost
#include <boost/python.hpp>
// mapnik
#include <mapnik/shield_symbolizer.hpp>
#include <mapnik/image_util.hpp>
#include <mapnik/path_expression_grammar.hpp>

View file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
// boost
#include <boost/python.hpp>

View file

@ -19,11 +19,12 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
// boost
#include <boost/python.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
// mapnik
#include "mapnik_enumeration.hpp"
#include <mapnik/feature_type_style.hpp>

View file

@ -19,10 +19,11 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
// boost
#include <boost/python.hpp>
// mapnik
//symbolizer typdef here rather than mapnik/symbolizer.hpp
#include <mapnik/rule.hpp>

View file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
// boost
#include <boost/python.hpp>

View file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
#if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO)

View file

@ -28,6 +28,7 @@
#include <boost/foreach.hpp>
// mapnik
#include <mapnik/debug.hpp>
#include <mapnik/grid/grid_renderer.hpp>
#include <mapnik/grid/grid.hpp>
#include <mapnik/grid/grid_util.hpp>
@ -271,7 +272,7 @@ static void write_features(T const& grid_type,
}
else
{
std::clog << "should not get here: key '" << key << "' not found in grid feature properties\n";
MAPNIK_LOG_DEBUG(bindings) << "write_features: Should not get here: key " << key << " not found in grid feature properties";
}
}
}

View file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
#include <boost/optional/optional.hpp>
#include <boost/python.hpp>

View file

@ -1,5 +1,3 @@
CXX = g++
CXXFLAGS = $(shell mapnik-config --cflags)
LDFLAGS = $(shell mapnik-config --libs --dep-libs --ldflags)

View file

@ -47,7 +47,6 @@ rundemo = demo_env.Program('rundemo', source, LIBS=libraries, LINKFLAGS=env["CUS
Depends(rundemo, env.subst('../../src/%s' % env['MAPNIK_LIB_NAME']))
# we don't install this app because the datasource paths are relative
# and we're not going to install the sample data.
#env.Install(install_prefix + '/bin', rundemo)
#env.Alias('install', install_prefix + '/bin')
# build locally if installing
if 'install' in COMMAND_LINE_TARGETS:
env.Alias('install',rundemo)

View file

@ -70,7 +70,7 @@ int main ( int argc , char** argv)
provpoly_style.add_rule(provpoly_rule_on);
rule provpoly_rule_qc;
provpoly_rule_qc.set_filter(parse_expression("[NOM_FR] = 'Québec'"));
provpoly_rule_qc.set_filter(parse_expression("[NOM_FR] = 'Québec'"));
provpoly_rule_qc.append(polygon_symbolizer(color(217, 235, 203)));
provpoly_style.add_rule(provpoly_rule_qc);
@ -175,6 +175,7 @@ int main ( int argc , char** argv)
parameters p;
p["type"]="shape";
p["file"]="../data/boundaries";
p["encoding"]="latin1";
layer lyr("Provinces");
lyr.set_datasource(datasource_cache::instance()->create(p));

View file

@ -125,7 +125,7 @@ public:
}
protected:
void render_marker(pixel_position const& pos, marker const& marker, const agg::trans_affine & mtx, double opacity=1.0);
void render_marker(pixel_position const& pos, marker const& marker, const agg::trans_affine & mtx, double opacity=1.0, bool recenter=true);
Map const& m_;
Cairo::RefPtr<Cairo::Context> context_;

View file

@ -24,6 +24,7 @@
#define MAPNIK_CTRANS_HPP
// mapnik
#include <mapnik/debug.hpp>
#include <mapnik/box2d.hpp>
#include <mapnik/vertex.hpp>
#include <mapnik/coord_array.hpp>
@ -254,10 +255,10 @@ struct MAPNIK_DECL coord_transform_parallel
angle_a = atan2((m_pre_y-m_cur_y),(m_pre_x-m_cur_x));
dx_pre = cos(angle_a + pi_by_2);
dy_pre = sin(angle_a + pi_by_2);
#ifdef MAPNIK_DEBUG
std::clog << "offsetting line by: " << offset_ << "\n";
std::clog << "initial dx=" << (dx_pre * offset_) << " dy=" << (dy_pre * offset_) << "\n";
#endif
MAPNIK_LOG_DEBUG(ctrans) << "coord_transform_parallel: Offsetting line by=" << offset_;
MAPNIK_LOG_DEBUG(ctrans) << "coord_transform_parallel: Initial dx=" << (dx_pre * offset_) << ",dy=" << (dy_pre * offset_);
*x = m_pre_x + (dx_pre * offset_);
*y = m_pre_y + (dy_pre * offset_);
m_status = process;
@ -304,15 +305,14 @@ struct MAPNIK_DECL coord_transform_parallel
}
else // skip sharp spikes
{
#ifdef MAPNIK_DEBUG
#ifdef MAPNIK_LOG
dx_curr = cos(angle_a + pi_by_2);
dy_curr = sin(angle_a + pi_by_2);
sin_curve = dx_curr*dy_pre-dy_curr*dx_pre;
std::clog << "angle a: " << angle_a << "\n";
std::clog << "angle b: " << angle_b << "\n";
std::clog << "h: " << h << "\n";
std::clog << "sin_curve: " << sin_curve << "\n";
MAPNIK_LOG_DEBUG(ctrans) << "coord_transform_parallel: angle a=" << angle_a;
MAPNIK_LOG_DEBUG(ctrans) << "coord_transform_parallel: angle b=" << angle_b;
MAPNIK_LOG_DEBUG(ctrans) << "coord_transform_parallel: h=" << h;
MAPNIK_LOG_DEBUG(ctrans) << "coord_transform_parallel: sin_curve=" << sin_curve;
#endif
m_status = process;
break;
@ -324,9 +324,7 @@ struct MAPNIK_DECL coord_transform_parallel
sin_curve = dx_curr*dy_pre-dy_curr*dx_pre;
cos_curve = -dx_pre*dx_curr-dy_pre*dy_curr;
#ifdef MAPNIK_DEBUG
std::clog << "sin_curve value: " << sin_curve << "\n";
#endif
MAPNIK_LOG_DEBUG(ctrans) << "coord_transform_parallel: sin_curve value=" << sin_curve;
if(sin_curve > -0.3 && sin_curve < 0.3) {
angle_b = atan2((m_cur_y-m_next_y),(m_cur_x-m_next_x));
h = tan((angle_b - angle_a)/2.0);

View file

@ -46,24 +46,29 @@ typedef MAPNIK_DECL boost::shared_ptr<Feature> feature_ptr;
struct MAPNIK_DECL Featureset : private boost::noncopyable
{
virtual feature_ptr next() = 0;
virtual ~Featureset() {};
virtual ~Featureset() {}
};
typedef MAPNIK_DECL boost::shared_ptr<Featureset> featureset_ptr;
class MAPNIK_DECL datasource_exception : public std::exception
{
private:
std::string message_;
public:
datasource_exception(const std::string& message = std::string("no reason"))
:message_(message) {}
: message_(message)
{
}
~datasource_exception() throw()
{
}
~datasource_exception() throw() {}
virtual const char* what() const throw()
{
return message_.c_str();
}
private:
std::string message_;
};
class MAPNIK_DECL datasource : private boost::noncopyable
@ -84,7 +89,8 @@ public:
datasource (parameters const& params)
: params_(params),
is_bound_(false)
{}
{
}
/*!
* @brief Get the configuration parameters of the data source.
@ -107,14 +113,14 @@ public:
/*!
* @brief Connect to the datasource
*/
virtual void bind() const {};
virtual void bind() const {}
virtual featureset_ptr features(const query& q) const = 0;
virtual featureset_ptr features_at_point(coord2d const& pt) const = 0;
virtual box2d<double> envelope() const = 0;
virtual boost::optional<geometry_t> get_geometry_type() const = 0;
virtual layer_descriptor get_descriptor() const = 0;
virtual ~datasource() {};
virtual ~datasource() {}
protected:
parameters params_;
mutable bool is_bound_;
@ -124,7 +130,6 @@ typedef std::string datasource_name();
typedef datasource* create_ds(const parameters& params, bool bind);
typedef void destroy_ds(datasource *ds);
class datasource_deleter
{
public:
@ -136,7 +141,6 @@ public:
typedef boost::shared_ptr<datasource> datasource_ptr;
#define DATASOURCE_PLUGIN(classname) \
extern "C" MAPNIK_EXP std::string datasource_name() \
{ \
@ -149,8 +153,7 @@ typedef boost::shared_ptr<datasource> datasource_ptr;
extern "C" MAPNIK_EXP void destroy(datasource *ds) \
{ \
delete ds; \
} \
//
}
}

340
include/mapnik/debug.hpp Normal file
View file

@ -0,0 +1,340 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 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
*
*****************************************************************************/
#ifndef MAPNIK_DEBUG_HPP
#define MAPNIK_DEBUG_HPP
// mapnik (should not depend on anything that need to use this)
#include <mapnik/config.hpp>
#include <mapnik/utils.hpp>
// boost
#include <boost/utility.hpp>
#include <boost/unordered_map.hpp>
#ifdef MAPNIK_THREADSAFE
#include <boost/thread/mutex.hpp>
#endif
// std
#include <iostream>
#include <sstream>
#include <ostream>
#include <fstream>
#include <string>
namespace mapnik {
/*
Global logger class that holds the configuration of severity, format
and file/console redirection.
*/
class MAPNIK_DECL logger :
public singleton<logger,CreateStatic>,
private boost::noncopyable
{
public:
enum severity_type
{
info,
debug,
warn,
error,
fatal,
none
};
typedef boost::unordered_map<std::string, severity_type> severity_map;
// global security level
static severity_type get_severity()
{
return severity_level_;
}
static void set_severity(const severity_type& severity_level)
{
#ifdef MAPNIK_THREADSAFE
boost::mutex::scoped_lock lock(severity_mutex_);
#endif
severity_level_ = severity_level;
}
// per object security levels
static severity_type get_object_severity(const std::string& object_name)
{
severity_map::iterator it = object_severity_level_.find(object_name);
if (object_name.empty() || it == object_severity_level_.end())
{
return severity_level_;
}
else
{
return it->second;
}
}
static void set_object_severity(const std::string& object_name,
const severity_type& security_level)
{
#ifdef MAPNIK_THREADSAFE
boost::mutex::scoped_lock lock(severity_mutex_);
#endif
if (! object_name.empty())
{
object_severity_level_[object_name] = security_level;
}
}
static void clear_object_severity()
{
#ifdef MAPNIK_THREADSAFE
boost::mutex::scoped_lock lock(severity_mutex_);
#endif
object_severity_level_.clear();
}
// format
static std::string get_format()
{
return format_;
}
static void set_format(const std::string& format)
{
#ifdef MAPNIK_THREADSAFE
boost::mutex::scoped_lock lock(format_mutex_);
#endif
format_ = format;
}
// interpolate the format string for output
static std::string str();
// output
static void use_file(const std::string& filepath);
static void use_console();
private:
static severity_type severity_level_;
static severity_map object_severity_level_;
static bool severity_env_check_;
static std::string format_;
static bool format_env_check_;
static std::ofstream file_output_;
static std::string file_name_;
static std::streambuf* saved_buf_;
#ifdef MAPNIK_THREADSAFE
static boost::mutex severity_mutex_;
static boost::mutex format_mutex_;
#endif
};
namespace detail {
/*
Default sink, it regulates access to clog
*/
template<class Ch, class Tr, class A>
class clog_sink
{
public:
typedef std::basic_ostringstream<Ch, Tr, A> stream_buffer;
void operator()(const logger::severity_type& severity, const stream_buffer &s)
{
#ifdef MAPNIK_THREADSAFE
static boost::mutex mutex;
boost::mutex::scoped_lock lock(mutex);
#endif
std::clog << logger::str() << " " << s.str() << std::endl;
}
};
/*
Base log class, should not log anything when no MAPNIK_LOG is defined
This is used for info/debug/warn reporting that should not output
anything when not compiling for speed.
*/
template<template <class Ch, class Tr, class A> class OutputPolicy,
logger::severity_type Severity,
class Ch = char,
class Tr = std::char_traits<Ch>,
class A = std::allocator<Ch> >
class base_log : public boost::noncopyable
{
public:
typedef OutputPolicy<Ch, Tr, A> output_policy;
base_log() {}
base_log(const char* object_name)
{
#ifdef MAPNIK_LOG
if (object_name != NULL)
{
object_name_ = object_name;
}
#endif
}
~base_log()
{
#ifdef MAPNIK_LOG
if (check_severity())
{
output_policy()(Severity, streambuf_);
}
#endif
}
template<class T>
base_log &operator<<(const T &x)
{
#ifdef MAPNIK_LOG
streambuf_ << x;
#endif
return *this;
}
private:
#ifdef MAPNIK_LOG
inline bool check_severity()
{
return Severity >= logger::get_object_severity(object_name_);
}
typename output_policy::stream_buffer streambuf_;
std::string object_name_;
#endif
};
/*
Base log class that always log, regardless of MAPNIK_LOG.
This is used for error/fatal reporting that should always log something
*/
template<template <class Ch, class Tr, class A> class OutputPolicy,
logger::severity_type Severity,
class Ch = char,
class Tr = std::char_traits<Ch>,
class A = std::allocator<Ch> >
class base_log_always : public boost::noncopyable
{
public:
typedef OutputPolicy<Ch, Tr, A> output_policy;
base_log_always() {}
base_log_always(const char* object_name)
{
if (object_name != NULL)
{
object_name_ = object_name;
}
}
~base_log_always()
{
if (check_severity())
{
output_policy()(Severity, streambuf_);
}
}
template<class T>
base_log_always &operator<<(const T &x)
{
streambuf_ << x;
return *this;
}
private:
inline bool check_severity()
{
return Severity >= logger::get_object_severity(object_name_);
}
typename output_policy::stream_buffer streambuf_;
std::string object_name_;
};
typedef base_log<clog_sink, logger::info> base_log_info;
typedef base_log<clog_sink, logger::debug> base_log_debug;
typedef base_log<clog_sink, logger::warn> base_log_warn;
typedef base_log_always<clog_sink, logger::error> base_log_error;
typedef base_log_always<clog_sink, logger::fatal> base_log_fatal;
} // namespace detail
// real interfaces
class MAPNIK_DECL info : public detail::base_log_info {
public:
info() : detail::base_log_info() {}
info(const char* object_name) : detail::base_log_info(object_name) {}
};
class MAPNIK_DECL debug : public detail::base_log_debug {
public:
debug() : detail::base_log_debug() {}
debug(const char* object_name) : detail::base_log_debug(object_name) {}
};
class MAPNIK_DECL warn : public detail::base_log_warn {
public:
warn() : detail::base_log_warn() {}
warn(const char* object_name) : detail::base_log_warn(object_name) {}
};
class MAPNIK_DECL error : public detail::base_log_error {
public:
error() : detail::base_log_error() {}
error(const char* object_name) : detail::base_log_error(object_name) {}
};
class MAPNIK_DECL fatal : public detail::base_log_fatal {
public:
fatal() : detail::base_log_fatal() {}
fatal(const char* object_name) : detail::base_log_fatal(object_name) {}
};
// logging helpers
#define MAPNIK_LOG_INFO(s) mapnik::info(#s)
#define MAPNIK_LOG_DEBUG(s) mapnik::debug(#s)
#define MAPNIK_LOG_WARN(s) mapnik::warn(#s)
#define MAPNIK_LOG_ERROR(s) mapnik::error(#s)
#define MAPNIK_LOG_FATAL(s) mapnik::fatal(#s)
}
#endif // MAPNIK_DEBUG_HPP

View file

@ -25,6 +25,7 @@
// mapnik
#include <mapnik/config.hpp>
#include <mapnik/debug.hpp>
// stl
#include <vector>
@ -73,7 +74,7 @@ protected:
* underscores (<i>_</i>) and dashes (<i>-</i>).
*
*
* @warning At the moment the verify() method is called during static initialization.
* @warning At the moment the verify_mapnik_enum() method is called during static initialization.
* It quits the application with exit code 1 if any error is detected. The other solution
* i thought of is to do the checks at compile time (using boost::mpl).
*
@ -139,10 +140,15 @@ template <class ENUM, int THE_MAX>
class MAPNIK_DECL enumeration {
public:
typedef ENUM native_type;
enumeration():
value_() {};
enumeration( ENUM v ) : value_(v) {}
enumeration( const enumeration & other ) : value_(other.value_) {}
enumeration()
: value_() {}
enumeration( ENUM v )
: value_(v) {}
enumeration( const enumeration & other )
: value_(other.value_) {}
/** Assignment operator for native enum values. */
void operator=(ENUM v)
@ -166,10 +172,12 @@ public:
{
MAX = THE_MAX
};
ENUM max() const
{
return THE_MAX;
}
/** Converts @p str to an enum.
* @throw illegal_enum_value @p str is not a legal identifier.
* */
@ -247,32 +255,36 @@ public:
/** Performs some simple checks and quits the application if
* any error is detected. Tries to print helpful error messages.
*/
static bool verify(const char * filename, unsigned line_no)
static bool verify_mapnik_enum(const char * filename, unsigned line_no)
{
for (unsigned i = 0; i < THE_MAX; ++i)
{
if (our_strings_[i] == 0 )
{
std::cerr << "### FATAL: Not enough strings for enum "
MAPNIK_LOG_FATAL(enumeration)
<< "### FATAL: Not enough strings for enum "
<< our_name_ << " defined in file '" << filename
<< "' at line " << line_no << std::endl;
<< "' at line " << line_no;
//std::exit(1);
}
}
if ( std::string("") != our_strings_[THE_MAX])
{
std::cerr << "### FATAL: The string array for enum " << our_name_
MAPNIK_LOG_FATAL(enumeration)
<< "### FATAL: The string array for enum " << our_name_
<< " defined in file '" << filename << "' at line " << line_no
<< " has too many items or is not terminated with an "
<< "empty string." << std::endl;
<< "empty string";
//std::exit(1);
}
return true;
}
static std::string const& get_full_qualified_name()
{
return our_name_;
}
static std::string get_name()
{
std::string::size_type idx = our_name_.find_last_of(":");
@ -283,6 +295,7 @@ public:
return our_name_.substr( idx + 1 );
}
}
private:
ENUM value_;
static const char ** our_strings_ ;
@ -320,13 +333,13 @@ operator>>(std::istream & is, mapnik::enumeration<ENUM, THE_MAX> & e)
#define DEFINE_ENUM( name, e) \
typedef enumeration<e, e ## _MAX> name
/** Helper macro. Runs the verify() method during static initialization.
/** Helper macro. Runs the verify_mapnik_enum() method during static initialization.
* @relates mapnik::enumeration
*/
#define IMPLEMENT_ENUM( name, strings ) \
template <> const char ** name ::our_strings_ = strings; \
template <> std::string name ::our_name_ = #name; \
template <> bool name ::our_verified_flag_( name ::verify(__FILE__, __LINE__));
template <> bool name ::our_verified_flag_( name ::verify_mapnik_enum(__FILE__, __LINE__));
#endif // MAPNIK_ENUMERATION_HPP

View file

@ -141,9 +141,8 @@ struct expression_grammar : qi::grammar<Iterator, expr_node(), space_type>
using qi::_r1;
#if BOOST_VERSION > 104200
using qi::no_skip;
#else
using qi::lexeme;
#endif
using qi::lexeme;
using qi::_val;
using qi::lit;
using qi::int_;

View file

@ -39,7 +39,8 @@ class layer_descriptor
public:
layer_descriptor(std::string const& name, std::string const& encoding)
: name_(name),
encoding_(encoding) {}
encoding_(encoding),
desc_ar_() {}
layer_descriptor(layer_descriptor const& other)
: name_(other.name_),

View file

@ -24,6 +24,7 @@
#define MAPNIK_FONT_ENGINE_FREETYPE_HPP
// mapnik
#include <mapnik/debug.hpp>
#include <mapnik/color.hpp>
#include <mapnik/utils.hpp>
#include <mapnik/ctrans.hpp>
@ -138,10 +139,8 @@ public:
~font_face()
{
#ifdef MAPNIK_DEBUG
std::clog << "~font_face: Clean up face \"" << family_name()
<< " " << style_name() << "\"" << std::endl;
#endif
MAPNIK_LOG_DEBUG(font_engine_freetype) << "font_face: Clean up face \"" << family_name() << " " << style_name() << "\"";
FT_Done_Face(face_);
}
@ -225,9 +224,8 @@ public:
~stroker()
{
#ifdef MAPNIK_DEBUG
std::clog << "~stroker: destroy stroker:" << s_ << std::endl;
#endif
MAPNIK_LOG_DEBUG(font_engine_freetype) << "stroker: Destroy stroker=" << s_;
FT_Stroker_Done(s_);
}
private:
@ -268,7 +266,8 @@ class MAPNIK_DECL face_manager : private boost::noncopyable
public:
face_manager(T & engine)
: engine_(engine),
stroker_(engine_.create_stroker()) {}
stroker_(engine_.create_stroker()),
face_ptr_cache_() {}
face_ptr get_face(std::string const& name)
{
@ -305,14 +304,19 @@ public:
face_set_ptr face_set = boost::make_shared<font_face_set>();
for (std::vector<std::string>::const_iterator name = names.begin(); name != names.end(); ++name)
{
if (face_ptr face = get_face(*name))
face_ptr face = get_face(*name);
if (face)
{
face_set->add(face);
} else {
#ifdef MAPNIK_DEBUG
std::cerr << "Failed to find face '" << *name << "' in font set '" << fset.get_name() << "'\n";
#endif
}
#ifdef MAPNIK_LOG
else
{
MAPNIK_LOG_DEBUG(font_engine_freetype)
<< "Failed to find face '" << *name
<< "' in font set '" << fset.get_name() << "'\n";
}
#endif
}
return face_set;
}
@ -335,9 +339,9 @@ public:
}
private:
face_ptr_cache_type face_ptr_cache_;
font_engine_type & engine_;
stroker_ptr stroker_;
face_ptr_cache_type face_ptr_cache_;
};
template <typename T>

View file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
#ifndef MAPNIK_GAMMA_METHOD_HPP
#define MAPNIK_GAMMA_METHOD_HPP

View file

@ -25,6 +25,7 @@
// mapnik
#include <mapnik/config.hpp>
#include <mapnik/debug.hpp>
#include <mapnik/image_data.hpp>
#include <mapnik/box2d.hpp>
#include <mapnik/grid/grid_view.hpp>
@ -62,17 +63,16 @@ private:
unsigned width_;
unsigned height_;
std::string key_;
feature_key_type f_keys_;
feature_type features_;
data_type data_;
std::set<std::string> names_;
unsigned int resolution_;
std::string id_name_;
bool painted_;
std::set<std::string> names_;
feature_key_type f_keys_;
feature_type features_;
public:
hit_grid(int width, int height, std::string const& key, unsigned int resolution)
:width_(width),
height_(height),
@ -80,7 +80,10 @@ public:
data_(width,height),
resolution_(resolution),
id_name_("__id__"),
painted_(false)
painted_(false),
names_(),
f_keys_(),
features_()
{
// this only works if each datasource's
// feature count starts at 1
@ -94,7 +97,10 @@ public:
data_(rhs.data_),
resolution_(rhs.resolution_),
id_name_("__id__"),
painted_(rhs.painted_)
painted_(rhs.painted_),
names_(rhs.names_),
f_keys_(rhs.f_keys_),
features_(rhs.features_)
{
f_keys_[0] = "";
}
@ -136,7 +142,7 @@ public:
}
else
{
std::clog << "should not get here: key '" << key_ << "' not found in feature properties\n";
MAPNIK_LOG_DEBUG(grid) << "hit_grid: Should not get here: key '" << key_ << "' not found in feature properties";
}
}
@ -153,7 +159,7 @@ public:
}
else
{
std::clog << "### Warning: key '" << key_ << "' was blank for " << *feature << "\n";
MAPNIK_LOG_DEBUG(grid) << "hit_grid: Warning - key '" << key_ << "' was blank for " << *feature;
}
}

View file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
#ifndef MAPNIK_GRID_RASTERIZER_HPP
#define MAPNIK_GRID_RASTERIZER_HPP

View file

@ -20,8 +20,6 @@
*
*****************************************************************************/
//$Id$
#ifndef GRID_RENDERER_HPP
#define GRID_RENDERER_HPP
@ -32,7 +30,6 @@
#include <mapnik/label_collision_detector.hpp>
#include <mapnik/map.hpp>
//#include <mapnik/marker.hpp>
#include <mapnik/grid/grid.hpp>
// boost

View file

@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
#ifndef MAPNIK_GRID_RENDERING_BUFFER_HPP
#define MAPNIK_GRID_RENDERING_BUFFER_HPP

View file

@ -20,8 +20,6 @@
*
*****************************************************************************/
//$Id$
#ifndef MAPNIK_GRID_VIEW_HPP
#define MAPNIK_GRID_VIEW_HPP
@ -34,6 +32,7 @@
// boost
#include <boost/cstdint.hpp>
// stl
#include <map>
#include <set>

View file

@ -27,6 +27,11 @@
#include <string>
#include <boost/optional.hpp>
#include <mapnik/config.hpp>
#ifdef _MSC_VER
#include <mapnik/image_data.hpp>
#endif
namespace mapnik
{
@ -66,10 +71,15 @@ enum composite_mode_e
invert_rgb
};
boost::optional<composite_mode_e> comp_op_from_string(std::string const& name);
MAPNIK_DECL boost::optional<composite_mode_e> comp_op_from_string(std::string const& name);
template <typename T1, typename T2>
void composite(T1 & im, T2 & im2, composite_mode_e mode, bool premultiply_src, bool premultiply_dst);
MAPNIK_DECL void composite(T1 & im, T2 & im2, composite_mode_e mode, bool premultiply_src, bool premultiply_dst);
#ifdef _MSC_VER
template MAPNIK_DECL void composite<mapnik::image_data_32,mapnik::image_data_32>(mapnik::image_data_32 & im, mapnik::image_data_32 & im2, composite_mode_e mode);
#endif
}
#endif // MAPNIK_IMAGE_COMPOSITING_HPP

View file

@ -266,12 +266,12 @@ struct feature_grammar :
//
;
coordinates = eps(_r2 == 1) > point_coordinates(extract_geometry_(_r1))
| eps(_r2 == 2) > linestring_coordinates(extract_geometry_(_r1))
| eps(_r2 == 3) > polygon_coordinates(extract_geometry_(_r1))
| eps(_r2 == 4) > multipoint_coordinates(extract_geometry_(_r1))
| eps(_r2 == 5) > multilinestring_coordinates(extract_geometry_(_r1))
| eps(_r2 == 6) > multipolygon_coordinates(extract_geometry_(_r1))
coordinates = (eps(_r2 == 1) > point_coordinates(extract_geometry_(_r1)))
| (eps(_r2 == 2) > linestring_coordinates(extract_geometry_(_r1)))
| (eps(_r2 == 3) > polygon_coordinates(extract_geometry_(_r1)))
| (eps(_r2 == 4) > multipoint_coordinates(extract_geometry_(_r1)))
| (eps(_r2 == 5) > multilinestring_coordinates(extract_geometry_(_r1)))
| (eps(_r2 == 6) > multipolygon_coordinates(extract_geometry_(_r1)))
;
point_coordinates = eps[ _a = new_<geometry_type>(Point) ]
@ -316,7 +316,7 @@ struct feature_grammar :
on_error<fail>
(
feature
, std::cerr
, std::clog
<< phoenix::val("Error! Expecting ")
<< _4 // what failed?
<< phoenix::val(" here: \"")

View file

@ -23,6 +23,7 @@
#ifndef MAPNIK_GEOJSON_GENERATOR_HPP
#define MAPNIK_GEOJSON_GENERATOR_HPP
#include <mapnik/config.hpp>
#include <mapnik/feature.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/utility.hpp>
@ -35,7 +36,7 @@ namespace mapnik { namespace json {
template <typename OutputIterator> struct feature_generator_grammar;
template <typename OutputIterator> struct multi_geometry_generator_grammar;
class feature_generator : private boost::noncopyable
class MAPNIK_DECL feature_generator : private boost::noncopyable
{
typedef std::back_insert_iterator<std::string> sink_type;
public:
@ -46,7 +47,7 @@ private:
boost::scoped_ptr<feature_generator_grammar<sink_type> > grammar_;
};
class geometry_generator : private boost::noncopyable
class MAPNIK_DECL geometry_generator : private boost::noncopyable
{
typedef std::back_insert_iterator<std::string> sink_type;
public:
@ -59,7 +60,7 @@ private:
#else
class feature_generator : private boost::noncopyable
class MAPNIK_DECL feature_generator : private boost::noncopyable
{
public:
feature_generator() {}
@ -67,7 +68,7 @@ public:
bool generate(std::string & geojson, mapnik::Feature const& f);
};
class geometry_generator : private boost::noncopyable
class MAPNIK_DECL geometry_generator : private boost::noncopyable
{
public:
geometry_generator() {}

View file

@ -20,8 +20,6 @@
*
*****************************************************************************/
//$Id$
#ifndef MAPNIK_JSON_GEOMETRY_GENERATOR_GRAMMAR_HPP
#define MAPNIK_JSON_GEOMETRY_GENERATOR_GRAMMAR_HPP
@ -30,6 +28,7 @@
#include <mapnik/geometry.hpp>
#include <mapnik/util/vertex_iterator.hpp>
#include <mapnik/util/container_adapter.hpp>
// boost
#include <boost/tuple/tuple.hpp>
#include <boost/spirit/include/karma.hpp>

View file

@ -140,7 +140,7 @@ class label_collision_detector4 : boost::noncopyable
public:
struct label
{
label(box2d<double> const& b) : box(b) {}
label(box2d<double> const& b) : box(b), text() {}
label(box2d<double> const& b, UnicodeString const& t) : box(b), text(t) {}
box2d<double> box;

View file

@ -25,6 +25,7 @@
// mapnik
#include <mapnik/map.hpp>
#include <mapnik/config.hpp> // for MAPNIK_DECL
// stl
#include <string>

View file

@ -337,6 +337,10 @@ public:
*/
boost::optional<box2d<double> > const& maximum_extent() const;
/*! \brief Get the non-const map maximum extent as box2d<double>
*/
boost::optional<box2d<double> > & maximum_extent();
/*! \brief Get the map base path where paths should be relative to.
*/
std::string const& base_path() const;

View file

@ -24,6 +24,7 @@
#define MAPNIK_MEMORY_FEATURESET_HPP
// mapnik
#include <mapnik/debug.hpp>
#include <mapnik/memory_datasource.hpp>
// boost
@ -52,11 +53,12 @@ public:
{
while (pos_ != end_)
{
for (unsigned i=0; i<(*pos_)->num_geometries();++i) {
for (unsigned i=0; i<(*pos_)->num_geometries();++i)
{
geometry_type & geom = (*pos_)->get_geometry(i);
#ifdef MAPNIK_DEBUG
std::clog << "bbox_=" << bbox_ << ", geom.envelope=" << geom.envelope() << "\n";
#endif
MAPNIK_LOG_DEBUG(memory_featureset) << "memory_featureset: BBox=" << bbox_ << ",Envelope=" << geom.envelope();
if (bbox_.intersects(geom.envelope()))
{
return *pos_++;

View file

@ -50,13 +50,18 @@ public:
typedef std::map<std::string, UnicodeString> property_map;
typedef property_map::const_iterator const_iterator;
metawriter_property_map() {}
metawriter_property_map() :
m_(),
not_found_() {}
UnicodeString const& operator[](std::string const& key) const;
UnicodeString& operator[](std::string const& key) {return m_[key];}
std::map<std::string, UnicodeString>::const_iterator find(std::string const& key) const
{
return m_.find(key);
}
std::map<std::string, UnicodeString>::const_iterator end() const
{
return m_.end();
@ -66,6 +71,7 @@ public:
{
return (*this)[key];
}
private:
property_map m_;
UnicodeString not_found_;

View file

@ -72,12 +72,14 @@ public:
void set_pixel_coordinates(bool on) { pixel_coordinates_ = on; }
bool get_pixel_coordinates() { return pixel_coordinates_; }
virtual void set_map_srs(projection const& proj);
protected:
enum {
HEADER_NOT_WRITTEN = -1,
STOPPED = -2,
STARTED = 0
};
/** Features written. */
int count_;
bool output_empty_;
@ -85,20 +87,23 @@ protected:
proj_transform *trans_;
projection output_srs_;
bool pixel_coordinates_;
virtual void write_header();
inline void write_feature_header(std::string type) {
#ifdef MAPNIK_DEBUG
if (count_ == STOPPED)
{
std::cerr << "WARNING: Metawriter not started before using it.\n";
MAPNIK_LOG_WARN(metawrite_json) << "Metawriter: instance not started before using it.";
}
#endif
if (count_ == HEADER_NOT_WRITTEN) write_header();
if (count_++) *f_ << ",\n";
*f_ << "{ \"type\": \"Feature\",\n \"geometry\": { \"type\": \"" << type << "\",\n \"coordinates\":";
}
void write_properties(Feature const& feature, metawriter_properties const& properties);
inline void write_point(CoordTransform const& t, double x, double y, bool last = false)
{
double z = 0.0;
@ -111,6 +116,7 @@ protected:
*f_ << ",";
}
}
void write_line_polygon(path_type & path, CoordTransform const& t, bool polygon);
private:
@ -136,10 +142,12 @@ public:
void set_filename(path_expression_ptr fn);
/** Get filename template. */
path_expression_ptr get_filename() const;
private:
path_expression_ptr fn_;
std::fstream f_;
std::string filename_;
protected:
virtual void write_header();
};

View file

@ -80,17 +80,22 @@ struct rgba
byte a;
inline rgba(byte r_, byte g_, byte b_, byte a_)
: r(r_), g(g_), b(b_), a(a_) {}
: r(r_),
g(g_),
b(b_),
a(a_) {}
inline rgba(rgb const& c)
: r(c.r), g(c.g), b(c.b), a(0xFF) {}
: r(c.r),
g(c.g),
b(c.b),
a(0xFF) {}
inline rgba(unsigned const& c) {
r = U2RED(c);
g = U2GREEN(c);
b = U2BLUE(c);
a = U2ALPHA(c);
}
inline rgba(unsigned const& c)
: r(U2RED(c)),
g(U2GREEN(c)),
b(U2BLUE(c)),
a(U2ALPHA(c)) {}
inline bool operator==(const rgba& y) const
{

View file

@ -43,8 +43,13 @@ namespace mapnik {
typedef boost::variant<std::string, attribute> path_component;
typedef std::vector<path_component> path_expression;
typedef boost::shared_ptr<path_expression> path_expression_ptr;
template <typename Iterator> struct path_expression_grammar;
MAPNIK_DECL path_expression_ptr parse_path(std::string const & str);
MAPNIK_DECL bool parse_path_from_string(path_expression_ptr const& path,
std::string const & str,
path_expression_grammar<std::string::const_iterator> const& g);
template <typename T>
struct path_processor

View file

@ -60,6 +60,7 @@ namespace standard_wide = boost::spirit::standard_wide;
using standard_wide::space_type;
using standard_wide::space;
typedef boost::variant<std::string, attribute> path_component;
template <typename Iterator>
struct path_expression_grammar : qi::grammar<Iterator, std::vector<path_component>(), space_type>

View file

@ -24,6 +24,7 @@
#define MAPNIK_POOL_HPP
// mapnik
#include <mapnik/debug.hpp>
#include <mapnik/utils.hpp>
// boost
@ -100,9 +101,8 @@ public:
typename ContType::iterator itr=unusedPool_.begin();
while ( itr!=unusedPool_.end())
{
#ifdef MAPNIK_DEBUG
std::clog<<"borrow "<<(*itr).get()<<"\n";
#endif
MAPNIK_LOG_DEBUG(pool) << "pool: Borrow instance=" << (*itr).get();
if ((*itr)->isOK())
{
usedPool_.push_back(*itr);
@ -111,9 +111,8 @@ public:
}
else
{
#ifdef MAPNIK_DEBUG
std::clog<<"bad connection (erase)" << (*itr).get()<<"\n";
#endif
MAPNIK_LOG_DEBUG(pool) << "pool: Bad connection (erase) instance=" << (*itr).get();
itr=unusedPool_.erase(itr);
}
}
@ -123,9 +122,9 @@ public:
if (conn->isOK())
{
usedPool_.push_back(conn);
#ifdef MAPNIK_DEBUG
std::clog << "create << " << conn.get() << "\n";
#endif
MAPNIK_LOG_DEBUG(pool) << "pool: Create connection=" << conn.get();
return conn;
}
}
@ -142,9 +141,8 @@ public:
{
if (obj.get()==(*itr).get())
{
#ifdef MAPNIK_DEBUG
std::clog<<"return "<<(*itr).get()<<"\n";
#endif
MAPNIK_LOG_DEBUG(pool) << "pool: Return instance=" << (*itr).get();
unusedPool_.push_back(*itr);
usedPool_.erase(itr);
return;

View file

@ -86,23 +86,20 @@ class quad_tree : boost::noncopyable
typedef typename node::cont_t cont_t;
typedef typename cont_t::iterator node_data_iterator;
nodes_t nodes_;
node * root_;
const unsigned int max_depth_;
const double ratio_;
public:
typedef typename nodes_t::iterator iterator;
typedef typename nodes_t::const_iterator const_iterator;
typedef typename boost::ptr_vector<T,boost::view_clone_allocator> result_t;
typedef typename result_t::iterator query_iterator;
result_t query_result_;
explicit quad_tree(box2d<double> const& ext,
unsigned int max_depth = 8,
double ratio = 0.55)
: max_depth_(max_depth),
ratio_(ratio)
ratio_(ratio),
query_result_(),
nodes_()
{
nodes_.push_back(new node(ext));
root_ = &nodes_[0];
@ -219,6 +216,13 @@ private:
ext[2]=box2d<double>(lox,hiy - height*ratio_,lox + width * ratio_,hiy);
ext[3]=box2d<double>(hix - width * ratio_,hiy - height*ratio_,hix,hiy);
}
const unsigned int max_depth_;
const double ratio_;
result_t query_result_;
nodes_t nodes_;
node * root_;
};
}

View file

@ -40,14 +40,6 @@ class query
{
public:
typedef boost::tuple<double,double> resolution_type;
private:
box2d<double> bbox_;
resolution_type resolution_;
double scale_denominator_;
double filter_factor_;
box2d<double> unbuffered_bbox_;
std::set<std::string> names_;
public:
query(box2d<double> const& bbox,
resolution_type const& resolution,
@ -57,7 +49,8 @@ public:
resolution_(resolution),
scale_denominator_(scale_denominator),
filter_factor_(1.0),
unbuffered_bbox_(unbuffered_bbox)
unbuffered_bbox_(unbuffered_bbox),
names_()
{}
query(box2d<double> const& bbox,
@ -67,7 +60,8 @@ public:
resolution_(resolution),
scale_denominator_(scale_denominator),
filter_factor_(1.0),
unbuffered_bbox_(bbox)
unbuffered_bbox_(bbox),
names_()
{}
query(box2d<double> const& bbox)
@ -75,7 +69,8 @@ public:
resolution_(resolution_type(1.0,1.0)),
scale_denominator_(1.0),
filter_factor_(1.0),
unbuffered_bbox_(bbox)
unbuffered_bbox_(bbox),
names_()
{}
query(query const& other)
@ -94,8 +89,8 @@ public:
resolution_=other.resolution_;
scale_denominator_=other.scale_denominator_;
filter_factor_=other.filter_factor_;
names_=other.names_;
unbuffered_bbox_=other.unbuffered_bbox_;
names_=other.names_;
return *this;
}
@ -119,12 +114,12 @@ public:
return unbuffered_bbox_;
}
void set_unbuffered_bbox(const box2d<double>& bbox)
void set_unbuffered_bbox(box2d<double> const& bbox)
{
unbuffered_bbox_ = bbox;
}
void set_bbox(const box2d<double>& bbox)
void set_bbox(box2d<double> const& bbox)
{
bbox_ = bbox;
}
@ -148,6 +143,14 @@ public:
{
return names_;
}
private:
box2d<double> bbox_;
resolution_type resolution_;
double scale_denominator_;
double filter_factor_;
box2d<double> unbuffered_bbox_;
std::set<std::string> names_;
};
}

View file

@ -200,9 +200,7 @@ private:
template <class T>
void copy_text_ptr(T & sym) const
{
#ifdef MAPNIK_DEBUG
std::cerr << "Warning: Deep copying TextSymbolizers is broken!\n";
#endif
MAPNIK_LOG_WARN(rule) << "rule: deep copying TextSymbolizers is broken!";
}
template <class T>

View file

@ -31,14 +31,14 @@ namespace mapnik { namespace sql_utils {
inline std::string unquote_double(const std::string& sql)
{
std::string table_name = boost::algorithm::to_lower_copy(sql);
std::string table_name = sql;
boost::algorithm::trim_if(table_name,boost::algorithm::is_any_of("\""));
return table_name;
}
inline std::string unquote(const std::string& sql)
{
std::string table_name = boost::algorithm::to_lower_copy(sql);
std::string table_name = sql;
boost::algorithm::trim_if(table_name,boost::algorithm::is_any_of("\"\'"));
return table_name;
}
@ -58,10 +58,11 @@ namespace mapnik { namespace sql_utils {
inline std::string table_from_sql(const std::string& sql)
{
std::string table_name = boost::algorithm::to_lower_copy(sql);
std::string table_name = sql;
boost::algorithm::replace_all(table_name,"\n"," ");
boost::algorithm::ireplace_all(table_name," from "," FROM ");
std::string::size_type idx = table_name.rfind(" from ");
std::string::size_type idx = table_name.rfind(" FROM ");
if (idx!=std::string::npos)
{
idx = table_name.find_first_not_of(" ",idx+5);

View file

@ -20,8 +20,6 @@
*
*****************************************************************************/
//$Id$
#ifndef MAPNIK_SVG_OUTPUT_ATTRIBUTES
#define MAPNIK_SVG_OUTPUT_ATTRIBUTES

View file

@ -24,6 +24,7 @@
#define MAPNIK_SVG_RENDERER_HPP
// mapnik
#include <mapnik/debug.hpp>
#include <mapnik/svg/svg_path_attributes.hpp>
#include <mapnik/gradient.hpp>
#include <mapnik/box2d.hpp>
@ -145,7 +146,7 @@ public:
unsigned g = stop_color.green();
unsigned b = stop_color.blue();
unsigned a = stop_color.alpha();
//std::clog << "r: " << r << " g: " << g << " b: " << b << "a: " << a << "\n";
//MAPNIK_LOG_DEBUG(svg_renderer) << "svg_renderer: r=" << r << ",g=" << g << ",b=" << b << ",a=" << a;
m_gradient_lut.add_color(st.first, agg::rgba8(r, g, b, int(a * opacity)));
}
m_gradient_lut.build_lut();
@ -278,7 +279,8 @@ public:
{
ras.reset();
if(fabs(curved_trans_contour.width()) < 0.0001)
// https://github.com/mapnik/mapnik/issues/1129
if(fabs(curved_trans_contour.width()) <= 1)
{
ras.add_path(curved_trans, attr.index);
}
@ -383,7 +385,7 @@ public:
{
ras.reset();
if(fabs(curved_trans_contour.width()) < 0.0001)
if(fabs(curved_trans_contour.width()) <= 1)
{
ras.add_path(curved_trans, attr.index);
}

View file

@ -171,7 +171,7 @@ namespace mapnik { namespace svg {
template <typename T>
void operator()(T const& c, qi::unused_type, qi::unused_type) const
{
std::cerr << typeid(c).name() << std::endl;
MAPNIK_LOG_DEBUG(svg) << typeid(c).name();
}
};
*/

View file

@ -30,8 +30,35 @@
#include <iomanip>
#include <ctime>
#ifdef _WINDOWS
#define NOMINMAX
#include <windows.h>
#else
#include <sys/time.h> // for gettimeofday() on unix
#include <sys/resource.h>
#endif
namespace mapnik {
// Try to return the time now
inline double time_now()
{
#ifdef _WINDOWS
LARGE_INTEGER t, f;
QueryPerformanceCounter(&t);
QueryPerformanceFrequency(&f);
return double(t.QuadPart) / double(f.QuadPart);
#else
struct timeval t;
struct timezone tzp;
gettimeofday(&t, &tzp);
return t.tv_sec + t.tv_usec * 1e-6;
#endif
}
// Measure times in both wall clock time and CPU times. Results are returned in milliseconds.
class timer
{
@ -41,44 +68,50 @@ public:
restart();
}
virtual ~timer()
{
}
void restart()
{
_stopped = false;
gettimeofday(&_wall_clock_start, NULL);
_cpu_start = clock();
stopped_ = false;
wall_clock_start_ = time_now();
cpu_start_ = clock();
}
virtual void stop() const
{
_stopped = true;
_cpu_end = clock();
gettimeofday(&_wall_clock_end, NULL);
stopped_ = true;
cpu_end_ = clock();
wall_clock_end_ = time_now();
}
double cpu_elapsed() const
{
// return elapsed CPU time in ms
if (!_stopped)
if (! stopped_)
{
stop();
}
return ((double) (_cpu_end - _cpu_start)) / CLOCKS_PER_SEC * 1000.0;
return ((double) (cpu_end_ - cpu_start_)) / CLOCKS_PER_SEC * 1000.0;
}
double wall_clock_elapsed() const
{
// return elapsed wall clock time in ms
if (!_stopped)
if (! stopped_)
{
stop();
long seconds = _wall_clock_end.tv_sec - _wall_clock_start.tv_sec;
long useconds = _wall_clock_end.tv_usec - _wall_clock_start.tv_usec;
return ((seconds) * 1000 + useconds / 1000.0) + 0.5;
}
return (wall_clock_end_ - wall_clock_start_) * 1000.0;
}
protected:
mutable timeval _wall_clock_start, _wall_clock_end;
mutable clock_t _cpu_start, _cpu_end;
mutable bool _stopped;
mutable double wall_clock_start_, wall_clock_end_;
mutable clock_t cpu_start_, cpu_end_;
mutable bool stopped_;
};
// A progress_timer behaves like a timer except that the destructor displays
@ -86,16 +119,18 @@ protected:
class progress_timer : public timer
{
public:
progress_timer(std::ostream & os, std::string const& base_message):
os_(os),
progress_timer(std::ostream & os, std::string const& base_message)
: os_(os),
base_message_(base_message)
{}
~progress_timer()
{
if (!_stopped)
if (! stopped_)
{
stop();
}
}
void stop() const
{
@ -112,8 +147,9 @@ public:
catch (...) {} // eat any exceptions
}
void discard() {
_stopped = true;
void discard()
{
stopped_ = true;
}
private:
@ -121,5 +157,6 @@ private:
std::string base_message_;
};
};
}
#endif // MAPNIK_TIMER_HPP

View file

@ -20,8 +20,6 @@
*
*****************************************************************************/
//$Id$
#ifndef CONTAINER_ADAPTER_HPP
#define CONTAINER_ADAPTER_HPP

View file

@ -23,23 +23,37 @@
#ifndef MAPNIK_UTIL_CONVERSIONS_HPP
#define MAPNIK_UTIL_CONVERSIONS_HPP
// mapnik
#include <mapnik/config.hpp>
// stl
#include <string>
// boost
#include <boost/config/warning_disable.hpp>
#include <boost/spirit/include/karma.hpp>
// boost
#include <boost/version.hpp>
#if BOOST_VERSION >= 104500
#include <boost/config/warning_disable.hpp>
#include <boost/spirit/include/karma.hpp>
#else
#include <boost/lexical_cast.hpp>
#endif
namespace mapnik { namespace util {
bool string2int(const char * value, int & result);
bool string2int(std::string const& value, int & result);
MAPNIK_DECL bool string2int(const char * value, int & result);
MAPNIK_DECL bool string2int(std::string const& value, int & result);
bool string2double(std::string const& value, double & result);
bool string2double(const char * value, double & result);
MAPNIK_DECL bool string2double(std::string const& value, double & result);
MAPNIK_DECL bool string2double(const char * value, double & result);
bool string2float(std::string const& value, float & result);
bool string2float(const char * value, float & result);
MAPNIK_DECL bool string2float(std::string const& value, float & result);
MAPNIK_DECL bool string2float(const char * value, float & result);
#if BOOST_VERSION >= 104500
// generic
template <typename T>
bool to_string(std::string & str, T value)
@ -68,6 +82,24 @@ inline bool to_string(std::string & str, double value)
return karma::generate(sink, double_type(), value);
}
#else
template <typename T>
bool to_string(std::string & str, T value)
{
try
{
str = boost::lexical_cast<T>(value);
return true;
}
catch (std::exception const& ex)
{
return false;
}
}
#endif
}}
#endif // MAPNIK_UTIL_CONVERSIONS_HPP

View file

@ -20,8 +20,6 @@
*
*****************************************************************************/
//$Id$
#ifndef MAPNIK_DEEPCOPY_HPP
#define MAPNIK_DEEPCOPY_HPP

View file

@ -20,8 +20,6 @@
*
*****************************************************************************/
//$Id$
#ifndef MAPNIK_GEOMETRY_SVG_GENERATOR_HPP
#define MAPNIK_GEOMETRY_SVG_GENERATOR_HPP
@ -30,6 +28,7 @@
#include <mapnik/geometry.hpp>
#include <mapnik/util/vertex_iterator.hpp>
#include <mapnik/util/container_adapter.hpp>
// boost
#include <boost/tuple/tuple.hpp>
#include <boost/spirit/include/karma.hpp>

View file

@ -20,8 +20,6 @@
*
*****************************************************************************/
//$Id$
#ifndef MAPNIK_GEOMETRY_TO_DS_TYPE
#define MAPNIK_GEOMETRY_TO_DS_TYPE

View file

@ -20,19 +20,19 @@
*
*****************************************************************************/
//$Id$
#ifndef MAPNIK_GEOMETRY_TO_WKB_HPP
#define MAPNIK_GEOMETRY_TO_WKB_HPP
// mapnik
#include <mapnik/global.hpp>
#include <mapnik/geometry.hpp>
// boost
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
#include <boost/interprocess/streams/bufferstream.hpp>
#include <boost/foreach.hpp>
// stl
#include <vector>
#include <cstdio>

View file

@ -20,8 +20,6 @@
*
*****************************************************************************/
//$Id$
#ifndef MAPNIK_GEOMETRY_TO_WKT_HPP
#define MAPNIK_GEOMETRY_TO_WKT_HPP

View file

@ -20,8 +20,6 @@
*
*****************************************************************************/
//$Id$
#ifndef MAPNIK_GEOMETRY_WKT_GENERATOR_HPP
#define MAPNIK_GEOMETRY_WKT_GENERATOR_HPP
@ -30,6 +28,7 @@
#include <mapnik/geometry.hpp>
#include <mapnik/util/vertex_iterator.hpp>
#include <mapnik/util/container_adapter.hpp>
// boost
#include <boost/tuple/tuple.hpp>
#include <boost/spirit/include/karma.hpp>

View file

@ -20,8 +20,6 @@
*
*****************************************************************************/
//$Id$
#ifndef MAPNIK_VERTEX_ITERATOR_HPP
#define MAPNIK_VERTEX_ITERATOR_HPP
@ -48,7 +46,9 @@ namespace mapnik { namespace util {
typedef vertex_vector<T> container_type;
vertex_iterator()
: v_(SEG_END,0,0)
: v_(SEG_END,0,0),
vertices_(),
pos_(0)
{}
explicit vertex_iterator(container_type const& vertices)
@ -76,8 +76,8 @@ namespace mapnik { namespace util {
return v_;
}
container_type const *vertices_;
value_type v_;
container_type const *vertices_;
unsigned pos_;
};

View file

@ -23,6 +23,7 @@
#ifndef MAPNIK_UTILS_HPP
#define MAPNIK_UTILS_HPP
// boost
#ifdef MAPNIK_THREADSAFE
#include <boost/thread/mutex.hpp>
#endif
@ -109,6 +110,7 @@ template <typename T,
static bool destroyed_;
singleton(const singleton &rhs);
singleton& operator=(const singleton&);
static void onDeadReference()
{
throw std::runtime_error("dead reference!");
@ -119,9 +121,6 @@ template <typename T,
CreatePolicy<T>::destroy(pInstance_);
pInstance_ = 0;
destroyed_ = true;
#ifdef MAPNIK_DEBUG
std::clog << " destroyed singleton \n";
#endif
}
protected:
@ -139,7 +138,6 @@ public:
#endif
if (! pInstance_)
{
if (destroyed_)
{
onDeadReference();
@ -147,6 +145,7 @@ public:
else
{
pInstance_ = CreatePolicy<T>::create();
// register destruction
std::atexit(&DestroySingleton);
}

View file

@ -668,7 +668,6 @@ struct to_double : public boost::static_visitor<double>
return result;
return 0;
}
double operator() (UnicodeString const& val) const
{
std::string utf8;
@ -702,7 +701,6 @@ struct to_int : public boost::static_visitor<double>
return result;
return 0;
}
int operator() (UnicodeString const& val) const
{
std::string utf8;

View file

@ -31,12 +31,14 @@ namespace mapnik {
class value_error : public std::exception
{
public:
value_error() {}
value_error() :
what_() {}
value_error( std::string const& what ) :
what_( what )
{
}
virtual ~value_error() throw() {};
virtual const char * what() const throw()

View file

@ -51,7 +51,7 @@ public:
class node_not_found: public std::exception
{
public:
node_not_found(std::string node_name);
node_not_found(std::string const& node_name);
virtual const char* what() const throw();
~node_not_found() throw ();
private:
@ -84,7 +84,7 @@ class xml_node
public:
typedef std::list<xml_node>::const_iterator const_iterator;
typedef std::map<std::string, xml_attribute> attribute_map;
xml_node(xml_tree &tree, std::string name, unsigned line=0, bool text_node = false);
xml_node(xml_tree &tree, std::string const& name, unsigned line=0, bool text_node = false);
std::string const& name() const;
std::string const& text() const;
@ -119,6 +119,11 @@ public:
std::string get_text() const;
xml_tree const& get_tree() const
{
return tree_;
}
template <typename T>
T get_value() const;
private:

View file

@ -25,6 +25,7 @@
//mapnik
#include <mapnik/xml_node.hpp>
#include <mapnik/expression_grammar.hpp>
#include <mapnik/path_expression_grammar.hpp>
// boost
#include <boost/format.hpp>
@ -55,6 +56,7 @@ private:
public:
mapnik::css_color_grammar<std::string::const_iterator> color_grammar;
mapnik::expression_grammar<std::string::const_iterator> expr_grammar;
path_expression_grammar<std::string::const_iterator> path_expr_grammar;
};
} //ns mapnik

View file

@ -1,3 +1,25 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2011 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
*
*****************************************************************************/
#include "csv_datasource.hpp"
// boost
@ -9,6 +31,7 @@
#include <boost/spirit/include/phoenix_operator.hpp>
// mapnik
#include <mapnik/debug.hpp>
#include <mapnik/feature_layer_desc.hpp>
#include <mapnik/feature_factory.hpp>
#include <mapnik/geometry.hpp>
@ -197,9 +220,8 @@ void csv_datasource::parse_csv(T& stream,
if (num_tabs > num_commas)
{
sep = "\t";
#ifdef MAPNIK_DEBUG
std::clog << "CSV Plugin: auto detected tab separator\n";
#endif
MAPNIK_LOG_DEBUG(csv) << "csv_datasource: auto detected tab separator";
}
}
else // pipes
@ -208,9 +230,8 @@ void csv_datasource::parse_csv(T& stream,
if (num_pipes > num_commas)
{
sep = "|";
#ifdef MAPNIK_DEBUG
std::clog << "CSV Plugin: auto detected '|' separator\n";
#endif
MAPNIK_LOG_DEBUG(csv) << "csv_datasource: auto detected '|' separator";
}
else // semicolons
{
@ -218,9 +239,8 @@ void csv_datasource::parse_csv(T& stream,
if (num_semicolons > num_commas)
{
sep = ";";
#ifdef MAPNIK_DEBUG
std::clog << "CSV Plugin: auto detected ';' separator\n";
#endif
MAPNIK_LOG_DEBUG(csv) << "csv_datasource: auto detected ';' separator";
}
}
}
@ -237,9 +257,7 @@ void csv_datasource::parse_csv(T& stream,
std::string quo = boost::trim_copy(quote);
if (quo.empty()) quo = "\"";
#ifdef MAPNIK_DEBUG
std::clog << "CSV Plugin: csv grammer: sep: '" << sep << "' quo: '" << quo << "' esc: '" << esc << "'\n";
#endif
MAPNIK_LOG_DEBUG(csv) << "csv_datasource: csv grammer: sep: '" << sep << "' quo: '" << quo << "' esc: '" << esc;
boost::escaped_list_separator<char> grammer;
try
@ -404,9 +422,8 @@ void csv_datasource::parse_csv(T& stream,
{
if ((row_limit_ > 0) && (line_number > row_limit_))
{
#ifdef MAPNIK_DEBUG
std::clog << "CSV Plugin: row limit hit, exiting at feature: " << feature_count << "\n";
#endif
MAPNIK_LOG_DEBUG(csv) << "csv_datasource: row limit hit, exiting at feature: " << feature_count;
break;
}
@ -417,12 +434,13 @@ void csv_datasource::parse_csv(T& stream,
{
std::string trimmed = csv_line;
boost::trim_if(trimmed,boost::algorithm::is_any_of("\",'\r\n"));
if (trimmed.empty()){
if (trimmed.empty())
{
++line_number;
MAPNIK_LOG_DEBUG(csv) << "csv_datasource: empty row encountered at line: " << line_number;
continue;
#ifdef MAPNIK_DEBUG
std::clog << "CSV Plugin: empty row encountered at line: " << line_number << "\n";
#endif
}
}
@ -524,7 +542,7 @@ void csv_datasource::parse_csv(T& stream,
}
else
{
if (!quiet_) std::clog << s.str() << "\n";
MAPNIK_LOG_ERROR(csv) << s.str();
}
}
}
@ -548,7 +566,7 @@ void csv_datasource::parse_csv(T& stream,
}
else
{
if (!quiet_) std::clog << s.str() << "\n";
MAPNIK_LOG_ERROR(csv) << s.str();
}
}
}
@ -585,7 +603,7 @@ void csv_datasource::parse_csv(T& stream,
}
else
{
if (!quiet_) std::clog << s.str() << "\n";
MAPNIK_LOG_ERROR(csv) << s.str();
}
}
}
@ -618,7 +636,7 @@ void csv_datasource::parse_csv(T& stream,
}
else
{
if (!quiet_) std::clog << s.str() << "\n";
MAPNIK_LOG_ERROR(csv) << s.str();
}
}
}
@ -711,7 +729,7 @@ void csv_datasource::parse_csv(T& stream,
}
else
{
if (!quiet_) std::clog << s.str() << "\n";
MAPNIK_LOG_ERROR(csv) << s.str();
continue;
}
}
@ -744,7 +762,7 @@ void csv_datasource::parse_csv(T& stream,
}
else
{
if (!quiet_) std::clog << s.str() << "\n";
MAPNIK_LOG_ERROR(csv) << s.str();
continue;
}
}
@ -795,7 +813,7 @@ void csv_datasource::parse_csv(T& stream,
}
else
{
if (!quiet_) std::clog << s.str() << "\n";
MAPNIK_LOG_ERROR(csv) << s.str();
continue;
}
}
@ -810,7 +828,7 @@ void csv_datasource::parse_csv(T& stream,
}
else
{
if (!quiet_) std::clog << ex.what() << "\n";
MAPNIK_LOG_ERROR(csv) << ex.what();
}
}
catch(const std::exception & ex)
@ -825,13 +843,13 @@ void csv_datasource::parse_csv(T& stream,
}
else
{
if (!quiet_) std::clog << s.str() << "\n";
MAPNIK_LOG_ERROR(csv) << s.str();
}
}
}
if (!feature_count > 0)
{
if (!quiet_) std::clog << "CSV Plugin: could not parse any lines of data\n";
MAPNIK_LOG_ERROR(csv) << "CSV Plugin: could not parse any lines of data";
}
}

Some files were not shown because too many files have changed in this diff Show more