From 992af4747d2641c685ac6efc150489995eef74fb Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Wed, 4 Oct 2006 11:22:18 +0000 Subject: [PATCH] 1. move include to mapnik/include 2. update demos,bibdibgs etc. --- SConstruct | 25 +- bindings/python/SConscript | 4 +- bindings/python/mapnik/__init__.py | 8 +- bindings/python/mapnik_color.cpp | 4 +- bindings/python/mapnik_datasource_cache.cpp | 2 +- bindings/python/mapnik_envelope.cpp | 2 +- bindings/python/mapnik_filter.cpp | 13 +- bindings/python/mapnik_font_engine.cpp | 2 +- bindings/python/mapnik_image.cpp | 5 +- bindings/python/mapnik_layer.cpp | 2 +- .../python/mapnik_line_pattern_symbolizer.cpp | 2 +- bindings/python/mapnik_line_symbolizer.cpp | 2 +- bindings/python/mapnik_map.cpp | 4 +- bindings/python/mapnik_parameters.cpp | 2 +- bindings/python/mapnik_point_symbolizer.cpp | 2 +- .../mapnik_polygon_pattern_symbolizer.cpp | 2 +- bindings/python/mapnik_polygon_symbolizer.cpp | 2 +- bindings/python/mapnik_python.cpp | 12 +- bindings/python/mapnik_query.cpp | 2 +- bindings/python/mapnik_raster_symbolizer.cpp | 2 +- bindings/python/mapnik_rule.cpp | 5 +- bindings/python/mapnik_stroke.cpp | 3 +- bindings/python/mapnik_style.cpp | 3 +- bindings/python/mapnik_text_symbolizer.cpp | 3 +- demo/c++/rundemo.cpp | 18 +- fonts/SConscript | 2 +- include/attribute.hpp | 222 --------- include/attribute_collector.hpp | 98 ---- include/comparison.hpp | 153 ------ include/coord_array.hpp | 92 ---- include/css_color_parser.hpp | 388 --------------- include/ctrans.hpp | 169 ------- include/expression.hpp | 127 ----- include/feature.hpp | 118 ----- include/feature_layer_desc.hpp | 250 ---------- include/filter_parser_ast.hpp | 265 ---------- include/font_engine_freetype.hpp | 432 ----------------- include/{ => mapnik}/agg_renderer.hpp | 13 +- include/mapnik/attribute.hpp | 222 +++++++++ include/mapnik/attribute_collector.hpp | 98 ++++ include/{ => mapnik}/attribute_descriptor.hpp | 9 +- include/{ => mapnik}/color.hpp | 4 +- include/{ => mapnik}/color_factory.hpp | 10 +- include/mapnik/comparison.hpp | 149 ++++++ include/{ => mapnik}/config.hpp | 2 +- include/{ => mapnik}/coord.hpp | 4 +- include/mapnik/coord_array.hpp | 92 ++++ include/mapnik/css_color_parser.hpp | 387 +++++++++++++++ include/mapnik/ctrans.hpp | 169 +++++++ include/{ => mapnik}/datasource.hpp | 43 +- include/{ => mapnik}/datasource_cache.hpp | 19 +- include/{ => mapnik}/envelope.hpp | 11 +- include/mapnik/expression.hpp | 126 +++++ include/{ => mapnik}/factory.hpp | 14 +- include/mapnik/feature.hpp | 121 +++++ include/{ => mapnik}/feature_factory.hpp | 12 +- include/mapnik/feature_layer_desc.hpp | 250 ++++++++++ .../{ => mapnik}/feature_style_processor.hpp | 25 +- include/{ => mapnik}/feature_type_style.hpp | 14 +- include/{ => mapnik}/fill.hpp | 0 include/{ => mapnik}/filter.hpp | 3 +- include/{ => mapnik}/filter_expression.hpp | 6 +- include/{ => mapnik}/filter_factory.hpp | 8 +- include/{ => mapnik}/filter_parser.hpp | 40 +- include/mapnik/filter_parser_ast.hpp | 266 +++++++++++ include/{ => mapnik}/filter_visitor.hpp | 4 +- include/mapnik/font_engine_freetype.hpp | 432 +++++++++++++++++ include/{ => mapnik}/gamma.hpp | 32 +- include/{ => mapnik}/geom_util.hpp | 7 +- include/{ => mapnik}/geometry.hpp | 15 +- include/{ => mapnik}/global.hpp | 44 +- include/{ => mapnik}/graphics.hpp | 11 +- include/{ => mapnik}/image_data.hpp | 0 include/{ => mapnik}/image_reader.hpp | 52 +- include/{ => mapnik}/image_util.hpp | 19 +- .../{ => mapnik}/label_collision_detector.hpp | 71 +-- include/{ => mapnik}/label_placement.hpp | 0 include/{ => mapnik}/layer.hpp | 11 +- .../{ => mapnik}/line_pattern_symbolizer.hpp | 14 +- include/{ => mapnik}/line_symbolizer.hpp | 2 +- include/{ => mapnik}/load_map.hpp | 2 +- include/{ => mapnik}/local_datasource.hpp | 0 include/{ => mapnik}/logical.hpp | 2 +- include/{ => mapnik}/map.hpp | 2 +- include/{ => mapnik}/math_expr.hpp | 2 +- include/{ => mapnik}/memory.hpp | 60 +-- include/{ => mapnik}/params.hpp | 2 +- include/{ => mapnik}/plugin.hpp | 16 +- include/{ => mapnik}/point_symbolizer.hpp | 2 +- .../polygon_pattern_symbolizer.hpp | 14 +- include/{ => mapnik}/polygon_symbolizer.hpp | 2 +- include/mapnik/pool.hpp | 122 +++++ include/{ => mapnik}/quad_tree.hpp | 9 +- include/{ => mapnik}/query.hpp | 9 +- include/{ => mapnik}/raster.hpp | 12 +- include/{ => mapnik}/raster_symbolizer.hpp | 5 +- include/mapnik/regex_filter.hpp | 81 ++++ include/{ => mapnik}/rule.hpp | 29 +- include/{ => mapnik}/save_map.hpp | 5 +- include/{ => mapnik}/spatial.hpp | 133 +++--- include/{ => mapnik}/stroke.hpp | 7 +- include/{ => mapnik}/style.hpp | 13 +- include/{ => mapnik}/style_factory.hpp | 2 +- include/{ => mapnik}/symbolizer.hpp | 0 include/{ => mapnik}/text_symbolizer.hpp | 57 +-- include/mapnik/utils.hpp | 222 +++++++++ include/mapnik/value.hpp | 452 ++++++++++++++++++ include/{ => mapnik}/vertex.hpp | 59 ++- include/{ => mapnik}/vertex_transform.hpp | 5 +- include/{ => mapnik}/vertex_vector.hpp | 9 +- include/{ => mapnik}/wkb.hpp | 12 +- include/pool.hpp | 119 ----- include/regex_filter.hpp | 81 ---- include/utils.hpp | 249 ---------- include/value.hpp | 443 ----------------- plugins/input/postgis/SConscript | 4 +- plugins/input/raster/SConscript | 4 +- plugins/input/raster/raster_datasource.cpp | 9 +- plugins/input/raster/raster_datasource.hpp | 7 +- plugins/input/raster/raster_featureset.cpp | 6 +- plugins/input/raster/raster_featureset.hpp | 3 +- plugins/input/shape/SConscript | 4 +- plugins/input/shape/dbffile.cpp | 11 +- plugins/input/shape/dbffile.hpp | 65 +-- plugins/input/shape/shape.cpp | 12 +- plugins/input/shape/shape.hpp | 13 +- plugins/input/shape/shape_featureset.cpp | 2 +- plugins/input/shape/shape_featureset.hpp | 4 +- .../input/shape/shape_index_featureset.cpp | 2 +- .../input/shape/shape_index_featureset.hpp | 12 +- plugins/input/shape/shapefile.cpp | 1 - plugins/input/shape/shapefile.hpp | 143 +++--- plugins/input/shape/shp_index.cpp | 3 +- plugins/input/shape/shp_index.hpp | 6 +- src/SConscript | 19 +- src/agg_renderer.cpp | 27 +- src/datasource_cache.cpp | 16 +- src/envelope.cpp | 58 +-- src/filter_factory.cpp | 2 +- src/font_engine_freetype.cpp | 2 +- src/graphics.cpp | 14 +- src/image_reader.cpp | 5 +- src/image_util.cpp | 104 ++-- src/layer.cpp | 30 +- src/line_pattern_symbolizer.cpp | 39 +- src/load_map.cpp | 21 +- src/map.cpp | 10 +- src/memory.cpp | 5 +- src/params.cpp | 2 +- src/plugin.cpp | 2 +- src/png_reader.cpp | 15 +- src/point_symbolizer.cpp | 11 +- src/polygon_pattern_symbolizer.cpp | 40 +- src/save_map.cpp | 16 +- src/text_symbolizer.cpp | 2 +- src/tiff_reader.cpp | 7 +- src/wkb.cpp | 401 ++++++++-------- utils/shapeindex/SConscript | 2 +- utils/shapeindex/quadtree.hpp | 5 +- utils/shapeindex/shapeindex.cpp | 13 +- 160 files changed, 4384 insertions(+), 4312 deletions(-) delete mode 100644 include/attribute.hpp delete mode 100644 include/attribute_collector.hpp delete mode 100644 include/comparison.hpp delete mode 100644 include/coord_array.hpp delete mode 100644 include/css_color_parser.hpp delete mode 100644 include/ctrans.hpp delete mode 100644 include/expression.hpp delete mode 100644 include/feature.hpp delete mode 100644 include/feature_layer_desc.hpp delete mode 100644 include/filter_parser_ast.hpp delete mode 100644 include/font_engine_freetype.hpp rename include/{ => mapnik}/agg_renderer.hpp (90%) create mode 100644 include/mapnik/attribute.hpp create mode 100644 include/mapnik/attribute_collector.hpp rename include/{ => mapnik}/attribute_descriptor.hpp (91%) rename include/{ => mapnik}/color.hpp (99%) rename include/{ => mapnik}/color_factory.hpp (93%) create mode 100644 include/mapnik/comparison.hpp rename include/{ => mapnik}/config.hpp (98%) rename include/{ => mapnik}/coord.hpp (98%) create mode 100644 include/mapnik/coord_array.hpp create mode 100644 include/mapnik/css_color_parser.hpp create mode 100644 include/mapnik/ctrans.hpp rename include/{ => mapnik}/datasource.hpp (81%) rename include/{ => mapnik}/datasource_cache.hpp (87%) rename include/{ => mapnik}/envelope.hpp (96%) create mode 100644 include/mapnik/expression.hpp rename include/{ => mapnik}/factory.hpp (89%) create mode 100644 include/mapnik/feature.hpp rename include/{ => mapnik}/feature_factory.hpp (90%) create mode 100644 include/mapnik/feature_layer_desc.hpp rename include/{ => mapnik}/feature_style_processor.hpp (93%) rename include/{ => mapnik}/feature_type_style.hpp (91%) rename include/{ => mapnik}/fill.hpp (100%) rename include/{ => mapnik}/filter.hpp (97%) rename include/{ => mapnik}/filter_expression.hpp (96%) rename include/{ => mapnik}/filter_factory.hpp (96%) rename include/{ => mapnik}/filter_parser.hpp (95%) create mode 100644 include/mapnik/filter_parser_ast.hpp rename include/{ => mapnik}/filter_visitor.hpp (96%) create mode 100644 include/mapnik/font_engine_freetype.hpp rename include/{ => mapnik}/gamma.hpp (70%) rename include/{ => mapnik}/geom_util.hpp (97%) rename include/{ => mapnik}/geometry.hpp (98%) rename include/{ => mapnik}/global.hpp (52%) rename include/{ => mapnik}/graphics.hpp (97%) rename include/{ => mapnik}/image_data.hpp (100%) rename include/{ => mapnik}/image_reader.hpp (50%) rename include/{ => mapnik}/image_util.hpp (91%) rename include/{ => mapnik}/label_collision_detector.hpp (55%) rename include/{ => mapnik}/label_placement.hpp (100%) rename include/{ => mapnik}/layer.hpp (96%) rename include/{ => mapnik}/line_pattern_symbolizer.hpp (77%) rename include/{ => mapnik}/line_symbolizer.hpp (98%) rename include/{ => mapnik}/load_map.hpp (97%) rename include/{ => mapnik}/local_datasource.hpp (100%) rename include/{ => mapnik}/logical.hpp (99%) rename include/{ => mapnik}/map.hpp (98%) rename include/{ => mapnik}/math_expr.hpp (99%) rename include/{ => mapnik}/memory.hpp (58%) rename include/{ => mapnik}/params.hpp (99%) rename include/{ => mapnik}/plugin.hpp (83%) rename include/{ => mapnik}/point_symbolizer.hpp (98%) rename include/{ => mapnik}/polygon_pattern_symbolizer.hpp (76%) rename include/{ => mapnik}/polygon_symbolizer.hpp (98%) create mode 100644 include/mapnik/pool.hpp rename include/{ => mapnik}/quad_tree.hpp (99%) rename include/{ => mapnik}/query.hpp (96%) rename include/{ => mapnik}/raster.hpp (87%) rename include/{ => mapnik}/raster_symbolizer.hpp (93%) create mode 100644 include/mapnik/regex_filter.hpp rename include/{ => mapnik}/rule.hpp (94%) rename include/{ => mapnik}/save_map.hpp (96%) rename include/{ => mapnik}/spatial.hpp (51%) rename include/{ => mapnik}/stroke.hpp (98%) rename include/{ => mapnik}/style.hpp (91%) rename include/{ => mapnik}/style_factory.hpp (97%) rename include/{ => mapnik}/symbolizer.hpp (100%) rename include/{ => mapnik}/text_symbolizer.hpp (51%) create mode 100644 include/mapnik/utils.hpp create mode 100644 include/mapnik/value.hpp rename include/{ => mapnik}/vertex.hpp (74%) rename include/{ => mapnik}/vertex_transform.hpp (97%) rename include/{ => mapnik}/vertex_vector.hpp (98%) rename include/{ => mapnik}/wkb.hpp (82%) delete mode 100644 include/pool.hpp delete mode 100644 include/regex_filter.hpp delete mode 100644 include/utils.hpp delete mode 100644 include/value.hpp diff --git a/SConstruct b/SConstruct index 16c1198ac..a6446b88c 100644 --- a/SConstruct +++ b/SConstruct @@ -22,37 +22,34 @@ import os, sys, platform - - if platform.uname()[4] == 'x86_64': - LIB_PLATFORM = 'lib64' -else : - LIB_PLATFORM = 'lib' + LIBDIR_SCHEMA='lib64' +else: + LIBDIR_SCHEMA='lib' - opts = Options() - opts.Add('PREFIX', 'The install path "prefix"', '/usr/local') opts.Add(PathOption('BOOST_INCLUDES', 'Search path for boost include files', '/usr/include')) -opts.Add(PathOption('BOOST_LIBS', 'Search path for boost library files', '/usr/' + LIB_PLATFORM)) +opts.Add(PathOption('BOOST_LIBS', 'Search path for boost library files', '/usr/' + LIBDIR_SCHEMA)) opts.Add(PathOption('FREETYPE_CONFIG', 'The path to the freetype-config executable.', '/usr/bin/freetype-config')) opts.Add(PathOption('PNG_INCLUDES', 'Search path for libpng include files', '/usr/include')) -opts.Add(PathOption('PNG_LIBS', 'Search path for libpng include files', '/usr/' + LIB_PLATFORM)) +opts.Add(PathOption('PNG_LIBS','Search path for libpng include files','/usr/' + LIBDIR_SCHEMA)) opts.Add(PathOption('JPEG_INCLUDES', 'Search path for libjpeg include files', '/usr/include')) -opts.Add(PathOption('JPEG_LIBS', 'Search path for libjpeg library files', '/usr/' + LIB_PLATFORM)) +opts.Add(PathOption('JPEG_LIBS', 'Search path for libjpeg library files', '/usr/' + LIBDIR_SCHEMA)) opts.Add(PathOption('TIFF_INCLUDES', 'Search path for libtiff include files', '/usr/include')) -opts.Add(PathOption('TIFF_LIBS', 'Search path for libtiff library files', '/usr/' + LIB_PLATFORM)) +opts.Add(PathOption('TIFF_LIBS', 'Search path for libtiff library files', '/usr/' + LIBDIR_SCHEMA)) opts.Add(PathOption('PGSQL_INCLUDES', 'Search path for PostgreSQL include files', '/usr/include')) -opts.Add(PathOption('PGSQL_LIBS', 'Search path for PostgreSQL library files', '/usr/' + LIB_PLATFORM)) +opts.Add(PathOption('PGSQL_LIBS', 'Search path for PostgreSQL library files', '/usr/' + LIBDIR_SCHEMA)) opts.Add(PathOption('PROJ_INCLUDES', 'Search path for PROJ.4 include files', '/usr/local/include')) -opts.Add(PathOption('PROJ_LIBS', 'Search path for PROJ.4 include files', '/usr/local/' + LIB_PLATFORM)) +opts.Add(PathOption('PROJ_LIBS', 'Search path for PROJ.4 include files', '/usr/local/' + LIBDIR_SCHEMA)) opts.Add(PathOption('PYTHON','Python executable', sys.executable)) opts.Add(ListOption('INPUT_PLUGINS','Input drivers to include','all',['postgis','shape','raster'])) opts.Add(ListOption('BINDINGS','Language bindings to build','all',['python'])) + opts.Add('DEBUG', 'Compile a debug version of mapnik', '') env = Environment(ENV=os.environ, options=opts) -env['LIB_PLATFORM'] = LIB_PLATFORM +env['LIBDIR_SCHEMA'] = LIBDIR_SCHEMA Help(opts.GenerateHelpText(env)) diff --git a/bindings/python/SConscript b/bindings/python/SConscript index 8a19673ae..4b5870cbc 100644 --- a/bindings/python/SConscript +++ b/bindings/python/SConscript @@ -23,7 +23,7 @@ import glob Import('env') -prefix = env['PYTHON_PREFIX'] + '/'+env['LIB_PLATFORM']+ '/python' + env['PYTHON_VERSION'] + '/site-packages/' +prefix = env['PYTHON_PREFIX'] + '/'+ 'lib' + '/python' + env['PYTHON_VERSION'] + '/site-packages/' libraries = ['mapnik', 'boost_python%s' % env['BOOST_APPEND']] headers = [env['PYTHON_PREFIX'] + '/include/python' + env['PYTHON_VERSION']] + env['CPPPATH'] @@ -36,7 +36,7 @@ inputpluginspath = mapniklibpath + '/input' fontscollectionpath = mapniklibpath + '/fonts' """ -file('mapnik/paths.py','w').write(paths % (env['PREFIX'] + '/'+env['LIB_PLATFORM']+'/mapnik',)) +file('mapnik/paths.py','w').write(paths % (env['PREFIX'] + '/'+env['LIBDIR_SCHEMA']+'/mapnik',)) pymapnik = glob.glob('mapnik/*.py') env.Alias(target='install', source=env.Install(prefix+'/mapnik', pymapnik)) diff --git a/bindings/python/mapnik/__init__.py b/bindings/python/mapnik/__init__.py index 099fa5387..5205a804c 100644 --- a/bindings/python/mapnik/__init__.py +++ b/bindings/python/mapnik/__init__.py @@ -59,10 +59,10 @@ class _Envelope(Envelope,_injector): return 'Envelope(%s,%s,%s,%s)' % \ (self.minx,self.miny,self.maxx,self.maxy) -def Layer (**keywords): - return CreateLayer(keywords) - - +def Datasource (**keywords): + return CreateDatasource(keywords) + + #register datasources from mapnik import DatasourceCache DatasourceCache.instance().register_datasources('%s' % inputpluginspath) diff --git a/bindings/python/mapnik_color.cpp b/bindings/python/mapnik_color.cpp index ae185efc8..04923a550 100644 --- a/bindings/python/mapnik_color.cpp +++ b/bindings/python/mapnik_color.cpp @@ -23,8 +23,8 @@ #include -#include -#include +#include +#include using mapnik::Color; using mapnik::color_factory; diff --git a/bindings/python/mapnik_datasource_cache.cpp b/bindings/python/mapnik_datasource_cache.cpp index 29ec61c98..efe67683e 100644 --- a/bindings/python/mapnik_datasource_cache.cpp +++ b/bindings/python/mapnik_datasource_cache.cpp @@ -23,7 +23,7 @@ //$Id$ #include -#include "datasource_cache.hpp" +#include void export_datasource_cache() { diff --git a/bindings/python/mapnik_envelope.cpp b/bindings/python/mapnik_envelope.cpp index 836cbc095..41d25892f 100644 --- a/bindings/python/mapnik_envelope.cpp +++ b/bindings/python/mapnik_envelope.cpp @@ -22,7 +22,7 @@ //$Id: mapnik_envelope.cc 27 2005-03-30 21:45:40Z pavlenko $ #include -#include +#include using mapnik::coord; using mapnik::Envelope; diff --git a/bindings/python/mapnik_filter.cpp b/bindings/python/mapnik_filter.cpp index 12271cc25..aa80d28cd 100644 --- a/bindings/python/mapnik_filter.cpp +++ b/bindings/python/mapnik_filter.cpp @@ -22,12 +22,13 @@ //$Id$ #include -#include -#include -#include -#include -#include -#include + +#include +#include +#include +#include +#include +#include using mapnik::filter; using mapnik::filter_ptr; diff --git a/bindings/python/mapnik_font_engine.cpp b/bindings/python/mapnik_font_engine.cpp index 2591e46c0..d48decae2 100644 --- a/bindings/python/mapnik_font_engine.cpp +++ b/bindings/python/mapnik_font_engine.cpp @@ -22,7 +22,7 @@ //$Id$ #include -#include +#include void export_font_engine() { diff --git a/bindings/python/mapnik_image.cpp b/bindings/python/mapnik_image.cpp index 141b2a734..63b2f1616 100644 --- a/bindings/python/mapnik_image.cpp +++ b/bindings/python/mapnik_image.cpp @@ -24,14 +24,11 @@ #include #include #include -#include +#include using mapnik::Image32; - - using namespace boost::python; - PyObject* rawdata( Image32 const& im) { int size = im.width() * im.height() * 4; diff --git a/bindings/python/mapnik_layer.cpp b/bindings/python/mapnik_layer.cpp index 04cd2d601..20ccb7ee5 100644 --- a/bindings/python/mapnik_layer.cpp +++ b/bindings/python/mapnik_layer.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include using mapnik::Layer; using mapnik::parameters; diff --git a/bindings/python/mapnik_line_pattern_symbolizer.cpp b/bindings/python/mapnik_line_pattern_symbolizer.cpp index 50b357a8e..f0de960c2 100644 --- a/bindings/python/mapnik_line_pattern_symbolizer.cpp +++ b/bindings/python/mapnik_line_pattern_symbolizer.cpp @@ -22,7 +22,7 @@ //$Id$ #include -#include +#include using mapnik::line_pattern_symbolizer; diff --git a/bindings/python/mapnik_line_symbolizer.cpp b/bindings/python/mapnik_line_symbolizer.cpp index b3799c33b..8e8feefb8 100644 --- a/bindings/python/mapnik_line_symbolizer.cpp +++ b/bindings/python/mapnik_line_symbolizer.cpp @@ -22,7 +22,7 @@ //$Id$ #include -#include +#include using mapnik::line_symbolizer; using mapnik::stroke; diff --git a/bindings/python/mapnik_map.cpp b/bindings/python/mapnik_map.cpp index 062dfa6a7..3e42f8da0 100644 --- a/bindings/python/mapnik_map.cpp +++ b/bindings/python/mapnik_map.cpp @@ -26,8 +26,8 @@ #include #include -#include -#include +#include +#include using mapnik::Color; using mapnik::coord; diff --git a/bindings/python/mapnik_parameters.cpp b/bindings/python/mapnik_parameters.cpp index 5945dcd68..c437f5189 100644 --- a/bindings/python/mapnik_parameters.cpp +++ b/bindings/python/mapnik_parameters.cpp @@ -23,7 +23,7 @@ #include #include -#include +#include using mapnik::parameter; using mapnik::parameters; diff --git a/bindings/python/mapnik_point_symbolizer.cpp b/bindings/python/mapnik_point_symbolizer.cpp index 4e6f01ddb..66621d0ab 100644 --- a/bindings/python/mapnik_point_symbolizer.cpp +++ b/bindings/python/mapnik_point_symbolizer.cpp @@ -22,7 +22,7 @@ //$Id$ #include -#include +#include void export_point_symbolizer() { diff --git a/bindings/python/mapnik_polygon_pattern_symbolizer.cpp b/bindings/python/mapnik_polygon_pattern_symbolizer.cpp index 59805959d..e76081b54 100644 --- a/bindings/python/mapnik_polygon_pattern_symbolizer.cpp +++ b/bindings/python/mapnik_polygon_pattern_symbolizer.cpp @@ -22,7 +22,7 @@ //$Id$ #include -#include +#include void export_polygon_pattern_symbolizer() { diff --git a/bindings/python/mapnik_polygon_symbolizer.cpp b/bindings/python/mapnik_polygon_symbolizer.cpp index 4b3722ca7..b61f1d95e 100644 --- a/bindings/python/mapnik_polygon_symbolizer.cpp +++ b/bindings/python/mapnik_polygon_symbolizer.cpp @@ -22,7 +22,7 @@ //$Id$ #include -#include +#include void export_polygon_symbolizer() { diff --git a/bindings/python/mapnik_python.cpp b/bindings/python/mapnik_python.cpp index b159da536..11866ee05 100644 --- a/bindings/python/mapnik_python.cpp +++ b/bindings/python/mapnik_python.cpp @@ -47,12 +47,12 @@ void export_raster_symbolizer(); void export_text_symbolizer(); void export_font_engine(); -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include void render_to_file(const mapnik::Map& map, const std::string& file, diff --git a/bindings/python/mapnik_query.cpp b/bindings/python/mapnik_query.cpp index becc48ef3..9b5373f95 100644 --- a/bindings/python/mapnik_query.cpp +++ b/bindings/python/mapnik_query.cpp @@ -22,7 +22,7 @@ //$Id$ #include -#include +#include void export_query() { diff --git a/bindings/python/mapnik_raster_symbolizer.cpp b/bindings/python/mapnik_raster_symbolizer.cpp index af879247a..b3458efc8 100644 --- a/bindings/python/mapnik_raster_symbolizer.cpp +++ b/bindings/python/mapnik_raster_symbolizer.cpp @@ -22,7 +22,7 @@ //$Id$ #include -#include +#include void export_raster_symbolizer() { diff --git a/bindings/python/mapnik_rule.cpp b/bindings/python/mapnik_rule.cpp index 58d3d6844..38d9054f3 100644 --- a/bindings/python/mapnik_rule.cpp +++ b/bindings/python/mapnik_rule.cpp @@ -21,12 +21,11 @@ *****************************************************************************/ //$Id$ - #include #include #include -#include +#include void export_rule() { @@ -45,7 +44,7 @@ void export_rule() using mapnik::text_symbolizer; using mapnik::symbolizer; using mapnik::symbolizers; - + implicitly_convertible(); implicitly_convertible(); diff --git a/bindings/python/mapnik_stroke.cpp b/bindings/python/mapnik_stroke.cpp index 3e8789310..890d4475b 100644 --- a/bindings/python/mapnik_stroke.cpp +++ b/bindings/python/mapnik_stroke.cpp @@ -22,7 +22,8 @@ //$Id$ #include -#include + +#include void export_stroke () { diff --git a/bindings/python/mapnik_style.cpp b/bindings/python/mapnik_style.cpp index 3fe4924d0..0156bb966 100644 --- a/bindings/python/mapnik_style.cpp +++ b/bindings/python/mapnik_style.cpp @@ -23,7 +23,8 @@ #include #include -#include + +#include void export_style() { diff --git a/bindings/python/mapnik_text_symbolizer.cpp b/bindings/python/mapnik_text_symbolizer.cpp index b1d348ffd..5440a25a7 100644 --- a/bindings/python/mapnik_text_symbolizer.cpp +++ b/bindings/python/mapnik_text_symbolizer.cpp @@ -22,7 +22,8 @@ //$Id$ #include -#include + +#include void export_text_symbolizer() { diff --git a/demo/c++/rundemo.cpp b/demo/c++/rundemo.cpp index 888bfaa15..6c834ad0b 100644 --- a/demo/c++/rundemo.cpp +++ b/demo/c++/rundemo.cpp @@ -21,14 +21,13 @@ *****************************************************************************/ // $Id$ -#include - -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include @@ -231,7 +230,8 @@ int main ( int argc , char** argv) m.addLayer(lyr); } - m.zoomToBox(Envelope(1405120.04127408,-247003.813399447,1706357.31328276,-25098.593149577)); + m.zoomToBox(Envelope(1405120.04127408,-247003.813399447, + 1706357.31328276,-25098.593149577)); Image32 buf(m.getWidth(),m.getHeight()); agg_renderer ren(m,buf); diff --git a/fonts/SConscript b/fonts/SConscript index d4e63f396..01a24726b 100644 --- a/fonts/SConscript +++ b/fonts/SConscript @@ -24,4 +24,4 @@ Import('env') prefix = env['PREFIX'] includes = glob.glob('*/*.ttf') -env.Alias(target='install', source=env.Install(prefix+'/' + env['LIB_PLATFORM'] + '/mapnik/fonts', includes)) +env.Alias(target='install', source=env.Install(prefix+'/' + env['LIBDIR_SCHEMA'] + '/mapnik/fonts', includes)) diff --git a/include/attribute.hpp b/include/attribute.hpp deleted file mode 100644 index 2195f47f2..000000000 --- a/include/attribute.hpp +++ /dev/null @@ -1,222 +0,0 @@ -/***************************************************************************** - * - * This file is part of Mapnik (c++ mapping toolkit) - * - * Copyright (C) 2006 Artem Pavlenko - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - *****************************************************************************/ - -//$Id: attribute.hpp 41 2005-04-13 20:21:56Z pavlenko $ - -#ifndef ATTRIBUTE_HPP -#define ATTRIBUTE_HPP - -#include -#include -#include -#include - - -namespace mapnik -{ - template - struct attribute_traits - { - static std::string to_string(const T& value) - { - std::stringstream ss; - ss << value; - return ss.str(); - } - }; - - template <> - struct attribute_traits - { - static std::string to_string(const std::string& value) - { - return value; - } - }; - - class MAPNIK_DECL attribute - { - public: - attribute() - : base_(0) {} - - template - attribute(const T& value) - : base_(new attribute_impl(value)) - {} - - attribute(const attribute& rhs) - : base_(rhs.base_ ? rhs.base_->clone() : 0) - {} - - ~attribute() - { - delete base_; - } - - template - attribute& operator=(const T& rhs) - { - attribute(rhs).swap(*this); - return *this; - } - - attribute& operator=(const attribute& rhs) - { - attribute(rhs).swap(*this); - return *this; - } - - bool empty() const - { - return !base_; - } - - const std::type_info & type() const - { - return base_ ? base_->type() : typeid(void); - } - - const std::string to_string() const - { - return base_ ? base_->to_string() : ""; - } - private: - attribute& swap(attribute& rhs) - { - std::swap(base_,rhs.base_); - return *this; - } - - class attribute_base - { - public: - virtual ~attribute_base() {} - virtual attribute_base* clone() const=0; - virtual std::string to_string() const=0; - virtual const std::type_info& type() const=0; - }; - - template > - class attribute_impl : public attribute_base - { - public: - typedef T value_type; - attribute_impl(const value_type& value) - : value_(value) {} - - virtual std::string to_string() const - { - return ATraits::to_string(value_); - } - - virtual attribute_base* clone() const - { - return new attribute_impl(value_); - } - virtual const std::type_info& type() const - { - return typeid(value_); - } - value_type value_; - }; - private: - template - friend value_type* attribute_cast(attribute*); - attribute_base* base_; - }; - - - template - struct bad_attribute_cast : public std::bad_cast - { - virtual const char* what() const throw() - { - return "attribute::failed conversion"; - } - }; - - template - bool is_type(const attribute& attr) - { - return attr.type()==typeid(T); - } - - template - T* attribute_cast(attribute* attr) - { - return attr && attr->type() == typeid(T) - ? &static_cast*>(attr->base_)->value_ - : 0; - } - - template - const T* attribute_cast(const attribute* attr) - { - return attribute_cast(const_cast(attr)); - } - - template - T attribute_cast(const attribute& attr) - { - using namespace boost; - typedef BOOST_DEDUCED_TYPENAME remove_reference::type nonref; - const nonref * result=attribute_cast(&attr); - if (!result) - { - throw bad_attribute_cast(); - } - return *result; - } - - template - T attribute_cast(attribute& attr) - { - using namespace boost; - typedef BOOST_DEDUCED_TYPENAME remove_reference::type nonref; - nonref * result=attribute_cast(&attr); - if (!result) - throw bad_attribute_cast(); - return *result; - } - - - template - attribute attribute_from_string(const std::string& val) - { - std::istringstream is(val); - T t; - is >> t; - return attribute(t); - } - - template - inline std::basic_ostream& - operator << (std::basic_ostream& out, - const attribute& attr) - { - out << attr.to_string(); - return out; - } -} - -#endif //ATTRIBUTE_HPP diff --git a/include/attribute_collector.hpp b/include/attribute_collector.hpp deleted file mode 100644 index 53bb696f1..000000000 --- a/include/attribute_collector.hpp +++ /dev/null @@ -1,98 +0,0 @@ -/***************************************************************************** - * - * This file is part of Mapnik (c++ mapping toolkit) - * - * Copyright (C) 2006 Artem Pavlenko - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - *****************************************************************************/ - -//$Id$ - -#ifndef ATTRIBUTE_COLLECTOR_HPP -#define ATTRIBUTE_COLLECTOR_HPP - -#include "filter.hpp" -#include "expression.hpp" -#include "feature_layer_desc.hpp" -#include "rule.hpp" -#include -#include - -namespace mapnik -{ - - struct symbolizer_attributes : public boost::static_visitor<> - { - symbolizer_attributes(std::set& names) - : names_(names) {} - - template - void operator () (T const&) const {} - void operator () (text_symbolizer const& sym) - { - names_.insert(sym.get_name()); - } - private: - std::set& names_; - }; - - template - class attribute_collector : public filter_visitor - { - private: - std::set& names_; - public: - - attribute_collector(std::set& names) - : names_(names) {} - - void visit(filter& /*filter*/) - { - //not interested - } - - void visit(expression& exp) - { - property* pf; - if ((pf = dynamic_cast*>(&exp))) - { - names_.insert(pf->name()); - } - } - void visit(rule_type const& r) - { - const symbolizers& symbols = r.get_symbolizers(); - symbolizers::const_iterator symIter=symbols.begin(); - symbolizer_attributes attr(names_); - while (symIter != symbols.end()) - { - boost::apply_visitor(attr,*symIter++); - } - filter_ptr const& filter = r.get_filter(); - filter->accept(*this); - } - - virtual ~attribute_collector() {} - private: - - // no copying - attribute_collector(attribute_collector const&); - attribute_collector& operator=(attribute_collector const&); - }; -} - -#endif //ATTRIBUTE_COLLECTOR_HPP diff --git a/include/comparison.hpp b/include/comparison.hpp deleted file mode 100644 index aa63fbb0e..000000000 --- a/include/comparison.hpp +++ /dev/null @@ -1,153 +0,0 @@ -/***************************************************************************** - * - * This file is part of Mapnik (c++ mapping toolkit) - * - * Copyright (C) 2006 Artem Pavlenko - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - *****************************************************************************/ -//$Id$ - -#ifndef COMPARISON_HPP -#define COMPARISON_HPP - - -#include "filter.hpp" -#include "expression.hpp" -#include "attribute.hpp" - -#include - -namespace mapnik -{ - template - struct greater_than - { - bool operator() (T const& left, T const& right) const - { - return left > right; - } - static std::string to_string() - { - return ">"; - } - }; - - template - struct greater_than_or_equal - { - bool operator() (T const& left, T const& right) const - { - return left >= right; - } - static std::string to_string() - { - return ">="; - } - }; - template - struct less_than - { - bool operator() (T const& left, T const& right) const - { - return left < right; - } - static std::string to_string() - { - return "<"; - } - }; - template - struct less_than_or_equal - { - bool operator() (T const& left, T const& right) const - { - return left <= right; - } - static std::string to_string() - { - return "<="; - } - }; - template - struct equals - { - bool operator() (T const& left, T const& right) const - { - return left == right; - } - static std::string to_string() - { - return "="; - } - }; - - template - struct not_equals - { - bool operator() (T const& left, T const& right) const - { - return left != right; - } - static std::string to_string() - { - return "<>"; - } - }; - - template - struct compare_filter : public filter - { - compare_filter(expression const& left, - expression const& right) - : filter(), - left_(left.clone()), right_(right.clone()) {} - - compare_filter(compare_filter const& other) - : filter(), - left_(other.left_->clone()),right_(other.right_->clone()) {} - - bool pass(const FeatureT& feature) const - { - return Op()(left_->get_value(feature),right_->get_value(feature)); - } - void accept(filter_visitor& v) - { - left_->accept(v); - right_->accept(v); - v.visit(*this); - } - std::string to_string() const - { - return "("+left_->to_string()+Op::to_string()+right_->to_string()+")"; - } - - filter* clone() const - { - return new compare_filter(*this); - } - virtual ~compare_filter() - { - delete left_; - delete right_; - } - private: - expression* left_; - expression* right_; - }; -} - -#endif //COMPARISON_HPP diff --git a/include/coord_array.hpp b/include/coord_array.hpp deleted file mode 100644 index 8a4ab745d..000000000 --- a/include/coord_array.hpp +++ /dev/null @@ -1,92 +0,0 @@ -/***************************************************************************** - * - * This file is part of Mapnik (c++ mapping toolkit) - * - * Copyright (C) 2006 Artem Pavlenko - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - *****************************************************************************/ - -//$Id: coord_array.hpp 39 2005-04-10 20:39:53Z pavlenko $ - -#ifndef COORD_ARRAY_HPP -#define COORD_ARRAY_HPP - -#include "coord.hpp" -#include - -namespace mapnik -{ - - template - class coord_array - { - typedef T coord_type; - coord_type* pt_; - const unsigned size_; - public: - coord_array(unsigned size=0) - : pt_(static_cast(size==0?0: ::operator new (sizeof(coord_type)*size))), - size_(size) {} - - coord_array(const coord_array& rhs) - : pt_(static_cast(rhs.size_==0?0: ::operator new (sizeof(coord_type)*rhs.size_))), - size_(rhs.size_) { - memcpy(pt_,rhs.pt_,sizeof(coord_type)*rhs.size_); - } - - ~coord_array() - { - ::operator delete (pt_); - } - - unsigned size() const - { - return size_; - } - - void set(unsigned index,double x,double y) - { - assert(index -#include - -using namespace boost::spirit; - -namespace mapnik -{ - template - struct named_colors : public symbols - { - named_colors() - { - symbols::add - ("aliceblue", ColorT(240, 248, 255)) - ("antiquewhite", ColorT(250, 235, 215)) - ("aqua", ColorT(0, 255, 255)) - ("aquamarine", ColorT(127, 255, 212)) - ("azure", ColorT(240, 255, 255)) - ("beige", ColorT(245, 245, 220)) - ("bisque", ColorT(255, 228, 196)) - ("black", ColorT(0, 0, 0)) - ("blanchedalmond", ColorT(255,235,205)) - ("blue", ColorT(0, 0, 255)) - ("blueviolet", ColorT(138, 43, 226)) - ("brown", ColorT(165, 42, 42)) - ("burlywood", ColorT(222, 184, 135)) - ("cadetblue", ColorT(95, 158, 160)) - ("chartreuse", ColorT(127, 255, 0)) - ("chocolate", ColorT(210, 105, 30)) - ("coral", ColorT(255, 127, 80)) - ("cornflowerblue", ColorT(100, 149, 237)) - ("cornsilk", ColorT(255, 248, 220)) - ("crimson", ColorT(220, 20, 60)) - ("cyan", ColorT(0, 255, 255)) - ("darkblue", ColorT(0, 0, 139)) - ("darkcyan", ColorT(0, 139, 139)) - ("darkgoldenrod", ColorT(184, 134, 11)) - ("darkgray", ColorT(169, 169, 169)) - ("darkgreen", ColorT(0, 100, 0)) - ("darkgrey", ColorT(169, 169, 169)) - ("darkkhaki", ColorT(189, 183, 107)) - ("darkmagenta", ColorT(139, 0, 139)) - ("darkolivegreen", ColorT(85, 107, 47)) - ("darkorange", ColorT(255, 140, 0)) - ("darkorchid", ColorT(153, 50, 204)) - ("darkred", ColorT(139, 0, 0)) - ("darksalmon", ColorT(233, 150, 122)) - ("darkseagreen", ColorT(143, 188, 143)) - ("darkslateblue", ColorT(72, 61, 139)) - ("darkslategrey", ColorT(47, 79, 79)) - ("darkturquoise", ColorT(0, 206, 209)) - ("darkviolet", ColorT(148, 0, 211)) - ("deeppink", ColorT(255, 20, 147)) - ("deepskyblue", ColorT(0, 191, 255)) - ("dimgray", ColorT(105, 105, 105)) - ("dimgrey", ColorT(105, 105, 105)) - ("dodgerblue", ColorT(30, 144, 255)) - ("firebrick", ColorT(178, 34, 34)) - ("floralwhite", ColorT(255, 250, 240)) - ("forestgreen", ColorT(34, 139, 34)) - ("fuchsia", ColorT(255, 0, 255)) - ("gainsboro", ColorT(220, 220, 220)) - ("ghostwhite", ColorT(248, 248, 255)) - ("gold", ColorT(255, 215, 0)) - ("goldenrod", ColorT(218, 165, 32)) - ("gray", ColorT(128, 128, 128)) - ("grey", ColorT(128, 128, 128)) - ("green", ColorT(0, 128, 0)) - ("greenyellow", ColorT(173, 255, 47)) - ("honeydew", ColorT(240, 255, 240)) - ("hotpink", ColorT(255, 105, 180)) - ("indianred", ColorT(205, 92, 92)) - ("indigo", ColorT(75, 0, 130)) - ("ivory", ColorT(255, 255, 240)) - ("khaki", ColorT(240, 230, 140)) - ("lavender", ColorT(230, 230, 250)) - ("lavenderblush", ColorT(255, 240, 245)) - ("lawngreen", ColorT(124, 252, 0)) - ("lemonchiffon", ColorT(255, 250, 205)) - ("lightblue", ColorT(173, 216, 230)) - ("lightcoral", ColorT(240, 128, 128)) - ("lightcyan", ColorT(224, 255, 255)) - ("lightgoldenrodyellow", ColorT(250, 250, 210)) - ("lightgray", ColorT(211, 211, 211)) - ("lightgreen", ColorT(144, 238, 144)) - ("lightgrey", ColorT(211, 211, 211)) - ("lightpink", ColorT(255, 182, 193)) - ("lightsalmon", ColorT(255, 160, 122)) - ("lightseagreen", ColorT(32, 178, 170)) - ("lightskyblue", ColorT(135, 206, 250)) - ("lightslategray", ColorT(119, 136, 153)) - ("lightslategrey", ColorT(119, 136, 153)) - ("lightsteelblue", ColorT(176, 196, 222)) - ("lightyellow", ColorT(255, 255, 224)) - ("lime", ColorT(0, 255, 0)) - ("limegreen", ColorT(50, 205, 50)) - ("linen", ColorT(250, 240, 230)) - ("magenta", ColorT(255, 0, 255)) - ("maroon", ColorT(128, 0, 0)) - ("mediumaquamarine", ColorT(102, 205, 170)) - ("mediumblue", ColorT(0, 0, 205)) - ("mediumorchid", ColorT(186, 85, 211)) - ("mediumpurple", ColorT(147, 112, 219)) - ("mediumseagreen", ColorT(60, 179, 113)) - ("mediumslateblue", ColorT(123, 104, 238)) - ("mediumspringgreen", ColorT(0, 250, 154)) - ("mediumturquoise", ColorT(72, 209, 204)) - ("mediumvioletred", ColorT(199, 21, 133)) - ("midnightblue", ColorT(25, 25, 112)) - ("mintcream", ColorT(245, 255, 250)) - ("mistyrose", ColorT(255, 228, 225)) - ("moccasin", ColorT(255, 228, 181)) - ("navajowhite", ColorT(255, 222, 173)) - ("navy", ColorT(0, 0, 128)) - ("oldlace", ColorT(253, 245, 230)) - ("olive", ColorT(128, 128, 0)) - ("olivedrab", ColorT(107, 142, 35)) - ("orange", ColorT(255, 165, 0)) - ("orangered", ColorT(255, 69, 0)) - ("orchid", ColorT(218, 112, 214)) - ("palegoldenrod", ColorT(238, 232, 170)) - ("palegreen", ColorT(152, 251, 152)) - ("paleturquoise", ColorT(175, 238, 238)) - ("palevioletred", ColorT(219, 112, 147)) - ("papayawhip", ColorT(255, 239, 213)) - ("peachpuff", ColorT(255, 218, 185)) - ("peru", ColorT(205, 133, 63)) - ("pink", ColorT(255, 192, 203)) - ("plum", ColorT(221, 160, 221)) - ("powderblue", ColorT(176, 224, 230)) - ("purple", ColorT(128, 0, 128)) - ("red", ColorT(255, 0, 0)) - ("rosybrown", ColorT(188, 143, 143)) - ("royalblue", ColorT(65, 105, 225)) - ("saddlebrown", ColorT(139, 69, 19)) - ("salmon", ColorT(250, 128, 114)) - ("sandybrown", ColorT(244, 164, 96)) - ("seagreen", ColorT(46, 139, 87)) - ("seashell", ColorT(255, 245, 238)) - ("sienna", ColorT(160, 82, 45)) - ("silver", ColorT(192, 192, 192)) - ("skyblue", ColorT(135, 206, 235)) - ("slateblue", ColorT(106, 90, 205)) - ("slategray", ColorT(112, 128, 144)) - ("slategrey", ColorT(112, 128, 144)) - ("snow", ColorT(255, 250, 250)) - ("springgreen", ColorT(0, 255, 127)) - ("steelblue", ColorT(70, 130, 180)) - ("tan", ColorT(210, 180, 140)) - ("teal", ColorT(0, 128, 128)) - ("thistle", ColorT(216, 191, 216)) - ("tomato", ColorT(255, 99, 71)) - ("turquoise", ColorT(64, 224, 208)) - ("violet", ColorT(238, 130, 238)) - ("wheat", ColorT(245, 222, 179)) - ("white", ColorT(255, 255, 255)) - ("whitesmoke", ColorT(245, 245, 245)) - ("yellow", ColorT(255, 255, 0)) - ("yellowgreen", ColorT(154, 205, 50)) - ; - } - }; - - template - struct css_color_grammar : public grammar > - { - css_color_grammar(ActionsT& actions_) - : actions(actions_) {} - - template - struct definition - { - definition(css_color_grammar const& self) - { - hex6 = ch_p('#') >> uint6x_p[self.actions.hex6_]; - hex3 = ch_p('#') >> uint3x_p[self.actions.hex3_]; - rgb = str_p("rgb") >> '(' >> uint3_p[self.actions.red_] - >> ',' >> uint3_p[self.actions.green_] - >> ',' >> uint3_p[self.actions.blue_] - >> ')'; - rgb_percent = str_p("rgb") >> '(' >> ureal_p[self.actions.red_p_] >> '%' - >> ',' >> ureal_p[self.actions.green_p_] >> '%' - >> ',' >> ureal_p[self.actions.blue_p_] >> '%' - >> ')'; - css_color = named_colors_p[self.actions.named_] | hex6 | hex3 | rgb_percent | rgb; - } - boost::spirit::rule rgb; - boost::spirit::rule rgb_percent; - boost::spirit::rule hex6; - boost::spirit::rule hex3; - boost::spirit::rule css_color; - boost::spirit::rule const& start() const - { - return css_color; - } - uint_parser uint3_p; - uint_parser uint6x_p; - uint_parser uint3x_p; - named_colors named_colors_p; - - }; - ActionsT& actions; - }; - - template - struct named_color_action - { - named_color_action(ColorT& c) - : c_(c) {} - - void operator() (ColorT const&c) const - { - c_=c; - } - ColorT& c_; - }; - - template - struct hex6_action - { - hex6_action(ColorT& c) - : c_(c) {} - - void operator () (unsigned int hex) const - { - unsigned r = (hex >> 16) & 0xff; - unsigned g = (hex >> 8) & 0xff; - unsigned b = hex & 0xff; - c_.set_red(r); - c_.set_green(g); - c_.set_blue(b); - } - ColorT& c_; - }; - - template - struct hex3_action - { - hex3_action(ColorT& c) - : c_(c) {} - - void operator () (unsigned int hex) const - { - unsigned int r = (hex >> 8) & 0xf; - unsigned int g = (hex >> 4) & 0xf; - unsigned int b = hex & 0xf; - c_.set_red( r | r << 4); - c_.set_green(g | g << 4); - c_.set_blue(b | b << 4); - } - ColorT& c_; - }; - - template - struct red_action - { - red_action(ColorT& c) - : c_(c) {} - - void operator () (unsigned int r) const - { - c_.set_red(r); - } - ColorT& c_; - }; - - template - struct green_action - { - green_action(ColorT& c) - : c_(c) {} - - void operator () (unsigned int g) const - { - c_.set_green(g); - } - ColorT& c_; - }; - - template - struct blue_action - { - blue_action(ColorT& c) - : c_(c) {} - - void operator () (unsigned int b) const - { - c_.set_blue(b); - } - ColorT& c_; - }; - - - template - struct red_action_p - { - red_action_p(ColorT& c) - : c_(c) {} - - void operator () (double r) const - { - c_.set_red(unsigned((255.0 * r)/100.0 + 0.5)); - } - ColorT& c_; - }; - - template - struct green_action_p - { - green_action_p(ColorT& c) - : c_(c) {} - - void operator () (double g) const - { - c_.set_green(unsigned((255.0 * g)/100.0 + 0.5)); - } - ColorT& c_; - }; - - template - struct blue_action_p - { - blue_action_p(ColorT& c) - : c_(c) {} - - void operator () (double b) const - { - c_.set_blue(unsigned((255.0 * b)/100.0 + 0.5)); - } - ColorT& c_; - }; - - - template - struct actions - { - typedef ColorT color_type; - actions(ColorT& c) - : named_(c), - hex6_(c), - hex3_(c), - red_(c), - green_(c), - blue_(c), - red_p_(c), - green_p_(c), - blue_p_(c) {} - - named_color_action named_; - hex6_action hex6_; - hex3_action hex3_; - red_action red_; - green_action green_; - blue_action blue_; - red_action_p red_p_; - green_action_p green_p_; - blue_action_p blue_p_; - }; -} - -#endif //CSS_COLOR_PARSER_HPP diff --git a/include/ctrans.hpp b/include/ctrans.hpp deleted file mode 100644 index 937ccd1d5..000000000 --- a/include/ctrans.hpp +++ /dev/null @@ -1,169 +0,0 @@ -/***************************************************************************** - * - * This file is part of Mapnik (c++ mapping toolkit) - * - * Copyright (C) 2006 Artem Pavlenko - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - *****************************************************************************/ - -//$Id: ctrans.hpp 39 2005-04-10 20:39:53Z pavlenko $ - -#ifndef CTRANS_HPP -#define CTRANS_HPP - -#include "envelope.hpp" -#include "coord_array.hpp" - -namespace mapnik -{ - typedef coord_array CoordinateArray; - - template - struct MAPNIK_DECL coord_transform - { - coord_transform(Transform const& t,Geometry& geom) - : t_(t), geom_(geom) {} - - unsigned vertex(double *x , double *y) const - { - unsigned command = geom_.vertex(x,y); - *x = t_.forward_x_(x); - *y = t_.forward_y_(y); - return command; - } - void rewind (unsigned pos) - { - geom_.rewind(pos); - } - - private: - Transform const& t_; - Geometry& geom_; - }; - - class CoordTransform - { - private: - int width; - int height; - double scale_; - Envelope extent; - public: - CoordTransform(int width,int height,const Envelope& extent) - :width(width),height(height),extent(extent) - { - double sx=((double)width)/extent.width(); - double sy=((double)height)/extent.height(); - scale_=std::min(sx,sy); - } - - inline double scale() const - { - return scale_; - } - - inline void forward_x(double* x) const - { - *x = (*x - extent.minx() ) * scale_; - } - - inline void forward_y(double* y) const - { - *y = (extent.maxy() - *y) * scale_; - } - - inline double forward_x_(double* x) const - { - return (*x - extent.minx() ) * scale_; - } - - inline double forward_y_(double* y) const - { - return (extent.maxy() - *y) * scale_; - } - - inline void backward_x(double* x) const - { - *x = extent.minx() + *x/scale_; - } - - inline void backward_y(double* y) const - { - *y = extent.maxy() - *y/scale_; - } - - inline coord2d& forward(coord2d& c) const - { - forward_x(&c.x); - forward_y(&c.y); - return c; - } - - inline coord2d& backward(coord2d& c) const - { - backward_x(&c.x); - backward_y(&c.y); - return c; - } - - inline Envelope forward(const Envelope& e) const - { - double x0 = e.minx(); - double y0 = e.miny(); - double x1 = e.maxx(); - double y1 = e.maxy(); - forward_x(&x0); - forward_y(&y0); - forward_x(&x1); - forward_y(&y1); - return Envelope(x0,y0,x1,y1); - } - - inline Envelope backward(const Envelope& e) const - { - double x0 = e.minx(); - double y0 = e.miny(); - double x1 = e.maxx(); - double y1 = e.maxy(); - backward_x(&x0); - backward_y(&y0); - backward_x(&x1); - backward_y(&y1); - - return Envelope(x0,y0,x1,y1); - } - - inline CoordinateArray& forward(CoordinateArray& coords) const - { - for (unsigned i=0;i class filter_visitor; - template - class expression - { - public: - virtual value get_value(FeatureT const& feature) const=0; - virtual void accept(filter_visitor& v)=0; - virtual expression* clone() const=0; - virtual std::string to_string() const=0; - virtual ~expression() {} - }; - - template - class literal : public expression - { - public: - literal(int val) - : expression(), - value_(val) {} - literal(double val) - : expression(), - value_(val) {} - literal(std::string const& val) - : expression(), - value_(val) {} - literal(literal const& other) - : expression(), - value_(other.value_) {} - - value get_value(FeatureT const& /*feature*/) const - { - return value_; - } - void accept(filter_visitor& v) - { - v.visit(*this); - } - expression* clone() const - { - return new literal(*this); - } - std::string to_string() const - { - return value_.to_expression_string(); - } - ~literal() {} - private: - value value_; - }; - - - template - class property : public expression - { - public: - property(std::string const& name) - : expression(), - name_(name) - {} - - property(property const& other) - : expression(), - name_(other.name_) - {} - - value get_value(FeatureT const& feature) const - { - return feature[name_]; - } - void accept(filter_visitor& v) - { - v.visit(*this); - } - expression* clone() const - { - return new property(*this); - } - std::string const& name() const - { - return name_; - } - - std::string to_string() const - { - return "["+name_+"]"; - } - - ~property() {} - - private: - std::string name_; - }; -} - -#endif //EXPRESSION_HPP diff --git a/include/feature.hpp b/include/feature.hpp deleted file mode 100644 index 38d9e8c02..000000000 --- a/include/feature.hpp +++ /dev/null @@ -1,118 +0,0 @@ -/***************************************************************************** - * - * This file is part of Mapnik (c++ mapping toolkit) - * - * Copyright (C) 2006 Artem Pavlenko - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - *****************************************************************************/ - -//$Id: feature.hpp 40 2005-04-13 20:20:46Z pavlenko $ - -#ifndef FEATURE_HPP -#define FEATURE_HPP - -#include "geometry.hpp" -#include "raster.hpp" -#include "value.hpp" -#include - -#include -#include - -namespace mapnik -{ - typedef boost::shared_ptr raster_ptr; - //typedef std::vector properties; - typedef boost::associative_property_map > properties; - - template - struct feature : public properties, - private boost::noncopyable - { - public: - typedef T1 geometry_type; - typedef T2 raster_type; - private: - int id_; - geometry_type geom_; - raster_type raster_; - std::map props_; - public: - explicit feature(int id) - : properties(props_), - id_(id), - geom_(), - raster_() {} - - feature(int id,const geometry_type& geom) - : properties(props_), - id_(id), - geom_(geom), - raster_() {} - - int id() const - { - return id_; - } - - void set_geometry(geometry_type& geom) - { - geom_=geom; - } - - geometry_type const& get_geometry() const - { - return geom_; - } - - const raster_type& get_raster() const - { - return raster_; - } - void set_raster(raster_type const& raster) - { - raster_=raster; - } - - const properties& get_properties() const - { - return props_; - } - - std::string to_string() const - { - std::stringstream ss; - ss << "feature (" << std::endl; - for (std::map::const_iterator itr=props_.begin(); - itr != props_.end();++itr) - { - ss << " " << itr->first << ":" << itr->second << std::endl; - } - ss << ")" << std::endl; - return ss.str(); - } - }; - - typedef feature Feature; - - inline std::ostream& operator<< (std::ostream & out,Feature const& f) - { - out << f.to_string(); - return out; - } -} -#endif //FEATURE_HPP diff --git a/include/feature_layer_desc.hpp b/include/feature_layer_desc.hpp deleted file mode 100644 index 4e273e9eb..000000000 --- a/include/feature_layer_desc.hpp +++ /dev/null @@ -1,250 +0,0 @@ -/***************************************************************************** - * - * This file is part of Mapnik (c++ mapping toolkit) - * - * Copyright (C) 2006 Artem Pavlenko - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - *****************************************************************************/ - -//$Id$ - -#ifndef FEATURE_LAYER_DESC_HPP -#define FEATURE_LAYER_DESC_HPP - -#include -#include -#include - -namespace mapnik -{ - - using std::string; - using std::vector; - using std::clog; - using std::endl; - - enum { - Integer=1, - Float =2, - Double =3, - String =4, - Geometry=5, - Object=6 - }; - - class attribute_descriptor - { - public: - attribute_descriptor(string const& name,unsigned type, - bool primary_key=false, - int size=-1, - int precision=-1) - : name_(name), - type_(type), - primary_key_(primary_key), - size_(size), - precision_(precision) {} - - attribute_descriptor(attribute_descriptor const& other) - : name_(other.name_), - type_(other.type_), - primary_key_(other.primary_key_), - size_(other.size_), - precision_(other.precision_) {} - - attribute_descriptor& operator=(attribute_descriptor const& other) - { - if (this == &other) - return *this; - name_=other.name_; - type_=other.type_; - primary_key_=other.primary_key_; - size_=other.size_; - precision_=other.precision_; - return *this; - } - string const& get_name() const - { - return name_; - } - unsigned get_type() const - { - return type_; - } - bool is_primary_key() const - { - return primary_key_; - } - int get_size() const - { - return size_; - } - - int get_precision() const - { - return precision_; - } - private: - string name_; - int type_; - bool primary_key_; - int size_; - int precision_; - }; - - template - inline std::basic_ostream& - operator << (std::basic_ostream& out, - attribute_descriptor const& ad) - { - out << "name=" << ad.get_name() << endl; - out << "type=" << ad.get_type() << endl; - out << "size=" << ad.get_size() << endl; - return out; - } - - class layer_descriptor - { - public: - layer_descriptor(string const& name,int srid=-1) - : name_(name), - srid_(srid) {} - - layer_descriptor(layer_descriptor const& other) - : name_(other.name_), - srid_(other.srid_), - desc_ar_(other.desc_ar_) {} - - void set_name(string const& name) - { - name_=name; - } - string const& get_name() const - { - return name_; - } - - void set_srid(int srid) - { - srid_=srid; - } - - int get_srid() const - { - return srid_; - } - - void add_descriptor(attribute_descriptor const& desc) - { - desc_ar_.push_back(desc); - } - - vector const& get_descriptors() const - { - return desc_ar_; - } - vector& get_descriptors() - { - return desc_ar_; - } - private: - string name_; - int srid_; - vector desc_ar_; - }; - - template - inline std::basic_ostream& - operator << (std::basic_ostream& out, - layer_descriptor const& ld) - { - out << "name=" << ld.get_name() << endl; - out << "srid=" << ld.get_srid() << endl; - vector const& desc_ar=ld.get_descriptors(); - vector::const_iterator pos=desc_ar.begin(); - while (pos != desc_ar.end()) - { - out << *pos++ << endl; - - } - return out; - } - /* - bool layer_descriptor_to_wkb(layer_descriptor const& desc,array<>& wkb) - { - //srid - int srid = desc.get_srid(); - wkb.write(&srid,sizeof(int)); - - //attribute descriptors - vector const& desc_ar = desc.get_descriptors(); - vector::const_iterator itr=desc_ar.begin(); - size_t num_desc = desc_ar.size(); - wkb.write(&num_desc,sizeof(int)); - - while (itr != desc_ar.end()) - { - string name = itr->get_name(); - wkb.write(name.c_str(),name.size()+1); - - unsigned type = static_cast(itr->get_type()); - wkb.write(&type,sizeof(unsigned)); - - bool prim_key = itr->is_primary_key(); - wkb.write(&prim_key,sizeof(bool)); - - int size = itr->get_size(); - wkb.write(&size,sizeof(int)); - - ++itr; - } - return true; - } - - bool layer_descriptor_from_wkb(const char* wkb, layer_descriptor &desc) - { - unsigned pos=0; - int srid; - - memcpy(&srid,wkb+pos,sizeof(int)); - desc.set_srid(srid); - pos+=sizeof(int); - - int num_desc; - memcpy(&num_desc,wkb+pos,sizeof(int)); - pos+=sizeof(int); - - for (int i=0;i -#include - -#include - -using namespace std; -using namespace boost::spirit; - -namespace mapnik -{ - struct filter_grammar_ast : public grammar - { - - static const int integerID = 1; - static const int realID = 2; - static const int stringID = 3; - static const int propertyID = 4; - static const int factorID = 5; - static const int termID = 6; - static const int expressionID = 7; - static const int relationID = 8; - static const int equationID = 9; - static const int and_exprID = 10; - static const int or_exprID = 11; - - template - struct definition - { - - definition(filter_grammar_ast const& /*self*/) - { - real = leaf_node_d[strict_real_p]; - integer = leaf_node_d[int_p]; - number = real | integer; - - string_ = inner_node_d['\''>> leaf_node_d[( (alpha_p | '_') >> - * (alnum_p | '_' ))] >> '\'']; - - property = inner_node_d['[' >> leaf_node_d[ ( (alpha_p | '_') >> * (alnum_p | '_' )) ] >> ']']; - - literal = number | string_ | property; - - factor = literal - | (root_node_d[str_p("not")] >> literal) - | inner_node_d[ch_p('(') >> or_expr >> ch_p(')') ] - | (root_node_d[ch_p('-')] >> factor) - ; - - term = factor - >> *((root_node_d[ch_p('*')] >> factor) | (root_node_d[ch_p('/')] >> factor)); - - expression = term >> *((root_node_d[ch_p('+')] >> term) | (root_node_d[ch_p('-')] >> term)); - relation = expression >> *((root_node_d[str_p(">=")] >> expression) - | (root_node_d[ch_p('>')] >> expression) - | (root_node_d[ch_p('<')] >> expression) - | (root_node_d[str_p("<=")] >> expression)); - - equation = relation >> *( (root_node_d[ch_p('=')] >> relation) - | (root_node_d[str_p("<>")] >> relation)); - and_expr = equation >> *(root_node_d[str_p("and")] >> equation); - or_expr = and_expr >> *(root_node_d[str_p("or")] >> and_expr); - - //spatial_op = str_p("Equals") | "Disjoint" | "Touches" | "Within" - // | "Overlaps" | "Crosses" | "Intersects" | "Contains" | "DWithin" | "Beyond" | "BBOX"; - - filter_statement = or_expr; - } - - rule const& start() const - { - return filter_statement; - } - - rule, parser_tag > factor; - rule, parser_tag > term; - rule, parser_tag > expression; - rule, parser_tag > relation; - rule, parser_tag > equation; - - rule, parser_tag > and_expr; - rule, parser_tag > or_expr; - - rule filter_statement; - rule literal,number; - - rule, parser_tag > integer; - rule, parser_tag > real; - rule, parser_tag > string_; - rule, parser_tag > property; - - - //rule spatial_op; - - }; - - }; - - class node_data - { - public: - enum { - Unknown=0, - Integer=1, - Real =2, - String =3, - Property=4 - }; - node_data() - : type_(Unknown) {} - - node_data(int type) - : type_(type) {} - - node_data(node_data const& other) - : type_(other.type_) {} - - node_data& operator=(node_data const& other) - { - if (this==&other) - return *this; - type_=other.type_; - return *this; - } - ~node_data() {} - private: - int type_; - }; - - typedef char const* iterator_t; - typedef node_val_data_factory factory_t; - typedef tree_match::tree_iterator iter_t; - - void process_node(iter_t const&,string&); - - void walk_ast_tree(tree_parse_info info,string& text) - { - process_node(info.trees.begin(),text); - } - - void process_node(iter_t const& i,string& text) - { - //clog << "In eval_expression. i->value = " << - // string(i->value.begin(), i->value.end()) << - // " i->children.size() = " << i->children.size() << endl; - //std::clog<value.id() == filter_grammar_ast::integerID) - { - assert(i->children.size()==0); - string integer(i->value.begin(), i->value.end()); - text+= integer; - } - else if (i->value.id() == filter_grammar_ast::realID) - { - assert(i->children.size()==0); - string real(i->value.begin(), i->value.end()); - text += real; - } - else if (i->value.id() == filter_grammar_ast::stringID) - { - assert(i->children.size()==0); - string str(i->value.begin(), i->value.end()); - text += str; - } - else if (i->value.id() == filter_grammar_ast::propertyID) - { - assert(i->children.size()==0); - string property_name(i->value.begin(), i->value.end()); - text += property_name; - } - else if (i->value.id() == filter_grammar_ast::expressionID) - { - assert(i->children.size() == 2); - assert(!i->children.begin()->value.is_root()); - process_node(i->children.begin(),text); - text += string(i->value.begin(), i->value.end()); - process_node(i->children.begin()+1,text); - - text +="\n"; - } - else if (i->value.id() == filter_grammar_ast::termID) - { - assert(i->children.size() == 2); - assert(!i->children.begin()->value.is_root()); - process_node(i->children.begin(),text); - text += string(i->value.begin(), i->value.end()); - process_node(i->children.begin()+1,text); - - text +="\n"; - - } - else if (i->value.id() == filter_grammar_ast::relationID) - { - assert(i->children.size() == 2); - assert(!i->children.begin()->value.is_root()); - process_node(i->children.begin(),text); - text += string(i->value.begin(), i->value.end()); - process_node(i->children.begin()+1,text); - - text +="\n"; - - } - else if (i->value.id() == filter_grammar_ast::equationID) - { - assert(i->children.size() == 2); - assert(!i->children.begin()->value.is_root()); - process_node(i->children.begin(),text); - text += string(i->value.begin(), i->value.end()); - process_node(i->children.begin()+1,text); - - text +="\n"; - } - else if (i->value.id() == filter_grammar_ast::and_exprID) - { - assert(i->children.size() == 2); - assert(!i->children.begin()->value.is_root()); - process_node(i->children.begin(),text); - text += string(i->value.begin(), i->value.end()); - process_node(i->children.begin()+1,text); - - text +="\n"; - } - else if (i->value.id() == filter_grammar_ast::or_exprID) - { - assert(i->children.size() == 2); - assert(!i->children.begin()->value.is_root()); - - process_node(i->children.begin(),text); - text += string(i->value.begin(), i->value.end()); - process_node(i->children.begin()+1,text); - - text +="\n"; - - } - } -} - -#endif //FILTER_PARSER_AST_HPP diff --git a/include/font_engine_freetype.hpp b/include/font_engine_freetype.hpp deleted file mode 100644 index 98552e7ea..000000000 --- a/include/font_engine_freetype.hpp +++ /dev/null @@ -1,432 +0,0 @@ -/***************************************************************************** - * - * This file is part of Mapnik (c++ mapping toolkit) - * - * Copyright (C) 2006 Artem Pavlenko - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - *****************************************************************************/ - -//$Id$ - -#if !defined FONT_ENGINE_FREETYPE_HPP -#define FONT_ENGINE_FREETYPE_HPP - -extern "C" -{ - #include - #include FT_FREETYPE_H - #include FT_GLYPH_H -} - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -namespace mapnik -{ - - class font_face : boost::noncopyable - { - public: - font_face(FT_Face face) - : face_(face) {} - - std::string family_name() const - { - return std::string(face_->family_name); - } - - std::string style_name() const - { - return std::string(face_->style_name); - } - - unsigned num_glyphs() const - { - return face_->num_glyphs; - } - - FT_GlyphSlot glyph() const - { - return face_->glyph; - } - - FT_Face get_face() const - { - return face_; - } - - bool set_pixel_sizes(unsigned size) - { - if (! FT_Set_Pixel_Sizes( face_, 0, size )) - return true; - return false; - } - - - ~font_face() - { - std::clog << "clean up face:" << family_name()<<":" << style_name() << std::endl; - FT_Done_Face(face_); - } - - private: - FT_Face face_; - }; - - typedef boost::shared_ptr face_ptr; - - class MAPNIK_DECL freetype_engine : public mapnik::singleton, - private boost::noncopyable - { - friend class mapnik::CreateStatic; - public: - - static bool register_font(std::string const& file_name); - static std::vector face_names (); - static face_ptr create_face(std::string const& family_name); - - private: - freetype_engine(); - virtual ~freetype_engine(); - static FT_Library library_; - static std::map name2file_; - }; - - template - class MAPNIK_DECL face_manager : private boost::noncopyable - { - typedef T font_engine_type; - typedef std::map faces; - - public: - face_ptr get_face(std::string const& name) - { - typename faces::iterator itr; - itr = faces_.find(name); - if (itr != faces_.end()) - { - return itr->second; - } - else - { - face_ptr face = font_engine_type::instance()->create_face(name); - if (face) - { - faces_.insert(make_pair(name,face)); - } - return face; - } - } - private: - faces faces_; - }; - - inline std::wstring to_unicode(std::string const& text) - { - std::wstring out; - unsigned long code = 0; - int expect = 0; - std::string::const_iterator itr=text.begin(); - - while ( itr != text.end()) - { - unsigned p = (*itr++) & 0xff; - if ( p >= 0xc0) - { - if ( p < 0xe0) // U+0080 - U+07ff - { - expect = 1; - code = p & 0x1f; - } - else if ( p < 0xf0) // U+0800 - U+ffff - { - expect = 2; - code = p & 0x0f; - } - else if ( p < 0xf8) // U+1000 - U+10ffff - { - expect = 3; - code = p & 0x07; - } - continue; - } - else if (p >= 0x80) - { - --expect; - if (expect >= 0) - { - code <<= 6; - code += p & 0x3f; - } - if (expect > 0) - continue; - expect = 0; - } - else - { - code = p; // U+0000 - U+007f (ascii) - } - out.push_back(wchar_t(code)); - } - return out; - } - - template - struct text_renderer : private boost::noncopyable - { - - struct glyph_t : boost::noncopyable - { - FT_Glyph image; - glyph_t(FT_Glyph image_) : image(image_) {} - ~glyph_t () { FT_Done_Glyph(image);} - }; - - typedef boost::ptr_vector glyphs_t; - typedef std::pair dimension_t; - typedef T pixmap_type; - - text_renderer (pixmap_type & pixmap, face_ptr face) - : pixmap_(pixmap), - face_(face), - fill_(0,0,0), - halo_fill_(255,255,255), - halo_radius_(0), - angle_(0.0) {} - - void set_pixel_size(unsigned size) - { - face_->set_pixel_sizes(size); - } - - void set_angle(float angle) - { - angle_=angle; - } - - void set_fill(mapnik::Color const& fill) - { - fill_=fill; - } - - void set_halo_fill(mapnik::Color const& halo) - { - halo_fill_=halo; - } - - void set_halo_radius( int radius=1) - { - halo_radius_=radius; - } - - dimension_t prepare_glyphs(std::string const& text) - { - //clear glyphs - glyphs_.clear(); - - FT_Matrix matrix; - FT_Vector pen; - FT_Error error; - - FT_Face face = face_->get_face(); - FT_GlyphSlot slot = face->glyph; - FT_Bool use_kerning; - FT_UInt previous = 0; - - pen.x = 0; - pen.y = 0; - - use_kerning = FT_HAS_KERNING(face)>0?true:false; - - FT_BBox bbox; - bbox.xMin = bbox.yMin = 32000; - bbox.xMax = bbox.yMax = -32000; //hmm?? - - for (std::string::const_iterator i=text.begin();i!=text.end();++i) - { - FT_BBox glyph_bbox; - FT_Glyph image; - - matrix.xx = (FT_Fixed)( cos( angle_ ) * 0x10000L ); - matrix.xy = (FT_Fixed)(-sin( angle_ ) * 0x10000L ); - matrix.yx = (FT_Fixed)( sin( angle_ ) * 0x10000L ); - matrix.yy = (FT_Fixed)( cos( angle_ ) * 0x10000L ); - - FT_Set_Transform (face,&matrix,&pen); - - FT_UInt glyph_index = FT_Get_Char_Index( face, unsigned(*i) & 0xff ); - - if ( use_kerning && previous && glyph_index) - { - FT_Vector delta; - FT_Get_Kerning(face,previous,glyph_index, - FT_KERNING_DEFAULT,&delta); - pen.x += delta.x; - pen.y += delta.y; - } - - error = FT_Load_Glyph (face,glyph_index,FT_LOAD_DEFAULT); - if ( error ) - continue; - - error = FT_Get_Glyph( face->glyph, &image); - if ( error ) - continue; - - FT_Glyph_Get_CBox(image,ft_glyph_bbox_pixels, &glyph_bbox); - if (glyph_bbox.xMin < bbox.xMin) - bbox.xMin = glyph_bbox.xMin; - if (glyph_bbox.yMin < bbox.yMin) - bbox.yMin = glyph_bbox.yMin; - if (glyph_bbox.xMax > bbox.xMax) - bbox.xMax = glyph_bbox.xMax; - if (glyph_bbox.yMax > bbox.yMax) - bbox.yMax = glyph_bbox.yMax; - - if ( bbox.xMin > bbox.xMax ) - { - bbox.xMin = 0; - bbox.yMin = 0; - bbox.xMax = 0; - bbox.yMax = 0; - } - - pen.x += slot->advance.x; - pen.y += slot->advance.y; - - previous = glyph_index; - // take ownership of the glyph - glyphs_.push_back(new glyph_t(image)); - } - - unsigned string_width = (bbox.xMax - bbox.xMin); - unsigned string_height = (bbox.yMax - bbox.yMin); - return dimension_t(string_width,string_height); - } - - void render(double x0, double y0) - { - FT_Error error; - FT_Vector start; - unsigned height = pixmap_.height(); - - start.x = unsigned(x0 * (1 << 6)); - start.y = unsigned((height - y0) * (1 << 6)); - // now render transformed glyphs - typename glyphs_t::iterator pos; - - if (halo_radius_ > 0) - { - //render halo - for ( pos = glyphs_.begin(); pos != glyphs_.end();++pos) - { - - FT_Glyph_Transform(pos->image,0,&start); - - error = FT_Glyph_To_Bitmap( &(pos->image),FT_RENDER_MODE_NORMAL,0,1); - if ( ! error ) - { - - FT_BitmapGlyph bit = (FT_BitmapGlyph)pos->image; - render_halo(&bit->bitmap, halo_fill_.rgba(), - bit->left, - height - bit->top,halo_radius_); - } - } - } - //render actual text - for ( pos = glyphs_.begin(); pos != glyphs_.end();++pos) - { - - FT_Glyph_Transform(pos->image,0,&start); - - error = FT_Glyph_To_Bitmap( &(pos->image),FT_RENDER_MODE_NORMAL,0,1); - if ( ! error ) - { - - FT_BitmapGlyph bit = (FT_BitmapGlyph)pos->image; - render_bitmap(&bit->bitmap, fill_.rgba(), - bit->left, - height - bit->top); - } - } - } - - private: - - void render_halo(FT_Bitmap *bitmap,unsigned rgba,int x,int y,int radius) - { - int x_max=x+bitmap->width; - int y_max=y+bitmap->rows; - int i,p,j,q; - - for (i=x,p=0;ibuffer[q*bitmap->width+p]; - if (gray) - { - for (int n=-halo_radius_; n <=halo_radius_; ++n) - for (int m=-halo_radius_;m <= halo_radius_; ++m) - pixmap_.blendPixel(i+m,j+n,rgba,gray); - } - } - } - } - - void render_bitmap(FT_Bitmap *bitmap,unsigned rgba,int x,int y) - { - int x_max=x+bitmap->width; - int y_max=y+bitmap->rows; - int i,p,j,q; - - for (i=x,p=0;ibuffer[q*bitmap->width+p]; - if (gray) - { - pixmap_.blendPixel(i,j,rgba,gray); - } - } - } - } - - pixmap_type & pixmap_; - face_ptr face_; - mapnik::Color fill_; - mapnik::Color halo_fill_; - int halo_radius_; - float angle_; - glyphs_t glyphs_; - }; -} - - -#endif // FONT_ENGINE_FREETYPE_HPP diff --git a/include/agg_renderer.hpp b/include/mapnik/agg_renderer.hpp similarity index 90% rename from include/agg_renderer.hpp rename to include/mapnik/agg_renderer.hpp index 31c655938..474556fde 100644 --- a/include/agg_renderer.hpp +++ b/include/mapnik/agg_renderer.hpp @@ -25,13 +25,16 @@ #ifndef AGG_RENDERER_HPP #define AGG_RENDERER_HPP -#include "feature_style_processor.hpp" +// boost #include -#include "font_engine_freetype.hpp" -#include "label_collision_detector.hpp" +// mapnik +#include +#include +#include +#include +#include -namespace mapnik -{ +namespace mapnik { template class MAPNIK_DECL agg_renderer : public feature_style_processor >, private boost::noncopyable diff --git a/include/mapnik/attribute.hpp b/include/mapnik/attribute.hpp new file mode 100644 index 000000000..bcd391f2d --- /dev/null +++ b/include/mapnik/attribute.hpp @@ -0,0 +1,222 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2006 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +//$Id: attribute.hpp 41 2005-04-13 20:21:56Z pavlenko $ + +#ifndef ATTRIBUTE_HPP +#define ATTRIBUTE_HPP + +// stl +#include +#include +#include +// boost +#include + +namespace mapnik { + template + struct attribute_traits + { + static std::string to_string(const T& value) + { + std::stringstream ss; + ss << value; + return ss.str(); + } + }; + + template <> + struct attribute_traits + { + static std::string to_string(const std::string& value) + { + return value; + } + }; + + class MAPNIK_DECL attribute + { + public: + attribute() + : base_(0) {} + + template + attribute(const T& value) + : base_(new attribute_impl(value)) + {} + + attribute(const attribute& rhs) + : base_(rhs.base_ ? rhs.base_->clone() : 0) + {} + + ~attribute() + { + delete base_; + } + + template + attribute& operator=(const T& rhs) + { + attribute(rhs).swap(*this); + return *this; + } + + attribute& operator=(const attribute& rhs) + { + attribute(rhs).swap(*this); + return *this; + } + + bool empty() const + { + return !base_; + } + + const std::type_info & type() const + { + return base_ ? base_->type() : typeid(void); + } + + const std::string to_string() const + { + return base_ ? base_->to_string() : ""; + } + private: + attribute& swap(attribute& rhs) + { + std::swap(base_,rhs.base_); + return *this; + } + + class attribute_base + { + public: + virtual ~attribute_base() {} + virtual attribute_base* clone() const=0; + virtual std::string to_string() const=0; + virtual const std::type_info& type() const=0; + }; + + template > + class attribute_impl : public attribute_base + { + public: + typedef T value_type; + attribute_impl(const value_type& value) + : value_(value) {} + + virtual std::string to_string() const + { + return ATraits::to_string(value_); + } + + virtual attribute_base* clone() const + { + return new attribute_impl(value_); + } + virtual const std::type_info& type() const + { + return typeid(value_); + } + value_type value_; + }; + private: + template + friend value_type* attribute_cast(attribute*); + attribute_base* base_; + }; + + + template + struct bad_attribute_cast : public std::bad_cast + { + virtual const char* what() const throw() + { + return "attribute::failed conversion"; + } + }; + + template + bool is_type(const attribute& attr) + { + return attr.type()==typeid(T); + } + + template + T* attribute_cast(attribute* attr) + { + return attr && attr->type() == typeid(T) + ? &static_cast*>(attr->base_)->value_ + : 0; + } + + template + const T* attribute_cast(const attribute* attr) + { + return attribute_cast(const_cast(attr)); + } + + template + T attribute_cast(const attribute& attr) + { + using namespace boost; + typedef BOOST_DEDUCED_TYPENAME remove_reference::type nonref; + const nonref * result=attribute_cast(&attr); + if (!result) + { + throw bad_attribute_cast(); + } + return *result; + } + + template + T attribute_cast(attribute& attr) + { + using namespace boost; + typedef BOOST_DEDUCED_TYPENAME remove_reference::type nonref; + nonref * result=attribute_cast(&attr); + if (!result) + throw bad_attribute_cast(); + return *result; + } + + + template + attribute attribute_from_string(const std::string& val) + { + std::istringstream is(val); + T t; + is >> t; + return attribute(t); + } + + template + inline std::basic_ostream& + operator << (std::basic_ostream& out, + const attribute& attr) + { + out << attr.to_string(); + return out; + } +} + +#endif //ATTRIBUTE_HPP diff --git a/include/mapnik/attribute_collector.hpp b/include/mapnik/attribute_collector.hpp new file mode 100644 index 000000000..0a192fc4c --- /dev/null +++ b/include/mapnik/attribute_collector.hpp @@ -0,0 +1,98 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2006 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +//$Id$ + +#ifndef ATTRIBUTE_COLLECTOR_HPP +#define ATTRIBUTE_COLLECTOR_HPP + +// stl +#include +#include +// mapnik +#include +#include +#include +#include + +namespace mapnik { + + struct symbolizer_attributes : public boost::static_visitor<> + { + symbolizer_attributes(std::set& names) + : names_(names) {} + + template + void operator () (T const&) const {} + void operator () (text_symbolizer const& sym) + { + names_.insert(sym.get_name()); + } + private: + std::set& names_; + }; + + template + class attribute_collector : public filter_visitor + { + private: + std::set& names_; + public: + + attribute_collector(std::set& names) + : names_(names) {} + + void visit(filter& /*filter*/) + { + //not interested + } + + void visit(expression& exp) + { + property* pf; + if ((pf = dynamic_cast*>(&exp))) + { + names_.insert(pf->name()); + } + } + void visit(rule_type const& r) + { + const symbolizers& symbols = r.get_symbolizers(); + symbolizers::const_iterator symIter=symbols.begin(); + symbolizer_attributes attr(names_); + while (symIter != symbols.end()) + { + boost::apply_visitor(attr,*symIter++); + } + filter_ptr const& filter = r.get_filter(); + filter->accept(*this); + } + + virtual ~attribute_collector() {} + private: + // no copying + attribute_collector(attribute_collector const&); + attribute_collector& operator=(attribute_collector const&); + }; +} + +#endif //ATTRIBUTE_COLLECTOR_HPP diff --git a/include/attribute_descriptor.hpp b/include/mapnik/attribute_descriptor.hpp similarity index 91% rename from include/attribute_descriptor.hpp rename to include/mapnik/attribute_descriptor.hpp index 081bda043..c71b7e6da 100644 --- a/include/attribute_descriptor.hpp +++ b/include/mapnik/attribute_descriptor.hpp @@ -27,13 +27,12 @@ #include -namespace mapnik -{ +namespace mapnik { struct attribute_desc { - std::string name; - eType type; + std::string name; + eType type; }; } -#endif +#endif // ATTRIBUTE_DESCRIPTOR_HPP diff --git a/include/color.hpp b/include/mapnik/color.hpp similarity index 99% rename from include/color.hpp rename to include/mapnik/color.hpp index 8c74829ac..f2ef8e843 100644 --- a/include/color.hpp +++ b/include/mapnik/color.hpp @@ -25,9 +25,9 @@ #ifndef COLOR_HPP #define COLOR_HPP -#include -#include "config.hpp" #include +#include +#include namespace mapnik { diff --git a/include/color_factory.hpp b/include/mapnik/color_factory.hpp similarity index 93% rename from include/color_factory.hpp rename to include/mapnik/color_factory.hpp index bcf9928ac..5bcf63001 100644 --- a/include/color_factory.hpp +++ b/include/mapnik/color_factory.hpp @@ -25,12 +25,12 @@ #ifndef COLOR_FACTORY_HPP #define COLOR_FACTORY_HPP -#include "config.hpp" -#include "css_color_parser.hpp" +#include +#include -namespace mapnik -{ - using namespace boost::spirit; +using namespace boost::spirit; + +namespace mapnik { class MAPNIK_DECL color_factory { public: diff --git a/include/mapnik/comparison.hpp b/include/mapnik/comparison.hpp new file mode 100644 index 000000000..fa6e61050 --- /dev/null +++ b/include/mapnik/comparison.hpp @@ -0,0 +1,149 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2006 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ +//$Id$ + +#ifndef COMPARISON_HPP +#define COMPARISON_HPP + +#include +#include +#include + +namespace mapnik { + template + struct greater_than + { + bool operator() (T const& left, T const& right) const + { + return left > right; + } + static std::string to_string() + { + return ">"; + } + }; + + template + struct greater_than_or_equal + { + bool operator() (T const& left, T const& right) const + { + return left >= right; + } + static std::string to_string() + { + return ">="; + } + }; + template + struct less_than + { + bool operator() (T const& left, T const& right) const + { + return left < right; + } + static std::string to_string() + { + return "<"; + } + }; + template + struct less_than_or_equal + { + bool operator() (T const& left, T const& right) const + { + return left <= right; + } + static std::string to_string() + { + return "<="; + } + }; + template + struct equals + { + bool operator() (T const& left, T const& right) const + { + return left == right; + } + static std::string to_string() + { + return "="; + } + }; + + template + struct not_equals + { + bool operator() (T const& left, T const& right) const + { + return left != right; + } + static std::string to_string() + { + return "<>"; + } + }; + + template + struct compare_filter : public filter + { + compare_filter(expression const& left, + expression const& right) + : filter(), + left_(left.clone()), right_(right.clone()) {} + + compare_filter(compare_filter const& other) + : filter(), + left_(other.left_->clone()),right_(other.right_->clone()) {} + + bool pass(const FeatureT& feature) const + { + return Op()(left_->get_value(feature),right_->get_value(feature)); + } + void accept(filter_visitor& v) + { + left_->accept(v); + right_->accept(v); + v.visit(*this); + } + std::string to_string() const + { + return "("+left_->to_string()+Op::to_string()+right_->to_string()+")"; + } + + filter* clone() const + { + return new compare_filter(*this); + } + virtual ~compare_filter() + { + delete left_; + delete right_; + } + private: + expression* left_; + expression* right_; + }; +} + +#endif //COMPARISON_HPP diff --git a/include/config.hpp b/include/mapnik/config.hpp similarity index 98% rename from include/config.hpp rename to include/mapnik/config.hpp index 70ee02aa1..37f685c67 100644 --- a/include/config.hpp +++ b/include/mapnik/config.hpp @@ -36,4 +36,4 @@ # define MAPNIK_DECL #endif -#endif +#endif // CONFIG_HPP diff --git a/include/coord.hpp b/include/mapnik/coord.hpp similarity index 98% rename from include/coord.hpp rename to include/mapnik/coord.hpp index c2813c9e5..019b7fd6a 100644 --- a/include/coord.hpp +++ b/include/mapnik/coord.hpp @@ -25,12 +25,10 @@ #ifndef COORD_HPP #define COORD_HPP -#include #include #include -namespace mapnik -{ +namespace mapnik { template struct coord { typedef T type; diff --git a/include/mapnik/coord_array.hpp b/include/mapnik/coord_array.hpp new file mode 100644 index 000000000..4bffe0ee8 --- /dev/null +++ b/include/mapnik/coord_array.hpp @@ -0,0 +1,92 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2006 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +//$Id: coord_array.hpp 39 2005-04-10 20:39:53Z pavlenko $ + +#ifndef COORD_ARRAY_HPP +#define COORD_ARRAY_HPP + +// stl +#include +//mapnik +#include + +namespace mapnik { + template + class coord_array + { + typedef T coord_type; + coord_type* pt_; + const unsigned size_; + public: + coord_array(unsigned size=0) + : pt_(static_cast(size==0?0: ::operator new (sizeof(coord_type)*size))), + size_(size) {} + + coord_array(const coord_array& rhs) + : pt_(static_cast(rhs.size_==0?0: ::operator new (sizeof(coord_type)*rhs.size_))), + size_(rhs.size_) { + memcpy(pt_,rhs.pt_,sizeof(coord_type)*rhs.size_); + } + + ~coord_array() + { + ::operator delete (pt_); + } + + unsigned size() const + { + return size_; + } + + void set(unsigned index,double x,double y) + { + assert(index +#include + +using namespace boost::spirit; + +namespace mapnik { + template + struct named_colors : public symbols + { + named_colors() + { + symbols::add + ("aliceblue", ColorT(240, 248, 255)) + ("antiquewhite", ColorT(250, 235, 215)) + ("aqua", ColorT(0, 255, 255)) + ("aquamarine", ColorT(127, 255, 212)) + ("azure", ColorT(240, 255, 255)) + ("beige", ColorT(245, 245, 220)) + ("bisque", ColorT(255, 228, 196)) + ("black", ColorT(0, 0, 0)) + ("blanchedalmond", ColorT(255,235,205)) + ("blue", ColorT(0, 0, 255)) + ("blueviolet", ColorT(138, 43, 226)) + ("brown", ColorT(165, 42, 42)) + ("burlywood", ColorT(222, 184, 135)) + ("cadetblue", ColorT(95, 158, 160)) + ("chartreuse", ColorT(127, 255, 0)) + ("chocolate", ColorT(210, 105, 30)) + ("coral", ColorT(255, 127, 80)) + ("cornflowerblue", ColorT(100, 149, 237)) + ("cornsilk", ColorT(255, 248, 220)) + ("crimson", ColorT(220, 20, 60)) + ("cyan", ColorT(0, 255, 255)) + ("darkblue", ColorT(0, 0, 139)) + ("darkcyan", ColorT(0, 139, 139)) + ("darkgoldenrod", ColorT(184, 134, 11)) + ("darkgray", ColorT(169, 169, 169)) + ("darkgreen", ColorT(0, 100, 0)) + ("darkgrey", ColorT(169, 169, 169)) + ("darkkhaki", ColorT(189, 183, 107)) + ("darkmagenta", ColorT(139, 0, 139)) + ("darkolivegreen", ColorT(85, 107, 47)) + ("darkorange", ColorT(255, 140, 0)) + ("darkorchid", ColorT(153, 50, 204)) + ("darkred", ColorT(139, 0, 0)) + ("darksalmon", ColorT(233, 150, 122)) + ("darkseagreen", ColorT(143, 188, 143)) + ("darkslateblue", ColorT(72, 61, 139)) + ("darkslategrey", ColorT(47, 79, 79)) + ("darkturquoise", ColorT(0, 206, 209)) + ("darkviolet", ColorT(148, 0, 211)) + ("deeppink", ColorT(255, 20, 147)) + ("deepskyblue", ColorT(0, 191, 255)) + ("dimgray", ColorT(105, 105, 105)) + ("dimgrey", ColorT(105, 105, 105)) + ("dodgerblue", ColorT(30, 144, 255)) + ("firebrick", ColorT(178, 34, 34)) + ("floralwhite", ColorT(255, 250, 240)) + ("forestgreen", ColorT(34, 139, 34)) + ("fuchsia", ColorT(255, 0, 255)) + ("gainsboro", ColorT(220, 220, 220)) + ("ghostwhite", ColorT(248, 248, 255)) + ("gold", ColorT(255, 215, 0)) + ("goldenrod", ColorT(218, 165, 32)) + ("gray", ColorT(128, 128, 128)) + ("grey", ColorT(128, 128, 128)) + ("green", ColorT(0, 128, 0)) + ("greenyellow", ColorT(173, 255, 47)) + ("honeydew", ColorT(240, 255, 240)) + ("hotpink", ColorT(255, 105, 180)) + ("indianred", ColorT(205, 92, 92)) + ("indigo", ColorT(75, 0, 130)) + ("ivory", ColorT(255, 255, 240)) + ("khaki", ColorT(240, 230, 140)) + ("lavender", ColorT(230, 230, 250)) + ("lavenderblush", ColorT(255, 240, 245)) + ("lawngreen", ColorT(124, 252, 0)) + ("lemonchiffon", ColorT(255, 250, 205)) + ("lightblue", ColorT(173, 216, 230)) + ("lightcoral", ColorT(240, 128, 128)) + ("lightcyan", ColorT(224, 255, 255)) + ("lightgoldenrodyellow", ColorT(250, 250, 210)) + ("lightgray", ColorT(211, 211, 211)) + ("lightgreen", ColorT(144, 238, 144)) + ("lightgrey", ColorT(211, 211, 211)) + ("lightpink", ColorT(255, 182, 193)) + ("lightsalmon", ColorT(255, 160, 122)) + ("lightseagreen", ColorT(32, 178, 170)) + ("lightskyblue", ColorT(135, 206, 250)) + ("lightslategray", ColorT(119, 136, 153)) + ("lightslategrey", ColorT(119, 136, 153)) + ("lightsteelblue", ColorT(176, 196, 222)) + ("lightyellow", ColorT(255, 255, 224)) + ("lime", ColorT(0, 255, 0)) + ("limegreen", ColorT(50, 205, 50)) + ("linen", ColorT(250, 240, 230)) + ("magenta", ColorT(255, 0, 255)) + ("maroon", ColorT(128, 0, 0)) + ("mediumaquamarine", ColorT(102, 205, 170)) + ("mediumblue", ColorT(0, 0, 205)) + ("mediumorchid", ColorT(186, 85, 211)) + ("mediumpurple", ColorT(147, 112, 219)) + ("mediumseagreen", ColorT(60, 179, 113)) + ("mediumslateblue", ColorT(123, 104, 238)) + ("mediumspringgreen", ColorT(0, 250, 154)) + ("mediumturquoise", ColorT(72, 209, 204)) + ("mediumvioletred", ColorT(199, 21, 133)) + ("midnightblue", ColorT(25, 25, 112)) + ("mintcream", ColorT(245, 255, 250)) + ("mistyrose", ColorT(255, 228, 225)) + ("moccasin", ColorT(255, 228, 181)) + ("navajowhite", ColorT(255, 222, 173)) + ("navy", ColorT(0, 0, 128)) + ("oldlace", ColorT(253, 245, 230)) + ("olive", ColorT(128, 128, 0)) + ("olivedrab", ColorT(107, 142, 35)) + ("orange", ColorT(255, 165, 0)) + ("orangered", ColorT(255, 69, 0)) + ("orchid", ColorT(218, 112, 214)) + ("palegoldenrod", ColorT(238, 232, 170)) + ("palegreen", ColorT(152, 251, 152)) + ("paleturquoise", ColorT(175, 238, 238)) + ("palevioletred", ColorT(219, 112, 147)) + ("papayawhip", ColorT(255, 239, 213)) + ("peachpuff", ColorT(255, 218, 185)) + ("peru", ColorT(205, 133, 63)) + ("pink", ColorT(255, 192, 203)) + ("plum", ColorT(221, 160, 221)) + ("powderblue", ColorT(176, 224, 230)) + ("purple", ColorT(128, 0, 128)) + ("red", ColorT(255, 0, 0)) + ("rosybrown", ColorT(188, 143, 143)) + ("royalblue", ColorT(65, 105, 225)) + ("saddlebrown", ColorT(139, 69, 19)) + ("salmon", ColorT(250, 128, 114)) + ("sandybrown", ColorT(244, 164, 96)) + ("seagreen", ColorT(46, 139, 87)) + ("seashell", ColorT(255, 245, 238)) + ("sienna", ColorT(160, 82, 45)) + ("silver", ColorT(192, 192, 192)) + ("skyblue", ColorT(135, 206, 235)) + ("slateblue", ColorT(106, 90, 205)) + ("slategray", ColorT(112, 128, 144)) + ("slategrey", ColorT(112, 128, 144)) + ("snow", ColorT(255, 250, 250)) + ("springgreen", ColorT(0, 255, 127)) + ("steelblue", ColorT(70, 130, 180)) + ("tan", ColorT(210, 180, 140)) + ("teal", ColorT(0, 128, 128)) + ("thistle", ColorT(216, 191, 216)) + ("tomato", ColorT(255, 99, 71)) + ("turquoise", ColorT(64, 224, 208)) + ("violet", ColorT(238, 130, 238)) + ("wheat", ColorT(245, 222, 179)) + ("white", ColorT(255, 255, 255)) + ("whitesmoke", ColorT(245, 245, 245)) + ("yellow", ColorT(255, 255, 0)) + ("yellowgreen", ColorT(154, 205, 50)) + ; + } + }; + + template + struct css_color_grammar : public grammar > + { + css_color_grammar(ActionsT& actions_) + : actions(actions_) {} + + template + struct definition + { + definition(css_color_grammar const& self) + { + hex6 = ch_p('#') >> uint6x_p[self.actions.hex6_]; + hex3 = ch_p('#') >> uint3x_p[self.actions.hex3_]; + rgb = str_p("rgb") >> '(' >> uint3_p[self.actions.red_] + >> ',' >> uint3_p[self.actions.green_] + >> ',' >> uint3_p[self.actions.blue_] + >> ')'; + rgb_percent = str_p("rgb") >> '(' >> ureal_p[self.actions.red_p_] >> '%' + >> ',' >> ureal_p[self.actions.green_p_] >> '%' + >> ',' >> ureal_p[self.actions.blue_p_] >> '%' + >> ')'; + css_color = named_colors_p[self.actions.named_] | hex6 | hex3 | rgb_percent | rgb; + } + boost::spirit::rule rgb; + boost::spirit::rule rgb_percent; + boost::spirit::rule hex6; + boost::spirit::rule hex3; + boost::spirit::rule css_color; + boost::spirit::rule const& start() const + { + return css_color; + } + uint_parser uint3_p; + uint_parser uint6x_p; + uint_parser uint3x_p; + named_colors named_colors_p; + + }; + ActionsT& actions; + }; + + template + struct named_color_action + { + named_color_action(ColorT& c) + : c_(c) {} + + void operator() (ColorT const&c) const + { + c_=c; + } + ColorT& c_; + }; + + template + struct hex6_action + { + hex6_action(ColorT& c) + : c_(c) {} + + void operator () (unsigned int hex) const + { + unsigned r = (hex >> 16) & 0xff; + unsigned g = (hex >> 8) & 0xff; + unsigned b = hex & 0xff; + c_.set_red(r); + c_.set_green(g); + c_.set_blue(b); + } + ColorT& c_; + }; + + template + struct hex3_action + { + hex3_action(ColorT& c) + : c_(c) {} + + void operator () (unsigned int hex) const + { + unsigned int r = (hex >> 8) & 0xf; + unsigned int g = (hex >> 4) & 0xf; + unsigned int b = hex & 0xf; + c_.set_red( r | r << 4); + c_.set_green(g | g << 4); + c_.set_blue(b | b << 4); + } + ColorT& c_; + }; + + template + struct red_action + { + red_action(ColorT& c) + : c_(c) {} + + void operator () (unsigned int r) const + { + c_.set_red(r); + } + ColorT& c_; + }; + + template + struct green_action + { + green_action(ColorT& c) + : c_(c) {} + + void operator () (unsigned int g) const + { + c_.set_green(g); + } + ColorT& c_; + }; + + template + struct blue_action + { + blue_action(ColorT& c) + : c_(c) {} + + void operator () (unsigned int b) const + { + c_.set_blue(b); + } + ColorT& c_; + }; + + + template + struct red_action_p + { + red_action_p(ColorT& c) + : c_(c) {} + + void operator () (double r) const + { + c_.set_red(unsigned((255.0 * r)/100.0 + 0.5)); + } + ColorT& c_; + }; + + template + struct green_action_p + { + green_action_p(ColorT& c) + : c_(c) {} + + void operator () (double g) const + { + c_.set_green(unsigned((255.0 * g)/100.0 + 0.5)); + } + ColorT& c_; + }; + + template + struct blue_action_p + { + blue_action_p(ColorT& c) + : c_(c) {} + + void operator () (double b) const + { + c_.set_blue(unsigned((255.0 * b)/100.0 + 0.5)); + } + ColorT& c_; + }; + + + template + struct actions + { + typedef ColorT color_type; + actions(ColorT& c) + : named_(c), + hex6_(c), + hex3_(c), + red_(c), + green_(c), + blue_(c), + red_p_(c), + green_p_(c), + blue_p_(c) {} + + named_color_action named_; + hex6_action hex6_; + hex3_action hex3_; + red_action red_; + green_action green_; + blue_action blue_; + red_action_p red_p_; + green_action_p green_p_; + blue_action_p blue_p_; + }; +} + +#endif //CSS_COLOR_PARSER_HPP diff --git a/include/mapnik/ctrans.hpp b/include/mapnik/ctrans.hpp new file mode 100644 index 000000000..37e3463ef --- /dev/null +++ b/include/mapnik/ctrans.hpp @@ -0,0 +1,169 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2006 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +//$Id: ctrans.hpp 39 2005-04-10 20:39:53Z pavlenko $ + +#ifndef CTRANS_HPP +#define CTRANS_HPP + +#include +#include + +namespace mapnik { + typedef coord_array CoordinateArray; + + template + struct MAPNIK_DECL coord_transform + { + coord_transform(Transform const& t,Geometry& geom) + : t_(t), geom_(geom) {} + + unsigned vertex(double *x , double *y) const + { + unsigned command = geom_.vertex(x,y); + *x = t_.forward_x_(x); + *y = t_.forward_y_(y); + return command; + } + void rewind (unsigned pos) + { + geom_.rewind(pos); + } + + private: + Transform const& t_; + Geometry& geom_; + }; + + class CoordTransform + { + private: + int width; + int height; + double scale_; + Envelope extent; + public: + CoordTransform(int width,int height,const Envelope& extent) + :width(width),height(height),extent(extent) + { + double sx=((double)width)/extent.width(); + double sy=((double)height)/extent.height(); + scale_=std::min(sx,sy); + } + + inline double scale() const + { + return scale_; + } + + inline void forward_x(double* x) const + { + *x = (*x - extent.minx() ) * scale_; + } + + inline void forward_y(double* y) const + { + *y = (extent.maxy() - *y) * scale_; + } + + inline double forward_x_(double* x) const + { + return (*x - extent.minx() ) * scale_; + } + + inline double forward_y_(double* y) const + { + return (extent.maxy() - *y) * scale_; + } + + inline void backward_x(double* x) const + { + *x = extent.minx() + *x/scale_; + } + + inline void backward_y(double* y) const + { + *y = extent.maxy() - *y/scale_; + } + + inline coord2d& forward(coord2d& c) const + { + forward_x(&c.x); + forward_y(&c.y); + return c; + } + + inline coord2d& backward(coord2d& c) const + { + backward_x(&c.x); + backward_y(&c.y); + return c; + } + + inline Envelope forward(const Envelope& e) const + { + double x0 = e.minx(); + double y0 = e.miny(); + double x1 = e.maxx(); + double y1 = e.maxy(); + forward_x(&x0); + forward_y(&y0); + forward_x(&x1); + forward_y(&y1); + return Envelope(x0,y0,x1,y1); + } + + inline Envelope backward(const Envelope& e) const + { + double x0 = e.minx(); + double y0 = e.miny(); + double x1 = e.maxx(); + double y1 = e.maxy(); + backward_x(&x0); + backward_y(&y0); + backward_x(&x1); + backward_y(&y1); + + return Envelope(x0,y0,x1,y1); + } + + inline CoordinateArray& forward(CoordinateArray& coords) const + { + for (unsigned i=0;i #include -#include "ctrans.hpp" -#include "params.hpp" -#include "feature.hpp" -#include "query.hpp" -#include "feature_layer_desc.hpp" - +// boost +#include #include +// mapnik +#include +#include +#include +#include +#include +#include -namespace mapnik -{ - typedef MAPNIK_DECL shared_ptr feature_ptr; +namespace mapnik { + typedef MAPNIK_DECL boost::shared_ptr feature_ptr; + struct MAPNIK_DECL Featureset { virtual feature_ptr next()=0; virtual ~Featureset() {}; }; + + typedef boost::shared_ptr featureset_ptr; - typedef shared_ptr featureset_ptr; class MAPNIK_DECL datasource_exception : public std::exception { private: @@ -100,12 +104,12 @@ namespace mapnik typedef boost::shared_ptr datasource_p; - /////////////////////////////////////////// -#define DATASOURCE_PLUGIN(classname) \ - extern "C" MAPNIK_DECL std::string datasource_name() \ - { \ - return classname::name(); \ - } \ + + #define DATASOURCE_PLUGIN(classname) \ + extern "C" MAPNIK_DECL std::string datasource_name() \ + { \ + return classname::name(); \ + } \ extern "C" MAPNIK_DECL datasource* create(const parameters ¶ms) \ { \ return new classname(params); \ @@ -114,6 +118,7 @@ namespace mapnik { \ delete ds; \ } \ - /////////////////////////////////////////// + // } -#endif //DATASOURCE_HPP + +#endif //DATASOURCE_HPP diff --git a/include/datasource_cache.hpp b/include/mapnik/datasource_cache.hpp similarity index 87% rename from include/datasource_cache.hpp rename to include/mapnik/datasource_cache.hpp index c0f33671b..67333616d 100644 --- a/include/datasource_cache.hpp +++ b/include/mapnik/datasource_cache.hpp @@ -25,17 +25,19 @@ #ifndef DATASOURCE_CACHE_HPP #define DATASOURCE_CACHE_HPP +// stl #include +// boost #include +// mapnik +#include +#include +#include +#include -#include "utils.hpp" -#include "params.hpp" -#include "plugin.hpp" -#include "datasource.hpp" - -namespace mapnik -{ - class MAPNIK_DECL datasource_cache : public singleton +namespace mapnik { + class MAPNIK_DECL datasource_cache : + public singleton { friend class CreateStatic; private: @@ -51,4 +53,5 @@ namespace mapnik static boost::shared_ptr create(parameters const& params); }; } + #endif //DATASOURCE_CACHE_HPP diff --git a/include/envelope.hpp b/include/mapnik/envelope.hpp similarity index 96% rename from include/envelope.hpp rename to include/mapnik/envelope.hpp index 3bdb3431f..e6fa87aa9 100644 --- a/include/envelope.hpp +++ b/include/mapnik/envelope.hpp @@ -25,13 +25,13 @@ #ifndef ENVELOPE_HPP #define ENVELOPE_HPP -#include "config.hpp" +// stl #include -#include "coord.hpp" - -namespace mapnik -{ +// mapnik +#include +#include +namespace mapnik { template class MAPNIK_DECL Envelope { public: @@ -85,4 +85,5 @@ namespace mapnik return out; } } + #endif // ENVELOPE_HPP diff --git a/include/mapnik/expression.hpp b/include/mapnik/expression.hpp new file mode 100644 index 000000000..bda328068 --- /dev/null +++ b/include/mapnik/expression.hpp @@ -0,0 +1,126 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2006 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +//$Id$ + +#ifndef EXPRESSION_HPP +#define EXPRESSION_HPP + +#include +#include + +namespace mapnik { + template class filter_visitor; + template + class expression + { + public: + virtual value get_value(FeatureT const& feature) const=0; + virtual void accept(filter_visitor& v)=0; + virtual expression* clone() const=0; + virtual std::string to_string() const=0; + virtual ~expression() {} + }; + + template + class literal : public expression + { + public: + literal(int val) + : expression(), + value_(val) {} + literal(double val) + : expression(), + value_(val) {} + literal(std::string const& val) + : expression(), + value_(val) {} + literal(literal const& other) + : expression(), + value_(other.value_) {} + + value get_value(FeatureT const& /*feature*/) const + { + return value_; + } + void accept(filter_visitor& v) + { + v.visit(*this); + } + expression* clone() const + { + return new literal(*this); + } + std::string to_string() const + { + return value_.to_expression_string(); + } + ~literal() {} + private: + value value_; + }; + + + template + class property : public expression + { + public: + property(std::string const& name) + : expression(), + name_(name) + {} + + property(property const& other) + : expression(), + name_(other.name_) + {} + + value get_value(FeatureT const& feature) const + { + return feature[name_]; + } + void accept(filter_visitor& v) + { + v.visit(*this); + } + expression* clone() const + { + return new property(*this); + } + std::string const& name() const + { + return name_; + } + + std::string to_string() const + { + return "["+name_+"]"; + } + + ~property() {} + + private: + std::string name_; + }; +} + +#endif //EXPRESSION_HPP diff --git a/include/factory.hpp b/include/mapnik/factory.hpp similarity index 89% rename from include/factory.hpp rename to include/mapnik/factory.hpp index 3ff5022d5..8ab7058bb 100644 --- a/include/factory.hpp +++ b/include/mapnik/factory.hpp @@ -25,12 +25,13 @@ #ifndef FACTORY_HPP #define FACTORY_HPP +// stl #include #include -#include "utils.hpp" +// mapnik +#include -namespace mapnik -{ +namespace mapnik { template class default_factory_error @@ -56,7 +57,9 @@ namespace mapnik typename product_creator=product_type* (*)(), template class factory_error_policy=default_factory_error > - class factory : public singleton >, + class factory : public singleton >, factory_error_policy { private: @@ -85,4 +88,5 @@ namespace mapnik } }; } -#endif //FACTORY_HPP + +#endif //FACTORY_HPP diff --git a/include/mapnik/feature.hpp b/include/mapnik/feature.hpp new file mode 100644 index 000000000..58d758141 --- /dev/null +++ b/include/mapnik/feature.hpp @@ -0,0 +1,121 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2006 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +//$Id: feature.hpp 40 2005-04-13 20:20:46Z pavlenko $ + +#ifndef FEATURE_HPP +#define FEATURE_HPP +// stl +#include +// boost +#include +#include +#include +// mapnik +#include +#include +#include + +namespace mapnik { + typedef boost::shared_ptr raster_ptr; + typedef boost::associative_property_map< + std::map > properties; + + template + struct feature : public properties, + private boost::noncopyable + { + public: + typedef T1 geometry_type; + typedef T2 raster_type; + private: + int id_; + geometry_type geom_; + raster_type raster_; + std::map props_; + public: + explicit feature(int id) + : properties(props_), + id_(id), + geom_(), + raster_() {} + + feature(int id,const geometry_type& geom) + : properties(props_), + id_(id), + geom_(geom), + raster_() {} + + int id() const + { + return id_; + } + + void set_geometry(geometry_type& geom) + { + geom_=geom; + } + + geometry_type const& get_geometry() const + { + return geom_; + } + + const raster_type& get_raster() const + { + return raster_; + } + void set_raster(raster_type const& raster) + { + raster_=raster; + } + + const properties& get_properties() const + { + return props_; + } + + std::string to_string() const + { + std::stringstream ss; + ss << "feature (" << std::endl; + for (std::map::const_iterator itr=props_.begin(); + itr != props_.end();++itr) + { + ss << " " << itr->first << ":" << itr->second << std::endl; + } + ss << ")" << std::endl; + return ss.str(); + } + }; + + typedef feature Feature; + + inline std::ostream& operator<< (std::ostream & out,Feature const& f) + { + out << f.to_string(); + return out; + } +} + +#endif //FEATURE_HPP diff --git a/include/feature_factory.hpp b/include/mapnik/feature_factory.hpp similarity index 90% rename from include/feature_factory.hpp rename to include/mapnik/feature_factory.hpp index 52449e537..0df52bebc 100644 --- a/include/feature_factory.hpp +++ b/include/mapnik/feature_factory.hpp @@ -25,17 +25,17 @@ #ifndef FEATURE_FACTORY_HPP #define FEATURE_FACTORY_HPP -#include "feature.hpp" +#include + namespace mapnik { struct feature_factory { - static Feature* create (int fid) - { - return new Feature(fid); - } + static Feature* create (int fid) + { + return new Feature(fid); + } }; } - #endif //FEATURE_FACTORY_HPP diff --git a/include/mapnik/feature_layer_desc.hpp b/include/mapnik/feature_layer_desc.hpp new file mode 100644 index 000000000..4001a546a --- /dev/null +++ b/include/mapnik/feature_layer_desc.hpp @@ -0,0 +1,250 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2006 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +//$Id$ + +#ifndef FEATURE_LAYER_DESC_HPP +#define FEATURE_LAYER_DESC_HPP + +#include +#include +#include + +namespace mapnik +{ + + using std::string; + using std::vector; + using std::clog; + using std::endl; + + enum { + Integer=1, + Float =2, + Double =3, + String =4, + Geometry=5, + Object=6 + }; + + class attribute_descriptor + { + public: + attribute_descriptor(string const& name,unsigned type, + bool primary_key=false, + int size=-1, + int precision=-1) + : name_(name), + type_(type), + primary_key_(primary_key), + size_(size), + precision_(precision) {} + + attribute_descriptor(attribute_descriptor const& other) + : name_(other.name_), + type_(other.type_), + primary_key_(other.primary_key_), + size_(other.size_), + precision_(other.precision_) {} + + attribute_descriptor& operator=(attribute_descriptor const& other) + { + if (this == &other) + return *this; + name_=other.name_; + type_=other.type_; + primary_key_=other.primary_key_; + size_=other.size_; + precision_=other.precision_; + return *this; + } + string const& get_name() const + { + return name_; + } + unsigned get_type() const + { + return type_; + } + bool is_primary_key() const + { + return primary_key_; + } + int get_size() const + { + return size_; + } + + int get_precision() const + { + return precision_; + } + private: + string name_; + int type_; + bool primary_key_; + int size_; + int precision_; + }; + + template + inline std::basic_ostream& + operator << (std::basic_ostream& out, + attribute_descriptor const& ad) + { + out << "name=" << ad.get_name() << endl; + out << "type=" << ad.get_type() << endl; + out << "size=" << ad.get_size() << endl; + return out; + } + + class layer_descriptor + { + public: + layer_descriptor(string const& name,int srid=-1) + : name_(name), + srid_(srid) {} + + layer_descriptor(layer_descriptor const& other) + : name_(other.name_), + srid_(other.srid_), + desc_ar_(other.desc_ar_) {} + + void set_name(string const& name) + { + name_=name; + } + string const& get_name() const + { + return name_; + } + + void set_srid(int srid) + { + srid_=srid; + } + + int get_srid() const + { + return srid_; + } + + void add_descriptor(attribute_descriptor const& desc) + { + desc_ar_.push_back(desc); + } + + vector const& get_descriptors() const + { + return desc_ar_; + } + vector& get_descriptors() + { + return desc_ar_; + } + private: + string name_; + int srid_; + vector desc_ar_; + }; + + template + inline std::basic_ostream& + operator << (std::basic_ostream& out, + layer_descriptor const& ld) + { + out << "name=" << ld.get_name() << endl; + out << "srid=" << ld.get_srid() << endl; + vector const& desc_ar=ld.get_descriptors(); + vector::const_iterator pos=desc_ar.begin(); + while (pos != desc_ar.end()) + { + out << *pos++ << endl; + + } + return out; + } + /* + bool layer_descriptor_to_wkb(layer_descriptor const& desc,array<>& wkb) + { + //srid + int srid = desc.get_srid(); + wkb.write(&srid,sizeof(int)); + + //attribute descriptors + vector const& desc_ar = desc.get_descriptors(); + vector::const_iterator itr=desc_ar.begin(); + size_t num_desc = desc_ar.size(); + wkb.write(&num_desc,sizeof(int)); + + while (itr != desc_ar.end()) + { + string name = itr->get_name(); + wkb.write(name.c_str(),name.size()+1); + + unsigned type = static_cast(itr->get_type()); + wkb.write(&type,sizeof(unsigned)); + + bool prim_key = itr->is_primary_key(); + wkb.write(&prim_key,sizeof(bool)); + + int size = itr->get_size(); + wkb.write(&size,sizeof(int)); + + ++itr; + } + return true; + } + + bool layer_descriptor_from_wkb(const char* wkb, layer_descriptor &desc) + { + unsigned pos=0; + int srid; + + memcpy(&srid,wkb+pos,sizeof(int)); + desc.set_srid(srid); + pos+=sizeof(int); + + int num_desc; + memcpy(&num_desc,wkb+pos,sizeof(int)); + pos+=sizeof(int); + + for (int i=0;i -#include +// boost #include -#include "envelope.hpp" -#include "datasource.hpp" -#include "layer.hpp" -#include "map.hpp" -#include "attribute_collector.hpp" -#include "utils.hpp" +// mapnik +#include +#include +#include +#include +#include +#include namespace mapnik { @@ -149,7 +151,8 @@ namespace mapnik symbolizers::const_iterator symIter=symbols.begin(); while (symIter!=symbols.end()) { - boost::apply_visitor(symbol_dispatch(p,*feature),*symIter++); + boost::apply_visitor + (symbol_dispatch(p,*feature),*symIter++); } } ++itr; @@ -157,14 +160,16 @@ namespace mapnik if (do_else) { //else filter - std::vector::const_iterator itr=else_rules.begin(); + std::vector::const_iterator itr= + else_rules.begin(); while (itr != else_rules.end()) { const symbolizers& symbols = (*itr)->get_symbolizers(); symbolizers::const_iterator symIter=symbols.begin(); while (symIter!=symbols.end()) { - boost::apply_visitor(symbol_dispatch(p,*feature),*symIter++); + boost::apply_visitor + (symbol_dispatch(p,*feature),*symIter++); } ++itr; } diff --git a/include/feature_type_style.hpp b/include/mapnik/feature_type_style.hpp similarity index 91% rename from include/feature_type_style.hpp rename to include/mapnik/feature_type_style.hpp index 0b5aa99e3..e8e449c59 100644 --- a/include/feature_type_style.hpp +++ b/include/mapnik/feature_type_style.hpp @@ -22,13 +22,13 @@ //$Id$ -#ifndef FEATURE_TYPE_STYLE -#define FEATURE_TYPE_STYLE - -#include "rule.hpp" -#include "feature.hpp" +#ifndef FEATURE_TYPE_STYLE_HPP +#define FEATURE_TYPE_STYLE_HPP +// stl #include - +// mapnik +#include +#include namespace mapnik { @@ -64,4 +64,4 @@ namespace mapnik }; } -#endif //FEATURE_TYPE_STYLE +#endif //FEATURE_TYPE_STYLE_HPP diff --git a/include/fill.hpp b/include/mapnik/fill.hpp similarity index 100% rename from include/fill.hpp rename to include/mapnik/fill.hpp diff --git a/include/filter.hpp b/include/mapnik/filter.hpp similarity index 97% rename from include/filter.hpp rename to include/mapnik/filter.hpp index 7331c65fd..664572b63 100644 --- a/include/filter.hpp +++ b/include/mapnik/filter.hpp @@ -25,7 +25,8 @@ #ifndef FILTER_HPP #define FILTER_HPP -#include "feature.hpp" +#include +#include namespace mapnik { diff --git a/include/filter_expression.hpp b/include/mapnik/filter_expression.hpp similarity index 96% rename from include/filter_expression.hpp rename to include/mapnik/filter_expression.hpp index 6ad65a6d0..f50a55494 100644 --- a/include/filter_expression.hpp +++ b/include/mapnik/filter_expression.hpp @@ -25,9 +25,11 @@ #ifndef FILTER_TO_STRING_HPP #define FILTER_TO_STRING_HPP -#include "filter.hpp" -#include "expression.hpp" +// stl #include +// mapnik +#include +#include namespace mapnik { diff --git a/include/filter_factory.hpp b/include/mapnik/filter_factory.hpp similarity index 96% rename from include/filter_factory.hpp rename to include/mapnik/filter_factory.hpp index 7a1ec0e93..db94286c4 100644 --- a/include/filter_factory.hpp +++ b/include/mapnik/filter_factory.hpp @@ -25,12 +25,12 @@ #ifndef FILTER_FACTORY_HPP #define FILTER_FACTORY_HPP -#include "filter_parser.hpp" - -using std::string; +#include namespace mapnik { + using std::string; + template class MAPNIK_DECL filter_factory { @@ -53,7 +53,7 @@ namespace mapnik } } }; - + MAPNIK_DECL filter_ptr create_filter (std::string const& wkt); } diff --git a/include/filter_parser.hpp b/include/mapnik/filter_parser.hpp similarity index 95% rename from include/filter_parser.hpp rename to include/mapnik/filter_parser.hpp index c4b1b8214..26ff4a7a8 100644 --- a/include/filter_parser.hpp +++ b/include/mapnik/filter_parser.hpp @@ -25,32 +25,34 @@ #ifndef FILTER_PARSER_HPP #define FILTER_PARSER_HPP - +// stl #include #include - +// boost #include #include #include #include #include #include - -#include "value.hpp" -#include "comparison.hpp" -#include "math_expr.hpp" -#include "expression.hpp" -#include "filter.hpp" -#include "regex_filter.hpp" -#include "logical.hpp" +// mapnik +#include +#include +#include +#include +#include +#include +#include using namespace boost::spirit; -using std::string; -using std::clog; -using std::stack; +using boost::shared_ptr; namespace mapnik { + using std::string; + using std::clog; + using std::stack; + template struct push_integer { @@ -59,7 +61,8 @@ namespace mapnik void operator() (int val) const { - exprs_.push(shared_ptr >(new literal(val))); + exprs_.push(shared_ptr > + ( new literal(val))); } stack > >& exprs_; }; @@ -158,7 +161,8 @@ namespace mapnik std::string pattern(start,end); try { - filters_.push(shared_ptr >(new regex_filter(*exp,pattern))); + filters_.push(shared_ptr > + (new regex_filter(*exp,pattern))); } catch (...)//boost::regex_error& ex) { @@ -216,7 +220,8 @@ namespace mapnik filters_.pop(); if (left && right) { - filters_.push(shared_ptr >(new logical_and(*left,*right))); + filters_.push(shared_ptr > + (new logical_and(*left,*right))); } } } @@ -240,7 +245,8 @@ namespace mapnik filters_.pop(); if (left && right) { - filters_.push(shared_ptr >(new logical_or(*left,*right))); + filters_.push(shared_ptr > + (new logical_or(*left,*right))); } } } diff --git a/include/mapnik/filter_parser_ast.hpp b/include/mapnik/filter_parser_ast.hpp new file mode 100644 index 000000000..97aee4f64 --- /dev/null +++ b/include/mapnik/filter_parser_ast.hpp @@ -0,0 +1,266 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2006 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +//$Id$ + +#ifndef FILTER_PARSER_AST_HPP +#define FILTER_PARSER_AST_HPP +// stl +#include +// boost +#include +#include + +using namespace std; +using namespace boost::spirit; + +namespace mapnik +{ + + struct filter_grammar_ast : public grammar + { + + static const int integerID = 1; + static const int realID = 2; + static const int stringID = 3; + static const int propertyID = 4; + static const int factorID = 5; + static const int termID = 6; + static const int expressionID = 7; + static const int relationID = 8; + static const int equationID = 9; + static const int and_exprID = 10; + static const int or_exprID = 11; + + template + struct definition + { + + definition(filter_grammar_ast const& /*self*/) + { + real = leaf_node_d[strict_real_p]; + integer = leaf_node_d[int_p]; + number = real | integer; + + string_ = inner_node_d['\''>> leaf_node_d[( (alpha_p | '_') >> + * (alnum_p | '_' ))] >> '\'']; + + property = inner_node_d['[' >> leaf_node_d[ ( (alpha_p | '_') >> * (alnum_p | '_' )) ] >> ']']; + + literal = number | string_ | property; + + factor = literal + | (root_node_d[str_p("not")] >> literal) + | inner_node_d[ch_p('(') >> or_expr >> ch_p(')') ] + | (root_node_d[ch_p('-')] >> factor) + ; + + term = factor + >> *((root_node_d[ch_p('*')] >> factor) | (root_node_d[ch_p('/')] >> factor)); + + expression = term >> *((root_node_d[ch_p('+')] >> term) | (root_node_d[ch_p('-')] >> term)); + relation = expression >> *((root_node_d[str_p(">=")] >> expression) + | (root_node_d[ch_p('>')] >> expression) + | (root_node_d[ch_p('<')] >> expression) + | (root_node_d[str_p("<=")] >> expression)); + + equation = relation >> *( (root_node_d[ch_p('=')] >> relation) + | (root_node_d[str_p("<>")] >> relation)); + and_expr = equation >> *(root_node_d[str_p("and")] >> equation); + or_expr = and_expr >> *(root_node_d[str_p("or")] >> and_expr); + + //spatial_op = str_p("Equals") | "Disjoint" | "Touches" | "Within" + // | "Overlaps" | "Crosses" | "Intersects" | "Contains" | "DWithin" | "Beyond" | "BBOX"; + + filter_statement = or_expr; + } + + rule const& start() const + { + return filter_statement; + } + + rule, parser_tag > factor; + rule, parser_tag > term; + rule, parser_tag > expression; + rule, parser_tag > relation; + rule, parser_tag > equation; + + rule, parser_tag > and_expr; + rule, parser_tag > or_expr; + + rule filter_statement; + rule literal,number; + + rule, parser_tag > integer; + rule, parser_tag > real; + rule, parser_tag > string_; + rule, parser_tag > property; + + + //rule spatial_op; + + }; + + }; + + class node_data + { + public: + enum { + Unknown=0, + Integer=1, + Real =2, + String =3, + Property=4 + }; + node_data() + : type_(Unknown) {} + + node_data(int type) + : type_(type) {} + + node_data(node_data const& other) + : type_(other.type_) {} + + node_data& operator=(node_data const& other) + { + if (this==&other) + return *this; + type_=other.type_; + return *this; + } + ~node_data() {} + private: + int type_; + }; + + typedef char const* iterator_t; + typedef node_val_data_factory factory_t; + typedef tree_match::tree_iterator iter_t; + + void process_node(iter_t const&,string&); + + void walk_ast_tree(tree_parse_info info,string& text) + { + process_node(info.trees.begin(),text); + } + + void process_node(iter_t const& i,string& text) + { + //clog << "In eval_expression. i->value = " << + // string(i->value.begin(), i->value.end()) << + // " i->children.size() = " << i->children.size() << endl; + //std::clog<value.id() == filter_grammar_ast::integerID) + { + assert(i->children.size()==0); + string integer(i->value.begin(), i->value.end()); + text+= integer; + } + else if (i->value.id() == filter_grammar_ast::realID) + { + assert(i->children.size()==0); + string real(i->value.begin(), i->value.end()); + text += real; + } + else if (i->value.id() == filter_grammar_ast::stringID) + { + assert(i->children.size()==0); + string str(i->value.begin(), i->value.end()); + text += str; + } + else if (i->value.id() == filter_grammar_ast::propertyID) + { + assert(i->children.size()==0); + string property_name(i->value.begin(), i->value.end()); + text += property_name; + } + else if (i->value.id() == filter_grammar_ast::expressionID) + { + assert(i->children.size() == 2); + assert(!i->children.begin()->value.is_root()); + process_node(i->children.begin(),text); + text += string(i->value.begin(), i->value.end()); + process_node(i->children.begin()+1,text); + + text +="\n"; + } + else if (i->value.id() == filter_grammar_ast::termID) + { + assert(i->children.size() == 2); + assert(!i->children.begin()->value.is_root()); + process_node(i->children.begin(),text); + text += string(i->value.begin(), i->value.end()); + process_node(i->children.begin()+1,text); + + text +="\n"; + + } + else if (i->value.id() == filter_grammar_ast::relationID) + { + assert(i->children.size() == 2); + assert(!i->children.begin()->value.is_root()); + process_node(i->children.begin(),text); + text += string(i->value.begin(), i->value.end()); + process_node(i->children.begin()+1,text); + + text +="\n"; + + } + else if (i->value.id() == filter_grammar_ast::equationID) + { + assert(i->children.size() == 2); + assert(!i->children.begin()->value.is_root()); + process_node(i->children.begin(),text); + text += string(i->value.begin(), i->value.end()); + process_node(i->children.begin()+1,text); + + text +="\n"; + } + else if (i->value.id() == filter_grammar_ast::and_exprID) + { + assert(i->children.size() == 2); + assert(!i->children.begin()->value.is_root()); + process_node(i->children.begin(),text); + text += string(i->value.begin(), i->value.end()); + process_node(i->children.begin()+1,text); + + text +="\n"; + } + else if (i->value.id() == filter_grammar_ast::or_exprID) + { + assert(i->children.size() == 2); + assert(!i->children.begin()->value.is_root()); + + process_node(i->children.begin(),text); + text += string(i->value.begin(), i->value.end()); + process_node(i->children.begin()+1,text); + + text +="\n"; + + } + } +} + +#endif //FILTER_PARSER_AST_HPP diff --git a/include/filter_visitor.hpp b/include/mapnik/filter_visitor.hpp similarity index 96% rename from include/filter_visitor.hpp rename to include/mapnik/filter_visitor.hpp index 203fb06b8..015cf0ede 100644 --- a/include/filter_visitor.hpp +++ b/include/mapnik/filter_visitor.hpp @@ -25,8 +25,8 @@ #ifndef FILTER_VISITOR_HPP #define FILTER_VISITOR_HPP -#include "filter.hpp" -#include "expression.hpp" +#include +#include namespace mapnik { diff --git a/include/mapnik/font_engine_freetype.hpp b/include/mapnik/font_engine_freetype.hpp new file mode 100644 index 000000000..10581d14f --- /dev/null +++ b/include/mapnik/font_engine_freetype.hpp @@ -0,0 +1,432 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2006 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +//$Id$ + +#ifndef FONT_ENGINE_FREETYPE_HPP +#define FONT_ENGINE_FREETYPE_HPP + +// freetype2 +extern "C" +{ + #include + #include FT_FREETYPE_H + #include FT_GLYPH_H +} + +// stl +#include +#include +#include +#include +// boost +#include +#include +#include +#include +// mapnik +#include +#include + +namespace mapnik +{ + class font_face : boost::noncopyable + { + public: + font_face(FT_Face face) + : face_(face) {} + + std::string family_name() const + { + return std::string(face_->family_name); + } + + std::string style_name() const + { + return std::string(face_->style_name); + } + + unsigned num_glyphs() const + { + return face_->num_glyphs; + } + + FT_GlyphSlot glyph() const + { + return face_->glyph; + } + + FT_Face get_face() const + { + return face_; + } + + bool set_pixel_sizes(unsigned size) + { + if (! FT_Set_Pixel_Sizes( face_, 0, size )) + return true; + return false; + } + + + ~font_face() + { + std::clog << "clean up face:" << family_name()<<":" << style_name() << std::endl; + FT_Done_Face(face_); + } + + private: + FT_Face face_; + }; + + typedef boost::shared_ptr face_ptr; + + class MAPNIK_DECL freetype_engine : public mapnik::singleton, + private boost::noncopyable + { + friend class mapnik::CreateStatic; + public: + + static bool register_font(std::string const& file_name); + static std::vector face_names (); + static face_ptr create_face(std::string const& family_name); + + private: + freetype_engine(); + virtual ~freetype_engine(); + static FT_Library library_; + static std::map name2file_; + }; + + template + class MAPNIK_DECL face_manager : private boost::noncopyable + { + typedef T font_engine_type; + typedef std::map faces; + + public: + face_ptr get_face(std::string const& name) + { + typename faces::iterator itr; + itr = faces_.find(name); + if (itr != faces_.end()) + { + return itr->second; + } + else + { + face_ptr face = font_engine_type::instance()->create_face(name); + if (face) + { + faces_.insert(make_pair(name,face)); + } + return face; + } + } + private: + faces faces_; + }; + + inline std::wstring to_unicode(std::string const& text) + { + std::wstring out; + unsigned long code = 0; + int expect = 0; + std::string::const_iterator itr=text.begin(); + + while ( itr != text.end()) + { + unsigned p = (*itr++) & 0xff; + if ( p >= 0xc0) + { + if ( p < 0xe0) // U+0080 - U+07ff + { + expect = 1; + code = p & 0x1f; + } + else if ( p < 0xf0) // U+0800 - U+ffff + { + expect = 2; + code = p & 0x0f; + } + else if ( p < 0xf8) // U+1000 - U+10ffff + { + expect = 3; + code = p & 0x07; + } + continue; + } + else if (p >= 0x80) + { + --expect; + if (expect >= 0) + { + code <<= 6; + code += p & 0x3f; + } + if (expect > 0) + continue; + expect = 0; + } + else + { + code = p; // U+0000 - U+007f (ascii) + } + out.push_back(wchar_t(code)); + } + return out; + } + + template + struct text_renderer : private boost::noncopyable + { + + struct glyph_t : boost::noncopyable + { + FT_Glyph image; + glyph_t(FT_Glyph image_) : image(image_) {} + ~glyph_t () { FT_Done_Glyph(image);} + }; + + typedef boost::ptr_vector glyphs_t; + typedef std::pair dimension_t; + typedef T pixmap_type; + + text_renderer (pixmap_type & pixmap, face_ptr face) + : pixmap_(pixmap), + face_(face), + fill_(0,0,0), + halo_fill_(255,255,255), + halo_radius_(0), + angle_(0.0) {} + + void set_pixel_size(unsigned size) + { + face_->set_pixel_sizes(size); + } + + void set_angle(float angle) + { + angle_=angle; + } + + void set_fill(mapnik::Color const& fill) + { + fill_=fill; + } + + void set_halo_fill(mapnik::Color const& halo) + { + halo_fill_=halo; + } + + void set_halo_radius( int radius=1) + { + halo_radius_=radius; + } + + dimension_t prepare_glyphs(std::string const& text) + { + //clear glyphs + glyphs_.clear(); + + FT_Matrix matrix; + FT_Vector pen; + FT_Error error; + + FT_Face face = face_->get_face(); + FT_GlyphSlot slot = face->glyph; + FT_Bool use_kerning; + FT_UInt previous = 0; + + pen.x = 0; + pen.y = 0; + + use_kerning = FT_HAS_KERNING(face)>0?true:false; + + FT_BBox bbox; + bbox.xMin = bbox.yMin = 32000; + bbox.xMax = bbox.yMax = -32000; //hmm?? + + for (std::string::const_iterator i=text.begin();i!=text.end();++i) + { + FT_BBox glyph_bbox; + FT_Glyph image; + + matrix.xx = (FT_Fixed)( cos( angle_ ) * 0x10000L ); + matrix.xy = (FT_Fixed)(-sin( angle_ ) * 0x10000L ); + matrix.yx = (FT_Fixed)( sin( angle_ ) * 0x10000L ); + matrix.yy = (FT_Fixed)( cos( angle_ ) * 0x10000L ); + + FT_Set_Transform (face,&matrix,&pen); + + FT_UInt glyph_index = FT_Get_Char_Index( face, unsigned(*i) & 0xff ); + + if ( use_kerning && previous && glyph_index) + { + FT_Vector delta; + FT_Get_Kerning(face,previous,glyph_index, + FT_KERNING_DEFAULT,&delta); + pen.x += delta.x; + pen.y += delta.y; + } + + error = FT_Load_Glyph (face,glyph_index,FT_LOAD_DEFAULT); + if ( error ) + continue; + + error = FT_Get_Glyph( face->glyph, &image); + if ( error ) + continue; + + FT_Glyph_Get_CBox(image,ft_glyph_bbox_pixels, &glyph_bbox); + if (glyph_bbox.xMin < bbox.xMin) + bbox.xMin = glyph_bbox.xMin; + if (glyph_bbox.yMin < bbox.yMin) + bbox.yMin = glyph_bbox.yMin; + if (glyph_bbox.xMax > bbox.xMax) + bbox.xMax = glyph_bbox.xMax; + if (glyph_bbox.yMax > bbox.yMax) + bbox.yMax = glyph_bbox.yMax; + + if ( bbox.xMin > bbox.xMax ) + { + bbox.xMin = 0; + bbox.yMin = 0; + bbox.xMax = 0; + bbox.yMax = 0; + } + + pen.x += slot->advance.x; + pen.y += slot->advance.y; + + previous = glyph_index; + // take ownership of the glyph + glyphs_.push_back(new glyph_t(image)); + } + + unsigned string_width = (bbox.xMax - bbox.xMin); + unsigned string_height = (bbox.yMax - bbox.yMin); + return dimension_t(string_width,string_height); + } + + void render(double x0, double y0) + { + FT_Error error; + FT_Vector start; + unsigned height = pixmap_.height(); + + start.x = unsigned(x0 * (1 << 6)); + start.y = unsigned((height - y0) * (1 << 6)); + // now render transformed glyphs + typename glyphs_t::iterator pos; + + if (halo_radius_ > 0) + { + //render halo + for ( pos = glyphs_.begin(); pos != glyphs_.end();++pos) + { + + FT_Glyph_Transform(pos->image,0,&start); + + error = FT_Glyph_To_Bitmap( &(pos->image),FT_RENDER_MODE_NORMAL,0,1); + if ( ! error ) + { + + FT_BitmapGlyph bit = (FT_BitmapGlyph)pos->image; + render_halo(&bit->bitmap, halo_fill_.rgba(), + bit->left, + height - bit->top,halo_radius_); + } + } + } + //render actual text + for ( pos = glyphs_.begin(); pos != glyphs_.end();++pos) + { + + FT_Glyph_Transform(pos->image,0,&start); + + error = FT_Glyph_To_Bitmap( &(pos->image),FT_RENDER_MODE_NORMAL,0,1); + if ( ! error ) + { + + FT_BitmapGlyph bit = (FT_BitmapGlyph)pos->image; + render_bitmap(&bit->bitmap, fill_.rgba(), + bit->left, + height - bit->top); + } + } + } + + private: + + void render_halo(FT_Bitmap *bitmap,unsigned rgba,int x,int y,int radius) + { + int x_max=x+bitmap->width; + int y_max=y+bitmap->rows; + int i,p,j,q; + + for (i=x,p=0;ibuffer[q*bitmap->width+p]; + if (gray) + { + for (int n=-halo_radius_; n <=halo_radius_; ++n) + for (int m=-halo_radius_;m <= halo_radius_; ++m) + pixmap_.blendPixel(i+m,j+n,rgba,gray); + } + } + } + } + + void render_bitmap(FT_Bitmap *bitmap,unsigned rgba,int x,int y) + { + int x_max=x+bitmap->width; + int y_max=y+bitmap->rows; + int i,p,j,q; + + for (i=x,p=0;ibuffer[q*bitmap->width+p]; + if (gray) + { + pixmap_.blendPixel(i,j,rgba,gray); + } + } + } + } + + pixmap_type & pixmap_; + face_ptr face_; + Color fill_; + Color halo_fill_; + int halo_radius_; + float angle_; + glyphs_t glyphs_; + }; +} + +#endif // FONT_ENGINE_FREETYPE_HPP diff --git a/include/gamma.hpp b/include/mapnik/gamma.hpp similarity index 70% rename from include/gamma.hpp rename to include/mapnik/gamma.hpp index d64ee167f..64a71e379 100644 --- a/include/gamma.hpp +++ b/include/mapnik/gamma.hpp @@ -29,22 +29,22 @@ namespace mapnik { struct MAPNIK_DECL gamma { - unsigned char g2l[256]; - unsigned char l2g[256]; - gamma(double gamma=2.0) - { - int result; - for (int i=0;i< 256;i++) - { - result=(int)(pow(i/255.0,gamma) * 255.0 + 0.5); - g2l[i]=(unsigned char)result; - } - for (int i = 0; i < 256; i++) - { - result = (int)(pow(i/255.0, 1/gamma) * 255.0 + 0.5); - l2g[i] = (unsigned char)result; - } - } + unsigned char g2l[256]; + unsigned char l2g[256]; + gamma(double gamma=2.0) + { + int result; + for (int i=0;i< 256;i++) + { + result=(int)(pow(i/255.0,gamma) * 255.0 + 0.5); + g2l[i]=(unsigned char)result; + } + for (int i = 0; i < 256; i++) + { + result = (int)(pow(i/255.0, 1/gamma) * 255.0 + 0.5); + l2g[i] = (unsigned char)result; + } + } }; } diff --git a/include/geom_util.hpp b/include/mapnik/geom_util.hpp similarity index 97% rename from include/geom_util.hpp rename to include/mapnik/geom_util.hpp index 8ea114845..b95ed092f 100644 --- a/include/geom_util.hpp +++ b/include/mapnik/geom_util.hpp @@ -24,8 +24,13 @@ #ifndef GEOM_UTIL_HPP #define GEOM_UTIL_HPP - +// stl #include +// boost +#include +// mapnik +#include +#include namespace mapnik { diff --git a/include/geometry.hpp b/include/mapnik/geometry.hpp similarity index 98% rename from include/geometry.hpp rename to include/mapnik/geometry.hpp index ccfb48d77..f7d5e6855 100644 --- a/include/geometry.hpp +++ b/include/mapnik/geometry.hpp @@ -26,21 +26,22 @@ #ifndef GEOMETRY_HPP #define GEOMETRY_HPP -#include "vertex_vector.hpp" -#include "vertex_transform.hpp" -#include "ctrans.hpp" -#include "geom_util.hpp" +// boost #include #include +// mapnik +#include +#include +#include +#include -namespace mapnik -{ +namespace mapnik { enum { Point = 1, LineString = 2, Polygon = 3 }; - + template class geometry : private boost::noncopyable { diff --git a/include/global.hpp b/include/mapnik/global.hpp similarity index 52% rename from include/global.hpp rename to include/mapnik/global.hpp index 6bf25ff20..24a6cacf0 100644 --- a/include/global.hpp +++ b/include/mapnik/global.hpp @@ -30,32 +30,32 @@ namespace mapnik { using namespace boost; -#define int2net(A) (int32_t) (((uint32_t) ((uint8_t) (A)[1])) |\ - (((uint32_t) ((uint8_t) (A)[0])) << 8)) +#define int2net(A) (int32_t) (((uint32_t) ((uint8_t) (A)[1])) | \ + (((uint32_t) ((uint8_t) (A)[0])) << 8)) -#define int4net(A) (int32_t) (((uint32_t) ((uint8_t) (A)[3])) |\ - (((uint32_t) ((uint8_t) (A)[2])) << 8) |\ - (((uint32_t) ((uint8_t) (A)[1])) << 16) |\ - (((uint32_t) ((uint8_t) (A)[0])) << 24)) +#define int4net(A) (int32_t) (((uint32_t) ((uint8_t) (A)[3])) | \ + (((uint32_t) ((uint8_t) (A)[2])) << 8) | \ + (((uint32_t) ((uint8_t) (A)[1])) << 16) | \ + (((uint32_t) ((uint8_t) (A)[0])) << 24)) typedef char byte; -#define float8net(V,M) do { double def_temp;\ - ((byte*) &def_temp)[0]=(M)[7];\ - ((byte*) &def_temp)[1]=(M)[6];\ - ((byte*) &def_temp)[2]=(M)[5];\ - ((byte*) &def_temp)[3]=(M)[4];\ - ((byte*) &def_temp)[4]=(M)[3];\ - ((byte*) &def_temp)[5]=(M)[2];\ - ((byte*) &def_temp)[6]=(M)[1];\ - ((byte*) &def_temp)[7]=(M)[0];\ - (V) = def_temp; } while(0) -#define float4net(V,M) do { float def_temp;\ - ((byte*) &def_temp)[0]=(M)[3];\ - ((byte*) &def_temp)[1]=(M)[2];\ - ((byte*) &def_temp)[2]=(M)[1];\ - ((byte*) &def_temp)[3]=(M)[0];\ - (V)=def_temp; } while(0) +#define float8net(V,M) do { double def_temp; \ + ((byte*) &def_temp)[0]=(M)[7]; \ + ((byte*) &def_temp)[1]=(M)[6]; \ + ((byte*) &def_temp)[2]=(M)[5]; \ + ((byte*) &def_temp)[3]=(M)[4]; \ + ((byte*) &def_temp)[4]=(M)[3]; \ + ((byte*) &def_temp)[5]=(M)[2]; \ + ((byte*) &def_temp)[6]=(M)[1]; \ + ((byte*) &def_temp)[7]=(M)[0]; \ + (V) = def_temp; } while(0) +#define float4net(V,M) do { float def_temp; \ + ((byte*) &def_temp)[0]=(M)[3]; \ + ((byte*) &def_temp)[1]=(M)[2]; \ + ((byte*) &def_temp)[2]=(M)[1]; \ + ((byte*) &def_temp)[3]=(M)[0]; \ + (V)=def_temp; } while(0) } #endif //GLOBAL_HPP diff --git a/include/graphics.hpp b/include/mapnik/graphics.hpp similarity index 97% rename from include/graphics.hpp rename to include/mapnik/graphics.hpp index 48da8c7a9..7244eea05 100644 --- a/include/graphics.hpp +++ b/include/mapnik/graphics.hpp @@ -24,14 +24,15 @@ #ifndef GRAPHICS_HPP #define GRAPHICS_HPP - +// stl #include #include #include -#include "color.hpp" -#include "gamma.hpp" -#include "image_data.hpp" -#include "envelope.hpp" +// mapnik +#include +#include +#include +#include namespace mapnik { diff --git a/include/image_data.hpp b/include/mapnik/image_data.hpp similarity index 100% rename from include/image_data.hpp rename to include/mapnik/image_data.hpp diff --git a/include/image_reader.hpp b/include/mapnik/image_reader.hpp similarity index 50% rename from include/image_reader.hpp rename to include/mapnik/image_reader.hpp index b525cd9fc..b3e56513f 100644 --- a/include/image_reader.hpp +++ b/include/mapnik/image_reader.hpp @@ -1,36 +1,35 @@ /***************************************************************************** -* -* This file is part of Mapnik (c++ mapping toolkit) -* -* Copyright (C) 2006 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 -* -*****************************************************************************/ + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2006 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ //$Id: image_reader.hpp 39 2005-04-10 20:39:53Z pavlenko $ #ifndef IMAGE_READER_HPP #define IMAGE_READER_HPP - +// stl #include #include - -#include "image_data.hpp" -#include "config.hpp" - +// mapnik +#include +#include namespace mapnik { @@ -60,7 +59,6 @@ namespace mapnik bool register_image_reader(const std::string& type,ImageReader* (*)(const std::string&)); MAPNIK_DECL ImageReader* get_image_reader(const std::string& type,const std::string& file); - } -#endif //IMAGE_READER_HPP +#endif //IMAGE_READER_HPP diff --git a/include/image_util.hpp b/include/mapnik/image_util.hpp similarity index 91% rename from include/image_util.hpp rename to include/mapnik/image_util.hpp index 122bd7a9b..57b31377c 100644 --- a/include/image_util.hpp +++ b/include/mapnik/image_util.hpp @@ -25,17 +25,28 @@ #ifndef IMAGE_UTIL_HPP #define IMAGE_UTIL_HPP +// stl +#include +// mapnik +#include +#include + namespace mapnik { class MAPNIK_DECL ImageUtils { public: - static void save_to_file(const std::string& filename,const std::string& type,const Image32& image); + static void save_to_file(const std::string& filename, + const std::string& type, + const Image32& image); private: - static void save_as_png(const std::string& filename,const Image32& image); - static void save_as_jpeg(const std::string& filename,int quality, const Image32& image); + static void save_as_png(const std::string& filename, + const Image32& image); + static void save_as_jpeg(const std::string& filename, + int quality, + const Image32& image); }; - + template double distance(T x0,T y0,T x1,T y1) { diff --git a/include/label_collision_detector.hpp b/include/mapnik/label_collision_detector.hpp similarity index 55% rename from include/label_collision_detector.hpp rename to include/mapnik/label_collision_detector.hpp index f9e2db0e7..55f7754da 100644 --- a/include/label_collision_detector.hpp +++ b/include/mapnik/label_collision_detector.hpp @@ -24,9 +24,10 @@ #if !defined LABEL_COLLISION_DETECTOR #define LABEL_COLLISION_DETECTOR - -#include "quad_tree.hpp" +// stl #include +// mapnik +#include namespace mapnik { @@ -35,52 +36,52 @@ namespace mapnik struct label_collision_detector { - typedef std::vector > label_placements; + typedef std::vector > label_placements; - bool has_plasement(Envelope const& box) - { - label_placements::const_iterator itr=labels_.begin(); - for( ; itr !=labels_.end();++itr) - { - if (itr->intersects(box)) - { - return false; - } - } - labels_.push_back(box); - return true; - } + bool has_plasement(Envelope const& box) + { + label_placements::const_iterator itr=labels_.begin(); + for( ; itr !=labels_.end();++itr) + { + if (itr->intersects(box)) + { + return false; + } + } + labels_.push_back(box); + return true; + } private: - label_placements labels_; + label_placements labels_; }; // quad_tree based label collision detector class label_collision_detector2 : boost::noncopyable { - typedef quad_tree > tree_t; - tree_t tree_; + typedef quad_tree > tree_t; + tree_t tree_; public: - explicit label_collision_detector2(Envelope const& extent) - : tree_(extent) {} + explicit label_collision_detector2(Envelope const& extent) + : tree_(extent) {} - bool has_placement(Envelope const& box) - { - tree_t::query_iterator itr = tree_.query_in_box(box); - tree_t::query_iterator end = tree_.query_end(); + bool has_placement(Envelope const& box) + { + tree_t::query_iterator itr = tree_.query_in_box(box); + tree_t::query_iterator end = tree_.query_end(); - for ( ;itr != end; ++itr) - { - if (itr->intersects(box)) - { - return false; - } - } + for ( ;itr != end; ++itr) + { + if (itr->intersects(box)) + { + return false; + } + } - tree_.insert(box,box); - return true; - } + tree_.insert(box,box); + return true; + } }; } diff --git a/include/label_placement.hpp b/include/mapnik/label_placement.hpp similarity index 100% rename from include/label_placement.hpp rename to include/mapnik/label_placement.hpp diff --git a/include/layer.hpp b/include/mapnik/layer.hpp similarity index 96% rename from include/layer.hpp rename to include/mapnik/layer.hpp index d0ccdebc1..f4d16cdfe 100644 --- a/include/layer.hpp +++ b/include/mapnik/layer.hpp @@ -23,11 +23,13 @@ #ifndef LAYER_HPP #define LAYER_HPP - +// stl #include -#include "feature.hpp" -#include "datasource.hpp" +// boost #include +// mapnik +#include +#include namespace mapnik { @@ -40,12 +42,11 @@ namespace mapnik double maxZoom_; bool active_; bool selectable_; - std::vector styles_; std::string selection_style_; + datasource_p ds_; mutable std::vector > selection_; - mutable datasource_p ds_; public: explicit Layer(std::string const& name); diff --git a/include/line_pattern_symbolizer.hpp b/include/mapnik/line_pattern_symbolizer.hpp similarity index 77% rename from include/line_pattern_symbolizer.hpp rename to include/mapnik/line_pattern_symbolizer.hpp index e5c156d34..c408eecac 100644 --- a/include/line_pattern_symbolizer.hpp +++ b/include/mapnik/line_pattern_symbolizer.hpp @@ -25,20 +25,20 @@ #define LINE_PATTERN_SYMBOLIZER_HPP #include -#include "graphics.hpp" +#include namespace mapnik { struct MAPNIK_DECL line_pattern_symbolizer { - line_pattern_symbolizer(std::string const& file, - std::string const& type, - unsigned width,unsigned height); + line_pattern_symbolizer(std::string const& file, + std::string const& type, + unsigned width,unsigned height); - line_pattern_symbolizer(line_pattern_symbolizer const& rhs); - ImageData32 const& get_pattern() const; + line_pattern_symbolizer(line_pattern_symbolizer const& rhs); + ImageData32 const& get_pattern() const; private: - boost::shared_ptr pattern_; + boost::shared_ptr pattern_; }; } diff --git a/include/line_symbolizer.hpp b/include/mapnik/line_symbolizer.hpp similarity index 98% rename from include/line_symbolizer.hpp rename to include/mapnik/line_symbolizer.hpp index 08953426f..77a162a99 100644 --- a/include/line_symbolizer.hpp +++ b/include/mapnik/line_symbolizer.hpp @@ -24,7 +24,7 @@ #ifndef LINE_SYMBOLIZER_HPP #define LINE_SYMBOLIZER_HPP -#include "stroke.hpp" +#include namespace mapnik { diff --git a/include/load_map.hpp b/include/mapnik/load_map.hpp similarity index 97% rename from include/load_map.hpp rename to include/mapnik/load_map.hpp index d5a54f779..48f9025bb 100644 --- a/include/load_map.hpp +++ b/include/mapnik/load_map.hpp @@ -25,7 +25,7 @@ #define MAP_LOADER_HPP #include -#include "map.hpp" +#include namespace mapnik { diff --git a/include/local_datasource.hpp b/include/mapnik/local_datasource.hpp similarity index 100% rename from include/local_datasource.hpp rename to include/mapnik/local_datasource.hpp diff --git a/include/logical.hpp b/include/mapnik/logical.hpp similarity index 99% rename from include/logical.hpp rename to include/mapnik/logical.hpp index bb5e76560..ebd2828fc 100644 --- a/include/logical.hpp +++ b/include/mapnik/logical.hpp @@ -24,7 +24,7 @@ #ifndef LOGICAL_HPP #define LOGICAL_HPP -#include "filter.hpp" +#include namespace mapnik { diff --git a/include/map.hpp b/include/mapnik/map.hpp similarity index 98% rename from include/map.hpp rename to include/mapnik/map.hpp index e0cd5799c..819261b6e 100644 --- a/include/map.hpp +++ b/include/mapnik/map.hpp @@ -24,7 +24,7 @@ #ifndef MAP_HPP #define MAP_HPP -#include "feature_type_style.hpp" +#include namespace mapnik { diff --git a/include/math_expr.hpp b/include/mapnik/math_expr.hpp similarity index 99% rename from include/math_expr.hpp rename to include/mapnik/math_expr.hpp index 56d677f99..6f8cbeb37 100644 --- a/include/math_expr.hpp +++ b/include/mapnik/math_expr.hpp @@ -24,7 +24,7 @@ #ifndef MATH_EXPR_HPP #define MATH_EXPR_HPP -#include "expression.hpp" +#include namespace mapnik { diff --git a/include/memory.hpp b/include/mapnik/memory.hpp similarity index 58% rename from include/memory.hpp rename to include/mapnik/memory.hpp index 9276d65b2..ce680a422 100644 --- a/include/memory.hpp +++ b/include/mapnik/memory.hpp @@ -32,57 +32,57 @@ namespace mapnik class MemoryUtils { public: - static size_t alignPointerSize(size_t ptrSize); + static size_t alignPointerSize(size_t ptrSize); private: - MemoryUtils(); - MemoryUtils(const MemoryUtils&); - MemoryUtils& operator=(const MemoryUtils&); + MemoryUtils(); + MemoryUtils(const MemoryUtils&); + MemoryUtils& operator=(const MemoryUtils&); }; class MemoryManager { public: - virtual void* allocate(size_t size)=0; - virtual void deallocate(void* p)=0; - virtual ~MemoryManager(); + virtual void* allocate(size_t size)=0; + virtual void deallocate(void* p)=0; + virtual ~MemoryManager(); protected: - MemoryManager(); // {} + MemoryManager(); // {} private: - MemoryManager(const MemoryManager&); - MemoryManager& operator=(const MemoryManager&); + MemoryManager(const MemoryManager&); + MemoryManager& operator=(const MemoryManager&); }; class Object { public: - void* operator new(size_t size); - void* operator new(size_t size, MemoryManager* manager); - void operator delete(void* p); - void operator delete(void* p, MemoryManager* manager); + void* operator new(size_t size); + void* operator new(size_t size, MemoryManager* manager); + void operator delete(void* p); + void operator delete(void* p, MemoryManager* manager); protected: - virtual ~Object() {} - Object() {} - Object(const Object&) {} + virtual ~Object() {} + Object() {} + Object(const Object&) {} protected: - Object& operator=(const Object&) - { - return *this; - } + Object& operator=(const Object&) + { + return *this; + } }; template class geometry_pool { public: - void* allocate() - { - return ::operator new(sizeof(Geometry)); - } - void deallocate(void* p) - { - ::operator delete(p); - } + void* allocate() + { + return ::operator new(sizeof(Geometry)); + } + void deallocate(void* p) + { + ::operator delete(p); + } }; } -#endif //MEMORY_HPP +#endif //MEMORY_HPP diff --git a/include/params.hpp b/include/mapnik/params.hpp similarity index 99% rename from include/params.hpp rename to include/mapnik/params.hpp index e9e4bdae3..3b22ae387 100644 --- a/include/params.hpp +++ b/include/mapnik/params.hpp @@ -35,7 +35,7 @@ namespace mapnik class parameters : public param_map { - public: + public: parameters() {} const std::string get(std::string const& key) const diff --git a/include/plugin.hpp b/include/mapnik/plugin.hpp similarity index 83% rename from include/plugin.hpp rename to include/mapnik/plugin.hpp index 3263585d8..8a8632452 100644 --- a/include/plugin.hpp +++ b/include/mapnik/plugin.hpp @@ -24,9 +24,11 @@ #ifndef PLUGIN_HPP #define PLUGIN_HPP - +// ltdl #include +// stl #include +// boost #include namespace mapnik @@ -34,14 +36,14 @@ namespace mapnik class PluginInfo : boost::noncopyable { private: - std::string name_; - lt_dlhandle module_; + std::string name_; + lt_dlhandle module_; public: - PluginInfo (const std::string& name,const lt_dlhandle module); - ~PluginInfo(); - const std::string& name() const; - lt_dlhandle handle() const; + PluginInfo (const std::string& name,const lt_dlhandle module); + ~PluginInfo(); + const std::string& name() const; + lt_dlhandle handle() const; }; } diff --git a/include/point_symbolizer.hpp b/include/mapnik/point_symbolizer.hpp similarity index 98% rename from include/point_symbolizer.hpp rename to include/mapnik/point_symbolizer.hpp index 1f27dff9b..dabe5cf82 100644 --- a/include/point_symbolizer.hpp +++ b/include/mapnik/point_symbolizer.hpp @@ -25,7 +25,7 @@ #define POINT_SYMBOLIZER_HPP #include -#include "graphics.hpp" +#include namespace mapnik { diff --git a/include/polygon_pattern_symbolizer.hpp b/include/mapnik/polygon_pattern_symbolizer.hpp similarity index 76% rename from include/polygon_pattern_symbolizer.hpp rename to include/mapnik/polygon_pattern_symbolizer.hpp index 76dce4e97..9a6729875 100644 --- a/include/polygon_pattern_symbolizer.hpp +++ b/include/mapnik/polygon_pattern_symbolizer.hpp @@ -25,22 +25,22 @@ #define POLYGON_PATTERN_SYMBOLIZER_HPP #include -#include "graphics.hpp" +#include namespace mapnik { struct MAPNIK_DECL polygon_pattern_symbolizer { - polygon_pattern_symbolizer(std::string const& file, - std::string const& type, - unsigned width,unsigned height); + polygon_pattern_symbolizer(std::string const& file, + std::string const& type, + unsigned width,unsigned height); - polygon_pattern_symbolizer(polygon_pattern_symbolizer const& rhs); + polygon_pattern_symbolizer(polygon_pattern_symbolizer const& rhs); - ImageData32 const& get_pattern() const; + ImageData32 const& get_pattern() const; private: - boost::shared_ptr pattern_; + boost::shared_ptr pattern_; }; } diff --git a/include/polygon_symbolizer.hpp b/include/mapnik/polygon_symbolizer.hpp similarity index 98% rename from include/polygon_symbolizer.hpp rename to include/mapnik/polygon_symbolizer.hpp index 80532c9d8..f542c3717 100644 --- a/include/polygon_symbolizer.hpp +++ b/include/mapnik/polygon_symbolizer.hpp @@ -25,7 +25,7 @@ #ifndef POLYGON_SYMBOLIZER_HPP #define POLYGON_SYMBOLIZER_HPP -#include "color.hpp" +#include namespace mapnik { diff --git a/include/mapnik/pool.hpp b/include/mapnik/pool.hpp new file mode 100644 index 000000000..ebead74d6 --- /dev/null +++ b/include/mapnik/pool.hpp @@ -0,0 +1,122 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2006 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +//$Id: pool.hpp 39 2005-04-10 20:39:53Z pavlenko $ + +#ifndef POOL_HPP +#define POOL_HPP + +// stl +#include +#include +#include +#include +// boost +#include +#include +#include +// mapnik +#include + +namespace mapnik +{ + template + class PoolGuard + { + private: + const T& obj_; + PoolT& pool_; + public: + explicit PoolGuard(const T& ptr,PoolT& pool) + : obj_(ptr), + pool_(pool) {} + + ~PoolGuard() + { + pool_->returnObject(obj_); + } + + private: + PoolGuard(); + PoolGuard(const PoolGuard&); + PoolGuard& operator=(const PoolGuard&); + }; + + template class Creator> + class Pool : private boost::noncopyable + { + typedef boost::shared_ptr HolderType; + typedef std::deque ContType; + + Creator creator_; + const int initialSize_; + const int maxSize_; + ContType usedPool_; + ContType unusedPool_; + boost::mutex mutex_; + public: + + Pool(const Creator& creator,int initialSize=5,int maxSize=20) + :creator_(creator), + initialSize_(initialSize), + maxSize_(maxSize) + { + for (int i=0;i +// boost #include #include -#include -#include "envelope.hpp" - +// mapnik +#include namespace mapnik { diff --git a/include/query.hpp b/include/mapnik/query.hpp similarity index 96% rename from include/query.hpp rename to include/mapnik/query.hpp index 7cfdf7a8f..586ab45b8 100644 --- a/include/query.hpp +++ b/include/mapnik/query.hpp @@ -24,12 +24,13 @@ #ifndef QUERY_HPP #define QUERY_HPP - +// stl #include #include -#include "filter.hpp" -#include "envelope.hpp" -#include "feature.hpp" +//mapnik +#include +#include +#include namespace mapnik { diff --git a/include/raster.hpp b/include/mapnik/raster.hpp similarity index 87% rename from include/raster.hpp rename to include/mapnik/raster.hpp index 8a975f45b..9d2e7ce62 100644 --- a/include/raster.hpp +++ b/include/mapnik/raster.hpp @@ -24,18 +24,18 @@ #ifndef RASTER_HPP #define RASTER_HPP -#include "graphics.hpp" +#include -namespace mapnik -{ +namespace mapnik { struct raster { Envelope ext_; ImageData32 data_; - raster(Envelope const ext,ImageData32& data) - : ext_(ext), - data_(data) {} + raster(Envelope const ext,ImageData32& data) + : ext_(ext), + data_(data) {} }; } #endif //RASTER_HPP + diff --git a/include/raster_symbolizer.hpp b/include/mapnik/raster_symbolizer.hpp similarity index 93% rename from include/raster_symbolizer.hpp rename to include/mapnik/raster_symbolizer.hpp index 2d24d9048..c77bdb12c 100644 --- a/include/raster_symbolizer.hpp +++ b/include/mapnik/raster_symbolizer.hpp @@ -24,12 +24,11 @@ #ifndef RASTER_SYMBOLIZER_HPP #define RASTER_SYMBOLIZER_HPP -#include -#include +#include namespace mapnik { struct MAPNIK_DECL raster_symbolizer { /* TODO */}; } -#endif //RASTER_SYMBOLIZER +#endif //RASTER_SYMBOLIZER_HPP diff --git a/include/mapnik/regex_filter.hpp b/include/mapnik/regex_filter.hpp new file mode 100644 index 000000000..d9ad800d1 --- /dev/null +++ b/include/mapnik/regex_filter.hpp @@ -0,0 +1,81 @@ +/* This file is part of Mapnik (c++ mapping toolkit) + * Copyright (C) 2005 Artem Pavlenko + * + * Mapnik is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +//$Id$ + +#ifndef REGEX_FILTER_HPP +#define REGEX_FILTER_HPP +// boost +#include +#include +// mapnik +#include +#include + +namespace mapnik +{ + template + struct regex_filter : public filter + { + + regex_filter(expression const& exp, + std::string const& pattern) + : filter(), + exp_(exp.clone()), + pattern_(pattern) {} + + regex_filter(regex_filter const& other) + : filter(), + exp_(other.exp_->clone()), + pattern_(other.pattern_) {} + + bool pass(FeatureT const& feature) const + { + std::string text=exp_->get_value(feature).to_string(); + boost::trim_if(text, boost::is_any_of("'")); + return boost::regex_match(text,pattern_); + } + + void accept(filter_visitor& v) + { + exp_->accept(v); + v.visit(*this); + } + + filter* clone() const + { + return new regex_filter(*this); + } + std::string to_string() const + { + return exp_->to_string()+".match("+pattern_.str()+")"; + } + ~regex_filter() + { + delete exp_; + } + + private: + expression* exp_; + boost::regex pattern_; + + }; +} + + +#endif //REGEX_FILTER_HPP diff --git a/include/rule.hpp b/include/mapnik/rule.hpp similarity index 94% rename from include/rule.hpp rename to include/mapnik/rule.hpp index 76b45733d..78524081d 100644 --- a/include/rule.hpp +++ b/include/mapnik/rule.hpp @@ -22,20 +22,22 @@ #ifndef RULE_HPP #define RULE_HPP - -#include "line_symbolizer.hpp" -#include "line_pattern_symbolizer.hpp" -#include "polygon_symbolizer.hpp" -#include "polygon_pattern_symbolizer.hpp" -#include "point_symbolizer.hpp" -#include "raster_symbolizer.hpp" -#include "text_symbolizer.hpp" -#include "filter.hpp" -#include "filter_visitor.hpp" -#include -#include +// stl #include #include +// boost +#include +#include +// mapnik +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace mapnik { @@ -88,7 +90,8 @@ namespace mapnik text_symbolizer> symbolizer; - typedef std::vector symbolizers; + typedef std::vector symbolizers; + template class all_filter; template class Filter> diff --git a/include/save_map.hpp b/include/mapnik/save_map.hpp similarity index 96% rename from include/save_map.hpp rename to include/mapnik/save_map.hpp index 3369ae496..f1699a862 100644 --- a/include/save_map.hpp +++ b/include/mapnik/save_map.hpp @@ -23,9 +23,10 @@ #ifndef SAVE_MAP_HPP #define SAVE_MAP_HPP - +// stl #include -#include "map.hpp" +// mapnik +#include namespace mapnik { diff --git a/include/spatial.hpp b/include/mapnik/spatial.hpp similarity index 51% rename from include/spatial.hpp rename to include/mapnik/spatial.hpp index 5379b18a0..d17a14aef 100644 --- a/include/spatial.hpp +++ b/include/mapnik/spatial.hpp @@ -22,8 +22,8 @@ #ifndef SPATIAL_HPP #define SPATIAL_HPP -#include "filter.hpp" -#include "filter_visitor.hpp" +#include +#include namespace mapnik { @@ -32,15 +32,15 @@ namespace mapnik struct equals_ : public filter { - bool pass(const FeatureT& feature) const - { - return false; - } + bool pass(const FeatureT& feature) const + { + return false; + } - void accept(const filter_visitor& v) - { - v.visit(*this); - } + void accept(const filter_visitor& v) + { + v.visit(*this); + } }; template @@ -48,15 +48,15 @@ namespace mapnik { - bool pass(const FeatureT& feature) const - { - return false; - } + bool pass(const FeatureT& feature) const + { + return false; + } - void accept(const filter_visitor& v) - { - v.visit(*this); - } + void accept(const filter_visitor& v) + { + v.visit(*this); + } }; template @@ -64,45 +64,45 @@ namespace mapnik { - bool pass(const FeatureT& feature) const - { - return false; - } + bool pass(const FeatureT& feature) const + { + return false; + } - void accept(const filter_visitor& v) - { - v.visit(*this); - } + void accept(const filter_visitor& v) + { + v.visit(*this); + } }; template struct within : public filter { - bool pass(const FeatureT& feature) const - { - return false; - } + bool pass(const FeatureT& feature) const + { + return false; + } - void accept(const filter_visitor& v) - { - v.visit(*this); - } + void accept(const filter_visitor& v) + { + v.visit(*this); + } }; template struct overlaps : public filter { - bool pass(const FeatureT& feature) const - { - return false; - } + bool pass(const FeatureT& feature) const + { + return false; + } - void accept(const filter_visitor& v) - { - v.visit(*this); - } + void accept(const filter_visitor& v) + { + v.visit(*this); + } }; template @@ -110,44 +110,43 @@ namespace mapnik { - bool pass(const FeatureT& feature) const - { - return false; - } + bool pass(const FeatureT& feature) const + { + return false; + } - void accept(const filter_visitor& v) - { - v.visit(*this); - } + void accept(const filter_visitor& v) + { + v.visit(*this); + } }; template struct bbox : public filter { private: - Envelope box_; + Envelope box_; public: - bbox(const Envelope& box) - : box_(box) {} + bbox(const Envelope& box) + : box_(box) {} - bool pass(const FeatureT& feature) const - { - return box_.contains(feature.get_geometry()->bbox()); - } + bool pass(const FeatureT& feature) const + { + return box_.contains(feature.get_geometry()->bbox()); + } - filter* clone() const - { - return new bbox(box_); - } - void accept(const filter_visitor& v) - { - v.visit(*this); - } + filter* clone() const + { + return new bbox(box_); + } + void accept(const filter_visitor& v) + { + v.visit(*this); + } - - virtual ~bbox() {} + virtual ~bbox() {} }; } diff --git a/include/stroke.hpp b/include/mapnik/stroke.hpp similarity index 98% rename from include/stroke.hpp rename to include/mapnik/stroke.hpp index 52b37fe2f..1eb1f1280 100644 --- a/include/stroke.hpp +++ b/include/mapnik/stroke.hpp @@ -23,10 +23,11 @@ #ifndef STROKE_HPP #define STROKE_HPP - -#include "color.hpp" +// stl #include - +// mapnik +#include + namespace mapnik { using std::pair; diff --git a/include/style.hpp b/include/mapnik/style.hpp similarity index 91% rename from include/style.hpp rename to include/mapnik/style.hpp index 051b0cd9f..a13996735 100644 --- a/include/style.hpp +++ b/include/mapnik/style.hpp @@ -23,17 +23,16 @@ #ifndef STYLE_HPP #define STYLE_HPP - -#include "color.hpp" -#include "symbolizer.hpp" - +// stl #include #include #include +// boost #include +// mapnik +#include +#include -namespace mapnik -{ -} +namespace mapnik { } #endif //STYLE_HPP diff --git a/include/style_factory.hpp b/include/mapnik/style_factory.hpp similarity index 97% rename from include/style_factory.hpp rename to include/mapnik/style_factory.hpp index efe3a980c..fd20eaab3 100644 --- a/include/style_factory.hpp +++ b/include/mapnik/style_factory.hpp @@ -24,7 +24,7 @@ #ifndef STYLE_FACTORY_HPP #define STYLE_FACTORY_HPP -//#include "style.hpp" +//#include namespace mapnik { diff --git a/include/symbolizer.hpp b/include/mapnik/symbolizer.hpp similarity index 100% rename from include/symbolizer.hpp rename to include/mapnik/symbolizer.hpp diff --git a/include/text_symbolizer.hpp b/include/mapnik/text_symbolizer.hpp similarity index 51% rename from include/text_symbolizer.hpp rename to include/mapnik/text_symbolizer.hpp index d2f9e7ae4..3fa15ffc8 100644 --- a/include/text_symbolizer.hpp +++ b/include/mapnik/text_symbolizer.hpp @@ -20,48 +20,49 @@ #ifndef TEXT_SYMBOLIZER_HPP #define TEXT_SYMBOLIZER_HPP - +// stl #include +// boost #include -#include "color.hpp" +// mapnik +#include namespace mapnik { enum label_placement_e { - point_placement=1, - line_placement=2 + point_placement=1, + line_placement=2 }; typedef boost::tuple position; struct MAPNIK_DECL text_symbolizer { - text_symbolizer(std::string const& name,unsigned size,Color const& fill); - text_symbolizer(text_symbolizer const& rhs); - text_symbolizer& operator=(text_symbolizer const& rhs); - std::string const& get_name() const; - unsigned get_text_size() const; - Color const& get_fill() const; - void set_halo_fill(Color const& fill); - Color const& get_halo_fill() const; - void set_halo_radius(unsigned radius); - unsigned get_halo_radius() const; - void set_label_placement(label_placement_e label_p); - label_placement_e get_label_placement() const; + text_symbolizer(std::string const& name,unsigned size,Color const& fill); + text_symbolizer(text_symbolizer const& rhs); + text_symbolizer& operator=(text_symbolizer const& rhs); + std::string const& get_name() const; + unsigned get_text_size() const; + Color const& get_fill() const; + void set_halo_fill(Color const& fill); + Color const& get_halo_fill() const; + void set_halo_radius(unsigned radius); + unsigned get_halo_radius() const; + void set_label_placement(label_placement_e label_p); + label_placement_e get_label_placement() const; void set_anchor(double x, double y); - position const& get_anchor() const; - void set_displacement(double x, double y); - position const& get_displacement() const; - + position const& get_anchor() const; + void set_displacement(double x, double y); + position const& get_displacement() const; private: - std::string name_; - unsigned size_; - Color fill_; - Color halo_fill_; - unsigned halo_radius_; - label_placement_e label_p_; - position anchor_; - position displacement_; + std::string name_; + unsigned size_; + Color fill_; + Color halo_fill_; + unsigned halo_radius_; + label_placement_e label_p_; + position anchor_; + position displacement_; }; } diff --git a/include/mapnik/utils.hpp b/include/mapnik/utils.hpp new file mode 100644 index 000000000..863813b1b --- /dev/null +++ b/include/mapnik/utils.hpp @@ -0,0 +1,222 @@ +/* This file is part of Mapnik (c++ mapping toolkit) + * Copyright (C) 2005 Artem Pavlenko + * + * Mapnik is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +//$Id: utils.hpp 39 2005-04-10 20:39:53Z pavlenko $ + +#ifndef UTILS_HPP +#define UTILS_HPP +// stl +#include +#include +#include +#include +#include +#include +#include +// boost +#include + +namespace mapnik +{ + using boost::mutex; + + template + class CreateUsingNew + { + public: + static T* create() + { + return new T; + } + static void destroy(T* obj) + { + delete obj; + } + }; + + template + class CreateStatic + { + private: + union MaxAlign + { + char t_[sizeof(T)]; + short int shortInt_; + int int_; + long int longInt_; + float float_; + double double_; + long double longDouble_; + struct Test; + int Test::* pMember_; + int (Test::*pMemberFn_)(int); + }; + public: + static T* create() + { + static MaxAlign staticMemory; + return new(&staticMemory) T; + } + static void destroy(volatile T* obj) + { + obj->~T(); + } + }; + + template class CreatePolicy=CreateStatic> class singleton + { + friend class CreatePolicy; + static T* pInstance_; + static bool destroyed_; + singleton(const singleton &rhs); + singleton& operator=(const singleton&); + static void onDeadReference() + { + throw std::runtime_error("dead reference!"); + } + protected: + static mutex mutex_; + singleton() {} + virtual ~singleton() + { + CreatePolicy::destroy(pInstance_); + destroyed_=true; + } + public: + static T* instance() + { + if (!pInstance_) + { + mutex::scoped_lock lock(mutex_); + if (!pInstance_) + { + if (destroyed_) + { + onDeadReference(); + } + else + { + pInstance_=CreatePolicy::create(); + } + } + } + return pInstance_; + } + }; + + template class CreatePolicy> mutex singleton::mutex_; + template class CreatePolicy> T* singleton::pInstance_=0; + template class CreatePolicy> bool singleton::destroyed_=false; + + template class Handle + { + T* ptr_; + int* pCount_; + public: + T* operator->() {return ptr_;} + const T* operator->() const {return ptr_;} + Handle(T* ptr) + :ptr_(ptr),pCount_(new int(1)) {} + Handle(const Handle& rhs) + :ptr_(rhs.ptr_),pCount_(rhs.pCount_) + { + (*pCount_)++; + } + Handle& operator=(const Handle& rhs) + { + if (ptr_==rhs.ptr_) return *this; + if (--(*pCount_)==0) + { + delete ptr_; + delete pCount_; + } + ptr_=rhs.ptr_; + pCount_=rhs.pCount_; + (*pCount_)++; + return *this; + } + ~Handle() + { + if (--(*pCount_)==0) + { + delete ptr_; + delete pCount_; + } + } + }; + + + struct timer + { + //struct timeval tv_; + timer() + { + //gettimeofday (&tv_,0); + } + void start() + { + //gettimeofday (&tv_,0); + } + void stop() + { + //timeval tv; + //gettimeofday (&tv,0); + //std::ostringstream s; + //long sec=1000*(tv.tv_sec-tv_.tv_sec); + //long total_ms=sec+static_cast(0.001*(tv.tv_usec-tv_.tv_usec)); + //s << "elapsed time is "< + inline std::string toString(const T& x) + { + std::ostringstream o; + if (!(o << x)) + throw BadConversion(std::string("toString(") + + typeid(x).name() + ")"); + return o.str(); + } + + template + inline void fromString(const std::string& s, T& x, + bool failIfLeftoverChars = true) + { + std::istringstream i(s); + char c; + if (!(i >> x) || (failIfLeftoverChars && i.get(c))) + throw BadConversion("fromString("+s+")"); + } +} + + +#endif //UTILS_HPP diff --git a/include/mapnik/value.hpp b/include/mapnik/value.hpp new file mode 100644 index 000000000..9b1f33e79 --- /dev/null +++ b/include/mapnik/value.hpp @@ -0,0 +1,452 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2006 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ +//$Id$ + +#ifndef VALUE_HPP +#define VALUE_HPP + +// stl +#include +#include +#include + +// boost +#include + +namespace mapnik { + typedef boost::variant value_base; + + namespace impl { + struct equals + : public boost::static_visitor + { + template + bool operator() (const T &, const U & ) const + { + return false; + } + + template + bool operator() (T lhs, T rhs) const + { + return lhs == rhs; + } + + bool operator() (int lhs, double rhs) const + { + return lhs == rhs; + } + + bool operator() (double lhs, int rhs) const + { + return lhs == rhs; + } + + bool operator() (std::string const& lhs, + std::string const& rhs) const + { + return lhs == rhs; + } + }; + + struct greater_than + : public boost::static_visitor + { + template + bool operator()( const T &, const U & ) const + { + return false; + } + + template + bool operator()( T lhs, T rhs ) const + { + return lhs > rhs; + } + + bool operator() (int lhs, double rhs) const + { + return lhs > rhs; + } + + bool operator() (double lhs, int rhs) const + { + return lhs > rhs; + } + + bool operator() (std::string const& lhs, std::string const& rhs) const + { + return lhs > rhs; + } + }; + + struct greater_or_equal + : public boost::static_visitor + { + template + bool operator()( const T &, const U & ) const + { + return false; + } + + template + bool operator() (T lhs, T rhs) const + { + return lhs >= rhs; + } + + bool operator() (int lhs, double rhs) const + { + return lhs >= rhs; + } + + bool operator() (double lhs, int rhs) const + { + return lhs >= rhs; + } + + bool operator() (std::string const& lhs, std::string const& rhs ) const + { + return lhs >= rhs; + } + }; + + struct less_than + : public boost::static_visitor + { + template + bool operator()( const T &, const U & ) const + { + return false; + } + + template + bool operator()( T lhs,T rhs) const + { + return lhs < rhs; + } + + bool operator() (int lhs, double rhs) const + { + return lhs < rhs; + } + + bool operator() (double lhs, int rhs) const + { + return lhs < rhs; + } + + bool operator()( std::string const& lhs, + std::string const& rhs ) const + { + return lhs < rhs; + } + }; + + struct less_or_equal + : public boost::static_visitor + { + template + bool operator()( const T &, const U & ) const + { + return false; + } + + template + bool operator()(T lhs, T rhs ) const + { + return lhs <= rhs; + } + + bool operator() (int lhs, double rhs) const + { + return lhs <= rhs; + } + + bool operator() (double lhs, int rhs) const + { + return lhs <= rhs; + } + + template + bool operator()( std::string const& lhs, + std::string const& rhs ) const + { + return lhs <= rhs; + } + }; + + template + struct add : public boost::static_visitor + { + typedef V value_type; + template + value_type operator() (T1 const& lhs, T2 const&) const + { + return lhs; + } + template + value_type operator() (T lhs, T rhs) const + { + return lhs + rhs ; + } + + value_type operator() (std::string const& lhs , + std::string const& rhs ) const + { + return lhs + rhs; + } + + value_type operator() (double lhs, int rhs) const + { + return lhs + rhs; + } + + value_type operator() (int lhs, double rhs) const + { + return lhs + rhs; + } + }; + template + struct sub : public boost::static_visitor + { + typedef V value_type; + template + value_type operator() (T1 const& lhs, T2 const&) const + { + return lhs; + } + + template + value_type operator() (T lhs, T rhs) const + { + return lhs - rhs ; + } + + value_type operator() (std::string const& lhs, + std::string const& ) const + { + return lhs; + } + + value_type operator() (double lhs, int rhs) const + { + return lhs - rhs; + } + + value_type operator() (int lhs, double rhs) const + { + return lhs - rhs; + } + }; + + template + struct mult : public boost::static_visitor + { + typedef V value_type; + template + value_type operator() (T1 const& lhs , T2 const& ) const + { + return lhs; + } + template + value_type operator() (T lhs, T rhs) const + { + return lhs * rhs; + } + + value_type operator() (std::string const& lhs, + std::string const& ) const + { + return lhs; + } + + value_type operator() (double lhs, int rhs) const + { + return lhs * rhs; + } + + value_type operator() (int lhs, double rhs) const + { + return lhs * rhs; + } + }; + + template + struct div: public boost::static_visitor + { + typedef V value_type; + template + value_type operator() (T1 const& lhs, T2 const&) const + { + return lhs; + } + + template + value_type operator() (T lhs, T rhs) const + { + return lhs / rhs; + } + + value_type operator() (std::string const& lhs, + std::string const&) const + { + return lhs; + } + + value_type operator() (double lhs, int rhs) const + { + return lhs / rhs; + } + + value_type operator() (int lhs, double rhs) const + { + return lhs / rhs; + } + }; + + struct to_string : public boost::static_visitor + { + template + std::string operator() (T val) const + { + std::stringstream ss; + ss << val; + return ss.str(); + } + std::string const& operator() (std::string const& val) const + { + return val; + } + }; + + struct to_expression_string : public boost::static_visitor + { + template + std::string operator() (T val) const + { + std::stringstream ss; + ss << val; + return ss.str(); + } + std::string operator() (std::string const& val) const + { + return "'" + val + "'"; + } + }; + } + + class value + { + value_base base_; + friend const value operator+(value const&,value const&); + friend const value operator-(value const&,value const&); + friend const value operator*(value const&,value const&); + friend const value operator/(value const&,value const&); + + public: + value () + : base_(0) {} + + template value(T _val_) + : base_(_val_) {} + + bool operator==(value const& other) const + { + return boost::apply_visitor(impl::equals(),base_,other.base_); + } + + bool operator!=(value const& other) const + { + return !(boost::apply_visitor(impl::equals(),base_,other.base_)); + } + + bool operator>(value const& other) const + { + return boost::apply_visitor(impl::greater_than(),base_,other.base_); + } + + bool operator>=(value const& other) const + { + return boost::apply_visitor(impl::greater_or_equal(),base_,other.base_); + } + + bool operator<(value const& other) const + { + return boost::apply_visitor(impl::less_than(),base_,other.base_); + } + + bool operator<=(value const& other) const + { + return boost::apply_visitor(impl::less_or_equal(),base_,other.base_); + } + value_base const& base() const + { + return base_; + } + + std::string to_expression_string() const + { + return boost::apply_visitor(impl::to_expression_string(),base_); + } + + std::string to_string() const + { + return boost::apply_visitor(impl::to_string(),base_); + } + }; + + inline const value operator+(value const& p1,value const& p2) + { + + return value(boost::apply_visitor(impl::add(),p1.base_, p2.base_)); + } + + inline const value operator-(value const& p1,value const& p2) + { + + return value(boost::apply_visitor(impl::sub(),p1.base_, p2.base_)); + } + + inline const value operator*(value const& p1,value const& p2) + { + + return value(boost::apply_visitor(impl::mult(),p1.base_, p2.base_)); + } + + inline const value operator/(value const& p1,value const& p2) + { + + return value(boost::apply_visitor(impl::div(),p1.base_, p2.base_)); + } + + template + inline std::basic_ostream& + operator << (std::basic_ostream& out, + value const& v) + { + out << v.base(); + return out; + } +} + +#endif //VALUE_HPP diff --git a/include/vertex.hpp b/include/mapnik/vertex.hpp similarity index 74% rename from include/vertex.hpp rename to include/mapnik/vertex.hpp index 4623caf3a..a8fdacdec 100644 --- a/include/vertex.hpp +++ b/include/mapnik/vertex.hpp @@ -29,8 +29,7 @@ namespace mapnik { - enum - { + enum { SEG_END =0, SEG_MOVETO=1, SEG_LINETO=2, @@ -39,38 +38,38 @@ namespace mapnik template struct vertex { - typedef T type; + typedef T type; }; template struct vertex { - typedef T type; - T x; - T y; - unsigned cmd; - vertex() - : x(0),y(0),cmd(SEG_END) {} - vertex(T x,T y,unsigned cmd) - : x(x),y(y),cmd(cmd) {} + typedef T type; + T x; + T y; + unsigned cmd; + vertex() + : x(0),y(0),cmd(SEG_END) {} + vertex(T x,T y,unsigned cmd) + : x(x),y(y),cmd(cmd) {} - template - vertex(const vertex& rhs) - : x(type(rhs.x)), - y(type(rhs.y)), - cmd(rhs.cmd) {} + template + vertex(const vertex& rhs) + : x(type(rhs.x)), + y(type(rhs.y)), + cmd(rhs.cmd) {} - template vertex operator=(const vertex& rhs) - { - if ((void*)this == (void*)&rhs) - { - return *this; - } - x=type(rhs.x); - y=type(rhs.y); - cmd=rhs.cmd; - return *this; - } + template vertex operator=(const vertex& rhs) + { + if ((void*)this == (void*)&rhs) + { + return *this; + } + x=type(rhs.x); + y=type(rhs.y); + cmd=rhs.cmd; + return *this; + } }; typedef vertex vertex2d; @@ -80,12 +79,12 @@ namespace mapnik template inline std::basic_ostream& operator << (std::basic_ostream& out, - const vertex& c); + const vertex& c); template inline std::basic_ostream& operator << (std::basic_ostream& out, - const vertex& v) + const vertex& v) { std::basic_ostringstream s; s.copyfmt(out); @@ -98,7 +97,7 @@ namespace mapnik template inline std::basic_ostream& operator << (std::basic_ostream& out, - const vertex& v) + const vertex& v) { std::basic_ostringstream s; s.copyfmt(out); diff --git a/include/vertex_transform.hpp b/include/mapnik/vertex_transform.hpp similarity index 97% rename from include/vertex_transform.hpp rename to include/mapnik/vertex_transform.hpp index e71a633f3..420272ec3 100644 --- a/include/vertex_transform.hpp +++ b/include/mapnik/vertex_transform.hpp @@ -24,8 +24,9 @@ #ifndef VERTEX_TRANSFORM_HPP #define VERTEX_TRANSFORM_HPP -#include "vertex.hpp" -#include "envelope.hpp" +// mapnik +#include +#include namespace mapnik { diff --git a/include/vertex_vector.hpp b/include/mapnik/vertex_vector.hpp similarity index 98% rename from include/vertex_vector.hpp rename to include/mapnik/vertex_vector.hpp index 3828e3901..85ce061d4 100644 --- a/include/vertex_vector.hpp +++ b/include/mapnik/vertex_vector.hpp @@ -29,13 +29,14 @@ #ifndef VERTEX_VECTOR_HPP #define VERTEX_VECTOT_HPP - -#include "vertex.hpp" -#include "ctrans.hpp" - +// stl #include +// boost #include #include +// mapnik +#include +#include namespace mapnik { diff --git a/include/wkb.hpp b/include/mapnik/wkb.hpp similarity index 82% rename from include/wkb.hpp rename to include/mapnik/wkb.hpp index ded63a724..884ce486d 100644 --- a/include/wkb.hpp +++ b/include/mapnik/wkb.hpp @@ -25,19 +25,19 @@ #ifndef WKB_HPP #define WKB_HPP -#include "geometry.hpp" -#include "ctrans.hpp" +#include +#include namespace mapnik { class MAPNIK_DECL geometry_utils { public: - static geometry_ptr from_wkb(const char* wkb, unsigned size,int srid); + static geometry_ptr from_wkb(const char* wkb, unsigned size,int srid); private: - geometry_utils(); - geometry_utils(const geometry_utils&); - geometry_utils& operator=(const geometry_utils&); + geometry_utils(); + geometry_utils(const geometry_utils&); + geometry_utils& operator=(const geometry_utils&); }; } #endif //WKB_HPP diff --git a/include/pool.hpp b/include/pool.hpp deleted file mode 100644 index 2edaff4d1..000000000 --- a/include/pool.hpp +++ /dev/null @@ -1,119 +0,0 @@ -/***************************************************************************** - * - * This file is part of Mapnik (c++ mapping toolkit) - * - * Copyright (C) 2006 Artem Pavlenko - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - *****************************************************************************/ - -//$Id: pool.hpp 39 2005-04-10 20:39:53Z pavlenko $ - -#ifndef POOL_HPP -#define POOL_HPP - -#include -#include -#include -#include -#include "utils.hpp" -#include -#include -#include - -namespace mapnik -{ - template - class PoolGuard - { - private: - const T& obj_; - PoolT& pool_; - public: - explicit PoolGuard(const T& ptr,PoolT& pool) - : obj_(ptr), - pool_(pool) {} - - ~PoolGuard() - { - pool_->returnObject(obj_); - } - - private: - PoolGuard(); - PoolGuard(const PoolGuard&); - PoolGuard& operator=(const PoolGuard&); - }; - - template class Creator> - class Pool : private boost::noncopyable - { - typedef boost::shared_ptr HolderType; - typedef std::deque ContType; - - Creator creator_; - const int initialSize_; - const int maxSize_; - ContType usedPool_; - ContType unusedPool_; - boost::mutex mutex_; - public: - - Pool(const Creator& creator,int initialSize=5,int maxSize=20) - :creator_(creator), - initialSize_(initialSize), - maxSize_(maxSize) - { - for (int i=0;i -#include - -namespace mapnik -{ - template - struct regex_filter : public filter - { - - regex_filter(expression const& exp, - std::string const& pattern) - : filter(), - exp_(exp.clone()), - pattern_(pattern) {} - - regex_filter(regex_filter const& other) - : filter(), - exp_(other.exp_->clone()), - pattern_(other.pattern_) {} - - bool pass(FeatureT const& feature) const - { - std::string text=exp_->get_value(feature).to_string(); - boost::trim_if(text,is_any_of("'")); - return boost::regex_match(text,pattern_); - } - - void accept(filter_visitor& v) - { - exp_->accept(v); - v.visit(*this); - } - - filter* clone() const - { - return new regex_filter(*this); - } - std::string to_string() const - { - return exp_->to_string()+".match("+pattern_.str()+")"; - } - ~regex_filter() - { - delete exp_; - } - - private: - expression* exp_; - boost::regex pattern_; - - }; -} - - -#endif //REGEX_FILTER_HPP diff --git a/include/utils.hpp b/include/utils.hpp deleted file mode 100644 index 323727af1..000000000 --- a/include/utils.hpp +++ /dev/null @@ -1,249 +0,0 @@ -/* This file is part of Mapnik (c++ mapping toolkit) - * Copyright (C) 2005 Artem Pavlenko - * - * Mapnik is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -//$Id: utils.hpp 39 2005-04-10 20:39:53Z pavlenko $ - -#ifndef UTILS_HPP -#define UTILS_HPP - -#include -#include -#include -//#include -#include -#include -#include -#include - -#include - -namespace mapnik -{ - using boost::mutex; - - template - class CreateUsingNew - { - public: - static T* create() - { - return new T; - } - static void destroy(T* obj) - { - delete obj; - } - }; - - template - class CreateStatic - { - private: - union MaxAlign - { - char t_[sizeof(T)]; - short int shortInt_; - int int_; - long int longInt_; - float float_; - double double_; - long double longDouble_; - struct Test; - int Test::* pMember_; - int (Test::*pMemberFn_)(int); - }; - public: - static T* create() - { - static MaxAlign staticMemory; - return new(&staticMemory) T; - } - static void destroy(volatile T* obj) - { - obj->~T(); - } - }; - - template class CreatePolicy=CreateStatic> class singleton - { - friend class CreatePolicy; - static T* pInstance_; - static bool destroyed_; - singleton(const singleton &rhs); - singleton& operator=(const singleton&); - static void onDeadReference() - { - throw std::runtime_error("dead reference!"); - } - protected: - static mutex mutex_; - singleton() {} - virtual ~singleton() - { - CreatePolicy::destroy(pInstance_); - destroyed_=true; - } - public: - static T* instance() - { - if (!pInstance_) - { - mutex::scoped_lock lock(mutex_); - if (!pInstance_) - { - if (destroyed_) - { - onDeadReference(); - } - else - { - pInstance_=CreatePolicy::create(); - } - } - } - return pInstance_; - } - }; - - template class CreatePolicy> mutex singleton::mutex_; - template class CreatePolicy> T* singleton::pInstance_=0; - template class CreatePolicy> bool singleton::destroyed_=false; - - template class Handle - { - T* ptr_; - int* pCount_; - public: - T* operator->() {return ptr_;} - const T* operator->() const {return ptr_;} - Handle(T* ptr) - :ptr_(ptr),pCount_(new int(1)) {} - Handle(const Handle& rhs) - :ptr_(rhs.ptr_),pCount_(rhs.pCount_) - { - (*pCount_)++; - } - Handle& operator=(const Handle& rhs) - { - if (ptr_==rhs.ptr_) return *this; - if (--(*pCount_)==0) - { - delete ptr_; - delete pCount_; - } - ptr_=rhs.ptr_; - pCount_=rhs.pCount_; - (*pCount_)++; - return *this; - } - ~Handle() - { - if (--(*pCount_)==0) - { - delete ptr_; - delete pCount_; - } - } - }; - - - struct timer - { - //struct timeval tv_; - timer() - { - //gettimeofday (&tv_,0); - } - void start() - { - //gettimeofday (&tv_,0); - } - void stop() - { - //timeval tv; - //gettimeofday (&tv,0); - //std::ostringstream s; - //long sec=1000*(tv.tv_sec-tv_.tv_sec); - //long total_ms=sec+static_cast(0.001*(tv.tv_usec-tv_.tv_usec)); - //s << "elapsed time is "< - inline std::string toString(const T& x) - { - std::ostringstream o; - if (!(o << x)) - throw BadConversion(std::string("toString(") - + typeid(x).name() + ")"); - return o.str(); - } - - template - inline void fromString(const std::string& s, T& x, - bool failIfLeftoverChars = true) - { - std::istringstream i(s); - char c; - if (!(i >> x) || (failIfLeftoverChars && i.get(c))) - throw BadConversion("fromString("+s+")"); - } - - //inline bool space (char c) - //{ -// return isspace(c); - // } - - // inline bool not_space (char c) - //{ -// return !isspace(c); - // } - - //inline std::string trim_left(const std::string& str) - //{ -// typedef std::string::const_iterator iter; -// iter i = std::find_if(str.begin(),str.end(),not_space); - //return std::string(i,str.end()); - //} - //inline std::string trim_right(const std::string& str) - //{ - // std::string::size_type idx=str.find_last_not_of(" "); -// return str.substr(0,idx+1); - // } -// inline std::string trim(const std::string& str) - // { - // return trim_left(trim_right(str)); - //} -} - - -#endif //UTILS_HPP diff --git a/include/value.hpp b/include/value.hpp deleted file mode 100644 index 035e96f4d..000000000 --- a/include/value.hpp +++ /dev/null @@ -1,443 +0,0 @@ -/***************************************************************************** - * - * This file is part of Mapnik (c++ mapping toolkit) - * - * Copyright (C) 2006 Artem Pavlenko - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - *****************************************************************************/ -//$Id$ - -#ifndef VALUE_HPP -#define VALUE_HPP - -#include -#include -#include - -using namespace boost; -namespace mapnik { - - typedef variant value_base; - - namespace impl { - struct equals - : public boost::static_visitor - { - template - bool operator() (const T &, const U & ) const - { - return false; - } - - template - bool operator() (T lhs, T rhs) const - { - return lhs == rhs; - } - - bool operator() (int lhs, double rhs) const - { - return lhs == rhs; - } - - bool operator() (double lhs, int rhs) const - { - return lhs == rhs; - } - - bool operator() (std::string const& lhs, std::string const& rhs) const - { - return lhs == rhs; - } - }; - - struct greater_than - : public boost::static_visitor - { - template - bool operator()( const T &, const U & ) const - { - return false; - } - - template - bool operator()( T lhs, T rhs ) const - { - return lhs > rhs; - } - - bool operator() (int lhs, double rhs) const - { - return lhs > rhs; - } - - bool operator() (double lhs, int rhs) const - { - return lhs > rhs; - } - - bool operator() (std::string const& lhs, std::string const& rhs) const - { - return lhs > rhs; - } - }; - - struct greater_or_equal - : public boost::static_visitor - { - template - bool operator()( const T &, const U & ) const - { - return false; - } - - template - bool operator() (T lhs, T rhs) const - { - return lhs >= rhs; - } - - bool operator() (int lhs, double rhs) const - { - return lhs >= rhs; - } - - bool operator() (double lhs, int rhs) const - { - return lhs >= rhs; - } - - bool operator() (std::string const& lhs, std::string const& rhs ) const - { - return lhs >= rhs; - } - }; - - struct less_than - : public boost::static_visitor - { - template - bool operator()( const T &, const U & ) const - { - return false; - } - - template - bool operator()( T lhs,T rhs) const - { - return lhs < rhs; - } - - bool operator() (int lhs, double rhs) const - { - return lhs < rhs; - } - - bool operator() (double lhs, int rhs) const - { - return lhs < rhs; - } - - bool operator()( std::string const& lhs, std::string const& rhs ) const - { - return lhs < rhs; - } - }; - - struct less_or_equal - : public boost::static_visitor - { - template - bool operator()( const T &, const U & ) const - { - return false; - } - - template - bool operator()(T lhs, T rhs ) const - { - return lhs <= rhs; - } - - bool operator() (int lhs, double rhs) const - { - return lhs <= rhs; - } - - bool operator() (double lhs, int rhs) const - { - return lhs <= rhs; - } - - template - bool operator()( std::string const& lhs, std::string const& rhs ) const - { - return lhs <= rhs; - } - }; - - template - struct add : public boost::static_visitor - { - typedef V value_type; - template - value_type operator() (T1 const& lhs, T2 const&) const - { - return lhs; - } - template - value_type operator() (T lhs, T rhs) const - { - return lhs + rhs ; - } - - value_type operator() (std::string const& lhs,std::string const& rhs ) const - { - return lhs + rhs; - } - - value_type operator() (double lhs, int rhs) const - { - return lhs + rhs; - } - - value_type operator() (int lhs, double rhs) const - { - return lhs + rhs; - } - }; - template - struct sub : public boost::static_visitor - { - typedef V value_type; - template - value_type operator() (T1 const& lhs, T2 const&) const - { - return lhs; - } - - template - value_type operator() (T lhs, T rhs) const - { - return lhs - rhs ; - } - - value_type operator() (std::string const& lhs,std::string const& ) const - { - return lhs; - } - - value_type operator() (double lhs, int rhs) const - { - return lhs - rhs; - } - - value_type operator() (int lhs, double rhs) const - { - return lhs - rhs; - } - }; - - template - struct mult : public boost::static_visitor - { - typedef V value_type; - template - value_type operator() (T1 const& lhs , T2 const& ) const - { - return lhs; - } - template - value_type operator() (T lhs, T rhs) const - { - return lhs * rhs; - } - - value_type operator() (std::string const& lhs,std::string const& ) const - { - return lhs; - } - - value_type operator() (double lhs, int rhs) const - { - return lhs * rhs; - } - - value_type operator() (int lhs, double rhs) const - { - return lhs * rhs; - } - }; - - template - struct div: public boost::static_visitor - { - typedef V value_type; - template - value_type operator() (T1 const& lhs, T2 const&) const - { - return lhs; - } - - template - value_type operator() (T lhs, T rhs) const - { - return lhs / rhs; - } - - value_type operator() (std::string const& lhs,std::string const&) const - { - return lhs; - } - - value_type operator() (double lhs, int rhs) const - { - return lhs / rhs; - } - - value_type operator() (int lhs, double rhs) const - { - return lhs / rhs; - } - }; - - struct to_string : public boost::static_visitor - { - template - std::string operator() (T val) const - { - std::stringstream ss; - ss << val; - return ss.str(); - } - std::string const& operator() (std::string const& val) const - { - return val; - } - }; - - struct to_expression_string : public boost::static_visitor - { - template - std::string operator() (T val) const - { - std::stringstream ss; - ss << val; - return ss.str(); - } - std::string operator() (std::string const& val) const - { - return "'" + val + "'"; - } - }; - } - - class value - { - value_base base_; - friend const value operator+(value const&,value const&); - friend const value operator-(value const&,value const&); - friend const value operator*(value const&,value const&); - friend const value operator/(value const&,value const&); - - public: - value () - : base_(0) {} - - template value(T _val_) - : base_(_val_) {} - - bool operator==(value const& other) const - { - return boost::apply_visitor(impl::equals(),base_,other.base_); - } - - bool operator!=(value const& other) const - { - return !(boost::apply_visitor(impl::equals(),base_,other.base_)); - } - - bool operator>(value const& other) const - { - return boost::apply_visitor(impl::greater_than(),base_,other.base_); - } - - bool operator>=(value const& other) const - { - return boost::apply_visitor(impl::greater_or_equal(),base_,other.base_); - } - - bool operator<(value const& other) const - { - return boost::apply_visitor(impl::less_than(),base_,other.base_); - } - - bool operator<=(value const& other) const - { - return boost::apply_visitor(impl::less_or_equal(),base_,other.base_); - } - value_base const& base() const - { - return base_; - } - - std::string to_expression_string() const - { - return boost::apply_visitor(impl::to_expression_string(),base_); - } - - std::string to_string() const - { - return boost::apply_visitor(impl::to_string(),base_); - } - }; - - inline const value operator+(value const& p1,value const& p2) - { - - return value(boost::apply_visitor(impl::add(),p1.base_, p2.base_)); - } - - inline const value operator-(value const& p1,value const& p2) - { - - return value(boost::apply_visitor(impl::sub(),p1.base_, p2.base_)); - } - - inline const value operator*(value const& p1,value const& p2) - { - - return value(boost::apply_visitor(impl::mult(),p1.base_, p2.base_)); - } - - inline const value operator/(value const& p1,value const& p2) - { - - return value(boost::apply_visitor(impl::div(),p1.base_, p2.base_)); - } - - template - inline std::basic_ostream& - operator << (std::basic_ostream& out, - value const& v) - { - out << v.base(); - return out; - } -} - -#endif //VALUE_HPP diff --git a/plugins/input/postgis/SConscript b/plugins/input/postgis/SConscript index fdb926853..d7ea75ae2 100644 --- a/plugins/input/postgis/SConscript +++ b/plugins/input/postgis/SConscript @@ -32,5 +32,5 @@ postgis_src = Split( postgis_inputdriver = env.SharedLibrary('postgis', source=postgis_src, SHLIBPREFIX='', LIBS='pq') -env.Install(prefix + '/' + env['LIB_PLATFORM'] + '/mapnik/input', postgis_inputdriver) -env.Alias('install', prefix + '/' + env['LIB_PLATFORM'] + '/mapnik/input') +env.Install(prefix + '/' + env['LIBDIR_SCHEMA'] + '/mapnik/input', postgis_inputdriver) +env.Alias('install', prefix + '/' + env['LIBDIR_SCHEMA'] + '/mapnik/input') diff --git a/plugins/input/raster/SConscript b/plugins/input/raster/SConscript index b855764e8..50e8ec547 100644 --- a/plugins/input/raster/SConscript +++ b/plugins/input/raster/SConscript @@ -33,5 +33,5 @@ raster_src = Split( raster_inputdriver = env.SharedLibrary('raster', source=raster_src, SHLIBPREFIX='', LIBS=[]) -env.Install(prefix + '/' + env['LIB_PLATFORM'] + '/mapnik/input', raster_inputdriver) -env.Alias('install', prefix + '/' + env['LIB_PLATFORM'] + '/mapnik/input') +env.Install(prefix + '/' + env['LIBDIR_SCHEMA'] + '/mapnik/input', raster_inputdriver) +env.Alias('install', prefix + '/' + env['LIBDIR_SCHEMA'] + '/mapnik/input') diff --git a/plugins/input/raster/raster_datasource.cpp b/plugins/input/raster/raster_datasource.cpp index 4fb3e937d..d4685917e 100644 --- a/plugins/input/raster/raster_datasource.cpp +++ b/plugins/input/raster/raster_datasource.cpp @@ -20,12 +20,15 @@ * *****************************************************************************/ //$Id: raster_datasource.cc 44 2005-04-22 18:53:54Z pavlenko $ +// boost +#include +// mapnik +#include -#include "raster_datasource.hpp" -#include "image_reader.hpp" #include "raster_featureset.hpp" #include "raster_info.hpp" -#include + +#include "raster_datasource.hpp" DATASOURCE_PLUGIN(raster_datasource) diff --git a/plugins/input/raster/raster_datasource.hpp b/plugins/input/raster/raster_datasource.hpp index 6e35e1456..e07e6b39e 100644 --- a/plugins/input/raster/raster_datasource.hpp +++ b/plugins/input/raster/raster_datasource.hpp @@ -24,10 +24,9 @@ #ifndef RASTER_DATASOURCE_HH #define RASTER_DATASOURCE_HH -#include "datasource.hpp" -#include "envelope.hpp" -#include "feature.hpp" -#include "image_reader.hpp" +#include +#include +#include using namespace mapnik; diff --git a/plugins/input/raster/raster_featureset.cpp b/plugins/input/raster/raster_featureset.cpp index 479f9d141..622a8e362 100644 --- a/plugins/input/raster/raster_featureset.cpp +++ b/plugins/input/raster/raster_featureset.cpp @@ -19,9 +19,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ +// mapnik +#include +#include + #include "raster_featureset.hpp" -#include "image_reader.hpp" -#include "image_util.hpp" template raster_featureset::raster_featureset(LookupPolicy const& policy, diff --git a/plugins/input/raster/raster_featureset.hpp b/plugins/input/raster/raster_featureset.hpp index fe3b6cea1..f917ddee3 100644 --- a/plugins/input/raster/raster_featureset.hpp +++ b/plugins/input/raster/raster_featureset.hpp @@ -22,9 +22,10 @@ #ifndef RASTER_FEATURESET_HH #define RASTER_FEATURESET_HH +#include + #include "raster_datasource.hpp" #include "raster_info.hpp" -#include using std::vector; diff --git a/plugins/input/shape/SConscript b/plugins/input/shape/SConscript index 85999be02..f374f3a7b 100644 --- a/plugins/input/shape/SConscript +++ b/plugins/input/shape/SConscript @@ -38,5 +38,5 @@ shape_src = Split( shape_inputdriver = env.SharedLibrary('shape', source=shape_src, SHLIBPREFIX='', LIBS=[]) -env.Install(prefix + '/' + env['LIB_PLATFORM'] + '/mapnik/input', shape_inputdriver) -env.Alias('install', prefix + '/' + env['LIB_PLATFORM'] + '/mapnik/input') +env.Install(prefix + '/' + env['LIBDIR_SCHEMA'] + '/mapnik/input', shape_inputdriver) +env.Alias('install', prefix + '/' + env['LIBDIR_SCHEMA'] + '/mapnik/input') diff --git a/plugins/input/shape/dbffile.cpp b/plugins/input/shape/dbffile.cpp index a87be3bb6..1f73cc252 100644 --- a/plugins/input/shape/dbffile.cpp +++ b/plugins/input/shape/dbffile.cpp @@ -19,12 +19,15 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ - -#include "dbffile.hpp" -#include "utils.hpp" +// stl +#include +// boost #include #include -#include +// mapnik +#include + +#include "dbffile.hpp" dbf_file::dbf_file() : num_records_(0), diff --git a/plugins/input/shape/dbffile.hpp b/plugins/input/shape/dbffile.hpp index 336ce4cb8..6dd4a3080 100644 --- a/plugins/input/shape/dbffile.hpp +++ b/plugins/input/shape/dbffile.hpp @@ -20,15 +20,15 @@ * *****************************************************************************/ -#ifndef DBFFILE_HH -#define DBFFILE_HH +#ifndef DBFFILE_HPP +#define DBFFILE_HPP #include #include #include #include -#include "feature.hpp" +#include using namespace mapnik; @@ -44,34 +44,35 @@ struct field_descriptor class dbf_file { - private: +private: - int num_records_; - int num_fields_; - int record_length_; - std::vector fields_; - std::ifstream file_; - char* record_; - public: - dbf_file(); - dbf_file(const char* file_name); - dbf_file(const std::string& file_name); - ~dbf_file(); - bool open(const std::string& file_name); - bool is_open(); - void close(); - int num_records() const; - int num_fields() const; - field_descriptor const& descriptor(int col) const; - void move_to(int index); - std::string string_value(int col) const; - void add_attribute(int col,Feature const& f) const throw(); - private: - dbf_file(const dbf_file&); - dbf_file& operator=(const dbf_file&); - void read_header(); - int read_short(); - int read_int(); - void skip(int bytes); + int num_records_; + int num_fields_; + int record_length_; + std::vector fields_; + std::ifstream file_; + char* record_; +public: + dbf_file(); + dbf_file(const char* file_name); + dbf_file(const std::string& file_name); + ~dbf_file(); + bool open(const std::string& file_name); + bool is_open(); + void close(); + int num_records() const; + int num_fields() const; + field_descriptor const& descriptor(int col) const; + void move_to(int index); + std::string string_value(int col) const; + void add_attribute(int col,Feature const& f) const throw(); +private: + dbf_file(const dbf_file&); + dbf_file& operator=(const dbf_file&); + void read_header(); + int read_short(); + int read_int(); + void skip(int bytes); }; -#endif //DBFFILE_HH + +#endif //DBFFILE_HPP diff --git a/plugins/input/shape/shape.cpp b/plugins/input/shape/shape.cpp index f50748418..3295fa2bf 100644 --- a/plugins/input/shape/shape.cpp +++ b/plugins/input/shape/shape.cpp @@ -20,13 +20,17 @@ * *****************************************************************************/ -#include "shape.hpp" +#include +#include +#include + +#include + + #include "shape_featureset.hpp" #include "shape_index_featureset.hpp" -#include "geom_util.hpp" -#include -#include +#include "shape.hpp" DATASOURCE_PLUGIN(shape_datasource) diff --git a/plugins/input/shape/shape.hpp b/plugins/input/shape/shape.hpp index f0841b466..7621056c7 100644 --- a/plugins/input/shape/shape.hpp +++ b/plugins/input/shape/shape.hpp @@ -20,11 +20,14 @@ * *****************************************************************************/ -#ifndef SHAPE_HH -#define SHAPE_HH +// $Id$ + +#ifndef SHAPE_HPP +#define SHAPE_HPP + +#include +#include -#include "datasource.hpp" -#include "envelope.hpp" #include "shape_io.hpp" using namespace mapnik; @@ -54,4 +57,4 @@ private: static std::string name_; }; -#endif //SHAPE_HH +#endif //SHAPE_HPP diff --git a/plugins/input/shape/shape_featureset.cpp b/plugins/input/shape/shape_featureset.cpp index 8cde0c320..8aa177af2 100644 --- a/plugins/input/shape/shape_featureset.cpp +++ b/plugins/input/shape/shape_featureset.cpp @@ -20,8 +20,8 @@ * *****************************************************************************/ -#include "shape_featureset.hpp" #include +#include "shape_featureset.hpp" template shape_featureset::shape_featureset(const filterT& filter, diff --git a/plugins/input/shape/shape_featureset.hpp b/plugins/input/shape/shape_featureset.hpp index 798c2a276..10e875980 100644 --- a/plugins/input/shape/shape_featureset.hpp +++ b/plugins/input/shape/shape_featureset.hpp @@ -23,8 +23,8 @@ #ifndef SHAPE_FS_HH #define SHAPE_FS_HH +#include #include "shape.hpp" -#include "geom_util.hpp" using namespace mapnik; @@ -42,7 +42,7 @@ class MAPNIK_DECL shape_featureset : public Featureset mutable int count_; public: shape_featureset(const filterT& filter, const std::string& shape_file, - const std::set& attribute_names,long file_length); + const std::set& attribute_names,long file_length); virtual ~shape_featureset(); feature_ptr next(); private: diff --git a/plugins/input/shape/shape_index_featureset.cpp b/plugins/input/shape/shape_index_featureset.cpp index 9819014da..1134f997e 100644 --- a/plugins/input/shape/shape_index_featureset.cpp +++ b/plugins/input/shape/shape_index_featureset.cpp @@ -22,8 +22,8 @@ //$Id: shape_index_featureset.cc 36 2005-04-05 14:32:18Z pavlenko $ +#include #include "shape_index_featureset.hpp" -#include "feature_factory.hpp" template shape_index_featureset::shape_index_featureset(const filterT& filter, diff --git a/plugins/input/shape/shape_index_featureset.hpp b/plugins/input/shape/shape_index_featureset.hpp index 0c611d9c1..9cb13ee69 100644 --- a/plugins/input/shape/shape_index_featureset.hpp +++ b/plugins/input/shape/shape_index_featureset.hpp @@ -20,13 +20,14 @@ * *****************************************************************************/ -#ifndef SHAPE_SQT_FS_HH -#define SHAPE_SQT_FS_HH +#ifndef SHAPE_INDEX_FEATURESET_HPP +#define SHAPE_INDEX_FEATURESET_HPP -#include "shape_featureset.hpp" #include #include +#include "shape_featureset.hpp" + template class MAPNIK_DECL shape_index_featureset : public Featureset { @@ -42,7 +43,7 @@ class MAPNIK_DECL shape_index_featureset : public Featureset public: shape_index_featureset(const filterT& filter,const std::string& shape_file, - const std::set& attribute_names); + const std::set& attribute_names); virtual ~shape_index_featureset(); feature_ptr next(); private: @@ -50,4 +51,5 @@ private: shape_index_featureset(const shape_index_featureset&); shape_index_featureset& operator=(const shape_index_featureset&); }; -#endif //SHAPE_SQT_FS_HH + +#endif //SHAPE_INDEX_FEATURESET_HPP diff --git a/plugins/input/shape/shapefile.cpp b/plugins/input/shape/shapefile.cpp index 6e78239bc..e1e3ecfa6 100644 --- a/plugins/input/shape/shapefile.cpp +++ b/plugins/input/shape/shapefile.cpp @@ -24,7 +24,6 @@ shape_file::shape_file() {} - shape_file::shape_file(const std::string& file_name) { //file_.rdbuf()->pubsetbuf(buff_,buffer_size); diff --git a/plugins/input/shape/shapefile.hpp b/plugins/input/shape/shapefile.hpp index 1ad89bee7..61148f34f 100644 --- a/plugins/input/shape/shapefile.hpp +++ b/plugins/input/shape/shapefile.hpp @@ -22,12 +22,12 @@ //$Id: shapefile.hh 33 2005-04-04 13:01:03Z pavlenko $ -#ifndef SHAPEFILE_HH -#define SHAPEFILE_HH +#ifndef SHAPEFILE_HPP +#define SHAPEFILE_HPP #include -#include "envelope.hpp" +#include using namespace mapnik; @@ -37,64 +37,66 @@ struct shape_record size_t size; size_t pos; explicit shape_record(size_t size) - : data(static_cast(::operator new(sizeof(char)*size))), - size(size), - pos(0) {} + : data(static_cast(::operator new(sizeof(char)*size))), + size(size), + pos(0) {} char* rawdata() { - return &data[0]; + return &data[0]; } + void skip(unsigned n) { - pos+=n; + pos+=n; } + int read_ndr_integer() { - int val=(data[pos] & 0xff) | - (data[pos+1] & 0xff) << 8 | - (data[pos+2] & 0xff) << 16 | - (data[pos+3] & 0xff) << 24; - pos+=4; - return val; + int val=(data[pos] & 0xff) | + (data[pos+1] & 0xff) << 8 | + (data[pos+2] & 0xff) << 16 | + (data[pos+3] & 0xff) << 24; + pos+=4; + return val; } int read_xdr_integer() { - int val=(data[pos] & 0xff) << 24 | - (data[pos+1] & 0xff) << 16 | - (data[pos+2] & 0xff) << 8 | - (data[pos+3] & 0xff); - pos+=4; - return val; + int val=(data[pos] & 0xff) << 24 | + (data[pos+1] & 0xff) << 16 | + (data[pos+2] & 0xff) << 8 | + (data[pos+3] & 0xff); + pos+=4; + return val; } double read_double() { - double val; + double val; #ifndef WORDS_BIGENDIAN - std::memcpy(&val,&data[pos],8); + std::memcpy(&val,&data[pos],8); #else long long bits = ((long long)data[pos] & 0xff) | - ((long long)data[pos+1] & 0xff) << 8 | - ((long long)data[pos+2] & 0xff) << 16 | - ((long long)data[pos+3] & 0xff) << 24 | - ((long long)data[pos+4] & 0xff) << 32 | - ((long long)data[pos+5] & 0xff) << 40 | - ((long long)data[pos+6] & 0xff) << 48 | - ((long long)data[pos+7] & 0xff) << 56 ; - std::memcpy(&val,&bits,8); + ((long long)data[pos+1] & 0xff) << 8 | + ((long long)data[pos+2] & 0xff) << 16 | + ((long long)data[pos+3] & 0xff) << 24 | + ((long long)data[pos+4] & 0xff) << 32 | + ((long long)data[pos+5] & 0xff) << 40 | + ((long long)data[pos+6] & 0xff) << 48 | + ((long long)data[pos+7] & 0xff) << 56 ; + std::memcpy(&val,&bits,8); #endif - pos+=8; - return val; + pos+=8; + return val; } long remains() { - return (size-pos); + return (size-pos); } ~shape_record() { - ::operator delete(data); + ::operator delete(data); } }; @@ -113,88 +115,87 @@ public: inline void read_record(shape_record& rec) { - file_.read(rec.rawdata(),rec.size); + file_.read(rec.rawdata(),rec.size); } inline int read_xdr_integer() { - char b[4]; - file_.read(b, 4); - return b[3] & 0xffu | (b[2] & 0xffu) << 8 | - (b[1] & 0xffu) << 16 | (b[0] & 0xffu) << 24; + char b[4]; + file_.read(b, 4); + return b[3] & 0xffu | (b[2] & 0xffu) << 8 | + (b[1] & 0xffu) << 16 | (b[0] & 0xffu) << 24; } inline int read_ndr_integer() { - char b[4]; - file_.read(b,4); - return b[0]&0xffu | (b[1]&0xffu) << 8 | - (b[2]&0xffu) << 16 | (b[3]&0xffu) << 24; + char b[4]; + file_.read(b,4); + return b[0]&0xffu | (b[1]&0xffu) << 8 | + (b[2]&0xffu) << 16 | (b[3]&0xffu) << 24; } inline double read_double() { - double val; + double val; #ifndef WORDS_BIGENDIAN - file_.read(reinterpret_cast(&val),8); + file_.read(reinterpret_cast(&val),8); #else - char b[8]; - file_.read(b,8); - long long bits = ((long long)b[0] & 0xff) | - ((long long)b[1] & 0xff) << 8 | - ((long long)b[2] & 0xff) << 16 | - ((long long)b[3] & 0xff) << 24 | - ((long long)b[4] & 0xff) << 32 | - ((long long)b[5] & 0xff) << 40 | - ((long long)b[6] & 0xff) << 48 | - ((long long)b[7] & 0xff) << 56 ; - memcpy(&val,&bits,8); + char b[8]; + file_.read(b,8); + long long bits = ((long long)b[0] & 0xff) | + ((long long)b[1] & 0xff) << 8 | + ((long long)b[2] & 0xff) << 16 | + ((long long)b[3] & 0xff) << 24 | + ((long long)b[4] & 0xff) << 32 | + ((long long)b[5] & 0xff) << 40 | + ((long long)b[6] & 0xff) << 48 | + ((long long)b[7] & 0xff) << 56 ; + memcpy(&val,&bits,8); #endif - return val; + return val; } inline void read_envelope(Envelope& envelope) { #ifndef WORDS_BIGENDIAN - file_.read(reinterpret_cast(&envelope),sizeof(envelope)); + file_.read(reinterpret_cast(&envelope),sizeof(envelope)); #else - double minx=read_double(); - double miny=read_double(); - double maxx=read_double(); - double maxy=read_double(); - envelope.init(minx,miny,maxx,maxy); + double minx=read_double(); + double miny=read_double(); + double maxx=read_double(); + double maxy=read_double(); + envelope.init(minx,miny,maxx,maxy); #endif } inline void skip(std::streampos bytes) { - file_.seekg(bytes,std::ios::cur); + file_.seekg(bytes,std::ios::cur); } inline void rewind() { - seek(100); + seek(100); } inline void seek(std::streampos pos) { - file_.seekg(pos,std::ios::beg); + file_.seekg(pos,std::ios::beg); } - inline std::streampos pos() { - return file_.tellg(); + return file_.tellg(); } - inline bool is_eof() { - return file_.eof(); + return file_.eof(); } private: shape_file(const shape_file&); shape_file& operator=(const shape_file&); }; -#endif //SHAPEFILE_HH + +#endif //SHAPEFILE_HPP diff --git a/plugins/input/shape/shp_index.cpp b/plugins/input/shape/shp_index.cpp index 3994616ae..b6d6b55ff 100644 --- a/plugins/input/shape/shp_index.cpp +++ b/plugins/input/shape/shp_index.cpp @@ -19,9 +19,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ - +#include #include "shp_index.hpp" -#include "geom_util.hpp" template void shp_index::query(const filterT& filter,std::ifstream& file,std::set& pos) diff --git a/plugins/input/shape/shp_index.hpp b/plugins/input/shape/shp_index.hpp index 5823d549c..1b5328016 100644 --- a/plugins/input/shape/shp_index.hpp +++ b/plugins/input/shape/shp_index.hpp @@ -23,10 +23,12 @@ #ifndef SHP_INDEX_HH #define SHP_INDEX_HH -#include "envelope.hpp" -#include "query.hpp" +// st #include #include +// mapnik +#include +#include using namespace mapnik; diff --git a/src/SConscript b/src/SConscript index 12e42d661..983159f79 100644 --- a/src/SConscript +++ b/src/SConscript @@ -32,32 +32,33 @@ linkflags = '-Wl,-rpath-link,. -Wl,-soname,libmapnik.so' source = Split( """ + agg_renderer.cpp datasource_cache.cpp envelope.cpp + filter_factory.cpp + font_engine_freetype.cpp graphics.cpp image_reader.cpp image_util.cpp layer.cpp + line_pattern_symbolizer.cpp + load_map.cpp map.cpp memory.cpp params.cpp plugin.cpp png_reader.cpp - tiff_reader.cpp - wkb.cpp - agg_renderer.cpp point_symbolizer.cpp polygon_pattern_symbolizer.cpp - line_pattern_symbolizer.cpp - text_symbolizer.cpp - font_engine_freetype.cpp - load_map.cpp save_map.cpp + text_symbolizer.cpp + tiff_reader.cpp + wkb.cpp """ ) mapnik = env.SharedLibrary('mapnik', source, LIBS=libraries, LINKFLAGS=linkflags) -env.Alias(target='install', source=env.Install(prefix + '/' + env['LIB_PLATFORM'], mapnik)) -includes = glob.glob('../include' + '/*.hpp') +env.Alias(target='install', source=env.Install(prefix + '/' + env['LIBDIR_SCHEMA'], mapnik)) +includes = glob.glob('../include/mapnik' + '/*.hpp') env.Alias(target='install', source=env.Install(prefix+'/include/mapnik', includes)) diff --git a/src/agg_renderer.cpp b/src/agg_renderer.cpp index f2c94bc28..559034bae 100644 --- a/src/agg_renderer.cpp +++ b/src/agg_renderer.cpp @@ -21,8 +21,11 @@ *****************************************************************************/ //$Id$ -#include "agg_renderer.hpp" - +// stl +#include +// boost +#include +// agg #include "agg_basics.h" #include "agg_rendering_buffer.h" #include "agg_rasterizer_scanline_aa.h" @@ -52,12 +55,11 @@ #include "agg_renderer_scanline.h" #include "agg_pattern_filters_rgba.h" #include "agg_renderer_outline_image.h" +// mapnik +#include +#include -#include -#include -#include "image_util.hpp" - -namespace mapnik +namespace mapnik { class pattern_source : private boost::noncopyable { @@ -76,7 +78,10 @@ namespace mapnik agg::rgba8 pixel(int x, int y) const { unsigned c = pattern_(x,y); - return agg::rgba8(c & 0xff, (c >> 8) & 0xff, (c >> 16) & 0xff,(c >> 24) & 0xff); + return agg::rgba8(c & 0xff, + (c >> 8) & 0xff, + (c >> 16) & 0xff, + (c >> 24) & 0xff); } private: ImageData32 const& pattern_; @@ -97,7 +102,8 @@ namespace mapnik template void agg_renderer::start_map_processing(Map const& map) { - std::clog << "start map processing bbox=" << map.getCurrentExtent() << std::endl; + std::clog << "start map processing bbox=" + << map.getCurrentExtent() << "\n"; } template @@ -460,7 +466,6 @@ namespace mapnik } } } - } - + } template class agg_renderer; } diff --git a/src/datasource_cache.cpp b/src/datasource_cache.cpp index 62c8cb60e..41ae5e7bd 100644 --- a/src/datasource_cache.cpp +++ b/src/datasource_cache.cpp @@ -21,13 +21,14 @@ *****************************************************************************/ //$Id: datasource_cache.cpp 23 2005-03-22 22:16:34Z pavlenko $ -#include "datasource_cache.hpp" - +// stl #include #include - +// boost #include #include +// mapnik +#include namespace mapnik { @@ -58,7 +59,8 @@ namespace mapnik { if (itr->second->handle()) { - create_ds* create_datasource = (create_ds*) lt_dlsym(itr->second->handle(), "create"); + create_ds* create_datasource = + (create_ds*) lt_dlsym(itr->second->handle(), "create"); if (!create_datasource) { std::clog << "Cannot load symbols: " << lt_dlerror() << std::endl; @@ -88,7 +90,8 @@ namespace mapnik bool datasource_cache::insert(const std::string& type,const lt_dlhandle module) { - return plugins_.insert(make_pair(type,boost::shared_ptr(new PluginInfo(type,module)))).second; + return plugins_.insert(make_pair(type,boost::shared_ptr + (new PluginInfo(type,module)))).second; } void datasource_cache::register_datasources(const std::string& str) @@ -106,7 +109,8 @@ namespace mapnik lt_dlhandle module=lt_dlopenext(itr->string().c_str()); if (module) { - datasource_name* ds_name = (datasource_name*) lt_dlsym(module, "datasource_name"); + datasource_name* ds_name = + (datasource_name*) lt_dlsym(module, "datasource_name"); if (ds_name && insert(ds_name(),module)) { std::clog<<"registered datasource : "< namespace mapnik { template - Envelope::Envelope() + Envelope::Envelope() :minx_(0),miny_(0),maxx_(-1),maxy_(-1) {} template - Envelope::Envelope(T minx_,T miny_,T maxx_,T maxy_) + Envelope::Envelope(T minx_,T miny_,T maxx_,T maxy_) { init(minx_,miny_,maxx_,maxy_); } template - Envelope::Envelope(const coord &c0,const coord &c1) + Envelope::Envelope(const coord &c0,const coord &c1) { init(c0.x,c0.y,c1.x,c1.y); } template - Envelope::Envelope(const Envelope &rhs) + Envelope::Envelope(const Envelope &rhs) { init(rhs.minx_,rhs.miny_,rhs.maxx_,rhs.maxy_); } template - inline bool Envelope::operator==(const Envelope& other) const + inline bool Envelope::operator==(const Envelope& other) const { return minx_==other.minx_ && miny_==other.miny_ && @@ -57,43 +57,43 @@ namespace mapnik } template - inline T Envelope::minx() const + inline T Envelope::minx() const { return minx_; } template - inline T Envelope::maxx() const + inline T Envelope::maxx() const { return maxx_; } template - inline T Envelope::miny() const + inline T Envelope::miny() const { return miny_; } template - inline T Envelope::maxy() const + inline T Envelope::maxy() const { return maxy_; } template - inline T Envelope::width() const + inline T Envelope::width() const { return maxx_-minx_; } template - inline T Envelope::height() const + inline T Envelope::height() const { return maxy_-miny_; } template - inline void Envelope::width(T w) + inline void Envelope::width(T w) { T cx=center().x; minx_=static_cast(cx-w*0.5); @@ -101,7 +101,7 @@ namespace mapnik } template - inline void Envelope::height(T h) + inline void Envelope::height(T h) { T cy=center().y; miny_=static_cast(cy-h*0.5); @@ -109,20 +109,20 @@ namespace mapnik } template - inline coord Envelope::center() const + inline coord Envelope::center() const { return coord(static_cast(0.5*(minx_+maxx_)), - static_cast(0.5*(miny_+maxy_))); + static_cast(0.5*(miny_+maxy_))); } template - inline void Envelope::expand_to_include(const coord& c) + inline void Envelope::expand_to_include(const coord& c) { expand_to_include(c.x,c.y); } template - inline void Envelope::expand_to_include(T x,T y) + inline void Envelope::expand_to_include(T x,T y) { if (xmaxx_) maxx_=x; @@ -131,7 +131,7 @@ namespace mapnik } template - void Envelope::expand_to_include(const Envelope &other) + void Envelope::expand_to_include(const Envelope &other) { if (other.minx_maxx_) maxx_=other.maxx_; @@ -140,19 +140,19 @@ namespace mapnik } template - inline bool Envelope::contains(const coord &c) const + inline bool Envelope::contains(const coord &c) const { return contains(c.x,c.y); } template - inline bool Envelope::contains(T x,T y) const + inline bool Envelope::contains(T x,T y) const { return x>=minx_ && x<=maxx_ && y>=miny_ && y<=maxy_; } template - inline bool Envelope::contains(const Envelope &other) const + inline bool Envelope::contains(const Envelope &other) const { return other.minx_>=minx_ && other.maxx_<=maxx_ && @@ -161,26 +161,26 @@ namespace mapnik } template - inline bool Envelope::intersects(const coord &c) const + inline bool Envelope::intersects(const coord &c) const { return intersects(c.x,c.y); } template - bool Envelope::intersects(T x,T y) const + bool Envelope::intersects(T x,T y) const { return !(x>maxx_ || xmaxy_ || y - inline bool Envelope::intersects(const Envelope &other) const + inline bool Envelope::intersects(const Envelope &other) const { return !(other.minx_>maxx_ || other.maxx_maxy_ || other.maxy_maxy_ || other.maxy_ - inline Envelope Envelope::intersect(const EnvelopeType& other) const + inline Envelope Envelope::intersect(const EnvelopeType& other) const { T x0=std::max(minx_,other.minx_); @@ -193,7 +193,7 @@ namespace mapnik } template - inline void Envelope::re_center(T cx,T cy) + inline void Envelope::re_center(T cx,T cy) { T dx=cx-center().x; T dy=cy-center().y; @@ -204,7 +204,7 @@ namespace mapnik } template - inline void Envelope::init(T x0,T y0,T x1,T y1) + inline void Envelope::init(T x0,T y0,T x1,T y1) { if (x0 namespace mapnik { diff --git a/src/font_engine_freetype.cpp b/src/font_engine_freetype.cpp index 641112a0e..435935ece 100644 --- a/src/font_engine_freetype.cpp +++ b/src/font_engine_freetype.cpp @@ -21,7 +21,7 @@ *****************************************************************************/ //$Id$ -#include "font_engine_freetype.hpp" +#include namespace mapnik { diff --git a/src/graphics.cpp b/src/graphics.cpp index 8fa253bdc..0897fd314 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -21,24 +21,26 @@ *****************************************************************************/ //$Id: graphics.cpp 17 2005-03-08 23:58:43Z pavlenko $ +// stl #include #include #include #include -#include "graphics.hpp" -#include "image_util.hpp" +// mapnik +#include +#include namespace mapnik { Image32::Image32(int width,int height) :width_(width), - height_(height), - data_(width,height) {} + height_(height), + data_(width,height) {} Image32::Image32(const Image32& rhs) :width_(rhs.width_), - height_(rhs.height_), - data_(rhs.data_) {} + height_(rhs.height_), + data_(rhs.data_) {} Image32::~Image32() {} diff --git a/src/image_reader.cpp b/src/image_reader.cpp index e25a05ae1..baf42992f 100644 --- a/src/image_reader.cpp +++ b/src/image_reader.cpp @@ -21,9 +21,8 @@ *****************************************************************************/ //$Id: image_reader.cpp 17 2005-03-08 23:58:43Z pavlenko $ - -#include "image_reader.hpp" -#include "factory.hpp" +#include +#include namespace mapnik { diff --git a/src/image_util.cpp b/src/image_util.cpp index bc178e38c..f7997ed2b 100644 --- a/src/image_util.cpp +++ b/src/image_util.cpp @@ -22,15 +22,17 @@ //$Id: image_util.cpp 36 2005-04-05 14:32:18Z pavlenko $ +// stl #include -#include "graphics.hpp" -#include "memory.hpp" -#include "image_util.hpp" - +// mapnik +#include +#include +#include +// jpeg png extern "C" { - #include - #include +#include +#include } namespace mapnik @@ -47,7 +49,9 @@ namespace mapnik Object::operator delete(ptr); } // - void ImageUtils::save_to_file(const std::string& filename,const std::string& type,const Image32& image) + void ImageUtils::save_to_file(const std::string& filename, + const std::string& type, + const Image32& image) { //all that should go into image_writer factory if (type=="png") @@ -66,20 +70,20 @@ namespace mapnik if (!fp) return; png_voidp mem_ptr=0; png_structp png_ptr=png_create_write_struct(PNG_LIBPNG_VER_STRING, - (png_voidp)mem_ptr,0, 0); + (png_voidp)mem_ptr,0, 0); if (!png_ptr) return; png_set_mem_fn(png_ptr,mem_ptr,malloc_fn,free_fn); // switch on optimization - #if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) +#if defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) png_uint_32 mask, flags; flags = png_get_asm_flags(png_ptr); mask = png_get_asm_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE); png_set_asm_flags(png_ptr, flags | mask); - #endif - png_set_filter (png_ptr, 0, PNG_FILTER_NONE); +#endif + png_set_filter (png_ptr, 0, PNG_FILTER_NONE); png_infop info_ptr = png_create_info_struct(png_ptr); if (!info_ptr) { @@ -95,11 +99,11 @@ namespace mapnik } png_init_io(png_ptr, fp); - //png_set_compression_level(png_ptr, Z_BEST_COMPRESSION); - //png_set_compression_strategy(png_ptr, Z_FILTERED); + //png_set_compression_level(png_ptr, Z_BEST_COMPRESSION); + //png_set_compression_strategy(png_ptr, Z_FILTERED); png_set_IHDR(png_ptr, info_ptr,image.width(),image.height(),8, - PNG_COLOR_TYPE_RGB_ALPHA,PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_DEFAULT,PNG_FILTER_TYPE_DEFAULT); + PNG_COLOR_TYPE_RGB_ALPHA,PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_DEFAULT,PNG_FILTER_TYPE_DEFAULT); png_write_info(png_ptr, info_ptr); const ImageData32& imageData=image.data(); @@ -116,43 +120,43 @@ namespace mapnik void ImageUtils::save_as_jpeg(const std::string& filename,int quality, const Image32& image) { - FILE *fp=fopen(filename.c_str(), "wb"); + FILE *fp=fopen(filename.c_str(), "wb"); if (!fp) return; - struct jpeg_compress_struct cinfo; - struct jpeg_error_mgr jerr; + struct jpeg_compress_struct cinfo; + struct jpeg_error_mgr jerr; - int width=image.width(); - int height=image.height(); + int width=image.width(); + int height=image.height(); - cinfo.err = jpeg_std_error(&jerr); - jpeg_create_compress(&cinfo); - jpeg_stdio_dest(&cinfo, fp); - cinfo.image_width = width; - cinfo.image_height = height; - cinfo.input_components = 3; - cinfo.in_color_space = JCS_RGB; - jpeg_set_defaults(&cinfo); - jpeg_set_quality(&cinfo, quality,1); - jpeg_start_compress(&cinfo, 1); - JSAMPROW row_pointer[1]; - JSAMPLE* row=new JSAMPLE[width*3]; - const ImageData32& imageData=image.data(); - while (cinfo.next_scanline < cinfo.image_height) - { - const unsigned* imageRow=imageData.getRow(cinfo.next_scanline); - int index=0; - for (int i=0;i>8)&0xff; - row[index++]=(imageRow[i]>>16)&0xff; - } - row_pointer[0] = &row[0]; - (void) jpeg_write_scanlines(&cinfo, row_pointer, 1); - } - delete [] row; - jpeg_finish_compress(&cinfo); - fclose(fp); - jpeg_destroy_compress(&cinfo); + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_compress(&cinfo); + jpeg_stdio_dest(&cinfo, fp); + cinfo.image_width = width; + cinfo.image_height = height; + cinfo.input_components = 3; + cinfo.in_color_space = JCS_RGB; + jpeg_set_defaults(&cinfo); + jpeg_set_quality(&cinfo, quality,1); + jpeg_start_compress(&cinfo, 1); + JSAMPROW row_pointer[1]; + JSAMPLE* row=new JSAMPLE[width*3]; + const ImageData32& imageData=image.data(); + while (cinfo.next_scanline < cinfo.image_height) + { + const unsigned* imageRow=imageData.getRow(cinfo.next_scanline); + int index=0; + for (int i=0;i>8)&0xff; + row[index++]=(imageRow[i]>>16)&0xff; + } + row_pointer[0] = &row[0]; + (void) jpeg_write_scanlines(&cinfo, row_pointer, 1); + } + delete [] row; + jpeg_finish_compress(&cinfo); + fclose(fp); + jpeg_destroy_compress(&cinfo); } } diff --git a/src/layer.cpp b/src/layer.cpp index 0952a737e..62dc4eca6 100644 --- a/src/layer.cpp +++ b/src/layer.cpp @@ -22,18 +22,22 @@ //$Id: layer.cpp 17 2005-03-08 23:58:43Z pavlenko $ - -#include "style.hpp" -#include "datasource.hpp" -#include "datasource_cache.hpp" -#include "layer.hpp" - +// stl #include #include +// boost +#include +// mapnik +#include +#include +#include +#include + +using namespace std; +using boost::shared_ptr; namespace mapnik -{ - using namespace std; +{ Layer::Layer(std::string const& name) : name_(name), title_(""), @@ -42,8 +46,8 @@ namespace mapnik maxZoom_(std::numeric_limits::max()), active_(true), selectable_(false), - selection_style_("default_selection") - {} + selection_style_("default_selection"), + ds_() {} Layer::Layer(const Layer& rhs) : name_(rhs.name_), @@ -54,8 +58,8 @@ namespace mapnik active_(rhs.active_), selectable_(rhs.selectable_), styles_(rhs.styles_), - ds_(rhs.ds_), - selection_style_(rhs.selection_style_) {} + selection_style_(rhs.selection_style_), + ds_(rhs.ds_) {} Layer& Layer::operator=(const Layer& rhs) { @@ -79,8 +83,8 @@ namespace mapnik active_=rhs.active_; selectable_=rhs.selectable_; styles_=rhs.styles_; - ds_=rhs.ds_; selection_style_=rhs.selection_style_; + ds_=rhs.ds_; } Layer::~Layer() {} diff --git a/src/line_pattern_symbolizer.cpp b/src/line_pattern_symbolizer.cpp index 6df471180..3dd216705 100644 --- a/src/line_pattern_symbolizer.cpp +++ b/src/line_pattern_symbolizer.cpp @@ -21,36 +21,37 @@ *****************************************************************************/ //$Id$ - -#include "line_pattern_symbolizer.hpp" -#include "image_reader.hpp" - +// stl +#include +// mapnik +#include +#include namespace mapnik { line_pattern_symbolizer::line_pattern_symbolizer(std::string const& file, - std::string const& type, - unsigned width,unsigned height) - : pattern_(new ImageData32(width,height)) + std::string const& type, + unsigned width,unsigned height) + : pattern_(new ImageData32(width,height)) { - try - { - std::auto_ptr reader(get_image_reader(type,file)); - if (reader.get()) - reader->read(0,0,*pattern_); - } - catch (...) - { - std::clog << "exception caught..." << std::endl; - } + try + { + std::auto_ptr reader(get_image_reader(type,file)); + if (reader.get()) + reader->read(0,0,*pattern_); + } + catch (...) + { + std::clog << "exception caught..." << std::endl; + } } line_pattern_symbolizer::line_pattern_symbolizer(line_pattern_symbolizer const& rhs) - : pattern_(rhs.pattern_) {} + : pattern_(rhs.pattern_) {} ImageData32 const& line_pattern_symbolizer::get_pattern() const { - return *pattern_; + return *pattern_; } } diff --git a/src/load_map.cpp b/src/load_map.cpp index 7c47eefda..704bf5d30 100644 --- a/src/load_map.cpp +++ b/src/load_map.cpp @@ -19,9 +19,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ - +// stl #include - +// boost #include #include #include @@ -29,13 +29,18 @@ #include #include #include +// mapnik +#include +#include +#include +#include +#include -#include "color.hpp" -#include "color_factory.hpp" -#include "filter_factory.hpp" -#include "layer.hpp" -#include "datasource_cache.hpp" -#include "load_map.hpp" +#include + +using boost::lexical_cast; +using boost::bad_lexical_cast; +using boost::tokenizer; namespace mapnik { diff --git a/src/map.cpp b/src/map.cpp index 86144db81..f7b329710 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -20,12 +20,12 @@ * *****************************************************************************/ -//$Id: map.cpp 17 2005-03-08 23:58:43Z pavlenko $ +//$Id: map.cpp 17 2005-03-08 23:58:43Z pavlenko $, -#include "style.hpp" -#include "datasource.hpp" -#include "layer.hpp" -#include "map.hpp" +#include +#include +#include +#include namespace mapnik { diff --git a/src/memory.cpp b/src/memory.cpp index 5a700b5a4..ece788930 100644 --- a/src/memory.cpp +++ b/src/memory.cpp @@ -22,10 +22,7 @@ //$Id: memory.cpp 17 2005-03-08 23:58:43Z pavlenko $ -#include "memory.hpp" - -//#define GC_THREADS -//#include "gc.h" +#include namespace mapnik { diff --git a/src/params.cpp b/src/params.cpp index bb9b905fa..1e1e146cb 100644 --- a/src/params.cpp +++ b/src/params.cpp @@ -22,7 +22,7 @@ //$Id: params.cpp 17 2005-03-08 23:58:43Z pavlenko $ -#include "params.hpp" +#include namespace mapnik { diff --git a/src/plugin.cpp b/src/plugin.cpp index b99330b83..ab9cdcbd0 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -22,7 +22,7 @@ //$Id: plugin.cpp 17 2005-03-08 23:58:43Z pavlenko $ -#include "plugin.hpp" +#include namespace mapnik { diff --git a/src/png_reader.cpp b/src/png_reader.cpp index c30fe1f25..8455991e7 100644 --- a/src/png_reader.cpp +++ b/src/png_reader.cpp @@ -22,13 +22,12 @@ //$Id: png_reader.cpp 33 2005-04-04 13:01:03Z pavlenko $ - #include -#include "image_reader.hpp" +#include extern "C" { - #include +#include } namespace mapnik @@ -64,10 +63,10 @@ namespace mapnik PngReader::PngReader(const std::string& fileName) : fileName_(fileName), - width_(0), - height_(0), - bit_depth_(0), - color_type_(0) + width_(0), + height_(0), + bit_depth_(0), + color_type_(0) { try { @@ -87,7 +86,7 @@ namespace mapnik { png_size_t check; check = (png_size_t)fread(data, (png_size_t)1, length, - (FILE *)png_ptr->io_ptr); + (FILE *)png_ptr->io_ptr); if (check != length) { diff --git a/src/point_symbolizer.cpp b/src/point_symbolizer.cpp index 9f1d3556c..e27a45b0b 100644 --- a/src/point_symbolizer.cpp +++ b/src/point_symbolizer.cpp @@ -21,11 +21,14 @@ *****************************************************************************/ //$Id$ - +// stl +#include +// boost #include -#include "point_symbolizer.hpp" -#include "image_data.hpp" -#include "image_reader.hpp" +// mapnik +#include +#include +#include namespace mapnik { diff --git a/src/polygon_pattern_symbolizer.cpp b/src/polygon_pattern_symbolizer.cpp index 6d83c43d7..4a57d229e 100644 --- a/src/polygon_pattern_symbolizer.cpp +++ b/src/polygon_pattern_symbolizer.cpp @@ -19,36 +19,36 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ - //$Id$ - -#include "polygon_pattern_symbolizer.hpp" - -#include "image_reader.hpp" +// stl +#include +// mapnik +#include +#include namespace mapnik { polygon_pattern_symbolizer::polygon_pattern_symbolizer(std::string const& file, - std::string const& type, - unsigned width,unsigned height) - : pattern_(new ImageData32(width,height)) + std::string const& type, + unsigned width,unsigned height) + : pattern_(new ImageData32(width,height)) { - try - { - std::auto_ptr reader(get_image_reader(type,file)); - if (reader.get()) - reader->read(0,0,*pattern_); - } - catch (...) - { - std::clog<<"exception caught..."< reader(get_image_reader(type,file)); + if (reader.get()) + reader->read(0,0,*pattern_); + } + catch (...) + { + std::clog<<"exception caught..."< - +// boost #include -//#include #include #include #include #include #include - -//#include "color.hpp" -//#include "color_factory.hpp" -//#include "filter_factory.hpp" -//#include "layer.hpp" -//#include "datasource_cache.hpp" -#include "save_map.hpp" +// mapnik +#include namespace mapnik { diff --git a/src/text_symbolizer.cpp b/src/text_symbolizer.cpp index e1c5c9fd6..92ad600e6 100644 --- a/src/text_symbolizer.cpp +++ b/src/text_symbolizer.cpp @@ -22,7 +22,7 @@ //$Id$ -#include "text_symbolizer.hpp" +#include namespace mapnik { diff --git a/src/tiff_reader.cpp b/src/tiff_reader.cpp index d12aaeb76..f0ebe8a44 100644 --- a/src/tiff_reader.cpp +++ b/src/tiff_reader.cpp @@ -21,15 +21,16 @@ *****************************************************************************/ //$Id: tiff_reader.cpp 17 2005-03-08 23:58:43Z pavlenko $ - +// stl #include -#include "image_reader.hpp" +// mapnik +#include + extern "C" { #include } - namespace mapnik { diff --git a/src/wkb.cpp b/src/wkb.cpp index f1ea845a8..6d05dd799 100644 --- a/src/wkb.cpp +++ b/src/wkb.cpp @@ -22,62 +22,62 @@ //$Id: wkb.cpp 19 2005-03-22 13:53:27Z pavlenko $ -#include "wkb.hpp" -#include "geom_util.hpp" +#include +#include namespace mapnik { struct wkb_reader { private: - enum wkbByteOrder { - wkbXDR=0, - wkbNDR=1 - }; - const char* wkb_; - unsigned size_; - int srid_; - unsigned pos_; - wkbByteOrder byteOrder_; - bool needSwap_; + enum wkbByteOrder { + wkbXDR=0, + wkbNDR=1 + }; + const char* wkb_; + unsigned size_; + int srid_; + unsigned pos_; + wkbByteOrder byteOrder_; + bool needSwap_; public: - enum wkbGeometryType { - wkbPoint=1, - wkbLineString=2, - wkbPolygon=3, - wkbMultiPoint=4, - wkbMultiLineString=5, - wkbMultiPolygon=6, - wkbGeometryCollection=7 - }; + enum wkbGeometryType { + wkbPoint=1, + wkbLineString=2, + wkbPolygon=3, + wkbMultiPoint=4, + wkbMultiLineString=5, + wkbMultiPolygon=6, + wkbGeometryCollection=7 + }; - wkb_reader(const char* wkb,unsigned size,int srid) - : wkb_(wkb), - size_(size), - srid_(srid), - pos_(0), - byteOrder_((wkbByteOrder)wkb_[0]) - { - ++pos_; + wkb_reader(const char* wkb,unsigned size,int srid) + : wkb_(wkb), + size_(size), + srid_(srid), + pos_(0), + byteOrder_((wkbByteOrder)wkb_[0]) + { + ++pos_; #ifndef WORDS_BIGENDIAN - needSwap_=byteOrder_?wkbXDR:wkbNDR; + needSwap_=byteOrder_?wkbXDR:wkbNDR; #else - needSwap_=byteOrder_?wkbNDR:wkbXDR; + needSwap_=byteOrder_?wkbNDR:wkbXDR; #endif - } + } - ~wkb_reader() {} + ~wkb_reader() {} - geometry_ptr read() - { - geometry_ptr geom; - int type=read_integer(); - switch (type) - { + geometry_ptr read() + { + geometry_ptr geom; + int type=read_integer(); + switch (type) + { case wkbPoint: - geom = read_point(); + geom = read_point(); break; case wkbLineString: geom = read_linestring(); @@ -86,7 +86,7 @@ namespace mapnik geom = read_polygon(); break; case wkbMultiPoint: - geom = read_multipoint(); + geom = read_multipoint(); break; case wkbMultiLineString: geom = read_multilinestring(); @@ -98,193 +98,192 @@ namespace mapnik break; default: break; - } - return geom; - } + } + return geom; + } private: - wkb_reader(const wkb_reader&); - wkb_reader& operator=(const wkb_reader&); + wkb_reader(const wkb_reader&); + wkb_reader& operator=(const wkb_reader&); - int read_integer() - { - int n; + int read_integer() + { + int n; - if (!needSwap_) - { - memcpy(&n,wkb_+pos_,4); - } - else - { - const char* b=wkb_+pos_; - n = b[3]&0xff | (b[2]&0xff)<<8 | (b[1]&0xff)<<16 | (b[0]&0xff)<<24; - } - pos_+=4; + if (!needSwap_) + { + memcpy(&n,wkb_+pos_,4); + } + else + { + const char* b=wkb_+pos_; + n = b[3]&0xff | (b[2]&0xff)<<8 | (b[1]&0xff)<<16 | (b[0]&0xff)<<24; + } + pos_+=4; - return n; - } + return n; + } - double read_double() - { - double d; + double read_double() + { + double d; - if (!needSwap_) - { - memcpy(&d,wkb_+pos_,8); - } - else - { - // we rely on the fact that "long long" is in C standard, - // but not in C++ yet - // this is not quite portable - const char* b= wkb_+pos_; - long long n = (long long)b[7]&0xff | - ((long long)b[6]&0xff)<<8 | - ((long long)b[5]&0xff)<<16 | - ((long long)b[4]&0xff)<<24 | - ((long long)b[3]&0xff)<<32 | - ((long long)b[2]&0xff)<<40 | - ((long long)b[1]&0xff)<<48 | - ((long long)b[0]&0xff)<<56; - memcpy(&d,&n,8); - } - pos_+=8; + if (!needSwap_) + { + memcpy(&d,wkb_+pos_,8); + } + else + { + // we rely on the fact that "long long" is in C standard, + // but not in C++ yet + // this is not quite portable + const char* b= wkb_+pos_; + long long n = (long long)b[7]&0xff | + ((long long)b[6]&0xff)<<8 | + ((long long)b[5]&0xff)<<16 | + ((long long)b[4]&0xff)<<24 | + ((long long)b[3]&0xff)<<32 | + ((long long)b[2]&0xff)<<40 | + ((long long)b[1]&0xff)<<48 | + ((long long)b[0]&0xff)<<56; + memcpy(&d,&n,8); + } + pos_+=8; - return d; - } + return d; + } - void read_coords(CoordinateArray& ar) - { - int size=sizeof(coord)*ar.size(); - if (!needSwap_) - { - std::memcpy(&ar[0],wkb_+pos_,size); + void read_coords(CoordinateArray& ar) + { + int size=sizeof(coord)*ar.size(); + if (!needSwap_) + { + std::memcpy(&ar[0],wkb_+pos_,size); - } - else - { - for (unsigned i=0;i(srid_)); - double x = read_double(); - double y = read_double(); - pt->move_to(x,y); - return pt; - } + geometry_ptr read_point() + { + geometry_ptr pt(new point(srid_)); + double x = read_double(); + double y = read_double(); + pt->move_to(x,y); + return pt; + } - geometry_ptr read_multipoint() - { - geometry_ptr pt(new point(srid_)); - int num_points = read_integer(); - for (int i=0;imove_to(x,y); - } - return pt; - } + geometry_ptr read_multipoint() + { + geometry_ptr pt(new point(srid_)); + int num_points = read_integer(); + for (int i=0;imove_to(x,y); + } + return pt; + } - geometry_ptr read_linestring() - { - geometry_ptr line(new line_string(srid_)); - int num_points=read_integer(); - CoordinateArray ar(num_points); - read_coords(ar); - line->set_capacity(num_points); - line->move_to(ar[0].x,ar[0].y); - for (int i=1;iline_to(ar[i].x,ar[i].y); - } - return line; - } + geometry_ptr read_linestring() + { + geometry_ptr line(new line_string(srid_)); + int num_points=read_integer(); + CoordinateArray ar(num_points); + read_coords(ar); + line->set_capacity(num_points); + line->move_to(ar[0].x,ar[0].y); + for (int i=1;iline_to(ar[i].x,ar[i].y); + } + return line; + } - geometry_ptr read_multilinestring() - { - geometry_ptr line(new line_string(srid_)); - int num_lines=read_integer(); + geometry_ptr read_multilinestring() + { + geometry_ptr line(new line_string(srid_)); + int num_lines=read_integer(); - for (int i=0;imove_to(ar[0].x,ar[0].y); + int num_points=read_integer(); + CoordinateArray ar(num_points); + read_coords(ar); + line->move_to(ar[0].x,ar[0].y); - for (int i=1;iline_to(ar[i].x,ar[i].y); - } - } - return line; - } + for (int i=1;iline_to(ar[i].x,ar[i].y); + } + } + return line; + } - geometry_ptr read_polygon() - { - geometry_ptr poly(new polygon(srid_)); + geometry_ptr read_polygon() + { + geometry_ptr poly(new polygon(srid_)); - int num_rings=read_integer(); + int num_rings=read_integer(); - for (int i=0;imove_to(ar[0].x,ar[0].y); + for (int i=0;imove_to(ar[0].x,ar[0].y); - for (int j=1;jline_to(ar[j].x,ar[j].y); - } - poly->line_to(ar[0].x,ar[0].y); + for (int j=1;jline_to(ar[j].x,ar[j].y); + } + poly->line_to(ar[0].x,ar[0].y); - } - return poly; - } + } + return poly; + } - geometry_ptr read_multipolygon() - { - geometry_ptr poly(new polygon(srid_)); + geometry_ptr read_multipolygon() + { + geometry_ptr poly(new polygon(srid_)); - int num_polys=read_integer(); - for (int i=0;imove_to(ar[0].x,ar[0].y); - for (int j=1;jline_to(ar[j].x,ar[j].y); - } - poly->line_to(ar[0].x,ar[0].y); - } - } - return poly; + int num_polys=read_integer(); + for (int i=0;imove_to(ar[0].x,ar[0].y); + for (int j=1;jline_to(ar[j].x,ar[j].y); + } + poly->line_to(ar[0].x,ar[0].y); + } + } + return poly; } }; - - + geometry_ptr geometry_utils::from_wkb(const char* wkb, unsigned size,int srid) { - wkb_reader reader(wkb,size,srid); - return reader.read(); + wkb_reader reader(wkb,size,srid); + return reader.read(); } } diff --git a/utils/shapeindex/SConscript b/utils/shapeindex/SConscript index e5f8c4751..6feb80050 100644 --- a/utils/shapeindex/SConscript +++ b/utils/shapeindex/SConscript @@ -33,7 +33,7 @@ source = Split( """ ) -headers = ['#plugins/input/shape'] + env['CPPPATH'] +headers = ['#plugins/input/shape'] + env['CPPPATH'] shapeindex = env.Program('shapeindex', source, CPPPATH=headers, LIBS='boost_program_options%s' % env['BOOST_APPEND']) diff --git a/utils/shapeindex/quadtree.hpp b/utils/shapeindex/quadtree.hpp index 1524d9e25..b2fe52f5c 100644 --- a/utils/shapeindex/quadtree.hpp +++ b/utils/shapeindex/quadtree.hpp @@ -23,10 +23,11 @@ #ifndef QUADTREE_HH #define QUADTREE_HH - -#include "envelope.hpp" +// stl #include #include +// mapnik +#include using namespace mapnik; diff --git a/utils/shapeindex/shapeindex.cpp b/utils/shapeindex/shapeindex.cpp index 68109d1c1..8ecaee4a5 100644 --- a/utils/shapeindex/shapeindex.cpp +++ b/utils/shapeindex/shapeindex.cpp @@ -21,17 +21,18 @@ *****************************************************************************/ //$Id: shapeindex.cc 27 2005-03-30 21:45:40Z pavlenko $ -#include "shape.hpp" -#include "quadtree.hpp" - -#include -#include -#include #include #include #include + +#include +#include +#include +#include "quadtree.hpp" +#include "shape.hpp" + const int MAXDEPTH = 64; const int DEFAULT_DEPTH = 8; const double MINRATIO=0.5;