Merge commit 'f483e590d846513c0ddc4e464139006a3f7cd917' into harfbuzz

This commit is contained in:
Hermann Kraus 2013-03-16 15:49:06 +01:00
commit c70f4c2c2d
114 changed files with 1028 additions and 1212 deletions

View file

@ -8,7 +8,7 @@ before_install:
- sudo apt-get install -qq libboost-dev libboost-filesystem-dev libboost-program-options-dev libboost-python-dev libboost-regex-dev libboost-system-dev libboost-thread-dev python-nose libicu-dev libpng-dev libjpeg-dev libtiff-dev libz-dev libfreetype6-dev libxml2-dev libproj-dev
script:
- ./configure DEMO=False BINDINGS='' CPP_TESTS=False CAIRO=False INPUT_PLUGINS='' OPTIMIZATION=1 JOBS=2 FAST=True && make
- ./configure DEMO=False BINDINGS='python' CPP_TESTS=False CAIRO=False INPUT_PLUGINS='' OPTIMIZATION=1 JOBS=2 FAST=True && make
branches:
only:

View file

@ -8,6 +8,12 @@ For a complete change history, see the git log.
## Future
- Added Layer `buffer-size` that can be used to override Map `buffer-size` to avoid
over-fetching of data that does not need to be buffered as much as other layers.
Map level `buffer-size` will be default if layers do not set the option. Renamed a
previously undocumented parameter by the same name that impacted clipping extent and
was not needed (clipping padding should likely be a symbolizer level option) (#1566)
- Fixed building symbolizer rendering to be fully sensitive to alpha (8b66128c892 / bc8ea1c5a7a)
- Added 64 bit integer support in the grid_renderer (#1662)

View file

@ -1,19 +1,27 @@
# Mapnik Installation
Mapnik is cross platform and runs on Linux, Mac OSX, Solaris, *BSD, and Windows.
## Quick Start
To configure and build mapnik do:
To configure and build Mapnik do:
./configure
make
NOTE: the above will not work on windows, rather see https://github.com/mapnik/mapnik/wiki/BuildingOnWindows
Then to run the tests locally (without needing to install):
make test-local
Install like:
sudo make install
If you need to uninstall do:
sudo make uninstall
For more details see the 'Building' Section below.
For more details see the `Building` Section below.
Platform specific install guides at https://github.com/mapnik/mapnik/wiki/Mapnik-Installation
@ -22,58 +30,54 @@ For troubleshooting help see https://github.com/mapnik/mapnik/wiki/InstallationT
## Depends
Mapnik is cross platform and runs on Linux, Mac OSX, Solaris, *BSD, and Windows.
The build system should work for all posix/unix systems but for windows see:
https://github.com/mapnik/mapnik/wiki/BuildingOnWindows
Build dependencies are:
Build system dependencies are:
* C++ compiler (like g++ or clang++)
* Python >= 2.4
* >= 2 GB RAM
* Python 2.4-2.7
* Scons (a copy is bundled)
Mapnik Core depends on:
* Boost
- >= 1.47 is required.
- These libraries are required:
- These libraries are used:
- filesystem
- system
- thread (if mapnik threadsafe support is required, default on)
- regex (optionally built with icu regex support)
- program_options (optionally for mapnik command line programs)
* libicuuc >= 4.0 (ideally >= 4.2) - International Components for Unicode
* libpng >= 1.2.x - PNG Graphics
* libjpeg - JPEG Graphics
* libtiff - TIFF Graphics
* libz - Zlib Compression
* libfreetype - Freetype2 for Font support (Install requires freetype-config)
* libpng >= 1.2.x - PNG graphics
* libjpeg - JPEG graphics
* libtiff - TIFF graphics
* libz - Zlib compression
* libfreetype - Freetype2 for font support (Install requires freetype-config)
* libxml2 - XML parsing (Install requires xml2-config)
* libproj - PROJ.4 Projection library
* libproj - PROJ.4 projection library
Mapnik Python binding depend on:
Mapnik Python bindings depend on:
* Python >= 2.4
* Python 2.5-2.7 or >= 3.2
* Boost python
Note: Python3k is supported, see: https://github.com/mapnik/mapnik/wiki/Python3k
Optional dependencies:
* Cairo - Graphics library for PDF, PS, and SVG formats
* Cairo - Graphics library for output formats like PDF, PS, and SVG
- pkg-config - Required for building with cairo support
- pycairo - Python bindings for cairo
* libpq - PostgreSQL libraries (For PostGIS plugin support)
* libgdal - GDAL/OGR input (For gdal and ogr plugin support)
* libsqlite3 - SQLite input (needs RTree support) (sqlite plugin support)
* libsqlite3 - SQLite input (needs RTree support builtin) (sqlite plugin support)
* libocci - Oracle input plugin support
* libcurl - OSM input plugin support
Instructions for installing many of these dependencies on
various platforms can be found at the Mapnik Community Wiki
(https://github.com/mapnik/mapnik/wiki/Mapnik-Installation).
various platforms can be found at the Mapnik Wiki:
https://github.com/mapnik/mapnik/wiki/Mapnik-Installation
## Building
@ -84,6 +88,10 @@ We provide a simple Makefile wrapper that can be used like:
./configure && make && make install
For help on what options are accepted do:
./configure --help
To interact with the local copy of scons directly you can do:
python scons/scons.py configure
@ -96,9 +104,9 @@ If you want to clean your build do:
make clean
If you experience odd configure errors, try resetting the SCons caches:
If you experience odd configure errors, try cleaning the configure caches:
make reset
make distclean
To install in a custom location do:
@ -116,57 +124,50 @@ To pass custom paths to a dependency, like icu, do:
./configure ICU_INCLUDES=/usr/local/include ICU_LIBS=/usr/local/include
If you want to see configure options do:
./configure --help
For more details on all the options see:
For more details on usage see:
https://github.com/mapnik/mapnik/wiki/UsingScons
## Testing Installation
First, try importing the Mapnik python module in a python interpreter,
and make sure it does so without errors:
You can run the Mapnik tests locally (without installing) like:
$ python
Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import mapnik
>>>
make test-local # see the Makefile for how this works
Then, try rendering the demo map, included in the Mapnik source code::
Or you can install and test like:
cd demo/python
python rundemo.py
make install && make test
If the resulting maps look good, this indicates the core components of
Mapnik are installed properly, as well as the Shapefile plugin, Unicode
text support (ICU), and re-projection support using Proj.
Many of the tests are written in python and you can run them individually like:
For further tests see the `tests` folder within the Mapnik source code.
make install
python tests/python_tests/shapefile_test.py
## Learning Mapnik
### Users
### Help
Visit https://github.com/mapnik/mapnik/wiki/LearningMapnik for basic tutorials on making maps with Mapnik using the Python bindings.
Mapnik has an active community of talented users and developers making beautiful maps.
### Developers
If you need help or want to participate starting points include:
- Sign up and post to the mailing list: http://mapnik.org/contact/
- Join and ask questions on the #mapnik channel on irc://irc.freenode.net/mapnik
- Add your help questions to https://github.com/mapnik/mapnik-support
### Cartographers
TileMill, which uses Mapnik internally, offers great step by step tutorials for
learning advanced map styling: http://mapbox.com/tilemill/docs/crashcourse/introduction/
### Programmers
Mapnik is great for building your own mapping applications. Visit
https://github.com/mapnik/mapnik/wiki/LearningMapnik for basic
tutorials on how to programmatically use Mapnik.
### Contributers
Read docs/contributing.markdown for resources for getting involved with Mapnik development.
## Mapnik Community
Mapnik has an active community of talented users and developers making
amazing maps.
Please feel free to subscribe to the community list and post on both
usage and development topics: http://mapnik.org/contact/
You can also get involved by joining the #mapnik channel on irc://irc.freenode.net/mapnik

View file

@ -18,8 +18,12 @@ clean:
@if test -e ".sconsign.dblite"; then rm ".sconsign.dblite"; fi
@find ./ -name "*.os" -exec rm {} \;
@find ./ -name "*.o" -exec rm {} \;
@find ./ -name "*.pyc" -exec rm {} \;
@rm bindings/python/mapnik/paths.py
distclean:
if test -e "config.cache"; then rm -r "config.cache"; fi
if test -e "config.log"; then rm -r "config.log"; fi
if test -e ".sconf_temp/"; then rm -r ".sconf_temp/"; fi
if test -e ".sconsign.dblite"; then rm ".sconsign.dblite"; fi
if test -e "config.cache"; then rm "config.cache"; fi

View file

@ -967,6 +967,7 @@ if not preconfigured:
env['PLUGINS'] = PLUGINS
env['EXTRA_FREETYPE_LIBS'] = []
env['SQLITE_LINKFLAGS'] = []
env['PYTHON_INCLUDES'] = []
# previously a leading / was expected for LIB_DIR_NAME
# now strip it to ensure expected behavior
if env['LIB_DIR_NAME'].startswith(os.path.sep):
@ -1267,6 +1268,9 @@ if not preconfigured:
env.Prepend(CPPPATH = '#deps/agg/include')
env.Prepend(LIBPATH = '#deps/agg')
# prepend deps dir for auxillary headers
env.Prepend(CPPPATH = '#deps')
if env['CAIRO']:
if env['CAIRO_LIBS'] or env['CAIRO_INCLUDES']:
c_inc = env['CAIRO_INCLUDES']
@ -1352,7 +1356,14 @@ if not preconfigured:
py_includes = '''%s -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())"''' % env['PYTHON']
else:
py_includes = '''%s -c "from distutils.sysconfig import get_python_inc; print get_python_inc()"''' % env['PYTHON']
env['PYTHON_INCLUDES'] = call(py_includes)
env['PYTHON_INCLUDES'].append(call(py_includes))
# also append platform specific includes
if py3:
py_plat_includes = '''%s -c "from distutils.sysconfig import get_python_inc; print(get_python_inc(plat_specific=True))"''' % env['PYTHON']
else:
py_plat_includes = '''%s -c "from distutils.sysconfig import get_python_inc; print get_python_inc(plat_specific=True)"''' % env['PYTHON']
env['PYTHON_INCLUDES'].append(call(py_plat_includes))
# Note: we use the plat_specific argument here to make sure to respect the arch-specific site-packages location
if py3:
@ -1363,7 +1374,7 @@ if not preconfigured:
else:
env['PYTHON_SYS_PREFIX'] = os.popen('''%s -c "import sys; print sys.prefix"''' % env['PYTHON']).read().strip()
env['PYTHON_VERSION'] = os.popen('''%s -c "import sys; print sys.version"''' % env['PYTHON']).read()[0:3]
env['PYTHON_INCLUDES'] = env['PYTHON_SYS_PREFIX'] + '/include/python' + env['PYTHON_VERSION']
env['PYTHON_INCLUDES'] = [env['PYTHON_SYS_PREFIX'] + '/include/python' + env['PYTHON_VERSION']]
env['PYTHON_SITE_PACKAGES'] = env['DESTDIR'] + os.path.sep + env['PYTHON_SYS_PREFIX'] + os.path.sep + env['LIBDIR_SCHEMA'] + '/python' + env['PYTHON_VERSION'] + '/site-packages/'
# if user-requested custom prefix fall back to manual concatenation for building subdirectories
@ -1529,7 +1540,8 @@ if not preconfigured:
# as they are later set in the python build.py
# ugly hack needed until we have env specific conf
backup = env.Clone().Dictionary()
env.AppendUnique(CPPPATH = os.path.realpath(env['PYTHON_INCLUDES']))
for pyinc in env['PYTHON_INCLUDES']:
env.AppendUnique(CPPPATH = os.path.realpath(pyinc))
if not conf.CheckHeader(header='Python.h',language='C'):
color_print(1,'Could not find required header files for the Python language (version %s)' % env['PYTHON_VERSION'])
@ -1671,6 +1683,9 @@ if not HELP_REQUESTED:
# Install headers
SConscript('include/build.py')
# Install auxiliary headers
SConscript('deps/mapnik/build.py')
# Build the requested and able-to-be-compiled input plug-ins
GDAL_BUILT = False
OGR_BUILT = False

View file

@ -21,6 +21,8 @@
*****************************************************************************/
#include <boost/python.hpp>
#include <mapnik/value.hpp>
#include <mapnik/attribute.hpp>
#include <mapnik/building_symbolizer.hpp>
using namespace mapnik;

View file

@ -225,6 +225,7 @@ void export_feature()
.def("has_key", &Feature::has_key)
.add_property("attributes",&attributes)
.def("__setitem__",&__setitem__)
.def("__contains__",&__getitem__)
.def("__getitem__",&__getitem__)
.def("__getitem__",&__getitem2__)
.def("__len__", &Feature::size)

View file

@ -103,6 +103,31 @@ void set_maximum_extent(mapnik::layer & l, boost::optional<mapnik::box2d<double>
}
}
void set_buffer_size(mapnik::layer & l, boost::optional<int> const& buffer_size)
{
if (buffer_size)
{
l.set_buffer_size(*buffer_size);
}
else
{
l.reset_buffer_size();
}
}
PyObject * get_buffer_size(mapnik::layer & l)
{
boost::optional<int> buffer_size = l.buffer_size();
if (buffer_size)
{
return PyInt_FromLong(*buffer_size);
}
else
{
Py_RETURN_NONE;
}
}
void export_layer()
{
using namespace boost::python;
@ -224,17 +249,18 @@ void export_layer()
)
.add_property("buffer_size",
&layer::buffer_size,
&layer::set_buffer_size,
&get_buffer_size,
&set_buffer_size,
"Get/Set the size of buffer around layer in pixels.\n"
"\n"
"Usage:\n"
">>> l.buffer_size\n"
"0 # zero by default\n"
">>> print(l.buffer_size)\n"
"None # None by default\n"
">>> l.buffer_size = 2\n"
">>> l.buffer_size\n"
"2\n"
)
.add_property("maximum_extent",make_function
(&layer::maximum_extent,return_value_policy<copy_const_reference>()),
&set_maximum_extent,

View file

@ -23,6 +23,7 @@
#include <boost/python.hpp>
#include <mapnik/graphics.hpp>
#include <mapnik/expression_node.hpp>
#include <mapnik/value_error.hpp>
#include <mapnik/image_util.hpp>
#include <mapnik/markers_symbolizer.hpp>

View file

@ -175,11 +175,23 @@ mapnik::value_holder get_param(mapnik::parameter const& p, int index)
}
}
boost::shared_ptr<mapnik::parameter> create_parameter(std::string const& key, mapnik::value_holder const& value)
boost::shared_ptr<mapnik::parameter> create_parameter(UnicodeString const& key, mapnik::value_holder const& value)
{
return boost::make_shared<mapnik::parameter>(key,mapnik::value_holder(value));
std::string key_utf8;
mapnik::to_utf8(key, key_utf8);
return boost::make_shared<mapnik::parameter>(key_utf8,value);
}
// needed for Python_Unicode to std::string (utf8) conversion
boost::shared_ptr<mapnik::parameter> create_parameter_from_string(UnicodeString const& key, UnicodeString const& ustr)
{
std::string key_utf8;
std::string ustr_utf8;
mapnik::to_utf8(key, key_utf8);
mapnik::to_utf8(ustr,ustr_utf8);
return boost::make_shared<mapnik::parameter>(key_utf8, ustr_utf8);
}
void export_parameters()
{
@ -193,6 +205,10 @@ void export_parameters()
.def("__init__", make_constructor(create_parameter),
"Create a mapnik.Parameter from a pair of values, the first being a string\n"
"and the second being either a string, and integer, or a float")
.def("__init__", make_constructor(create_parameter_from_string),
"Create a mapnik.Parameter from a pair of values, the first being a string\n"
"and the second being either a string, and integer, or a float")
.def_pickle(parameter_pickle_suite())
.def("__getitem__",get_param)
;

View file

@ -382,7 +382,11 @@ bool has_cairo()
bool has_pycairo()
{
#if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO)
#if PY_MAJOR_VERSION >= 3
Pycairo_CAPI = (Pycairo_CAPI_t*) PyCapsule_Import(const_cast<char *>("cairo.CAPI"), 0);
#else
Pycairo_CAPI = (Pycairo_CAPI_t*) PyCObject_Import(const_cast<char *>("cairo"), const_cast<char *>("CAPI"));
#endif
if (Pycairo_CAPI == NULL){
/*
Case where pycairo support has been compiled into
@ -739,6 +743,7 @@ BOOST_PYTHON_MODULE(_mapnik)
python_optional<double>();
python_optional<float>();
python_optional<bool>();
python_optional<int>();
python_optional<mapnik::text_transform_e>();
register_ptr_to_python<mapnik::expression_ptr>();
register_ptr_to_python<mapnik::path_expression_ptr>();

View file

@ -22,6 +22,7 @@
// boost
#include <boost/python.hpp>
#include <boost/variant.hpp>
// mapnik
//symbolizer typdef here rather than mapnik/symbolizer.hpp

View file

@ -31,6 +31,7 @@ static Pycairo_CAPI_t *Pycairo_CAPI;
static void *extract_surface(PyObject* op)
{
if (PyObject_TypeCheck(op, const_cast<PyTypeObject*>(Pycairo_CAPI->Surface_Type)))
{
return op;
@ -55,7 +56,11 @@ static void *extract_context(PyObject* op)
void register_cairo()
{
#if PY_MAJOR_VERSION >= 3
Pycairo_CAPI = (Pycairo_CAPI_t*) PyCapsule_Import(const_cast<char *>("cairo.CAPI"), 0);
#else
Pycairo_CAPI = (Pycairo_CAPI_t*) PyCObject_Import(const_cast<char *>("cairo"), const_cast<char *>("CAPI"));
#endif
if (Pycairo_CAPI == NULL) return;
boost::python::converter::registry::insert(&extract_surface, boost::python::type_id<PycairoSurface>());

View file

@ -48,23 +48,28 @@ int main ( int argc , char** argv)
{
if (argc != 2)
{
std::cout << "usage: ./rundemo <mapnik_install_dir>\nUsually /usr/local/lib/mapnik\n";
std::cout << "usage: ./rundemo <mapnik_install_dir>\nUsually /usr/local\n";
std::cout << "Warning: ./rundemo looks for data in ../data/,\nTherefore must be run from within the demo/c++ folder.\n";
return EXIT_SUCCESS;
}
using namespace mapnik;
const std::string srs_lcc="+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 \
+datum=NAD83 +units=m +no_defs";
const std::string srs_merc="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 \
+lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs";
try {
std::cout << " running demo ... \n";
std::string mapnik_dir(argv[1]);
std::cout << " looking for 'shape.input' plugin in... " << mapnik_dir << "/input/" << "\n";
datasource_cache::instance().register_datasources(mapnik_dir + "/input/");
std::cout << " looking for DejaVuSans font in... " << mapnik_dir << "/fonts/DejaVuSans.ttf" << "\n";
freetype_engine::register_font(mapnik_dir + "/fonts/DejaVuSans.ttf");
std::cout << " looking for 'shape.input' plugin in... " << mapnik_dir << "/lib/mapnik/input/" << "\n";
datasource_cache::instance().register_datasources(mapnik_dir + "/lib/mapnik/input/");
std::cout << " looking for DejaVuSans font in... " << mapnik_dir << "/lib/mapnik/fonts/DejaVuSans.ttf" << "\n";
freetype_engine::register_font(mapnik_dir + "/lib/mapnik/fonts/DejaVuSans.ttf");
Map m(800,600);
m.set_background(parse_color("white"));
m.set_srs(srs_merc);
// create styles
// Provinces (polygon)
@ -186,6 +191,7 @@ int main ( int argc , char** argv)
layer lyr("Provinces");
lyr.set_datasource(datasource_cache::instance().create(p));
lyr.add_style("provinces");
lyr.set_srs(srs_lcc);
m.addLayer(lyr);
}
@ -196,6 +202,7 @@ int main ( int argc , char** argv)
p["file"]="../data/qcdrainage";
layer lyr("Quebec Hydrography");
lyr.set_datasource(datasource_cache::instance().create(p));
lyr.set_srs(srs_lcc);
lyr.add_style("drainage");
m.addLayer(lyr);
}
@ -204,9 +211,9 @@ int main ( int argc , char** argv)
parameters p;
p["type"]="shape";
p["file"]="../data/ontdrainage";
layer lyr("Ontario Hydrography");
lyr.set_datasource(datasource_cache::instance().create(p));
lyr.set_srs(srs_lcc);
lyr.add_style("drainage");
m.addLayer(lyr);
}
@ -217,6 +224,7 @@ int main ( int argc , char** argv)
p["type"]="shape";
p["file"]="../data/boundaries_l";
layer lyr("Provincial borders");
lyr.set_srs(srs_lcc);
lyr.set_datasource(datasource_cache::instance().create(p));
lyr.add_style("provlines");
m.addLayer(lyr);
@ -228,6 +236,7 @@ int main ( int argc , char** argv)
p["type"]="shape";
p["file"]="../data/roads";
layer lyr("Roads");
lyr.set_srs(srs_lcc);
lyr.set_datasource(datasource_cache::instance().create(p));
lyr.add_style("smallroads");
lyr.add_style("road-border");
@ -244,13 +253,13 @@ int main ( int argc , char** argv)
p["file"]="../data/popplaces";
p["encoding"] = "latin1";
layer lyr("Populated Places");
lyr.set_srs(srs_lcc);
lyr.set_datasource(datasource_cache::instance().create(p));
lyr.add_style("popplaces");
m.addLayer(lyr);
}
m.zoom_to_box(box2d<double>(1405120.04127408,-247003.813399447,
1706357.31328276,-25098.593149577));
m.zoom_to_box(box2d<double>(-8024477.28459,5445190.38849,-7381388.20071,5662941.44855));
image_32 buf(m.width(),m.height());
agg_renderer<image_32> ren(m,buf);
@ -275,9 +284,9 @@ int main ( int argc , char** argv)
/* we could also do:
save_to_cairo_file(m,"cairo-demo.png");
save_to_cairo_file(m,"cairo-demo.png");
but instead let's build up a surface for more flexibility
but instead let's build up a surface for more flexibility
*/
cairo_surface_ptr image_surface(

View file

@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
#
#
#
# This file is part of Mapnik (c++ mapping toolkit)
# Copyright (C) 2005 Jean-Francois Doyon
@ -186,7 +186,7 @@ m.layers.append(provlines_lyr)
roads34_lyr = mapnik.Layer('Roads')
roads34_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs"
# create roads datasource (we're going to re-use it later)
# create roads datasource (we're going to re-use it later)
roads34_lyr.datasource = mapnik.Shapefile(file='../data/roads')
@ -221,7 +221,7 @@ m.layers.append(roads34_lyr)
roads2_lyr = mapnik.Layer('Roads')
roads2_lyr.srs = "+proj=lcc +ellps=GRS80 +lat_0=49 +lon_0=-95 +lat+1=49 +lat_2=77 +datum=NAD83 +units=m +no_defs"
# Just get a copy from roads34_lyr
roads2_lyr.datasource = roads34_lyr.datasource
roads2_lyr.datasource = roads34_lyr.datasource
roads2_style_1 = mapnik.Style()
roads2_rule_1 = mapnik.Rule()
@ -306,7 +306,7 @@ popplaces_text_symbolizer = mapnik.TextSymbolizer(mapnik.Expression("[GEONAME]")
# We set a "halo" around the text, which looks like an outline if thin enough,
# or an outright background if large enough.
popplaces_text_symbolizer.label_placement= mapnik.label_placement.POINT_PLACEMENT
popplaces_text_symbolizer.halo_fill = mapnik.Color('white')
popplaces_text_symbolizer.halo_fill = mapnik.Color(255,255,200)
popplaces_text_symbolizer.halo_radius = 1
popplaces_text_symbolizer.avoid_edges = True
#popplaces_text_symbolizer.minimum_padding = 30
@ -322,7 +322,7 @@ m.layers.append(popplaces_lyr)
# Draw map
# Set the initial extent of the map in 'master' spherical Mercator projection
m.zoom_to_box(mapnik.Box2d(-8024477.28459,5445190.38849,-7381388.20071,5662941.44855))
m.zoom_to_box(mapnik.Box2d(-8024477.28459,5445190.38849,-7381388.20071,5662941.44855))
# Render map
im = mapnik.Image(m.width,m.height)
@ -354,7 +354,7 @@ images_.append('demo.tif')
# Render cairo examples
if HAS_PYCAIRO_MODULE and mapnik.has_pycairo():
svg_surface = cairo.SVGSurface('demo.svg', m.width,m.height)
mapnik.render(m, svg_surface)
svg_surface.finish()
@ -368,7 +368,7 @@ if HAS_PYCAIRO_MODULE and mapnik.has_pycairo():
postscript_surface = cairo.PSSurface('demo.ps', m.width,m.height)
mapnik.render(m, postscript_surface)
images_.append('demo.ps')
postscript_surface.finish()
postscript_surface.finish()
image_surface = cairo.ImageSurface(cairo.FORMAT_RGB24, m.width, m.height)
mapnik.render(m, image_surface)
@ -381,12 +381,12 @@ if HAS_PYCAIRO_MODULE and mapnik.has_pycairo():
image_surface.write_to_png('demo_cairo_argb32.png')
images_.append('demo_cairo_argb32.png')
image_surface.finish()
else:
print '\n\nPycairo not available...',
if mapnik.has_cairo():
print ' will render Cairo formats using alternative method'
mapnik.render_to_file(m,'demo.pdf')
images_.append('demo.pdf')
mapnik.render_to_file(m,'demo.ps')
@ -399,7 +399,7 @@ else:
images_.append('demo_cairo_argb.png')
print "\n\n", len(images_), "maps have been rendered in the current directory:"
for im_ in images_:
print "-", im_

View file

@ -21,6 +21,8 @@
#include "layer_info_dialog.hpp"
// mapnik
#include <mapnik/params.hpp>
#include <mapnik/params_impl.hpp>
#include <mapnik/layer.hpp>

13
deps/mapnik/build.py vendored Normal file
View file

@ -0,0 +1,13 @@
import os
from glob import glob
Import('env')
subdirs = ['sparsehash','sparsehash/internal']
if 'install' in COMMAND_LINE_TARGETS:
for subdir in subdirs:
pathdir = os.path.join(subdir,'*')
includes = glob(pathdir)
inc_target = os.path.normpath(env['INSTALL_PREFIX']+'/include/mapnik/'+subdir)
env.Alias(target='install', source=env.Install(inc_target, includes))

View file

@ -96,13 +96,13 @@
#ifndef _DENSE_HASH_MAP_H_
#define _DENSE_HASH_MAP_H_
#include <deps/sparsehash/internal/sparseconfig.h>
#include <mapnik/sparsehash/internal/sparseconfig.h>
#include <algorithm> // needed by stl_alloc
#include <functional> // for equal_to<>, select1st<>, etc
#include <memory> // for alloc
#include <utility> // for pair<>
#include <deps/sparsehash/internal/densehashtable.h> // IWYU pragma: export
#include <deps/sparsehash/internal/libc_allocator_with_realloc.h>
#include <mapnik/sparsehash/internal/densehashtable.h> // IWYU pragma: export
#include <mapnik/sparsehash/internal/libc_allocator_with_realloc.h>
#include HASH_FUN_H // for hash<>
_START_GOOGLE_NAMESPACE_

View file

@ -89,7 +89,7 @@
#ifndef _DENSEHASHTABLE_H_
#define _DENSEHASHTABLE_H_
#include <deps/sparsehash/internal/sparseconfig.h>
#include <mapnik/sparsehash/internal/sparseconfig.h>
#include <assert.h>
#include <stdio.h> // for FILE, fwrite, fread
#include <algorithm> // For swap(), eg
@ -97,9 +97,9 @@
#include <limits> // for numeric_limits
#include <memory> // For uninitialized_fill
#include <utility> // for pair
#include <deps/sparsehash/internal/hashtable-common.h>
#include <deps/sparsehash/internal/libc_allocator_with_realloc.h>
#include <deps/sparsehash/type_traits.h>
#include <mapnik/sparsehash/internal/hashtable-common.h>
#include <mapnik/sparsehash/internal/libc_allocator_with_realloc.h>
#include <mapnik/sparsehash/type_traits.h>
#include <stdexcept> // For length_error
_START_GOOGLE_NAMESPACE_

View file

@ -40,7 +40,7 @@
#ifndef UTIL_GTL_HASHTABLE_COMMON_H_
#define UTIL_GTL_HASHTABLE_COMMON_H_
#include <deps/sparsehash/internal/sparseconfig.h>
#include <mapnik/sparsehash/internal/sparseconfig.h>
#include <assert.h>
#include <stdio.h>
#include <stddef.h> // for size_t

View file

@ -32,7 +32,7 @@
#ifndef UTIL_GTL_LIBC_ALLOCATOR_WITH_REALLOC_H_
#define UTIL_GTL_LIBC_ALLOCATOR_WITH_REALLOC_H_
#include <deps/sparsehash/internal/sparseconfig.h>
#include <mapnik/sparsehash/internal/sparseconfig.h>
#include <stdlib.h> // for malloc/realloc/free
#include <stddef.h> // for ptrdiff_t
#include <new> // for placement new

View file

@ -7,10 +7,10 @@
#define GOOGLE_NAMESPACE ::google
/* the location of the header defining hash functions */
#define HASH_FUN_H <tr1/functional>
#define HASH_FUN_H <boost/functional/hash.hpp>
/* the namespace of the hash<> function */
#define HASH_NAMESPACE std::tr1
#define HASH_NAMESPACE boost
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1

View file

@ -49,7 +49,7 @@
#ifndef BASE_TEMPLATE_UTIL_H_
#define BASE_TEMPLATE_UTIL_H_
#include <deps/sparsehash/internal/sparseconfig.h>
#include <mapnik/sparsehash/internal/sparseconfig.h>
_START_GOOGLE_NAMESPACE_
// Types small_ and big_ are guaranteed such that sizeof(small_) <

View file

@ -57,10 +57,10 @@
#ifndef BASE_TYPE_TRAITS_H_
#define BASE_TYPE_TRAITS_H_
#include <deps/sparsehash/internal/sparseconfig.h>
#include <mapnik/sparsehash/internal/sparseconfig.h>
#include <utility> // For pair
#include <deps/sparsehash/template_util.h> // For true_type and false_type
#include <mapnik/sparsehash/template_util.h> // For true_type and false_type
_START_GOOGLE_NAMESPACE_

View file

@ -27,6 +27,7 @@
#include <mapnik/transform_processor.hpp>
#include <mapnik/noncopyable.hpp>
#include <mapnik/attribute.hpp>
#include <mapnik/symbolizer.hpp> // for transform_list_ptr
#include <mapnik/building_symbolizer.hpp>
#include <mapnik/line_symbolizer.hpp>
#include <mapnik/line_pattern_symbolizer.hpp>
@ -39,15 +40,17 @@
#include <mapnik/markers_symbolizer.hpp>
#include <mapnik/rule.hpp> // for rule::symbolizers
#include <mapnik/expression.hpp> // for expression_ptr, etc
#include <mapnik/expression_node_types.hpp>
#include <mapnik/expression_node.hpp>
#include <mapnik/parse_path.hpp> // for path_processor_type
#include <mapnik/path_expression.hpp> // for path_expression_ptr
#include <mapnik/text_placements/base.hpp> // for text_placements
#include <mapnik/transform_expression.hpp>
// boost
#include <boost/variant.hpp>
#include <boost/concept_check.hpp>
#include <boost/variant/static_visitor.hpp>
#include <boost/variant/apply_visitor.hpp>
// stl
#include <set>

View file

@ -26,38 +26,39 @@
#include <istream>
#include <algorithm>
#include <string>
#include <iostream>
namespace mapnik
{
/** Helper for class bool */
// Helper for class bool
class boolean {
public:
boolean(): b_(false) {}
boolean(bool b) : b_(b) {}
boolean(boolean const& b) : b_(b.b_) {}
boolean()
: b_(false) {}
boolean(bool b)
: b_(b) {}
explicit boolean(boolean const& b)
: b_(b.b_) {}
operator bool() const
{
return b_;
}
boolean & operator = (boolean const& other)
boolean & operator =(boolean const& other)
{
if (this == &other)
return *this;
b_ = other.b_;
return * this;
}
boolean & operator = (bool other)
{
b_ = other;
return * this;
return *this;
}
private:
bool b_;
};
/** Special stream input operator for boolean values */
// Special stream input operator for boolean values
template <typename charT, typename traits>
std::basic_istream<charT, traits> &
operator >> ( std::basic_istream<charT, traits> & s, boolean & b )

View file

@ -27,7 +27,6 @@
#include <mapnik/color.hpp>
// spirit2
#include <boost/config/warning_disable.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/qi_action.hpp>

View file

@ -33,6 +33,7 @@
// boost
#include <boost/shared_ptr.hpp>
#include <boost/optional.hpp>
// stl
#include <map>

View file

@ -135,19 +135,19 @@ protected:
* @endcode
*/
template <class ENUM, int THE_MAX>
template <typename ENUM, int THE_MAX>
class MAPNIK_DECL enumeration {
public:
typedef ENUM native_type;
enumeration()
: value_() {}
: value_() {}
enumeration( ENUM v )
: value_(v) {}
: value_(v) {}
enumeration( const enumeration & other )
: value_(other.value_) {}
enumeration( enumeration const& other )
: value_(other.value_) {}
/** Assignment operator for native enum values. */
void operator=(ENUM v)
@ -156,7 +156,7 @@ public:
}
/** Assignment operator. */
void operator=(const enumeration & other)
void operator=(enumeration const& other)
{
value_ = other.value_;
}
@ -172,11 +172,6 @@ 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.
* */
@ -225,7 +220,7 @@ public:
{
from_string( word );
}
catch (const illegal_enum_value &)
catch (illegal_enum_value const&)
{
is.setstate(std::ios::failbit);
}
@ -261,8 +256,8 @@ public:
if (our_strings_[i] == 0 )
{
std::cerr << "### FATAL: Not enough strings for enum "
<< our_name_ << " defined in file '" << filename
<< "' at line " << line_no;
<< our_name_ << " defined in file '" << filename
<< "' at line " << line_no;
}
}
if ( std::string("") != our_strings_[THE_MAX])

View file

@ -29,6 +29,8 @@
#include <mapnik/expression_node.hpp>
// boost
#include <boost/variant/static_visitor.hpp>
#include <boost/variant/apply_visitor.hpp>
#include <boost/regex.hpp>
#if defined(BOOST_REGEX_HAS_ICU)
#include <boost/regex/icu.hpp>

View file

@ -29,17 +29,11 @@
#include <mapnik/expression_node.hpp>
// spirit2
#include <boost/spirit/home/qi/domain.hpp> // for qi
#include <boost/spirit/home/qi/nonterminal/grammar.hpp> // for grammar
#include <boost/spirit/home/qi/nonterminal/rule.hpp> // for rule
#include <boost/spirit/home/qi/numeric/int.hpp> // for int_parser
#include <boost/spirit/home/qi/numeric/real.hpp> // for real_parser
#include <boost/spirit/home/qi/string/symbols.hpp>
#include <boost/spirit/home/support/common_terminals.hpp>
#include <boost/spirit/home/support/nonterminal/locals.hpp> // for locals
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/support_locals.hpp>
// phoenix
#include <boost/spirit/home/phoenix/function/function.hpp>
#include <boost/spirit/include/phoenix_function.hpp>
namespace mapnik
{

View file

@ -33,7 +33,6 @@
#if defined(BOOST_REGEX_HAS_ICU)
#include <boost/regex/icu.hpp>
#endif
#include <boost/variant.hpp>
#include <boost/function.hpp>
namespace mapnik

View file

@ -28,7 +28,9 @@
//#include <mapnik/attribute.hpp>
// boost
#include <boost/variant.hpp>
#include <boost/variant/variant_fwd.hpp>
namespace boost { template <typename T> class recursive_wrapper; }
namespace mapnik
{

View file

@ -26,7 +26,9 @@
// mapnik
#include <mapnik/config.hpp>
#include <mapnik/value.hpp>
// boost
#include <boost/variant/apply_visitor.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/iterator/iterator_traits.hpp>
#include <boost/iterator/iterator_facade.hpp>

View file

@ -46,6 +46,8 @@
#include <mapnik/proj_transform.hpp>
// boost
#include <boost/variant/apply_visitor.hpp>
#include <boost/variant/static_visitor.hpp>
#include <boost/foreach.hpp>
#include <boost/concept_check.hpp>
@ -244,7 +246,21 @@ void feature_style_processor<Processor>::apply_to_layer(layer const& lay, Proces
}
#endif
box2d<double> buffered_query_ext = m_.get_buffered_extent(); // buffered
box2d<double> query_ext = m_.get_current_extent(); // unbuffered
box2d<double> buffered_query_ext(query_ext); // buffered
boost::optional<int> layer_buffer_size = lay.buffer_size();
if (layer_buffer_size) // if layer overrides buffer size, use this value to compute buffered extent
{
double extra = 2.0 * m_.scale() * *layer_buffer_size;
buffered_query_ext.width(query_ext.width() + extra);
buffered_query_ext.height(query_ext.height() + extra);
}
else
{
buffered_query_ext = m_.get_buffered_extent();
}
// clip buffered extent by maximum extent, if supplied
boost::optional<box2d<double> > const& maximum_extent = m_.maximum_extent();
@ -315,7 +331,6 @@ void feature_style_processor<Processor>::apply_to_layer(layer const& lay, Proces
// if we've got this far, now prepare the unbuffered extent
// which is used as a bbox for clipping geometries
box2d<double> query_ext = m_.get_current_extent(); // unbuffered
if (maximum_extent)
{
query_ext.clip(*maximum_extent);

View file

@ -29,7 +29,11 @@
namespace mapnik {
#ifdef BIGINT
typedef agg::renderer_base<mapnik::pixfmt_gray64> grid_renderer_base_type;
#else
typedef agg::renderer_base<mapnik::pixfmt_gray32> grid_renderer_base_type;
#endif
}

View file

@ -26,9 +26,12 @@
//mapnik
#include <mapnik/image_filter_types.hpp>
// boost
#include <boost/variant/static_visitor.hpp>
#include <boost/gil/gil_all.hpp>
#include <boost/concept_check.hpp>
// agg
#include "agg_basics.h"
#include "agg_rendering_buffer.h"

View file

@ -24,12 +24,13 @@
#define MAPNIK_IMAGE_FILTER_TYPES_HPP
// boost
#include <boost/variant.hpp>
#include <boost/config/warning_disable.hpp>
#include <boost/variant/variant_fwd.hpp>
// stl
#include <iostream>
#include <vector>
#include <ostream>
#include <iterator> // for std::back_insert_iterator
namespace mapnik { namespace filter {

View file

@ -35,10 +35,10 @@ extern "C"
#include <jpeglib.h>
}
namespace mapnik {
#define BUFFER_SIZE 4096
namespace jpeg_detail {
typedef struct
{
struct jpeg_destination_mgr pub;
@ -76,6 +76,10 @@ inline void term_destination( j_compress_ptr cinfo)
dest->out->flush();
}
}
namespace mapnik {
template <typename T1, typename T2>
void save_as_jpeg(T1 & file,int quality, T2 const& image)
{
@ -89,11 +93,11 @@ void save_as_jpeg(T1 & file,int quality, T2 const& image)
jpeg_create_compress(&cinfo);
cinfo.dest = (struct jpeg_destination_mgr *)(*cinfo.mem->alloc_small)
((j_common_ptr) &cinfo, JPOOL_PERMANENT, sizeof(dest_mgr));
dest_mgr * dest = (dest_mgr*) cinfo.dest;
dest->pub.init_destination = init_destination;
dest->pub.empty_output_buffer = empty_output_buffer;
dest->pub.term_destination = term_destination;
((j_common_ptr) &cinfo, JPOOL_PERMANENT, sizeof(jpeg_detail::dest_mgr));
jpeg_detail::dest_mgr * dest = (jpeg_detail::dest_mgr*) cinfo.dest;
dest->pub.init_destination = jpeg_detail::init_destination;
dest->pub.empty_output_buffer = jpeg_detail::empty_output_buffer;
dest->pub.term_destination = jpeg_detail::term_destination;
dest->out = &file;
//jpeg_stdio_dest(&cinfo, fp);

View file

@ -29,11 +29,8 @@
#include <mapnik/feature.hpp>
// spirit::qi
#include <boost/config/warning_disable.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix.hpp>
#include <boost/variant/apply_visitor.hpp>
#include <boost/variant/variant.hpp>
namespace mapnik { namespace json {

View file

@ -31,12 +31,11 @@
#include <mapnik/value.hpp>
// spirit::qi
#include <boost/config/warning_disable.hpp>
#include <boost/cstdint.hpp>
#include <boost/variant/static_visitor.hpp>
#include <boost/variant/apply_visitor.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix.hpp>
#include <boost/variant/apply_visitor.hpp>
#include <boost/variant/variant.hpp>
#include <boost/variant/variant_fwd.hpp>
namespace mapnik { namespace json {

View file

@ -29,6 +29,7 @@
#include <boost/scoped_ptr.hpp>
#include <string>
#include <iterator>
namespace mapnik { namespace json {

View file

@ -28,6 +28,7 @@
#include <mapnik/geometry.hpp>
#include <mapnik/util/path_iterator.hpp>
#include <mapnik/util/container_adapter.hpp>
#include <mapnik/vertex.hpp> // for CommandType::SEG_MOVETO
// boost
#include <boost/tuple/tuple.hpp>
@ -36,7 +37,7 @@
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/phoenix_fusion.hpp>
#include <boost/spirit/include/phoenix_function.hpp>
#include <boost/spirit/home/phoenix/statement/if.hpp>
#include <boost/spirit/include/phoenix_statement.hpp>
#include <boost/fusion/include/boost_tuple.hpp>
#include <boost/math/special_functions/trunc.hpp> // trunc to avoid needing C++11
@ -158,7 +159,6 @@ struct geometry_generator_grammar :
using boost::spirit::karma::_a;
using boost::spirit::karma::_r1;
using boost::spirit::karma::eps;
using boost::spirit::karma::string;
coordinates = point | linestring | polygon
;
@ -186,7 +186,7 @@ struct geometry_generator_grammar :
;
polygon_coord %= ( &uint_(mapnik::SEG_MOVETO) << eps[_r1 += 1]
<< string[ if_ (_r1 > 1) [_1 = "],["]
<< karma::string[ if_ (_r1 > 1) [_1 = "],["]
.else_[_1 = '[' ]] | &uint_ << lit(','))
<< lit('[') << coord_type
<< lit(',')
@ -235,7 +235,6 @@ struct multi_geometry_generator_grammar :
using boost::spirit::karma::_1;
using boost::spirit::karma::_a;
using boost::spirit::karma::_r1;
using boost::spirit::karma::string;
geometry_types.add
(mapnik::Point,"\"Point\"")
@ -259,9 +258,9 @@ struct multi_geometry_generator_grammar :
geometry = (lit("{\"type\":")
<< geometry_types[_1 = phoenix::at_c<0>(_a)][_a = _multi_type(_val)]
<< lit(",\"coordinates\":")
<< string[ if_ (phoenix::at_c<0>(_a) > 3) [_1 = '[']]
<< karma::string[ if_ (phoenix::at_c<0>(_a) > 3) [_1 = '[']]
<< coordinates
<< string[ if_ (phoenix::at_c<0>(_a) > 3) [_1 = ']']]
<< karma::string[ if_ (phoenix::at_c<0>(_a) > 3) [_1 = ']']]
<< lit('}')) | lit("null")
;

View file

@ -24,15 +24,12 @@
#define MAPNIK_GEOMETRY_GRAMMAR_HPP
// mapnik
#include <mapnik/geometry.hpp>
#include <mapnik/feature.hpp>
#include <mapnik/geometry.hpp> // for geometry_type
#include <mapnik/vertex.hpp> // for CommandType
// spirit::qi
#include <boost/config/warning_disable.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix.hpp>
#include <boost/variant/apply_visitor.hpp>
#include <boost/variant/variant.hpp>
namespace mapnik { namespace json {

View file

@ -194,7 +194,8 @@ public:
boost::optional<box2d<double> > const& maximum_extent() const;
void reset_maximum_extent();
void set_buffer_size(int size);
int buffer_size() const;
boost::optional<int> const& buffer_size() const;
void reset_buffer_size();
~layer();
private:
void swap(layer& other);
@ -211,7 +212,7 @@ private:
std::string group_by_;
std::vector<std::string> styles_;
datasource_ptr ds_;
int buffer_size_;
boost::optional<int> buffer_size_;
boost::optional<box2d<double> > maximum_extent_;
};
}

View file

@ -51,6 +51,7 @@
// boost
#include <boost/optional.hpp>
#include <boost/variant/apply_visitor.hpp>
namespace mapnik {

View file

@ -24,8 +24,6 @@
#define MAPNIK_MARKERS_PLACEMENT_HPP
// mapnik
#include <mapnik/markers_placement.hpp>
#include <mapnik/geometry.hpp>
#include <mapnik/ctrans.hpp>
#include <mapnik/debug.hpp>
#include <mapnik/label_collision_detector.hpp>
@ -35,11 +33,7 @@
// agg
#include "agg_basics.h"
#include "agg_conv_clip_polygon.h"
#include "agg_conv_clip_polyline.h"
#include "agg_trans_affine.h"
#include "agg_conv_transform.h"
#include "agg_conv_smooth_poly1.h"
// stl
#include <cmath>
@ -74,12 +68,12 @@ public:
allow_overlap_(allow_overlap),
marker_width_((size_ * tr_).width()),
done_(false),
last_x(.0),
last_y(.0),
next_x(.0),
next_y(.0),
error_(.0),
spacing_left_(.0),
last_x(0.0),
last_y(0.0),
next_x(0.0),
next_y(0.0),
error_(0.0),
spacing_left_(0.0),
marker_nr_(0)
{
if (spacing >= 0)
@ -104,7 +98,7 @@ public:
done_ = agg::is_stop(locator_.vertex(&next_x, &next_y));
last_x = next_x;
last_y = next_y; // Force request of new segment
error_ = 0;
error_ = 0.0;
marker_nr_ = 0;
}
@ -133,9 +127,10 @@ public:
error = 0: Perfect position.
error < 0: Marker too near to the beginning of the path.
*/
if (marker_nr_++ == 0)
if (marker_nr_ == 0)
{
//First marker
marker_nr_++;
spacing_left_ = spacing_ / 2;
}
else
@ -143,7 +138,8 @@ public:
spacing_left_ = spacing_;
}
spacing_left_ -= error_;
error_ = 0;
error_ = 0.0;
double max_err_allowed = max_error_ * spacing_;
//Loop exits when a position is found or when no more segments are available
while (true)
{
@ -153,15 +149,15 @@ public:
set_spacing_left(marker_width_/2); //Only moves forward
}
//Error for this marker is too large. Skip to the next position.
if (abs(error_) > max_error_ * spacing_)
if (std::fabs(error_) > max_err_allowed)
{
if (error_ > spacing_)
{
error_ = 0; //Avoid moving backwards
MAPNIK_LOG_WARN(markers_placement) << "Extremely large error in markers_placement. Please file a bug report.";
MAPNIK_LOG_WARN(markers_placement) << "Extremely large error (" << error_ << ") in markers_placement. Please file a bug report.";
error_ = 0.0; //Avoid moving backwards
}
spacing_left_ += spacing_ - error_;
error_ = 0;
error_ = 0.0;
}
double dx = next_x - last_x;
double dy = next_y - last_y;
@ -214,7 +210,7 @@ public:
}
continue; //Force checking of max_error constraint
}
angle = atan2(dy, dx);
angle = std::atan2(dy, dx);
x = last_x + dx * (spacing_left_ / segment_length);
y = last_y + dy * (spacing_left_ / segment_length);
box2d<double> box = perform_transform(angle, x, y);

View file

@ -38,7 +38,6 @@ namespace mapnik
{
const double pi = boost::math::constants::pi<double>();
const double half_pi = pi/2.0;
template <typename Geometry>
struct MAPNIK_DECL offset_converter

View file

@ -31,7 +31,7 @@
#define USE_DENSE_HASH_MAP
#ifdef USE_DENSE_HASH_MAP
#include "deps/sparsehash/dense_hash_map"
#include <mapnik/sparsehash/dense_hash_map>
typedef google::dense_hash_map<unsigned int, unsigned char> rgba_hash_table;
#else
#warning compiling without dense_hash_map

View file

@ -23,12 +23,13 @@
#ifndef MAPNIK_PARAMS_HPP
#define MAPNIK_PARAMS_HPP
// mapnik
#include <mapnik/config.hpp>
#include <mapnik/value_types.hpp>
// boost
#include <boost/variant/variant.hpp>
#include <boost/optional.hpp>
#include <boost/lexical_cast.hpp>
// mapnik
#include <mapnik/value_types.hpp>
// stl
#include <string>
@ -36,45 +37,58 @@
namespace mapnik
{
// fwd declare
class boolean;
typedef boost::variant<value_null,value_integer,value_double,std::string> value_holder;
typedef std::pair<std::string, value_holder> parameter;
typedef std::map<std::string, value_holder> param_map;
// TODO - rewrite to avoid usage of lexical_cast
template <typename T>
struct value_extractor_visitor : public boost::static_visitor<>
{
value_extractor_visitor(boost::optional<T> & var)
:var_(var) {}
void operator () (T val) const
{
var_ = val;
}
template <typename T1>
void operator () (T1 val) const
{
try
{
var_ = boost::lexical_cast<T>(val);
}
catch (boost::bad_lexical_cast & ) {}
}
boost::optional<T> & var_;
};
class parameters : public param_map
class MAPNIK_DECL parameters : public param_map
{
public:
parameters();
parameters() {}
template <typename T>
boost::optional<T> get(std::string const& key) const;
template <typename T>
boost::optional<T> get(std::string const& key, T const& default_opt_value) const;
};
#ifdef _MSC_VER
template MAPNIK_DECL
boost::optional<std::string> parameters::get(std::string const& key) const;
template MAPNIK_DECL
boost::optional<std::string> parameters::get(std::string const& key,
std::string const& default_opt_value) const;
template MAPNIK_DECL
boost::optional<value_double> parameters::get(std::string const& key) const;
template MAPNIK_DECL
boost::optional<value_double> parameters::get(std::string const& key,
value_double const& default_opt_value) const;
template MAPNIK_DECL
boost::optional<int> parameters::get(std::string const& key) const;
template MAPNIK_DECL
boost::optional<int> parameters::get(std::string const& key,
int const& default_opt_value) const;
#ifdef BIGINT
template MAPNIK_DECL
boost::optional<value_integer> parameters::get(std::string const& key) const;
template MAPNIK_DECL
boost::optional<value_integer> parameters::get(std::string const& key,
value_integer const& default_opt_value) const;
#endif
template MAPNIK_DECL
boost::optional<mapnik::boolean> parameters::get(std::string const& key) const;
template MAPNIK_DECL
boost::optional<mapnik::boolean> parameters::get(std::string const& key,
mapnik::boolean const& default_opt_value) const;
#endif
}
#endif // MAPNIK_PARAMS_HPP

View file

@ -0,0 +1,203 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2013 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
*
*****************************************************************************/
// NOTE: This is an implementation header file and is only meant to be included
// from implementation files. It therefore doesn't have an include guard.
// mapnik
#include <mapnik/params.hpp>
#include <mapnik/value_types.hpp>
#include <mapnik/util/conversions.hpp>
// boost
#include <boost/variant/static_visitor.hpp>
#include <boost/variant/apply_visitor.hpp> // keep gcc happy
#include <boost/variant/variant.hpp>
#include <boost/optional.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/format.hpp>
// stl
#include <string>
namespace mapnik { namespace detail {
template <typename T>
struct extract_value
{
static inline boost::optional<T> do_extract_from_string(std::string const& source)
{
std::string err_msg = (boost::format("No conversion from std::string to %s") % typeid(T).name()).str();
throw std::runtime_error(err_msg);
}
};
template <>
struct extract_value<mapnik::boolean>
{
static inline boost::optional<mapnik::boolean> do_extract_from_string(std::string const& source)
{
bool result;
if (mapnik::util::string2bool(source, result))
return boost::optional<mapnik::boolean>(result);
return boost::optional<mapnik::boolean>();
}
};
template <>
struct extract_value<int>
{
static inline boost::optional<int> do_extract_from_string(std::string const& source)
{
mapnik::value_integer result;
if (mapnik::util::string2int(source, result))
return boost::optional<int>(result);
return boost::optional<int>();
}
};
#ifdef BIGINT
template <>
struct extract_value<mapnik::value_integer>
{
static inline boost::optional<mapnik::value_integer> do_extract_from_string(std::string const& source)
{
mapnik::value_integer result;
if (mapnik::util::string2int(source, result))
return boost::optional<mapnik::value_integer>(result);
return boost::optional<mapnik::value_integer>();
}
};
#endif
template <>
struct extract_value<mapnik::value_double>
{
static inline boost::optional<mapnik::value_double> do_extract_from_string(std::string const& source)
{
mapnik::value_double result;
if (mapnik::util::string2double(source, result))
return boost::optional<double>(result);
return boost::optional<double>();
}
};
template <>
struct extract_value<mapnik::value_null>
{
static inline boost::optional<mapnik::value_null> do_extract_from_string(std::string const& source)
{
return boost::optional<mapnik::value_null>(); // FIXME
}
};
template <>
struct extract_value<std::string>
{
static inline boost::optional<std::string> do_extract_from_string(std::string const& source)
{
return boost::optional<std::string>(source);
}
};
template <typename T>
boost::optional<T> param_cast(std::string const& source)
{
return extract_value<T>::do_extract_from_string(source);
}
} // end namespace detail
template <typename T>
struct value_extractor_visitor : public boost::static_visitor<>
{
value_extractor_visitor(boost::optional<T> & var)
:var_(var) {}
void operator() (std::string const& val) const
{
var_ = detail::param_cast<T>(val);
}
template <typename T1>
void operator () (T1 val) const
{
// TODO
try
{
var_ = boost::lexical_cast<T>(val);
}
catch (boost::bad_lexical_cast & ) {}
//std::string err_msg = (boost::format("No conversion from %s to %s")
// % typeid(T1).name()
// % typeid(T).name()).str();
//throw std::runtime_error(err_msg);
}
boost::optional<T> & var_;
};
namespace params_detail {
template <typename T>
struct converter
{
typedef T value_type;
typedef boost::optional<value_type> return_type;
static return_type extract(parameters const& params,
std::string const& name,
boost::optional<T> const& default_opt_value)
{
boost::optional<T> result(default_opt_value);
parameters::const_iterator itr = params.find(name);
if (itr != params.end())
{
boost::apply_visitor(value_extractor_visitor<T>(result),itr->second);
}
return result;
}
};
} // end namespace params_detail
template <typename T>
boost::optional<T> parameters::get(std::string const& key) const
{
return params_detail::converter<T>::extract(*this,key, boost::none);
}
template <typename T>
boost::optional<T> parameters::get(std::string const& key, T const& default_opt_value) const
{
return params_detail::converter<T>::extract(*this,key,boost::optional<T>(default_opt_value));
}
}

View file

@ -25,14 +25,14 @@
// mapnik
#include <mapnik/config.hpp>
#include <mapnik/transform_expression.hpp>
#include <mapnik/symbolizer.hpp> // for transform_list_ptr
namespace mapnik {
template <typename Iterator> struct transform_expression_grammar;
typedef transform_expression_grammar<std::string::const_iterator>
transform_expression_grammar__string;
transform_expression_grammar_string;
MAPNIK_DECL transform_list_ptr parse_transform(std::string const& str);
@ -41,7 +41,7 @@ MAPNIK_DECL transform_list_ptr parse_transform(std::string const& str,
MAPNIK_DECL bool parse_transform(transform_list& list,
std::string const& str,
transform_expression_grammar__string const& g);
transform_expression_grammar_string const& g);
} // namespace mapnik

View file

@ -24,7 +24,7 @@
#define MAPNIK_PATH_EXPRESSION_HPP
// boost
#include <boost/variant.hpp>
#include <boost/variant/variant_fwd.hpp>
#include <boost/shared_ptr.hpp>
// stl

View file

@ -41,11 +41,12 @@
#include <mapnik/config.hpp> // MAPNIK_DECL
// boost
#include <boost/variant.hpp>
#include <boost/variant/variant_fwd.hpp>
// stl
#include <string>
#include <vector>
#include <limits>
namespace mapnik
{

View file

@ -24,6 +24,7 @@
#define MAPNIK_STROKE_HPP
// mapnik
#include <mapnik/config.hpp>
#include <mapnik/color.hpp>
#include <mapnik/gamma_method.hpp>
#include <mapnik/enumeration.hpp>

View file

@ -24,18 +24,22 @@
#define SVG_OUTPUT_GRAMMARS_HPP
// mapnik
#include <mapnik/vertex.hpp>
#include <mapnik/ctrans.hpp>
#include <mapnik/geometry.hpp>
#include <mapnik/svg/output/svg_path_iterator.hpp>
#include <mapnik/svg/output/svg_output_attributes.hpp>
#include <mapnik/stroke.hpp>
// fwd declare
namespace mapnik { namespace svg {
struct path_output_attributes;
struct rect_output_attributes;
struct root_output_attributes;
} }
// boost
#include <boost/spirit/include/karma.hpp>
#include <boost/spirit/include/karma_omit.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/repository/include/karma_confix.hpp>
#include <boost/spirit/home/phoenix/bind/bind_member_function.hpp>
#include <boost/spirit/include/phoenix_function.hpp>
#include <boost/spirit/include/phoenix_bind.hpp>
#include <boost/fusion/include/std_pair.hpp>
#include <boost/fusion/include/struct.hpp>
#include <boost/fusion/include/boost_tuple.hpp>

View file

@ -38,6 +38,7 @@
#include <mapnik/pixel_position.hpp>
// boost
#include <boost/variant/static_visitor.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/shared_ptr.hpp>

View file

@ -35,7 +35,6 @@
namespace mapnik { namespace svg {
using namespace boost::spirit;
using namespace boost::fusion;
using namespace boost::phoenix;
template <typename Iterator, typename SkipType, typename PathType>
@ -135,7 +134,7 @@ namespace mapnik { namespace svg {
qi::rule<Iterator,qi::locals<bool>,SkipType> A; // A,a
qi::rule<Iterator,SkipType> Z; // Z,z
qi::rule<Iterator,vector2<double,double>(),SkipType> coord;
qi::rule<Iterator,boost::fusion::vector2<double,double>(),SkipType> coord;
// commands
function<move_to<PathType> > move_to_;

View file

@ -34,7 +34,6 @@
namespace mapnik { namespace svg {
using namespace boost::spirit;
using namespace boost::fusion;
using namespace boost::phoenix;
template <typename Iterator, typename SkipType, typename PathType>
@ -58,7 +57,7 @@ namespace mapnik { namespace svg {
// rules
qi::rule<Iterator,SkipType> start;
qi::rule<Iterator,vector2<double,double>(),SkipType> coord;
qi::rule<Iterator,boost::fusion::vector2<double,double>(),SkipType> coord;
// commands
function<move_to<PathType> > move_to_;

View file

@ -34,7 +34,7 @@
#include <boost/spirit/include/phoenix_function.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/home/phoenix/object/construct.hpp>
#include <boost/spirit/include/phoenix_object.hpp>
namespace mapnik { namespace svg {

View file

@ -27,18 +27,23 @@
#include <mapnik/config.hpp>
#include <mapnik/path_expression.hpp>
#include <mapnik/image_compositing.hpp>
#include <mapnik/transform_expression.hpp>
#include <mapnik/simplify.hpp>
// boost
#include <boost/array.hpp>
#include <boost/optional.hpp>
namespace agg { struct trans_affine; }
namespace mapnik
{
// fwd declares
// TODO - move these transform declares to own header
namespace detail { struct transform_node; }
typedef std::vector<detail::transform_node> transform_list;
typedef boost::shared_ptr<transform_list> transform_list_ptr;
typedef transform_list_ptr transform_type;
class Map;
class feature_impl;

View file

@ -29,7 +29,7 @@
// boost
#include <boost/optional.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/variant.hpp>
#include <boost/variant/variant.hpp>
// fusion
#include <boost/fusion/include/at.hpp>

View file

@ -28,19 +28,22 @@
#ifdef MAPNIK_LOG
#include <mapnik/debug.hpp>
#endif
#include <mapnik/feature.hpp>
#include <mapnik/value.hpp>
#include <mapnik/transform_expression.hpp>
#include <mapnik/expression_evaluator.hpp>
// boost
#include <boost/foreach.hpp>
#include <boost/variant/static_visitor.hpp>
#include <boost/variant/apply_visitor.hpp>
// agg
#include <agg_trans_affine.h>
namespace mapnik {
class feature_impl;
template <typename Container> struct expression_attributes;
template <typename T>

View file

@ -28,7 +28,7 @@
#include <mapnik/util/path_iterator.hpp>
// boost
#include <boost/spirit/home/support/container.hpp>
#include <boost/spirit/include/support_container.hpp>
namespace boost { namespace spirit { namespace traits {

View file

@ -32,6 +32,9 @@
namespace mapnik { namespace util {
MAPNIK_DECL bool string2bool(const char * value, bool & result);
MAPNIK_DECL bool string2bool(std::string const& value, bool & result);
MAPNIK_DECL bool string2int(const char * value, int & result);
MAPNIK_DECL bool string2int(std::string const& value, int & result);
@ -47,10 +50,12 @@ MAPNIK_DECL bool string2float(std::string const& value, float & result);
MAPNIK_DECL bool string2float(const char * value, float & result);
MAPNIK_DECL bool to_string(std::string & str, int value);
#ifdef BIGINT
MAPNIK_DECL bool to_string(std::string & str, mapnik::value_integer value);
#endif
MAPNIK_DECL bool to_string(std::string & str, unsigned value);
MAPNIK_DECL bool to_string(std::string & str, bool value);
MAPNIK_DECL bool to_string(std::string & str, double value);
MAPNIK_DECL bool to_string(std::string & str, mapnik::value_integer value);
}}

View file

@ -37,7 +37,7 @@
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/phoenix_fusion.hpp>
#include <boost/spirit/include/phoenix_function.hpp>
#include <boost/spirit/home/phoenix/statement/if.hpp>
#include <boost/spirit/include/phoenix_statement.hpp>
#include <boost/fusion/include/boost_tuple.hpp>
#include <boost/type_traits/remove_pointer.hpp>

View file

@ -25,6 +25,8 @@
// mapnik
#include <mapnik/global.hpp>
#include <mapnik/geometry.hpp>
#include <mapnik/vertex.hpp> // for CommandType::SEG_MOVETO
// boost
#include <boost/tuple/tuple.hpp>
@ -33,7 +35,7 @@
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/phoenix_fusion.hpp>
#include <boost/spirit/include/phoenix_function.hpp>
#include <boost/spirit/home/phoenix/statement/if.hpp>
#include <boost/spirit/include/phoenix_statement.hpp>
#include <boost/fusion/include/boost_tuple.hpp>
#include <boost/type_traits/remove_pointer.hpp>

View file

@ -30,7 +30,10 @@
#include <mapnik/util/conversions.hpp>
// boost
#include <boost/variant.hpp>
#include <boost/variant/recursive_wrapper.hpp>
#include <boost/variant/static_visitor.hpp>
#include <boost/variant/apply_visitor.hpp>
#include <boost/variant/variant.hpp>
#include <boost/scoped_array.hpp>
#include <boost/concept_check.hpp>

View file

@ -32,7 +32,7 @@
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/phoenix_fusion.hpp>
#include <boost/spirit/home/phoenix/object/new.hpp>
#include <boost/spirit/include/phoenix_object.hpp>
#include <boost/spirit/include/phoenix_stl.hpp>
// mapnik
#include <mapnik/geometry.hpp>

View file

@ -0,0 +1,194 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2013 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_XML_ATTRIBUTE_CAST_HPP
#define MAPNIK_XML_ATTRIBUTE_CAST_HPP
//mapnik
#include <mapnik/debug.hpp>
#include <mapnik/xml_tree.hpp>
#include <mapnik/enumeration.hpp>
#include <mapnik/boolean.hpp>
#include <mapnik/color_factory.hpp>
#include <mapnik/expression.hpp>
// boost
#include <boost/optional.hpp>
#include <boost/format.hpp>
// stl
#include <string>
namespace mapnik { namespace detail {
template <typename T>
struct do_xml_attribute_cast
{
static inline boost::optional<T> xml_attribute_cast_impl(xml_tree const& tree, std::string const& source)
{
std::string err_msg = (boost::format("No conversion from std::string to %s") % typeid(T).name()).str();
throw std::runtime_error(err_msg);
}
};
// specialization for mapnik::boolean
template <>
struct do_xml_attribute_cast<mapnik::boolean>
{
static inline boost::optional<mapnik::boolean> xml_attribute_cast_impl(xml_tree const& tree, std::string const& source)
{
bool result;
if (mapnik::util::string2bool(source, result))
return boost::optional<mapnik::boolean>(result);
return boost::optional<mapnik::boolean>();
}
};
// specialization for int
template <>
struct do_xml_attribute_cast<int>
{
static inline boost::optional<int> xml_attribute_cast_impl(xml_tree const& tree, std::string const& source)
{
int result;
if (mapnik::util::string2int(source, result))
return boost::optional<int>(result);
return boost::optional<int>();
}
};
#ifdef BIGINT
// specialization for long long
template <>
struct do_xml_attribute_cast<long long>
{
static inline boost::optional<long long> xml_attribute_cast_impl(xml_tree const& tree, std::string const& source)
{
int result;
if (mapnik::util::string2int(source, result))
return boost::optional<long long>(result);
return boost::optional<long long>();
}
};
#endif
// specialization for unsigned
template <>
struct do_xml_attribute_cast<unsigned>
{
static inline boost::optional<unsigned> xml_attribute_cast_impl(xml_tree const& tree, std::string const& source)
{
int result;
if (mapnik::util::string2int(source, result))
return boost::optional<unsigned>(result);
return boost::optional<unsigned>();
}
};
// specialization for float
template <>
struct do_xml_attribute_cast<float>
{
static inline boost::optional<float> xml_attribute_cast_impl(xml_tree const& tree, std::string const& source)
{
float result;
if (mapnik::util::string2float(source, result))
return boost::optional<float>(result);
return boost::optional<float>();
}
};
// specialization for double
template <>
struct do_xml_attribute_cast<double>
{
static inline boost::optional<double> xml_attribute_cast_impl(xml_tree const& tree, std::string const& source)
{
double result;
if (mapnik::util::string2double(source, result))
return boost::optional<double>(result);
return boost::optional<double>();
}
};
// specialization for mapnik::enumeration<T,int>
template <typename T, int MAX>
struct do_xml_attribute_cast<mapnik::enumeration<T,MAX> >
{
static inline boost::optional<mapnik::enumeration<T,MAX> > xml_attribute_cast_impl(xml_tree const& tree, std::string const& source)
{
typedef typename boost::optional<mapnik::enumeration<T,MAX> > result_type;
try
{
mapnik::enumeration<T,MAX> e;
e.from_string(source);
return result_type(e);
}
catch (illegal_enum_value const& ex)
{
MAPNIK_LOG_ERROR(do_xml_attribute_cast) << ex.what();
return result_type();
}
}
};
// specialization for mapnik::color
template <>
struct do_xml_attribute_cast<mapnik::color>
{
static inline boost::optional<mapnik::color> xml_attribute_cast_impl(xml_tree const& tree, std::string const& source)
{
return parse_color(source, tree.color_grammar);
}
};
// specialization for std::string
template <>
struct do_xml_attribute_cast<std::string>
{
static inline boost::optional<std::string> xml_attribute_cast_impl(xml_tree const& tree, std::string const& source)
{
return boost::optional<std::string>(source);
}
};
// specialization for mapnik::expression_ptr
template <>
struct do_xml_attribute_cast<mapnik::expression_ptr>
{
static inline boost::optional<mapnik::expression_ptr> xml_attribute_cast_impl(xml_tree const& tree, std::string const& source)
{
return parse_expression(source, tree.expr_grammar);
}
};
} // end namespace detail
template <typename T>
boost::optional<T> xml_attribute_cast(xml_tree const& tree, std::string const& source)
{
return detail::do_xml_attribute_cast<T>::xml_attribute_cast_impl(tree, source);
}
} // end namespace mapnik
#endif // MAPNIK_XML_ATTRIBUTE_CAST_HPP

View file

@ -32,7 +32,6 @@
// boost
#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/tokenizer.hpp>
#include <boost/make_shared.hpp>
@ -43,9 +42,6 @@
#include <sstream>
#include <iomanip>
using boost::lexical_cast;
using boost::bad_lexical_cast;
using mapnik::datasource;
using mapnik::parameters;
using mapnik::query;
@ -379,19 +375,12 @@ box2d<double> occi_datasource::envelope() const
ResultSet* rs = conn.execute_query(s.str());
if (rs && rs->next())
{
try
{
lox = lexical_cast<double>(rs->getDouble(1));
loy = lexical_cast<double>(rs->getDouble(2));
hix = lexical_cast<double>(rs->getDouble(3));
hiy = lexical_cast<double>(rs->getDouble(4));
extent_.init(lox, loy, hix, hiy);
extent_initialized_ = true;
}
catch (bad_lexical_cast& ex)
{
MAPNIK_LOG_WARN(occi) << "OCCI Plugin: " << ex.what();
}
lox = rs->getDouble(1);
loy = rs->getDouble(2);
hix = rs->getDouble(3);
hiy = rs->getDouble(4);
extent_.init(lox, loy, hix, hiy);
extent_initialized_ = true;
}
}
catch (SQLException& ex)
@ -427,30 +416,15 @@ box2d<double> occi_datasource::envelope() const
{
if (rs->next())
{
try
{
lox = lexical_cast<double>(rs->getDouble(1));
hix = lexical_cast<double>(rs->getDouble(2));
}
catch (bad_lexical_cast& ex)
{
MAPNIK_LOG_WARN(occi) << "OCCI Plugin: " << ex.what();
}
lox = rs->getDouble(1);
hix = rs->getDouble(2);
}
if (rs->next())
{
try
{
loy = lexical_cast<double>(rs->getDouble(1));
hiy = lexical_cast<double>(rs->getDouble(2));
}
catch (bad_lexical_cast& ex)
{
MAPNIK_LOG_WARN(occi) << "OCCI Plugin: " << ex.what();
}
loy = rs->getDouble(1);
hiy = rs->getDouble(2);
}
extent_.init(lox, loy, hix, hiy);
extent_initialized_ = true;
}

View file

@ -1,97 +0,0 @@
#ifndef GOOGLEPROJECTION_H
#define GOOGLEPROJECTION_H
#include <vector>
using std::vector;
#include <cmath>
#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
struct ScreenPos
{
int x,y;
ScreenPos() { x=y=0; }
ScreenPos(int x,int y) { this->x=x; this->y=y; }
};
struct EarthPoint
{
double x,y;
EarthPoint() { x=y=0.0; }
EarthPoint(double x,double y) { this->x=x; this->y=y; }
};
class GoogleProjection
{
private:
vector<double> Bc,Cc,zc,Ac;
int levels;
double minmax (double a,double b, double c)
{
a = max(a,b);
a = min(a,c);
return a;
}
public:
GoogleProjection(int levels=18)
{
this->levels=levels;
double c = 256;
double e;
for (int d=0; d<levels; d++)
{
e = c/2;
Bc.push_back(c/360.0);
Cc.push_back(c/(2 * M_PI));
zc.push_back(e);
Ac.push_back(c);
c *= 2;
}
}
ScreenPos fromLLToPixel(double lon,double lat,int zoom)
{
double d = zc[zoom];
double e = round(d + lon * Bc[zoom]);
double f = minmax(sin((M_PI/180.0) * lat),-0.9999,0.9999);
double g = round(d + 0.5*log((1+f)/(1-f))*-Cc[zoom]);
return ScreenPos(e,g);
}
EarthPoint fromPixelToLL(int x,int y,int zoom)
{
double e = zc[zoom];
double f = (x - e)/Bc[zoom];
double g = (y - e)/-Cc[zoom];
double h = (180.0/M_PI) * ( 2 * atan(exp(g)) - 0.5 * M_PI);
return EarthPoint(f,h);
}
// convert to the zoom independent Google system; TBH I don't really
// understand what it represents....
static EarthPoint fromLLToGoog(double lon,double lat)
{
double a = log(tan((90+lat)*M_PI / 360))/(M_PI / 180);
double custLat = a * 20037508.34 / 180;
double custLon=lon;
custLon = custLon * 20037508.34 / 180;
return EarthPoint(custLon,custLat);
}
// other way round
static EarthPoint fromGoogToLL(double x,double y)
{
double lat_deg,lon_deg;
lat_deg = (y / 20037508.34) * 180;
lon_deg = (x / 20037508.34) * 180;
lat_deg = 180/M_PI *
(2 * atan(exp(lat_deg * M_PI / 180)) - M_PI / 2);
return EarthPoint(lon_deg,lat_deg);
}
};
#endif // GOOGLEPROJECTION_H

View file

@ -1,398 +0,0 @@
#include "MapSource.h"
#include <gd.h>
void MapSource::process_cmd_line_args(int argc,char *argv[])
{
std::string bbox="";
argc--;
argv++;
width=800;
height=600;
while(argc>0)
{
if(argv[0][0]=='-' && strlen(argv[0])>1)
{
switch(argv[0][1])
{
case 's': setSource(argv[1]);
argv+=2;
argc-=2;
break;
case 'w': width=atoi(argv[1]);
argv+=2;
argc-=2;
break;
case 'h': height=atoi(argv[1]);
argv+=2;
argc-=2;
break;
case 'x': xmlfile=argv[1];
argv+=2;
argc-=2;
break;
case 'i': osmfile=argv[1];
argv+=2;
argc-=2;
break;
case 'b': bbox=argv[1];
argv+=2;
argc-=2;
break;
case 'z': zoom_start=atoi(argv[1]);
argv+=2;
argc-=2;
break;
case 'Z': zoom_end=atoi(argv[1]);
argv+=2;
argc-=2;
break;
case 't': tiled=true;
argv+=1;
argc-=1;
break;
case 'm': multirqst=true;
argv+=1;
argc-=1;
break;
case 'u': url=argv[1];
argv+=2;
argc-=2;
break;
case 'o': outfile=argv[1];
argv+=2;
argc-=2;
break;
case 'r': srtm=true;
argv++;
argc--;
break;
}
}
else
{
argv++;
argc--;
}
}
if(bbox!="")
{
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
boost::char_separator<char> comma(",");
tokenizer t (bbox,comma);
int count=0;
for(tokenizer::iterator i=t.begin(); i!=t.end(); i++)
{
if(count==0)
w=atof(i->c_str());
else if (count==1)
s=atof(i->c_str());
else if (count==2)
e=atof(i->c_str());
else if (count==3)
n=atof(i->c_str());
count++;
}
}
if(zoom_end == -1)
zoom_end = zoom_start;
if(tiled)
width=height=256+(32*2);
}
void MapSource::generateMaps()
{
GoogleProjection proj;
if(tiled)
{
ScreenPos topLeft = (proj.fromLLToPixel(w,n,zoom_start)) ,
bottomRight = (proj.fromLLToPixel(e,s,zoom_start)) ;
topLeft.x /= 256;
topLeft.y /= 256;
bottomRight.x /= 256;
bottomRight.y /= 256;
int x_fetch_freq, y_fetch_freq, x_fetches, y_fetches;
if(multirqst)
{
// Gives a value approx equal to 0.1 lat/lon in southern UK
x_fetch_freq = (int)(pow(2.0,zoom_start-11));
y_fetch_freq = (int)(pow(2.0,zoom_start-11));
x_fetches = ((bottomRight.x-topLeft.x) / x_fetch_freq)+1,
y_fetches = ((bottomRight.y-topLeft.y) / y_fetch_freq)+1;
}
else
{
x_fetch_freq = bottomRight.x - topLeft.x;
y_fetch_freq = bottomRight.y - topLeft.y;
x_fetches = 1;
y_fetches = 1;
}
fprintf(stderr,"topLeft: %d %d\n",topLeft.x,topLeft.y);
fprintf(stderr,"bottomRight: %d %d\n",bottomRight.x,bottomRight.y);
fprintf(stderr,"xfetches yfetches: %d %d\n",x_fetches, y_fetches);
for(int xfetch=0; xfetch<x_fetches; xfetch++)
{
for (int yfetch=0; yfetch<y_fetches; yfetch++)
{
cerr<<"XFETCH="<<xfetch<<" YFETCH="<<yfetch<<endl;
EarthPoint bottomL_LL =
proj.fromPixelToLL( (topLeft.x+xfetch*x_fetch_freq)*256,
((topLeft.y+yfetch*y_fetch_freq)
+y_fetch_freq)*256, zoom_start),
topR_LL =
proj.fromPixelToLL( (
(topLeft.x+xfetch*x_fetch_freq)+x_fetch_freq)*256,
(topLeft.y+yfetch*y_fetch_freq)
*256, zoom_start),
bottomR_LL =
proj.fromPixelToLL( ((topLeft.x+xfetch*x_fetch_freq)+
x_fetch_freq)*256,
((topLeft.y+yfetch*y_fetch_freq)
+y_fetch_freq)*256, zoom_start),
topL_LL =
proj.fromPixelToLL(
(topLeft.x+xfetch*x_fetch_freq)*256,
(topLeft.y+yfetch*y_fetch_freq)
*256, zoom_start);
double w1 = min(bottomL_LL.x-0.01,topL_LL.x-0.01),
s1 = min(bottomL_LL.y-0.01,bottomR_LL.y-0.01),
e1 = max(bottomR_LL.x+0.01,topR_LL.x+0.01),
n1 = max(topL_LL.y+0.01,topR_LL.y+0.01);
parameters p;
if(getSource()=="api")
{
std::ostringstream str;
str<<w1<<","<<s1<<"," <<e1<<","<<n1;
p["url"] = url;
p["file"] = "";
p["bbox"] = str.str();
cerr<<"URL="<<str.str()<<endl;
}
else if (getSource()=="osm")
{
p["file"] = osmfile;
}
Map m (width, height);
p["type"] ="osm";
load_map(m,xmlfile);
setOSMLayers(m,p);
if(srtm)
{
addSRTMLayers(m,w1,s1,e1,n1);
}
// lonToX() and latToY() give *pixel* coordinates
// See email Chris Schmidt 12/02/09
double metres_per_pixel = (20037508.34/pow(2.0,
7+zoom_start));
for(int z=zoom_start; z<=zoom_end; z++)
{
EarthPoint bl,tr;
int ZOOM_FCTR = (int)(pow(2.0,z-zoom_start));
for(int tileX=
(topLeft.x+xfetch*x_fetch_freq)*ZOOM_FCTR;
tileX<
(topLeft.x+xfetch*x_fetch_freq+x_fetch_freq)
*ZOOM_FCTR;
tileX++)
{
for(int tileY=(topLeft.y+yfetch*y_fetch_freq)
*ZOOM_FCTR;
tileY<(topLeft.y+yfetch*y_fetch_freq+y_fetch_freq)
*ZOOM_FCTR;
tileY++)
{
cerr<<"x: " << tileX << " y: " << tileY
<<" z: " << z << endl;
image_32 buf(m.width(),m.height());
double metres_w =( (tileX*256.0) *
metres_per_pixel ) -
20037814.088;
double metres_s = 20034756.658 -
((tileY*256.0) * metres_per_pixel );
double metres_e = metres_w + (metres_per_pixel*256);
double metres_n = metres_s + (metres_per_pixel*256);
box2d<double> bb
(metres_w-32*metres_per_pixel,
metres_s-32*metres_per_pixel,
metres_e+32*metres_per_pixel,
metres_n+32*metres_per_pixel);
m.zoom_to_box(bb);
agg_renderer<image_32> r(m,buf);
r.apply();
string filename="";
std::ostringstream str;
str<< z<< "."<<tileX<<"." << tileY << ".png";
save_to_file<image_data_32>(buf.data(),
"tmp.png","png");
FILE *in=fopen("tmp.png","r");
FILE *out=fopen(str.str().c_str(),"w");
gdImagePtr image, image2;
image=gdImageCreateTrueColor(256,256);
image2=gdImageCreateFromPng(in);
gdImageCopy(image,image2,0,0,32,32,256,256);
gdImagePng(image,out);
gdImageDestroy(image2);
gdImageDestroy(image);
fclose(out);
fclose(in);
}
}
metres_per_pixel /= 2;
}
}
}
}
else
{
// standard rendering
Map m(width,height);
parameters p;
p["type"] = "osm";
p["file"] = osmfile;
load_map(m,xmlfile);
setOSMLayers(m,p);
box2d<double> latlon=
(hasBbox()) ?
box2d<double>(w,s,e,n):
m.getLayer(0).envelope();
EarthPoint bottomL_LL =
GoogleProjection::fromLLToGoog(latlon.minx(),latlon.miny()),
topR_LL =
GoogleProjection::fromLLToGoog(latlon.maxx(),latlon.maxy());
box2d<double> bb =
box2d<double>(bottomL_LL.x,bottomL_LL.y,
topR_LL.x,topR_LL.y);
m.zoom_to_box(bb);
image_32 buf (m.width(), m.height());
agg_renderer<image_32> r(m,buf);
r.apply();
save_to_file<image_data_32>(buf.data(),outfile,"png");
}
}
void MapSource::setOSMLayers(Map& m, const parameters &p)
{
parameters q;
for(int count=0; count<m.layer_count(); count++)
{
q = m.getLayer(count).datasource()->params();
if(boost::get<std::string>(q["type"])=="osm")
{
m.getLayer(count).set_datasource
(datasource_cache::instance().create(p));
}
}
}
void MapSource::addSRTMLayers(Map& m,double w,double s,double e,double n)
{
// Get the layers from the map
vector<Layer> layers=m.layers();
cerr<<"***addSRTMLayers():w s e n="<<w<<" "<<s<<" "<<e<<" "<<n<<endl;
int i=0;
// Find the index of the SRTM layer
while(i<layers.size() && layers[i].name()!="srtm")
i++;
// Return if we can't find an SRTM layer
if(i==layers.size())
return;
// Set the specific latlon shapefile for the first SRTM layer
parameters p;
p["type"] = "shape";
std::stringstream str;
int lon=floor(w),lat=floor(s);
str<<(lat<0 ? "S":"N")<<setw(2)<<setfill('0')<<
(lat<0 ? -lat:lat)<<
(lon>=0 ? "E":"W") << setw(3)<<setfill('0')
<<(lon>=0 ? lon:-lon)<<"c10";
p["file"] = str.str();
cerr<<"ADDING SRTM LAYER: " << p["file"] << endl;
m.getLayer(i).set_datasource(datasource_cache::instance().create(p));
// do we have more than one srtm layer?
if(floor(w) != floor(e) || floor(s) != floor(n))
{
// remove all layers after the SRTM layer. This is because there
// are multiple SRTM layers (if the current tile spans a lat/lon square
// boundary)
for(int j=i+1; j<layers.size(); j++)
m.removeLayer(j);
for(int lon=floor(w); lon<=floor(e); lon++)
{
for(int lat=floor(s); lat<=floor(n); lat++)
{
// if this isn't the bottom left lat/lon square, add another
// SRTM layer for it
if(lon!=floor(w) || lat!=floor(s))
{
parameters p;
p["type"] = "shape";
std::stringstream str;
str<<(lat<0 ? "S":"N")<<setw(2)<<setfill('0')<<
(lat<0 ? -lat:lat)<<
(lon>=0 ? "E":"W") << setw(3)<<setfill('0')
<<(lon>=0 ? lon:-lon)<<"c10";
p["file"] = str.str();
cerr<<"ADDING SRTM LAYER: " << p["file"] << endl;
layer lyr("srtm_" + str.str());
lyr.add_style("contours");
lyr.add_style("contours-text");
lyr.set_datasource
(datasource_cache::instance().create(p));
m.addLayer(lyr);
}
}
}
// Add the other layers back
for(int j=i+1; j<layers.size(); j++)
m.addLayer(layers[j]);
}
}

View file

@ -1,96 +0,0 @@
#ifndef MAPSOURCE_H
#define MAPSOURCE_H
#include <iostream>
#include <cmath>
#include <fstream>
using namespace std;
#include <boost/tokenizer.hpp>
#include <mapnik/map.hpp>
#include <mapnik/layer.hpp>
#include <mapnik/envelope.hpp>
#include <mapnik/agg_renderer.hpp>
#include <mapnik/image_util.hpp>
#include <mapnik/load_map.hpp>
#include <mapnik/datasource_cache.hpp>
#include <mapnik/font_engine_freetype.hpp>
#include <mapnik/projection.hpp>
#include "MapSource.h"
#include "GoogleProjection.h"
using namespace mapnik;
class MapSource
{
private:
std::string source; // osm. postgis or api
std::string osmfile;
std::string xmlfile;
std::string url;
std::string outfile;
int width, height;
double w,s,e,n;
bool useBbox, tiled, multirqst;
int zoom_start,zoom_end;
bool srtm;
static void setOSMLayers(Map& m, const parameters &p);
static void addSRTMLayers(Map& m,double w,double s,double e,double n);
public:
MapSource()
{
osmfile="";
source="";
xmlfile="";
outfile="";
width=height=-1;
w=-181;
e=181;
n=91;
s=-91;
zoom_start=zoom_end=-1;
tiled=false;
multirqst=false;
url="http://xapi.openstreetmap.org/api/0.5/map";
//url="http://osmxapi.hypercube.telascience.org/api/0.5/map";
srtm=false;
}
bool isValid()
{
return xmlfile!="" && ((tiled==false&&outfile!="" &&
width>0 && height>0) ||
(tiled==true&&zoom_start>=0)) &&
((source=="osm" && osmfile!="" && width>0 && height>0) ||
(source=="api" && hasBbox() && zoom_start>=0 && tiled==true));
}
void setSource(std::string const& src)
{
if(src=="api" || src=="osm")
{
source=src;
}
}
std::string getSource()
{
return source;
}
bool hasBbox()
{
return w>=-180 && w<=180 && s>=-90 && s<=90
&& e>=-180 && e<=180 && n>=-90 && n<=90 && w<e && s<n;
}
void process_cmd_line_args(int argc,char *argv[]);
void generateMaps();
};
#endif

View file

@ -1,9 +0,0 @@
easymapnik: a command line tool for generating Mapnik maps from OSM data
bypassing the need to set up a PostGIS database or to deal with large
planet files. easymapnik is aimed at the user who wishes to create a
custom Mapnik OSM "slippy map" of their own local area (e.g. a county or city)
easily.
Sample command line for compiling (Mac OS X 10.5):
g++ -I/usr/local/include/mapnik -I/opt/local/include -I/usr/X11/include -I/usr/X11/include/freetype2 -I../../agg/include -L/usr/local/lib -L/opt/local/lib -lmapnik easymapnik.cpp MapSource.cpp -o easymapnik -lboost_thread-mt

View file

@ -1,73 +0,0 @@
#include "MapSource.h"
void usage();
void help();
//////////// modes ////////////////////////////////
//
// render an OSM file:
// Input: XMLfile OSMfile width height [bbox]
//
// render live data in 256x256 tiles:
// Input: XMLfile bbox
int main(int argc,char *argv[])
{
if(argc<2 || (argc>=2 && !strcmp(argv[1],"-h")))
{
usage();
help();
exit(0);
}
MapSource s ;
s.process_cmd_line_args(argc,argv);
if(!s.isValid())
{
cerr << "Invalid combination of command-line parameters!" << endl<<endl;
usage();
exit(1);
}
datasource_cache::instance().register_datasources
("/usr/local/lib/mapnik/input");
freetype_engine::register_font
("/usr/local/lib/mapnik/fonts/DejaVuSans.ttf");
s.generateMaps();
return 0;
}
void usage()
{
cerr << "Usage: easymapnik -s source [-w width] [-h height] -x xmlfile "
<< endl <<
"[-i InOSMFile] [-o OutPNGFile] [-t] [-z startzoom] [-Z endzoom] "
<< endl <<
"[-b bbox] [-u serverURL] [-m]" << endl << endl;
}
void help()
{
cerr << "Source should be 'osm' or 'api', indicating OSM files and "
<< endl << "retrieval direct from a server (e.g. OSMXAPI) respectively."
<< endl <<
"-t indicates tiled mode (generate 'Google' style tiles); you must "
<< endl <<
"supply at least a start zoom, and a bounding box, for this."
<< endl <<
"-m means 'multirequest'; if you're requesting a relatively large "
<< endl <<
"area from the server (e.g. OSMXAPI), it will fetch it in "
<< "0.1x0.1 degree tiles. "
<< endl << "This speeds up processing considerably." << endl;
exit(1);
}

View file

@ -24,6 +24,7 @@
#define SHAPE_FEATURESET_HPP
//mapnik
#include <mapnik/datasource.hpp>
#include <mapnik/geom_util.hpp>
#include <mapnik/feature.hpp>
#include <mapnik/unicode.hpp>

View file

@ -34,6 +34,7 @@
#include "shape_index_featureset.hpp"
#include "shape_utils.hpp"
#include "shp_index.hpp"
using mapnik::feature_factory;
using mapnik::geometry_type;

View file

@ -25,7 +25,7 @@
// mapnik
#include <mapnik/geometry.hpp>
#include <mapnik/datasource.hpp>
#include <mapnik/box2d.hpp>
#include <mapnik/noncopyable.hpp>
// boost
@ -33,7 +33,6 @@
#include "dbfile.hpp"
#include "shapefile.hpp"
#include "shp_index.hpp"
struct shape_io : mapnik::noncopyable
{

View file

@ -68,6 +68,9 @@ TARGET = plugin_env.SharedLibrary(
LINKFLAGS=env.get('CUSTOM_LDFLAGS')
)
# if the plugin links to libmapnik ensure it is built first
Depends(TARGET, env.subst('../../../../src/%s' % env['MAPNIK_LIB_NAME']))
# if 'uninstall' is not passed on the command line
# then we actually create the install targets that
# scons will install if 'install' is passed as an arg

View file

@ -183,13 +183,6 @@ void agg_renderer<T>::start_layer_processing(layer const& lay, box2d<double> con
}
query_extent_ = query_extent;
int buffer_size = lay.buffer_size();
if (buffer_size != 0 )
{
double padding = buffer_size * (double)(query_extent.width()/pixmap_.width());
query_extent_.pad(padding);
}
boost::optional<box2d<double> > const& maximum_extent = lay.maximum_extent();
if (maximum_extent)
{

View file

@ -204,11 +204,11 @@ source = Split(
)
if env['HAS_CAIRO']:
lib_env.PrependUnique(LIBPATH=env['CAIRO_LIBPATHS'])
lib_env.AppendUnique(LIBPATH=env['CAIRO_LIBPATHS'])
lib_env.Append(LIBS=env['CAIRO_LINKFLAGS'])
lib_env.Append(CXXFLAGS = '-DHAVE_CAIRO')
libmapnik_cxxflags.append('-DHAVE_CAIRO')
lib_env.PrependUnique(CPPPATH=copy(env['CAIRO_CPPPATHS']))
lib_env.AppendUnique(CPPPATH=copy(env['CAIRO_CPPPATHS']))
source.insert(0,'cairo_renderer.cpp')
source.insert(0,'cairo_context.cpp')

View file

@ -22,6 +22,8 @@
// mapnik
#include <mapnik/building_symbolizer.hpp>
#include <mapnik/value.hpp>
#include <mapnik/attribute.hpp>
namespace mapnik
{

View file

@ -47,7 +47,8 @@ void cairo_context::set_color(color const &color, double opacity)
void cairo_context::set_color(double r, double g, double b, double opacity)
{
cairo_set_source_rgb(cairo_.get(), r, g, b);
// http://lists.cairographics.org/archives/cairo/2008-August/014759.html
cairo_set_source_rgba(cairo_.get(), r, g, b, opacity);
check_object_status_and_throw_exception(*this);
}

View file

@ -47,6 +47,8 @@
#include <boost/lexical_cast.hpp>
#endif
#include <cstring>
namespace mapnik {
namespace util {
@ -60,21 +62,51 @@ BOOST_SPIRIT_AUTO(qi, LONGLONG, qi::long_long)
BOOST_SPIRIT_AUTO(qi, FLOAT, qi::float_)
BOOST_SPIRIT_AUTO(qi, DOUBLE, qi::double_)
struct bool_symbols : qi::symbols<char,bool>
{
bool_symbols()
{
add("true",true)
("false",false)
("yes",true)
("no",false)
("on",true)
("off",false)
("1",true)
("0",false);
}
};
bool string2bool(const char * value, bool & result)
{
using boost::spirit::qi::no_case;
const char *iter = value;
const char *end = value + std::strlen(value);
bool r = qi::phrase_parse(iter,end, no_case[bool_symbols()] ,ascii::space,result);
return r && (iter == end);
}
bool string2bool(std::string const& value, bool & result)
{
using boost::spirit::qi::no_case;
std::string::const_iterator str_beg = value.begin();
std::string::const_iterator str_end = value.end();
bool r = qi::phrase_parse(str_beg,str_end,no_case[bool_symbols()],ascii::space,result);
return r && (str_beg == str_end);
}
bool string2int(const char * value, int & result)
{
size_t length = strlen(value);
if (length < 1 || value == NULL)
return false;
const char *iter = value;
const char *end = value + length;
const char *iter = value;
const char *end = value + std::strlen(value);
bool r = qi::phrase_parse(iter,end,INTEGER,ascii::space,result);
return r && (iter == end);
}
bool string2int(std::string const& value, int & result)
{
if (value.empty())
return false;
std::string::const_iterator str_beg = value.begin();
std::string::const_iterator str_end = value.end();
bool r = qi::phrase_parse(str_beg,str_end,INTEGER,ascii::space,result);
@ -84,19 +116,14 @@ bool string2int(std::string const& value, int & result)
#ifdef BIGINT
bool string2int(const char * value, mapnik::value_integer & result)
{
size_t length = strlen(value);
if (length < 1 || value == NULL)
return false;
const char *iter = value;
const char *end = value + length;
const char *end = value + std::strlen(value);
bool r = qi::phrase_parse(iter,end,LONGLONG,ascii::space,result);
return r && (iter == end);
}
bool string2int(std::string const& value, mapnik::value_integer & result)
{
if (value.empty())
return false;
std::string::const_iterator str_beg = value.begin();
std::string::const_iterator str_end = value.end();
bool r = qi::phrase_parse(str_beg,str_end,LONGLONG,ascii::space,result);
@ -106,8 +133,6 @@ bool string2int(std::string const& value, mapnik::value_integer & result)
bool string2double(std::string const& value, double & result)
{
if (value.empty())
return false;
std::string::const_iterator str_beg = value.begin();
std::string::const_iterator str_end = value.end();
bool r = qi::phrase_parse(str_beg,str_end,DOUBLE,ascii::space,result);
@ -116,19 +141,14 @@ bool string2double(std::string const& value, double & result)
bool string2double(const char * value, double & result)
{
size_t length = strlen(value);
if (length < 1 || value == NULL)
return false;
const char *iter = value;
const char *end = value + length;
const char *iter = value;
const char *end = value + std::strlen(value);
bool r = qi::phrase_parse(iter,end,DOUBLE,ascii::space,result);
return r && (iter == end);
}
bool string2float(std::string const& value, float & result)
{
if (value.empty())
return false;
std::string::const_iterator str_beg = value.begin();
std::string::const_iterator str_end = value.end();
bool r = qi::phrase_parse(str_beg,str_end,FLOAT,ascii::space,result);
@ -137,16 +157,12 @@ bool string2float(std::string const& value, float & result)
bool string2float(const char * value, float & result)
{
size_t length = strlen(value);
if (length < 1 || value == NULL)
return false;
const char *iter = value;
const char *end = value + length;
const char *end = value + std::strlen(value);
bool r = qi::phrase_parse(iter,end,FLOAT,ascii::space,result);
return r && (iter == end);
}
#if BOOST_VERSION >= 104500
bool to_string(std::string & str, int value)
@ -156,6 +172,15 @@ bool to_string(std::string & str, int value)
return karma::generate(sink, value);
}
#ifdef BIGINT
bool to_string(std::string & str, mapnik::value_integer value)
{
namespace karma = boost::spirit::karma;
std::back_insert_iterator<std::string> sink(str);
return karma::generate(sink, value);
}
#endif
bool to_string(std::string & str, unsigned value)
{
namespace karma = boost::spirit::karma;
@ -170,13 +195,6 @@ bool to_string(std::string & str, bool value)
return karma::generate(sink, value);
}
bool to_string(std::string & str, boost::long_long_type value)
{
namespace karma = boost::spirit::karma;
std::back_insert_iterator<std::string> sink(str);
return karma::generate(sink, value);
}
namespace detail {
template <typename T>
struct double_policy : boost::spirit::karma::real_policies<T>
@ -287,6 +305,12 @@ bool to_string(std::string & str, int value)
return to_string_lexical(str, value);
}
#ifdef BIGINT
bool to_string(std::string & str, mapnik::value_integer value)
{
return to_string_lexical(str, value);
}
bool to_string(std::string & str, unsigned value)
{
return to_string_lexical(str, value);
@ -302,10 +326,7 @@ bool to_string(std::string & str, double value)
return to_string_lexical(str, value);
}
bool to_string(std::string & str, boost::long_long_type value)
{
return to_string_lexical(str, value);
}
#endif
#endif

View file

@ -24,6 +24,7 @@
#include <mapnik/debug.hpp>
#include <mapnik/datasource_cache.hpp>
#include <mapnik/config_error.hpp>
#include <mapnik/params.hpp>
// boost
#include <boost/make_shared.hpp>
@ -36,6 +37,7 @@
// stl
#include <algorithm>
#include <stdexcept>
#include <map>
namespace mapnik {
@ -123,7 +125,7 @@ datasource_ptr datasource_cache::create(const parameters& params)
bool datasource_cache::insert(std::string const& type,const lt_dlhandle module)
{
return plugins_.insert(make_pair(type,boost::make_shared<PluginInfo>
return plugins_.insert(std::make_pair(type,boost::make_shared<PluginInfo>
(type,module))).second;
}

View file

@ -30,7 +30,7 @@
#include <boost/version.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/home/phoenix/object/construct.hpp>
#include <boost/spirit/include/phoenix_object.hpp>
// fwd declare
namespace mapnik {

View file

@ -21,15 +21,22 @@
*****************************************************************************/
// mapnik
#include <mapnik/config.hpp> // needed by msvc
#include <mapnik/expression_string.hpp> // needed by msvc
#include <mapnik/expression_node_types.hpp>
#include <mapnik/expression_node.hpp>
#include <mapnik/attribute.hpp>
#include <mapnik/value.hpp>
// boost
#include <boost/variant.hpp>
#if defined(BOOST_REGEX_HAS_ICU)
#include <boost/regex/icu.hpp> // for u32regex
#endif
// icu
#include <unicode/uversion.h>
#include <unicode/unistr.h> // for UnicodeString
namespace mapnik

View file

@ -107,13 +107,6 @@ void grid_renderer<T>::start_layer_processing(layer const& lay, box2d<double> co
detector_->clear();
}
query_extent_ = query_extent;
int buffer_size = lay.buffer_size();
if (buffer_size != 0 )
{
double padding = buffer_size * (double)(query_extent.width()/pixmap_.width());
query_extent_.pad(padding);
}
boost::optional<box2d<double> > const& maximum_extent = lay.maximum_extent();
if (maximum_extent)
{

View file

@ -20,6 +20,12 @@
*
*****************************************************************************/
// TODO https://github.com/mapnik/mapnik/issues/1658
#include <boost/version.hpp>
#if BOOST_VERSION >= 105200
#define BOOST_SPIRIT_USE_PHOENIX_V3
#endif
// mapnik
#include <mapnik/json/feature_collection_parser.hpp>
#include <mapnik/json/feature_collection_grammar.hpp>

View file

@ -40,8 +40,7 @@ layer::layer(std::string const& name, std::string const& srs)
clear_label_cache_(false),
cache_features_(false),
group_by_(""),
ds_(),
buffer_size_(0) {}
ds_() {}
layer::layer(const layer& rhs)
: name_(rhs.name_),
@ -197,14 +196,20 @@ void layer::reset_maximum_extent()
void layer::set_buffer_size(int size)
{
buffer_size_ = size;
buffer_size_.reset(size);
}
int layer::buffer_size() const
boost::optional<int> const& layer::buffer_size() const
{
return buffer_size_;
}
void layer::reset_buffer_size()
{
buffer_size_.reset();
}
box2d<double> layer::envelope() const
{
if (ds_) return ds_->envelope();

View file

@ -22,6 +22,8 @@
// mapnik
#include <mapnik/markers_symbolizer.hpp>
#include <mapnik/value.hpp>
#include <mapnik/attribute.hpp>
// boost
#include <boost/make_shared.hpp>

View file

@ -23,62 +23,26 @@
// mapnik
#include <mapnik/boolean.hpp>
#include <mapnik/params.hpp>
#include <mapnik/params_impl.hpp>
#include <mapnik/value_types.hpp>
// boost
#include <boost/variant/static_visitor.hpp>
#include <boost/variant/apply_visitor.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/none.hpp>
#include <boost/optional.hpp>
namespace mapnik {
namespace params_detail {
template boost::optional<std::string> parameters::get(std::string const& key) const;
template boost::optional<std::string> parameters::get(std::string const& key, std::string const& default_opt_value) const;
template <typename T>
struct converter
{
typedef boost::optional<T> return_type;
static return_type extract(parameters const& params,
std::string const& name,
boost::optional<T> const& default_opt_value)
{
boost::optional<T> result(default_opt_value);
parameters::const_iterator itr = params.find(name);
if (itr != params.end())
{
boost::apply_visitor(value_extractor_visitor<T>(result),itr->second);
}
return result;
}
};
} // end namespace params_detail
template boost::optional<value_double> parameters::get(std::string const& key) const;
template boost::optional<value_double> parameters::get(std::string const& key, value_double const& default_opt_value) const;
// parameters
template boost::optional<int> parameters::get(std::string const& key) const;
template boost::optional<int> parameters::get(std::string const& key, int const& default_opt_value) const;
parameters::parameters() {}
template boost::optional<mapnik::boolean> parameters::get(std::string const& key) const;
template boost::optional<mapnik::boolean> parameters::get(std::string const& key, mapnik::boolean const& default_opt_value) const;
template <typename T>
boost::optional<T> parameters::get(std::string const& key) const
{
return params_detail::converter<T>::extract(*this,key, boost::none);
}
template <typename T>
boost::optional<T> parameters::get(std::string const& key, T const& default_opt_value) const
{
return params_detail::converter<T>::extract(*this,key,boost::optional<T>(default_opt_value));
}
#define compile_params_get(T) template boost::optional<T> parameters::get(std::string const& key) const; template boost::optional<T> parameters::get(std::string const& key, T const& default_opt_value) const
compile_params_get(std::string);
compile_params_get(value_double);
compile_params_get(int);
#ifdef BIGINT
compile_params_get(value_integer);
template boost::optional<value_integer> parameters::get(std::string const& key) const;
template boost::optional<value_integer> parameters::get(std::string const& key, value_integer const& default_opt_value) const;
#endif
compile_params_get(mapnik::boolean);
}

View file

@ -39,7 +39,7 @@ transform_list_ptr parse_transform(std::string const& str, std::string const& en
transform_list_ptr tl = boost::make_shared<transform_list>();
transcoder tc(encoding);
expression_grammar<std::string::const_iterator> ge(tc);
transform_expression_grammar__string gte(ge);
transform_expression_grammar_string gte(ge);
if (!parse_transform(*tl, str, gte))
{
@ -50,7 +50,7 @@ transform_list_ptr parse_transform(std::string const& str, std::string const& en
bool parse_transform(transform_list& transform,
std::string const& str,
transform_expression_grammar__string const& g)
transform_expression_grammar_string const& g)
{
std::string::const_iterator itr = str.begin();
std::string::const_iterator end = str.end();

View file

@ -25,7 +25,6 @@
#include <mapnik/attribute.hpp>
// boost
#include <boost/spirit/home/phoenix/object/construct.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_object.hpp>
#include <boost/spirit/include/phoenix_stl.hpp>

View file

@ -22,6 +22,8 @@
// mapnik
#include <mapnik/point_symbolizer.hpp>
#include <mapnik/value.hpp>
#include <mapnik/attribute.hpp>
#include <mapnik/enumeration.hpp>
namespace mapnik

View file

@ -23,6 +23,7 @@
// mapnik
#include <mapnik/debug.hpp>
#include <mapnik/value_types.hpp>
#include <mapnik/value.hpp> // for to_double
#include <mapnik/feature.hpp>
#include <mapnik/raster.hpp>
#include <mapnik/raster_colorizer.hpp>

View file

@ -22,6 +22,7 @@
// mapnik
#include <mapnik/rule.hpp>
#include <mapnik/expression_node.hpp>
#include <mapnik/debug.hpp>
#include <mapnik/raster_colorizer.hpp>
#include <mapnik/expression_string.hpp>

View file

@ -762,10 +762,10 @@ void serialize_layer( ptree & map_node, const layer & layer, bool explicit_defau
set_attr( layer_node, "group-by", layer.group_by() );
}
int buffer_size = layer.buffer_size();
boost::optional<int> const& buffer_size = layer.buffer_size();
if ( buffer_size || explicit_defaults)
{
set_attr( layer_node, "buffer-size", buffer_size );
set_attr( layer_node, "buffer-size", *buffer_size );
}
optional<box2d<double> > const& maximum_extent = layer.maximum_extent();

View file

@ -40,6 +40,7 @@
#include <string>
#include <stdexcept>
#include <vector>
#include <cstring>
namespace mapnik { namespace svg {
@ -86,7 +87,7 @@ double parse_double(const char* str)
{
using namespace boost::spirit::qi;
double val = 0.0;
parse(str, str+ strlen(str),double_,val);
parse(str, str + std::strlen(str),double_,val);
return val;
}
@ -102,7 +103,7 @@ double parse_double_optional_percent(const char* str, bool &percent)
double val = 0.0;
char unit='\0';
parse(str, str+ strlen(str),double_[ref(val)=_1] >> *char_('%')[ref(unit)=_1]);
parse(str, str + std::strlen(str),double_[ref(val)=_1] >> *char_('%')[ref(unit)=_1]);
if (unit =='%')
{
percent = true;
@ -120,7 +121,7 @@ bool parse_style (const char* str, pairs_type & v)
using namespace boost::spirit::qi;
typedef boost::spirit::ascii::space_type skip_type;
key_value_sequence_ordered<const char*, skip_type> kv_parser;
return phrase_parse(str, str + strlen(str), kv_parser, skip_type(), v);
return phrase_parse(str, str + std::strlen(str), kv_parser, skip_type(), v);
}
svg_parser::svg_parser(svg_converter<svg_path_adapter,
@ -458,7 +459,7 @@ void svg_parser::parse_path(xmlTextReaderPtr reader)
if (value)
{
// d="" (empty paths) are valid
if (strlen((const char*)value) < 1)
if (std::strlen((const char*)value) < 1)
{
xmlFree(value);
}

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