From 9453d93f1508fa0e9e7cc45ae7798a329f0d62af Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 14 Dec 2012 19:22:04 +0000 Subject: [PATCH 01/15] + update conversion tests to have 0.0 and negative numbers --- tests/cpp_tests/conversions_test.cpp | 39 ++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tests/cpp_tests/conversions_test.cpp b/tests/cpp_tests/conversions_test.cpp index b31dc1f55..b48dff321 100644 --- a/tests/cpp_tests/conversions_test.cpp +++ b/tests/cpp_tests/conversions_test.cpp @@ -10,39 +10,74 @@ int main( int, char*[] ) std::string out; // Test double + to_string(out, double(0)); + BOOST_TEST_EQ( out, "0" ); + out.clear(); to_string(out, double(1)); BOOST_TEST_EQ( out, "1" ); out.clear(); + to_string(out, double(-1)); + BOOST_TEST_EQ( out, "-1" ); + out.clear(); + to_string(out, double(0.1)); BOOST_TEST_EQ( out, "0.1" ); out.clear(); + to_string(out, double(-0.1)); + BOOST_TEST_EQ( out, "-0.1" ); + out.clear(); + to_string(out, double(0.123)); BOOST_TEST_EQ( out, "0.123" ); out.clear(); + to_string(out, double(-0.123)); + BOOST_TEST_EQ( out, "-0.123" ); + out.clear(); + to_string(out, double(1e-06)); BOOST_TEST_EQ( out, "1e-06" ); out.clear(); + to_string(out, double(-1e-06)); + BOOST_TEST_EQ( out, "-1e-06" ); + out.clear(); + to_string(out, double(1e-05)); BOOST_TEST_EQ( out, "0.00001" ); out.clear(); + to_string(out, double(-1e-05)); + BOOST_TEST_EQ( out, "-0.00001" ); + out.clear(); + to_string(out, double(0.0001)); BOOST_TEST_EQ( out, "0.0001" ); out.clear(); + to_string(out, double(-0.0001)); + BOOST_TEST_EQ( out, "-0.0001" ); + out.clear(); + to_string(out, double(0.0001234567890123456)); BOOST_TEST_EQ( out, "0.0001234567890123456" ); out.clear(); + to_string(out, double(-0.0001234567890123456)); + BOOST_TEST_EQ( out, "-0.0001234567890123456" ); + out.clear(); + to_string(out, double(1000000000000000)); BOOST_TEST_EQ( out, "1000000000000000" ); out.clear(); + to_string(out, double(-1000000000000000)); + BOOST_TEST_EQ( out, "-1000000000000000" ); + out.clear(); + to_string(out, double(100000000000000.1)); BOOST_TEST_EQ( out, "100000000000000.1" ); out.clear(); @@ -59,6 +94,10 @@ int main( int, char*[] ) BOOST_TEST_EQ( out, "1.234e+16" ); out.clear(); + to_string(out, double(-1.234e+16)); + BOOST_TEST_EQ( out, "-1.234e+16" ); + out.clear(); + // Test int to_string(out, int(2)); From 4040eebf109906fb943b2be0a5511c6fed33876d Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Fri, 14 Dec 2012 13:52:39 -0800 Subject: [PATCH 02/15] catch c++ abort --- tests/cpp_tests/conversions_test.cpp | 202 ++++++++++++++------------- 1 file changed, 105 insertions(+), 97 deletions(-) diff --git a/tests/cpp_tests/conversions_test.cpp b/tests/cpp_tests/conversions_test.cpp index b48dff321..a24c807b7 100644 --- a/tests/cpp_tests/conversions_test.cpp +++ b/tests/cpp_tests/conversions_test.cpp @@ -7,105 +7,113 @@ int main( int, char*[] ) { using mapnik::util::to_string; - std::string out; - - // Test double - to_string(out, double(0)); - BOOST_TEST_EQ( out, "0" ); - out.clear(); - - to_string(out, double(1)); - BOOST_TEST_EQ( out, "1" ); - out.clear(); - - to_string(out, double(-1)); - BOOST_TEST_EQ( out, "-1" ); - out.clear(); - - to_string(out, double(0.1)); - BOOST_TEST_EQ( out, "0.1" ); - out.clear(); - - to_string(out, double(-0.1)); - BOOST_TEST_EQ( out, "-0.1" ); - out.clear(); - - to_string(out, double(0.123)); - BOOST_TEST_EQ( out, "0.123" ); - out.clear(); - - to_string(out, double(-0.123)); - BOOST_TEST_EQ( out, "-0.123" ); - out.clear(); - - to_string(out, double(1e-06)); - BOOST_TEST_EQ( out, "1e-06" ); - out.clear(); - - to_string(out, double(-1e-06)); - BOOST_TEST_EQ( out, "-1e-06" ); - out.clear(); - - to_string(out, double(1e-05)); - BOOST_TEST_EQ( out, "0.00001" ); - out.clear(); - - to_string(out, double(-1e-05)); - BOOST_TEST_EQ( out, "-0.00001" ); - out.clear(); - - to_string(out, double(0.0001)); - BOOST_TEST_EQ( out, "0.0001" ); - out.clear(); - - to_string(out, double(-0.0001)); - BOOST_TEST_EQ( out, "-0.0001" ); - out.clear(); - - to_string(out, double(0.0001234567890123456)); - BOOST_TEST_EQ( out, "0.0001234567890123456" ); - out.clear(); - - to_string(out, double(-0.0001234567890123456)); - BOOST_TEST_EQ( out, "-0.0001234567890123456" ); - out.clear(); - - to_string(out, double(1000000000000000)); - BOOST_TEST_EQ( out, "1000000000000000" ); - out.clear(); - - to_string(out, double(-1000000000000000)); - BOOST_TEST_EQ( out, "-1000000000000000" ); - out.clear(); - - to_string(out, double(100000000000000.1)); - BOOST_TEST_EQ( out, "100000000000000.1" ); - out.clear(); - - to_string(out, double(1.00001)); - BOOST_TEST_EQ( out, "1.00001" ); - out.clear(); - - to_string(out, double(1234000000000000)); - BOOST_TEST_EQ( out, "1234000000000000" ); - out.clear(); - - to_string(out, double(1.234e+16)); - BOOST_TEST_EQ( out, "1.234e+16" ); - out.clear(); - - to_string(out, double(-1.234e+16)); - BOOST_TEST_EQ( out, "-1.234e+16" ); - out.clear(); - - // Test int - - to_string(out, int(2)); - BOOST_TEST_EQ( out, "2" ); - out.clear(); + try + { + std::string out; + + // Test double + to_string(out, double(0)); + BOOST_TEST_EQ( out, "0" ); + out.clear(); + + to_string(out, double(1)); + BOOST_TEST_EQ( out, "1" ); + out.clear(); + + to_string(out, double(-1)); + BOOST_TEST_EQ( out, "-1" ); + out.clear(); + + to_string(out, double(0.1)); + BOOST_TEST_EQ( out, "0.1" ); + out.clear(); + + to_string(out, double(-0.1)); + BOOST_TEST_EQ( out, "-0.1" ); + out.clear(); + + to_string(out, double(0.123)); + BOOST_TEST_EQ( out, "0.123" ); + out.clear(); + + to_string(out, double(-0.123)); + BOOST_TEST_EQ( out, "-0.123" ); + out.clear(); + + to_string(out, double(1e-06)); + BOOST_TEST_EQ( out, "1e-06" ); + out.clear(); + + to_string(out, double(-1e-06)); + BOOST_TEST_EQ( out, "-1e-06" ); + out.clear(); + + to_string(out, double(1e-05)); + BOOST_TEST_EQ( out, "0.00001" ); + out.clear(); + + to_string(out, double(-1e-05)); + BOOST_TEST_EQ( out, "-0.00001" ); + out.clear(); + + to_string(out, double(0.0001)); + BOOST_TEST_EQ( out, "0.0001" ); + out.clear(); + + to_string(out, double(-0.0001)); + BOOST_TEST_EQ( out, "-0.0001" ); + out.clear(); + + to_string(out, double(0.0001234567890123456)); + BOOST_TEST_EQ( out, "0.0001234567890123456" ); + out.clear(); + + to_string(out, double(-0.0001234567890123456)); + BOOST_TEST_EQ( out, "-0.0001234567890123456" ); + out.clear(); + + to_string(out, double(1000000000000000)); + BOOST_TEST_EQ( out, "1000000000000000" ); + out.clear(); + + to_string(out, double(-1000000000000000)); + BOOST_TEST_EQ( out, "-1000000000000000" ); + out.clear(); + + to_string(out, double(100000000000000.1)); + BOOST_TEST_EQ( out, "100000000000000.1" ); + out.clear(); + + to_string(out, double(1.00001)); + BOOST_TEST_EQ( out, "1.00001" ); + out.clear(); + + to_string(out, double(1234000000000000)); + BOOST_TEST_EQ( out, "1234000000000000" ); + out.clear(); + + to_string(out, double(1.234e+16)); + BOOST_TEST_EQ( out, "1.234e+16" ); + out.clear(); + + to_string(out, double(-1.234e+16)); + BOOST_TEST_EQ( out, "-1.234e+16" ); + out.clear(); + + // Test int + + to_string(out, int(2)); + BOOST_TEST_EQ( out, "2" ); + out.clear(); + } + catch (std::exception const & ex) + { + std::clog << "C++ type conversions problem: " << ex.what() << "\n"; + BOOST_TEST(false); + } if (!::boost::detail::test_errors()) { - std::clog << "C++ exceptions: \x1b[1;32m✓ \x1b[0m\n"; + std::clog << "C++ type conversions: \x1b[1;32m✓ \x1b[0m\n"; #if BOOST_VERSION >= 104600 ::boost::detail::report_errors_remind().called_report_errors_function = true; #endif From 159dec9aa59746c18fc055f8608401780896ae37 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Sun, 16 Dec 2012 12:23:01 -0800 Subject: [PATCH 03/15] configure python details if building python plugin as well as bindings --- SConstruct | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/SConstruct b/SConstruct index 45a3e5560..7c035a09f 100644 --- a/SConstruct +++ b/SConstruct @@ -1331,7 +1331,7 @@ if not preconfigured: else: color_print(4,'Not building with cairo support, pass CAIRO=True to enable') - if 'python' in env['BINDINGS']: + if 'python' in env['BINDINGS'] or 'python' in env['REQUESTED_PLUGINS']: if not os.access(env['PYTHON'], os.X_OK): color_print(1,"Cannot run python interpreter at '%s', make sure that you have the permissions to execute it." % env['PYTHON']) Exit(1) @@ -1386,22 +1386,22 @@ if not preconfigured: else: env['PYTHON_IS_64BIT'] = False - if py3 and env['BOOST_PYTHON_LIB'] == 'boost_python': - env['BOOST_PYTHON_LIB'] = 'boost_python3%s' % env['BOOST_APPEND'] - elif env['BOOST_PYTHON_LIB'] == 'boost_python': - env['BOOST_PYTHON_LIB'] = 'boost_python%s' % env['BOOST_APPEND'] + if 'python' in env['BINDINGS']: + if py3 and env['BOOST_PYTHON_LIB'] == 'boost_python': + env['BOOST_PYTHON_LIB'] = 'boost_python3%s' % env['BOOST_APPEND'] + elif env['BOOST_PYTHON_LIB'] == 'boost_python': + env['BOOST_PYTHON_LIB'] = 'boost_python%s' % env['BOOST_APPEND'] + if not conf.CheckHeader(header='boost/python/detail/config.hpp',language='C++'): + color_print(1,'Could not find required header files for boost python') + env['MISSING_DEPS'].append('boost python') - if not conf.CheckHeader(header='boost/python/detail/config.hpp',language='C++'): - color_print(1,'Could not find required header files for boost python') - env['MISSING_DEPS'].append('boost python') - - if env['CAIRO']: - if conf.CheckPKGConfig('0.15.0') and conf.CheckPKG('pycairo'): - env['HAS_PYCAIRO'] = True + if env['CAIRO']: + if conf.CheckPKGConfig('0.15.0') and conf.CheckPKG('pycairo'): + env['HAS_PYCAIRO'] = True + else: + env['SKIPPED_DEPS'].extend(['pycairo']) else: - env['SKIPPED_DEPS'].extend(['pycairo']) - else: - color_print(4,'Not building with pycairo support, pass CAIRO=True to enable') + color_print(4,'Not building with pycairo support, pass CAIRO=True to enable') #### End Config Stage for Required Dependencies #### @@ -1526,7 +1526,7 @@ if not preconfigured: if env['DEBUG_UNDEFINED']: env.Append(CXXFLAGS = '-fcatch-undefined-behavior -ftrapv -fwrapv') - if 'python' in env['BINDINGS']: + if 'python' in env['BINDINGS'] or 'python' in env['REQUESTED_PLUGINS']: majver, minver = env['PYTHON_VERSION'].split('.') # we don't want the includes it in the main environment... # as they are later set in the python build.py @@ -1542,9 +1542,10 @@ if not preconfigured: color_print(1,"Python version 2.2 or greater required") Exit(1) - color_print(4,'Bindings Python version... %s' % env['PYTHON_VERSION']) - color_print(4,'Python %s prefix... %s' % (env['PYTHON_VERSION'], env['PYTHON_SYS_PREFIX'])) - color_print(4,'Python bindings will install in... %s' % os.path.normpath(env['PYTHON_INSTALL_LOCATION'])) + if 'python' in env['BINDINGS']: + color_print(4,'Bindings Python version... %s' % env['PYTHON_VERSION']) + color_print(4,'Python %s prefix... %s' % (env['PYTHON_VERSION'], env['PYTHON_SYS_PREFIX'])) + color_print(4,'Python bindings will install in... %s' % os.path.normpath(env['PYTHON_INSTALL_LOCATION'])) env.Replace(**backup) # if requested, sort LIBPATH and CPPPATH one last time before saving... From 16aae90bfc68b18229b96281ebe3da05359f9962 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Sun, 16 Dec 2012 12:50:36 -0800 Subject: [PATCH 04/15] iwyu --- bindings/python/mapnik_datasource.cpp | 1 + bindings/python/mapnik_datasource_cache.cpp | 2 ++ bindings/python/mapnik_expression.cpp | 2 ++ bindings/python/mapnik_feature.cpp | 2 ++ bindings/python/mapnik_featureset.cpp | 1 + bindings/python/mapnik_font_engine.cpp | 2 ++ bindings/python/mapnik_geometry.cpp | 2 ++ bindings/python/mapnik_label_collision_detector.cpp | 2 ++ bindings/python/mapnik_logger.cpp | 2 ++ bindings/python/mapnik_palette.cpp | 1 + bindings/python/mapnik_proj_transform.cpp | 1 + bindings/python/mapnik_text_placement.cpp | 1 + bindings/python/python_optional.hpp | 1 + 13 files changed, 20 insertions(+) diff --git a/bindings/python/mapnik_datasource.cpp b/bindings/python/mapnik_datasource.cpp index 5ffb7c69b..445c1b11f 100644 --- a/bindings/python/mapnik_datasource.cpp +++ b/bindings/python/mapnik_datasource.cpp @@ -23,6 +23,7 @@ // boost #include #include +#include // stl #include diff --git a/bindings/python/mapnik_datasource_cache.cpp b/bindings/python/mapnik_datasource_cache.cpp index 50074f3af..db30d72c2 100644 --- a/bindings/python/mapnik_datasource_cache.cpp +++ b/bindings/python/mapnik_datasource_cache.cpp @@ -21,6 +21,8 @@ *****************************************************************************/ #include +#include + #include namespace { diff --git a/bindings/python/mapnik_expression.cpp b/bindings/python/mapnik_expression.cpp index b39c4c069..109b21e15 100644 --- a/bindings/python/mapnik_expression.cpp +++ b/bindings/python/mapnik_expression.cpp @@ -23,6 +23,8 @@ // boost #include #include +#include + // mapnik #include diff --git a/bindings/python/mapnik_feature.cpp b/bindings/python/mapnik_feature.cpp index d20af1793..d8e430cb2 100644 --- a/bindings/python/mapnik_feature.cpp +++ b/bindings/python/mapnik_feature.cpp @@ -28,6 +28,8 @@ #include #include #include +#include + // mapnik #include diff --git a/bindings/python/mapnik_featureset.cpp b/bindings/python/mapnik_featureset.cpp index 18fa63387..3148d116e 100644 --- a/bindings/python/mapnik_featureset.cpp +++ b/bindings/python/mapnik_featureset.cpp @@ -22,6 +22,7 @@ // boost #include +#include // mapnik #include diff --git a/bindings/python/mapnik_font_engine.cpp b/bindings/python/mapnik_font_engine.cpp index 5f4160756..1742de20b 100644 --- a/bindings/python/mapnik_font_engine.cpp +++ b/bindings/python/mapnik_font_engine.cpp @@ -21,6 +21,8 @@ *****************************************************************************/ #include +#include + #include void export_font_engine() diff --git a/bindings/python/mapnik_geometry.cpp b/bindings/python/mapnik_geometry.cpp index 17aa11389..bf90e167a 100644 --- a/bindings/python/mapnik_geometry.cpp +++ b/bindings/python/mapnik_geometry.cpp @@ -26,6 +26,8 @@ #include #include #include +#include + // mapnik #include diff --git a/bindings/python/mapnik_label_collision_detector.cpp b/bindings/python/mapnik_label_collision_detector.cpp index 4ee4c004c..55747e41f 100644 --- a/bindings/python/mapnik_label_collision_detector.cpp +++ b/bindings/python/mapnik_label_collision_detector.cpp @@ -24,6 +24,8 @@ #include #include #include +#include + #include #include diff --git a/bindings/python/mapnik_logger.cpp b/bindings/python/mapnik_logger.cpp index 0f3b30949..fee924ee6 100644 --- a/bindings/python/mapnik_logger.cpp +++ b/bindings/python/mapnik_logger.cpp @@ -21,6 +21,8 @@ *****************************************************************************/ #include +#include + #include #include #include "mapnik_enumeration.hpp" diff --git a/bindings/python/mapnik_palette.cpp b/bindings/python/mapnik_palette.cpp index 16a614757..2d82c0919 100644 --- a/bindings/python/mapnik_palette.cpp +++ b/bindings/python/mapnik_palette.cpp @@ -23,6 +23,7 @@ // boost #include #include +#include //mapnik #include diff --git a/bindings/python/mapnik_proj_transform.cpp b/bindings/python/mapnik_proj_transform.cpp index 7dec3b36b..5b1115555 100644 --- a/bindings/python/mapnik_proj_transform.cpp +++ b/bindings/python/mapnik_proj_transform.cpp @@ -22,6 +22,7 @@ // mapnik #include +#include // boost #include diff --git a/bindings/python/mapnik_text_placement.cpp b/bindings/python/mapnik_text_placement.cpp index 67b9a241e..2cdb744fc 100644 --- a/bindings/python/mapnik_text_placement.cpp +++ b/bindings/python/mapnik_text_placement.cpp @@ -21,6 +21,7 @@ *****************************************************************************/ #include #include +#include #include #include diff --git a/bindings/python/python_optional.hpp b/bindings/python/python_optional.hpp index 29c1990db..0d785b0f3 100644 --- a/bindings/python/python_optional.hpp +++ b/bindings/python/python_optional.hpp @@ -22,6 +22,7 @@ #include #include +#include // boost::optional to/from converter from John Wiegley From bb27156df0a111fdecfe87b48d27b2866b7a2816 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Sun, 16 Dec 2012 18:19:52 -0800 Subject: [PATCH 05/15] use internal noncopyable class to speed up compile times slightly --- demo/viewer/styles_model.cpp | 5 +++-- include/mapnik/agg_pattern_source.hpp | 6 ++---- include/mapnik/agg_rasterizer.hpp | 6 +++--- include/mapnik/agg_renderer.hpp | 4 ++-- include/mapnik/attribute_collector.hpp | 5 +++-- include/mapnik/cairo_renderer.hpp | 6 +++--- include/mapnik/datasource.hpp | 6 +++--- include/mapnik/datasource_cache.hpp | 4 ++-- include/mapnik/debug.hpp | 8 ++++---- include/mapnik/feature.hpp | 8 +++++--- include/mapnik/font_engine_freetype.hpp | 16 ++++++++-------- include/mapnik/formatting/registry.hpp | 6 ++---- include/mapnik/geometry.hpp | 4 ++-- include/mapnik/grid/grid_rasterizer.hpp | 4 ++-- include/mapnik/grid/grid_renderer.hpp | 4 ++-- include/mapnik/hextree.hpp | 4 ++-- .../mapnik/json/feature_collection_grammar.hpp | 3 ++- .../mapnik/json/feature_collection_parser.hpp | 5 +++-- include/mapnik/json/geojson_generator.hpp | 11 ++++++----- include/mapnik/json/geometry_parser.hpp | 5 +++-- include/mapnik/label_collision_detector.hpp | 7 ++++--- include/mapnik/mapped_memory_cache.hpp | 4 ++-- include/mapnik/marker.hpp | 4 ++-- include/mapnik/marker_cache.hpp | 4 ++-- include/mapnik/markers_placement.hpp | 6 ++---- include/mapnik/octree.hpp | 6 ++---- include/mapnik/palette.hpp | 4 ++-- include/mapnik/placement_finder.hpp | 3 ++- include/mapnik/plugin.hpp | 6 +++--- include/mapnik/pool.hpp | 4 ++-- include/mapnik/processed_text.hpp | 3 ++- include/mapnik/proj_transform.hpp | 6 ++---- include/mapnik/quad_tree.hpp | 4 ++-- include/mapnik/raster.hpp | 6 ++---- include/mapnik/simplify_converter.hpp | 3 ++- include/mapnik/svg/output/svg_generator.hpp | 5 ++--- include/mapnik/svg/output/svg_renderer.hpp | 3 ++- include/mapnik/svg/svg_converter.hpp | 6 ++---- include/mapnik/svg/svg_parser.hpp | 4 ++-- include/mapnik/svg/svg_path_adapter.hpp | 6 +++--- include/mapnik/svg/svg_renderer_agg.hpp | 4 ++-- include/mapnik/svg/svg_storage.hpp | 6 ++---- include/mapnik/text_path.hpp | 6 +++--- include/mapnik/text_placements/base.hpp | 2 +- include/mapnik/text_placements/registry.hpp | 6 ++---- include/mapnik/unicode.hpp | 4 ++-- include/mapnik/vertex_converters.hpp | 4 ++-- include/mapnik/vertex_vector.hpp | 4 ++-- include/mapnik/wkb.hpp | 6 ++---- include/mapnik/wkt/wkt_factory.hpp | 5 +++-- plugins/input/shape/dbfile.hpp | 6 ++++-- plugins/input/shape/shape_io.hpp | 4 ++-- plugins/input/shape/shapefile.hpp | 4 ++-- plugins/input/sqlite/sqlite_prepared.hpp | 4 ++-- src/agg/process_line_pattern_symbolizer.cpp | 4 ++-- src/cairo_renderer.cpp | 10 +++++----- src/jpeg_reader.cpp | 4 ++-- src/libxml2_loader.cpp | 4 ++-- src/load_map.cpp | 3 ++- src/png_reader.cpp | 4 ++-- src/rapidxml_loader.cpp | 6 ++---- src/wkb.cpp | 4 ++-- utils/pgsql2sqlite/sqlite.hpp | 7 ++++--- 63 files changed, 160 insertions(+), 165 deletions(-) diff --git a/demo/viewer/styles_model.cpp b/demo/viewer/styles_model.cpp index 3468de005..875d97dbe 100644 --- a/demo/viewer/styles_model.cpp +++ b/demo/viewer/styles_model.cpp @@ -20,17 +20,18 @@ #include "styles_model.hpp" #include +#include + // boost #include #include -#include // qt #include #include #include #include -class node : private boost::noncopyable +class node : private mapnik::noncopyable { struct node_base { diff --git a/include/mapnik/agg_pattern_source.hpp b/include/mapnik/agg_pattern_source.hpp index 0f24ddaf4..39688e07e 100644 --- a/include/mapnik/agg_pattern_source.hpp +++ b/include/mapnik/agg_pattern_source.hpp @@ -25,9 +25,7 @@ // mapnik #include - -// boost -#include +#include // agg #include "agg_color_rgba.h" @@ -35,7 +33,7 @@ namespace mapnik { -class pattern_source : private boost::noncopyable +class pattern_source : private mapnik::noncopyable { public: pattern_source(image_data_32 const& pattern) diff --git a/include/mapnik/agg_rasterizer.hpp b/include/mapnik/agg_rasterizer.hpp index 49ac23b81..1f93c556f 100644 --- a/include/mapnik/agg_rasterizer.hpp +++ b/include/mapnik/agg_rasterizer.hpp @@ -23,15 +23,15 @@ #ifndef MAPNIK_AGG_RASTERIZER_HPP #define MAPNIK_AGG_RASTERIZER_HPP -// boost -#include +// mapnik +#include // agg #include "agg_rasterizer_scanline_aa.h" namespace mapnik { -struct rasterizer : agg::rasterizer_scanline_aa<>, boost::noncopyable {}; +struct rasterizer : agg::rasterizer_scanline_aa<>, mapnik::noncopyable {}; } diff --git a/include/mapnik/agg_renderer.hpp b/include/mapnik/agg_renderer.hpp index 68823917e..08b387a08 100644 --- a/include/mapnik/agg_renderer.hpp +++ b/include/mapnik/agg_renderer.hpp @@ -30,9 +30,9 @@ #include #include #include // for all symbolizers +#include // boost -#include #include #include #include @@ -53,7 +53,7 @@ struct rasterizer; template class MAPNIK_DECL agg_renderer : public feature_style_processor >, - private boost::noncopyable + private mapnik::noncopyable { public: diff --git a/include/mapnik/attribute_collector.hpp b/include/mapnik/attribute_collector.hpp index 9ff8b56cc..a1abc86a8 100644 --- a/include/mapnik/attribute_collector.hpp +++ b/include/mapnik/attribute_collector.hpp @@ -26,8 +26,9 @@ // mapnik #include #include +#include + // boost -#include #include #include // stl @@ -206,7 +207,7 @@ private: }; -class attribute_collector : public boost::noncopyable +class attribute_collector : public mapnik::noncopyable { private: std::set& names_; diff --git a/include/mapnik/cairo_renderer.hpp b/include/mapnik/cairo_renderer.hpp index b188050f8..e747823e3 100644 --- a/include/mapnik/cairo_renderer.hpp +++ b/include/mapnik/cairo_renderer.hpp @@ -32,13 +32,13 @@ #include #include #include // for all symbolizers +#include // cairo #include #include // boost -#include #include // FIXME @@ -57,7 +57,7 @@ class cairo_face; typedef boost::shared_ptr cairo_face_ptr; -class cairo_face_manager : private boost::noncopyable +class cairo_face_manager : private mapnik::noncopyable { public: cairo_face_manager(boost::shared_ptr engine); @@ -69,7 +69,7 @@ private: cairo_face_cache cache_; }; -class MAPNIK_DECL cairo_renderer_base : private boost::noncopyable +class MAPNIK_DECL cairo_renderer_base : private mapnik::noncopyable { protected: cairo_renderer_base(Map const& m, Cairo::RefPtr const& context, double scale_factor=1.0, unsigned offset_x=0, unsigned offset_y=0); diff --git a/include/mapnik/datasource.hpp b/include/mapnik/datasource.hpp index 014cc99e6..f05ce0c2b 100644 --- a/include/mapnik/datasource.hpp +++ b/include/mapnik/datasource.hpp @@ -29,9 +29,9 @@ #include #include #include +#include // boost -#include #include // stl @@ -42,7 +42,7 @@ namespace mapnik { typedef MAPNIK_DECL boost::shared_ptr feature_ptr; -struct MAPNIK_DECL Featureset : private boost::noncopyable +struct MAPNIK_DECL Featureset : private mapnik::noncopyable { virtual feature_ptr next() = 0; virtual ~Featureset() {} @@ -70,7 +70,7 @@ private: std::string message_; }; -class MAPNIK_DECL datasource : private boost::noncopyable +class MAPNIK_DECL datasource : private mapnik::noncopyable { public: enum datasource_t { diff --git a/include/mapnik/datasource_cache.hpp b/include/mapnik/datasource_cache.hpp index 51cdfd415..0b74f1663 100644 --- a/include/mapnik/datasource_cache.hpp +++ b/include/mapnik/datasource_cache.hpp @@ -28,9 +28,9 @@ #include #include #include +#include // boost -#include #include // stl @@ -40,7 +40,7 @@ namespace mapnik { class MAPNIK_DECL datasource_cache : public singleton, - private boost::noncopyable + private mapnik::noncopyable { friend class CreateStatic; public: diff --git a/include/mapnik/debug.hpp b/include/mapnik/debug.hpp index b53cc985c..caf5777fc 100644 --- a/include/mapnik/debug.hpp +++ b/include/mapnik/debug.hpp @@ -26,9 +26,9 @@ // mapnik (should not depend on anything that need to use this) #include #include +#include // boost -#include #include #ifdef MAPNIK_THREADSAFE #include @@ -50,7 +50,7 @@ namespace mapnik { */ class MAPNIK_DECL logger : public singleton, - private boost::noncopyable + private mapnik::noncopyable { public: enum severity_type @@ -186,7 +186,7 @@ namespace mapnik { class Ch = char, class Tr = std::char_traits, class A = std::allocator > - class base_log : public boost::noncopyable + class base_log : public mapnik::noncopyable { public: typedef OutputPolicy output_policy; @@ -245,7 +245,7 @@ namespace mapnik { class Ch = char, class Tr = std::char_traits, class A = std::allocator > - class base_log_always : public boost::noncopyable + class base_log_always : public mapnik::noncopyable { public: typedef OutputPolicy output_policy; diff --git a/include/mapnik/feature.hpp b/include/mapnik/feature.hpp index 3b6bf4751..d6a88a2aa 100644 --- a/include/mapnik/feature.hpp +++ b/include/mapnik/feature.hpp @@ -29,6 +29,8 @@ #include #include #include +#include + // boost #include #if BOOST_VERSION >= 104000 @@ -36,7 +38,7 @@ #else #include #endif -#include + #include #include @@ -52,7 +54,7 @@ typedef boost::shared_ptr raster_ptr; class feature_impl; template -class context : private boost::noncopyable, +class context : private mapnik::noncopyable, public boost::associative_property_map { @@ -95,7 +97,7 @@ typedef MAPNIK_DECL boost::shared_ptr context_ptr; static const value default_value; -class MAPNIK_DECL feature_impl : private boost::noncopyable +class MAPNIK_DECL feature_impl : private mapnik::noncopyable { friend class feature_kv_iterator; public: diff --git a/include/mapnik/font_engine_freetype.hpp b/include/mapnik/font_engine_freetype.hpp index d77206cb4..858b2c0cd 100644 --- a/include/mapnik/font_engine_freetype.hpp +++ b/include/mapnik/font_engine_freetype.hpp @@ -32,6 +32,7 @@ #include #include #include +#include // freetype2 extern "C" @@ -45,7 +46,6 @@ extern "C" // boost #include #include -#include #include #include #ifdef MAPNIK_THREADSAFE @@ -69,7 +69,7 @@ class string_info; typedef boost::shared_ptr face_ptr; -class MAPNIK_DECL font_glyph : private boost::noncopyable +class MAPNIK_DECL font_glyph : private mapnik::noncopyable { public: font_glyph(face_ptr face, unsigned index) @@ -91,7 +91,7 @@ private: typedef boost::shared_ptr glyph_ptr; -class font_face : boost::noncopyable +class font_face : mapnik::noncopyable { public: font_face(FT_Face face) @@ -145,7 +145,7 @@ private: FT_Face face_; }; -class MAPNIK_DECL font_face_set : private boost::noncopyable +class MAPNIK_DECL font_face_set : private mapnik::noncopyable { public: font_face_set(void) @@ -200,7 +200,7 @@ private: }; // FT_Stroker wrapper -class stroker : boost::noncopyable +class stroker : mapnik::noncopyable { public: explicit stroker(FT_Stroker s) @@ -264,7 +264,7 @@ private: }; template -class MAPNIK_DECL face_manager : private boost::noncopyable +class MAPNIK_DECL face_manager : private mapnik::noncopyable { typedef T font_engine_type; typedef std::map face_ptr_cache_type; @@ -351,9 +351,9 @@ private: }; template -struct text_renderer : private boost::noncopyable +struct text_renderer : private mapnik::noncopyable { - struct glyph_t : boost::noncopyable + struct glyph_t : mapnik::noncopyable { FT_Glyph image; char_properties *properties; diff --git a/include/mapnik/formatting/registry.hpp b/include/mapnik/formatting/registry.hpp index ef0f2c978..5e77ca006 100644 --- a/include/mapnik/formatting/registry.hpp +++ b/include/mapnik/formatting/registry.hpp @@ -25,9 +25,7 @@ // mapnik #include #include - -// boost -#include +#include // stl #include @@ -41,7 +39,7 @@ namespace formatting typedef node_ptr (*from_xml_function_ptr)(xml_node const& xml); class registry : public singleton, - private boost::noncopyable + private mapnik::noncopyable { public: registry(); diff --git a/include/mapnik/geometry.hpp b/include/mapnik/geometry.hpp index 2dcc0aeb9..aecc4536d 100644 --- a/include/mapnik/geometry.hpp +++ b/include/mapnik/geometry.hpp @@ -26,10 +26,10 @@ // mapnik #include #include +#include // boost #include -#include #include namespace mapnik { @@ -42,7 +42,7 @@ enum eGeomType { }; template class Container=vertex_vector> -class geometry : private::boost::noncopyable +class geometry : private::mapnik::noncopyable { public: typedef T coord_type; diff --git a/include/mapnik/grid/grid_rasterizer.hpp b/include/mapnik/grid/grid_rasterizer.hpp index 43fa30b72..9cdbf2724 100644 --- a/include/mapnik/grid/grid_rasterizer.hpp +++ b/include/mapnik/grid/grid_rasterizer.hpp @@ -23,12 +23,12 @@ #ifndef MAPNIK_GRID_RASTERIZER_HPP #define MAPNIK_GRID_RASTERIZER_HPP -#include +#include #include "agg_rasterizer_scanline_aa.h" namespace mapnik { -struct grid_rasterizer : agg::rasterizer_scanline_aa<>, boost::noncopyable {}; +struct grid_rasterizer : agg::rasterizer_scanline_aa<>, mapnik::noncopyable {}; } diff --git a/include/mapnik/grid/grid_renderer.hpp b/include/mapnik/grid/grid_renderer.hpp index 55e9cd901..6db0581a8 100644 --- a/include/mapnik/grid/grid_renderer.hpp +++ b/include/mapnik/grid/grid_renderer.hpp @@ -31,9 +31,9 @@ #include #include // for all symbolizers #include +#include // boost -#include #include // FIXME @@ -52,7 +52,7 @@ struct grid_rasterizer; template class MAPNIK_DECL grid_renderer : public feature_style_processor >, - private boost::noncopyable + private mapnik::noncopyable { public: diff --git a/include/mapnik/hextree.hpp b/include/mapnik/hextree.hpp index 9d399188c..20aa7e689 100644 --- a/include/mapnik/hextree.hpp +++ b/include/mapnik/hextree.hpp @@ -26,9 +26,9 @@ // mapnik #include #include +#include // boost -#include #include #include #if BOOST_VERSION >= 104600 @@ -60,7 +60,7 @@ struct RGBAPolicy }; template -class hextree : private boost::noncopyable +class hextree : private mapnik::noncopyable { struct node { diff --git a/include/mapnik/json/feature_collection_grammar.hpp b/include/mapnik/json/feature_collection_grammar.hpp index 6bd86590b..491a9ace1 100644 --- a/include/mapnik/json/feature_collection_grammar.hpp +++ b/include/mapnik/json/feature_collection_grammar.hpp @@ -25,6 +25,7 @@ // mapnik #include +#include // spirit::qi #include @@ -88,7 +89,7 @@ struct feature_collection_grammar : > lit(']') ; - feature = eps[_a = construct(new_(ctx_,generate_id_()))] + feature = eps[_a = construct(new_(ctx_,generate_id_()))] >> feature_g(*_a)[push_back(_r1,_a)] ; diff --git a/include/mapnik/json/feature_collection_parser.hpp b/include/mapnik/json/feature_collection_parser.hpp index f3805a621..5238f37a0 100644 --- a/include/mapnik/json/feature_collection_parser.hpp +++ b/include/mapnik/json/feature_collection_parser.hpp @@ -27,10 +27,11 @@ #include #include #include +#include // boost #include -#include + // stl #include @@ -39,7 +40,7 @@ namespace mapnik { namespace json { template struct feature_collection_grammar; template -class feature_collection_parser : private boost::noncopyable +class feature_collection_parser : private mapnik::noncopyable { typedef Iterator iterator_type; typedef mapnik::Feature feature_type; diff --git a/include/mapnik/json/geojson_generator.hpp b/include/mapnik/json/geojson_generator.hpp index 360272f11..36c587c3b 100644 --- a/include/mapnik/json/geojson_generator.hpp +++ b/include/mapnik/json/geojson_generator.hpp @@ -25,8 +25,9 @@ #include #include +#include + #include -#include #include namespace mapnik { namespace json { @@ -36,7 +37,7 @@ namespace mapnik { namespace json { template struct feature_generator_grammar; template struct multi_geometry_generator_grammar; -class MAPNIK_DECL feature_generator : private boost::noncopyable +class MAPNIK_DECL feature_generator : private mapnik::noncopyable { typedef std::back_insert_iterator sink_type; public: @@ -47,7 +48,7 @@ private: boost::scoped_ptr > grammar_; }; -class MAPNIK_DECL geometry_generator : private boost::noncopyable +class MAPNIK_DECL geometry_generator : private mapnik::noncopyable { typedef std::back_insert_iterator sink_type; public: @@ -60,7 +61,7 @@ private: #else -class MAPNIK_DECL feature_generator : private boost::noncopyable +class MAPNIK_DECL feature_generator : private mapnik::noncopyable { public: feature_generator() {} @@ -68,7 +69,7 @@ public: bool generate(std::string & geojson, mapnik::Feature const& f); }; -class MAPNIK_DECL geometry_generator : private boost::noncopyable +class MAPNIK_DECL geometry_generator : private mapnik::noncopyable { public: geometry_generator() {} diff --git a/include/mapnik/json/geometry_parser.hpp b/include/mapnik/json/geometry_parser.hpp index 851887714..76985f9a5 100644 --- a/include/mapnik/json/geometry_parser.hpp +++ b/include/mapnik/json/geometry_parser.hpp @@ -26,10 +26,11 @@ // mapnik #include #include +#include // boost #include -#include + // stl //#include @@ -40,7 +41,7 @@ template struct geometry_grammar; MAPNIK_DECL bool from_geojson(std::string const& json, boost::ptr_vector & paths); template -class MAPNIK_DECL geometry_parser : private boost::noncopyable +class MAPNIK_DECL geometry_parser : private mapnik::noncopyable { typedef Iterator iterator_type; public: diff --git a/include/mapnik/label_collision_detector.hpp b/include/mapnik/label_collision_detector.hpp index b4256bb6b..2db67d48f 100644 --- a/include/mapnik/label_collision_detector.hpp +++ b/include/mapnik/label_collision_detector.hpp @@ -25,6 +25,7 @@ // mapnik #include +#include // stl #include @@ -63,7 +64,7 @@ private: }; // quad_tree based label collision detector -class label_collision_detector2 : boost::noncopyable +class label_collision_detector2 : mapnik::noncopyable { typedef quad_tree > tree_t; tree_t tree_; @@ -97,7 +98,7 @@ public: }; // quad_tree based label collision detector with seperate check/insert -class label_collision_detector3 : boost::noncopyable +class label_collision_detector3 : mapnik::noncopyable { typedef quad_tree< box2d > tree_t; tree_t tree_; @@ -135,7 +136,7 @@ public: //quad tree based label collision detector so labels dont appear within a given distance -class label_collision_detector4 : boost::noncopyable +class label_collision_detector4 : mapnik::noncopyable { public: struct label diff --git a/include/mapnik/mapped_memory_cache.hpp b/include/mapnik/mapped_memory_cache.hpp index a8144a7c0..6b53481c1 100644 --- a/include/mapnik/mapped_memory_cache.hpp +++ b/include/mapnik/mapped_memory_cache.hpp @@ -26,9 +26,9 @@ // mapnik #include #include +#include // boost -#include #include #include #include @@ -43,7 +43,7 @@ typedef boost::shared_ptr mapped_region_ptr; struct MAPNIK_DECL mapped_memory_cache : public singleton, - private boost::noncopyable + private mapnik::noncopyable { friend class CreateStatic; boost::unordered_map cache_; diff --git a/include/mapnik/marker.hpp b/include/mapnik/marker.hpp index c882727a3..aac1a3660 100644 --- a/include/mapnik/marker.hpp +++ b/include/mapnik/marker.hpp @@ -29,12 +29,12 @@ #include #include #include +#include // agg #include "agg_path_storage.h" // boost -#include #include #include #include @@ -55,7 +55,7 @@ typedef boost::shared_ptr image_ptr; * A class to hold either vector or bitmap marker data. This allows these to be treated equally * in the image caches and most of the render paths. */ -class marker: private boost::noncopyable +class marker: private mapnik::noncopyable { public: marker() diff --git a/include/mapnik/marker_cache.hpp b/include/mapnik/marker_cache.hpp index e97d09ca8..eca2decd3 100644 --- a/include/mapnik/marker_cache.hpp +++ b/include/mapnik/marker_cache.hpp @@ -26,9 +26,9 @@ // mapnik #include #include +#include // boost -#include #include #include #include @@ -43,7 +43,7 @@ typedef boost::shared_ptr marker_ptr; class MAPNIK_DECL marker_cache : public singleton , - private boost::noncopyable + private mapnik::noncopyable { friend class CreateUsingNew; private: diff --git a/include/mapnik/markers_placement.hpp b/include/mapnik/markers_placement.hpp index 74b35011a..eddedafe3 100644 --- a/include/mapnik/markers_placement.hpp +++ b/include/mapnik/markers_placement.hpp @@ -30,9 +30,7 @@ #include #include //round #include - -// boost -#include +#include // agg #include "agg_basics.h" @@ -48,7 +46,7 @@ namespace mapnik { template -class markers_placement : boost::noncopyable +class markers_placement : mapnik::noncopyable { public: /** Constructor for markers_placement object. diff --git a/include/mapnik/octree.hpp b/include/mapnik/octree.hpp index 5535f2747..c2ec49f2c 100644 --- a/include/mapnik/octree.hpp +++ b/include/mapnik/octree.hpp @@ -26,9 +26,7 @@ // mapnik #include #include - -// boost -#include +#include // stl #include @@ -51,7 +49,7 @@ struct RGBPolicy }; template -class octree : private boost::noncopyable +class octree : private mapnik::noncopyable { struct node { diff --git a/include/mapnik/palette.hpp b/include/mapnik/palette.hpp index 703e38c02..8617c5735 100644 --- a/include/mapnik/palette.hpp +++ b/include/mapnik/palette.hpp @@ -26,9 +26,9 @@ // mapnik #include #include +#include // boost -#include #include // stl @@ -126,7 +126,7 @@ struct rgba typedef boost::unordered_map rgba_hash_table; -class MAPNIK_DECL rgba_palette : private boost::noncopyable { +class MAPNIK_DECL rgba_palette : private mapnik::noncopyable { public: enum palette_type { PALETTE_RGBA = 0, PALETTE_RGB = 1, PALETTE_ACT = 2 }; diff --git a/include/mapnik/placement_finder.hpp b/include/mapnik/placement_finder.hpp index fca15958b..9be885c72 100644 --- a/include/mapnik/placement_finder.hpp +++ b/include/mapnik/placement_finder.hpp @@ -30,6 +30,7 @@ #include #include #include +#include // agg @@ -54,7 +55,7 @@ typedef label_collision_detector4 DetectorType; template -class placement_finder : boost::noncopyable +class placement_finder : mapnik::noncopyable { public: placement_finder(Feature const& feature, diff --git a/include/mapnik/plugin.hpp b/include/mapnik/plugin.hpp index ef7a84d4d..8058f1483 100644 --- a/include/mapnik/plugin.hpp +++ b/include/mapnik/plugin.hpp @@ -23,8 +23,8 @@ #ifndef MAPNIK_PLUGIN_HPP #define MAPNIK_PLUGIN_HPP -// boost -#include +// mapnik +#include // stl #include @@ -34,7 +34,7 @@ namespace mapnik { -class PluginInfo : boost::noncopyable +class PluginInfo : mapnik::noncopyable { private: std::string name_; diff --git a/include/mapnik/pool.hpp b/include/mapnik/pool.hpp index efe338ce9..fe0572687 100644 --- a/include/mapnik/pool.hpp +++ b/include/mapnik/pool.hpp @@ -26,10 +26,10 @@ // mapnik #include #include +#include // boost #include -#include #ifdef MAPNIK_THREADSAFE #include #endif @@ -65,7 +65,7 @@ private: }; template class Creator> -class Pool : private boost::noncopyable +class Pool : private mapnik::noncopyable { typedef boost::shared_ptr HolderType; typedef std::deque ContType; diff --git a/include/mapnik/processed_text.hpp b/include/mapnik/processed_text.hpp index 54c2958e5..734300d89 100644 --- a/include/mapnik/processed_text.hpp +++ b/include/mapnik/processed_text.hpp @@ -26,11 +26,12 @@ #include #include #include +#include namespace mapnik { -class processed_text : boost::noncopyable +class processed_text : mapnik::noncopyable { public: class processed_expression diff --git a/include/mapnik/proj_transform.hpp b/include/mapnik/proj_transform.hpp index 607e99fb9..f238fc6e8 100644 --- a/include/mapnik/proj_transform.hpp +++ b/include/mapnik/proj_transform.hpp @@ -26,13 +26,11 @@ // mapnik #include #include - -// boost -#include +#include namespace mapnik { -class MAPNIK_DECL proj_transform : private boost::noncopyable +class MAPNIK_DECL proj_transform : private mapnik::noncopyable { public: proj_transform(projection const& source, diff --git a/include/mapnik/quad_tree.hpp b/include/mapnik/quad_tree.hpp index 9496122a3..3bbcbc465 100644 --- a/include/mapnik/quad_tree.hpp +++ b/include/mapnik/quad_tree.hpp @@ -25,10 +25,10 @@ // mapnik #include +#include // boost #include -#include // stl #include @@ -37,7 +37,7 @@ namespace mapnik { template -class quad_tree : boost::noncopyable +class quad_tree : mapnik::noncopyable { struct node { diff --git a/include/mapnik/raster.hpp b/include/mapnik/raster.hpp index e4b4ec288..4b1ce1cfb 100644 --- a/include/mapnik/raster.hpp +++ b/include/mapnik/raster.hpp @@ -26,12 +26,10 @@ // mapnik #include #include - -// boost -#include +#include namespace mapnik { -class raster : private boost::noncopyable +class raster : private mapnik::noncopyable { public: box2d ext_; diff --git a/include/mapnik/simplify_converter.hpp b/include/mapnik/simplify_converter.hpp index 2476311d2..a25cd7479 100644 --- a/include/mapnik/simplify_converter.hpp +++ b/include/mapnik/simplify_converter.hpp @@ -5,6 +5,7 @@ #include #include #include +#include // STL #include @@ -17,7 +18,7 @@ namespace mapnik { -struct weighted_vertex : private boost::noncopyable +struct weighted_vertex : private mapnik::noncopyable { vertex2d coord; double weight; diff --git a/include/mapnik/svg/output/svg_generator.hpp b/include/mapnik/svg/output/svg_generator.hpp index 973f32c75..bd5b3fffd 100644 --- a/include/mapnik/svg/output/svg_generator.hpp +++ b/include/mapnik/svg/output/svg_generator.hpp @@ -30,9 +30,8 @@ #include #include #include +#include -// boost -#include namespace mapnik { namespace svg { @@ -43,7 +42,7 @@ namespace mapnik { namespace svg { * structure. */ template - class svg_generator : private boost::noncopyable + class svg_generator : private mapnik::noncopyable { typedef svg::svg_root_attributes_grammar root_attributes_grammar; typedef svg::svg_rect_attributes_grammar rect_attributes_grammar; diff --git a/include/mapnik/svg/output/svg_renderer.hpp b/include/mapnik/svg/output/svg_renderer.hpp index bcde8d37c..05ebe356d 100644 --- a/include/mapnik/svg/output/svg_renderer.hpp +++ b/include/mapnik/svg/output/svg_renderer.hpp @@ -28,6 +28,7 @@ #include #include #include +#include // stl #include @@ -39,7 +40,7 @@ namespace mapnik // can target many other output destinations besides streams. template class MAPNIK_DECL svg_renderer : public feature_style_processor >, - private boost::noncopyable + private mapnik::noncopyable { public: typedef svg_renderer processor_impl_type; diff --git a/include/mapnik/svg/svg_converter.hpp b/include/mapnik/svg/svg_converter.hpp index 4ba4c4bff..d67c6c2ca 100644 --- a/include/mapnik/svg/svg_converter.hpp +++ b/include/mapnik/svg/svg_converter.hpp @@ -26,9 +26,7 @@ // mapnik #include #include - -// boost -#include +#include // agg #include "agg_path_storage.h" @@ -46,7 +44,7 @@ namespace mapnik { namespace svg { template -class svg_converter : boost::noncopyable +class svg_converter : mapnik::noncopyable { public: diff --git a/include/mapnik/svg/svg_parser.hpp b/include/mapnik/svg/svg_parser.hpp index 96559b6dc..68f151bf2 100644 --- a/include/mapnik/svg/svg_parser.hpp +++ b/include/mapnik/svg/svg_parser.hpp @@ -28,9 +28,9 @@ #include #include #include +#include // boost -#include #include // stl @@ -38,7 +38,7 @@ namespace mapnik { namespace svg { - class svg_parser : private boost::noncopyable + class svg_parser : private mapnik::noncopyable { public: explicit svg_parser(svg_converter_type & path); diff --git a/include/mapnik/svg/svg_path_adapter.hpp b/include/mapnik/svg/svg_path_adapter.hpp index edf24f27b..57f38aafd 100644 --- a/include/mapnik/svg/svg_path_adapter.hpp +++ b/include/mapnik/svg/svg_path_adapter.hpp @@ -24,7 +24,7 @@ #define MAPNIK_SVG_PATH_ADAPTER_HPP // mapnik -#include +#include // agg #include "agg_math.h" @@ -40,7 +40,7 @@ namespace svg { using namespace agg; -template class path_adapter : boost::noncopyable +template class path_adapter : mapnik::noncopyable { public: typedef VertexContainer container_type; @@ -838,7 +838,7 @@ void path_adapter::translate_all_paths(double dx, double dy) } -template class vertex_stl_adapter : boost::noncopyable +template class vertex_stl_adapter : mapnik::noncopyable { public: diff --git a/include/mapnik/svg/svg_renderer_agg.hpp b/include/mapnik/svg/svg_renderer_agg.hpp index 28a9b6128..c8aa62345 100644 --- a/include/mapnik/svg/svg_renderer_agg.hpp +++ b/include/mapnik/svg/svg_renderer_agg.hpp @@ -29,9 +29,9 @@ #include #include #include +#include // boost -#include #include // agg @@ -100,7 +100,7 @@ private: }; template -class svg_renderer_agg : boost::noncopyable +class svg_renderer_agg : mapnik::noncopyable { public: typedef agg::conv_curve curved_type; diff --git a/include/mapnik/svg/svg_storage.hpp b/include/mapnik/svg/svg_storage.hpp index 4d229cd81..a0827972a 100644 --- a/include/mapnik/svg/svg_storage.hpp +++ b/include/mapnik/svg/svg_storage.hpp @@ -25,15 +25,13 @@ // mapnik #include - -// boost -#include +#include namespace mapnik { namespace svg { template -class svg_storage : boost::noncopyable +class svg_storage : mapnik::noncopyable { public: svg_storage() {} diff --git a/include/mapnik/text_path.hpp b/include/mapnik/text_path.hpp index 557519ed2..b45ae9a6c 100644 --- a/include/mapnik/text_path.hpp +++ b/include/mapnik/text_path.hpp @@ -26,12 +26,12 @@ // mapnik #include #include +#include //stl #include // boost -#include #include // uci @@ -40,7 +40,7 @@ namespace mapnik { -class string_info : private boost::noncopyable +class string_info : private mapnik::noncopyable { protected: typedef std::vector characters_t; @@ -122,7 +122,7 @@ typedef char_info const * char_info_ptr; /** List of all characters and their positions and formats for a placement. */ -class text_path : boost::noncopyable +class text_path : mapnik::noncopyable { struct character_node { diff --git a/include/mapnik/text_placements/base.hpp b/include/mapnik/text_placements/base.hpp index 477bea26d..5fbc5c8fe 100644 --- a/include/mapnik/text_placements/base.hpp +++ b/include/mapnik/text_placements/base.hpp @@ -37,7 +37,7 @@ class MAPNIK_DECL text_placements; * This placement has first to be tested by placement_finder to verify it * can actually be used. */ -class text_placement_info : boost::noncopyable +class text_placement_info : mapnik::noncopyable { public: /** Constructor. Takes the parent text_placements object as a parameter diff --git a/include/mapnik/text_placements/registry.hpp b/include/mapnik/text_placements/registry.hpp index f3bd123bf..4fc71070e 100644 --- a/include/mapnik/text_placements/registry.hpp +++ b/include/mapnik/text_placements/registry.hpp @@ -25,9 +25,7 @@ // mapnik #include #include - -// boost -#include +#include // stl #include @@ -42,7 +40,7 @@ typedef text_placements_ptr (*from_xml_function_ptr)( xml_node const& xml, fontset_map const & fontsets); class registry : public singleton, - private boost::noncopyable + private mapnik::noncopyable { public: registry(); diff --git a/include/mapnik/unicode.hpp b/include/mapnik/unicode.hpp index 2e8a64656..ae2139a5e 100644 --- a/include/mapnik/unicode.hpp +++ b/include/mapnik/unicode.hpp @@ -25,13 +25,13 @@ //mapnik #include +#include // icu #include #include // boost -#include #include // stl @@ -39,7 +39,7 @@ namespace mapnik { -class MAPNIK_DECL transcoder : private boost::noncopyable +class MAPNIK_DECL transcoder : private mapnik::noncopyable { public: explicit transcoder (std::string const& encoding); diff --git a/include/mapnik/vertex_converters.hpp b/include/mapnik/vertex_converters.hpp index 5070c0ad9..cc41f7e91 100644 --- a/include/mapnik/vertex_converters.hpp +++ b/include/mapnik/vertex_converters.hpp @@ -44,13 +44,13 @@ #include #include -#include #include // mapnik #include #include #include +#include // agg #include "agg_conv_clip_polygon.h" @@ -317,7 +317,7 @@ struct dispatcher template -struct vertex_converter : private boost::noncopyable +struct vertex_converter : private mapnik::noncopyable { typedef C conv_types; typedef B bbox_type; diff --git a/include/mapnik/vertex_vector.hpp b/include/mapnik/vertex_vector.hpp index e17a69320..44fbd7884 100644 --- a/include/mapnik/vertex_vector.hpp +++ b/include/mapnik/vertex_vector.hpp @@ -29,9 +29,9 @@ // mapnik #include +#include // boost -#include #include #include // required for memcpy with linux/g++ @@ -40,7 +40,7 @@ namespace mapnik { template -class vertex_vector : private boost::noncopyable +class vertex_vector : private mapnik::noncopyable { typedef T coord_type; typedef vertex vertex_type; diff --git a/include/mapnik/wkb.hpp b/include/mapnik/wkb.hpp index 5f546fe69..0f440aa57 100644 --- a/include/mapnik/wkb.hpp +++ b/include/mapnik/wkb.hpp @@ -25,9 +25,7 @@ // mapnik #include - -// boost -#include +#include namespace mapnik { @@ -50,7 +48,7 @@ enum wkbFormat wkbSpatiaLite=3 }; -class MAPNIK_DECL geometry_utils : private boost::noncopyable +class MAPNIK_DECL geometry_utils : private mapnik::noncopyable { public: diff --git a/include/mapnik/wkt/wkt_factory.hpp b/include/mapnik/wkt/wkt_factory.hpp index 8fc246db9..a35299b9b 100644 --- a/include/mapnik/wkt/wkt_factory.hpp +++ b/include/mapnik/wkt/wkt_factory.hpp @@ -27,8 +27,9 @@ #include #include #include +#include + // boost -#include #include #include #include @@ -42,7 +43,7 @@ MAPNIK_DECL bool from_wkt(std::string const& wkt, boost::ptr_vector= 104700 -class MAPNIK_DECL wkt_parser : boost::noncopyable +class MAPNIK_DECL wkt_parser : mapnik::noncopyable { typedef std::string::const_iterator iterator_type; public: diff --git a/plugins/input/shape/dbfile.hpp b/plugins/input/shape/dbfile.hpp index 1d6bb4473..423409e3e 100644 --- a/plugins/input/shape/dbfile.hpp +++ b/plugins/input/shape/dbfile.hpp @@ -23,9 +23,11 @@ #ifndef DBFFILE_HPP #define DBFFILE_HPP +// mapnik #include +#include + // boost -#include #include // stl @@ -48,7 +50,7 @@ struct field_descriptor }; -class dbf_file : private boost::noncopyable +class dbf_file : private mapnik::noncopyable { private: int num_records_; diff --git a/plugins/input/shape/shape_io.hpp b/plugins/input/shape/shape_io.hpp index bbfe2cd85..4f5c8cd2b 100644 --- a/plugins/input/shape/shape_io.hpp +++ b/plugins/input/shape/shape_io.hpp @@ -26,16 +26,16 @@ // mapnik #include #include +#include // boost -#include #include #include "dbfile.hpp" #include "shapefile.hpp" #include "shp_index.hpp" -struct shape_io : boost::noncopyable +struct shape_io : mapnik::noncopyable { public: enum shapeType diff --git a/plugins/input/shape/shapefile.hpp b/plugins/input/shape/shapefile.hpp index 095f2c69b..cf97a9da0 100644 --- a/plugins/input/shape/shapefile.hpp +++ b/plugins/input/shape/shapefile.hpp @@ -31,9 +31,9 @@ #include #include #include +#include // boost -#include #include #include @@ -130,7 +130,7 @@ struct shape_record using namespace boost::interprocess; -class shape_file : boost::noncopyable +class shape_file : mapnik::noncopyable { public: diff --git a/plugins/input/sqlite/sqlite_prepared.hpp b/plugins/input/sqlite/sqlite_prepared.hpp index f6bf45339..477759f5d 100644 --- a/plugins/input/sqlite/sqlite_prepared.hpp +++ b/plugins/input/sqlite/sqlite_prepared.hpp @@ -27,10 +27,10 @@ #include #include #include +#include // boost #include -#include // stl #include @@ -42,7 +42,7 @@ extern "C" { #include } -class prepared_index_statement : boost::noncopyable +class prepared_index_statement : mapnik::noncopyable { public: diff --git a/src/agg/process_line_pattern_symbolizer.cpp b/src/agg/process_line_pattern_symbolizer.cpp index 29ce388b7..e68e7d0ff 100644 --- a/src/agg/process_line_pattern_symbolizer.cpp +++ b/src/agg/process_line_pattern_symbolizer.cpp @@ -31,6 +31,7 @@ #include #include #include +#include // agg #include "agg_basics.h" @@ -47,12 +48,11 @@ #include "agg_conv_clip_polyline.h" // boost -#include #include namespace { -class pattern_source : private boost::noncopyable +class pattern_source : private mapnik::noncopyable { public: pattern_source(mapnik::image_data_32 const& pattern) diff --git a/src/cairo_renderer.cpp b/src/cairo_renderer.cpp index 1b9e90540..3701ec044 100644 --- a/src/cairo_renderer.cpp +++ b/src/cairo_renderer.cpp @@ -44,6 +44,7 @@ #include #include #include +#include // cairo #include @@ -52,7 +53,6 @@ #include // boost -#include #include #include @@ -72,7 +72,7 @@ namespace mapnik { -class cairo_pattern : private boost::noncopyable +class cairo_pattern : private mapnik::noncopyable { public: cairo_pattern(image_data_32 const& data) @@ -146,7 +146,7 @@ private: Cairo::RefPtr pattern_; }; -class cairo_gradient : private boost::noncopyable +class cairo_gradient : private mapnik::noncopyable { public: cairo_gradient(const mapnik::gradient &grad, double opacity=1.0) @@ -202,7 +202,7 @@ private: }; -class cairo_face : private boost::noncopyable +class cairo_face : private mapnik::noncopyable { public: cairo_face(boost::shared_ptr const& engine, face_ptr const& face) @@ -269,7 +269,7 @@ cairo_face_ptr cairo_face_manager::get_face(face_ptr face) return entry; } -class cairo_context : private boost::noncopyable +class cairo_context : private mapnik::noncopyable { public: cairo_context(Cairo::RefPtr const& context) diff --git a/src/jpeg_reader.cpp b/src/jpeg_reader.cpp index 47703651b..1b3eab6c1 100644 --- a/src/jpeg_reader.cpp +++ b/src/jpeg_reader.cpp @@ -23,6 +23,7 @@ // mapnik #include #include +#include // jpeg extern "C" @@ -32,14 +33,13 @@ extern "C" // boost #include -#include // std #include namespace mapnik { -class JpegReader : public image_reader, boost::noncopyable +class JpegReader : public image_reader, mapnik::noncopyable { private: std::string fileName_; diff --git a/src/libxml2_loader.cpp b/src/libxml2_loader.cpp index 90f6e5cc3..e4af0c66c 100644 --- a/src/libxml2_loader.cpp +++ b/src/libxml2_loader.cpp @@ -27,9 +27,9 @@ #include #include #include +#include // boost -#include #include // libxml @@ -42,7 +42,7 @@ namespace mapnik { -class libxml2_loader : boost::noncopyable +class libxml2_loader : mapnik::noncopyable { public: libxml2_loader(const char *encoding = NULL, int options = DEFAULT_OPTIONS, const char *url = NULL) : diff --git a/src/load_map.cpp b/src/load_map.cpp index 1f7efe210..5ab4a1f15 100644 --- a/src/load_map.cpp +++ b/src/load_map.cpp @@ -50,6 +50,7 @@ #include #include #include +#include // boost #include @@ -71,7 +72,7 @@ namespace mapnik { using boost::optional; -class map_parser : boost::noncopyable { +class map_parser : mapnik::noncopyable { public: map_parser(bool strict, std::string const& filename = "") : strict_(strict), diff --git a/src/png_reader.cpp b/src/png_reader.cpp index dde14ed70..1e542ce0b 100644 --- a/src/png_reader.cpp +++ b/src/png_reader.cpp @@ -22,6 +22,7 @@ #include #include +#include extern "C" { @@ -29,11 +30,10 @@ extern "C" } #include -#include namespace mapnik { -class png_reader : public image_reader, boost::noncopyable +class png_reader : public image_reader, mapnik::noncopyable { private: std::string fileName_; diff --git a/src/rapidxml_loader.cpp b/src/rapidxml_loader.cpp index 4c0898bee..a983b7c22 100644 --- a/src/rapidxml_loader.cpp +++ b/src/rapidxml_loader.cpp @@ -32,9 +32,7 @@ #include #include #include - -// boost -#include +#include // stl #include @@ -43,7 +41,7 @@ namespace rapidxml = boost::property_tree::detail::rapidxml; namespace mapnik { -class rapidxml_loader : boost::noncopyable +class rapidxml_loader : mapnik::noncopyable { public: rapidxml_loader(const char *encoding = NULL) : diff --git a/src/wkb.cpp b/src/wkb.cpp index 2e57b8600..dfef08a69 100644 --- a/src/wkb.cpp +++ b/src/wkb.cpp @@ -27,9 +27,9 @@ #include #include #include +#include // boost -#include #include namespace mapnik @@ -37,7 +37,7 @@ namespace mapnik typedef coord_array CoordinateArray; -struct wkb_reader : boost::noncopyable +struct wkb_reader : mapnik::noncopyable { private: enum wkbByteOrder { diff --git a/utils/pgsql2sqlite/sqlite.hpp b/utils/pgsql2sqlite/sqlite.hpp index e7ce0eb1b..1266a7604 100644 --- a/utils/pgsql2sqlite/sqlite.hpp +++ b/utils/pgsql2sqlite/sqlite.hpp @@ -20,10 +20,11 @@ * *****************************************************************************/ +#include // boost #include -#include #include + //sqlite3 #include @@ -36,7 +37,7 @@ namespace mapnik { namespace sqlite { - class database : private boost::noncopyable + class database : private mapnik::noncopyable { friend class prepared_statement; @@ -73,7 +74,7 @@ namespace mapnik { namespace sqlite { typedef boost::variant value_type; typedef std::vector record_type; - class prepared_statement : boost::noncopyable + class prepared_statement : mapnik::noncopyable { struct binder : public boost::static_visitor { From c5410fac7e937b9b29be17a9f1143718977553f8 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 17 Dec 2012 10:03:07 -0800 Subject: [PATCH 06/15] remove bind option for datasources - refs #962 --- bindings/python/mapnik_datasource.cpp | 12 +- bindings/python/mapnik_datasource_cache.cpp | 10 +- include/mapnik/datasource.hpp | 22 +--- include/mapnik/datasource_cache.hpp | 2 +- plugins/input/csv/csv_datasource.cpp | 53 +++----- plugins/input/csv/csv_datasource.hpp | 3 +- plugins/input/gdal/gdal_datasource.cpp | 39 ++---- plugins/input/gdal/gdal_datasource.hpp | 3 +- plugins/input/geojson/geojson_datasource.cpp | 38 ++---- plugins/input/geojson/geojson_datasource.hpp | 3 +- plugins/input/geos/geos_datasource.cpp | 54 +++----- plugins/input/geos/geos_datasource.hpp | 16 +-- plugins/input/kismet/kismet_datasource.cpp | 27 +--- plugins/input/kismet/kismet_datasource.hpp | 3 +- plugins/input/occi/occi_datasource.cpp | 124 +++++++----------- plugins/input/occi/occi_datasource.hpp | 4 +- plugins/input/ogr/ogr_datasource.cpp | 71 ++++------ plugins/input/ogr/ogr_datasource.hpp | 20 +-- plugins/input/osm/osm_datasource.cpp | 30 +---- plugins/input/osm/osm_datasource.hpp | 3 +- plugins/input/postgis/postgis_datasource.cpp | 94 ++++--------- plugins/input/postgis/postgis_datasource.hpp | 4 +- plugins/input/postgis/postgis_featureset.cpp | 2 +- plugins/input/python/python_datasource.cpp | 71 ++++------ plugins/input/python/python_datasource.hpp | 5 +- plugins/input/raster/raster_datasource.cpp | 42 +++--- plugins/input/raster/raster_datasource.hpp | 3 +- .../rasterlite/rasterlite_datasource.cpp | 19 +-- .../rasterlite/rasterlite_datasource.hpp | 3 +- plugins/input/shape/shape_datasource.cpp | 31 +---- plugins/input/shape/shape_datasource.hpp | 3 +- plugins/input/sqlite/sqlite_datasource.cpp | 70 ++++------ plugins/input/sqlite/sqlite_datasource.hpp | 6 +- .../templates/helloworld/hello_datasource.cpp | 23 +--- .../templates/helloworld/hello_datasource.hpp | 8 +- src/datasource_cache.cpp | 4 +- src/deepcopy.cpp | 3 +- 37 files changed, 293 insertions(+), 635 deletions(-) diff --git a/bindings/python/mapnik_datasource.cpp b/bindings/python/mapnik_datasource.cpp index 445c1b11f..651f030eb 100644 --- a/bindings/python/mapnik_datasource.cpp +++ b/bindings/python/mapnik_datasource.cpp @@ -50,24 +50,15 @@ namespace using namespace boost::python; boost::shared_ptr create_datasource(const dict& d) { - bool bind=true; mapnik::parameters params; boost::python::list keys=d.keys(); for (int i=0; i(keys[i]); object obj = d[key]; - - if (key == "bind") - { - bind = extract(obj)(); - continue; - } - extract ex0(obj); extract ex1(obj); extract ex2(obj); - if (ex0.check()) { params[key] = ex0(); @@ -82,7 +73,7 @@ boost::shared_ptr create_datasource(const dict& d) } } - return mapnik::datasource_cache::instance().create(params, bind); + return mapnik::datasource_cache::instance().create(params); } boost::python::dict describe(boost::shared_ptr const& ds) @@ -170,7 +161,6 @@ void export_datasource() .def("describe",&describe) .def("envelope",&datasource::envelope) .def("features",&datasource::features) - .def("bind",&datasource::bind) .def("fields",&fields) .def("field_types",&field_types) .def("features_at_point",&datasource::features_at_point, (arg("coord"),arg("tolerance")=0)) diff --git a/bindings/python/mapnik_datasource_cache.cpp b/bindings/python/mapnik_datasource_cache.cpp index db30d72c2..ad9c6c376 100644 --- a/bindings/python/mapnik_datasource_cache.cpp +++ b/bindings/python/mapnik_datasource_cache.cpp @@ -31,20 +31,12 @@ using namespace boost::python; boost::shared_ptr create_datasource(const dict& d) { - bool bind=true; mapnik::parameters params; boost::python::list keys=d.keys(); for (int i=0; i(keys[i]); object obj = d[key]; - - if (key == "bind") - { - bind = extract(obj)(); - continue; - } - extract ex0(obj); extract ex1(obj); extract ex2(obj); @@ -63,7 +55,7 @@ boost::shared_ptr create_datasource(const dict& d) } } - return mapnik::datasource_cache::instance().create(params, bind); + return mapnik::datasource_cache::instance().create(params); } void register_datasources(std::string const& path) diff --git a/include/mapnik/datasource.hpp b/include/mapnik/datasource.hpp index 014cc99e6..2693b0a2c 100644 --- a/include/mapnik/datasource.hpp +++ b/include/mapnik/datasource.hpp @@ -86,10 +86,7 @@ public: }; datasource (parameters const& params) - : params_(params), - is_bound_(false) - { - } + : params__(params) {} /*! * @brief Get the configuration parameters of the data source. @@ -100,7 +97,7 @@ public: */ parameters const& params() const { - return params_; + return params__; } /*! @@ -108,12 +105,6 @@ public: * @return The type of the datasource (Vector or Raster) */ virtual datasource_t type() const = 0; - - /*! - * @brief Connect to the datasource - */ - virtual void bind() const {} - virtual featureset_ptr features(query const& q) const = 0; virtual featureset_ptr features_at_point(coord2d const& pt, double tol = 0) const = 0; virtual box2d envelope() const = 0; @@ -121,12 +112,11 @@ public: virtual layer_descriptor get_descriptor() const = 0; virtual ~datasource() {} protected: - parameters params_; - mutable bool is_bound_; + parameters params__; }; typedef const char * datasource_name(); -typedef datasource* create_ds(parameters const& params, bool bind); +typedef datasource* create_ds(parameters const& params); typedef void destroy_ds(datasource *ds); class datasource_deleter @@ -145,9 +135,9 @@ typedef boost::shared_ptr datasource_ptr; { \ return classname::name(); \ } \ - extern "C" MAPNIK_EXP datasource* create(parameters const& params, bool bind) \ + extern "C" MAPNIK_EXP datasource* create(parameters const& params) \ { \ - return new classname(params, bind); \ + return new classname(params); \ } \ extern "C" MAPNIK_EXP void destroy(datasource *ds) \ { \ diff --git a/include/mapnik/datasource_cache.hpp b/include/mapnik/datasource_cache.hpp index 51cdfd415..ee8e3ad6d 100644 --- a/include/mapnik/datasource_cache.hpp +++ b/include/mapnik/datasource_cache.hpp @@ -48,7 +48,7 @@ public: std::string plugin_directories(); void register_datasources(std::string const& path); bool register_datasource(std::string const& path); - boost::shared_ptr create(parameters const& params, bool bind=true); + boost::shared_ptr create(parameters const& params); private: datasource_cache(); ~datasource_cache(); diff --git a/plugins/input/csv/csv_datasource.cpp b/plugins/input/csv/csv_datasource.cpp index 042c19448..4ce9b3f23 100644 --- a/plugins/input/csv/csv_datasource.cpp +++ b/plugins/input/csv/csv_datasource.cpp @@ -56,23 +56,23 @@ using namespace boost::spirit; DATASOURCE_PLUGIN(csv_datasource) -csv_datasource::csv_datasource(parameters const& params, bool bind) +csv_datasource::csv_datasource(parameters const& params) : datasource(params), - desc_(*params_.get("type"), *params_.get("encoding", "utf-8")), + desc_(*params.get("type"), *params.get("encoding", "utf-8")), extent_(), filename_(), inline_string_(), file_length_(0), - row_limit_(*params_.get("row_limit", 0)), + row_limit_(*params.get("row_limit", 0)), features_(), - escape_(*params_.get("escape", "")), - separator_(*params_.get("separator", "")), - quote_(*params_.get("quote", "")), + escape_(*params.get("escape", "")), + separator_(*params.get("separator", "")), + quote_(*params.get("quote", "")), headers_(), - manual_headers_(mapnik::util::trim_copy(*params_.get("headers", ""))), - strict_(*params_.get("strict", false)), - quiet_(*params_.get("quiet", false)), - filesize_max_(*params_.get("filesize_max", 20.0)), // MB + manual_headers_(mapnik::util::trim_copy(*params.get("headers", ""))), + strict_(*params.get("strict", false)), + quiet_(*params.get("quiet", false)), + filesize_max_(*params.get("filesize_max", 20.0)), // MB ctx_(boost::make_shared()) { /* TODO: @@ -97,36 +97,22 @@ csv_datasource::csv_datasource(parameters const& params, bool bind) http://boost-spirit.com/home/articles/qi-example/tracking-the-input-position-while-parsing/ */ - boost::optional inline_string = params_.get("inline"); + boost::optional inline_string = params.get("inline"); if (inline_string) { inline_string_ = *inline_string; } else { - boost::optional file = params_.get("file"); + boost::optional file = params.get("file"); if (!file) throw mapnik::datasource_exception("CSV Plugin: missing parameter"); - boost::optional base = params_.get("base"); + boost::optional base = params.get("base"); if (base) filename_ = *base + "/" + *file; else filename_ = *file; } - - if (bind) - { - this->bind(); - } -} - - -csv_datasource::~csv_datasource() { } - -void csv_datasource::bind() const -{ - if (is_bound_) return; - if (!inline_string_.empty()) { std::istringstream in(inline_string_); @@ -140,9 +126,11 @@ void csv_datasource::bind() const parse_csv(in,escape_, separator_, quote_); in.close(); } - is_bound_ = true; } + +csv_datasource::~csv_datasource() { } + template void csv_datasource::parse_csv(T & stream, std::string const& escape, @@ -890,14 +878,11 @@ datasource::datasource_t csv_datasource::type() const mapnik::box2d csv_datasource::envelope() const { - if (!is_bound_) bind(); - return extent_; } boost::optional csv_datasource::get_geometry_type() const { - if (! is_bound_) bind(); boost::optional result; int multi_type = 0; unsigned num_features = features_.size(); @@ -920,15 +905,11 @@ boost::optional csv_datasource::get_geometry_typ mapnik::layer_descriptor csv_datasource::get_descriptor() const { - if (!is_bound_) bind(); - return desc_; } mapnik::featureset_ptr csv_datasource::features(mapnik::query const& q) const { - if (!is_bound_) bind(); - const std::set& attribute_names = q.property_names(); std::set::const_iterator pos = attribute_names.begin(); while (pos != attribute_names.end()) @@ -958,7 +939,5 @@ mapnik::featureset_ptr csv_datasource::features(mapnik::query const& q) const mapnik::featureset_ptr csv_datasource::features_at_point(mapnik::coord2d const& pt, double tol) const { - if (!is_bound_) bind(); - throw mapnik::datasource_exception("CSV Plugin: features_at_point is not supported yet"); } diff --git a/plugins/input/csv/csv_datasource.hpp b/plugins/input/csv/csv_datasource.hpp index 991a005a1..fb8b21666 100644 --- a/plugins/input/csv/csv_datasource.hpp +++ b/plugins/input/csv/csv_datasource.hpp @@ -42,7 +42,7 @@ class csv_datasource : public mapnik::datasource { public: - csv_datasource(mapnik::parameters const& params, bool bind=true); + csv_datasource(mapnik::parameters const& params); virtual ~csv_datasource (); mapnik::datasource::datasource_t type() const; static const char * name(); @@ -51,7 +51,6 @@ public: mapnik::box2d envelope() const; boost::optional get_geometry_type() const; mapnik::layer_descriptor get_descriptor() const; - void bind() const; template void parse_csv(T & stream, diff --git a/plugins/input/gdal/gdal_datasource.cpp b/plugins/input/gdal/gdal_datasource.cpp index 3a7ea2122..69d49a229 100644 --- a/plugins/input/gdal/gdal_datasource.cpp +++ b/plugins/input/gdal/gdal_datasource.cpp @@ -73,20 +73,24 @@ inline GDALDataset* gdal_datasource::open_dataset() const } -gdal_datasource::gdal_datasource(parameters const& params, bool bind) +gdal_datasource::gdal_datasource(parameters const& params) : datasource(params), desc_(*params.get("type"), "utf-8"), - filter_factor_(*params_.get("filter_factor", 0.0)), - nodata_value_(params_.get("nodata")) + filter_factor_(*params.get("filter_factor", 0.0)), + nodata_value_(params.get("nodata")) { MAPNIK_LOG_DEBUG(gdal) << "gdal_datasource: Initializing..."; +#ifdef MAPNIK_STATS + mapnik::progress_timer __stats__(std::clog, "gdal_datasource::init"); +#endif + GDALAllRegister(); boost::optional file = params.get("file"); if (! file) throw datasource_exception("missing parameter"); - boost::optional base = params_.get("base"); + boost::optional base = params.get("base"); if (base) { dataset_name_ = *base + "/" + *file; @@ -96,22 +100,8 @@ gdal_datasource::gdal_datasource(parameters const& params, bool bind) dataset_name_ = *file; } - if (bind) - { - this->bind(); - } -} - -void gdal_datasource::bind() const -{ - if (is_bound_) return; - -#ifdef MAPNIK_STATS - mapnik::progress_timer __stats__(std::clog, "gdal_datasource::bind"); -#endif - - shared_dataset_ = *params_.get("shared", false); - band_ = *params_.get("band", -1); + shared_dataset_ = *params.get("shared", false); + band_ = *params.get("band", -1); GDALDataset *dataset = open_dataset(); @@ -121,7 +111,7 @@ void gdal_datasource::bind() const double tr[6]; bool bbox_override = false; - boost::optional bbox_s = params_.get("extent"); + boost::optional bbox_s = params.get("extent"); if (bbox_s) { MAPNIK_LOG_DEBUG(gdal) << "gdal_datasource: BBox Parameter=" << *bbox_s; @@ -188,7 +178,6 @@ void gdal_datasource::bind() const MAPNIK_LOG_DEBUG(gdal) << "gdal_datasource: Raster Size=" << width_ << "," << height_; MAPNIK_LOG_DEBUG(gdal) << "gdal_datasource: Raster Extent=" << extent_; - is_bound_ = true; } gdal_datasource::~gdal_datasource() @@ -207,8 +196,6 @@ const char * gdal_datasource::name() box2d gdal_datasource::envelope() const { - if (! is_bound_) bind(); - return extent_; } @@ -224,8 +211,6 @@ layer_descriptor gdal_datasource::get_descriptor() const featureset_ptr gdal_datasource::features(query const& q) const { - if (! is_bound_) bind(); - #ifdef MAPNIK_STATS mapnik::progress_timer __stats__(std::clog, "gdal_datasource::features"); #endif @@ -248,8 +233,6 @@ featureset_ptr gdal_datasource::features(query const& q) const featureset_ptr gdal_datasource::features_at_point(coord2d const& pt, double tol) const { - if (! is_bound_) bind(); - #ifdef MAPNIK_STATS mapnik::progress_timer __stats__(std::clog, "gdal_datasource::features_at_point"); #endif diff --git a/plugins/input/gdal/gdal_datasource.hpp b/plugins/input/gdal/gdal_datasource.hpp index 1152c5849..2032f0194 100644 --- a/plugins/input/gdal/gdal_datasource.hpp +++ b/plugins/input/gdal/gdal_datasource.hpp @@ -45,7 +45,7 @@ class gdal_datasource : public mapnik::datasource { public: - gdal_datasource(mapnik::parameters const& params, bool bind = true); + gdal_datasource(mapnik::parameters const& params); virtual ~gdal_datasource(); mapnik::datasource::datasource_t type() const; static const char * name(); @@ -54,7 +54,6 @@ public: mapnik::box2d envelope() const; boost::optional get_geometry_type() const; mapnik::layer_descriptor get_descriptor() const; - void bind() const; private: GDALDataset* open_dataset() const; mutable mapnik::box2d extent_; diff --git a/plugins/input/geojson/geojson_datasource.cpp b/plugins/input/geojson/geojson_datasource.cpp index 60f63b0b7..ea60b69d0 100644 --- a/plugins/input/geojson/geojson_datasource.cpp +++ b/plugins/input/geojson/geojson_datasource.cpp @@ -49,24 +49,6 @@ using mapnik::parameters; DATASOURCE_PLUGIN(geojson_datasource) -geojson_datasource::geojson_datasource(parameters const& params, bool bind) -: datasource(params), - type_(datasource::Vector), - desc_(*params_.get("type"), - *params_.get("encoding","utf-8")), - file_(*params_.get("file","")), - extent_(), - tr_(new mapnik::transcoder(*params_.get("encoding","utf-8"))), - features_(), - tree_(16,1) -{ - if (file_.empty()) throw mapnik::datasource_exception("GeoJSON Plugin: missing parameter"); - if (bind) - { - this->bind(); - } -} - struct attr_value_converter : public boost::static_visitor { mapnik::eAttributeType operator() (int /*val*/) const @@ -105,9 +87,18 @@ struct attr_value_converter : public boost::static_visitor("type"), + *params.get("encoding","utf-8")), + file_(*params.get("file","")), + extent_(), + tr_(new mapnik::transcoder(*params.get("encoding","utf-8"))), + features_(), + tree_(16,1) { - if (is_bound_) return; + if (file_.empty()) throw mapnik::datasource_exception("GeoJSON Plugin: missing parameter"); typedef std::istreambuf_iterator base_iterator_type; @@ -149,7 +140,6 @@ void geojson_datasource::bind() const } tree_.insert(box_type(point_type(box.minx(),box.miny()),point_type(box.maxx(),box.maxy())), count++); } - is_bound_ = true; } geojson_datasource::~geojson_datasource() { } @@ -188,21 +178,16 @@ mapnik::datasource::datasource_t geojson_datasource::type() const mapnik::box2d geojson_datasource::envelope() const { - if (!is_bound_) bind(); return extent_; } mapnik::layer_descriptor geojson_datasource::get_descriptor() const { - if (!is_bound_) bind(); - return desc_; } mapnik::featureset_ptr geojson_datasource::features(mapnik::query const& q) const { - if (!is_bound_) bind(); - // if the query box intersects our world extent then query for features mapnik::box2d const& b = q.get_bbox(); if (extent_.intersects(b)) @@ -218,7 +203,6 @@ mapnik::featureset_ptr geojson_datasource::features(mapnik::query const& q) cons // FIXME mapnik::featureset_ptr geojson_datasource::features_at_point(mapnik::coord2d const& pt, double tol) const { - if (!is_bound_) bind(); throw mapnik::datasource_exception("GeoJSON Plugin: features_at_point is not supported yet"); return mapnik::featureset_ptr(); } diff --git a/plugins/input/geojson/geojson_datasource.hpp b/plugins/input/geojson/geojson_datasource.hpp index e3d0e491c..41537868d 100644 --- a/plugins/input/geojson/geojson_datasource.hpp +++ b/plugins/input/geojson/geojson_datasource.hpp @@ -55,7 +55,7 @@ public: typedef boost::geometry::index::rtree spatial_index_type; // constructor - geojson_datasource(mapnik::parameters const& params, bool bind=true); + geojson_datasource(mapnik::parameters const& params); virtual ~geojson_datasource (); mapnik::datasource::datasource_t type() const; static const char * name(); @@ -64,7 +64,6 @@ public: mapnik::box2d envelope() const; mapnik::layer_descriptor get_descriptor() const; boost::optional get_geometry_type() const; - void bind() const; private: mapnik::datasource::datasource_t type_; mutable std::map statistics_; diff --git a/plugins/input/geos/geos_datasource.cpp b/plugins/input/geos/geos_datasource.cpp index 9e24bf968..9e44d7e7d 100644 --- a/plugins/input/geos/geos_datasource.cpp +++ b/plugins/input/geos/geos_datasource.cpp @@ -85,7 +85,7 @@ void geos_error(const char* format, ...) } -geos_datasource::geos_datasource(parameters const& params, bool bind) +geos_datasource::geos_datasource(parameters const& params) : datasource(params), extent_(), extent_initialized_(false), @@ -99,42 +99,22 @@ geos_datasource::geos_datasource(parameters const& params, bool bind) if (! geometry) throw datasource_exception("missing parameter"); geometry_string_ = *geometry; - boost::optional ext = params_.get("extent"); + boost::optional ext = params.get("extent"); if (ext) extent_initialized_ = extent_.from_string(*ext); - boost::optional id = params_.get("gid"); + boost::optional id = params.get("gid"); if (id) geometry_id_ = *id; - boost::optional gdata = params_.get("field_data"); + boost::optional gdata = params.get("field_data"); if (gdata) geometry_data_ = *gdata; - boost::optional gdata_name = params_.get("field_name"); + boost::optional gdata_name = params.get("field_name"); if (gdata_name) geometry_data_name_ = *gdata_name; desc_.add_descriptor(attribute_descriptor(geometry_data_name_, mapnik::String)); - if (bind) - { - this->bind(); - } -} - -geos_datasource::~geos_datasource() -{ - if (is_bound_) - { - geometry_.set_feature(0); - - finishGEOS(); - } -} - -void geos_datasource::bind() const -{ - if (is_bound_) return; - #ifdef MAPNIK_STATS - mapnik::progress_timer __stats__(std::clog, "geos_datasource::bind"); + mapnik::progress_timer __stats__(std::clog, "geos_datasource::init"); #endif // open geos driver @@ -151,7 +131,7 @@ void geos_datasource::bind() const if (! extent_initialized_) { #ifdef MAPNIK_STATS - mapnik::progress_timer __stats2__(std::clog, "geos_datasource::bind(initialize_extent)"); + mapnik::progress_timer __stats2__(std::clog, "geos_datasource::init(initialize_extent)"); #endif MAPNIK_LOG_DEBUG(geos) << "geos_datasource: Initializing extent from geometry"; @@ -222,9 +202,18 @@ void geos_datasource::bind() const throw datasource_exception("GEOS Plugin: cannot determine extent for geometry"); } - is_bound_ = true; } +geos_datasource::~geos_datasource() +{ + { + geometry_.set_feature(0); + + finishGEOS(); + } +} + + const char * geos_datasource::name() { return "geos"; @@ -237,14 +226,11 @@ mapnik::datasource::datasource_t geos_datasource::type() const box2d geos_datasource::envelope() const { - if (! is_bound_) bind(); - return extent_; } boost::optional geos_datasource::get_geometry_type() const { - if (! is_bound_) bind(); boost::optional result; #ifdef MAPNIK_STATS @@ -280,15 +266,11 @@ boost::optional geos_datasource::get_geometry_ty layer_descriptor geos_datasource::get_descriptor() const { - if (! is_bound_) bind(); - return desc_; } featureset_ptr geos_datasource::features(query const& q) const { - if (! is_bound_) bind(); - #ifdef MAPNIK_STATS mapnik::progress_timer __stats__(std::clog, "geos_datasource::features"); #endif @@ -316,8 +298,6 @@ featureset_ptr geos_datasource::features(query const& q) const featureset_ptr geos_datasource::features_at_point(coord2d const& pt, double tol) const { - if (! is_bound_) bind(); - #ifdef MAPNIK_STATS mapnik::progress_timer __stats__(std::clog, "geos_datasource::features_at_point"); #endif diff --git a/plugins/input/geos/geos_datasource.hpp b/plugins/input/geos/geos_datasource.hpp index 463ed497f..35bb813ec 100644 --- a/plugins/input/geos/geos_datasource.hpp +++ b/plugins/input/geos/geos_datasource.hpp @@ -45,7 +45,7 @@ class geos_datasource : public mapnik::datasource { public: - geos_datasource(mapnik::parameters const& params, bool bind = true); + geos_datasource(mapnik::parameters const& params); virtual ~geos_datasource (); mapnik::datasource::datasource_t type() const; static const char * name(); @@ -54,17 +54,17 @@ public: mapnik::box2d envelope() const; boost::optional get_geometry_type() const; mapnik::layer_descriptor get_descriptor() const; - void bind() const; private: - mutable mapnik::box2d extent_; - mutable bool extent_initialized_; + void init(mapnik::parameters const& params); + mapnik::box2d extent_; + bool extent_initialized_; mapnik::datasource::datasource_t type_; - mutable mapnik::layer_descriptor desc_; + mapnik::layer_descriptor desc_; mutable geos_feature_ptr geometry_; - mutable std::string geometry_data_; - mutable std::string geometry_data_name_; - mutable int geometry_id_; + std::string geometry_data_; + std::string geometry_data_name_; + int geometry_id_; std::string geometry_string_; }; diff --git a/plugins/input/kismet/kismet_datasource.cpp b/plugins/input/kismet/kismet_datasource.cpp index cfd149ed7..209bd9a20 100644 --- a/plugins/input/kismet/kismet_datasource.cpp +++ b/plugins/input/kismet/kismet_datasource.cpp @@ -67,7 +67,7 @@ boost::mutex knd_list_mutex; std::list knd_list; const unsigned int queue_size = 20; -kismet_datasource::kismet_datasource(parameters const& params, bool bind) +kismet_datasource::kismet_datasource(parameters const& params) : datasource(params), extent_(), extent_initialized_(false), @@ -75,7 +75,7 @@ kismet_datasource::kismet_datasource(parameters const& params, bool bind) srs_("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"), desc_(*params.get("type"), *params.get("encoding","utf-8")) { - boost::optional host = params_.get("host"); + boost::optional host = params.get("host"); if (host) { host_ = *host; @@ -85,37 +85,25 @@ kismet_datasource::kismet_datasource(parameters const& params, bool bind) throw datasource_exception("Kismet Plugin: missing parameter"); } - boost::optional port = params_.get("port", 2501); + boost::optional port = params.get("port", 2501); if (port) { port_ = *port; } - boost::optional srs = params_.get("srs"); + boost::optional srs = params.get("srs"); if (srs) { srs_ = *srs; } - boost::optional ext = params_.get("extent"); + boost::optional ext = params.get("extent"); if (ext) { extent_initialized_ = extent_.from_string(*ext); } kismet_thread.reset(new boost::thread(boost::bind(&kismet_datasource::run, this, host_, port_))); - - if (bind) - { - this->bind(); - } -} - -void kismet_datasource::bind() const -{ - if (is_bound_) return; - - is_bound_ = true; } kismet_datasource::~kismet_datasource() @@ -134,7 +122,6 @@ mapnik::datasource::datasource_t kismet_datasource::type() const box2d kismet_datasource::envelope() const { - if (! is_bound_) bind(); return extent_; } @@ -150,8 +137,6 @@ layer_descriptor kismet_datasource::get_descriptor() const featureset_ptr kismet_datasource::features(query const& q) const { - if (! is_bound_) bind(); - MAPNIK_LOG_DEBUG(kismet) << "kismet_datasource::features()"; // TODO: use box2d to filter bbox before adding to featureset_ptr @@ -168,8 +153,6 @@ featureset_ptr kismet_datasource::features(query const& q) const featureset_ptr kismet_datasource::features_at_point(coord2d const& pt, double tol) const { - if (! is_bound_) bind(); - MAPNIK_LOG_DEBUG(kismet) << "kismet_datasource::features_at_point()"; return featureset_ptr(); diff --git a/plugins/input/kismet/kismet_datasource.hpp b/plugins/input/kismet/kismet_datasource.hpp index 28d3c335b..c1d727830 100644 --- a/plugins/input/kismet/kismet_datasource.hpp +++ b/plugins/input/kismet/kismet_datasource.hpp @@ -47,7 +47,7 @@ class kismet_datasource : public mapnik::datasource { public: - kismet_datasource(mapnik::parameters const& params, bool bind = true); + kismet_datasource(mapnik::parameters const& params); virtual ~kismet_datasource (); datasource::datasource_t type() const; static const char * name(); @@ -56,7 +56,6 @@ public: mapnik::box2d envelope() const; boost::optional get_geometry_type() const; mapnik::layer_descriptor get_descriptor() const; - void bind() const; private: void run (std::string const& host, const unsigned int port); diff --git a/plugins/input/occi/occi_datasource.cpp b/plugins/input/occi/occi_datasource.cpp index 8f23675ae..93d01c725 100644 --- a/plugins/input/occi/occi_datasource.cpp +++ b/plugins/input/occi/occi_datasource.cpp @@ -68,25 +68,29 @@ const std::string occi_datasource::METADATA_TABLE = "USER_SDO_GEOM_METADATA"; DATASOURCE_PLUGIN(occi_datasource) -occi_datasource::occi_datasource(parameters const& params, bool bind) +occi_datasource::occi_datasource(parameters const& params) : datasource (params), type_(datasource::Vector), - fields_(*params_.get("fields", "*")), - geometry_field_(*params_.get("geometry_field", "")), + fields_(*params.get("fields", "*")), + geometry_field_(*params.get("geometry_field", "")), srid_initialized_(false), extent_initialized_(false), - desc_(*params_.get("type"), *params_.get("encoding", "utf-8")), - use_wkb_(*params_.get("use_wkb", false)), - row_limit_(*params_.get("row_limit", 0)), - row_prefetch_(*params_.get("row_prefetch", 100)), + desc_(*params.get("type"), *params.get("encoding", "utf-8")), + use_wkb_(*params.get("use_wkb", false)), + row_limit_(*params.get("row_limit", 0)), + row_prefetch_(*params.get("row_prefetch", 100)), pool_(0), conn_(0) { - if (! params_.get("user")) throw datasource_exception("OCCI Plugin: no specified"); - if (! params_.get("password")) throw datasource_exception("OCCI Plugin: no specified"); - if (! params_.get("host")) throw datasource_exception("OCCI Plugin: no string specified"); +#ifdef MAPNIK_STATS + mapnik::progress_timer __stats__(std::clog, "occi_datasource::init"); +#endif - boost::optional table = params_.get("table"); + if (! params.get("user")) throw datasource_exception("OCCI Plugin: no specified"); + if (! params.get("password")) throw datasource_exception("OCCI Plugin: no specified"); + if (! params.get("host")) throw datasource_exception("OCCI Plugin: no string specified"); + + boost::optional table = params.get("table"); if (! table) { throw datasource_exception("OCCI Plugin: no parameter specified"); @@ -95,57 +99,20 @@ occi_datasource::occi_datasource(parameters const& params, bool bind) { table_ = *table; } + estimate_extent_ = *params.get("estimate_extent",false); + use_spatial_index_ = *params.get("use_spatial_index",true); + use_connection_pool_ = *params.get("use_connection_pool",true); - use_spatial_index_ = *params_.get("use_spatial_index",true); - use_connection_pool_ = *params_.get("use_connection_pool",true); - - boost::optional ext = params_.get("extent"); + boost::optional ext = params.get("extent"); if (ext) extent_initialized_ = extent_.from_string(*ext); - boost::optional srid = params_.get("srid"); + boost::optional srid = params.get("srid"); if (srid) { srid_ = *srid; srid_initialized_ = true; } - if (bind) - { - this->bind(); - } -} - -occi_datasource::~occi_datasource() -{ - if (is_bound_) - { - Environment* env = occi_environment::get_environment(); - - if (use_connection_pool_) - { - if (pool_ != 0) - { - env->terminateStatelessConnectionPool(pool_, StatelessConnectionPool::SPD_FORCE); - } - } - else - { - if (conn_ != 0) - { - env->terminateConnection(conn_); - } - } - } -} - -void occi_datasource::bind() const -{ - if (is_bound_) return; - -#ifdef MAPNIK_STATS - mapnik::progress_timer __stats__(std::clog, "occi_datasource::bind"); -#endif - // connect to environment if (use_connection_pool_) { @@ -154,11 +121,11 @@ void occi_datasource::bind() const Environment* env = occi_environment::get_environment(); pool_ = env->createStatelessConnectionPool( - *params_.get("user"), - *params_.get("password"), - *params_.get("host"), - *params_.get("max_size", 5), - *params_.get("initial_size", 1), + *params.get("user"), + *params.get("password"), + *params.get("host"), + *params.get("max_size", 5), + *params.get("initial_size", 1), 1, StatelessConnectionPool::HOMOGENEOUS); } @@ -174,9 +141,9 @@ void occi_datasource::bind() const Environment* env = occi_environment::get_environment(); conn_ = env->createConnection( - *params_.get("user"), - *params_.get("password"), - *params_.get("host")); + *params.get("user"), + *params.get("password"), + *params.get("host")); } catch (SQLException& ex) { @@ -348,8 +315,28 @@ void occi_datasource::bind() const throw datasource_exception(ex.getMessage()); } } +} - is_bound_ = true; +occi_datasource::~occi_datasource() +{ + { + Environment* env = occi_environment::get_environment(); + + if (use_connection_pool_) + { + if (pool_ != 0) + { + env->terminateStatelessConnectionPool(pool_, StatelessConnectionPool::SPD_FORCE); + } + } + else + { + if (conn_ != 0) + { + env->terminateConnection(conn_); + } + } + } } const char * occi_datasource::name() @@ -365,14 +352,11 @@ mapnik::datasource::datasource_t occi_datasource::type() const box2d occi_datasource::envelope() const { if (extent_initialized_) return extent_; - if (! is_bound_) bind(); double lox = 0.0, loy = 0.0, hix = 0.0, hiy = 0.0; - boost::optional estimate_extent = - params_.get("estimate_extent",false); - if (estimate_extent && *estimate_extent) + if (estimate_extent_) { #ifdef MAPNIK_STATS mapnik::progress_timer __stats__(std::clog, "occi_datasource::envelope(estimate_extent)"); @@ -487,22 +471,16 @@ box2d occi_datasource::envelope() const boost::optional occi_datasource::get_geometry_type() const { - // FIXME - //if (! is_bound_) bind(); return boost::optional(); } layer_descriptor occi_datasource::get_descriptor() const { - if (! is_bound_) bind(); - return desc_; } featureset_ptr occi_datasource::features(query const& q) const { - if (! is_bound_) bind(); - #ifdef MAPNIK_STATS mapnik::progress_timer __stats__(std::clog, "occi_datasource::features"); #endif @@ -592,8 +570,6 @@ featureset_ptr occi_datasource::features(query const& q) const featureset_ptr occi_datasource::features_at_point(coord2d const& pt, double tol) const { - if (! is_bound_) bind(); - #ifdef MAPNIK_STATS mapnik::progress_timer __stats__(std::clog, "occi_datasource::features_at_point"); #endif diff --git a/plugins/input/occi/occi_datasource.hpp b/plugins/input/occi/occi_datasource.hpp index 4d0d2ba22..76c8288f3 100644 --- a/plugins/input/occi/occi_datasource.hpp +++ b/plugins/input/occi/occi_datasource.hpp @@ -46,7 +46,7 @@ class occi_datasource : public mapnik::datasource { public: - occi_datasource(mapnik::parameters const& params, bool bind = true); + occi_datasource(mapnik::parameters const& params); virtual ~occi_datasource (); mapnik::datasource::datasource_t type() const; static const char * name(); @@ -55,7 +55,6 @@ public: mapnik::box2d envelope() const; boost::optional get_geometry_type() const; mapnik::layer_descriptor get_descriptor() const; - void bind() const; private: static const std::string METADATA_TABLE; @@ -77,6 +76,7 @@ private: mutable oracle::occi::Connection* conn_; bool use_connection_pool_; bool use_spatial_index_; + bool estimate_extent_; }; #endif // OCCI_DATASOURCE_HPP diff --git a/plugins/input/ogr/ogr_datasource.cpp b/plugins/input/ogr/ogr_datasource.cpp index 1125f9091..ca6602b6b 100644 --- a/plugins/input/ogr/ogr_datasource.cpp +++ b/plugins/input/ogr/ogr_datasource.cpp @@ -57,13 +57,32 @@ using mapnik::filter_in_box; using mapnik::filter_at_point; -ogr_datasource::ogr_datasource(parameters const& params, bool bind) +ogr_datasource::ogr_datasource(parameters const& params) : datasource(params), extent_(), type_(datasource::Vector), - desc_(*params_.get("type"), *params_.get("encoding", "utf-8")), + desc_(*params.get("type"), *params.get("encoding", "utf-8")), indexed_(false) { + init(params); +} + +ogr_datasource::~ogr_datasource() +{ + // free layer before destroying the datasource + layer_.free_layer(); + OGRDataSource::DestroyDataSource (dataset_); +} + +void ogr_datasource::init(mapnik::parameters const& params) +{ +#ifdef MAPNIK_STATS + mapnik::progress_timer __stats__(std::clog, "ogr_datasource::init"); +#endif + + // initialize ogr formats + OGRRegisterAll(); + boost::optional file = params.get("file"); boost::optional string = params.get("string"); if (! file && ! string) @@ -88,35 +107,7 @@ ogr_datasource::ogr_datasource(parameters const& params, bool bind) } } - if (bind) - { - this->bind(); - } -} - -ogr_datasource::~ogr_datasource() -{ - if (is_bound_) - { - // free layer before destroying the datasource - layer_.free_layer(); - - OGRDataSource::DestroyDataSource (dataset_); - } -} - -void ogr_datasource::bind() const -{ - if (is_bound_) return; - -#ifdef MAPNIK_STATS - mapnik::progress_timer __stats__(std::clog, "ogr_datasource::bind"); -#endif - - // initialize ogr formats - OGRRegisterAll(); - - std::string driver = *params_.get("driver",""); + std::string driver = *params.get("driver",""); if (! driver.empty()) { @@ -147,9 +138,9 @@ void ogr_datasource::bind() const } // initialize layer - boost::optional layer_by_name = params_.get("layer"); - boost::optional layer_by_index = params_.get("layer_by_index"); - boost::optional layer_by_sql = params_.get("layer_by_sql"); + boost::optional layer_by_name = params.get("layer"); + boost::optional layer_by_index = params.get("layer_by_index"); + boost::optional layer_by_sql = params.get("layer_by_sql"); int passed_parameters = 0; passed_parameters += layer_by_name ? 1 : 0; @@ -185,7 +176,7 @@ void ogr_datasource::bind() const else if (layer_by_sql) { #ifdef MAPNIK_STATS - mapnik::progress_timer __stats_sql__(std::clog, "ogr_datasource::bind(layer_by_sql)"); + mapnik::progress_timer __stats_sql__(std::clog, "ogr_datasource::init(layer_by_sql)"); #endif layer_.layer_by_sql(dataset_, *layer_by_sql); @@ -278,7 +269,7 @@ void ogr_datasource::bind() const #endif #ifdef MAPNIK_STATS - mapnik::progress_timer __stats2__(std::clog, "ogr_datasource::bind(get_column_description)"); + mapnik::progress_timer __stats2__(std::clog, "ogr_datasource::init(get_column_description)"); #endif // deal with attributes descriptions @@ -328,8 +319,6 @@ void ogr_datasource::bind() const } } } - - is_bound_ = true; } const char * ogr_datasource::name() @@ -344,7 +333,6 @@ mapnik::datasource::datasource_t ogr_datasource::type() const box2d ogr_datasource::envelope() const { - if (! is_bound_) bind(); return extent_; } @@ -432,7 +420,6 @@ boost::optional ogr_datasource::get_geometry_typ layer_descriptor ogr_datasource::get_descriptor() const { - if (! is_bound_) bind(); return desc_; } @@ -475,8 +462,6 @@ void validate_attribute_names(query const& q, std::vector featureset_ptr ogr_datasource::features(query const& q) const { - if (! is_bound_) bind(); - #ifdef MAPNIK_STATS mapnik::progress_timer __stats__(std::clog, "ogr_datasource::features"); #endif @@ -522,8 +507,6 @@ featureset_ptr ogr_datasource::features(query const& q) const featureset_ptr ogr_datasource::features_at_point(coord2d const& pt, double tol) const { - if (!is_bound_) bind(); - #ifdef MAPNIK_STATS mapnik::progress_timer __stats__(std::clog, "ogr_datasource::features_at_point"); #endif diff --git a/plugins/input/ogr/ogr_datasource.hpp b/plugins/input/ogr/ogr_datasource.hpp index 3b383f053..ebff6c548 100644 --- a/plugins/input/ogr/ogr_datasource.hpp +++ b/plugins/input/ogr/ogr_datasource.hpp @@ -47,7 +47,7 @@ class ogr_datasource : public mapnik::datasource { public: - ogr_datasource(mapnik::parameters const& params, bool bind=true); + ogr_datasource(mapnik::parameters const& params); virtual ~ogr_datasource (); mapnik::datasource::datasource_t type() const; static const char * name(); @@ -56,18 +56,18 @@ public: mapnik::box2d envelope() const; boost::optional get_geometry_type() const; mapnik::layer_descriptor get_descriptor() const; - void bind() const; - + private: - mutable mapnik::box2d extent_; + void init(mapnik::parameters const& params); + mapnik::box2d extent_; mapnik::datasource::datasource_t type_; std::string dataset_name_; - mutable std::string index_name_; - mutable OGRDataSource* dataset_; - mutable ogr_layer_ptr layer_; - mutable std::string layer_name_; - mutable mapnik::layer_descriptor desc_; - mutable bool indexed_; + std::string index_name_; + OGRDataSource* dataset_; + ogr_layer_ptr layer_; + std::string layer_name_; + mapnik::layer_descriptor desc_; + bool indexed_; }; #endif // OGR_DATASOURCE_HPP diff --git a/plugins/input/osm/osm_datasource.cpp b/plugins/input/osm/osm_datasource.cpp index b2ba7ff5b..0a18b4975 100644 --- a/plugins/input/osm/osm_datasource.cpp +++ b/plugins/input/osm/osm_datasource.cpp @@ -49,28 +49,17 @@ using mapnik::attribute_descriptor; DATASOURCE_PLUGIN(osm_datasource) -osm_datasource::osm_datasource(const parameters& params, bool bind) +osm_datasource::osm_datasource(const parameters& params) : datasource (params), extent_(), type_(datasource::Vector), - desc_(*params_.get("type"), *params_.get("encoding", "utf-8")) + desc_(*params.get("type"), *params.get("encoding", "utf-8")) { - if (bind) - { - this->bind(); - } -} - -void osm_datasource::bind() const -{ - if (is_bound_) return; - osm_data_ = NULL; - std::string osm_filename = *params_.get("file", ""); - std::string parser = *params_.get("parser", "libxml2"); - std::string url = *params_.get("url", ""); - std::string bbox = *params_.get("bbox", ""); - + std::string osm_filename = *params.get("file", ""); + std::string parser = *params.get("parser", "libxml2"); + std::string url = *params.get("url", ""); + std::string bbox = *params.get("bbox", ""); // load the data if (url != "" && bbox != "") @@ -118,7 +107,6 @@ void osm_datasource::bind() const // Get the bounds of the data and set extent_ accordingly bounds b = osm_data_->get_bounds(); extent_ = box2d(b.w, b.s, b.e, b.n); - is_bound_ = true; } osm_datasource::~osm_datasource() @@ -144,8 +132,6 @@ layer_descriptor osm_datasource::get_descriptor() const featureset_ptr osm_datasource::features(const query& q) const { - if (!is_bound_) bind(); - filter_in_box filter(q.get_bbox()); // so we need to filter osm features by bbox here... @@ -157,8 +143,6 @@ featureset_ptr osm_datasource::features(const query& q) const featureset_ptr osm_datasource::features_at_point(coord2d const& pt, double tol) const { - if (!is_bound_) bind(); - filter_at_point filter(pt); // collect all attribute names std::vector const& desc_vector = desc_.get_descriptors(); @@ -180,12 +164,10 @@ featureset_ptr osm_datasource::features_at_point(coord2d const& pt, double tol) box2d osm_datasource::envelope() const { - if (!is_bound_) bind(); return extent_; } boost::optional osm_datasource::get_geometry_type() const { - if (! is_bound_) bind(); return boost::optional(mapnik::datasource::Collection); } diff --git a/plugins/input/osm/osm_datasource.hpp b/plugins/input/osm/osm_datasource.hpp index 2ef8b5841..4b7d60fa3 100644 --- a/plugins/input/osm/osm_datasource.hpp +++ b/plugins/input/osm/osm_datasource.hpp @@ -53,7 +53,7 @@ using mapnik::box2d; class osm_datasource : public datasource { public: - osm_datasource(const parameters& params, bool bind = true); + osm_datasource(const parameters& params); virtual ~osm_datasource(); mapnik::datasource::datasource_t type() const; static const char * name(); @@ -62,7 +62,6 @@ public: box2d envelope() const; boost::optional get_geometry_type() const; layer_descriptor get_descriptor() const; - void bind() const; private: mutable box2d extent_; diff --git a/plugins/input/postgis/postgis_datasource.cpp b/plugins/input/postgis/postgis_datasource.cpp index 30719541b..2d78ea093 100644 --- a/plugins/input/postgis/postgis_datasource.cpp +++ b/plugins/input/postgis/postgis_datasource.cpp @@ -55,20 +55,20 @@ using boost::shared_ptr; using mapnik::PoolGuard; using mapnik::attribute_descriptor; -postgis_datasource::postgis_datasource(parameters const& params, bool bind) +postgis_datasource::postgis_datasource(parameters const& params) : datasource(params), - table_(*params_.get("table", "")), + table_(*params.get("table", "")), schema_(""), - geometry_table_(*params_.get("geometry_table", "")), - geometry_field_(*params_.get("geometry_field", "")), - key_field_(*params_.get("key_field", "")), - cursor_fetch_size_(*params_.get("cursor_size", 0)), - row_limit_(*params_.get("row_limit", 0)), + geometry_table_(*params.get("geometry_table", "")), + geometry_field_(*params.get("geometry_field", "")), + key_field_(*params.get("key_field", "")), + cursor_fetch_size_(*params.get("cursor_size", 0)), + row_limit_(*params.get("row_limit", 0)), type_(datasource::Vector), - srid_(*params_.get("srid", 0)), + srid_(*params.get("srid", 0)), extent_initialized_(false), simplify_geometries_(false), - desc_(*params_.get("type"), "utf-8"), + desc_(*params.get("type"), "utf-8"), creator_(params.get("host"), params.get("port"), params.get("dbname"), @@ -79,45 +79,32 @@ postgis_datasource::postgis_datasource(parameters const& params, bool bind) scale_denom_token_("!scale_denominator!"), pixel_width_token_("!pixel_width!"), pixel_height_token_("!pixel_height!"), - persist_connection_(*params_.get("persist_connection", true)), - extent_from_subquery_(*params_.get("extent_from_subquery", false)), + persist_connection_(*params.get("persist_connection", true)), + extent_from_subquery_(*params.get("extent_from_subquery", false)), // params below are for testing purposes only (will likely be removed at any time) - intersect_min_scale_(*params_.get("intersect_min_scale", 0)), - intersect_max_scale_(*params_.get("intersect_max_scale", 0)) + intersect_min_scale_(*params.get("intersect_min_scale", 0)), + intersect_max_scale_(*params.get("intersect_max_scale", 0)) { +#ifdef MAPNIK_STATS + mapnik::progress_timer __stats__(std::clog, "postgis_datasource::init"); +#endif if (table_.empty()) { throw mapnik::datasource_exception("Postgis Plugin: missing
parameter"); } - boost::optional ext = params_.get("extent"); + boost::optional ext = params.get("extent"); if (ext && !ext->empty()) { extent_initialized_ = extent_.from_string(*ext); } - if (bind) - { - this->bind(); - } -} - -void postgis_datasource::bind() const -{ - if (is_bound_) - { - return; - } - -#ifdef MAPNIK_STATS - mapnik::progress_timer __stats__(std::clog, "postgis_datasource::bind"); -#endif - - boost::optional initial_size = params_.get("initial_size", 1); - boost::optional max_size = params_.get("max_size", 10); - boost::optional autodetect_key_field = params_.get("autodetect_key_field", false); - - boost::optional simplify_opt = params_.get("simplify_geometries", false); + boost::optional initial_size = params.get("initial_size", 1); + boost::optional max_size = params.get("max_size", 10); + boost::optional autodetect_key_field = params.get("autodetect_key_field", false); + boost::optional estimate_extent = params.get("estimate_extent", false); + estimate_extent_ = estimate_extent && *estimate_extent; + boost::optional simplify_opt = params.get("simplify_geometries", false); simplify_geometries_ = simplify_opt && *simplify_opt; ConnectionManager::instance().registerPool(creator_, *initial_size, *max_size); @@ -424,14 +411,13 @@ void postgis_datasource::bind() const rs->close(); - is_bound_ = true; - } + } } } postgis_datasource::~postgis_datasource() { - if (is_bound_ && ! persist_connection_) + if (! persist_connection_) { shared_ptr< Pool > pool = ConnectionManager::instance().getPool(creator_.id()); if (pool) @@ -457,11 +443,6 @@ mapnik::datasource::datasource_t postgis_datasource::type() const layer_descriptor postgis_datasource::get_descriptor() const { - if (! is_bound_) - { - bind(); - } - return desc_; } @@ -603,11 +584,6 @@ boost::shared_ptr postgis_datasource::get_resultset(boost::shared_pt featureset_ptr postgis_datasource::features(const query& q) const { - if (! is_bound_) - { - bind(); - } - #ifdef MAPNIK_STATS mapnik::progress_timer __stats__(std::clog, "postgis_datasource::features"); #endif @@ -725,11 +701,6 @@ featureset_ptr postgis_datasource::features(const query& q) const featureset_ptr postgis_datasource::features_at_point(coord2d const& pt, double tol) const { - if (! is_bound_) - { - bind(); - } - #ifdef MAPNIK_STATS mapnik::progress_timer __stats__(std::clog, "postgis_datasource::features_at_point"); #endif @@ -817,11 +788,6 @@ box2d postgis_datasource::envelope() const return extent_; } - if (! is_bound_) - { - bind(); - } - shared_ptr< Pool > pool = ConnectionManager::instance().getPool(creator_.id()); if (pool) { @@ -832,9 +798,6 @@ box2d postgis_datasource::envelope() const std::ostringstream s; - boost::optional estimate_extent = - params_.get("estimate_extent", false); - if (geometryColumn_.empty()) { std::ostringstream s_error; @@ -852,7 +815,7 @@ box2d postgis_datasource::envelope() const throw mapnik::datasource_exception("Postgis Plugin: " + s_error.str()); } - if (estimate_extent && *estimate_extent) + if (estimate_extent_) { s << "SELECT ST_XMin(ext),ST_YMin(ext),ST_XMax(ext),ST_YMax(ext)" << " FROM (SELECT ST_Estimated_Extent('"; @@ -915,11 +878,6 @@ box2d postgis_datasource::envelope() const boost::optional postgis_datasource::get_geometry_type() const { - if (! is_bound_) - { - bind(); - } - boost::optional result; shared_ptr< Pool > pool = ConnectionManager::instance().getPool(creator_.id()); diff --git a/plugins/input/postgis/postgis_datasource.hpp b/plugins/input/postgis/postgis_datasource.hpp index 9885ca3c2..32e6069ad 100644 --- a/plugins/input/postgis/postgis_datasource.hpp +++ b/plugins/input/postgis/postgis_datasource.hpp @@ -58,7 +58,7 @@ using mapnik::coord2d; class postgis_datasource : public datasource { public: - postgis_datasource(const parameters ¶ms, bool bind=true); + postgis_datasource(const parameters ¶ms); ~postgis_datasource(); mapnik::datasource::datasource_t type() const; static const char * name(); @@ -67,7 +67,6 @@ public: mapnik::box2d envelope() const; boost::optional get_geometry_type() const; layer_descriptor get_descriptor() const; - void bind() const; private: std::string sql_bbox(box2d const& env) const; @@ -104,6 +103,7 @@ private: const std::string pixel_height_token_; bool persist_connection_; bool extent_from_subquery_; + bool estimate_extent_; // params below are for testing purposes only (will likely be removed at any time) int intersect_min_scale_; int intersect_max_scale_; diff --git a/plugins/input/postgis/postgis_featureset.cpp b/plugins/input/postgis/postgis_featureset.cpp index 25d516bc8..2da06d113 100644 --- a/plugins/input/postgis/postgis_featureset.cpp +++ b/plugins/input/postgis/postgis_featureset.cpp @@ -75,7 +75,7 @@ feature_ptr postgis_featureset::next() const char* buf = rs_->getValue(pos); std::string name = rs_->getFieldName(pos); - // validation happens of this type at bind() + // validation happens of this type at initialization int val; if (oid == 20) { diff --git a/plugins/input/python/python_datasource.cpp b/plugins/input/python/python_datasource.cpp index bceeb20bb..3c8795503 100644 --- a/plugins/input/python/python_datasource.cpp +++ b/plugins/input/python/python_datasource.cpp @@ -20,53 +20,27 @@ using mapnik::parameters; DATASOURCE_PLUGIN(python_datasource) -python_datasource::python_datasource(parameters const& params, bool bind) +python_datasource::python_datasource(parameters const& params) : datasource(params), - desc_(*params_.get("type"), *params_.get("encoding","utf-8")), - factory_(*params_.get("factory", "")) + desc_(*params.get("type"), *params.get("encoding","utf-8")), + factory_(*params.get("factory", "")) { // extract any remaining parameters as keyword args for the factory - BOOST_FOREACH(const mapnik::parameters::value_type& kv, params_) + BOOST_FOREACH(const mapnik::parameters::value_type& kv, params) { if((kv.first != "type") && (kv.first != "factory")) { - kwargs_.insert(std::make_pair(kv.first, *params_.get(kv.first))); + kwargs_.insert(std::make_pair(kv.first, *params.get(kv.first))); } } - if (bind) - { - this->bind(); - } -} - -python_datasource::~python_datasource() { } - -// This name must match the plugin filename, eg 'python.input' -const char* python_datasource::name_="python"; - -const char* python_datasource::name() -{ - return name_; -} - -mapnik::layer_descriptor python_datasource::get_descriptor() const -{ - if (!is_bound_) bind(); - - return desc_; -} - -// The following methods call into the Python interpreter and hence require, unfortunately, that the GIL be held. - -void python_datasource::bind() const -{ + // The following methods call into the Python interpreter and hence require, unfortunately, that the GIL be held. using namespace boost; - if (is_bound_) return; - - // if no factory callable is defined, bind is a nop - if (factory_.empty()) return; + if (factory_.empty()) + { + throw mapnik::datasource_exception("Python: 'factory' option must be defined"); + } try { @@ -111,16 +85,27 @@ void python_datasource::bind() const { throw mapnik::datasource_exception(extractException()); } +} - is_bound_ = true; +python_datasource::~python_datasource() { } + +// This name must match the plugin filename, eg 'python.input' +const char* python_datasource::name_="python"; + +const char* python_datasource::name() +{ + return name_; +} + +mapnik::layer_descriptor python_datasource::get_descriptor() const +{ + return desc_; } mapnik::datasource::datasource_t python_datasource::type() const { typedef boost::optional return_type; - if (!is_bound_) bind(); - try { ensure_gil lock; @@ -137,8 +122,6 @@ mapnik::datasource::datasource_t python_datasource::type() const mapnik::box2d python_datasource::envelope() const { - if (!is_bound_) bind(); - try { ensure_gil lock; @@ -154,8 +137,6 @@ boost::optional python_datasource::get_geometry_ { typedef boost::optional return_type; - if (!is_bound_) bind(); - try { ensure_gil lock; @@ -181,8 +162,6 @@ boost::optional python_datasource::get_geometry_ mapnik::featureset_ptr python_datasource::features(mapnik::query const& q) const { - if (!is_bound_) bind(); - try { // if the query box intersects our world extent then query for features @@ -209,8 +188,6 @@ mapnik::featureset_ptr python_datasource::features(mapnik::query const& q) const mapnik::featureset_ptr python_datasource::features_at_point(mapnik::coord2d const& pt, double tol) const { - if (!is_bound_) bind(); - try { ensure_gil lock; diff --git a/plugins/input/python/python_datasource.hpp b/plugins/input/python/python_datasource.hpp index 1b9980dfe..3465a3024 100644 --- a/plugins/input/python/python_datasource.hpp +++ b/plugins/input/python/python_datasource.hpp @@ -12,7 +12,7 @@ class python_datasource : public mapnik::datasource public: // constructor // arguments must not change - python_datasource(mapnik::parameters const& params, bool bind=true); + python_datasource(mapnik::parameters const& params); // destructor virtual ~python_datasource (); @@ -41,9 +41,6 @@ public: // mandatory: return the layer descriptor mapnik::layer_descriptor get_descriptor() const; - // mandatory: will bind the datasource given params - void bind() const; - private: static const char* name_; mutable mapnik::layer_descriptor desc_; diff --git a/plugins/input/raster/raster_datasource.cpp b/plugins/input/raster/raster_datasource.cpp index d188c1de7..125c2eac1 100644 --- a/plugins/input/raster/raster_datasource.cpp +++ b/plugins/input/raster/raster_datasource.cpp @@ -45,7 +45,7 @@ using mapnik::image_reader; DATASOURCE_PLUGIN(raster_datasource) -raster_datasource::raster_datasource(parameters const& params, bool bind) +raster_datasource::raster_datasource(parameters const& params) : datasource(params), desc_(*params.get("type"), "utf-8"), extent_initialized_(false) @@ -61,18 +61,19 @@ raster_datasource::raster_datasource(parameters const& params, bool bind) else filename_ = *file; - multi_tiles_ = *params_.get("multi", false); - tile_size_ = *params_.get("tile_size", 256); - tile_stride_ = *params_.get("tile_stride", 1); + multi_tiles_ = *params.get("multi", false); + tile_size_ = *params.get("tile_size", 256); + tile_stride_ = *params.get("tile_stride", 1); - format_ = *params_.get("format","tiff"); - - boost::optional lox = params_.get("lox"); - boost::optional loy = params_.get("loy"); - boost::optional hix = params_.get("hix"); - boost::optional hiy = params_.get("hiy"); - boost::optional ext = params_.get("extent"); + format_ = *params.get("format","tiff"); + boost::optional lox = params.get("lox"); + boost::optional loy = params.get("loy"); + boost::optional hix = params.get("hix"); + boost::optional hiy = params.get("hiy"); + + boost::optional ext = params.get("extent"); + if (lox && loy && hix && hiy) { extent_.init(*lox, *loy, *hix, *hiy); @@ -87,21 +88,11 @@ raster_datasource::raster_datasource(parameters const& params, bool bind) { throw datasource_exception("Raster Plugin: valid or are required"); } - - if (bind) - { - this->bind(); - } -} - -void raster_datasource::bind() const -{ - if (is_bound_) return; - + if (multi_tiles_) { - boost::optional x_width = params_.get("x_width"); - boost::optional y_width = params_.get("y_width"); + boost::optional x_width = params.get("x_width"); + boost::optional y_width = params.get("y_width"); if (! x_width) { @@ -148,7 +139,6 @@ void raster_datasource::bind() const MAPNIK_LOG_DEBUG(raster) << "raster_datasource: Raster size=" << width_ << "," << height_; - is_bound_ = true; } raster_datasource::~raster_datasource() @@ -182,8 +172,6 @@ layer_descriptor raster_datasource::get_descriptor() const featureset_ptr raster_datasource::features(query const& q) const { - if (! is_bound_) bind(); - mapnik::CoordTransform t(width_, height_, extent_, 0, 0); mapnik::box2d intersect = extent_.intersect(q.get_bbox()); mapnik::box2d ext = t.forward(intersect); diff --git a/plugins/input/raster/raster_datasource.hpp b/plugins/input/raster/raster_datasource.hpp index 91306ca14..44fff7df1 100644 --- a/plugins/input/raster/raster_datasource.hpp +++ b/plugins/input/raster/raster_datasource.hpp @@ -44,7 +44,7 @@ class raster_datasource : public mapnik::datasource { public: - raster_datasource(const mapnik::parameters& params, bool bind=true); + raster_datasource(const mapnik::parameters& params); virtual ~raster_datasource(); datasource::datasource_t type() const; static const char * name(); @@ -54,7 +54,6 @@ public: boost::optional get_geometry_type() const; mapnik::layer_descriptor get_descriptor() const; bool log_enabled() const; - void bind() const; private: mapnik::layer_descriptor desc_; diff --git a/plugins/input/rasterlite/rasterlite_datasource.cpp b/plugins/input/rasterlite/rasterlite_datasource.cpp index 803090635..893fb7f45 100644 --- a/plugins/input/rasterlite/rasterlite_datasource.cpp +++ b/plugins/input/rasterlite/rasterlite_datasource.cpp @@ -71,7 +71,7 @@ inline void* rasterlite_datasource::open_dataset() const } -rasterlite_datasource::rasterlite_datasource(parameters const& params, bool bind) +rasterlite_datasource::rasterlite_datasource(parameters const& params) : datasource(params), desc_(*params.get("type"),"utf-8") { @@ -91,16 +91,11 @@ rasterlite_datasource::rasterlite_datasource(parameters const& params, bool bind else dataset_name_ = *file; - if (bind) - { - this->bind(); - } + this->init(params); } -void rasterlite_datasource::bind() const +void rasterlite_datasource::init(mapnik::parameters const& params) { - if (is_bound_) return; - if (!boost::filesystem::exists(dataset_name_)) throw datasource_exception(dataset_name_ + " does not exist"); void *dataset = open_dataset(); @@ -158,8 +153,6 @@ void rasterlite_datasource::bind() const #endif rasterliteClose(dataset); - - is_bound_ = true; } rasterlite_datasource::~rasterlite_datasource() @@ -178,8 +171,6 @@ mapnik::datasource::datasource_t rasterlite_datasource::type() const box2d rasterlite_datasource::envelope() const { - if (!is_bound_) bind(); - return extent_; } @@ -195,16 +186,12 @@ layer_descriptor rasterlite_datasource::get_descriptor() const featureset_ptr rasterlite_datasource::features(query const& q) const { - if (!is_bound_) bind(); - rasterlite_query gq = q; return boost::make_shared(open_dataset(), gq); } featureset_ptr rasterlite_datasource::features_at_point(coord2d const& pt, double tol) const { - if (!is_bound_) bind(); - rasterlite_query gq = pt; return boost::make_shared(open_dataset(), gq); } diff --git a/plugins/input/rasterlite/rasterlite_datasource.hpp b/plugins/input/rasterlite/rasterlite_datasource.hpp index 7c046e582..c9c41f3e7 100644 --- a/plugins/input/rasterlite/rasterlite_datasource.hpp +++ b/plugins/input/rasterlite/rasterlite_datasource.hpp @@ -45,7 +45,7 @@ class rasterlite_datasource : public mapnik::datasource { public: - rasterlite_datasource(mapnik::parameters const& params, bool bind = true); + rasterlite_datasource(mapnik::parameters const& params); virtual ~rasterlite_datasource (); mapnik::datasource::datasource_t type() const; static const char * name(); @@ -54,7 +54,6 @@ public: mapnik::box2d envelope() const; boost::optional get_geometry_type() const; mapnik::layer_descriptor get_descriptor() const; - void bind() const; private: void* open_dataset() const; diff --git a/plugins/input/shape/shape_datasource.cpp b/plugins/input/shape/shape_datasource.cpp index 3a4dff4c8..c1679a189 100644 --- a/plugins/input/shape/shape_datasource.cpp +++ b/plugins/input/shape/shape_datasource.cpp @@ -55,14 +55,17 @@ using mapnik::filter_in_box; using mapnik::filter_at_point; using mapnik::attribute_descriptor; -shape_datasource::shape_datasource(const parameters ¶ms, bool bind) +shape_datasource::shape_datasource(const parameters ¶ms) : datasource (params), type_(datasource::Vector), file_length_(0), indexed_(false), - row_limit_(*params_.get("row_limit",0)), + row_limit_(*params.get("row_limit",0)), desc_(*params.get("type"), *params.get("encoding","utf-8")) { +#ifdef MAPNIK_STATS + mapnik::progress_timer __stats__(std::clog, "shape_datasource::init"); +#endif boost::optional file = params.get("file"); if (!file) throw datasource_exception("Shape Plugin: missing parameter"); @@ -74,20 +77,6 @@ shape_datasource::shape_datasource(const parameters ¶ms, bool bind) boost::algorithm::ireplace_last(shape_name_,".shp",""); - if (bind) - { - this->bind(); - } -} - -void shape_datasource::bind() const -{ - if (is_bound_) return; - -#ifdef MAPNIK_STATS - mapnik::progress_timer __stats__(std::clog, "shape_datasource::bind"); -#endif - if (!boost::filesystem::exists(shape_name_ + ".shp")) { throw datasource_exception("Shape Plugin: shapefile '" + shape_name_ + ".shp' does not exist"); @@ -107,7 +96,7 @@ void shape_datasource::bind() const try { #ifdef MAPNIK_STATS - mapnik::progress_timer __stats2__(std::clog, "shape_datasource::bind(get_column_description)"); + mapnik::progress_timer __stats2__(std::clog, "shape_datasource::init(get_column_description)"); #endif boost::shared_ptr shape_ref = boost::make_shared(shape_name_); @@ -171,7 +160,6 @@ void shape_datasource::bind() const throw; } - is_bound_ = true; } shape_datasource::~shape_datasource() {} @@ -252,14 +240,11 @@ datasource::datasource_t shape_datasource::type() const layer_descriptor shape_datasource::get_descriptor() const { - if (!is_bound_) bind(); return desc_; } featureset_ptr shape_datasource::features(const query& q) const { - if (!is_bound_) bind(); - #ifdef MAPNIK_STATS mapnik::progress_timer __stats__(std::clog, "shape_datasource::features"); #endif @@ -290,8 +275,6 @@ featureset_ptr shape_datasource::features(const query& q) const featureset_ptr shape_datasource::features_at_point(coord2d const& pt, double tol) const { - if (!is_bound_) bind(); - #ifdef MAPNIK_STATS mapnik::progress_timer __stats__(std::clog, "shape_datasource::features_at_point"); #endif @@ -334,8 +317,6 @@ featureset_ptr shape_datasource::features_at_point(coord2d const& pt, double tol box2d shape_datasource::envelope() const { - if (!is_bound_) bind(); - return extent_; } diff --git a/plugins/input/shape/shape_datasource.hpp b/plugins/input/shape/shape_datasource.hpp index ea3e10587..6e10b9608 100644 --- a/plugins/input/shape/shape_datasource.hpp +++ b/plugins/input/shape/shape_datasource.hpp @@ -52,7 +52,7 @@ using mapnik::coord2d; class shape_datasource : public datasource { public: - shape_datasource(const parameters ¶ms, bool bind=true); + shape_datasource(const parameters ¶ms); virtual ~shape_datasource(); datasource::datasource_t type() const; static const char * name(); @@ -61,7 +61,6 @@ public: box2d envelope() const; boost::optional get_geometry_type() const; layer_descriptor get_descriptor() const; - void bind() const; private: void init(shape_io& shape) const; diff --git a/plugins/input/sqlite/sqlite_datasource.cpp b/plugins/input/sqlite/sqlite_datasource.cpp index 10a2f8b9d..4c3c2e816 100644 --- a/plugins/input/sqlite/sqlite_datasource.cpp +++ b/plugins/input/sqlite/sqlite_datasource.cpp @@ -52,22 +52,22 @@ using mapnik::parameters; DATASOURCE_PLUGIN(sqlite_datasource) -sqlite_datasource::sqlite_datasource(parameters const& params, bool bind) +sqlite_datasource::sqlite_datasource(parameters const& params) : datasource(params), extent_(), extent_initialized_(false), type_(datasource::Vector), - table_(*params_.get("table", "")), - fields_(*params_.get("fields", "*")), - metadata_(*params_.get("metadata", "")), - geometry_table_(*params_.get("geometry_table", "")), - geometry_field_(*params_.get("geometry_field", "")), - index_table_(*params_.get("index_table", "")), - key_field_(*params_.get("key_field", "")), - row_offset_(*params_.get("row_offset", 0)), - row_limit_(*params_.get("row_limit", 0)), + table_(*params.get("table", "")), + fields_(*params.get("fields", "*")), + metadata_(*params.get("metadata", "")), + geometry_table_(*params.get("geometry_table", "")), + geometry_field_(*params.get("geometry_field", "")), + index_table_(*params.get("index_table", "")), + key_field_(*params.get("key_field", "")), + row_offset_(*params.get("row_offset", 0)), + row_limit_(*params.get("row_limit", 0)), intersects_token_("!intersects!"), - desc_(*params_.get("type"), *params_.get("encoding", "utf-8")), + desc_(*params.get("type"), *params.get("encoding", "utf-8")), format_(mapnik::wkbAuto) { /* TODO @@ -76,27 +76,14 @@ sqlite_datasource::sqlite_datasource(parameters const& params, bool bind) - if spatialite - leverage more of the metadata for geometry type detection */ - boost::optional file = params_.get("file"); - if (! file) throw datasource_exception("Sqlite Plugin: missing parameter"); - - if (bind) - { - this->bind(); - } -} - -void sqlite_datasource::bind() const -{ - if (is_bound_) return; - #ifdef MAPNIK_STATS - mapnik::progress_timer __stats__(std::clog, "sqlite_datasource::bind"); + mapnik::progress_timer __stats__(std::clog, "sqlite_datasource::init"); #endif - boost::optional file = params_.get("file"); + boost::optional file = params.get("file"); if (! file) throw datasource_exception("Sqlite Plugin: missing parameter"); - boost::optional base = params_.get("base"); + boost::optional base = params.get("base"); if (base) dataset_name_ = *base + "/" + *file; else @@ -107,15 +94,15 @@ void sqlite_datasource::bind() const throw datasource_exception("Sqlite Plugin: " + dataset_name_ + " does not exist"); } - use_spatial_index_ = *params_.get("use_spatial_index", true); + use_spatial_index_ = *params.get("use_spatial_index", true); // TODO - remove this option once all datasources have an indexing api - bool auto_index = *params_.get("auto_index", true); + bool auto_index = *params.get("auto_index", true); - boost::optional ext = params_.get("extent"); + boost::optional ext = params.get("extent"); if (ext) extent_initialized_ = extent_.from_string(*ext); - boost::optional wkb = params_.get("wkb_format"); + boost::optional wkb = params.get("wkb_format"); if (wkb) { if (*wkb == "spatialite") @@ -139,13 +126,13 @@ void sqlite_datasource::bind() const // databases are relative to directory containing dataset_name_. Sqlite // will default to attaching from cwd. Typicaly usage means that the // map loader will produce full paths here. - boost::optional attachdb = params_.get("attachdb"); + boost::optional attachdb = params.get("attachdb"); if (attachdb) { parse_attachdb(*attachdb); } - boost::optional initdb = params_.get("initdb"); + boost::optional initdb = params.get("initdb"); if (initdb) { init_statements_.push_back(*initdb); @@ -154,10 +141,10 @@ void sqlite_datasource::bind() const // now actually create the connection and start executing setup sql dataset_ = boost::make_shared(dataset_name_); - boost::optional table_by_index = params_.get("table_by_index"); + boost::optional table_by_index = params.get("table_by_index"); int passed_parameters = 0; - passed_parameters += params_.get("table") ? 1 : 0; + passed_parameters += params.get("table") ? 1 : 0; passed_parameters += table_by_index ? 1 : 0; if (passed_parameters > 1) @@ -289,7 +276,7 @@ void sqlite_datasource::bind() const if (use_spatial_index_) { #ifdef MAPNIK_STATS - mapnik::progress_timer __stats2__(std::clog, "sqlite_datasource::bind(use_spatial_index)"); + mapnik::progress_timer __stats2__(std::clog, "sqlite_datasource::init(use_spatial_index)"); #endif if (boost::filesystem::exists(index_db)) @@ -374,7 +361,6 @@ void sqlite_datasource::bind() const } } - is_bound_ = true; } std::string sqlite_datasource::populate_tokens(std::string const& sql) const @@ -487,15 +473,11 @@ mapnik::datasource::datasource_t sqlite_datasource::type() const box2d sqlite_datasource::envelope() const { - if (! is_bound_) bind(); - return extent_; } boost::optional sqlite_datasource::get_geometry_type() const { - if (! is_bound_) bind(); - #ifdef MAPNIK_STATS mapnik::progress_timer __stats__(std::clog, "sqlite_datasource::get_geometry_type"); #endif @@ -547,15 +529,11 @@ boost::optional sqlite_datasource::get_geometry_ layer_descriptor sqlite_datasource::get_descriptor() const { - if (! is_bound_) bind(); - return desc_; } featureset_ptr sqlite_datasource::features(query const& q) const { - if (! is_bound_) bind(); - #ifdef MAPNIK_STATS mapnik::progress_timer __stats__(std::clog, "sqlite_datasource::features"); #endif @@ -634,8 +612,6 @@ featureset_ptr sqlite_datasource::features(query const& q) const featureset_ptr sqlite_datasource::features_at_point(coord2d const& pt, double tol) const { - if (! is_bound_) bind(); - #ifdef MAPNIK_STATS mapnik::progress_timer __stats__(std::clog, "sqlite_datasource::features_at_point"); #endif diff --git a/plugins/input/sqlite/sqlite_datasource.hpp b/plugins/input/sqlite/sqlite_datasource.hpp index c87d94d04..11ef7196b 100644 --- a/plugins/input/sqlite/sqlite_datasource.hpp +++ b/plugins/input/sqlite/sqlite_datasource.hpp @@ -48,7 +48,7 @@ class sqlite_datasource : public mapnik::datasource { public: - sqlite_datasource(mapnik::parameters const& params, bool bind = true); + sqlite_datasource(mapnik::parameters const& params); virtual ~sqlite_datasource (); datasource::datasource_t type() const; static const char * name(); @@ -57,7 +57,6 @@ public: mapnik::box2d envelope() const; boost::optional get_geometry_type() const; mapnik::layer_descriptor get_descriptor() const; - void bind() const; private: // Fill init_statements with any statements @@ -65,9 +64,6 @@ private: void parse_attachdb(std::string const& attachdb) const; std::string populate_tokens(std::string const& sql) const; - // FIXME: remove mutable qualifier from data members - // by factoring out bind() logic out from - // datasource impl !!! mutable mapnik::box2d extent_; mutable bool extent_initialized_; mapnik::datasource::datasource_t type_; diff --git a/plugins/input/templates/helloworld/hello_datasource.cpp b/plugins/input/templates/helloworld/hello_datasource.cpp index 9b9b4437a..38b1d0e10 100644 --- a/plugins/input/templates/helloworld/hello_datasource.cpp +++ b/plugins/input/templates/helloworld/hello_datasource.cpp @@ -11,29 +11,22 @@ using mapnik::parameters; DATASOURCE_PLUGIN(hello_datasource) -hello_datasource::hello_datasource(parameters const& params, bool bind) +hello_datasource::hello_datasource(parameters const& params) : datasource(params), - desc_(*params_.get("type"), *params_.get("encoding","utf-8")), + desc_(*params.get("type"), *params.get("encoding","utf-8")), extent_() { - if (bind) - { - this->bind(); - } + this->init(params); } -void hello_datasource::bind() const +void hello_datasource::init(mapnik::parameters const& params) { - if (is_bound_) return; - // every datasource must have some way of reporting its extent // in this case we are not actually reading from any data so for fun // let's just create a world extent in Mapnik's default srs: // '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs' (equivalent to +init=epsg:4326) // see http://spatialreference.org/ref/epsg/4326/ for more details extent_.init(-180,-90,180,90); - - is_bound_ = true; } hello_datasource::~hello_datasource() { } @@ -51,8 +44,6 @@ mapnik::datasource::datasource_t hello_datasource::type() const mapnik::box2d hello_datasource::envelope() const { - if (!is_bound_) bind(); - return extent_; } @@ -63,15 +54,11 @@ boost::optional hello_datasource::get_geometry_t mapnik::layer_descriptor hello_datasource::get_descriptor() const { - if (!is_bound_) bind(); - return desc_; } mapnik::featureset_ptr hello_datasource::features(mapnik::query const& q) const { - if (!is_bound_) bind(); - // if the query box intersects our world extent then query for features if (extent_.intersects(q.get_bbox())) { @@ -84,8 +71,6 @@ mapnik::featureset_ptr hello_datasource::features(mapnik::query const& q) const mapnik::featureset_ptr hello_datasource::features_at_point(mapnik::coord2d const& pt, double tol) const { - if (!is_bound_) bind(); - // features_at_point is rarely used - only by custom applications, // so for this sample plugin let's do nothing... return mapnik::featureset_ptr(); diff --git a/plugins/input/templates/helloworld/hello_datasource.hpp b/plugins/input/templates/helloworld/hello_datasource.hpp index 969c07332..b1d8f2b32 100644 --- a/plugins/input/templates/helloworld/hello_datasource.hpp +++ b/plugins/input/templates/helloworld/hello_datasource.hpp @@ -22,7 +22,7 @@ class hello_datasource : public mapnik::datasource public: // constructor // arguments must not change - hello_datasource(mapnik::parameters const& params, bool bind=true); + hello_datasource(mapnik::parameters const& params); // destructor virtual ~hello_datasource (); @@ -51,10 +51,10 @@ public: // mandatory: return the layer descriptor mapnik::layer_descriptor get_descriptor() const; - // mandatory: will bind the datasource given params - void bind() const; - private: + // recommended - do intialization in a so-named init function + // to reduce code in constructor + void init(mapnik::parameters const& params); // recommended naming convention of datasource members: // name_, type_, extent_, and desc_ static const std::string name_; diff --git a/src/datasource_cache.cpp b/src/datasource_cache.cpp index 5d5d63616..1b68b22a7 100644 --- a/src/datasource_cache.cpp +++ b/src/datasource_cache.cpp @@ -55,7 +55,7 @@ datasource_cache::~datasource_cache() lt_dlexit(); } -datasource_ptr datasource_cache::create(const parameters& params, bool bind) +datasource_ptr datasource_cache::create(const parameters& params) { boost::optional type = params.get("type"); if ( ! type) @@ -114,7 +114,7 @@ datasource_ptr datasource_cache::create(const parameters& params, bool bind) } #endif - ds = datasource_ptr(create_datasource(params, bind), datasource_deleter()); + ds = datasource_ptr(create_datasource(params), datasource_deleter()); MAPNIK_LOG_DEBUG(datasource_cache) << "datasource_cache: Datasource=" << ds << " type=" << type; diff --git a/src/deepcopy.cpp b/src/deepcopy.cpp index 3613b90e3..22356c966 100644 --- a/src/deepcopy.cpp +++ b/src/deepcopy.cpp @@ -119,7 +119,6 @@ namespace mapnik { namespace util { feature_type_style style_out(style_in,true); // deep copy map_out.insert_style(kv.first, style_out); } - } - }} +}} From e8b7b82bbb03ca079a2725dcd71ff0c257acf7be Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Mon, 17 Dec 2012 19:29:44 +0100 Subject: [PATCH 07/15] Implement scientific notation for double-to-string Also fixes tests for 1e5 expecting fixed precision rather than scientific notation (stringstream gives scientific notation indeed) The only still failing test now is the one having less than 16 significant digits of precision, due to the boost bug: https://svn.boost.org/trac/boost/ticket/7785 --- include/mapnik/util/conversions.hpp | 74 ++++++++++++++++++++++++++-- tests/cpp_tests/conversions_test.cpp | 4 +- 2 files changed, 73 insertions(+), 5 deletions(-) diff --git a/include/mapnik/util/conversions.hpp b/include/mapnik/util/conversions.hpp index 48f2daa3d..a0c573869 100644 --- a/include/mapnik/util/conversions.hpp +++ b/include/mapnik/util/conversions.hpp @@ -70,12 +70,80 @@ template struct double_policy : boost::spirit::karma::real_policies { typedef boost::spirit::karma::real_policies base_type; - static int floatfield(T n) { return base_type::fmtflags::fixed; } - static unsigned precision(T n) { return static_cast(15 - boost::math::trunc(log10(n))); } + + static int floatfield(T n) { + using namespace boost::spirit; // for traits + + if (traits::test_zero(n)) + return base_type::fmtflags::fixed; + + T abs_n = traits::get_absolute_value(n); + return (abs_n >= 1e16 || abs_n < 1e-4) + ? base_type::fmtflags::scientific : base_type::fmtflags::fixed; + } + + static unsigned precision(T n) { + if ( n == 0.0 ) return 0; + using namespace boost::spirit; // for traits + return static_cast(15 - boost::math::trunc(log10(traits::get_absolute_value(n)))); + } + template static bool dot(OutputIterator& sink, T n, unsigned precision) { - return n ? *sink = '.', true : false; + if (n == 0.0) return true; // avoid trailing zeroes + return base_type::dot(sink, n, precision); } + + template + static bool fraction_part (OutputIterator& sink, T n + , unsigned precision_, unsigned precision) + { + // NOTE: copied from karma only to avoid trailing zeroes + // (maybe a bug ?) + + // allow for ADL to find the correct overload for floor and log10 + using namespace std; + + using namespace boost::spirit; // for traits + using namespace boost::spirit::karma; // for char_inserter + using namespace boost; // for remove_const + + if ( traits::test_zero(n) ) return true; // this part added to karma + + // The following is equivalent to: + // generate(sink, right_align(precision, '0')[ulong], n); + // but it's spelled out to avoid inter-modular dependencies. + + typename remove_const::type digits = + (traits::test_zero(n) ? 0 : floor(log10(n))) + 1; + bool r = true; + for (/**/; r && digits < precision_; digits = digits + 1) + r = char_inserter<>::call(sink, '0'); + if (precision && r) + r = int_inserter<10>::call(sink, n); + return r; + } + + template + static bool exponent (OutputIterator& sink, long n) + { + // NOTE: copied from karma to force sign in exponent + const bool force_sign = true; + + using namespace boost::spirit; // for traits + using namespace boost::spirit::karma; // for char_inserter, sign_inserter + + long abs_n = traits::get_absolute_value(n); + bool r = char_inserter::call(sink, 'e') && + sign_inserter::call(sink, traits::test_zero(n) + , traits::test_negative(n), force_sign); + + // the C99 Standard requires at least two digits in the exponent + if (r && abs_n < 10) + r = char_inserter::call(sink, '0'); + return r && int_inserter<10>::call(sink, abs_n); + } + }; diff --git a/tests/cpp_tests/conversions_test.cpp b/tests/cpp_tests/conversions_test.cpp index a24c807b7..362e09067 100644 --- a/tests/cpp_tests/conversions_test.cpp +++ b/tests/cpp_tests/conversions_test.cpp @@ -49,11 +49,11 @@ int main( int, char*[] ) out.clear(); to_string(out, double(1e-05)); - BOOST_TEST_EQ( out, "0.00001" ); + BOOST_TEST_EQ( out, "1e-05" ); out.clear(); to_string(out, double(-1e-05)); - BOOST_TEST_EQ( out, "-0.00001" ); + BOOST_TEST_EQ( out, "-1e-05" ); out.clear(); to_string(out, double(0.0001)); From 14f80192df406b3833e4bdc1108002b6c7d5ad70 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 17 Dec 2012 10:32:00 -0800 Subject: [PATCH 08/15] add internal noncopyable header --- include/mapnik/noncopyable.hpp | 45 ++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 include/mapnik/noncopyable.hpp diff --git a/include/mapnik/noncopyable.hpp b/include/mapnik/noncopyable.hpp new file mode 100644 index 000000000..f5467ad1d --- /dev/null +++ b/include/mapnik/noncopyable.hpp @@ -0,0 +1,45 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2012 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +#ifndef MAPNIK_NONCOPYABLE_HPP +#define MAPNIK_NONCOPYABLE_HPP + +namespace mapnik { + +namespace non_copyable_ +{ + class noncopyable + { + protected: + noncopyable() {} + ~noncopyable() {} + private: + noncopyable( const noncopyable& ); + const noncopyable& operator=( const noncopyable& ); + }; +} + +typedef non_copyable_::noncopyable noncopyable; + +} // namespace mapnik + +#endif // MAPNIK_NONCOPYABLE_HPP From bdfdca99e9ed6b04fe5753663d4c42a8309d1ee7 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 17 Dec 2012 10:51:10 -0800 Subject: [PATCH 09/15] fix debug output --- plugins/input/postgis/postgis_datasource.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/input/postgis/postgis_datasource.cpp b/plugins/input/postgis/postgis_datasource.cpp index 2d78ea093..700615dcb 100644 --- a/plugins/input/postgis/postgis_datasource.cpp +++ b/plugins/input/postgis/postgis_datasource.cpp @@ -145,7 +145,7 @@ postgis_datasource::postgis_datasource(parameters const& params) if (geometryColumn_.empty() || srid_ == 0) { #ifdef MAPNIK_STATS - mapnik::progress_timer __stats2__(std::clog, "postgis_datasource::bind(get_srid_and_geometry_column)"); + mapnik::progress_timer __stats2__(std::clog, "postgis_datasource::init(get_srid_and_geometry_column)"); #endif std::ostringstream s; From 7b39333234c44332d21ae6251dbc24e0d56f511a Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 17 Dec 2012 12:59:15 -0800 Subject: [PATCH 10/15] remove as much mutable as possible --- plugins/input/csv/csv_datasource.cpp | 2 +- plugins/input/csv/csv_datasource.hpp | 34 +++++++++---------- plugins/input/gdal/gdal_datasource.hpp | 16 ++++----- plugins/input/geojson/geojson_datasource.hpp | 12 +++---- plugins/input/kismet/kismet_datasource.hpp | 2 +- plugins/input/occi/occi_datasource.hpp | 20 +++++------ plugins/input/osm/osm_datasource.hpp | 6 ++-- plugins/input/postgis/postgis_datasource.hpp | 14 ++++---- plugins/input/python/python_datasource.hpp | 4 +-- plugins/input/raster/raster_datasource.hpp | 4 +-- .../rasterlite/rasterlite_datasource.hpp | 2 +- plugins/input/shape/shape_datasource.cpp | 6 ++-- plugins/input/shape/shape_datasource.hpp | 14 ++++---- plugins/input/sqlite/sqlite_datasource.hpp | 32 ++++++++--------- .../templates/helloworld/hello_datasource.hpp | 4 +-- 15 files changed, 86 insertions(+), 86 deletions(-) diff --git a/plugins/input/csv/csv_datasource.cpp b/plugins/input/csv/csv_datasource.cpp index 4ce9b3f23..9063060e5 100644 --- a/plugins/input/csv/csv_datasource.cpp +++ b/plugins/input/csv/csv_datasource.cpp @@ -135,7 +135,7 @@ template void csv_datasource::parse_csv(T & stream, std::string const& escape, std::string const& separator, - std::string const& quote) const + std::string const& quote) { stream.seekg(0, std::ios::end); file_length_ = stream.tellg(); diff --git a/plugins/input/csv/csv_datasource.hpp b/plugins/input/csv/csv_datasource.hpp index fb8b21666..30ce5f8a5 100644 --- a/plugins/input/csv/csv_datasource.hpp +++ b/plugins/input/csv/csv_datasource.hpp @@ -56,25 +56,25 @@ public: void parse_csv(T & stream, std::string const& escape, std::string const& separator, - std::string const& quote) const; + std::string const& quote); private: - mutable mapnik::layer_descriptor desc_; - mutable mapnik::box2d extent_; - mutable std::string filename_; - mutable std::string inline_string_; - mutable unsigned file_length_; - mutable int row_limit_; - mutable std::vector features_; - mutable std::string escape_; - mutable std::string separator_; - mutable std::string quote_; - mutable std::vector headers_; - mutable std::string manual_headers_; - mutable bool strict_; - mutable bool quiet_; - mutable double filesize_max_; - mutable mapnik::context_ptr ctx_; + mapnik::layer_descriptor desc_; + mapnik::box2d extent_; + std::string filename_; + std::string inline_string_; + unsigned file_length_; + int row_limit_; + std::vector features_; + std::string escape_; + std::string separator_; + std::string quote_; + std::vector headers_; + std::string manual_headers_; + bool strict_; + bool quiet_; + double filesize_max_; + mapnik::context_ptr ctx_; }; #endif // MAPNIK_CSV_DATASOURCE_HPP diff --git a/plugins/input/gdal/gdal_datasource.hpp b/plugins/input/gdal/gdal_datasource.hpp index 2032f0194..7bd1f33ed 100644 --- a/plugins/input/gdal/gdal_datasource.hpp +++ b/plugins/input/gdal/gdal_datasource.hpp @@ -56,16 +56,16 @@ public: mapnik::layer_descriptor get_descriptor() const; private: GDALDataset* open_dataset() const; - mutable mapnik::box2d extent_; + mapnik::box2d extent_; std::string dataset_name_; - mutable int band_; + int band_; mapnik::layer_descriptor desc_; - mutable unsigned width_; - mutable unsigned height_; - mutable double dx_; - mutable double dy_; - mutable int nbands_; - mutable bool shared_dataset_; + unsigned width_; + unsigned height_; + double dx_; + double dy_; + int nbands_; + bool shared_dataset_; double filter_factor_; boost::optional nodata_value_; }; diff --git a/plugins/input/geojson/geojson_datasource.hpp b/plugins/input/geojson/geojson_datasource.hpp index 41537868d..c953fcae9 100644 --- a/plugins/input/geojson/geojson_datasource.hpp +++ b/plugins/input/geojson/geojson_datasource.hpp @@ -66,13 +66,13 @@ public: boost::optional get_geometry_type() const; private: mapnik::datasource::datasource_t type_; - mutable std::map statistics_; - mutable mapnik::layer_descriptor desc_; - mutable std::string file_; - mutable mapnik::box2d extent_; + std::map statistics_; + mapnik::layer_descriptor desc_; + std::string file_; + mapnik::box2d extent_; boost::shared_ptr tr_; - mutable std::vector features_; - mutable spatial_index_type tree_; + std::vector features_; + spatial_index_type tree_; mutable std::deque index_array_; }; diff --git a/plugins/input/kismet/kismet_datasource.hpp b/plugins/input/kismet/kismet_datasource.hpp index c1d727830..272a15ddd 100644 --- a/plugins/input/kismet/kismet_datasource.hpp +++ b/plugins/input/kismet/kismet_datasource.hpp @@ -66,7 +66,7 @@ private: unsigned int port_; mapnik::datasource::datasource_t type_; std::string srs_; - mutable mapnik::layer_descriptor desc_; + mapnik::layer_descriptor desc_; boost::shared_ptr kismet_thread; }; diff --git a/plugins/input/occi/occi_datasource.hpp b/plugins/input/occi/occi_datasource.hpp index 76c8288f3..5a191449e 100644 --- a/plugins/input/occi/occi_datasource.hpp +++ b/plugins/input/occi/occi_datasource.hpp @@ -60,20 +60,20 @@ private: static const std::string METADATA_TABLE; mapnik::datasource::datasource_t type_; - mutable std::string table_; - mutable std::string table_name_; - mutable std::string fields_; - mutable std::string geometry_field_; - mutable int srid_; - mutable bool srid_initialized_; + std::string table_; + std::string table_name_; + std::string fields_; + std::string geometry_field_; + int srid_; + bool srid_initialized_; mutable bool extent_initialized_; mutable mapnik::box2d extent_; - mutable mapnik::layer_descriptor desc_; - mutable bool use_wkb_; + mapnik::layer_descriptor desc_; + bool use_wkb_; int row_limit_; int row_prefetch_; - mutable oracle::occi::StatelessConnectionPool* pool_; - mutable oracle::occi::Connection* conn_; + oracle::occi::StatelessConnectionPool* pool_; + oracle::occi::Connection* conn_; bool use_connection_pool_; bool use_spatial_index_; bool estimate_extent_; diff --git a/plugins/input/osm/osm_datasource.hpp b/plugins/input/osm/osm_datasource.hpp index 4b7d60fa3..efdd20d68 100644 --- a/plugins/input/osm/osm_datasource.hpp +++ b/plugins/input/osm/osm_datasource.hpp @@ -64,10 +64,10 @@ public: layer_descriptor get_descriptor() const; private: - mutable box2d extent_; - mutable osm_dataset* osm_data_; + box2d extent_; + osm_dataset* osm_data_; mapnik::datasource::datasource_t type_; - mutable layer_descriptor desc_; + layer_descriptor desc_; }; #endif // OSM_DATASOURCE_HPP diff --git a/plugins/input/postgis/postgis_datasource.hpp b/plugins/input/postgis/postgis_datasource.hpp index 32e6069ad..b61611864 100644 --- a/plugins/input/postgis/postgis_datasource.hpp +++ b/plugins/input/postgis/postgis_datasource.hpp @@ -83,19 +83,19 @@ private: const std::string username_; const std::string password_; const std::string table_; - mutable std::string schema_; - mutable std::string geometry_table_; + std::string schema_; + std::string geometry_table_; const std::string geometry_field_; - mutable std::string key_field_; + std::string key_field_; const int cursor_fetch_size_; const int row_limit_; - mutable std::string geometryColumn_; + std::string geometryColumn_; mapnik::datasource::datasource_t type_; - mutable int srid_; + int srid_; mutable bool extent_initialized_; mutable mapnik::box2d extent_; - mutable bool simplify_geometries_; - mutable layer_descriptor desc_; + bool simplify_geometries_; + layer_descriptor desc_; ConnectionCreator creator_; const std::string bbox_token_; const std::string scale_denom_token_; diff --git a/plugins/input/python/python_datasource.hpp b/plugins/input/python/python_datasource.hpp index 3465a3024..fc9941c6b 100644 --- a/plugins/input/python/python_datasource.hpp +++ b/plugins/input/python/python_datasource.hpp @@ -43,10 +43,10 @@ public: private: static const char* name_; - mutable mapnik::layer_descriptor desc_; + mapnik::layer_descriptor desc_; const std::string factory_; std::map kwargs_; - mutable boost::python::object datasource_; + boost::python::object datasource_; }; diff --git a/plugins/input/raster/raster_datasource.hpp b/plugins/input/raster/raster_datasource.hpp index 44fff7df1..381a6568f 100644 --- a/plugins/input/raster/raster_datasource.hpp +++ b/plugins/input/raster/raster_datasource.hpp @@ -64,8 +64,8 @@ private: bool multi_tiles_; unsigned tile_size_; unsigned tile_stride_; - mutable unsigned width_; - mutable unsigned height_; + unsigned width_; + unsigned height_; }; #endif // RASTER_DATASOURCE_HPP diff --git a/plugins/input/rasterlite/rasterlite_datasource.hpp b/plugins/input/rasterlite/rasterlite_datasource.hpp index c9c41f3e7..f5b46584b 100644 --- a/plugins/input/rasterlite/rasterlite_datasource.hpp +++ b/plugins/input/rasterlite/rasterlite_datasource.hpp @@ -57,7 +57,7 @@ public: private: void* open_dataset() const; - mutable mapnik::box2d extent_; + mapnik::box2d extent_; std::string dataset_name_; std::string table_name_; mapnik::layer_descriptor desc_; diff --git a/plugins/input/shape/shape_datasource.cpp b/plugins/input/shape/shape_datasource.cpp index c1679a189..a42aa94ab 100644 --- a/plugins/input/shape/shape_datasource.cpp +++ b/plugins/input/shape/shape_datasource.cpp @@ -162,9 +162,7 @@ shape_datasource::shape_datasource(const parameters ¶ms) } -shape_datasource::~shape_datasource() {} - -void shape_datasource::init(shape_io& shape) const +void shape_datasource::init(shape_io& shape) { #ifdef MAPNIK_STATS mapnik::progress_timer __stats__(std::clog, "shape_datasource::init"); @@ -228,6 +226,8 @@ void shape_datasource::init(shape_io& shape) const MAPNIK_LOG_DEBUG(shape) << "shape_datasource: Shape type=" << shape_type_; } +shape_datasource::~shape_datasource() {} + const char * shape_datasource::name() { return "shape"; diff --git a/plugins/input/shape/shape_datasource.hpp b/plugins/input/shape/shape_datasource.hpp index 6e10b9608..f194572b8 100644 --- a/plugins/input/shape/shape_datasource.hpp +++ b/plugins/input/shape/shape_datasource.hpp @@ -63,17 +63,17 @@ public: layer_descriptor get_descriptor() const; private: - void init(shape_io& shape) const; + void init(shape_io& shape); datasource::datasource_t type_; std::string shape_name_; - mutable boost::shared_ptr shape_; - mutable shape_io::shapeType shape_type_; - mutable long file_length_; - mutable box2d extent_; - mutable bool indexed_; + boost::shared_ptr shape_; + shape_io::shapeType shape_type_; + long file_length_; + box2d extent_; + bool indexed_; const int row_limit_; - mutable layer_descriptor desc_; + layer_descriptor desc_; }; #endif //SHAPE_HPP diff --git a/plugins/input/sqlite/sqlite_datasource.hpp b/plugins/input/sqlite/sqlite_datasource.hpp index 11ef7196b..868fa8e14 100644 --- a/plugins/input/sqlite/sqlite_datasource.hpp +++ b/plugins/input/sqlite/sqlite_datasource.hpp @@ -64,27 +64,27 @@ private: void parse_attachdb(std::string const& attachdb) const; std::string populate_tokens(std::string const& sql) const; - mutable mapnik::box2d extent_; - mutable bool extent_initialized_; + mapnik::box2d extent_; + bool extent_initialized_; mapnik::datasource::datasource_t type_; - mutable std::string dataset_name_; - mutable boost::shared_ptr dataset_; - mutable std::string table_; + std::string dataset_name_; + boost::shared_ptr dataset_; + std::string table_; std::string fields_; std::string metadata_; - mutable std::string geometry_table_; - mutable std::string geometry_field_; - mutable std::string index_table_; - mutable std::string key_field_; - mutable int row_offset_; - mutable int row_limit_; + std::string geometry_table_; + std::string geometry_field_; + std::string index_table_; + std::string key_field_; + int row_offset_; + int row_limit_; // TODO - also add to postgis.input const std::string intersects_token_; - mutable mapnik::layer_descriptor desc_; - mutable mapnik::wkbFormat format_; - mutable bool use_spatial_index_; - mutable bool has_spatial_index_; - mutable bool using_subquery_; + mapnik::layer_descriptor desc_; + mapnik::wkbFormat format_; + bool use_spatial_index_; + bool has_spatial_index_; + bool using_subquery_; mutable std::vector init_statements_; }; diff --git a/plugins/input/templates/helloworld/hello_datasource.hpp b/plugins/input/templates/helloworld/hello_datasource.hpp index b1d8f2b32..018ff6f2f 100644 --- a/plugins/input/templates/helloworld/hello_datasource.hpp +++ b/plugins/input/templates/helloworld/hello_datasource.hpp @@ -58,8 +58,8 @@ private: // recommended naming convention of datasource members: // name_, type_, extent_, and desc_ static const std::string name_; - mutable mapnik::layer_descriptor desc_; - mutable mapnik::box2d extent_; + mapnik::layer_descriptor desc_; + mapnik::box2d extent_; }; From 8d2b00ea75ff040a8cac80dca8bfbe4edf52ec39 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 17 Dec 2012 13:12:31 -0800 Subject: [PATCH 11/15] fix member name --- include/mapnik/datasource.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/mapnik/datasource.hpp b/include/mapnik/datasource.hpp index 6a0bdeb53..92974c998 100644 --- a/include/mapnik/datasource.hpp +++ b/include/mapnik/datasource.hpp @@ -86,7 +86,7 @@ public: }; datasource (parameters const& params) - : params__(params) {} + : params_(params) {} /*! * @brief Get the configuration parameters of the data source. @@ -97,7 +97,7 @@ public: */ parameters const& params() const { - return params__; + return params_; } /*! @@ -112,7 +112,7 @@ public: virtual layer_descriptor get_descriptor() const = 0; virtual ~datasource() {} protected: - parameters params__; + parameters params_; }; typedef const char * datasource_name(); From c7ed1f93d7e4b734249c4e6eb672c34842a9e823 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 17 Dec 2012 19:13:00 -0800 Subject: [PATCH 12/15] update svg_renderer --- include/mapnik/svg/output/svg_renderer.hpp | 5 ++ src/build.py | 66 +++++++++------------- 2 files changed, 32 insertions(+), 39 deletions(-) diff --git a/include/mapnik/svg/output/svg_renderer.hpp b/include/mapnik/svg/output/svg_renderer.hpp index 05ebe356d..0461fb909 100644 --- a/include/mapnik/svg/output/svg_renderer.hpp +++ b/include/mapnik/svg/output/svg_renderer.hpp @@ -104,6 +104,11 @@ public: // nothing to do } + inline eAttributeCollectionPolicy attribute_collection_policy() const + { + return DEFAULT; + } + inline OutputIterator& get_output_iterator() { return output_iterator_; diff --git a/src/build.py b/src/build.py index e40777915..d6ba1969f 100644 --- a/src/build.py +++ b/src/build.py @@ -202,45 +202,6 @@ if env['HAS_CAIRO']: libmapnik_cxxflags.append('-DHAVE_CAIRO') lib_env.PrependUnique(CPPPATH=copy(env['CAIROMM_CPPPATHS'])) source.insert(0,'cairo_renderer.cpp') - #cairo_env.PrependUnique(CPPPATH=env['CAIROMM_CPPPATHS']) - # not safe, to much depends on graphics.hpp - #cairo_env = lib_env.Clone() - #cairo_env.Append(CXXFLAGS = '-DHAVE_CAIRO') - #fixup = ['feature_type_style.cpp','load_map.cpp','cairo_renderer.cpp','graphics.cpp','image_util.cpp'] - #for cpp in fixup: - # if cpp in source: - # source.remove(cpp) - # if env['LINKING'] == 'static': - # source.insert(0,cairo_env.StaticObject(cpp)) - # else: - # source.insert(0,cairo_env.SharedObject(cpp)) - - -processor_cpp = 'feature_style_processor.cpp' - -if env['RENDERING_STATS']: - env3 = lib_env.Clone() - env3.Append(CXXFLAGS='-DRENDERING_STATS') - if env['LINKING'] == 'static': - source.insert(0,env3.StaticObject(processor_cpp)) - else: - source.insert(0,env3.SharedObject(processor_cpp)) -else: - source.insert(0,processor_cpp); - -if env.get('BOOST_LIB_VERSION_FROM_HEADER'): - boost_version_from_header = int(env['BOOST_LIB_VERSION_FROM_HEADER'].split('_')[1]) - if boost_version_from_header < 46: - # avoid ubuntu issue with boost interprocess: - # https://github.com/mapnik/mapnik/issues/1001 - env4 = lib_env.Clone() - env4.Append(CXXFLAGS = '-fpermissive') - cpp ='mapped_memory_cache.cpp' - source.remove(cpp) - if env['LINKING'] == 'static': - source.insert(0,env4.StaticObject(cpp)) - else: - source.insert(0,env4.SharedObject(cpp)) if env['JPEG']: source += Split( @@ -308,6 +269,21 @@ if env['SVG_RENDERER']: # svg backend lib_env.Append(CXXFLAGS = '-DSVG_RENDERER') libmapnik_cxxflags.append('-DSVG_RENDERER') + +if env.get('BOOST_LIB_VERSION_FROM_HEADER'): + boost_version_from_header = int(env['BOOST_LIB_VERSION_FROM_HEADER'].split('_')[1]) + if boost_version_from_header < 46: + # avoid ubuntu issue with boost interprocess: + # https://github.com/mapnik/mapnik/issues/1001 + env4 = lib_env.Clone() + env4.Append(CXXFLAGS = '-fpermissive') + cpp ='mapped_memory_cache.cpp' + source.remove(cpp) + if env['LINKING'] == 'static': + source.insert(0,env4.StaticObject(cpp)) + else: + source.insert(0,env4.SharedObject(cpp)) + if env['XMLPARSER'] == 'libxml2' and env['HAS_LIBXML2']: source += Split( """ @@ -331,6 +307,18 @@ else: """ ) +processor_cpp = 'feature_style_processor.cpp' + +if env['RENDERING_STATS']: + env3 = lib_env.Clone() + env3.Append(CXXFLAGS='-DRENDERING_STATS') + if env['LINKING'] == 'static': + source.insert(0,env3.StaticObject(processor_cpp)) + else: + source.insert(0,env3.SharedObject(processor_cpp)) +else: + source.insert(0,processor_cpp); + if env['CUSTOM_LDFLAGS']: linkflags = '%s %s' % (env['CUSTOM_LDFLAGS'], mapnik_lib_link_flag) else: From 274fbf8f7afda7d1c081722b601cabc0f985b0bb Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 18 Dec 2012 11:44:35 +0000 Subject: [PATCH 13/15] + ensure 'close path' handled correcly (currenlty SEG_CLOSE command must have valid x,y) + implement real_policies in wkt and geojson generators --- include/mapnik/geometry.hpp | 31 ++++++++-- .../json/geometry_generator_grammar.hpp | 23 +++++++- include/mapnik/json/geometry_grammar.hpp | 2 +- include/mapnik/util/geometry_to_wkb.hpp | 9 +++ .../mapnik/util/geometry_wkt_generator.hpp | 58 +++++++++++++++++-- include/mapnik/wkt/wkt_grammar.hpp | 2 +- plugins/input/shape/shape_io.cpp | 13 ++++- src/wkb.cpp | 24 +++++++- src/wkt/wkt_generator.cpp | 22 +++++-- 9 files changed, 162 insertions(+), 22 deletions(-) diff --git a/include/mapnik/geometry.hpp b/include/mapnik/geometry.hpp index aecc4536d..d57083fcc 100644 --- a/include/mapnik/geometry.hpp +++ b/include/mapnik/geometry.hpp @@ -91,10 +91,11 @@ public: double x = 0; double y = 0; rewind(0); - for (unsigned i=0;i 3) { - cont_.set_command(cont_.size() - 1, SEG_CLOSE); + unsigned cmd; + double x,y; + int index = cont_.size() - 1; + unsigned last_cmd = cont_.get_vertex(index,&x,&y); + if (last_cmd == SEG_LINETO) + { + double last_x = x; + double last_y = y; + for (int pos = index - 1; pos >=0 ; --pos) + { + cmd = cont_.get_vertex(pos,&x,&y); + if (cmd == SEG_MOVETO) + { + if (x == last_x && y == last_y) + { + cont_.set_command(index , SEG_CLOSE); + } + break; + } + } + } } } diff --git a/include/mapnik/json/geometry_generator_grammar.hpp b/include/mapnik/json/geometry_generator_grammar.hpp index 408bbf212..791b9db76 100644 --- a/include/mapnik/json/geometry_generator_grammar.hpp +++ b/include/mapnik/json/geometry_generator_grammar.hpp @@ -116,7 +116,28 @@ struct json_coordinate_policy : karma::real_policies { typedef boost::spirit::karma::real_policies base_type; static int floatfield(T n) { return base_type::fmtflags::fixed; } - static unsigned precision(T n) { return 12 ;} + + static unsigned precision(T n) + { + if (n == 0.0) return 0; + using namespace boost::spirit; + return static_cast(15 - boost::math::trunc(log10(traits::get_absolute_value(n)))); + } + + template + static bool dot(OutputIterator& sink, T n, unsigned precision) + { + if (n == 0) return true; + return base_type::dot(sink, n, precision); + } + + template + static bool fraction_part(OutputIterator& sink, T n + , unsigned adjprec, unsigned precision) + { + if (n == 0) return true; + return base_type::fraction_part(sink, n, adjprec, precision); + } }; } diff --git a/include/mapnik/json/geometry_grammar.hpp b/include/mapnik/json/geometry_grammar.hpp index 64a776f3e..4fd7159ca 100644 --- a/include/mapnik/json/geometry_grammar.hpp +++ b/include/mapnik/json/geometry_grammar.hpp @@ -69,7 +69,7 @@ struct close_path void operator() (T path) const { BOOST_ASSERT( path!=0 ); - path->close(); + path->set_close(); } }; diff --git a/include/mapnik/util/geometry_to_wkb.hpp b/include/mapnik/util/geometry_to_wkb.hpp index 10572ec12..399fc02eb 100644 --- a/include/mapnik/util/geometry_to_wkb.hpp +++ b/include/mapnik/util/geometry_to_wkb.hpp @@ -172,6 +172,8 @@ wkb_buffer_ptr to_polygon_wkb( GeometryType const& g, wkbByteOrder byte_order) double x = 0; double y = 0; + double start_x = 0; + double start_y = 0; std::size_t size = 1 + 4 + 4 ; // byteOrder + wkbType + numRings for (unsigned i=0; i< num_points; ++i) { @@ -179,8 +181,15 @@ wkb_buffer_ptr to_polygon_wkb( GeometryType const& g, wkbByteOrder byte_order) if (command == SEG_MOVETO) { rings.push_back(new linear_ring); // start new loop + start_x = x; + start_y = y; size += 4; // num_points } + else if (command == SEG_CLOSE) + { + x = start_x; + y = start_y; + } rings.back().push_back(std::make_pair(x,y)); size += 2 * 8; // point } diff --git a/include/mapnik/util/geometry_wkt_generator.hpp b/include/mapnik/util/geometry_wkt_generator.hpp index ee75c3dbd..929168e81 100644 --- a/include/mapnik/util/geometry_wkt_generator.hpp +++ b/include/mapnik/util/geometry_wkt_generator.hpp @@ -37,6 +37,7 @@ #include #include +#include // trunc to avoid needing C++11 //#define BOOST_SPIRIT_USE_PHOENIX_V3 1 namespace boost { namespace spirit { namespace traits { @@ -92,13 +93,40 @@ struct multi_geometry_ template struct result { typedef bool type; }; - bool operator() (geometry_container const& geom) const { return geom.size() > 1 ? true : false; } }; +template +struct get_x +{ + typedef T value_type; + + template + struct result { typedef double type; }; + + double operator() (value_type const& val) const + { + return boost::get<1>(val); + } +}; + +template +struct get_y +{ + typedef T value_type; + + template + struct result { typedef double type; }; + + double operator() (value_type const& val) const + { + return boost::get<2>(val); + } +}; + template struct multi_geometry_type { @@ -116,7 +144,27 @@ struct wkt_coordinate_policy : karma::real_policies { typedef boost::spirit::karma::real_policies base_type; static int floatfield(T n) { return base_type::fmtflags::fixed; } - static unsigned precision(T n) { return 6 ;} + static unsigned precision(T n) + { + if (n == 0.0) return 0; + using namespace boost::spirit; // for traits + return static_cast(15 - boost::math::trunc(log10(traits::get_absolute_value(n)))); + } + + template + static bool dot(OutputIterator& sink, T n, unsigned precision) + { + if (n == 0) return true; + return base_type::dot(sink, n, precision); + } + + template + static bool fraction_part(OutputIterator& sink, T n + , unsigned adjprec, unsigned precision) + { + if (n == 0) return true; + return base_type::fraction_part(sink, n, adjprec, precision); + } }; } @@ -136,13 +184,15 @@ struct wkt_generator : karma::rule polygon; karma::rule coords; - karma::rule, geometry_type const& ()> coords2; + karma::rule, geometry_type const& ()> coords2; karma::rule point_coord; - karma::rule polygon_coord; + karma::rule, coord_type (unsigned&, double&, double& )> polygon_coord; // phoenix functions phoenix::function > _type; phoenix::function > _first; + phoenix::function > _x; + phoenix::function > _y; // karma::real_generator > coordinate; }; diff --git a/include/mapnik/wkt/wkt_grammar.hpp b/include/mapnik/wkt/wkt_grammar.hpp index 5d5c20562..2dd3244d3 100644 --- a/include/mapnik/wkt/wkt_grammar.hpp +++ b/include/mapnik/wkt/wkt_grammar.hpp @@ -71,7 +71,7 @@ namespace mapnik { namespace wkt { void operator() (T path) const { BOOST_ASSERT( path!=0 ); - path->close(); + path->set_close(); } }; diff --git a/plugins/input/shape/shape_io.cpp b/plugins/input/shape/shape_io.cpp index 51c53e9df..12d481fad 100644 --- a/plugins/input/shape/shape_io.cpp +++ b/plugins/input/shape/shape_io.cpp @@ -175,7 +175,8 @@ void shape_io::read_polygon(shape_file::record_type & record, mapnik::geometry_c double x = record.read_double(); double y = record.read_double(); poly->move_to(x, y); - + double start_x = x; + double start_y = y; for (int j=start+1;jclose(x, y); - + if (x == start_x && y == start_y) + { + poly->close(x, y); + } + else + { + poly->line_to(x, y); + } geom.push_back(poly); } } diff --git a/src/wkb.cpp b/src/wkb.cpp index dfef08a69..a43754387 100644 --- a/src/wkb.cpp +++ b/src/wkb.cpp @@ -357,7 +357,18 @@ private: { poly->line_to(ar[j].x, ar[j].y); } - poly->close(ar[num_points-1].x, ar[num_points-1].y); + + if (ar[0].x == ar[num_points-1].x && + ar[0].y == ar[num_points-1].y) + { + poly->close(ar[num_points-1].x, ar[num_points-1].y); + } + else + { + // leave un-closed polygon intact - don't attempt to close them + poly->line_to(ar[num_points-1].x, ar[num_points-1].y); + } + poly->set_close(); } } if (poly->size() > 2) // ignore if polygon has less than 3 vertices @@ -393,7 +404,16 @@ private: { poly->line_to(ar[j].x, ar[j].y); } - poly->close(ar[num_points-1].x, ar[num_points-1].y); + if (ar[0].x == ar[num_points-1].x && + ar[0].y == ar[num_points-1].y) + { + poly->close(ar[num_points-1].x, ar[num_points-1].y); + } + else + { + // leave un-closed polygon intact- don't attempt to close them + poly->line_to(ar[num_points-1].x, ar[num_points-1].y); + } } } if (poly->size() > 2) // ignore if polygon has less than 3 vertices diff --git a/src/wkt/wkt_generator.cpp b/src/wkt/wkt_generator.cpp index 9e04640b1..03900ee4e 100644 --- a/src/wkt/wkt_generator.cpp +++ b/src/wkt/wkt_generator.cpp @@ -62,7 +62,11 @@ wkt_generator::wkt_generator(bool single) using boost::spirit::karma::_1; using boost::spirit::karma::lit; using boost::spirit::karma::_a; + using boost::spirit::karma::_b; + using boost::spirit::karma::_c; using boost::spirit::karma::_r1; + using boost::spirit::karma::_r2; + using boost::spirit::karma::_r3; using boost::spirit::karma::eps; using boost::spirit::karma::string; @@ -92,15 +96,23 @@ wkt_generator::wkt_generator(bool single) point_coord = &uint_ << coordinate << lit(' ') << coordinate ; - polygon_coord %= ( &uint_(mapnik::SEG_MOVETO) << eps[_r1 += 1] + polygon_coord %= ( &uint_(mapnik::SEG_MOVETO) + << eps[_r1 += 1][_a = _r2 = _x(_val)][ _b = _r3 = _y(_val)] << string[ if_ (_r1 > 1) [_1 = "),("] - .else_[_1 = "("] ] | &uint_ << ",") - << coordinate + .else_[_1 = "("]] + | + &uint_(mapnik::SEG_LINETO) + << lit(',') << eps[_a = _x(_val)][_b = _y(_val)] + | + &uint_(mapnik::SEG_CLOSE) + << lit(',') << eps[_a = _r2][_b = _r3] + ) + << coordinate[_1 = _a] << lit(' ') - << coordinate + << coordinate[_1 = _b] ; - coords2 %= *polygon_coord(_a) + coords2 %= *polygon_coord(_a,_b,_c) ; coords = point_coord % lit(',') From e82e5e2fb3717b97e89d2faed365b705ec7a55d4 Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 18 Dec 2012 12:12:43 +0000 Subject: [PATCH 14/15] + default to 6 digit precision in wkt generator for now --- include/mapnik/util/geometry_wkt_generator.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/mapnik/util/geometry_wkt_generator.hpp b/include/mapnik/util/geometry_wkt_generator.hpp index 929168e81..04f25f303 100644 --- a/include/mapnik/util/geometry_wkt_generator.hpp +++ b/include/mapnik/util/geometry_wkt_generator.hpp @@ -147,8 +147,9 @@ struct wkt_coordinate_policy : karma::real_policies static unsigned precision(T n) { if (n == 0.0) return 0; - using namespace boost::spirit; // for traits - return static_cast(15 - boost::math::trunc(log10(traits::get_absolute_value(n)))); + return 6; + //using namespace boost::spirit; // for traits + //return std::max(6u, static_cast(15 - boost::math::trunc(log10(traits::get_absolute_value(n))))); } template From ae69ee9a245b16c1fda55c0002448ad7a85e1387 Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 18 Dec 2012 12:13:42 +0000 Subject: [PATCH 15/15] + update tests to respect new real formatting policies --- tests/python_tests/filter_test.py | 22 +++++++++++++--------- tests/python_tests/geometry_io_test.py | 4 ++-- tests/python_tests/object_test.py | 6 +++--- tests/python_tests/sqlite_rtree_test.py | 2 +- tests/python_tests/sqlite_test.py | 2 +- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/tests/python_tests/filter_test.py b/tests/python_tests/filter_test.py index e2d1f89dd..a30f9a2ce 100644 --- a/tests/python_tests/filter_test.py +++ b/tests/python_tests/filter_test.py @@ -20,9 +20,9 @@ map_ = ''' = 0) + ([region] >= 0) - and + and ([region] <= 50) ]]> @@ -49,7 +49,7 @@ map_ = ''' ''' -def test_filter_init(): +def test_filter_init(): m = mapnik.Map(1,1) mapnik.load_map_from_string(m,map_) filters = [] @@ -74,7 +74,7 @@ def test_filter_init(): 0) and ([region] - <= + <= 50) ''')) @@ -174,13 +174,17 @@ def test_float_precision(): context = mapnik.Context() context.push('num') f = mapnik.Feature(context,0) - f["num"] = 1.0000 - eq_(f["num"],1.0000) - expr = mapnik.Expression("[num] = 1.0000") + f["num1"] = 1.0000 + f["num2"] = 1.0001 + eq_(f["num1"],1.0000) + eq_(f["num2"],1.0001) + expr = mapnik.Expression("[num1] = 1.0000") eq_(expr.evaluate(f),True) - expr = mapnik.Expression("[num].match('.*0$')") + expr = mapnik.Expression("[num1].match('1')") eq_(expr.evaluate(f),True) - expr = mapnik.Expression("[num].match('.*0$')") + expr = mapnik.Expression("[num2] = 1.0001") + eq_(expr.evaluate(f),True) + expr = mapnik.Expression("[num2].match('1.0001')") eq_(expr.evaluate(f),True) def test_string_matching_on_precision(): diff --git a/tests/python_tests/geometry_io_test.py b/tests/python_tests/geometry_io_test.py index f69c7061e..b6def270d 100644 --- a/tests/python_tests/geometry_io_test.py +++ b/tests/python_tests/geometry_io_test.py @@ -14,7 +14,7 @@ def setup(): wkts = [ [1,"POINT(30 10)"], - [1,"POINT(30.0 10.0)"], + [1,"POINT(30 10)"], [1,"POINT(30.1 10.1)"], [1,"LINESTRING(30 10,10 30,40 40)"], [1,"POLYGON((30 10,10 20,20 40,40 40,30 10))"], @@ -61,7 +61,7 @@ wkbs = [ ] geojson = [ -[1,'{"type":"Point","coordinates":[30.0,10.0]}'], +[1,'{"type":"Point","coordinates":[30,10]}'], [1,'{"type":"Point","coordinates":[30.0,10.0]}'], [1,'{"type":"Point","coordinates":[30.1,10.1]}'], [1,'{"type":"LineString","coordinates":[[30.0,10.0],[10.0,30.0],[40.0,40.0]]}'], diff --git a/tests/python_tests/object_test.py b/tests/python_tests/object_test.py index 98ecf8b99..e24034c8f 100644 --- a/tests/python_tests/object_test.py +++ b/tests/python_tests/object_test.py @@ -182,11 +182,11 @@ def test_shield_symbolizer_modify(): def check_transform(expr, expect_str=None): s.transform = expr eq_(s.transform, expr if expect_str is None else expect_str) - check_transform("matrix(1 2 3 4 5 6)", "matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0)") + check_transform("matrix(1 2 3 4 5 6)", "matrix(1, 2, 3, 4, 5, 6)") check_transform("matrix(1, 2, 3, 4, 5, 6 +7)", "matrix(1, 2, 3, 4, 5, (6+7))") check_transform("rotate([a])") check_transform("rotate([a] -2)", "rotate(([a]-2))") - check_transform("rotate([a] -2 -3)", "rotate([a], -2.0, -3.0)") + check_transform("rotate([a] -2 -3)", "rotate([a], -2, -3)") check_transform("rotate([a] -2 -3 -4)", "rotate(((([a]-2)-3)-4))") check_transform("rotate([a] -2, 3, 4)", "rotate(([a]-2), 3, 4)") check_transform("translate([tx]) rotate([a])") @@ -231,7 +231,7 @@ def test_markers_symbolizer(): eq_(p.transform,'') eq_(p.clip,True) eq_(p.comp_op,mapnik.CompositeOp.src_over) - + p.width = mapnik.Expression('12') p.height = mapnik.Expression('12') diff --git a/tests/python_tests/sqlite_rtree_test.py b/tests/python_tests/sqlite_rtree_test.py index c4d45d0ec..f27afb919 100644 --- a/tests/python_tests/sqlite_rtree_test.py +++ b/tests/python_tests/sqlite_rtree_test.py @@ -133,7 +133,7 @@ if 'sqlite' in mapnik.DatasourceCache.plugin_names(): eq_(feat['name'],'test point') geoms = feat.geometries() eq_(len(geoms),1) - eq_(geoms.to_wkt(),'Point(-122.0 48.0)') + eq_(geoms.to_wkt(),'Point(-122 48)') # ensure it matches data read with just sqlite cur = conn.cursor() diff --git a/tests/python_tests/sqlite_test.py b/tests/python_tests/sqlite_test.py index 233dd167c..dc94f1f1e 100644 --- a/tests/python_tests/sqlite_test.py +++ b/tests/python_tests/sqlite_test.py @@ -358,7 +358,7 @@ if 'sqlite' in mapnik.DatasourceCache.plugin_names(): #eq_(feat.id(),1) eq_(feat['alias'],'test') eq_(len(feat.geometries()),1) - eq_(feat.geometries()[0].to_wkt(),'Point(0.0 0.0)') + eq_(feat.geometries()[0].to_wkt(),'Point(0 0)') if __name__ == "__main__": setup()