[mapnik] 01/06: Imported Upstream version 3.0.0+ds

Jérémy Lal kapouer at moszumanska.debian.org
Wed Jul 8 21:02:56 UTC 2015


This is an automated email from the git hooks/post-receive script.

kapouer pushed a commit to branch master
in repository mapnik.

commit 73a6d10a7416e9225a10c35e2322c6e4586753cf
Author: Jérémy Lal <kapouer at melix.org>
Date:   Wed Jul 8 22:08:31 2015 +0200

    Imported Upstream version 3.0.0+ds
---
 .gitignore                                         |    1 +
 .travis.yml                                        |    4 +-
 CHANGELOG.md                                       |  103 +-
 INSTALL.md                                         |   16 +-
 Makefile                                           |    2 +-
 SConstruct                                         |    5 +-
 benchmark/bench_framework.hpp                      |   11 +-
 benchmark/build.py                                 |    3 +
 benchmark/compare_images.hpp                       |   14 +-
 benchmark/run                                      |   15 +-
 benchmark/test_marker_cache.cpp                    |   42 +
 benchmark/test_offset_converter.cpp                |  101 +
 benchmark/test_polygon_clipping.cpp                |   14 +-
 benchmark/test_proj_transform1.cpp                 |    9 +-
 benchmark/test_quad_tree.cpp                       |   54 +
 bootstrap.sh                                       |    2 +-
 demo/c++/build.py                                  |    4 +-
 demo/c++/rundemo.cpp                               |    2 +-
 demo/viewer/about_dialog.cpp                       |    2 +-
 demo/viewer/about_dialog.hpp                       |    2 +-
 demo/viewer/build.py                               |    6 +-
 demo/viewer/info_dialog.cpp                        |    2 +-
 demo/viewer/info_dialog.hpp                        |    2 +-
 demo/viewer/layer_info_dialog.cpp                  |    2 +-
 demo/viewer/layer_info_dialog.hpp                  |    2 +-
 demo/viewer/layerdelegate.cpp                      |    2 +-
 demo/viewer/layerdelegate.hpp                      |    2 +-
 demo/viewer/layerlistmodel.cpp                     |    2 +-
 demo/viewer/layerlistmodel.hpp                     |    2 +-
 demo/viewer/layerwidget.cpp                        |    2 +-
 demo/viewer/layerwidget.hpp                        |    2 +-
 demo/viewer/main.cpp                               |    2 +-
 demo/viewer/mainwindow.cpp                         |    2 +-
 demo/viewer/mainwindow.hpp                         |    2 +-
 demo/viewer/mapwidget.cpp                          |    2 +-
 demo/viewer/mapwidget.hpp                          |    2 +-
 demo/viewer/styles_model.cpp                       |    2 +-
 demo/viewer/styles_model.hpp                       |    2 +-
 deps/agg/build.py                                  |    4 +-
 deps/agg/include/agg_color_gray.h                  |    4 +-
 deps/agg/src/agg_image_filters.cpp                 |    2 +-
 deps/agg/src/agg_pixfmt_rgba.cpp                   |    3 +
 deps/agg/src/agg_trans_single_path.cpp             |    4 +-
 deps/agg/src/agg_vcgen_dash.cpp                    |    4 +-
 deps/clipper/build.py                              |   26 -
 deps/clipper/include/clipper.hpp                   |  411 --
 deps/clipper/src/clipper.cpp                       | 4571 --------------------
 deps/mapnik/build.py                               |    1 -
 docs/{contributing.markdown => contributing.md}    |    0
 docs/{design.markdown => design.md}                |    0
 fonts/build.py                                     |    6 +-
 include/build.py                                   |    2 +-
 include/mapnik/agg_helpers.hpp                     |    2 +-
 include/mapnik/agg_pattern_source.hpp              |    2 +-
 include/mapnik/agg_rasterizer.hpp                  |    2 +-
 include/mapnik/agg_render_marker.hpp               |   25 +-
 include/mapnik/agg_renderer.hpp                    |    2 +-
 include/mapnik/attribute.hpp                       |    2 +-
 include/mapnik/attribute_collector.hpp             |   11 +-
 include/mapnik/attribute_descriptor.hpp            |    2 +-
 include/mapnik/boolean.hpp                         |    2 +-
 include/mapnik/box2d.hpp                           |    2 +-
 include/mapnik/cairo/cairo_context.hpp             |    6 +-
 include/mapnik/cairo/cairo_image_util.hpp          |    4 +-
 include/mapnik/cairo/cairo_render_vector.hpp       |    2 +-
 include/mapnik/cairo/cairo_renderer.hpp            |    4 +-
 include/mapnik/cairo_io.hpp                        |    2 +-
 include/mapnik/color.hpp                           |    2 +-
 include/mapnik/color_factory.hpp                   |    2 +-
 include/mapnik/config.hpp                          |    2 +-
 include/mapnik/config_error.hpp                    |    2 +-
 include/mapnik/coord.hpp                           |    2 +-
 include/mapnik/css_color_grammar.hpp               |   33 +-
 include/mapnik/css_color_grammar_impl.hpp          |    2 +-
 include/mapnik/datasource.hpp                      |    2 +-
 include/mapnik/datasource_cache.hpp                |    5 +-
 include/mapnik/debug.hpp                           |    4 +-
 include/mapnik/ellipsoid.hpp                       |    2 +-
 include/mapnik/enumeration.hpp                     |    2 +-
 include/mapnik/evaluate_global_attributes.hpp      |    2 +-
 include/mapnik/expression.hpp                      |    2 +-
 include/mapnik/expression_evaluator.hpp            |    2 +-
 include/mapnik/expression_grammar.hpp              |    5 +-
 include/mapnik/expression_grammar_impl.hpp         |    2 +-
 include/mapnik/expression_node.hpp                 |   10 +-
 include/mapnik/expression_node_types.hpp           |    2 +-
 include/mapnik/expression_string.hpp               |    2 +-
 include/mapnik/factory.hpp                         |    4 +-
 include/mapnik/feature.hpp                         |    6 +-
 include/mapnik/feature_factory.hpp                 |    2 +-
 include/mapnik/feature_kv_iterator.hpp             |    2 +-
 include/mapnik/feature_layer_desc.hpp              |    2 +-
 include/mapnik/feature_style_processor.hpp         |    2 +-
 include/mapnik/feature_style_processor_context.hpp |    2 +-
 include/mapnik/feature_style_processor_impl.hpp    |    6 +-
 include/mapnik/feature_type_style.hpp              |    2 +-
 include/mapnik/featureset.hpp                      |    2 +-
 include/mapnik/filter_featureset.hpp               |    2 +-
 include/mapnik/font_engine_freetype.hpp            |    2 +-
 include/mapnik/font_set.hpp                        |    2 +-
 include/mapnik/function_call.hpp                   |    2 +-
 include/mapnik/geom_util.hpp                       |    2 +-
 include/mapnik/geometry.hpp                        |   37 +-
 include/mapnik/geometry_adapters.hpp               |    4 +
 include/mapnik/geometry_centroid.hpp               |    2 +-
 include/mapnik/geometry_correct.hpp                |    5 +-
 include/mapnik/geometry_reprojection.hpp           |    2 +-
 include/mapnik/geometry_reprojection_impl.hpp      |    6 +-
 include/mapnik/geometry_transform.hpp              |   24 +-
 include/mapnik/global.hpp                          |    2 +-
 include/mapnik/gradient.hpp                        |    2 +-
 include/mapnik/grid/grid.hpp                       |   11 +-
 include/mapnik/grid/grid_pixel.hpp                 |    2 +-
 include/mapnik/grid/grid_pixfmt.hpp                |   10 +-
 include/mapnik/grid/grid_rasterizer.hpp            |    2 +-
 include/mapnik/grid/grid_render_marker.hpp         |    2 +-
 include/mapnik/grid/grid_renderer.hpp              |    2 +-
 include/mapnik/grid/grid_renderer_base.hpp         |    9 +-
 include/mapnik/grid/grid_rendering_buffer.hpp      |    2 +-
 include/mapnik/grid/grid_util.hpp                  |    2 +-
 include/mapnik/grid/grid_view.hpp                  |    2 +-
 include/mapnik/group/group_layout.hpp              |    2 +-
 include/mapnik/group/group_layout_manager.hpp      |    2 +-
 include/mapnik/group/group_rule.hpp                |    2 +-
 include/mapnik/group/group_symbolizer_helper.hpp   |    2 +-
 .../mapnik/group/group_symbolizer_properties.hpp   |    2 +-
 include/mapnik/hextree.hpp                         |    2 +-
 include/mapnik/hit_test_filter.hpp                 |    2 +-
 include/mapnik/image.hpp                           |    2 +-
 include/mapnik/image_any.hpp                       |    2 +-
 include/mapnik/image_compositing.hpp               |    2 +-
 include/mapnik/image_copy.hpp                      |    2 +-
 include/mapnik/image_filter.hpp                    |   83 +-
 include/mapnik/image_filter_grammar.hpp            |    5 +-
 include/mapnik/image_filter_grammar_impl.hpp       |    5 +-
 include/mapnik/image_filter_types.hpp              |    2 +-
 include/mapnik/image_impl.hpp                      |    2 +-
 include/mapnik/image_null.hpp                      |   36 +-
 include/mapnik/image_reader.hpp                    |    2 +-
 include/mapnik/image_scaling.hpp                   |    2 +-
 include/mapnik/image_scaling_traits.hpp            |    2 +-
 include/mapnik/image_util.hpp                      |   11 +-
 include/mapnik/image_util_jpeg.hpp                 |    2 +-
 include/mapnik/image_util_png.hpp                  |    4 +-
 include/mapnik/image_util_tiff.hpp                 |    2 +-
 include/mapnik/image_util_webp.hpp                 |    2 +-
 include/mapnik/image_view.hpp                      |    2 +-
 include/mapnik/image_view_any.hpp                  |    2 +-
 include/mapnik/image_view_impl.hpp                 |    2 +-
 include/mapnik/image_view_null.hpp                 |   16 +-
 include/mapnik/internal/dump_xml.hpp               |   34 -
 include/mapnik/jpeg_io.hpp                         |    2 +-
 include/mapnik/json/error_handler.hpp              |    5 +-
 .../mapnik/json/extract_bounding_box_grammar.hpp   |    3 +
 include/mapnik/json/feature_collection_grammar.hpp |    2 +-
 .../json/feature_collection_grammar_impl.hpp       |    2 +-
 include/mapnik/json/feature_generator.hpp          |    2 +-
 include/mapnik/json/feature_generator_grammar.hpp  |    6 +-
 .../mapnik/json/feature_generator_grammar_impl.hpp |    2 +-
 include/mapnik/json/feature_grammar.hpp            |    7 +-
 include/mapnik/json/feature_grammar_impl.hpp       |    2 +-
 include/mapnik/json/feature_parser.hpp             |    2 +-
 include/mapnik/json/generic_json.hpp               |    5 +-
 include/mapnik/json/geometry_generator_grammar.hpp |    5 +-
 include/mapnik/json/geometry_grammar.hpp           |    2 +-
 include/mapnik/json/geometry_grammar_impl.hpp      |    2 +-
 include/mapnik/json/geometry_parser.hpp            |    2 +-
 include/mapnik/json/geometry_util.hpp              |    2 +-
 include/mapnik/json/positions_grammar.hpp          |    5 +-
 include/mapnik/json/positions_grammar_impl.hpp     |    2 +-
 .../mapnik/json/properties_generator_grammar.hpp   |    9 +-
 .../json/properties_generator_grammar_impl.hpp     |    2 +-
 include/mapnik/json/symbolizer_grammar.hpp         |    2 +-
 include/mapnik/json/topojson_grammar.hpp           |    5 +-
 include/mapnik/json/topojson_grammar_impl.hpp      |    2 +-
 include/mapnik/json/topojson_utils.hpp             |   10 +-
 include/mapnik/json/topology.hpp                   |    5 +-
 include/mapnik/json/value_converters.hpp           |    2 +-
 include/mapnik/label_collision_detector.hpp        |   12 +-
 include/mapnik/layer.hpp                           |    2 +-
 include/mapnik/load_map.hpp                        |    2 +-
 include/mapnik/make_unique.hpp                     |    2 +-
 include/mapnik/map.hpp                             |    2 +-
 include/mapnik/mapped_memory_cache.hpp             |    4 +-
 include/mapnik/marker.hpp                          |   28 +-
 include/mapnik/marker_cache.hpp                    |   12 +-
 include/mapnik/marker_helpers.hpp                  |    7 +-
 include/mapnik/markers_placement.hpp               |    2 +-
 include/mapnik/markers_placements/interior.hpp     |    2 +-
 include/mapnik/markers_placements/line.hpp         |    2 +-
 include/mapnik/markers_placements/point.hpp        |    2 +-
 .../mapnik/markers_placements/vertext_first.hpp    |    2 +-
 include/mapnik/markers_placements/vertext_last.hpp |    2 +-
 include/mapnik/memory.hpp                          |   86 -
 include/mapnik/memory_datasource.hpp               |    2 +-
 include/mapnik/memory_featureset.hpp               |    2 +-
 include/mapnik/miniz_png.hpp                       |    2 +-
 include/mapnik/octree.hpp                          |    2 +-
 include/mapnik/offset_converter.hpp                |  313 +-
 include/mapnik/palette.hpp                         |   13 +-
 include/mapnik/params.hpp                          |    2 +-
 include/mapnik/params_impl.hpp                     |   11 +-
 include/mapnik/parse_path.hpp                      |    2 +-
 include/mapnik/parse_transform.hpp                 |    2 +-
 include/mapnik/path.hpp                            |    4 +-
 include/mapnik/path_expression.hpp                 |    2 +-
 include/mapnik/path_expression_grammar.hpp         |    5 +-
 include/mapnik/path_expression_grammar_impl.hpp    |    2 +-
 include/mapnik/pixel_position.hpp                  |    2 +-
 include/mapnik/pixel_types.hpp                     |    2 +-
 include/mapnik/plugin.hpp                          |    2 +-
 include/mapnik/png_io.hpp                          |    2 +-
 include/mapnik/pool.hpp                            |    4 +-
 include/mapnik/proj_strategy.hpp                   |    9 +-
 include/mapnik/proj_transform.hpp                  |    2 +-
 include/mapnik/projection.hpp                      |    2 +-
 include/mapnik/ptree_helpers.hpp                   |    2 +-
 include/mapnik/quad_tree.hpp                       |   41 +-
 include/mapnik/query.hpp                           |    2 +-
 include/mapnik/raster.hpp                          |    2 +-
 include/mapnik/raster_colorizer.hpp                |    2 +-
 include/mapnik/renderer_common.hpp                 |    2 +-
 include/mapnik/renderer_common/clipping_extent.hpp |    2 +-
 .../mapnik/renderer_common/pattern_alignment.hpp   |    2 +-
 .../process_building_symbolizer.hpp                |    2 +-
 .../renderer_common/process_group_symbolizer.hpp   |   44 +-
 .../renderer_common/process_markers_symbolizer.hpp |   10 +-
 .../renderer_common/process_point_symbolizer.hpp   |   18 +-
 .../renderer_common/process_polygon_symbolizer.hpp |    2 +-
 .../renderer_common/process_raster_symbolizer.hpp  |   66 +-
 include/mapnik/renderer_common/render_pattern.hpp  |    2 +-
 include/mapnik/request.hpp                         |    2 +-
 include/mapnik/rule.hpp                            |    2 +-
 include/mapnik/rule_cache.hpp                      |    2 +-
 include/mapnik/safe_cast.hpp                       |  154 +
 include/mapnik/save_map.hpp                        |    2 +-
 include/mapnik/scale_denominator.hpp               |    2 +-
 include/mapnik/segment.hpp                         |    2 +-
 include/mapnik/simplify_converter.hpp              |    2 +-
 include/mapnik/span_image_filter.hpp               |    2 +-
 include/mapnik/sql_utils.hpp                       |    5 +-
 include/mapnik/sse.hpp                             |    4 +-
 include/mapnik/svg/geometry_svg_generator.hpp      |    5 +-
 include/mapnik/svg/geometry_svg_generator_impl.hpp |    2 +-
 include/mapnik/svg/output/svg_generator.hpp        |    2 +-
 .../mapnik/svg/output/svg_output_attributes.hpp    |    2 +-
 include/mapnik/svg/output/svg_output_grammars.hpp  |    5 +-
 .../mapnik/svg/output/svg_output_grammars_impl.hpp |    5 +-
 include/mapnik/svg/output/svg_path_iterator.hpp    |    2 +-
 include/mapnik/svg/output/svg_renderer.hpp         |    2 +-
 include/mapnik/svg/svg_converter.hpp               |   11 +-
 include/mapnik/svg/svg_parser.hpp                  |    5 +-
 include/mapnik/svg/svg_path_adapter.hpp            |   18 +-
 include/mapnik/svg/svg_path_attributes.hpp         |    2 +-
 include/mapnik/svg/svg_path_commands.hpp           |    5 +-
 include/mapnik/svg/svg_path_grammar.hpp            |    2 +-
 include/mapnik/svg/svg_path_parser.hpp             |    2 +-
 include/mapnik/svg/svg_points_grammar.hpp          |    2 +-
 include/mapnik/svg/svg_renderer_agg.hpp            |   10 +-
 include/mapnik/svg/svg_storage.hpp                 |    2 +-
 include/mapnik/svg/svg_transform_grammar.hpp       |    5 +-
 include/mapnik/symbolizer.hpp                      |    2 +-
 include/mapnik/symbolizer_base.hpp                 |    2 +-
 include/mapnik/symbolizer_default_values.hpp       |    2 +-
 include/mapnik/symbolizer_dispatch.hpp             |    6 +-
 include/mapnik/symbolizer_enumerations.hpp         |    2 +-
 include/mapnik/symbolizer_hash.hpp                 |    2 +-
 include/mapnik/symbolizer_keys.hpp                 |    2 +-
 include/mapnik/symbolizer_utils.hpp                |    6 +-
 .../text/evaluated_format_properties_ptr.hpp       |    2 +-
 include/mapnik/text/face.hpp                       |    4 +-
 include/mapnik/text/font_feature_settings.hpp      |    2 +-
 include/mapnik/text/font_library.hpp               |    2 +-
 include/mapnik/text/formatting/base.hpp            |    2 +-
 include/mapnik/text/formatting/format.hpp          |    2 +-
 include/mapnik/text/formatting/layout.hpp          |    2 +-
 include/mapnik/text/formatting/list.hpp            |    2 +-
 include/mapnik/text/formatting/registry.hpp        |    4 +-
 include/mapnik/text/formatting/text.hpp            |    2 +-
 include/mapnik/text/glyph_info.hpp                 |    2 +-
 include/mapnik/text/glyph_positions.hpp            |    5 +-
 include/mapnik/text/harfbuzz_shaper.hpp            |   18 +-
 include/mapnik/text/icu_shaper.hpp                 |    2 +-
 include/mapnik/text/itemizer.hpp                   |    6 +-
 include/mapnik/text/placement_finder.hpp           |    8 +-
 include/mapnik/text/placement_finder_impl.hpp      |    2 +-
 include/mapnik/text/placements/base.hpp            |    2 +-
 include/mapnik/text/placements/dummy.hpp           |    2 +-
 include/mapnik/text/placements/list.hpp            |    4 +-
 include/mapnik/text/placements/registry.hpp        |    4 +-
 include/mapnik/text/placements/simple.hpp          |    2 +-
 include/mapnik/text/properties_util.hpp            |    2 +-
 include/mapnik/text/renderer.hpp                   |    2 +-
 include/mapnik/text/scrptrun.hpp                   |   10 +-
 include/mapnik/text/symbolizer_helpers.hpp         |    4 +-
 include/mapnik/text/text_layout.hpp                |    2 +-
 include/mapnik/text/text_line.hpp                  |    2 +-
 include/mapnik/text/text_properties.hpp            |    2 +-
 include/mapnik/tiff_io.hpp                         |    2 +-
 include/mapnik/timer.hpp                           |    2 +-
 include/mapnik/tolerance_iterator.hpp              |    2 +-
 include/mapnik/transform_expression.hpp            |    5 +-
 include/mapnik/transform_expression_grammar.hpp    |    2 +-
 .../mapnik/transform_expression_grammar_impl.hpp   |    2 +-
 include/mapnik/transform_path_adapter.hpp          |    2 +-
 include/mapnik/transform_processor.hpp             |    2 +-
 include/mapnik/unicode.hpp                         |    2 +-
 include/mapnik/util/const_rendering_buffer.hpp     |   58 +
 include/mapnik/util/container_adapter.hpp          |    5 +-
 include/mapnik/util/conversions.hpp                |    2 +-
 include/mapnik/util/dasharray_parser.hpp           |    2 +-
 include/mapnik/util/feature_to_geojson.hpp         |    2 +-
 include/mapnik/util/featureset_buffer.hpp          |    2 +-
 include/mapnik/util/file_io.hpp                    |    5 +-
 include/mapnik/util/fs.hpp                         |    2 +-
 include/mapnik/util/geometry_to_ds_type.hpp        |    2 +-
 include/mapnik/util/geometry_to_geojson.hpp        |    2 +-
 include/mapnik/util/geometry_to_svg.hpp            |    2 +-
 include/mapnik/util/geometry_to_wkb.hpp            |   12 +-
 include/mapnik/util/geometry_to_wkt.hpp            |    6 +-
 include/mapnik/util/hsl.hpp                        |    4 +-
 include/mapnik/util/noncopyable.hpp                |    2 +-
 include/mapnik/util/path_iterator.hpp              |    4 +-
 include/mapnik/util/recursive_wrapper.hpp          |    2 +-
 include/mapnik/{utils.hpp => util/singleton.hpp}   |  108 +-
 include/mapnik/util/timer.hpp                      |    2 +-
 include/mapnik/util/trim.hpp                       |    2 +-
 .../mapnik/{save_map.hpp => util/utf_conv_win.hpp} |   19 +-
 include/mapnik/util/variant_io.hpp                 |    2 +-
 include/mapnik/value.hpp                           |   21 +-
 include/mapnik/value_error.hpp                     |    2 +-
 include/mapnik/value_hash.hpp                      |    4 +-
 include/mapnik/value_types.hpp                     |    2 +-
 include/mapnik/version.hpp                         |    4 +-
 include/mapnik/vertex.hpp                          |    2 +-
 include/mapnik/vertex_cache.hpp                    |    4 +-
 include/mapnik/vertex_converters.hpp               |   34 +-
 include/mapnik/vertex_vector.hpp                   |    2 +-
 include/mapnik/view_strategy.hpp                   |   10 +-
 include/mapnik/view_transform.hpp                  |    2 +-
 include/mapnik/warp.hpp                            |    2 +-
 include/mapnik/webp_io.hpp                         |    2 +-
 include/mapnik/well_known_srs.hpp                  |    4 +-
 include/mapnik/wkb.hpp                             |    2 +-
 include/mapnik/wkt/wkt_factory.hpp                 |    2 +-
 include/mapnik/wkt/wkt_generator_grammar.hpp       |   85 +-
 include/mapnik/wkt/wkt_generator_grammar_impl.hpp  |   89 +-
 include/mapnik/wkt/wkt_grammar.hpp                 |    3 +
 include/mapnik/xml_attribute_cast.hpp              |   15 +-
 include/mapnik/xml_loader.hpp                      |   11 +-
 include/mapnik/xml_node.hpp                        |   17 +-
 include/mapnik/xml_tree.hpp                        |    6 +-
 mason_latest.sh                                    |    6 +-
 plugins/input/csv/build.py                         |    2 +-
 plugins/input/csv/csv_datasource.cpp               |   28 +-
 plugins/input/csv/csv_datasource.hpp               |    2 +-
 plugins/input/csv/csv_utils.hpp                    |    3 +-
 plugins/input/gdal/build.py                        |    4 +-
 plugins/input/gdal/gdal_datasource.cpp             |    2 +-
 plugins/input/gdal/gdal_datasource.hpp             |    2 +-
 plugins/input/gdal/gdal_featureset.cpp             |    2 +-
 plugins/input/gdal/gdal_featureset.hpp             |    2 +-
 plugins/input/geojson/build.py                     |    2 +-
 plugins/input/geojson/geojson_datasource.cpp       |   24 +-
 plugins/input/geojson/geojson_datasource.hpp       |    5 +-
 plugins/input/geojson/geojson_featureset.cpp       |    2 +-
 plugins/input/geojson/geojson_featureset.hpp       |    2 +-
 plugins/input/geojson/large_geojson_featureset.cpp |    4 +-
 plugins/input/geojson/large_geojson_featureset.hpp |    2 +-
 plugins/input/occi/build.py                        |    2 +-
 plugins/input/occi/occi_datasource.cpp             |    2 +-
 plugins/input/occi/occi_datasource.hpp             |    2 +-
 plugins/input/occi/occi_featureset.cpp             |    2 +-
 plugins/input/occi/occi_featureset.hpp             |    2 +-
 plugins/input/occi/occi_types.cpp                  |    2 +-
 plugins/input/occi/occi_types.hpp                  |    4 +-
 plugins/input/ogr/build.py                         |    2 +-
 plugins/input/ogr/ogr_converter.cpp                |   10 +-
 plugins/input/ogr/ogr_converter.hpp                |    2 +-
 plugins/input/ogr/ogr_datasource.cpp               |    5 +-
 plugins/input/ogr/ogr_datasource.hpp               |    5 +-
 plugins/input/ogr/ogr_featureset.cpp               |    8 +-
 plugins/input/ogr/ogr_featureset.hpp               |    8 +-
 plugins/input/ogr/ogr_index.hpp                    |    2 +-
 plugins/input/ogr/ogr_index_featureset.cpp         |    6 +-
 plugins/input/ogr/ogr_index_featureset.hpp         |    2 +-
 plugins/input/ogr/ogr_layer_ptr.hpp                |    2 +-
 plugins/input/osm/basiccurl.cpp                    |    2 +-
 plugins/input/osm/build.py                         |    2 +-
 plugins/input/osm/dataset_deliverer.cpp            |    2 +-
 plugins/input/osm/osm.cpp                          |    2 +-
 plugins/input/osm/osm_datasource.cpp               |    2 +-
 plugins/input/osm/osm_datasource.hpp               |    2 +-
 plugins/input/osm/osm_featureset.cpp               |    2 +-
 plugins/input/osm/osm_featureset.hpp               |    2 +-
 plugins/input/pgraster/build.py                    |    2 +-
 plugins/input/pgraster/pgraster_datasource.cpp     |    2 +-
 plugins/input/pgraster/pgraster_datasource.hpp     |    2 +-
 plugins/input/pgraster/pgraster_featureset.cpp     |    2 +-
 plugins/input/pgraster/pgraster_featureset.hpp     |    2 +-
 plugins/input/pgraster/pgraster_wkb_reader.cpp     |   22 +-
 plugins/input/pgraster/pgraster_wkb_reader.hpp     |    2 +-
 plugins/input/postgis/asyncresultset.hpp           |    2 +-
 plugins/input/postgis/build.py                     |    2 +-
 plugins/input/postgis/connection.hpp               |    2 +-
 plugins/input/postgis/connection_manager.hpp       |    4 +-
 plugins/input/postgis/cursorresultset.hpp          |    2 +-
 plugins/input/postgis/numeric2string.hpp           |    2 +-
 plugins/input/postgis/postgis_datasource.cpp       |    2 +-
 plugins/input/postgis/postgis_datasource.hpp       |    2 +-
 plugins/input/postgis/postgis_featureset.cpp       |    2 +-
 plugins/input/postgis/postgis_featureset.hpp       |    2 +-
 plugins/input/postgis/resultset.hpp                |    2 +-
 plugins/input/raster/build.py                      |    2 +-
 plugins/input/raster/raster_datasource.cpp         |    2 +-
 plugins/input/raster/raster_datasource.hpp         |    2 +-
 plugins/input/raster/raster_featureset.cpp         |    2 +-
 plugins/input/raster/raster_featureset.hpp         |    2 +-
 plugins/input/raster/raster_info.cpp               |    2 +-
 plugins/input/raster/raster_info.hpp               |    2 +-
 plugins/input/rasterlite/build.py                  |    2 +-
 plugins/input/rasterlite/rasterlite_datasource.cpp |    2 +-
 plugins/input/rasterlite/rasterlite_datasource.hpp |    2 +-
 plugins/input/rasterlite/rasterlite_featureset.cpp |    2 +-
 plugins/input/rasterlite/rasterlite_featureset.hpp |    2 +-
 plugins/input/rasterlite/rasterlite_include.hpp    |    2 +-
 plugins/input/shape/build.py                       |    2 +-
 plugins/input/shape/dbf_test.cpp                   |    2 +-
 plugins/input/shape/dbfile.cpp                     |   13 +-
 plugins/input/shape/dbfile.hpp                     |   10 +-
 plugins/input/shape/shape_datasource.cpp           |    4 +-
 plugins/input/shape/shape_datasource.hpp           |    2 +-
 plugins/input/shape/shape_featureset.cpp           |    2 +-
 plugins/input/shape/shape_featureset.hpp           |    2 +-
 plugins/input/shape/shape_index_featureset.cpp     |    2 +-
 plugins/input/shape/shape_index_featureset.hpp     |    2 +-
 plugins/input/shape/shape_io.cpp                   |   29 +-
 plugins/input/shape/shape_io.hpp                   |    2 +-
 plugins/input/shape/shape_utils.cpp                |    2 +-
 plugins/input/shape/shape_utils.hpp                |    2 +-
 plugins/input/shape/shapefile.hpp                  |   16 +-
 plugins/input/shape/shp_index.hpp                  |    2 +-
 plugins/input/sqlite/build.py                      |    2 +-
 plugins/input/sqlite/sqlite_connection.hpp         |    2 +-
 plugins/input/sqlite/sqlite_datasource.cpp         |    2 +-
 plugins/input/sqlite/sqlite_datasource.hpp         |    2 +-
 plugins/input/sqlite/sqlite_featureset.cpp         |    2 +-
 plugins/input/sqlite/sqlite_featureset.hpp         |    2 +-
 plugins/input/sqlite/sqlite_prepared.hpp           |    2 +-
 plugins/input/sqlite/sqlite_resultset.hpp          |    2 +-
 plugins/input/sqlite/sqlite_utils.hpp              |    3 +-
 plugins/input/topojson/build.py                    |    2 +-
 plugins/input/topojson/topojson_datasource.cpp     |    2 +-
 plugins/input/topojson/topojson_datasource.hpp     |    5 +-
 plugins/input/topojson/topojson_featureset.cpp     |   18 +-
 plugins/input/topojson/topojson_featureset.hpp     |    2 +-
 src/agg/agg_renderer.cpp                           |   14 +-
 src/agg/process_building_symbolizer.cpp            |    2 +-
 src/agg/process_debug_symbolizer.cpp               |   16 +-
 src/agg/process_dot_symbolizer.cpp                 |    8 +-
 src/agg/process_group_symbolizer.cpp               |    4 +-
 src/agg/process_line_pattern_symbolizer.cpp        |   19 +-
 src/agg/process_line_symbolizer.cpp                |   26 +-
 src/agg/process_markers_symbolizer.cpp             |    2 +-
 src/agg/process_point_symbolizer.cpp               |    2 +-
 src/agg/process_polygon_pattern_symbolizer.cpp     |    2 +-
 src/agg/process_polygon_symbolizer.cpp             |    2 +-
 src/agg/process_raster_symbolizer.cpp              |    4 +-
 src/agg/process_shield_symbolizer.cpp              |    4 +-
 src/agg/process_text_symbolizer.cpp                |   18 +-
 src/box2d.cpp                                      |   13 +-
 src/build.py                                       |    9 +-
 src/cairo/cairo_context.cpp                        |   26 +-
 src/cairo/cairo_render_vector.cpp                  |    2 +-
 src/cairo/cairo_renderer.cpp                       |   18 +-
 src/cairo/process_building_symbolizer.cpp          |    2 +-
 src/cairo/process_debug_symbolizer.cpp             |    8 +-
 src/cairo/process_group_symbolizer.cpp             |    4 +-
 src/cairo/process_line_pattern_symbolizer.cpp      |   14 +-
 src/cairo/process_line_symbolizer.cpp              |   13 +-
 src/cairo/process_markers_symbolizer.cpp           |    4 +-
 src/cairo/process_point_symbolizer.cpp             |    2 +-
 src/cairo/process_polygon_pattern_symbolizer.cpp   |    2 +-
 src/cairo/process_polygon_symbolizer.cpp           |    2 +-
 src/cairo/process_raster_symbolizer.cpp            |    4 +-
 src/cairo/process_text_symbolizer.cpp              |    6 +-
 src/cairo_io.cpp                                   |    2 +-
 src/color.cpp                                      |    5 +-
 src/color_factory.cpp                              |    2 +-
 src/conversions.cpp                                |    5 +-
 src/css_color_grammar.cpp                          |    2 +-
 src/dasharray_parser.cpp                           |    4 +-
 src/datasource_cache.cpp                           |    3 +-
 src/datasource_cache_static.cpp                    |    6 +-
 src/debug.cpp                                      |    2 +-
 src/expression.cpp                                 |    2 +-
 src/expression_grammar.cpp                         |    2 +-
 src/expression_node.cpp                            |   10 +-
 src/expression_string.cpp                          |    2 +-
 src/feature_kv_iterator.cpp                        |    2 +-
 src/feature_style_processor.cpp                    |    2 +-
 src/feature_type_style.cpp                         |    2 +-
 src/font_engine_freetype.cpp                       |   10 +-
 src/font_set.cpp                                   |    2 +-
 src/fs.cpp                                         |    4 +-
 src/function_call.cpp                              |    2 +-
 src/geometry_reprojection.cpp                      |    2 +-
 src/gradient.cpp                                   |    2 +-
 src/grid/grid.cpp                                  |    2 +-
 src/grid/grid_renderer.cpp                         |   22 +-
 src/grid/process_building_symbolizer.cpp           |    2 +-
 src/grid/process_group_symbolizer.cpp              |    6 +-
 src/grid/process_line_pattern_symbolizer.cpp       |    9 +-
 src/grid/process_line_symbolizer.cpp               |   20 +-
 src/grid/process_markers_symbolizer.cpp            |    2 +-
 src/grid/process_point_symbolizer.cpp              |    2 +-
 src/grid/process_polygon_pattern_symbolizer.cpp    |    2 +-
 src/grid/process_polygon_symbolizer.cpp            |    2 +-
 src/grid/process_raster_symbolizer.cpp             |    2 +-
 src/grid/process_shield_symbolizer.cpp             |    4 +-
 src/grid/process_text_symbolizer.cpp               |   19 +-
 src/group/group_layout_manager.cpp                 |    9 +-
 src/group/group_rule.cpp                           |    2 +-
 src/group/group_symbolizer_helper.cpp              |    2 +-
 src/image.cpp                                      |    2 +-
 src/image_any.cpp                                  |   26 +-
 src/image_compositing.cpp                          |   47 +-
 src/image_copy.cpp                                 |   88 +-
 src/image_filter_types.cpp                         |    5 +-
 src/image_options.cpp                              |    8 +
 src/image_reader.cpp                               |    2 +-
 src/image_scaling.cpp                              |    4 +-
 src/image_util.cpp                                 |  215 +-
 src/image_util_jpeg.cpp                            |    2 +-
 src/image_util_png.cpp                             |    4 +-
 src/image_util_tiff.cpp                            |    2 +-
 src/image_util_webp.cpp                            |    2 +-
 src/image_view.cpp                                 |    2 +-
 src/image_view_any.cpp                             |    6 +-
 src/jpeg_reader.cpp                                |    7 +-
 src/json/build.py                                  |    2 +-
 .../mapnik_json_feature_collection_grammar.cpp     |    2 +-
 src/json/mapnik_json_feature_grammar.cpp           |    2 +-
 src/json/mapnik_json_generator_grammar.cpp         |    2 +-
 src/json/mapnik_json_geometry_grammar.cpp          |    2 +-
 src/json/mapnik_topojson_grammar.cpp               |    2 +-
 src/layer.cpp                                      |    2 +-
 src/libxml2_loader.cpp                             |    2 +-
 src/load_map.cpp                                   |   37 +-
 src/map.cpp                                        |    4 +-
 src/mapped_memory_cache.cpp                        |    6 +-
 src/marker_cache.cpp                               |   29 +-
 src/marker_helpers.cpp                             |    3 +-
 src/memory.cpp                                     |   62 -
 src/memory_datasource.cpp                          |    2 +-
 src/miniz_png.cpp                                  |    7 +-
 src/palette.cpp                                    |    2 +-
 src/params.cpp                                     |    2 +-
 src/parse_path.cpp                                 |    2 +-
 src/parse_transform.cpp                            |    2 +-
 src/plugin.cpp                                     |    2 +-
 src/png_reader.cpp                                 |    2 +-
 src/proj_transform.cpp                             |   78 +-
 src/projection.cpp                                 |    3 +-
 src/rapidxml_loader.cpp                            |   10 +-
 src/raster_colorizer.cpp                           |    2 +-
 src/renderer_common.cpp                            |    3 +-
 src/renderer_common/process_group_symbolizer.cpp   |   30 +-
 src/renderer_common/render_pattern.cpp             |    2 +-
 src/request.cpp                                    |    2 +-
 src/rule.cpp                                       |    2 +-
 src/save_map.cpp                                   |   64 +-
 src/scale_denominator.cpp                          |    2 +-
 src/simplify.cpp                                   |    2 +
 src/svg/output/process_line_symbolizer.cpp         |    2 +-
 src/svg/output/process_polygon_symbolizer.cpp      |    4 +-
 src/svg/output/process_symbolizers.cpp             |    8 +-
 src/svg/output/svg_generator.cpp                   |    9 +-
 src/svg/output/svg_output_attributes.cpp           |    2 +-
 src/svg/output/svg_output_grammars.cpp             |    2 +-
 src/svg/output/svg_renderer.cpp                    |    2 +-
 src/svg/svg_parser.cpp                             |    6 +-
 src/svg/svg_path_parser.cpp                        |    2 +-
 src/svg/svg_points_parser.cpp                      |    2 +-
 src/svg/svg_transform_parser.cpp                   |    2 +-
 src/symbolizer.cpp                                 |    2 +-
 src/symbolizer_enumerations.cpp                    |    2 +-
 src/symbolizer_keys.cpp                            |    2 +-
 src/text/face.cpp                                  |    2 +-
 src/text/font_feature_settings.cpp                 |    3 +-
 src/text/font_library.cpp                          |   15 +-
 src/text/formatting/base.cpp                       |    2 +-
 src/text/formatting/format.cpp                     |    2 +-
 src/text/formatting/layout.cpp                     |    2 +-
 src/text/formatting/list.cpp                       |    2 +-
 src/text/formatting/registry.cpp                   |    2 +-
 src/text/formatting/text.cpp                       |    4 +-
 src/text/glyph_positions.cpp                       |    2 +-
 src/text/itemizer.cpp                              |    2 +-
 src/text/placement_finder.cpp                      |   63 +-
 src/text/placements/base.cpp                       |    2 +-
 src/text/placements/dummy.cpp                      |    4 +-
 src/text/placements/list.cpp                       |    6 +-
 src/text/placements/registry.cpp                   |    2 +-
 src/text/placements/simple.cpp                     |    6 +-
 src/text/properties_util.cpp                       |    2 +-
 src/text/renderer.cpp                              |   11 +-
 src/text/symbolizer_helpers.cpp                    |   81 +-
 src/text/text_layout.cpp                           |    6 +-
 src/text/text_line.cpp                             |    4 +-
 src/text/text_properties.cpp                       |    2 +-
 src/tiff_reader.cpp                                |   96 +-
 src/transform_expression.cpp                       |    2 +-
 src/transform_expression_grammar.cpp               |    2 +-
 src/unicode.cpp                                    |    2 +-
 src/{utils.cpp => util/utf_conv_win.cpp}           |    4 +-
 src/vertex_cache.cpp                               |   10 +-
 src/warp.cpp                                       |    2 +-
 src/webp_reader.cpp                                |    2 +-
 src/well_known_srs.cpp                             |    2 +-
 src/wkb.cpp                                        |   48 +-
 src/wkt/build.py                                   |    4 +-
 src/wkt/mapnik_wkt_generator_grammar.cpp           |    6 +-
 src/xml_tree.cpp                                   |    6 +-
 test/{unit/run.cpp => cleanup.hpp}                 |   33 +-
 test/standalone/csv_test.cpp                       | 1032 +++--
 test/unit/color/css_color.cpp                      |   38 +
 test/unit/core/conversions_test.cpp                |   17 +-
 test/unit/core/copy_move_test.cpp                  |  103 +-
 test/unit/core/exceptions_test.cpp                 |    2 +-
 test/unit/geometry/geometry_envelope_test.cpp      |    2 +-
 test/unit/geometry/geometry_reprojection.cpp       |   10 +-
 test/unit/geometry/geometry_strategy_test.cpp      |   30 +-
 test/unit/imaging/image.cpp                        |    1 +
 test/unit/imaging/image_io_test.cpp                |   15 +
 test/unit/imaging/image_painted_test.cpp           |   71 +-
 test/unit/imaging/image_set_pixel.cpp              |   28 +
 test/unit/imaging/tiff_io.cpp                      |    5 +-
 test/unit/numerics/safe_cast.cpp                   |   59 +
 test/unit/projection/proj_transform.cpp            |   88 +-
 test/unit/run.cpp                                  |   27 +-
 test/unit/serialization/xml_parser_trim.cpp        |   45 +
 test/unit/vertex_adapter/line_offset_test.cpp      |   12 +-
 test/unit/vertex_adapter/offset_converter.cpp      |  398 ++
 test/visual/compare_images.hpp                     |   53 -
 test/visual/config.hpp                             |   13 +-
 test/visual/map_sizes_grammar.hpp                  |    2 +
 test/visual/renderer.hpp                           |  117 +-
 test/visual/report.cpp                             |   13 +-
 test/visual/report.hpp                             |    9 +-
 test/visual/run.cpp                                |   62 +-
 test/visual/runner.cpp                             |  143 +-
 test/visual/runner.hpp                             |    7 +-
 utils/geometry_to_wkb/main.cpp                     |    2 +-
 utils/mapnik-config/build.py                       |    6 +-
 utils/ogrindex/build.py                            |    6 +-
 utils/ogrindex/ogrindex.cpp                        |    2 +-
 utils/pgsql2sqlite/build.py                        |    4 +-
 utils/pgsql2sqlite/main.cpp                        |    2 +-
 utils/pgsql2sqlite/pgsql2sqlite.hpp                |    2 +-
 utils/pgsql2sqlite/sqlite.cpp                      |    2 +-
 utils/pgsql2sqlite/sqlite.hpp                      |    2 +-
 utils/shapeindex/build.py                          |    8 +-
 utils/shapeindex/quadtree.hpp                      |    2 +-
 utils/shapeindex/shapeindex.cpp                    |    2 +-
 utils/svg2png/build.py                             |    4 +-
 utils/svg2png/svg2png.cpp                          |    2 +-
 667 files changed, 4429 insertions(+), 8041 deletions(-)

diff --git a/.gitignore b/.gitignore
index 0293fee..9b10ae8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,6 +18,7 @@ bindings/python/mapnik/paths.py
 config.cache
 config.log
 config.py
+mapnik-settings.env
 mason_packages/
 .mason/
 .sconf_temp/
diff --git a/.travis.yml b/.travis.yml
index f5a8d29..c0e2afb 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -67,7 +67,7 @@ script:
      export MASON_VERSION=latest;
      export MASON_LIB_FILE=lib/libmapnik-wkt.a;
      source ./.mason/mason.sh;
-     ./configure PREFIX=${MASON_PREFIX} PATH_REPLACE='' MAPNIK_BUNDLED_SHARE_DIRECTORY=True;
+     ./configure PREFIX=${MASON_PREFIX} PATH_REPLACE='' MAPNIK_BUNDLED_SHARE_DIRECTORY=True RUNTIME_LINK='static';
    else
      ./configure;
    fi
@@ -79,8 +79,6 @@ script:
  - if [[ ${COVERAGE} != true ]]; then
      make bench;
    fi
-
-after_success:
  - if [[ ${MASON_PUBLISH} == true ]]; then
      ./mason_latest.sh build;
      ./mason_latest.sh link;
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 49849e3..2cdd960 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,42 +8,112 @@ For a complete change history, see the git log.
 
 ## 3.0.0
 
-- Added new and experimental `dot` symbolizer for fast rendering of points
+Released: July 7th, 2015
+
+(Packaged from e6891a0)
+
+#### Summary
+
+The 3.0 release is a major milestone for Mapnik and includes many performance and design improvements. The is the first release to provide text shaping using the harfbuzz library. This harfbuzz support unlocks improved rendering and layer for many new languages, particularly SE Asian scripts. The internal storage for working with images and geometries has been made more flexible, faster, and strongly typed. The python bindings that were previously bundled with Mapnik have now been moved  [...]
+
+#### Notice
+
+ - Mapnik 3.0.0 requires a compiler capable of `std=c++11`.
+ - It is highly recommended you use the `clang++` compiler on both OS X and Linux since it has robust c++11 support lower memory requirements.
+
+##### Major Changes
+
 - Improved support for International Text (now uses harfbuzz library for text shaping)
-- Uses latest c++11 features for better performance (especially map loading)
+
+- Uses latest C++11 features for better performance (especially map loading)
+
 - Expressions everywhere: all symbolizer properties can now be data driven expressions (with the exception of `face-name` and `fontset-name` on the `TextSymbolizer`).
+
+- Rewritten geometry storage based on `std::vector` (#2739)
+  - Separate storage of polygon exterior rings and interior rings to allow for more robust clipping of parts.
+  - Enforces consistent winding order per OGC spec (exterior rings are CCW, interior CW)
+  - Reduced memory consumption for layers with many points
+  - Ability to adapt Mapnik geometries to boost::geometry operations (in a zero-copy way)
+  - Ability to have i/o grammars for json/wkt work on geometries rather than paths for better efficiency and simpler code
+
+- Added new and experimental `dot` symbolizer for fast rendering of points
+
 - New functions supported in expressions: `exp`, `sin`, `cos`, `tan`, `atan`, `abs`.
+
 - New constants supported in expressions: `PI`, `DEG_TO_RAD`, `RAD_TO_DEG`
+
+- Added support for a variety of different grayscale images:
+  - `mapnik.imageType.null`
+  - `mapnik.imageType.rgba8`
+  - `mapnik.imageType.gray8`
+  - `mapnik.imageType.gray8s`
+  - `mapnik.imageType.gray16`
+  - `mapnik.imageType.gray16s`
+  - `mapnik.imageType.gray32`
+  - `mapnik.imageType.gray32s`
+  - `mapnik.imageType.gray32f`
+  - `mapnik.imageType.gray64`
+  - `mapnik.imageType.gray64s`
+  - `mapnik.imageType.gray64f`
+
 - Pattern symbolizers now support SVG input and applying transformations on them dynamically
+
 - Experimental / interface may change: `@variables` can be passed to renderer and evaluated in expressions
+
 - Supports being built with clang++ using `-fvisibility=hidden -flto` for smaller binaries
+
 - Supports being built with Visual Studio 2014 CTP #3
+
 - Shield icons are now pixel snapped for crisp rendering
+
 - `MarkersSymbolizer` now supports `avoid-edges`, `offset`, `geometry-transform`, `simplify` for `line` placement and two new `placement` options called `vertex-last` and `vertex-first` to place a single marker at the end or beginning of a path. Also `clip` is now respected when rendering markers on a LineString 
 geometry.
+
 - `TextSymbolizer` now supports `smooth`, `simplify`, `halo-opacity`, `halo-comp-op`, and `halo-transform`
-- `ShieldSymbolizer` now supports `smooth`, `simplify`, `halo-opacity`, `halo-comp-op`, and `halo-transform`
-- New GroupSymbolizer for applying multiple symbolizers in a single layout
 
-Released ...
+- `ShieldSymbolizer` now supports `smooth`, `simplify`, `halo-opacity`, `halo-comp-op`, and `halo-transform`
 
-(Packaged from ...)
+- The `text-transform` property of `TextSymbolizer` now supports `reverse` value to flip direction of text.
 
-Summary: TODO
+- The `TextSymbolizer` now supports `font-feature-settings` for advanced control over Opentype font rendering (https://developer.mozilla.org/en-US/docs/Web/CSS/font-feature-settings)
 
-- PostGIS: Added support for rendering 3D and 4D geometries (previously silently skipped) (#44)
+- New GroupSymbolizer for applying multiple symbolizers in a single layout
 
 - AGG renderer: fixed geometry offsetting to work after smoothing to produce more consistent results (#2202)
 
 - AGG renderer: increased `vertex_dist_epsilon` to ensure nearly coincident points are discarded more readily (#2196)
 
-- GDAL plugin: Added back support for user driven `nodata` on rgb(a) images (#2023)
+- GDAL plugin
+  - Now keeps datasets open for the lifetime of the datasource (rather than per featureset)
+  - Added back support for user driven `nodata` on rgb(a) images (#2023)
+  - Allowed nodata to override alpha band if set on rgba images (#2023)
+  - Added `nodata_tolerance` option to set nearby pixels transparent (has similar effect to the `nearblack` program) (#2023)
+  - At process exit Mapnik core no longer calls `dlclose` on gdal.input (#2716)
+
+- TopoJSON plugin
+  - Now supporting optional `bbox` property on layer
+  - Fixed support for reporting correct `feature.id()`
+  - Now supports `inline` string for passing data from memory
+  - Faster parsing via static initialization of grammars
+  - Fix crash on invalid arc index
+
+- GeoJSON plugin
+  - Now supporting optional `bbox` property on layer
+  - Fixed support for reporting correct `feature.id()`
+  - Now supports `inline` string for passing data from memory
+  - Faster parsing via static initialization of grammars
+
+- SQLite plugin
+  - Fixed support for handling all column types
 
-- GDAL plugin: Allowed nodata to override alpha band if set on rgba images (#2023)
+- CSV Plugin
+  - Added the ability to pass an `extent` in options
 
-- GDAL plugin: Added `nodata_tolerance` option to set nearby pixels transparent (has similar effect to the `nearblack` program) (#2023)
+- PostGIS plugin
+  - Added Async support to  - https://github.com/mapnik/mapnik/wiki/PostGIS-Async
+  - Added support for rendering 3D and 4D geometries (previously silently skipped) (#44)
 
-- Added support for web fonts: .woff format (#2113)
+- Added support for web fonts: `.woff` format (#2113)
 
 - Added missing support for `geometry-transform` in `line-pattern` and `polygon-pattern` symbolizers (#2065)
 
@@ -51,11 +121,9 @@ Summary: TODO
 
 - Upgraded unifont to `unifont-6.3.20131020`
 
-- CSV Plugin: added the ability to pass an `extent` in options
-
 - Fixed crash when rendering to cairo context from python (#2031)
 
-- Moved `label-position-tolerance` from unsigned type to double
+- Moved `label-position-tolerance` from `unsigned` type to `double`
 
 - Added support for more seamless blurring by rendering to a larger internal image to avoid edge effects (#1478)
 
@@ -67,8 +135,6 @@ Summary: TODO
 
 - Added `color-to-alpha` `image-filter` to allow for applying alpha in proportion to color similiarity (#2023)
 
-- Added Async support to PostGIS plugin - https://github.com/mapnik/mapnik/wiki/PostGIS-Async
-
 - Fixed alpha handling bug with `comp-op:dst-over` (#1995)
 
 - Fixed alpha handling bug with building-fill-opacity (#2011)
@@ -133,6 +199,9 @@ are not set. (#1966)
 
 - Added `scale-hsla` image-filter that allows scaling colors in HSL color space. RGB is converted to HSL (hue-saturation-lightness) and then each value (and the original alpha value) is stretched based on the specified scaling values. An example syntax is `scale-hsla(0,1,0,1,0,1,0,1)` which means no change because the full range will be kept (0 for lowest, 1 for highest). Other examples are: 1) `scale-hsla(0,0,0,1,0,1,0,1)` which would force all colors to be red in hue in the same way `s [...]
 
+- The `shapeindex` tool now works correctly with point 3d geometry types
+
+
 ## 2.2.0
 
 Released June 3rd, 2013
diff --git a/INSTALL.md b/INSTALL.md
index 974a280..b88abd2 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -5,17 +5,23 @@ Mapnik runs on Linux, OS X, Windows, and BSD systems.
 To configure and build Mapnik do:
 
 ```bash
-    $ ./configure
-    $ make
+./configure
+make
 ```
 
 To trigger parallel compilation you can pass a JOBS value to make:
 
 ```bash
-    $ JOBS=4 make
+JOBS=4 make
 ```
 
-(Note that compiling Mapnik needs several GBytes of RAM. If you use parallel compilation it needs more.)
+Mapnik needs > 2 GB of RAM to build. If you use parallel compilation it needs more.
+
+If you are on a system with less memory make sure you only build with one JOB:
+
+```bash
+JOBS=1 make
+```
 
 To use a Python interpreter that is not named `python` for your build, do
 something like the following instead:
@@ -178,4 +184,4 @@ tutorials on how to programmatically use Mapnik.
 
 ### Contributers
 
-Read docs/contributing.markdown for resources for getting involved with Mapnik development.
+Read docs/contributing.md for resources for getting involved with Mapnik development.
diff --git a/Makefile b/Makefile
index b86f8fe..ef02f71 100755
--- a/Makefile
+++ b/Makefile
@@ -13,7 +13,7 @@ install:
 	$(PYTHON) scons/scons.py -j$(JOBS) --config=cache --implicit-cache --max-drift=1 install
 
 python:
-	if [[ ! -d ./bindings/python ]]; then git clone git at github.com:mapnik/python-mapnik.git --recursive ./bindings/python; else (cd bindings/python && git pull && git submodule update --init); fi;
+	if [ ! -d ./bindings/python ]; then git clone git at github.com:mapnik/python-mapnik.git --recursive ./bindings/python; else (cd bindings/python && git pull && git submodule update --init); fi;
 	make
 	python bindings/python/test/visual.py -q
 
diff --git a/SConstruct b/SConstruct
index 15b9e82..f4e910b 100644
--- a/SConstruct
+++ b/SConstruct
@@ -1593,7 +1593,6 @@ if not preconfigured:
     # prepend to make sure we link locally
     env.Prepend(CPPPATH = '#deps/agg/include')
     env.Prepend(LIBPATH = '#deps/agg')
-    env.Prepend(CPPPATH = '#deps/clipper/include')
     # prepend deps dir for auxillary headers
     env.Prepend(CPPPATH = '#deps')
 
@@ -1771,8 +1770,8 @@ if not preconfigured:
             env.Append(CPPDEFINES = ndebug_defines)
 
         # Common flags for g++/clang++ CXX compiler.
-        # TODO: clean up code more to make -Wextra -Wsign-compare -Wsign-conversion -Wconversion -Wshadow viable
-        common_cxx_flags = '-Wall %s %s -ftemplate-depth-300 ' % (env['WARNING_CXXFLAGS'], pthread)
+        # TODO: clean up code more to make -Wextra -Wsign-compare -Wsign-conversion -Wconversion viable
+        common_cxx_flags = '-Wall %s %s -ftemplate-depth-300 -Wsign-compare -Wshadow ' % (env['WARNING_CXXFLAGS'], pthread)
 
         if 'clang++' in env['CXX']:
             common_cxx_flags += ' -Wno-unknown-pragmas -Wno-unsequenced '
diff --git a/benchmark/bench_framework.hpp b/benchmark/bench_framework.hpp
index 33c5b0f..52088e4 100644
--- a/benchmark/bench_framework.hpp
+++ b/benchmark/bench_framework.hpp
@@ -4,6 +4,8 @@
 // mapnik
 #include <mapnik/params.hpp>
 #include <mapnik/value_types.hpp>
+#include <mapnik/safe_cast.hpp>
+#include "../test/cleanup.hpp"
 
 // stl
 #include <chrono>
@@ -25,8 +27,8 @@ protected:
 public:
     test_case(mapnik::parameters const& params)
        : params_(params),
-         threads_(*params.get<mapnik::value_integer>("threads",0)),
-         iterations_(*params.get<mapnik::value_integer>("iterations",0))
+         threads_(mapnik::safe_cast<std::size_t>(*params.get<mapnik::value_integer>("threads",0))),
+         iterations_(mapnik::safe_cast<std::size_t>(*params.get<mapnik::value_integer>("iterations",0)))
          {}
     std::size_t threads() const
     {
@@ -66,11 +68,14 @@ void handle_args(int argc, char** argv, mapnik::parameters & params)
             mapnik::parameters params;                  \
             benchmark::handle_args(argc,argv,params);   \
             test_class test_runner(params);             \
-            return run(test_runner,name);               \
+            auto result = run(test_runner,name);        \
+            testing::run_cleanup();                     \
+            return result;                              \
         }                                               \
         catch (std::exception const& ex)                \
         {                                               \
             std::clog << ex.what() << "\n";             \
+            testing::run_cleanup();                     \
             return -1;                                  \
         }                                               \
     }                                                   \
diff --git a/benchmark/build.py b/benchmark/build.py
index e84f421..8b2049e 100644
--- a/benchmark/build.py
+++ b/benchmark/build.py
@@ -43,6 +43,9 @@ benchmarks = [
     "test_font_registration.cpp",
     "test_rendering.cpp",
     "test_rendering_shared_map.cpp",
+    "test_offset_converter.cpp",
+    "test_marker_cache.cpp",
+    "test_quad_tree.cpp",
 #    "test_numeric_cast_vs_static_cast.cpp",
 ]
 for cpp_test in benchmarks:
diff --git a/benchmark/compare_images.hpp b/benchmark/compare_images.hpp
index 8fc6b19..fb0e4ac 100644
--- a/benchmark/compare_images.hpp
+++ b/benchmark/compare_images.hpp
@@ -29,19 +29,7 @@ namespace benchmark {
         image_rgba8 const& dest = util::get<image_rgba8>(desc_any);
         image_rgba8 const& src = util::get<image_rgba8>(src_any);
 
-        unsigned int width = src.width();
-        unsigned int height = src.height();
-        if ((width != dest.width()) || height != dest.height()) return false;
-        for (unsigned int y = 0; y < height; ++y)
-        {
-            const unsigned int* row_from = src.get_row(y);
-            const unsigned int* row_to = dest.get_row(y);
-            for (unsigned int x = 0; x < width; ++x)
-            {
-               if (row_from[x] != row_to[x]) return false;
-            }
-        }
-        return true;
+        return compare(dest, src, 0, true) == 0;
     }
 
 }
diff --git a/benchmark/run b/benchmark/run
index 13e7e49..b17f82a 100755
--- a/benchmark/run
+++ b/benchmark/run
@@ -18,9 +18,10 @@ function run {
 #run test_polygon_clipping 10 1000
 #run test_polygon_clipping_rendering 10 100
 run test_proj_transform1 10 100
-run test_expression_parse 10 10000
-run test_face_ptr_creation 10 10000
-run test_font_registration 10 1000
+run test_expression_parse 10 1000
+run test_face_ptr_creation 10 1000
+run test_font_registration 10 100
+run test_offset_converter 10 1000
 
 ./benchmark/out/test_rendering \
   --name "text rendering" \
@@ -48,3 +49,11 @@ run test_font_registration 10 1000
   --height 600 \
   --iterations 20 \
   --threads 10
+
+./benchmark/out/test_quad_tree \
+  --iterations 10000 \
+  --threads 1
+
+./benchmark/out/test_quad_tree \
+  --iterations 10000 \
+  --threads 10
diff --git a/benchmark/test_marker_cache.cpp b/benchmark/test_marker_cache.cpp
new file mode 100644
index 0000000..03aed7f
--- /dev/null
+++ b/benchmark/test_marker_cache.cpp
@@ -0,0 +1,42 @@
+#include "bench_framework.hpp"
+#include <mapnik/marker_cache.hpp>
+
+class test : public benchmark::test_case
+{
+    std::vector<std::string> images_;
+public:
+    test(mapnik::parameters const& params)
+     : test_case(params),
+       images_{
+          "./test/data/images/dummy.jpg",
+          "./test/data/images/dummy.jpeg",
+          "./test/data/images/dummy.png",
+          "./test/data/images/dummy.tif",
+          "./test/data/images/dummy.tiff",
+          //"./test/data/images/landusepattern.jpeg", // will fail since it is a png
+          //"./test/data/images/xcode-CgBI.png", // will fail since its an invalid png
+          "./test/data/svg/octocat.svg",
+          "./test/data/svg/place-of-worship-24.svg",
+          "./test/data/svg/point_sm.svg",
+          "./test/data/svg/point.svg",
+          "./test/data/svg/airfield-12.svg"
+       } {}
+    bool validate() const
+    {
+        return true;
+    }
+    bool operator()() const
+    {
+        unsigned count = 0;
+        for (std::size_t i=0;i<iterations_;++i) {
+            for (auto filename : images_)
+            {
+                auto marker = mapnik::marker_cache::instance().find(filename,true);
+            }
+            ++count;
+        }
+        return (count == iterations_);
+    }
+};
+
+BENCHMARK(test,"marker cache")
\ No newline at end of file
diff --git a/benchmark/test_offset_converter.cpp b/benchmark/test_offset_converter.cpp
new file mode 100644
index 0000000..4bd3175
--- /dev/null
+++ b/benchmark/test_offset_converter.cpp
@@ -0,0 +1,101 @@
+#include "bench_framework.hpp"
+
+// mapnik
+#include <mapnik/global.hpp>
+#include <mapnik/coord.hpp>
+#include <mapnik/vertex.hpp>
+#include <mapnik/offset_converter.hpp>
+
+struct fake_path
+{
+    using coord_type = std::tuple<double, double, unsigned>;
+    using cont_type = std::vector<coord_type>;
+    cont_type vertices_;
+    cont_type::iterator itr_;
+
+    fake_path(std::initializer_list<double> l)
+        : fake_path(l.begin(), l.size()) {
+    }
+
+    fake_path(std::vector<double> const &v)
+        : fake_path(v.begin(), v.size()) {
+    }
+
+    template <typename Itr>
+    fake_path(Itr itr, size_t sz) {
+        size_t num_coords = sz >> 1;
+        vertices_.reserve(num_coords);
+
+        for (size_t i = 0; i < num_coords; ++i) {
+            double x = *itr++;
+            double y = *itr++;
+            unsigned cmd = (i == 0) ? mapnik::SEG_MOVETO : mapnik::SEG_LINETO;
+            vertices_.push_back(std::make_tuple(x, y, cmd));
+            if (i == num_coords - 1) cmd = mapnik::SEG_END;
+            vertices_.push_back(std::make_tuple(x, y, cmd));
+        }
+        itr_ = vertices_.begin();
+    }
+
+    unsigned vertex(double *x, double *y) {
+        if (itr_ == vertices_.end()) {
+            return mapnik::SEG_END;
+        }
+        *x = std::get<0>(*itr_);
+        *y = std::get<1>(*itr_);
+        unsigned cmd = std::get<2>(*itr_);
+        ++itr_;
+        return cmd;
+    }
+
+    void rewind(unsigned) {
+        itr_ = vertices_.begin();
+    }
+};
+
+class test_offset : public benchmark::test_case
+{
+public:
+    test_offset(mapnik::parameters const& params)
+     : test_case(params) {}
+    bool validate() const
+    {
+        return true;
+    }
+    bool operator()() const
+    {
+        std::vector<double> path;
+        int mysize = 2500;
+        int x1 = 0;
+        path.reserve(mysize*2);
+        for( int i = 0; i < mysize; i++ )
+        {
+            path.push_back( i );
+            path.push_back( 0 );
+        }
+        fake_path fpath(path);
+        for (std::size_t i=0;i<iterations_;++i) {
+            mapnik::offset_converter<fake_path> off_path(fpath);
+            off_path.set_offset(10);
+            unsigned cmd;
+            double x, y;
+            while ((cmd = off_path.vertex(&x, &y)) != mapnik::SEG_END)
+            {
+                x1++;
+            }
+        }
+        return x1 > 0;
+    }
+};
+
+
+int main(int argc, char** argv)
+{
+    mapnik::parameters params;
+    benchmark::handle_args(argc,argv,params);
+    {
+        test_offset test_runner(params);
+        run(test_runner,"offset_test");
+    }
+    return 0;
+}
diff --git a/benchmark/test_polygon_clipping.cpp b/benchmark/test_polygon_clipping.cpp
index 1591fb1..25eacea 100644
--- a/benchmark/test_polygon_clipping.cpp
+++ b/benchmark/test_polygon_clipping.cpp
@@ -19,7 +19,6 @@
 // agg
 #include "agg_conv_clip_polygon.h"
 // clipper
-#include "clipper.hpp"
 #include "agg_path_storage.h"
 // rendering
 #include "agg_basics.h"
@@ -247,10 +246,10 @@ public:
         std::string expect = expected_+".png";
         std::string actual = expected_+"_actual.png";
         mapnik::geometry::multi_polygon<double> mp;
-        for (auto const& geom: result)
+        for (auto const& _geom: result)
         {
             //std::clog << boost::geometry::dsv(geom) << "\n";
-            mp.emplace_back(geom);
+            mp.emplace_back(_geom);
         }
         mapnik::geometry::geometry<double> geom2(mp);
         auto env = mapnik::geometry::envelope(geom2);
@@ -288,9 +287,9 @@ public:
             std::deque<mapnik::geometry::polygon<double> > result;
             boost::geometry::intersection(extent_,poly,result);
             unsigned count = 0;
-            for (auto const& geom : result)
+            for (auto const& _geom : result)
             {
-                mapnik::geometry::polygon_vertex_adapter<double> va(geom);
+                mapnik::geometry::polygon_vertex_adapter<double> va(_geom);
                 unsigned cmd;
                 double x,y;
                 while ((cmd = va.vertex(&x, &y)) != mapnik::SEG_END) {
@@ -307,6 +306,8 @@ public:
     }
 };
 
+/*
+Commented out section because clipper moved out of mapnik core.
 inline void process_polynode_branch(ClipperLib::PolyNode* polynode,
                              mapnik::geometry::multi_polygon<double> & mp)
 {
@@ -491,6 +492,7 @@ public:
         return valid;
     }
 };
+*/
 
 int main(int argc, char** argv)
 {
@@ -518,9 +520,11 @@ int main(int argc, char** argv)
         test3 test_runner(params,wkt_in,clipping_box);
         run(test_runner,"clipping polygon with boost");
     }
+    /*
     {
         test4 test_runner(params,wkt_in,clipping_box);
         run(test_runner,"clipping polygon with clipper_tree");
     }
+    */
     return 0;
 }
diff --git a/benchmark/test_proj_transform1.cpp b/benchmark/test_proj_transform1.cpp
index 38fcf8b..b98a497 100644
--- a/benchmark/test_proj_transform1.cpp
+++ b/benchmark/test_proj_transform1.cpp
@@ -38,15 +38,16 @@ public:
     }
     bool operator()() const
     {
-        for (std::size_t i=0;i<iterations_;++i) {
-            for (int i=-180;i<180;i=i+5)
+        for (std::size_t i=0;i<iterations_;++i)
+        {
+            for (int j=-180;j<180;j=j+5)
             {
-                for (int j=-85;j<85;j=j+5)
+                for (int k=-85;k<85;k=k+5)
                 {
                     mapnik::projection src(src_,defer_proj4_init_);
                     mapnik::projection dest(dest_,defer_proj4_init_);
                     mapnik::proj_transform tr(src,dest);
-                    mapnik::box2d<double> box(i,j,i,j);
+                    mapnik::box2d<double> box(j,k,j,k);
                     if (!tr.forward(box)) throw std::runtime_error("could not transform coords");
                 }
             }
diff --git a/benchmark/test_quad_tree.cpp b/benchmark/test_quad_tree.cpp
new file mode 100644
index 0000000..e3aabac
--- /dev/null
+++ b/benchmark/test_quad_tree.cpp
@@ -0,0 +1,54 @@
+#include "bench_framework.hpp"
+#include <mapnik/quad_tree.hpp>
+#include <random>
+
+using quad_tree_type = mapnik::quad_tree<std::size_t>;
+
+class test : public benchmark::test_case
+{
+public:
+    test(mapnik::parameters const& params)
+     : test_case(params) {}
+
+    bool validate() const
+    {
+        return true;
+    }
+
+    bool operator()() const
+    {
+        std::random_device rd;
+        std::default_random_engine engine(rd());
+        std::uniform_int_distribution<int> uniform_dist(0, 2048);
+        quad_tree_type tree(mapnik::box2d<double>(0,0,2048,2048));
+        //populate
+        for (size_t i = 0; i < iterations_; ++i)
+        {
+            int cx = uniform_dist(engine);
+            int cy = uniform_dist(engine);
+            int sx = 0.2 * uniform_dist(engine);
+            int sy = 0.2 * uniform_dist(engine);
+            mapnik::box2d<double> box(cx - sx,cy - sy, cx + sx, cy + sy);
+            tree.insert(i, box);
+        }
+        // bounding box query
+        std::size_t count=0;
+        for (size_t i = 0; i < iterations_; ++i)
+        {
+            int cx = uniform_dist(engine);
+            int cy = uniform_dist(engine);
+            int sx = 0.4 * uniform_dist(engine);
+            int sy = 0.4 * uniform_dist(engine);
+            mapnik::box2d<double> box(cx - sx,cy - sy, cx + sx, cy + sy);
+            auto itr = tree.query_in_box(box);
+            auto end = tree.query_end();
+            for ( ;itr != end; ++itr)
+            {
+                ++count;
+            }
+        }
+        return true;
+    }
+};
+
+BENCHMARK(test,"quad_tree creation")
diff --git a/bootstrap.sh b/bootstrap.sh
index 695613d..d68daa8 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -61,7 +61,7 @@ function install_mason_deps() {
     install harfbuzz 0.9.40 libharfbuzz &
     install jpeg_turbo 1.4.0 libjpeg &
     install libxml2 2.9.2 libxml2 &
-    install libpng 1.6.16 libpng &
+    install libpng 1.6.17 libpng &
     install webp 0.4.2 libwebp &
     install icu 54.1 &
     install proj 4.8.0 libproj &
diff --git a/demo/c++/build.py b/demo/c++/build.py
index 7eb878f..c059b05 100644
--- a/demo/c++/build.py
+++ b/demo/c++/build.py
@@ -1,7 +1,7 @@
 #
 # This file is part of Mapnik (c++ mapping toolkit)
 #
-# Copyright (C) 2009 Artem Pavlenko, Dane Springmeyer
+# Copyright (C) 2015 Artem Pavlenko, Dane Springmeyer
 #
 # Mapnik is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -17,7 +17,7 @@
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
-# 
+#
 
 import os
 from copy import copy
diff --git a/demo/c++/rundemo.cpp b/demo/c++/rundemo.cpp
index 39614bf..c07bd5c 100644
--- a/demo/c++/rundemo.cpp
+++ b/demo/c++/rundemo.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/demo/viewer/about_dialog.cpp b/demo/viewer/about_dialog.cpp
index 468a298..06f0a96 100644
--- a/demo/viewer/about_dialog.cpp
+++ b/demo/viewer/about_dialog.cpp
@@ -1,6 +1,6 @@
 /* This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * Mapnik is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/demo/viewer/about_dialog.hpp b/demo/viewer/about_dialog.hpp
index b555a6d..6705671 100644
--- a/demo/viewer/about_dialog.hpp
+++ b/demo/viewer/about_dialog.hpp
@@ -1,6 +1,6 @@
 /* This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * Mapnik is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/demo/viewer/build.py b/demo/viewer/build.py
index b60a80b..cbd35f7 100644
--- a/demo/viewer/build.py
+++ b/demo/viewer/build.py
@@ -1,7 +1,7 @@
 #
 # This file is part of Mapnik (c++ mapping toolkit)
 #
-# Copyright (C) 2013 Artem Pavlenko
+# Copyright (C) 2015 Artem Pavlenko
 #
 # Mapnik is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -17,13 +17,13 @@
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
-# 
+#
 
 Import ('env')
 import os
 import platform
 
-lib_dir = os.path.normpath(env['DESTDIR'] + '/' + env['PREFIX'] + '/' + env['LIBDIR_SCHEMA'] + '/mapnik') 
+lib_dir = os.path.normpath(env['DESTDIR'] + '/' + env['PREFIX'] + '/' + env['LIBDIR_SCHEMA'] + '/mapnik')
 
 fonts = 1
 ini_template = '''
diff --git a/demo/viewer/info_dialog.cpp b/demo/viewer/info_dialog.cpp
index 37c243d..304abf8 100644
--- a/demo/viewer/info_dialog.cpp
+++ b/demo/viewer/info_dialog.cpp
@@ -1,6 +1,6 @@
 /* This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * Mapnik is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/demo/viewer/info_dialog.hpp b/demo/viewer/info_dialog.hpp
index 8ac7620..dde4c66 100644
--- a/demo/viewer/info_dialog.hpp
+++ b/demo/viewer/info_dialog.hpp
@@ -1,6 +1,6 @@
 /* This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * Mapnik is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/demo/viewer/layer_info_dialog.cpp b/demo/viewer/layer_info_dialog.cpp
index 6d176e8..23de7e8 100644
--- a/demo/viewer/layer_info_dialog.cpp
+++ b/demo/viewer/layer_info_dialog.cpp
@@ -1,6 +1,6 @@
 /* This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * Mapnik is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/demo/viewer/layer_info_dialog.hpp b/demo/viewer/layer_info_dialog.hpp
index 9cea6e8..efac782 100644
--- a/demo/viewer/layer_info_dialog.hpp
+++ b/demo/viewer/layer_info_dialog.hpp
@@ -1,6 +1,6 @@
 /* This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * Mapnik is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/demo/viewer/layerdelegate.cpp b/demo/viewer/layerdelegate.cpp
index 93b5059..13a1135 100644
--- a/demo/viewer/layerdelegate.cpp
+++ b/demo/viewer/layerdelegate.cpp
@@ -1,6 +1,6 @@
 /* This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * Mapnik is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/demo/viewer/layerdelegate.hpp b/demo/viewer/layerdelegate.hpp
index 53fd8b3..941621d 100644
--- a/demo/viewer/layerdelegate.hpp
+++ b/demo/viewer/layerdelegate.hpp
@@ -1,6 +1,6 @@
 /* This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * Mapnik is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/demo/viewer/layerlistmodel.cpp b/demo/viewer/layerlistmodel.cpp
index fccfdfd..6a4b0bb 100644
--- a/demo/viewer/layerlistmodel.cpp
+++ b/demo/viewer/layerlistmodel.cpp
@@ -1,6 +1,6 @@
 /* This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * Mapnik is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/demo/viewer/layerlistmodel.hpp b/demo/viewer/layerlistmodel.hpp
index cc2b73f..ab838c7 100644
--- a/demo/viewer/layerlistmodel.hpp
+++ b/demo/viewer/layerlistmodel.hpp
@@ -1,6 +1,6 @@
 /* This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * Mapnik is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/demo/viewer/layerwidget.cpp b/demo/viewer/layerwidget.cpp
index 93dea25..58b88a2 100644
--- a/demo/viewer/layerwidget.cpp
+++ b/demo/viewer/layerwidget.cpp
@@ -1,6 +1,6 @@
 /* This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * Mapnik is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/demo/viewer/layerwidget.hpp b/demo/viewer/layerwidget.hpp
index d19a16a..f458ee9 100644
--- a/demo/viewer/layerwidget.hpp
+++ b/demo/viewer/layerwidget.hpp
@@ -1,6 +1,6 @@
 /* This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * Mapnik is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/demo/viewer/main.cpp b/demo/viewer/main.cpp
index da915d3..e806197 100644
--- a/demo/viewer/main.cpp
+++ b/demo/viewer/main.cpp
@@ -1,6 +1,6 @@
 /* This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * Mapnik is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/demo/viewer/mainwindow.cpp b/demo/viewer/mainwindow.cpp
index 442b990..bd80bcf 100644
--- a/demo/viewer/mainwindow.cpp
+++ b/demo/viewer/mainwindow.cpp
@@ -1,6 +1,6 @@
 /* This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * Mapnik is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/demo/viewer/mainwindow.hpp b/demo/viewer/mainwindow.hpp
index d0943dc..260968c 100644
--- a/demo/viewer/mainwindow.hpp
+++ b/demo/viewer/mainwindow.hpp
@@ -1,6 +1,6 @@
 /* This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * Mapnik is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/demo/viewer/mapwidget.cpp b/demo/viewer/mapwidget.cpp
index 0f6c540..efcab89 100644
--- a/demo/viewer/mapwidget.cpp
+++ b/demo/viewer/mapwidget.cpp
@@ -1,6 +1,6 @@
 /* This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * Mapnik is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/demo/viewer/mapwidget.hpp b/demo/viewer/mapwidget.hpp
index 2373d58..cc7964b 100644
--- a/demo/viewer/mapwidget.hpp
+++ b/demo/viewer/mapwidget.hpp
@@ -1,6 +1,6 @@
 /* This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * Mapnik is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/demo/viewer/styles_model.cpp b/demo/viewer/styles_model.cpp
index 5b40e2a..d2b2f70 100644
--- a/demo/viewer/styles_model.cpp
+++ b/demo/viewer/styles_model.cpp
@@ -1,6 +1,6 @@
 /* This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * Mapnik is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/demo/viewer/styles_model.hpp b/demo/viewer/styles_model.hpp
index 407ec59..b6ead4b 100644
--- a/demo/viewer/styles_model.hpp
+++ b/demo/viewer/styles_model.hpp
@@ -1,6 +1,6 @@
 /* This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * Mapnik is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
diff --git a/deps/agg/build.py b/deps/agg/build.py
index 51e6bc8..e6ab9c5 100644
--- a/deps/agg/build.py
+++ b/deps/agg/build.py
@@ -1,7 +1,7 @@
 #
 # This file is part of Mapnik (c++ mapping toolkit)
 #
-# Copyright (C) 2013 Artem Pavlenko
+# Copyright (C) 2015 Artem Pavlenko
 #
 # Mapnik is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -17,7 +17,7 @@
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
-# 
+#
 
 import os
 from glob import glob
diff --git a/deps/agg/include/agg_color_gray.h b/deps/agg/include/agg_color_gray.h
index f2cd0ff..bf300b8 100644
--- a/deps/agg/include/agg_color_gray.h
+++ b/deps/agg/include/agg_color_gray.h
@@ -652,8 +652,8 @@ struct gray16
     //--------------------------------------------------------------------
     self_type& opacity(double a_)
     {
-        if (a_ < 0) a_ = 0;
-        else if(a_ > 1) a_ = 1;
+        if (a_ < 0) a = 0;
+        else if(a_ > 1) a = 1;
         else a = (value_type)uround(a_ * double(base_mask));
         return *this;
     }
diff --git a/deps/agg/src/agg_image_filters.cpp b/deps/agg/src/agg_image_filters.cpp
index 0f6191d..bc3aa97 100644
--- a/deps/agg/src/agg_image_filters.cpp
+++ b/deps/agg/src/agg_image_filters.cpp
@@ -63,7 +63,7 @@ void image_filter_lut::normalize()
 
             if(sum == image_filter_scale) break;
 
-            double k = double(image_filter_scale) / double(sum);
+            double k = (sum > 0) ? double(image_filter_scale) / double(sum) : 1;
             sum = 0;
             for(j = 0; j < m_diameter; j++)
             {
diff --git a/deps/agg/src/agg_pixfmt_rgba.cpp b/deps/agg/src/agg_pixfmt_rgba.cpp
index 05b8734..45e0b19 100644
--- a/deps/agg/src/agg_pixfmt_rgba.cpp
+++ b/deps/agg/src/agg_pixfmt_rgba.cpp
@@ -6,6 +6,9 @@
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wc++11-narrowing"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/gil/gil_all.hpp>
 #include <boost/gil/extension/toolbox/hsv.hpp>
 #include <boost/gil/extension/toolbox/hsl.hpp>
diff --git a/deps/agg/src/agg_trans_single_path.cpp b/deps/agg/src/agg_trans_single_path.cpp
index 57a6cb0..9b1d7cb 100644
--- a/deps/agg/src/agg_trans_single_path.cpp
+++ b/deps/agg/src/agg_trans_single_path.cpp
@@ -91,9 +91,9 @@ void trans_single_path::finalize_path()
         for(i = 0; i < m_src_vertices.size(); i++)
         {
             vertex_dist& v = m_src_vertices[i];
-            double d = v.dist;
+            double dd = v.dist;
             v.dist = dist;
-            dist += d;
+            dist += dd;
         }
         m_kindex = (m_src_vertices.size() - 1) / dist;
         m_status = ready;
diff --git a/deps/agg/src/agg_vcgen_dash.cpp b/deps/agg/src/agg_vcgen_dash.cpp
index 3112390..6bfa5db 100644
--- a/deps/agg/src/agg_vcgen_dash.cpp
+++ b/deps/agg/src/agg_vcgen_dash.cpp
@@ -169,7 +169,7 @@ unsigned vcgen_dash::vertex(double* x, double* y)
         {
             double dash_rest = m_dashes[m_curr_dash] - m_curr_dash_start;
 
-            unsigned cmd = (m_curr_dash & 1) ?
+            unsigned cmd2 = (m_curr_dash & 1) ?
                 path_cmd_move_to :
                 path_cmd_line_to;
 
@@ -217,7 +217,7 @@ unsigned vcgen_dash::vertex(double* x, double* y)
                     }
                 }
             }
-            return cmd;
+            return cmd2;
         }
         break;
 
diff --git a/deps/clipper/build.py b/deps/clipper/build.py
deleted file mode 100644
index 618bd3f..0000000
--- a/deps/clipper/build.py
+++ /dev/null
@@ -1,26 +0,0 @@
-#  This file is part of Mapnik (c++ mapping toolkit)
-#  Copyright (C) 2013 Artem Pavlenko
-#
-#  Mapnik is free software; you can redistribute it and/or
-#  modify it under the terms of the GNU General Public License
-#  as published by the Free Software Foundation; either version 2
-#  of the License, or any later version.
-#
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU General Public License for more details.
-#
-#  You should have received a copy of the GNU General Public License
-#  along with this program; if not, write to the Free Software
-#  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-#
-#
-
-import os
-from glob import glob
-
-Import('env')
-lib_env = env.Clone()
-lib_env.Append(CXXFLAGS='-fPIC')
-lib_env.StaticLibrary('clipper', ['./src/clipper.cpp',], LIBS=[])
diff --git a/deps/clipper/include/clipper.hpp b/deps/clipper/include/clipper.hpp
deleted file mode 100755
index 3b03988..0000000
--- a/deps/clipper/include/clipper.hpp
+++ /dev/null
@@ -1,411 +0,0 @@
-/*******************************************************************************
-*                                                                              *
-* Author    :  Angus Johnson                                                   *
-* Version   :  6.2.9                                                           *
-* Date      :  16 February 2015                                                *
-* Website   :  http://www.angusj.com                                           *
-* Copyright :  Angus Johnson 2010-2015                                         *
-*                                                                              *
-* License:                                                                     *
-* Use, modification & distribution is subject to Boost Software License Ver 1. *
-* http://www.boost.org/LICENSE_1_0.txt                                         *
-*                                                                              *
-* Attributions:                                                                *
-* The code in this library is an extension of Bala Vatti's clipping algorithm: *
-* "A generic solution to polygon clipping"                                     *
-* Communications of the ACM, Vol 35, Issue 7 (July 1992) pp 56-63.             *
-* http://portal.acm.org/citation.cfm?id=129906                                 *
-*                                                                              *
-* Computer graphics and geometric modeling: implementation and algorithms      *
-* By Max K. Agoston                                                            *
-* Springer; 1 edition (January 4, 2005)                                        *
-* http://books.google.com/books?q=vatti+clipping+agoston                       *
-*                                                                              *
-* See also:                                                                    *
-* "Polygon Offsetting by Computing Winding Numbers"                            *
-* Paper no. DETC2005-85513 pp. 565-575                                         *
-* ASME 2005 International Design Engineering Technical Conferences             *
-* and Computers and Information in Engineering Conference (IDETC/CIE2005)      *
-* September 24-28, 2005 , Long Beach, California, USA                          *
-* http://www.me.berkeley.edu/~mcmains/pubs/DAC05OffsetPolygon.pdf              *
-*                                                                              *
-*******************************************************************************/
-
-#ifndef clipper_hpp
-#define clipper_hpp
-
-#include <mapnik/config.hpp>
-#include <mapnik/geometry.hpp>
-
-#define CLIPPER_VERSION "6.2.6"
-
-//use_int32: When enabled 32bit ints are used instead of 64bit ints. This
-//improve performance but coordinate values are limited to the range +/- 46340
-//#define use_int32
-
-//use_xyz: adds a Z member to IntPoint. Adds a minor cost to perfomance.
-//#define use_xyz
-
-//use_lines: Enables line clipping. Adds a very minor cost to performance.
-#define use_lines
-  
-//use_deprecated: Enables temporary support for the obsolete functions
-//#define use_deprecated  
-
-#include <vector>
-#include <list>
-#include <set>
-#include <stdexcept>
-#include <cstring>
-#include <cstdlib>
-#include <ostream>
-#include <functional>
-#include <queue>
-
-namespace ClipperLib {
-
-enum ClipType { ctIntersection, ctUnion, ctDifference, ctXor };
-enum PolyType { ptSubject, ptClip };
-//By far the most widely used winding rules for polygon filling are
-//EvenOdd & NonZero (GDI, GDI+, XLib, OpenGL, Cairo, AGG, Quartz, SVG, Gr32)
-//Others rules include Positive, Negative and ABS_GTR_EQ_TWO (only in OpenGL)
-//see http://glprogramming.com/red/chapter11.html
-enum PolyFillType { pftEvenOdd, pftNonZero, pftPositive, pftNegative };
-
-#ifdef use_int32
-  typedef int cInt;
-  static cInt const loRange = 0x7FFF;
-  static cInt const hiRange = 0x7FFF;
-#else
-  typedef std::int64_t cInt;
-  static cInt const loRange = 0x3FFFFFFF;
-  static cInt const hiRange = 0x3FFFFFFFFFFFFFFFLL;
-  typedef std::int64_t long64;     //used by Int128 class
-  typedef std::uint64_t ulong64;
-
-#endif
-/*
-struct IntPoint {
-  cInt x;
-  cInt y;
-#ifdef use_xyz
-  cInt z;
-  IntPoint(cInt x = 0, cInt y = 0, cInt z = 0): X(x), Y(y), Z(z) {};
-#else
-  IntPoint(cInt x_ = 0, cInt y_ = 0): x(x_), y(y_) {};
-#endif
-
-  friend inline bool operator== (const IntPoint& a, const IntPoint& b)
-  {
-    return a.x == b.x && a.y == b.y;
-  }
-  friend inline bool operator!= (const IntPoint& a, const IntPoint& b)
-  {
-    return a.x != b.x  || a.y != b.y; 
-  }
-};*/
-
-typedef mapnik::geometry::point<cInt> IntPoint;
-
-//------------------------------------------------------------------------------
-
-//typedef std::vector< IntPoint > Path;
-typedef mapnik::geometry::line_string<cInt> Path;
-typedef mapnik::geometry::multi_line_string<cInt> Paths;
-
-inline Path& operator <<(Path& poly, const IntPoint& p) {poly.push_back(p); return poly;}
-inline Paths& operator <<(Paths& polys, const Path& p) {polys.push_back(p); return polys;}
-
-std::ostream& operator <<(std::ostream &s, const IntPoint &p);
-std::ostream& operator <<(std::ostream &s, const Path &p);
-std::ostream& operator <<(std::ostream &s, const Paths &p);
-
-struct DoublePoint
-{
-  double x;
-  double y;
-  DoublePoint(double x_ = 0, double y_ = 0) : x(x_), y(y_) {}
-  DoublePoint(IntPoint ip) : x((double)ip.x), y((double)ip.y) {}
-};
-//------------------------------------------------------------------------------
-
-#ifdef use_xyz
-typedef void (*ZFillCallback)(IntPoint& e1bot, IntPoint& e1top, IntPoint& e2bot, IntPoint& e2top, IntPoint& pt);
-#endif
-
-enum InitOptions {ioReverseSolution = 1, ioStrictlySimple = 2, ioPreserveCollinear = 4};
-enum JoinType {jtSquare, jtRound, jtMiter};
-enum EndType {etClosedPolygon, etClosedLine, etOpenButt, etOpenSquare, etOpenRound};
-
-class PolyNode;
-typedef std::vector< PolyNode* > PolyNodes;
-
-class MAPNIK_DECL PolyNode 
-{ 
-public:
-    PolyNode();
-    virtual ~PolyNode(){};
-    Path Contour;
-    PolyNodes Childs;
-    PolyNode* Parent;
-    PolyNode* GetNext() const;
-    bool IsHole() const;
-    bool IsOpen() const;
-    int ChildCount() const;
-private:
-    unsigned Index; //node index in Parent.Childs
-    bool m_IsOpen;
-    JoinType m_jointype;
-    EndType m_endtype;
-    PolyNode* GetNextSiblingUp() const;
-    void AddChild(PolyNode& child);
-    friend class MAPNIK_DECL Clipper; //to access Index
-    friend class MAPNIK_DECL ClipperOffset; 
-};
-
-class MAPNIK_DECL PolyTree: public PolyNode
-{ 
-public:
-    ~PolyTree(){Clear();};
-    PolyNode* GetFirst() const;
-    void Clear();
-    int Total() const;
-private:
-    PolyNodes AllNodes;
-    friend class MAPNIK_DECL Clipper; //to access AllNodes
-};
-
-MAPNIK_DECL bool Orientation(const Path &poly);
-MAPNIK_DECL double Area(const Path &poly);
-MAPNIK_DECL int PointInPolygon(const IntPoint &pt, const Path &path);
-
-MAPNIK_DECL void SimplifyPolygon(const Path &in_poly, Paths &out_polys, PolyFillType fillType = pftEvenOdd);
-MAPNIK_DECL void SimplifyPolygons(const Paths &in_polys, Paths &out_polys, PolyFillType fillType = pftEvenOdd);
-MAPNIK_DECL void SimplifyPolygons(Paths &polys, PolyFillType fillType = pftEvenOdd);
-
-MAPNIK_DECL void CleanPolygon(const Path& in_poly, Path& out_poly, double distance = 1.415);
-MAPNIK_DECL void CleanPolygon(Path& poly, double distance = 1.415);
-MAPNIK_DECL void CleanPolygons(const Paths& in_polys, Paths& out_polys, double distance = 1.415);
-MAPNIK_DECL void CleanPolygons(Paths& polys, double distance = 1.415);
-
-void MinkowskiSum(const Path& pattern, const Path& path, Paths& solution, bool pathIsClosed);
-void MinkowskiSum(const Path& pattern, const Paths& paths, Paths& solution, bool pathIsClosed);
-void MinkowskiDiff(const Path& poly1, const Path& poly2, Paths& solution);
-
-void PolyTreeToPaths(const PolyTree& polytree, Paths& paths);
-void ClosedPathsFromPolyTree(const PolyTree& polytree, Paths& paths);
-MAPNIK_DECL void OpenPathsFromPolyTree(PolyTree& polytree, Paths& paths);
-
-void ReversePath(Path& p);
-void ReversePaths(Paths& p);
-
-struct IntRect { cInt left; cInt top; cInt right; cInt bottom; };
-
-//enums that are used internally ...
-enum EdgeSide { esLeft = 1, esRight = 2};
-
-//forward declarations (for stuff used internally) ...
-struct TEdge;
-struct IntersectNode;
-struct LocalMinimum;
-struct OutPt;
-struct OutRec;
-struct Join;
-
-typedef std::vector < OutRec* > PolyOutList;
-typedef std::vector < TEdge* > EdgeList;
-typedef std::vector < Join* > JoinList;
-typedef std::vector < IntersectNode* > IntersectList;
-
-//------------------------------------------------------------------------------
-
-//ClipperBase is the ancestor to the Clipper class. It should not be
-//instantiated directly. This class simply abstracts the conversion of sets of
-//polygon coordinates into edge objects that are stored in a LocalMinima list.
-class MAPNIK_DECL ClipperBase
-{
-public:
-  ClipperBase();
-  virtual ~ClipperBase();
-  bool AddPath(const Path &pg, PolyType PolyTyp, bool Closed);
-  bool AddPaths(const Paths &ppg, PolyType PolyTyp, bool Closed);
-  virtual void Clear();
-  IntRect GetBounds();
-  bool PreserveCollinear() {return m_PreserveCollinear;};
-  void PreserveCollinear(bool value) {m_PreserveCollinear = value;};
-protected:
-  void DisposeLocalMinimaList();
-  TEdge* AddBoundsToLML(TEdge *e, bool IsClosed);
-  void PopLocalMinima();
-  virtual void Reset();
-  TEdge* ProcessBound(TEdge* E, bool IsClockwise);
-  TEdge* DescendToMin(TEdge *&E);
-  void AscendToMax(TEdge *&E, bool Appending, bool IsClosed);
-
-  typedef std::vector<LocalMinimum> MinimaList;
-  MinimaList::iterator m_CurrentLM;
-  MinimaList           m_MinimaList;
-
-  bool              m_UseFullRange;
-  EdgeList          m_edges;
-  bool             m_PreserveCollinear;
-  bool             m_HasOpenPaths;
-};
-//------------------------------------------------------------------------------
-
-class MAPNIK_DECL Clipper : public virtual ClipperBase
-{
-public:
-  Clipper(int initOptions = 0);
-  ~Clipper();
-  bool Execute(ClipType clipType,
-      Paths &solution,
-      PolyFillType fillType = pftEvenOdd);
-  bool Execute(ClipType clipType,
-      Paths &solution,
-      PolyFillType subjFillType,
-      PolyFillType clipFillType);
-  bool Execute(ClipType clipType,
-      PolyTree &polytree,
-      PolyFillType fillType = pftEvenOdd);
-  bool Execute(ClipType clipType,
-      PolyTree &polytree,
-      PolyFillType subjFillType,
-      PolyFillType clipFillType);
-  bool ReverseSolution() { return m_ReverseOutput; };
-  void ReverseSolution(bool value) {m_ReverseOutput = value;};
-  bool StrictlySimple() {return m_StrictSimple;};
-  void StrictlySimple(bool value) {m_StrictSimple = value;};
-  //set the callback function for z value filling on intersections (otherwise Z is 0)
-#ifdef use_xyz
-  void ZFillFunction(ZFillCallback zFillFunc);
-#endif
-protected:
-  void Reset();
-  virtual bool ExecuteInternal();
-private:
-  PolyOutList      m_PolyOuts;
-  JoinList         m_Joins;
-  JoinList         m_GhostJoins;
-  IntersectList    m_IntersectList;
-  ClipType         m_ClipType;
-  typedef std::priority_queue<cInt> ScanbeamList;
-  ScanbeamList     m_Scanbeam;
-  typedef std::list<cInt> MaximaList;
-  MaximaList       m_Maxima;
-  TEdge           *m_ActiveEdges;
-  TEdge           *m_SortedEdges;
-  bool             m_ExecuteLocked;
-  PolyFillType     m_ClipFillType;
-  PolyFillType     m_SubjFillType;
-  bool             m_ReverseOutput;
-  bool             m_UsingPolyTree; 
-  bool             m_StrictSimple;
-#ifdef use_xyz
-  ZFillCallback   m_ZFill; //custom callback 
-#endif
-  void SetWindingCount(TEdge& edge);
-  bool IsEvenOddFillType(const TEdge& edge) const;
-  bool IsEvenOddAltFillType(const TEdge& edge) const;
-  void InsertScanbeam(const cInt Y);
-  cInt PopScanbeam();
-  void InsertLocalMinimaIntoAEL(const cInt botY);
-  void InsertEdgeIntoAEL(TEdge *edge, TEdge* startEdge);
-  void AddEdgeToSEL(TEdge *edge);
-  void CopyAELToSEL();
-  void DeleteFromSEL(TEdge *e);
-  void DeleteFromAEL(TEdge *e);
-  void UpdateEdgeIntoAEL(TEdge *&e);
-  void SwapPositionsInSEL(TEdge *edge1, TEdge *edge2);
-  bool IsContributing(const TEdge& edge) const;
-  bool IsTopHorz(const cInt XPos);
-  void SwapPositionsInAEL(TEdge *edge1, TEdge *edge2);
-  void DoMaxima(TEdge *e);
-  void ProcessHorizontals();
-  void ProcessHorizontal(TEdge *horzEdge);
-  void AddLocalMaxPoly(TEdge *e1, TEdge *e2, const IntPoint &pt);
-  OutPt* AddLocalMinPoly(TEdge *e1, TEdge *e2, const IntPoint &pt);
-  OutRec* GetOutRec(int idx);
-  void AppendPolygon(TEdge *e1, TEdge *e2);
-  void IntersectEdges(TEdge *e1, TEdge *e2, IntPoint &pt);
-  OutRec* CreateOutRec();
-  OutPt* AddOutPt(TEdge *e, const IntPoint &pt);
-  OutPt* GetLastOutPt(TEdge *e);
-  void DisposeAllOutRecs();
-  void DisposeOutRec(PolyOutList::size_type index);
-  bool ProcessIntersections(const cInt topY);
-  void BuildIntersectList(const cInt topY);
-  void ProcessIntersectList();
-  void ProcessEdgesAtTopOfScanbeam(const cInt topY);
-  void BuildResult(Paths& polys);
-  void BuildResult2(PolyTree& polytree);
-  void SetHoleState(TEdge *e, OutRec *outrec);
-  void DisposeIntersectNodes();
-  bool FixupIntersectionOrder();
-  void FixupOutPolygon(OutRec &outrec);
-  void FixupOutPolyline(OutRec &outrec);
-  bool IsHole(TEdge *e);
-  bool FindOwnerFromSplitRecs(OutRec &outRec, OutRec *&currOrfl);
-  void FixHoleLinkage(OutRec &outrec);
-  void AddJoin(OutPt *op1, OutPt *op2, const IntPoint offPt);
-  void ClearJoins();
-  void ClearGhostJoins();
-  void AddGhostJoin(OutPt *op, const IntPoint offPt);
-  bool JoinPoints(Join *j, OutRec* outRec1, OutRec* outRec2);
-  void JoinCommonEdges();
-  void DoSimplePolygons();
-  void FixupFirstLefts1(OutRec* OldOutRec, OutRec* NewOutRec);
-  void FixupFirstLefts2(OutRec* OldOutRec, OutRec* NewOutRec);
-#ifdef use_xyz
-  void SetZ(IntPoint& pt, TEdge& e1, TEdge& e2);
-#endif
-};
-//------------------------------------------------------------------------------
-
-class MAPNIK_DECL ClipperOffset 
-{
-public:
-  ClipperOffset(double miterLimit = 2.0, double roundPrecision = 0.25);
-  ~ClipperOffset();
-  void AddPath(const Path& path, JoinType joinType, EndType endType);
-  void AddPaths(const Paths& paths, JoinType joinType, EndType endType);
-  void Execute(Paths& solution, double delta);
-  void Execute(PolyTree& solution, double delta);
-  void Clear();
-  double MiterLimit;
-  double ArcTolerance;
-private:
-  Paths m_destPolys;
-  Path m_srcPoly;
-  Path m_destPoly;
-  std::vector<DoublePoint> m_normals;
-  double m_delta, m_sinA, m_sin, m_cos;
-  double m_miterLim, m_StepsPerRad;
-  IntPoint m_lowest;
-  PolyNode m_polyNodes;
-
-  void FixOrientations();
-  void DoOffset(double delta);
-  void OffsetPoint(int j, int& k, JoinType jointype);
-  void DoSquare(int j, int k);
-  void DoMiter(int j, int k, double r);
-  void DoRound(int j, int k);
-};
-//------------------------------------------------------------------------------
-
-class clipperException : public std::exception
-{
-  public:
-    clipperException(const char* description): m_descr(description) {}
-    virtual ~clipperException() throw() {}
-    virtual const char* what() const throw() {return m_descr.c_str();}
-  private:
-    std::string m_descr;
-};
-//------------------------------------------------------------------------------
-
-} //ClipperLib namespace
-
-#endif //clipper_hpp
-
-
diff --git a/deps/clipper/src/clipper.cpp b/deps/clipper/src/clipper.cpp
deleted file mode 100755
index d515439..0000000
--- a/deps/clipper/src/clipper.cpp
+++ /dev/null
@@ -1,4571 +0,0 @@
-/*******************************************************************************
-*                                                                              *
-* Author    :  Angus Johnson                                                   *
-* Version   :  6.2.9                                                           *
-* Date      :  16 February 2015                                                *
-* Website   :  http://www.angusj.com                                           *
-* Copyright :  Angus Johnson 2010-2015                                         *
-*                                                                              *
-* License:                                                                     *
-* Use, modification & distribution is subject to Boost Software License Ver 1. *
-* http://www.boost.org/LICENSE_1_0.txt                                         *
-*                                                                              *
-* Attributions:                                                                *
-* The code in this library is an extension of Bala Vatti's clipping algorithm: *
-* "A generic solution to polygon clipping"                                     *
-* Communications of the ACM, Vol 35, Issue 7 (July 1992) pp 56-63.             *
-* http://portal.acm.org/citation.cfm?id=129906                                 *
-*                                                                              *
-* Computer graphics and geometric modeling: implementation and algorithms      *
-* By Max K. Agoston                                                            *
-* Springer; 1 edition (January 4, 2005)                                        *
-* http://books.google.com/books?q=vatti+clipping+agoston                       *
-*                                                                              *
-* See also:                                                                    *
-* "Polygon Offsetting by Computing Winding Numbers"                            *
-* Paper no. DETC2005-85513 pp. 565-575                                         *
-* ASME 2005 International Design Engineering Technical Conferences             *
-* and Computers and Information in Engineering Conference (IDETC/CIE2005)      *
-* September 24-28, 2005 , Long Beach, California, USA                          *
-* http://www.me.berkeley.edu/~mcmains/pubs/DAC05OffsetPolygon.pdf              *
-*                                                                              *
-*******************************************************************************/
-
-/*******************************************************************************
-*                                                                              *
-* This is a translation of the Delphi Clipper library and the naming style     *
-* used has retained a Delphi flavour.                                          *
-*                                                                              *
-*******************************************************************************/
-
-#include "clipper.hpp"
-#include <cmath>
-#include <vector>
-#include <algorithm>
-#include <stdexcept>
-#include <cstring>
-#include <cstdlib>
-#include <ostream>
-#include <functional>
-
-namespace ClipperLib {
-
-static double const pi = 3.141592653589793238;
-static double const two_pi = pi *2;
-static double const def_arc_tolerance = 0.25;
-
-enum Direction { dRightToLeft, dLeftToRight };
-
-static int const Unassigned = -1;  //edge not currently 'owning' a solution
-static int const Skip = -2;        //edge that would otherwise close a path
-
-#define HORIZONTAL (-1.0E+40)
-#define TOLERANCE (1.0e-20)
-#define NEAR_ZERO(val) (((val) > -TOLERANCE) && ((val) < TOLERANCE))
-
-struct TEdge {
-  IntPoint Bot;
-  IntPoint Curr;
-  IntPoint Top;
-  IntPoint Delta;
-  double Dx;
-  PolyType PolyTyp;
-  EdgeSide Side;
-  int WindDelta; //1 or -1 depending on winding direction
-  int WindCnt;
-  int WindCnt2; //winding count of the opposite polytype
-  int OutIdx;
-  TEdge *Next;
-  TEdge *Prev;
-  TEdge *NextInLML;
-  TEdge *NextInAEL;
-  TEdge *PrevInAEL;
-  TEdge *NextInSEL;
-  TEdge *PrevInSEL;
-};
-
-struct IntersectNode {
-  TEdge          *Edge1;
-  TEdge          *Edge2;
-  IntPoint        Pt;
-};
-
-struct LocalMinimum {
-  cInt          y;
-  TEdge        *LeftBound;
-  TEdge        *RightBound;
-};
-
-struct OutPt;
-
-struct OutRec {
-  int       Idx;
-  bool      IsHole;
-  bool      IsOpen;
-  OutRec   *FirstLeft;  //see comments in clipper.pas
-  PolyNode *PolyNd;
-  OutPt    *Pts;
-  OutPt    *BottomPt;
-};
-
-struct OutPt {
-  int       Idx;
-  IntPoint  Pt;
-  OutPt    *Next;
-  OutPt    *Prev;
-};
-
-struct Join {
-  OutPt    *OutPt1;
-  OutPt    *OutPt2;
-  IntPoint  OffPt;
-};
-
-struct LocMinSorter
-{
-  inline bool operator()(const LocalMinimum& locMin1, const LocalMinimum& locMin2)
-  {
-    return locMin2.y < locMin1.y;
-  }
-};
-
-//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-
-inline cInt Round(double val)
-{
-  if ((val < 0)) return static_cast<cInt>(val - 0.5); 
-  else return static_cast<cInt>(val + 0.5);
-}
-//------------------------------------------------------------------------------
-
-inline cInt Abs(cInt val)
-{
-  return val < 0 ? -val : val;
-}
-
-//------------------------------------------------------------------------------
-// PolyTree methods ...
-//------------------------------------------------------------------------------
-
-void PolyTree::Clear()
-{
-    for (PolyNodes::size_type i = 0; i < AllNodes.size(); ++i)
-      delete AllNodes[i];
-    AllNodes.resize(0); 
-    Childs.resize(0);
-}
-//------------------------------------------------------------------------------
-
-PolyNode* PolyTree::GetFirst() const
-{
-  if (!Childs.empty())
-      return Childs[0];
-  else
-      return 0;
-}
-//------------------------------------------------------------------------------
-
-int PolyTree::Total() const
-{
-  int result = (int)AllNodes.size();
-  //with negative offsets, ignore the hidden outer polygon ...
-  if (result > 0 && Childs[0] != AllNodes[0]) result--;
-  return result;
-}
-
-//------------------------------------------------------------------------------
-// PolyNode methods ...
-//------------------------------------------------------------------------------
-
-PolyNode::PolyNode(): Childs(), Parent(0), Index(0), m_IsOpen(false)
-{
-}
-//------------------------------------------------------------------------------
-
-int PolyNode::ChildCount() const
-{
-  return (int)Childs.size();
-}
-//------------------------------------------------------------------------------
-
-void PolyNode::AddChild(PolyNode& child)
-{
-  unsigned cnt = (unsigned)Childs.size();
-  Childs.push_back(&child);
-  child.Parent = this;
-  child.Index = cnt;
-}
-//------------------------------------------------------------------------------
-
-PolyNode* PolyNode::GetNext() const
-{ 
-  if (!Childs.empty()) 
-      return Childs[0]; 
-  else
-      return GetNextSiblingUp();    
-}  
-//------------------------------------------------------------------------------
-
-PolyNode* PolyNode::GetNextSiblingUp() const
-{ 
-  if (!Parent) //protects against PolyTree.GetNextSiblingUp()
-      return 0;
-  else if (Index == Parent->Childs.size() - 1)
-      return Parent->GetNextSiblingUp();
-  else
-      return Parent->Childs[Index + 1];
-}  
-//------------------------------------------------------------------------------
-
-bool PolyNode::IsHole() const
-{ 
-  bool result = true;
-  PolyNode* node = Parent;
-  while (node)
-  {
-      result = !result;
-      node = node->Parent;
-  }
-  return result;
-}  
-//------------------------------------------------------------------------------
-
-bool PolyNode::IsOpen() const
-{ 
-  return m_IsOpen;
-}  
-//------------------------------------------------------------------------------
-
-#ifndef use_int32
-
-//------------------------------------------------------------------------------
-// Int128 class (enables safe math on signed 64bit integers)
-// eg Int128 val1((long64)9223372036854775807); //ie 2^63 -1
-//    Int128 val2((long64)9223372036854775807);
-//    Int128 val3 = val1 * val2;
-//    val3.AsString => "85070591730234615847396907784232501249" (8.5e+37)
-//------------------------------------------------------------------------------
-
-class Int128
-{
-  public:
-    ulong64 lo;
-    long64 hi;
-
-    Int128(long64 _lo = 0)
-    {
-      lo = (ulong64)_lo;   
-      if (_lo < 0)  hi = -1; else hi = 0; 
-    }
-
-
-    Int128(const Int128 &val): lo(val.lo), hi(val.hi){}
-
-    Int128(const long64& _hi, const ulong64& _lo): lo(_lo), hi(_hi){}
-    
-    Int128& operator = (const long64 &val)
-    {
-      lo = (ulong64)val;
-      if (val < 0) hi = -1; else hi = 0;
-      return *this;
-    }
-
-    bool operator == (const Int128 &val) const
-      {return (hi == val.hi && lo == val.lo);}
-
-    bool operator != (const Int128 &val) const
-      { return !(*this == val);}
-
-    bool operator > (const Int128 &val) const
-    {
-      if (hi != val.hi)
-        return hi > val.hi;
-      else
-        return lo > val.lo;
-    }
-
-    bool operator < (const Int128 &val) const
-    {
-      if (hi != val.hi)
-        return hi < val.hi;
-      else
-        return lo < val.lo;
-    }
-
-    bool operator >= (const Int128 &val) const
-      { return !(*this < val);}
-
-    bool operator <= (const Int128 &val) const
-      { return !(*this > val);}
-
-    Int128& operator += (const Int128 &rhs)
-    {
-      hi += rhs.hi;
-      lo += rhs.lo;
-      if (lo < rhs.lo) hi++;
-      return *this;
-    }
-
-    Int128 operator + (const Int128 &rhs) const
-    {
-      Int128 result(*this);
-      result+= rhs;
-      return result;
-    }
-
-    Int128& operator -= (const Int128 &rhs)
-    {
-      *this += -rhs;
-      return *this;
-    }
-
-    Int128 operator - (const Int128 &rhs) const
-    {
-      Int128 result(*this);
-      result -= rhs;
-      return result;
-    }
-
-    Int128 operator-() const //unary negation
-    {
-      if (lo == 0)
-        return Int128(-hi, 0);
-      else
-        return Int128(~hi, ~lo + 1);
-    }
-
-    operator double() const
-    {
-      const double shift64 = 18446744073709551616.0; //2^64
-      if (hi < 0)
-      {
-        if (lo == 0) return (double)hi * shift64;
-        else return -(double)(~lo + ~hi * shift64);
-      }
-      else
-        return (double)(lo + hi * shift64);
-    }
-
-};
-//------------------------------------------------------------------------------
-
-Int128 Int128Mul (long64 lhs, long64 rhs)
-{
-  bool negate = (lhs < 0) != (rhs < 0);
-
-  if (lhs < 0) lhs = -lhs;
-  ulong64 int1Hi = ulong64(lhs) >> 32;
-  ulong64 int1Lo = ulong64(lhs & 0xFFFFFFFF);
-
-  if (rhs < 0) rhs = -rhs;
-  ulong64 int2Hi = ulong64(rhs) >> 32;
-  ulong64 int2Lo = ulong64(rhs & 0xFFFFFFFF);
-
-  //nb: see comments in clipper.pas
-  ulong64 a = int1Hi * int2Hi;
-  ulong64 b = int1Lo * int2Lo;
-  ulong64 c = int1Hi * int2Lo + int1Lo * int2Hi;
-
-  Int128 tmp;
-  tmp.hi = long64(a + (c >> 32));
-  tmp.lo = long64(c << 32);
-  tmp.lo += long64(b);
-  if (tmp.lo < b) tmp.hi++;
-  if (negate) tmp = -tmp;
-  return tmp;
-};
-#endif
-
-//------------------------------------------------------------------------------
-// Miscellaneous global functions
-//------------------------------------------------------------------------------
-
-bool Orientation(const Path &poly)
-{
-    return Area(poly) >= 0;
-}
-//------------------------------------------------------------------------------
-
-double Area(const Path &poly)
-{
-  int size = (int)poly.size();
-  if (size < 3) return 0;
-
-  double a = 0;
-  for (int i = 0, j = size -1; i < size; ++i)
-  {
-    a += ((double)poly[j].x + poly[i].x) * ((double)poly[j].y - poly[i].y);
-    j = i;
-  }
-  return -a * 0.5;
-}
-//------------------------------------------------------------------------------
-
-double Area(const OutRec &outRec)
-{
-  OutPt *op = outRec.Pts;
-  if (!op) return 0;
-  double a = 0;
-  do {
-    a +=  (double)(op->Prev->Pt.x + op->Pt.x) * (double)(op->Prev->Pt.y - op->Pt.y);
-    op = op->Next;
-  } while (op != outRec.Pts);
-  return a * 0.5;
-}
-//------------------------------------------------------------------------------
-
-bool PointIsVertex(const IntPoint &Pt, OutPt *pp)
-{
-  OutPt *pp2 = pp;
-  do
-  {
-    if (pp2->Pt == Pt) return true;
-    pp2 = pp2->Next;
-  }
-  while (pp2 != pp);
-  return false;
-}
-//------------------------------------------------------------------------------
-
-//See "The Point in Polygon Problem for Arbitrary Polygons" by Hormann & Agathos
-//http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.88.5498&rep=rep1&type=pdf
-int PointInPolygon(const IntPoint &pt, const Path &path)
-{
-  //returns 0 if false, +1 if true, -1 if pt ON polygon boundary
-  int result = 0;
-  size_t cnt = path.size();
-  if (cnt < 3) return 0;
-  IntPoint ip = path[0];
-  for(size_t i = 1; i <= cnt; ++i)
-  {
-    IntPoint ipNext = (i == cnt ? path[0] : path[i]);
-    if (ipNext.y == pt.y)
-    {
-        if ((ipNext.x == pt.x) || (ip.y == pt.y && 
-          ((ipNext.x > pt.x) == (ip.x < pt.x)))) return -1;
-    }
-    if ((ip.y < pt.y) != (ipNext.y < pt.y))
-    {
-      if (ip.x >= pt.x)
-      {
-        if (ipNext.x > pt.x) result = 1 - result;
-        else
-        {
-          double d = (double)(ip.x - pt.x) * (ipNext.y - pt.y) - 
-            (double)(ipNext.x - pt.x) * (ip.y - pt.y);
-          if (!d) return -1;
-          if ((d > 0) == (ipNext.y > ip.y)) result = 1 - result;
-        }
-      } else
-      {
-        if (ipNext.x > pt.x)
-        {
-          double d = (double)(ip.x - pt.x) * (ipNext.y - pt.y) - 
-            (double)(ipNext.x - pt.x) * (ip.y - pt.y);
-          if (!d) return -1;
-          if ((d > 0) == (ipNext.y > ip.y)) result = 1 - result;
-        }
-      }
-    }
-    ip = ipNext;
-  } 
-  return result;
-}
-//------------------------------------------------------------------------------
-
-int PointInPolygon (const IntPoint &pt, OutPt *op)
-{
-  //returns 0 if false, +1 if true, -1 if pt ON polygon boundary
-  int result = 0;
-  OutPt* startOp = op;
-  for(;;)
-  {
-    if (op->Next->Pt.y == pt.y)
-    {
-        if ((op->Next->Pt.x == pt.x) || (op->Pt.y == pt.y && 
-          ((op->Next->Pt.x > pt.x) == (op->Pt.x < pt.x)))) return -1;
-    }
-    if ((op->Pt.y < pt.y) != (op->Next->Pt.y < pt.y))
-    {
-      if (op->Pt.x >= pt.x)
-      {
-        if (op->Next->Pt.x > pt.x) result = 1 - result;
-        else
-        {
-          double d = (double)(op->Pt.x - pt.x) * (op->Next->Pt.y - pt.y) - 
-            (double)(op->Next->Pt.x - pt.x) * (op->Pt.y - pt.y);
-          if (!d) return -1;
-          if ((d > 0) == (op->Next->Pt.y > op->Pt.y)) result = 1 - result;
-        }
-      } else
-      {
-        if (op->Next->Pt.x > pt.x)
-        {
-          double d = (double)(op->Pt.x - pt.x) * (op->Next->Pt.y - pt.y) - 
-            (double)(op->Next->Pt.x - pt.x) * (op->Pt.y - pt.y);
-          if (!d) return -1;
-          if ((d > 0) == (op->Next->Pt.y > op->Pt.y)) result = 1 - result;
-        }
-      }
-    } 
-    op = op->Next;
-    if (startOp == op) break;
-  } 
-  return result;
-}
-//------------------------------------------------------------------------------
-
-bool Poly2ContainsPoly1(OutPt *OutPt1, OutPt *OutPt2)
-{
-  OutPt* op = OutPt1;
-  do
-  {
-    //nb: PointInPolygon returns 0 if false, +1 if true, -1 if pt on polygon
-    int res = PointInPolygon(op->Pt, OutPt2);
-    if (res >= 0) return res > 0;
-    op = op->Next; 
-  }
-  while (op != OutPt1);
-  return true; 
-}
-//----------------------------------------------------------------------
-
-bool SlopesEqual(const TEdge &e1, const TEdge &e2, bool UseFullInt64Range)
-{
-#ifndef use_int32
-  if (UseFullInt64Range)
-    return Int128Mul(e1.Delta.y, e2.Delta.x) == Int128Mul(e1.Delta.x, e2.Delta.y);
-  else 
-#endif
-    return e1.Delta.y * e2.Delta.x == e1.Delta.x * e2.Delta.y;
-}
-//------------------------------------------------------------------------------
-
-bool SlopesEqual(const IntPoint pt1, const IntPoint pt2,
-  const IntPoint pt3, bool UseFullInt64Range)
-{
-#ifndef use_int32
-  if (UseFullInt64Range)
-    return Int128Mul(pt1.y-pt2.y, pt2.x-pt3.x) == Int128Mul(pt1.x-pt2.x, pt2.y-pt3.y);
-  else 
-#endif
-    return (pt1.y-pt2.y)*(pt2.x-pt3.x) == (pt1.x-pt2.x)*(pt2.y-pt3.y);
-}
-//------------------------------------------------------------------------------
-
-bool SlopesEqual(const IntPoint pt1, const IntPoint pt2,
-  const IntPoint pt3, const IntPoint pt4, bool UseFullInt64Range)
-{
-#ifndef use_int32
-  if (UseFullInt64Range)
-    return Int128Mul(pt1.y-pt2.y, pt3.x-pt4.x) == Int128Mul(pt1.x-pt2.x, pt3.y-pt4.y);
-  else 
-#endif
-    return (pt1.y-pt2.y)*(pt3.x-pt4.x) == (pt1.x-pt2.x)*(pt3.y-pt4.y);
-}
-//------------------------------------------------------------------------------
-
-inline bool IsHorizontal(TEdge &e)
-{
-  return e.Delta.y == 0;
-}
-//------------------------------------------------------------------------------
-
-inline double GetDx(const IntPoint pt1, const IntPoint pt2)
-{
-  return (pt1.y == pt2.y) ?
-    HORIZONTAL : (double)(pt2.x - pt1.x) / (pt2.y - pt1.y);
-}
-//---------------------------------------------------------------------------
-
-inline void SetDx(TEdge &e)
-{
-  e.Delta.x = (e.Top.x - e.Bot.x);
-  e.Delta.y = (e.Top.y - e.Bot.y);
-
-  if (e.Delta.y == 0) e.Dx = HORIZONTAL;
-  else e.Dx = (double)(e.Delta.x) / e.Delta.y;
-}
-//---------------------------------------------------------------------------
-
-inline void SwapSides(TEdge &Edge1, TEdge &Edge2)
-{
-  EdgeSide Side =  Edge1.Side;
-  Edge1.Side = Edge2.Side;
-  Edge2.Side = Side;
-}
-//------------------------------------------------------------------------------
-
-inline void SwapPolyIndexes(TEdge &Edge1, TEdge &Edge2)
-{
-  int OutIdx =  Edge1.OutIdx;
-  Edge1.OutIdx = Edge2.OutIdx;
-  Edge2.OutIdx = OutIdx;
-}
-//------------------------------------------------------------------------------
-
-inline cInt TopX(TEdge &edge, const cInt currentY)
-{
-  return ( currentY == edge.Top.y ) ?
-    edge.Top.x : edge.Bot.x + Round(edge.Dx *(currentY - edge.Bot.y));
-}
-//------------------------------------------------------------------------------
-
-void IntersectPoint(TEdge &Edge1, TEdge &Edge2, IntPoint &ip)
-{
-#ifdef use_xyz  
-  ip.Z = 0;
-#endif
-
-  double b1, b2;
-  if (Edge1.Dx == Edge2.Dx)
-  {
-    ip.y = Edge1.Curr.y;
-    ip.x = TopX(Edge1, ip.y);
-    return;
-  }
-  else if (Edge1.Delta.x == 0)
-  {
-    ip.x = Edge1.Bot.x;
-    if (IsHorizontal(Edge2))
-      ip.y = Edge2.Bot.y;
-    else
-    {
-      b2 = Edge2.Bot.y - (Edge2.Bot.x / Edge2.Dx);
-      ip.y = Round(ip.x / Edge2.Dx + b2);
-    }
-  }
-  else if (Edge2.Delta.x == 0)
-  {
-    ip.x = Edge2.Bot.x;
-    if (IsHorizontal(Edge1))
-      ip.y = Edge1.Bot.y;
-    else
-    {
-      b1 = Edge1.Bot.y - (Edge1.Bot.x / Edge1.Dx);
-      ip.y = Round(ip.x / Edge1.Dx + b1);
-    }
-  } 
-  else 
-  {
-    b1 = Edge1.Bot.x - Edge1.Bot.y * Edge1.Dx;
-    b2 = Edge2.Bot.x - Edge2.Bot.y * Edge2.Dx;
-    double q = (b2-b1) / (Edge1.Dx - Edge2.Dx);
-    ip.y = Round(q);
-    if (std::fabs(Edge1.Dx) < std::fabs(Edge2.Dx))
-      ip.x = Round(Edge1.Dx * q + b1);
-    else 
-      ip.x = Round(Edge2.Dx * q + b2);
-  }
-
-  if (ip.y < Edge1.Top.y || ip.y < Edge2.Top.y) 
-  {
-    if (Edge1.Top.y > Edge2.Top.y)
-      ip.y = Edge1.Top.y;
-    else
-      ip.y = Edge2.Top.y;
-    if (std::fabs(Edge1.Dx) < std::fabs(Edge2.Dx))
-      ip.x = TopX(Edge1, ip.y);
-    else
-      ip.x = TopX(Edge2, ip.y);
-  } 
-  //finally, don't allow 'ip' to be BELOW curr.y (ie bottom of scanbeam) ...
-  if (ip.y > Edge1.Curr.y)
-  {
-    ip.y = Edge1.Curr.y;
-    //use the more vertical edge to derive X ...
-    if (std::fabs(Edge1.Dx) > std::fabs(Edge2.Dx))
-      ip.x = TopX(Edge2, ip.y); else
-      ip.x = TopX(Edge1, ip.y);
-  }
-}
-//------------------------------------------------------------------------------
-
-void ReversePolyPtLinks(OutPt *pp)
-{
-  if (!pp) return;
-  OutPt *pp1, *pp2;
-  pp1 = pp;
-  do {
-  pp2 = pp1->Next;
-  pp1->Next = pp1->Prev;
-  pp1->Prev = pp2;
-  pp1 = pp2;
-  } while( pp1 != pp );
-}
-//------------------------------------------------------------------------------
-
-void DisposeOutPts(OutPt*& pp)
-{
-  if (pp == 0) return;
-    pp->Prev->Next = 0;
-  while( pp )
-  {
-    OutPt *tmpPp = pp;
-    pp = pp->Next;
-    delete tmpPp;
-  }
-}
-//------------------------------------------------------------------------------
-
-inline void InitEdge(TEdge* e, TEdge* eNext, TEdge* ePrev, const IntPoint& Pt)
-{
-  std::memset(e, 0, sizeof(TEdge));
-  e->Next = eNext;
-  e->Prev = ePrev;
-  e->Curr = Pt;
-  e->OutIdx = Unassigned;
-}
-//------------------------------------------------------------------------------
-
-void InitEdge2(TEdge& e, PolyType Pt)
-{
-  if (e.Curr.y >= e.Next->Curr.y)
-  {
-    e.Bot = e.Curr;
-    e.Top = e.Next->Curr;
-  } else
-  {
-    e.Top = e.Curr;
-    e.Bot = e.Next->Curr;
-  }
-  SetDx(e);
-  e.PolyTyp = Pt;
-}
-//------------------------------------------------------------------------------
-
-TEdge* RemoveEdge(TEdge* e)
-{
-  //removes e from double_linked_list (but without removing from memory)
-  e->Prev->Next = e->Next;
-  e->Next->Prev = e->Prev;
-  TEdge* result = e->Next;
-  e->Prev = 0; //flag as removed (see ClipperBase.Clear)
-  return result;
-}
-//------------------------------------------------------------------------------
-
-inline void ReverseHorizontal(TEdge &e)
-{
-  //swap horizontal edges' Top and Bottom x's so they follow the natural
-  //progression of the bounds - ie so their xbots will align with the
-  //adjoining lower edge. [Helpful in the ProcessHorizontal() method.]
-  std::swap(e.Top.x, e.Bot.x);
-#ifdef use_xyz  
-  std::swap(e.Top.Z, e.Bot.Z);
-#endif
-}
-//------------------------------------------------------------------------------
-
-void SwapPoints(IntPoint &pt1, IntPoint &pt2)
-{
-  IntPoint tmp = pt1;
-  pt1 = pt2;
-  pt2 = tmp;
-}
-//------------------------------------------------------------------------------
-
-bool GetOverlapSegment(IntPoint pt1a, IntPoint pt1b, IntPoint pt2a,
-  IntPoint pt2b, IntPoint &pt1, IntPoint &pt2)
-{
-  //precondition: segments are Collinear.
-  if (Abs(pt1a.x - pt1b.x) > Abs(pt1a.y - pt1b.y))
-  {
-    if (pt1a.x > pt1b.x) SwapPoints(pt1a, pt1b);
-    if (pt2a.x > pt2b.x) SwapPoints(pt2a, pt2b);
-    if (pt1a.x > pt2a.x) pt1 = pt1a; else pt1 = pt2a;
-    if (pt1b.x < pt2b.x) pt2 = pt1b; else pt2 = pt2b;
-    return pt1.x < pt2.x;
-  } else
-  {
-    if (pt1a.y < pt1b.y) SwapPoints(pt1a, pt1b);
-    if (pt2a.y < pt2b.y) SwapPoints(pt2a, pt2b);
-    if (pt1a.y < pt2a.y) pt1 = pt1a; else pt1 = pt2a;
-    if (pt1b.y > pt2b.y) pt2 = pt1b; else pt2 = pt2b;
-    return pt1.y > pt2.y;
-  }
-}
-//------------------------------------------------------------------------------
-
-bool FirstIsBottomPt(const OutPt* btmPt1, const OutPt* btmPt2)
-{
-  OutPt *p = btmPt1->Prev;
-  while ((p->Pt == btmPt1->Pt) && (p != btmPt1)) p = p->Prev;
-  double dx1p = std::fabs(GetDx(btmPt1->Pt, p->Pt));
-  p = btmPt1->Next;
-  while ((p->Pt == btmPt1->Pt) && (p != btmPt1)) p = p->Next;
-  double dx1n = std::fabs(GetDx(btmPt1->Pt, p->Pt));
-
-  p = btmPt2->Prev;
-  while ((p->Pt == btmPt2->Pt) && (p != btmPt2)) p = p->Prev;
-  double dx2p = std::fabs(GetDx(btmPt2->Pt, p->Pt));
-  p = btmPt2->Next;
-  while ((p->Pt == btmPt2->Pt) && (p != btmPt2)) p = p->Next;
-  double dx2n = std::fabs(GetDx(btmPt2->Pt, p->Pt));
-  return (dx1p >= dx2p && dx1p >= dx2n) || (dx1n >= dx2p && dx1n >= dx2n);
-}
-//------------------------------------------------------------------------------
-
-OutPt* GetBottomPt(OutPt *pp)
-{
-  OutPt* dups = 0;
-  OutPt* p = pp->Next;
-  while (p != pp)
-  {
-    if (p->Pt.y > pp->Pt.y)
-    {
-      pp = p;
-      dups = 0;
-    }
-    else if (p->Pt.y == pp->Pt.y && p->Pt.x <= pp->Pt.x)
-    {
-      if (p->Pt.x < pp->Pt.x)
-      {
-        dups = 0;
-        pp = p;
-      } else
-      {
-        if (p->Next != pp && p->Prev != pp) dups = p;
-      }
-    }
-    p = p->Next;
-  }
-  if (dups)
-  {
-    //there appears to be at least 2 vertices at BottomPt so ...
-    while (dups != p)
-    {
-      if (!FirstIsBottomPt(p, dups)) pp = dups;
-      dups = dups->Next;
-      while (dups->Pt != pp->Pt) dups = dups->Next;
-    }
-  }
-  return pp;
-}
-//------------------------------------------------------------------------------
-
-bool Pt2IsBetweenPt1AndPt3(const IntPoint pt1,
-  const IntPoint pt2, const IntPoint pt3)
-{
-  if ((pt1 == pt3) || (pt1 == pt2) || (pt3 == pt2))
-    return false;
-  else if (pt1.x != pt3.x)
-    return (pt2.x > pt1.x) == (pt2.x < pt3.x);
-  else
-    return (pt2.y > pt1.y) == (pt2.y < pt3.y);
-}
-//------------------------------------------------------------------------------
-
-bool HorzSegmentsOverlap(cInt seg1a, cInt seg1b, cInt seg2a, cInt seg2b)
-{
-  if (seg1a > seg1b) std::swap(seg1a, seg1b);
-  if (seg2a > seg2b) std::swap(seg2a, seg2b);
-  return (seg1a < seg2b) && (seg2a < seg1b);
-}
-
-//------------------------------------------------------------------------------
-// ClipperBase class methods ...
-//------------------------------------------------------------------------------
-
-ClipperBase::ClipperBase() //constructor
-{
-  m_CurrentLM = m_MinimaList.begin(); //begin() == end() here
-  m_UseFullRange = false;
-}
-//------------------------------------------------------------------------------
-
-ClipperBase::~ClipperBase() //destructor
-{
-  Clear();
-}
-//------------------------------------------------------------------------------
-
-void RangeTest(const IntPoint& Pt, bool& useFullRange)
-{
-  if (useFullRange)
-  {
-    if (Pt.x > hiRange || Pt.y > hiRange || -Pt.x > hiRange || -Pt.y > hiRange) 
-      throw "Coordinate outside allowed range";
-  }
-  else if (Pt.x > loRange|| Pt.y > loRange || -Pt.x > loRange || -Pt.y > loRange) 
-  {
-    useFullRange = true;
-    RangeTest(Pt, useFullRange);
-  }
-}
-//------------------------------------------------------------------------------
-
-TEdge* FindNextLocMin(TEdge* E)
-{
-  for (;;)
-  {
-    while (E->Bot != E->Prev->Bot || E->Curr == E->Top) E = E->Next;
-    if (!IsHorizontal(*E) && !IsHorizontal(*E->Prev)) break;
-    while (IsHorizontal(*E->Prev)) E = E->Prev;
-    TEdge* E2 = E;
-    while (IsHorizontal(*E)) E = E->Next;
-    if (E->Top.y == E->Prev->Bot.y) continue; //ie just an intermediate horz.
-    if (E2->Prev->Bot.x < E->Bot.x) E = E2;
-    break;
-  }
-  return E;
-}
-//------------------------------------------------------------------------------
-
-TEdge* ClipperBase::ProcessBound(TEdge* E, bool NextIsForward)
-{
-  TEdge *Result = E;
-  TEdge *Horz = 0;
-
-  if (E->OutIdx == Skip)
-  {
-    //if edges still remain in the current bound beyond the skip edge then
-    //create another LocMin and call ProcessBound once more
-    if (NextIsForward)
-    {
-      while (E->Top.y == E->Next->Bot.y) E = E->Next;
-      //don't include top horizontals when parsing a bound a second time,
-      //they will be contained in the opposite bound ...
-      while (E != Result && IsHorizontal(*E)) E = E->Prev;
-    }
-    else
-    {
-      while (E->Top.y == E->Prev->Bot.y) E = E->Prev;
-      while (E != Result && IsHorizontal(*E)) E = E->Next;
-    }
-
-    if (E == Result)
-    {
-      if (NextIsForward) Result = E->Next;
-      else Result = E->Prev;
-    }
-    else
-    {
-      //there are more edges in the bound beyond result starting with E
-      if (NextIsForward)
-        E = Result->Next;
-      else
-        E = Result->Prev;
-      MinimaList::value_type locMin;
-      locMin.y = E->Bot.y;
-      locMin.LeftBound = 0;
-      locMin.RightBound = E;
-      E->WindDelta = 0;
-      Result = ProcessBound(E, NextIsForward);
-      m_MinimaList.push_back(locMin);
-    }
-    return Result;
-  }
-
-  TEdge *EStart;
-
-  if (IsHorizontal(*E))
-  {
-    //We need to be careful with open paths because this may not be a
-    //true local minima (ie E may be following a skip edge).
-    //Also, consecutive horz. edges may start heading left before going right.
-    if (NextIsForward) 
-      EStart = E->Prev;
-    else 
-      EStart = E->Next;
-    if (IsHorizontal(*EStart)) //ie an adjoining horizontal skip edge
-      {
-        if (EStart->Bot.x != E->Bot.x && EStart->Top.x != E->Bot.x)
-          ReverseHorizontal(*E);
-      }
-      else if (EStart->Bot.x != E->Bot.x)
-        ReverseHorizontal(*E);
-  }
-  
-  EStart = E;
-  if (NextIsForward)
-  {
-    while (Result->Top.y == Result->Next->Bot.y && Result->Next->OutIdx != Skip)
-      Result = Result->Next;
-    if (IsHorizontal(*Result) && Result->Next->OutIdx != Skip)
-    {
-      //nb: at the top of a bound, horizontals are added to the bound
-      //only when the preceding edge attaches to the horizontal's left vertex
-      //unless a Skip edge is encountered when that becomes the top divide
-      Horz = Result;
-      while (IsHorizontal(*Horz->Prev)) Horz = Horz->Prev;
-      if (Horz->Prev->Top.x > Result->Next->Top.x) Result = Horz->Prev;
-    }
-    while (E != Result) 
-    {
-      E->NextInLML = E->Next;
-      if (IsHorizontal(*E) && E != EStart &&
-        E->Bot.x != E->Prev->Top.x) ReverseHorizontal(*E);
-      E = E->Next;
-    }
-    if (IsHorizontal(*E) && E != EStart && E->Bot.x != E->Prev->Top.x) 
-      ReverseHorizontal(*E);
-    Result = Result->Next; //move to the edge just beyond current bound
-  } else
-  {
-    while (Result->Top.y == Result->Prev->Bot.y && Result->Prev->OutIdx != Skip) 
-      Result = Result->Prev;
-    if (IsHorizontal(*Result) && Result->Prev->OutIdx != Skip)
-    {
-      Horz = Result;
-      while (IsHorizontal(*Horz->Next)) Horz = Horz->Next;
-      if (Horz->Next->Top.x == Result->Prev->Top.x ||
-          Horz->Next->Top.x > Result->Prev->Top.x) Result = Horz->Next;
-    }
-
-    while (E != Result)
-    {
-      E->NextInLML = E->Prev;
-      if (IsHorizontal(*E) && E != EStart && E->Bot.x != E->Next->Top.x) 
-        ReverseHorizontal(*E);
-      E = E->Prev;
-    }
-    if (IsHorizontal(*E) && E != EStart && E->Bot.x != E->Next->Top.x) 
-      ReverseHorizontal(*E);
-    Result = Result->Prev; //move to the edge just beyond current bound
-  }
-
-  return Result;
-}
-//------------------------------------------------------------------------------
-
-bool ClipperBase::AddPath(const Path &pg, PolyType PolyTyp, bool Closed)
-{
-#ifdef use_lines
-  if (!Closed && PolyTyp == ptClip)
-    throw clipperException("AddPath: Open paths must be subject.");
-#else
-  if (!Closed)
-    throw clipperException("AddPath: Open paths have been disabled.");
-#endif
-
-  int highI = (int)pg.size() -1;
-  if (Closed) while (highI > 0 && (pg[highI] == pg[0])) --highI;
-  while (highI > 0 && (pg[highI] == pg[highI -1])) --highI;
-  if ((Closed && highI < 2) || (!Closed && highI < 1)) return false;
-
-  //create a new edge array ...
-  TEdge *edges = new TEdge [highI +1];
-
-  bool IsFlat = true;
-  //1. Basic (first) edge initialization ...
-  try
-  {
-    edges[1].Curr = pg[1];
-    RangeTest(pg[0], m_UseFullRange);
-    RangeTest(pg[highI], m_UseFullRange);
-    InitEdge(&edges[0], &edges[1], &edges[highI], pg[0]);
-    InitEdge(&edges[highI], &edges[0], &edges[highI-1], pg[highI]);
-    for (int i = highI - 1; i >= 1; --i)
-    {
-      RangeTest(pg[i], m_UseFullRange);
-      InitEdge(&edges[i], &edges[i+1], &edges[i-1], pg[i]);
-    }
-  }
-  catch(...)
-  {
-    delete [] edges;
-    throw; //range test fails
-  }
-  TEdge *eStart = &edges[0];
-
-  //2. Remove duplicate vertices, and (when closed) collinear edges ...
-  TEdge *E = eStart, *eLoopStop = eStart;
-  for (;;)
-  {
-    //nb: allows matching start and end points when not Closed ...
-    if (E->Curr == E->Next->Curr && (Closed || E->Next != eStart))
-    {
-      if (E == E->Next) break;
-      if (E == eStart) eStart = E->Next;
-      E = RemoveEdge(E);
-      eLoopStop = E;
-      continue;
-    }
-    if (E->Prev == E->Next) 
-      break; //only two vertices
-    else if (Closed &&
-      SlopesEqual(E->Prev->Curr, E->Curr, E->Next->Curr, m_UseFullRange) && 
-      (!m_PreserveCollinear ||
-      !Pt2IsBetweenPt1AndPt3(E->Prev->Curr, E->Curr, E->Next->Curr)))
-    {
-      //Collinear edges are allowed for open paths but in closed paths
-      //the default is to merge adjacent collinear edges into a single edge.
-      //However, if the PreserveCollinear property is enabled, only overlapping
-      //collinear edges (ie spikes) will be removed from closed paths.
-      if (E == eStart) eStart = E->Next;
-      E = RemoveEdge(E);
-      E = E->Prev;
-      eLoopStop = E;
-      continue;
-    }
-    E = E->Next;
-    if ((E == eLoopStop) || (!Closed && E->Next == eStart)) break;
-  }
-
-  if ((!Closed && (E == E->Next)) || (Closed && (E->Prev == E->Next)))
-  {
-    delete [] edges;
-    return false;
-  }
-
-  if (!Closed)
-  { 
-    m_HasOpenPaths = true;
-    eStart->Prev->OutIdx = Skip;
-  }
-
-  //3. Do second stage of edge initialization ...
-  E = eStart;
-  do
-  {
-    InitEdge2(*E, PolyTyp);
-    E = E->Next;
-    if (IsFlat && E->Curr.y != eStart->Curr.y) IsFlat = false;
-  }
-  while (E != eStart);
-
-  //4. Finally, add edge bounds to LocalMinima list ...
-
-  //Totally flat paths must be handled differently when adding them
-  //to LocalMinima list to avoid endless loops etc ...
-  if (IsFlat) 
-  {
-    if (Closed) 
-    {
-      delete [] edges;
-      return false;
-    }
-    E->Prev->OutIdx = Skip;
-    MinimaList::value_type locMin;
-    locMin.y = E->Bot.y;
-    locMin.LeftBound = 0;
-    locMin.RightBound = E;
-    locMin.RightBound->Side = esRight;
-    locMin.RightBound->WindDelta = 0;
-    for (;;)
-    {
-      if (E->Bot.x != E->Prev->Top.x) ReverseHorizontal(*E);
-      if (E->Next->OutIdx == Skip) break;
-      E->NextInLML = E->Next;
-      E = E->Next;
-    }
-    m_MinimaList.push_back(locMin);
-    m_edges.push_back(edges);
-	  return true;
-  }
-
-  m_edges.push_back(edges);
-  bool leftBoundIsForward;
-  TEdge* EMin = 0;
-
-  //workaround to avoid an endless loop in the while loop below when
-  //open paths have matching start and end points ...
-  if (E->Prev->Bot == E->Prev->Top) E = E->Next;
-
-  for (;;)
-  {
-    E = FindNextLocMin(E);
-    if (E == EMin) break;
-    else if (!EMin) EMin = E;
-
-    //E and E.Prev now share a local minima (left aligned if horizontal).
-    //Compare their slopes to find which starts which bound ...
-    MinimaList::value_type locMin;
-    locMin.y = E->Bot.y;
-    if (E->Dx < E->Prev->Dx) 
-    {
-      locMin.LeftBound = E->Prev;
-      locMin.RightBound = E;
-      leftBoundIsForward = false; //Q.nextInLML = Q.prev
-    } else
-    {
-      locMin.LeftBound = E;
-      locMin.RightBound = E->Prev;
-      leftBoundIsForward = true; //Q.nextInLML = Q.next
-    }
-    locMin.LeftBound->Side = esLeft;
-    locMin.RightBound->Side = esRight;
-
-    if (!Closed) locMin.LeftBound->WindDelta = 0;
-    else if (locMin.LeftBound->Next == locMin.RightBound)
-      locMin.LeftBound->WindDelta = -1;
-    else locMin.LeftBound->WindDelta = 1;
-    locMin.RightBound->WindDelta = -locMin.LeftBound->WindDelta;
-
-    E = ProcessBound(locMin.LeftBound, leftBoundIsForward);
-    if (E->OutIdx == Skip) E = ProcessBound(E, leftBoundIsForward);
-
-    TEdge* E2 = ProcessBound(locMin.RightBound, !leftBoundIsForward);
-    if (E2->OutIdx == Skip) E2 = ProcessBound(E2, !leftBoundIsForward);
-
-    if (locMin.LeftBound->OutIdx == Skip)
-      locMin.LeftBound = 0;
-    else if (locMin.RightBound->OutIdx == Skip)
-      locMin.RightBound = 0;
-    m_MinimaList.push_back(locMin);
-    if (!leftBoundIsForward) E = E2;
-  }
-  return true;
-}
-//------------------------------------------------------------------------------
-
-bool ClipperBase::AddPaths(const Paths &ppg, PolyType PolyTyp, bool Closed)
-{
-  bool result = false;
-  for (Paths::size_type i = 0; i < ppg.size(); ++i)
-    if (AddPath(ppg[i], PolyTyp, Closed)) result = true;
-  return result;
-}
-//------------------------------------------------------------------------------
-
-void ClipperBase::Clear()
-{
-  DisposeLocalMinimaList();
-  for (EdgeList::size_type i = 0; i < m_edges.size(); ++i)
-  {
-    //for each edge array in turn, find the first used edge and 
-    //check for and remove any hiddenPts in each edge in the array.
-    TEdge* edges = m_edges[i];
-    delete [] edges;
-  }
-  m_edges.clear();
-  m_UseFullRange = false;
-  m_HasOpenPaths = false;
-}
-//------------------------------------------------------------------------------
-
-void ClipperBase::Reset()
-{
-  m_CurrentLM = m_MinimaList.begin();
-  if (m_CurrentLM == m_MinimaList.end()) return; //ie nothing to process
-  std::stable_sort(m_MinimaList.begin(), m_MinimaList.end(), LocMinSorter());
-
-  //reset all edges ...
-  for (MinimaList::iterator lm = m_MinimaList.begin(); lm != m_MinimaList.end(); ++lm)
-  {
-    TEdge* e = lm->LeftBound;
-    if (e)
-    {
-      e->Curr = e->Bot;
-      e->Side = esLeft;
-      e->OutIdx = Unassigned;
-    }
-
-    e = lm->RightBound;
-    if (e)
-    {
-      e->Curr = e->Bot;
-      e->Side = esRight;
-      e->OutIdx = Unassigned;
-    }
-  }
-}
-//------------------------------------------------------------------------------
-
-void ClipperBase::DisposeLocalMinimaList()
-{
-  m_MinimaList.clear();
-  m_CurrentLM = m_MinimaList.begin();
-}
-//------------------------------------------------------------------------------
-
-void ClipperBase::PopLocalMinima()
-{
-  if (m_CurrentLM == m_MinimaList.end()) return;
-  ++m_CurrentLM;
-}
-//------------------------------------------------------------------------------
-
-IntRect ClipperBase::GetBounds()
-{
-  IntRect result;
-  MinimaList::iterator lm = m_MinimaList.begin();
-  if (lm == m_MinimaList.end())
-  {
-    result.left = result.top = result.right = result.bottom = 0;
-    return result;
-  }
-  result.left = lm->LeftBound->Bot.x;
-  result.top = lm->LeftBound->Bot.y;
-  result.right = lm->LeftBound->Bot.x;
-  result.bottom = lm->LeftBound->Bot.y;
-  while (lm != m_MinimaList.end())
-  {
-    result.bottom = std::max(result.bottom, lm->LeftBound->Bot.y);
-    TEdge* e = lm->LeftBound;
-    for (;;) {
-      TEdge* bottomE = e;
-      while (e->NextInLML)
-      {
-        if (e->Bot.x < result.left) result.left = e->Bot.x;
-        if (e->Bot.x > result.right) result.right = e->Bot.x;
-        e = e->NextInLML;
-      }
-      result.left = std::min(result.left, e->Bot.x);
-      result.right = std::max(result.right, e->Bot.x);
-      result.left = std::min(result.left, e->Top.x);
-      result.right = std::max(result.right, e->Top.x);
-      result.top = std::min(result.top, e->Top.y);
-      if (bottomE == lm->LeftBound) e = lm->RightBound;
-      else break;
-    }
-    ++lm;
-  }
-  return result;
-}
-
-//------------------------------------------------------------------------------
-// TClipper methods ...
-//------------------------------------------------------------------------------
-
-Clipper::Clipper(int initOptions) : ClipperBase() //constructor
-{
-  m_ActiveEdges = 0;
-  m_SortedEdges = 0;
-  m_ExecuteLocked = false;
-  m_UseFullRange = false;
-  m_ReverseOutput = ((initOptions & ioReverseSolution) != 0);
-  m_StrictSimple = ((initOptions & ioStrictlySimple) != 0);
-  m_PreserveCollinear = ((initOptions & ioPreserveCollinear) != 0);
-  m_HasOpenPaths = false;
-#ifdef use_xyz  
-  m_ZFill = 0;
-#endif
-}
-//------------------------------------------------------------------------------
-
-Clipper::~Clipper() //destructor
-{
-  Clear();
-}
-//------------------------------------------------------------------------------
-
-#ifdef use_xyz  
-void Clipper::ZFillFunction(ZFillCallback zFillFunc)
-{  
-  m_ZFill = zFillFunc;
-}
-//------------------------------------------------------------------------------
-#endif
-
-void Clipper::Reset()
-{
-  ClipperBase::Reset();
-  m_Scanbeam = ScanbeamList();
-  m_Maxima = MaximaList();
-  m_ActiveEdges = 0;
-  m_SortedEdges = 0;
-  for (MinimaList::iterator lm = m_MinimaList.begin(); lm != m_MinimaList.end(); ++lm)
-    InsertScanbeam(lm->y);
-}
-//------------------------------------------------------------------------------
-
-bool Clipper::Execute(ClipType clipType, Paths &solution, PolyFillType fillType)
-{
-    return Execute(clipType, solution, fillType, fillType);
-}
-//------------------------------------------------------------------------------
-
-bool Clipper::Execute(ClipType clipType, PolyTree &polytree, PolyFillType fillType)
-{
-    return Execute(clipType, polytree, fillType, fillType);
-}
-//------------------------------------------------------------------------------
-
-bool Clipper::Execute(ClipType clipType, Paths &solution,
-    PolyFillType subjFillType, PolyFillType clipFillType)
-{
-  if( m_ExecuteLocked ) return false;
-  if (m_HasOpenPaths)
-    throw clipperException("Error: PolyTree struct is needed for open path clipping.");
-  m_ExecuteLocked = true;
-  solution.resize(0);
-  m_SubjFillType = subjFillType;
-  m_ClipFillType = clipFillType;
-  m_ClipType = clipType;
-  m_UsingPolyTree = false;
-  bool succeeded = ExecuteInternal();
-  if (succeeded) BuildResult(solution);
-  DisposeAllOutRecs();
-  m_ExecuteLocked = false;
-  return succeeded;
-}
-//------------------------------------------------------------------------------
-
-bool Clipper::Execute(ClipType clipType, PolyTree& polytree,
-    PolyFillType subjFillType, PolyFillType clipFillType)
-{
-  if( m_ExecuteLocked ) return false;
-  m_ExecuteLocked = true;
-  m_SubjFillType = subjFillType;
-  m_ClipFillType = clipFillType;
-  m_ClipType = clipType;
-  m_UsingPolyTree = true;
-  bool succeeded = ExecuteInternal();
-  if (succeeded) BuildResult2(polytree);
-  DisposeAllOutRecs();
-  m_ExecuteLocked = false;
-  return succeeded;
-}
-//------------------------------------------------------------------------------
-
-void Clipper::FixHoleLinkage(OutRec &outrec)
-{
-  //skip OutRecs that (a) contain outermost polygons or
-  //(b) already have the correct owner/child linkage ...
-  if (!outrec.FirstLeft ||                
-      (outrec.IsHole != outrec.FirstLeft->IsHole &&
-      outrec.FirstLeft->Pts)) return;
-
-  OutRec* orfl = outrec.FirstLeft;
-  while (orfl && ((orfl->IsHole == outrec.IsHole) || !orfl->Pts))
-      orfl = orfl->FirstLeft;
-  outrec.FirstLeft = orfl;
-}
-//------------------------------------------------------------------------------
-
-bool Clipper::ExecuteInternal()
-{
-  bool succeeded = true;
-  try {
-    Reset();
-    if (m_CurrentLM == m_MinimaList.end()) return true;
-    cInt botY = PopScanbeam();
-    do {
-      InsertLocalMinimaIntoAEL(botY);
-      ProcessHorizontals();
-	  ClearGhostJoins();
-	  if (m_Scanbeam.empty()) break;
-      cInt topY = PopScanbeam();
-      succeeded = ProcessIntersections(topY);
-      if (!succeeded) break;
-      ProcessEdgesAtTopOfScanbeam(topY);
-      botY = topY;
-    } while (!m_Scanbeam.empty() || m_CurrentLM != m_MinimaList.end());
-  }
-  catch(...) 
-  {
-    succeeded = false;
-  }
-
-  if (succeeded)
-  {
-    //fix orientations ...
-    for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); ++i)
-    {
-      OutRec *outRec = m_PolyOuts[i];
-      if (!outRec->Pts || outRec->IsOpen) continue;
-      if ((outRec->IsHole ^ m_ReverseOutput) == (Area(*outRec) > 0))
-        ReversePolyPtLinks(outRec->Pts);
-    }
-
-    if (!m_Joins.empty()) JoinCommonEdges();
-
-    //unfortunately FixupOutPolygon() must be done after JoinCommonEdges()
-    for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); ++i)
-    {
-      OutRec *outRec = m_PolyOuts[i];
-      if (!outRec->Pts) continue;
-      if (outRec->IsOpen)
-        FixupOutPolyline(*outRec);
-      else
-        FixupOutPolygon(*outRec);
-    }
-
-    if (m_StrictSimple) DoSimplePolygons();
-  }
-
-  ClearJoins();
-  ClearGhostJoins();
-  return succeeded;
-}
-//------------------------------------------------------------------------------
-
-void Clipper::InsertScanbeam(const cInt Y)
-{
-    m_Scanbeam.push(Y);
-}
-//------------------------------------------------------------------------------
-
-cInt Clipper::PopScanbeam()
-{
-    const cInt Y = m_Scanbeam.top();
-    m_Scanbeam.pop();
-    while (!m_Scanbeam.empty() && Y == m_Scanbeam.top()) { m_Scanbeam.pop(); } // Pop duplicates.
-    return Y;
-}
-//------------------------------------------------------------------------------
-
-void Clipper::DisposeAllOutRecs(){
-  for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); ++i)
-    DisposeOutRec(i);
-  m_PolyOuts.clear();
-}
-//------------------------------------------------------------------------------
-
-void Clipper::DisposeOutRec(PolyOutList::size_type index)
-{
-  OutRec *outRec = m_PolyOuts[index];
-  if (outRec->Pts) DisposeOutPts(outRec->Pts);
-  delete outRec;
-  m_PolyOuts[index] = 0;
-}
-//------------------------------------------------------------------------------
-
-void Clipper::SetWindingCount(TEdge &edge)
-{
-  TEdge *e = edge.PrevInAEL;
-  //find the edge of the same polytype that immediately preceeds 'edge' in AEL
-  while (e  && ((e->PolyTyp != edge.PolyTyp) || (e->WindDelta == 0))) e = e->PrevInAEL;
-  if (!e)
-  {
-    edge.WindCnt = (edge.WindDelta == 0 ? 1 : edge.WindDelta);
-    edge.WindCnt2 = 0;
-    e = m_ActiveEdges; //ie get ready to calc WindCnt2
-  }   
-  else if (edge.WindDelta == 0 && m_ClipType != ctUnion)
-  {
-    edge.WindCnt = 1;
-    edge.WindCnt2 = e->WindCnt2;
-    e = e->NextInAEL; //ie get ready to calc WindCnt2
-  }
-  else if (IsEvenOddFillType(edge))
-  {
-    //EvenOdd filling ...
-    if (edge.WindDelta == 0)
-    {
-      //are we inside a subj polygon ...
-      bool Inside = true;
-      TEdge *e2 = e->PrevInAEL;
-      while (e2)
-      {
-        if (e2->PolyTyp == e->PolyTyp && e2->WindDelta != 0) 
-          Inside = !Inside;
-        e2 = e2->PrevInAEL;
-      }
-      edge.WindCnt = (Inside ? 0 : 1);
-    }
-    else
-    {
-      edge.WindCnt = edge.WindDelta;
-    }
-    edge.WindCnt2 = e->WindCnt2;
-    e = e->NextInAEL; //ie get ready to calc WindCnt2
-  } 
-  else
-  {
-    //nonZero, Positive or Negative filling ...
-    if (e->WindCnt * e->WindDelta < 0)
-    {
-      //prev edge is 'decreasing' WindCount (WC) toward zero
-      //so we're outside the previous polygon ...
-      if (Abs(e->WindCnt) > 1)
-      {
-        //outside prev poly but still inside another.
-        //when reversing direction of prev poly use the same WC 
-        if (e->WindDelta * edge.WindDelta < 0) edge.WindCnt = e->WindCnt;
-        //otherwise continue to 'decrease' WC ...
-        else edge.WindCnt = e->WindCnt + edge.WindDelta;
-      } 
-      else
-        //now outside all polys of same polytype so set own WC ...
-        edge.WindCnt = (edge.WindDelta == 0 ? 1 : edge.WindDelta);
-    } else
-    {
-      //prev edge is 'increasing' WindCount (WC) away from zero
-      //so we're inside the previous polygon ...
-      if (edge.WindDelta == 0) 
-        edge.WindCnt = (e->WindCnt < 0 ? e->WindCnt - 1 : e->WindCnt + 1);
-      //if wind direction is reversing prev then use same WC
-      else if (e->WindDelta * edge.WindDelta < 0) edge.WindCnt = e->WindCnt;
-      //otherwise add to WC ...
-      else edge.WindCnt = e->WindCnt + edge.WindDelta;
-    }
-    edge.WindCnt2 = e->WindCnt2;
-    e = e->NextInAEL; //ie get ready to calc WindCnt2
-  }
-
-  //update WindCnt2 ...
-  if (IsEvenOddAltFillType(edge))
-  {
-    //EvenOdd filling ...
-    while (e != &edge)
-    {
-      if (e->WindDelta != 0)
-        edge.WindCnt2 = (edge.WindCnt2 == 0 ? 1 : 0);
-      e = e->NextInAEL;
-    }
-  } else
-  {
-    //nonZero, Positive or Negative filling ...
-    while ( e != &edge )
-    {
-      edge.WindCnt2 += e->WindDelta;
-      e = e->NextInAEL;
-    }
-  }
-}
-//------------------------------------------------------------------------------
-
-bool Clipper::IsEvenOddFillType(const TEdge& edge) const
-{
-  if (edge.PolyTyp == ptSubject)
-    return m_SubjFillType == pftEvenOdd; else
-    return m_ClipFillType == pftEvenOdd;
-}
-//------------------------------------------------------------------------------
-
-bool Clipper::IsEvenOddAltFillType(const TEdge& edge) const
-{
-  if (edge.PolyTyp == ptSubject)
-    return m_ClipFillType == pftEvenOdd; else
-    return m_SubjFillType == pftEvenOdd;
-}
-//------------------------------------------------------------------------------
-
-bool Clipper::IsContributing(const TEdge& edge) const
-{
-  PolyFillType pft, pft2;
-  if (edge.PolyTyp == ptSubject)
-  {
-    pft = m_SubjFillType;
-    pft2 = m_ClipFillType;
-  } else
-  {
-    pft = m_ClipFillType;
-    pft2 = m_SubjFillType;
-  }
-
-  switch(pft)
-  {
-    case pftEvenOdd: 
-      //return false if a subj line has been flagged as inside a subj polygon
-      if (edge.WindDelta == 0 && edge.WindCnt != 1) return false;
-      break;
-    case pftNonZero:
-      if (Abs(edge.WindCnt) != 1) return false;
-      break;
-    case pftPositive: 
-      if (edge.WindCnt != 1) return false;
-      break;
-    default: //pftNegative
-      if (edge.WindCnt != -1) return false;
-  }
-
-  switch(m_ClipType)
-  {
-    case ctIntersection:
-      switch(pft2)
-      {
-        case pftEvenOdd: 
-        case pftNonZero: 
-          return (edge.WindCnt2 != 0);
-        case pftPositive: 
-          return (edge.WindCnt2 > 0);
-        default: 
-          return (edge.WindCnt2 < 0);
-      }
-      break;
-    case ctUnion:
-      switch(pft2)
-      {
-        case pftEvenOdd: 
-        case pftNonZero: 
-          return (edge.WindCnt2 == 0);
-        case pftPositive: 
-          return (edge.WindCnt2 <= 0);
-        default: 
-          return (edge.WindCnt2 >= 0);
-      }
-      break;
-    case ctDifference:
-      if (edge.PolyTyp == ptSubject)
-        switch(pft2)
-        {
-          case pftEvenOdd: 
-          case pftNonZero: 
-            return (edge.WindCnt2 == 0);
-          case pftPositive: 
-            return (edge.WindCnt2 <= 0);
-          default: 
-            return (edge.WindCnt2 >= 0);
-        }
-      else
-        switch(pft2)
-        {
-          case pftEvenOdd: 
-          case pftNonZero: 
-            return (edge.WindCnt2 != 0);
-          case pftPositive: 
-            return (edge.WindCnt2 > 0);
-          default: 
-            return (edge.WindCnt2 < 0);
-        }
-      break;
-    case ctXor:
-      if (edge.WindDelta == 0) //XOr always contributing unless open
-        switch(pft2)
-        {
-          case pftEvenOdd: 
-          case pftNonZero: 
-            return (edge.WindCnt2 == 0);
-          case pftPositive: 
-            return (edge.WindCnt2 <= 0);
-          default: 
-            return (edge.WindCnt2 >= 0);
-        }
-      else 
-        return true;
-      break;
-    default:
-      return true;
-  }
-}
-//------------------------------------------------------------------------------
-
-OutPt* Clipper::AddLocalMinPoly(TEdge *e1, TEdge *e2, const IntPoint &Pt)
-{
-  OutPt* result;
-  TEdge *e, *prevE;
-  if (IsHorizontal(*e2) || ( e1->Dx > e2->Dx ))
-  {
-    result = AddOutPt(e1, Pt);
-    e2->OutIdx = e1->OutIdx;
-    e1->Side = esLeft;
-    e2->Side = esRight;
-    e = e1;
-    if (e->PrevInAEL == e2)
-      prevE = e2->PrevInAEL; 
-    else
-      prevE = e->PrevInAEL;
-  } else
-  {
-    result = AddOutPt(e2, Pt);
-    e1->OutIdx = e2->OutIdx;
-    e1->Side = esRight;
-    e2->Side = esLeft;
-    e = e2;
-    if (e->PrevInAEL == e1)
-        prevE = e1->PrevInAEL;
-    else
-        prevE = e->PrevInAEL;
-  }
-
-  if (prevE && prevE->OutIdx >= 0 &&
-      (TopX(*prevE, Pt.y) == TopX(*e, Pt.y)) &&
-      SlopesEqual(*e, *prevE, m_UseFullRange) &&
-      (e->WindDelta != 0) && (prevE->WindDelta != 0))
-  {
-    OutPt* outPt = AddOutPt(prevE, Pt);
-    AddJoin(result, outPt, e->Top);
-  }
-  return result;
-}
-//------------------------------------------------------------------------------
-
-void Clipper::AddLocalMaxPoly(TEdge *e1, TEdge *e2, const IntPoint &Pt)
-{
-  AddOutPt( e1, Pt );
-  if (e2->WindDelta == 0) AddOutPt(e2, Pt);
-  if( e1->OutIdx == e2->OutIdx )
-  {
-    e1->OutIdx = Unassigned;
-    e2->OutIdx = Unassigned;
-  }
-  else if (e1->OutIdx < e2->OutIdx) 
-    AppendPolygon(e1, e2); 
-  else 
-    AppendPolygon(e2, e1);
-}
-//------------------------------------------------------------------------------
-
-void Clipper::AddEdgeToSEL(TEdge *edge)
-{
-  //SEL pointers in PEdge are reused to build a list of horizontal edges.
-  //However, we don't need to worry about order with horizontal edge processing.
-  if( !m_SortedEdges )
-  {
-    m_SortedEdges = edge;
-    edge->PrevInSEL = 0;
-    edge->NextInSEL = 0;
-  }
-  else
-  {
-    edge->NextInSEL = m_SortedEdges;
-    edge->PrevInSEL = 0;
-    m_SortedEdges->PrevInSEL = edge;
-    m_SortedEdges = edge;
-  }
-}
-//------------------------------------------------------------------------------
-
-void Clipper::CopyAELToSEL()
-{
-  TEdge* e = m_ActiveEdges;
-  m_SortedEdges = e;
-  while ( e )
-  {
-    e->PrevInSEL = e->PrevInAEL;
-    e->NextInSEL = e->NextInAEL;
-    e = e->NextInAEL;
-  }
-}
-//------------------------------------------------------------------------------
-
-void Clipper::AddJoin(OutPt *op1, OutPt *op2, const IntPoint OffPt)
-{
-  Join* j = new Join;
-  j->OutPt1 = op1;
-  j->OutPt2 = op2;
-  j->OffPt = OffPt;
-  m_Joins.push_back(j);
-}
-//------------------------------------------------------------------------------
-
-void Clipper::ClearJoins()
-{
-  for (JoinList::size_type i = 0; i < m_Joins.size(); i++)
-    delete m_Joins[i];
-  m_Joins.resize(0);
-}
-//------------------------------------------------------------------------------
-
-void Clipper::ClearGhostJoins()
-{
-  for (JoinList::size_type i = 0; i < m_GhostJoins.size(); i++)
-    delete m_GhostJoins[i];
-  m_GhostJoins.resize(0);
-}
-//------------------------------------------------------------------------------
-
-void Clipper::AddGhostJoin(OutPt *op, const IntPoint OffPt)
-{
-  Join* j = new Join;
-  j->OutPt1 = op;
-  j->OutPt2 = 0;
-  j->OffPt = OffPt;
-  m_GhostJoins.push_back(j);
-}
-//------------------------------------------------------------------------------
-
-void Clipper::InsertLocalMinimaIntoAEL(const cInt botY)
-{
-  while (m_CurrentLM != m_MinimaList.end() && (m_CurrentLM->y == botY))
-  {
-    TEdge* lb = m_CurrentLM->LeftBound;
-    TEdge* rb = m_CurrentLM->RightBound;
-    PopLocalMinima();
-    OutPt *Op1 = 0;
-    if (!lb)
-    {
-      //nb: don't insert LB into either AEL or SEL
-      InsertEdgeIntoAEL(rb, 0);
-      SetWindingCount(*rb);
-      if (IsContributing(*rb))
-        Op1 = AddOutPt(rb, rb->Bot); 
-    } 
-    else if (!rb)
-    {
-      InsertEdgeIntoAEL(lb, 0);
-      SetWindingCount(*lb);
-      if (IsContributing(*lb))
-        Op1 = AddOutPt(lb, lb->Bot);
-      InsertScanbeam(lb->Top.y);
-    }
-    else
-    {
-      InsertEdgeIntoAEL(lb, 0);
-      InsertEdgeIntoAEL(rb, lb);
-      SetWindingCount( *lb );
-      rb->WindCnt = lb->WindCnt;
-      rb->WindCnt2 = lb->WindCnt2;
-      if (IsContributing(*lb))
-        Op1 = AddLocalMinPoly(lb, rb, lb->Bot);      
-      InsertScanbeam(lb->Top.y);
-    }
-
-     if (rb)
-     {
-       if(IsHorizontal(*rb)) AddEdgeToSEL(rb);
-       else InsertScanbeam( rb->Top.y );
-     }
-
-    if (!lb || !rb) continue;
-
-    //if any output polygons share an edge, they'll need joining later ...
-    if (Op1 && IsHorizontal(*rb) && 
-      m_GhostJoins.size() > 0 && (rb->WindDelta != 0))
-    {
-      for (JoinList::size_type i = 0; i < m_GhostJoins.size(); ++i)
-      {
-        Join* jr = m_GhostJoins[i];
-        //if the horizontal Rb and a 'ghost' horizontal overlap, then convert
-        //the 'ghost' join to a real join ready for later ...
-        if (HorzSegmentsOverlap(jr->OutPt1->Pt.x, jr->OffPt.x, rb->Bot.x, rb->Top.x))
-          AddJoin(jr->OutPt1, Op1, jr->OffPt);
-      }
-    }
-
-    if (lb->OutIdx >= 0 && lb->PrevInAEL && 
-      lb->PrevInAEL->Curr.x == lb->Bot.x &&
-      lb->PrevInAEL->OutIdx >= 0 &&
-      SlopesEqual(*lb->PrevInAEL, *lb, m_UseFullRange) &&
-      (lb->WindDelta != 0) && (lb->PrevInAEL->WindDelta != 0))
-    {
-        OutPt *Op2 = AddOutPt(lb->PrevInAEL, lb->Bot);
-        AddJoin(Op1, Op2, lb->Top);
-    }
-
-    if(lb->NextInAEL != rb)
-    {
-
-      if (rb->OutIdx >= 0 && rb->PrevInAEL->OutIdx >= 0 &&
-        SlopesEqual(*rb->PrevInAEL, *rb, m_UseFullRange) &&
-        (rb->WindDelta != 0) && (rb->PrevInAEL->WindDelta != 0))
-      {
-          OutPt *Op2 = AddOutPt(rb->PrevInAEL, rb->Bot);
-          AddJoin(Op1, Op2, rb->Top);
-      }
-
-      TEdge* e = lb->NextInAEL;
-      if (e)
-      {
-        while( e != rb )
-        {
-          //nb: For calculating winding counts etc, IntersectEdges() assumes
-          //that param1 will be to the Right of param2 ABOVE the intersection ...
-          IntersectEdges(rb , e , lb->Curr); //order important here
-          e = e->NextInAEL;
-        }
-      }
-    }
-    
-  }
-}
-//------------------------------------------------------------------------------
-
-void Clipper::DeleteFromAEL(TEdge *e)
-{
-  TEdge* AelPrev = e->PrevInAEL;
-  TEdge* AelNext = e->NextInAEL;
-  if(  !AelPrev &&  !AelNext && (e != m_ActiveEdges) ) return; //already deleted
-  if( AelPrev ) AelPrev->NextInAEL = AelNext;
-  else m_ActiveEdges = AelNext;
-  if( AelNext ) AelNext->PrevInAEL = AelPrev;
-  e->NextInAEL = 0;
-  e->PrevInAEL = 0;
-}
-//------------------------------------------------------------------------------
-
-void Clipper::DeleteFromSEL(TEdge *e)
-{
-  TEdge* SelPrev = e->PrevInSEL;
-  TEdge* SelNext = e->NextInSEL;
-  if( !SelPrev &&  !SelNext && (e != m_SortedEdges) ) return; //already deleted
-  if( SelPrev ) SelPrev->NextInSEL = SelNext;
-  else m_SortedEdges = SelNext;
-  if( SelNext ) SelNext->PrevInSEL = SelPrev;
-  e->NextInSEL = 0;
-  e->PrevInSEL = 0;
-}
-//------------------------------------------------------------------------------
-
-#ifdef use_xyz
-void Clipper::SetZ(IntPoint& pt, TEdge& e1, TEdge& e2)
-{
-  if (pt.Z != 0 || !m_ZFill) return;
-  else if (pt == e1.Bot) pt.Z = e1.Bot.Z;
-  else if (pt == e1.Top) pt.Z = e1.Top.Z;
-  else if (pt == e2.Bot) pt.Z = e2.Bot.Z;
-  else if (pt == e2.Top) pt.Z = e2.Top.Z;
-  else (*m_ZFill)(e1.Bot, e1.Top, e2.Bot, e2.Top, pt); 
-}
-//------------------------------------------------------------------------------
-#endif
-
-void Clipper::IntersectEdges(TEdge *e1, TEdge *e2, IntPoint &Pt)
-{
-  bool e1Contributing = ( e1->OutIdx >= 0 );
-  bool e2Contributing = ( e2->OutIdx >= 0 );
-
-#ifdef use_xyz
-        SetZ(Pt, *e1, *e2);
-#endif
-
-#ifdef use_lines
-  //if either edge is on an OPEN path ...
-  if (e1->WindDelta == 0 || e2->WindDelta == 0)
-  {
-    //ignore subject-subject open path intersections UNLESS they
-    //are both open paths, AND they are both 'contributing maximas' ...
-	if (e1->WindDelta == 0 && e2->WindDelta == 0) return;
-
-    //if intersecting a subj line with a subj poly ...
-    else if (e1->PolyTyp == e2->PolyTyp && 
-      e1->WindDelta != e2->WindDelta && m_ClipType == ctUnion)
-    {
-      if (e1->WindDelta == 0)
-      {
-        if (e2Contributing)
-        {
-          AddOutPt(e1, Pt);
-          if (e1Contributing) e1->OutIdx = Unassigned;
-        }
-      }
-      else
-      {
-        if (e1Contributing)
-        {
-          AddOutPt(e2, Pt);
-          if (e2Contributing) e2->OutIdx = Unassigned;
-        }
-      }
-    }
-    else if (e1->PolyTyp != e2->PolyTyp)
-    {
-      //toggle subj open path OutIdx on/off when Abs(clip.WndCnt) == 1 ...
-      if ((e1->WindDelta == 0) && abs(e2->WindCnt) == 1 && 
-        (m_ClipType != ctUnion || e2->WindCnt2 == 0))
-      {
-        AddOutPt(e1, Pt);
-        if (e1Contributing) e1->OutIdx = Unassigned;
-      }
-      else if ((e2->WindDelta == 0) && (abs(e1->WindCnt) == 1) && 
-        (m_ClipType != ctUnion || e1->WindCnt2 == 0))
-      {
-        AddOutPt(e2, Pt);
-        if (e2Contributing) e2->OutIdx = Unassigned;
-      }
-    }
-    return;
-  }
-#endif
-
-  //update winding counts...
-  //assumes that e1 will be to the Right of e2 ABOVE the intersection
-  if ( e1->PolyTyp == e2->PolyTyp )
-  {
-    if ( IsEvenOddFillType( *e1) )
-    {
-      int oldE1WindCnt = e1->WindCnt;
-      e1->WindCnt = e2->WindCnt;
-      e2->WindCnt = oldE1WindCnt;
-    } else
-    {
-      if (e1->WindCnt + e2->WindDelta == 0 ) e1->WindCnt = -e1->WindCnt;
-      else e1->WindCnt += e2->WindDelta;
-      if ( e2->WindCnt - e1->WindDelta == 0 ) e2->WindCnt = -e2->WindCnt;
-      else e2->WindCnt -= e1->WindDelta;
-    }
-  } else
-  {
-    if (!IsEvenOddFillType(*e2)) e1->WindCnt2 += e2->WindDelta;
-    else e1->WindCnt2 = ( e1->WindCnt2 == 0 ) ? 1 : 0;
-    if (!IsEvenOddFillType(*e1)) e2->WindCnt2 -= e1->WindDelta;
-    else e2->WindCnt2 = ( e2->WindCnt2 == 0 ) ? 1 : 0;
-  }
-
-  PolyFillType e1FillType, e2FillType, e1FillType2, e2FillType2;
-  if (e1->PolyTyp == ptSubject)
-  {
-    e1FillType = m_SubjFillType;
-    e1FillType2 = m_ClipFillType;
-  } else
-  {
-    e1FillType = m_ClipFillType;
-    e1FillType2 = m_SubjFillType;
-  }
-  if (e2->PolyTyp == ptSubject)
-  {
-    e2FillType = m_SubjFillType;
-    e2FillType2 = m_ClipFillType;
-  } else
-  {
-    e2FillType = m_ClipFillType;
-    e2FillType2 = m_SubjFillType;
-  }
-
-  cInt e1Wc, e2Wc;
-  switch (e1FillType)
-  {
-    case pftPositive: e1Wc = e1->WindCnt; break;
-    case pftNegative: e1Wc = -e1->WindCnt; break;
-    default: e1Wc = Abs(e1->WindCnt);
-  }
-  switch(e2FillType)
-  {
-    case pftPositive: e2Wc = e2->WindCnt; break;
-    case pftNegative: e2Wc = -e2->WindCnt; break;
-    default: e2Wc = Abs(e2->WindCnt);
-  }
-
-  if ( e1Contributing && e2Contributing )
-  {
-    if ((e1Wc != 0 && e1Wc != 1) || (e2Wc != 0 && e2Wc != 1) ||
-      (e1->PolyTyp != e2->PolyTyp && m_ClipType != ctXor) )
-    {
-      AddLocalMaxPoly(e1, e2, Pt); 
-    }
-    else
-    {
-      AddOutPt(e1, Pt);
-      AddOutPt(e2, Pt);
-      SwapSides( *e1 , *e2 );
-      SwapPolyIndexes( *e1 , *e2 );
-    }
-  }
-  else if ( e1Contributing )
-  {
-    if (e2Wc == 0 || e2Wc == 1) 
-    {
-      AddOutPt(e1, Pt);
-      SwapSides(*e1, *e2);
-      SwapPolyIndexes(*e1, *e2);
-    }
-  }
-  else if ( e2Contributing )
-  {
-    if (e1Wc == 0 || e1Wc == 1) 
-    {
-      AddOutPt(e2, Pt);
-      SwapSides(*e1, *e2);
-      SwapPolyIndexes(*e1, *e2);
-    }
-  } 
-  else if ( (e1Wc == 0 || e1Wc == 1) && (e2Wc == 0 || e2Wc == 1))
-  {
-    //neither edge is currently contributing ...
-
-    cInt e1Wc2, e2Wc2;
-    switch (e1FillType2)
-    {
-      case pftPositive: e1Wc2 = e1->WindCnt2; break;
-      case pftNegative : e1Wc2 = -e1->WindCnt2; break;
-      default: e1Wc2 = Abs(e1->WindCnt2);
-    }
-    switch (e2FillType2)
-    {
-      case pftPositive: e2Wc2 = e2->WindCnt2; break;
-      case pftNegative: e2Wc2 = -e2->WindCnt2; break;
-      default: e2Wc2 = Abs(e2->WindCnt2);
-    }
-
-    if (e1->PolyTyp != e2->PolyTyp)
-    {
-      AddLocalMinPoly(e1, e2, Pt);
-    }
-    else if (e1Wc == 1 && e2Wc == 1)
-      switch( m_ClipType ) {
-        case ctIntersection:
-          if (e1Wc2 > 0 && e2Wc2 > 0)
-            AddLocalMinPoly(e1, e2, Pt);
-          break;
-        case ctUnion:
-          if ( e1Wc2 <= 0 && e2Wc2 <= 0 )
-            AddLocalMinPoly(e1, e2, Pt);
-          break;
-        case ctDifference:
-          if (((e1->PolyTyp == ptClip) && (e1Wc2 > 0) && (e2Wc2 > 0)) ||
-              ((e1->PolyTyp == ptSubject) && (e1Wc2 <= 0) && (e2Wc2 <= 0)))
-                AddLocalMinPoly(e1, e2, Pt);
-          break;
-        case ctXor:
-          AddLocalMinPoly(e1, e2, Pt);
-      }
-    else
-      SwapSides( *e1, *e2 );
-  }
-}
-//------------------------------------------------------------------------------
-
-void Clipper::SetHoleState(TEdge *e, OutRec *outrec)
-{
-  bool IsHole = false;
-  TEdge *e2 = e->PrevInAEL;
-  while (e2)
-  {
-    if (e2->OutIdx >= 0 && e2->WindDelta != 0)
-    {
-      IsHole = !IsHole;
-      if (! outrec->FirstLeft)
-        outrec->FirstLeft = m_PolyOuts[e2->OutIdx];
-    }
-    e2 = e2->PrevInAEL;
-  }
-  if (IsHole) outrec->IsHole = true;
-}
-//------------------------------------------------------------------------------
-
-OutRec* GetLowermostRec(OutRec *outRec1, OutRec *outRec2)
-{
-  //work out which polygon fragment has the correct hole state ...
-  if (!outRec1->BottomPt) 
-    outRec1->BottomPt = GetBottomPt(outRec1->Pts);
-  if (!outRec2->BottomPt) 
-    outRec2->BottomPt = GetBottomPt(outRec2->Pts);
-  OutPt *OutPt1 = outRec1->BottomPt;
-  OutPt *OutPt2 = outRec2->BottomPt;
-  if (OutPt1->Pt.y > OutPt2->Pt.y) return outRec1;
-  else if (OutPt1->Pt.y < OutPt2->Pt.y) return outRec2;
-  else if (OutPt1->Pt.x < OutPt2->Pt.x) return outRec1;
-  else if (OutPt1->Pt.x > OutPt2->Pt.x) return outRec2;
-  else if (OutPt1->Next == OutPt1) return outRec2;
-  else if (OutPt2->Next == OutPt2) return outRec1;
-  else if (FirstIsBottomPt(OutPt1, OutPt2)) return outRec1;
-  else return outRec2;
-}
-//------------------------------------------------------------------------------
-
-bool Param1RightOfParam2(OutRec* outRec1, OutRec* outRec2)
-{
-  do
-  {
-    outRec1 = outRec1->FirstLeft;
-    if (outRec1 == outRec2) return true;
-  } while (outRec1);
-  return false;
-}
-//------------------------------------------------------------------------------
-
-OutRec* Clipper::GetOutRec(int Idx)
-{
-  OutRec* outrec = m_PolyOuts[Idx];
-  while (outrec != m_PolyOuts[outrec->Idx])
-    outrec = m_PolyOuts[outrec->Idx];
-  return outrec;
-}
-//------------------------------------------------------------------------------
-
-void Clipper::AppendPolygon(TEdge *e1, TEdge *e2)
-{
-  //get the start and ends of both output polygons ...
-  OutRec *outRec1 = m_PolyOuts[e1->OutIdx];
-  OutRec *outRec2 = m_PolyOuts[e2->OutIdx];
-
-  OutRec *holeStateRec;
-  if (Param1RightOfParam2(outRec1, outRec2)) 
-    holeStateRec = outRec2;
-  else if (Param1RightOfParam2(outRec2, outRec1)) 
-    holeStateRec = outRec1;
-  else 
-    holeStateRec = GetLowermostRec(outRec1, outRec2);
-
-  //get the start and ends of both output polygons and
-  //join e2 poly onto e1 poly and delete pointers to e2 ...
-
-  OutPt* p1_lft = outRec1->Pts;
-  OutPt* p1_rt = p1_lft->Prev;
-  OutPt* p2_lft = outRec2->Pts;
-  OutPt* p2_rt = p2_lft->Prev;
-
-  EdgeSide Side;
-  //join e2 poly onto e1 poly and delete pointers to e2 ...
-  if(  e1->Side == esLeft )
-  {
-    if(  e2->Side == esLeft )
-    {
-      //z y x a b c
-      ReversePolyPtLinks(p2_lft);
-      p2_lft->Next = p1_lft;
-      p1_lft->Prev = p2_lft;
-      p1_rt->Next = p2_rt;
-      p2_rt->Prev = p1_rt;
-      outRec1->Pts = p2_rt;
-    } else
-    {
-      //x y z a b c
-      p2_rt->Next = p1_lft;
-      p1_lft->Prev = p2_rt;
-      p2_lft->Prev = p1_rt;
-      p1_rt->Next = p2_lft;
-      outRec1->Pts = p2_lft;
-    }
-    Side = esLeft;
-  } else
-  {
-    if(  e2->Side == esRight )
-    {
-      //a b c z y x
-      ReversePolyPtLinks(p2_lft);
-      p1_rt->Next = p2_rt;
-      p2_rt->Prev = p1_rt;
-      p2_lft->Next = p1_lft;
-      p1_lft->Prev = p2_lft;
-    } else
-    {
-      //a b c x y z
-      p1_rt->Next = p2_lft;
-      p2_lft->Prev = p1_rt;
-      p1_lft->Prev = p2_rt;
-      p2_rt->Next = p1_lft;
-    }
-    Side = esRight;
-  }
-
-  outRec1->BottomPt = 0;
-  if (holeStateRec == outRec2)
-  {
-    if (outRec2->FirstLeft != outRec1)
-      outRec1->FirstLeft = outRec2->FirstLeft;
-    outRec1->IsHole = outRec2->IsHole;
-  }
-  outRec2->Pts = 0;
-  outRec2->BottomPt = 0;
-  outRec2->FirstLeft = outRec1;
-
-  int OKIdx = e1->OutIdx;
-  int ObsoleteIdx = e2->OutIdx;
-
-  e1->OutIdx = Unassigned; //nb: safe because we only get here via AddLocalMaxPoly
-  e2->OutIdx = Unassigned;
-
-  TEdge* e = m_ActiveEdges;
-  while( e )
-  {
-    if( e->OutIdx == ObsoleteIdx )
-    {
-      e->OutIdx = OKIdx;
-      e->Side = Side;
-      break;
-    }
-    e = e->NextInAEL;
-  }
-
-  outRec2->Idx = outRec1->Idx;
-}
-//------------------------------------------------------------------------------
-
-OutRec* Clipper::CreateOutRec()
-{
-  OutRec* result = new OutRec;
-  result->IsHole = false;
-  result->IsOpen = false;
-  result->FirstLeft = 0;
-  result->Pts = 0;
-  result->BottomPt = 0;
-  result->PolyNd = 0;
-  m_PolyOuts.push_back(result);
-  result->Idx = (int)m_PolyOuts.size()-1;
-  return result;
-}
-//------------------------------------------------------------------------------
-
-OutPt* Clipper::AddOutPt(TEdge *e, const IntPoint &pt)
-{
-  if(  e->OutIdx < 0 )
-  {
-    OutRec *outRec = CreateOutRec();
-    outRec->IsOpen = (e->WindDelta == 0);
-    OutPt* newOp = new OutPt;
-    outRec->Pts = newOp;
-    newOp->Idx = outRec->Idx;
-    newOp->Pt = pt;
-    newOp->Next = newOp;
-    newOp->Prev = newOp;
-    if (!outRec->IsOpen)
-      SetHoleState(e, outRec);
-    e->OutIdx = outRec->Idx;
-    return newOp;
-  } else
-  {
-    OutRec *outRec = m_PolyOuts[e->OutIdx];
-    //OutRec.Pts is the 'Left-most' point & OutRec.Pts.Prev is the 'Right-most'
-    OutPt* op = outRec->Pts;
-
-	bool ToFront = (e->Side == esLeft);
-	if (ToFront && (pt == op->Pt)) return op;
-    else if (!ToFront && (pt == op->Prev->Pt)) return op->Prev;
-
-    OutPt* newOp = new OutPt;
-    newOp->Idx = outRec->Idx;
-    newOp->Pt = pt;
-    newOp->Next = op;
-    newOp->Prev = op->Prev;
-    newOp->Prev->Next = newOp;
-    op->Prev = newOp;
-    if (ToFront) outRec->Pts = newOp;
-    return newOp;
-  }
-}
-//------------------------------------------------------------------------------
-
-OutPt* Clipper::GetLastOutPt(TEdge *e)
-{
-	OutRec *outRec = m_PolyOuts[e->OutIdx];
-	if (e->Side == esLeft)
-		return outRec->Pts;
-	else
-		return outRec->Pts->Prev;
-}
-//------------------------------------------------------------------------------
-
-void Clipper::ProcessHorizontals()
-{
-  TEdge* horzEdge = m_SortedEdges;
-  while(horzEdge)
-  {
-    DeleteFromSEL(horzEdge);
-    ProcessHorizontal(horzEdge);
-    horzEdge = m_SortedEdges;
-  }
-}
-//------------------------------------------------------------------------------
-
-inline bool IsMinima(TEdge *e)
-{
-  return e  && (e->Prev->NextInLML != e) && (e->Next->NextInLML != e);
-}
-//------------------------------------------------------------------------------
-
-inline bool IsMaxima(TEdge *e, const cInt Y)
-{
-  return e && e->Top.y == Y && !e->NextInLML;
-}
-//------------------------------------------------------------------------------
-
-inline bool IsIntermediate(TEdge *e, const cInt Y)
-{
-  return e->Top.y == Y && e->NextInLML;
-}
-//------------------------------------------------------------------------------
-
-TEdge *GetMaximaPair(TEdge *e)
-{
-  TEdge* result = 0;
-  if ((e->Next->Top == e->Top) && !e->Next->NextInLML)
-    result = e->Next;
-  else if ((e->Prev->Top == e->Top) && !e->Prev->NextInLML)
-    result = e->Prev;
-
-  if (result && (result->OutIdx == Skip ||
-    //result is false if both NextInAEL & PrevInAEL are nil & not horizontal ...
-    (result->NextInAEL == result->PrevInAEL && !IsHorizontal(*result))))
-      return 0;
-  return result;
-}
-//------------------------------------------------------------------------------
-
-void Clipper::SwapPositionsInAEL(TEdge *Edge1, TEdge *Edge2)
-{
-  //check that one or other edge hasn't already been removed from AEL ...
-  if (Edge1->NextInAEL == Edge1->PrevInAEL || 
-    Edge2->NextInAEL == Edge2->PrevInAEL) return;
-
-  if(  Edge1->NextInAEL == Edge2 )
-  {
-    TEdge* Next = Edge2->NextInAEL;
-    if( Next ) Next->PrevInAEL = Edge1;
-    TEdge* Prev = Edge1->PrevInAEL;
-    if( Prev ) Prev->NextInAEL = Edge2;
-    Edge2->PrevInAEL = Prev;
-    Edge2->NextInAEL = Edge1;
-    Edge1->PrevInAEL = Edge2;
-    Edge1->NextInAEL = Next;
-  }
-  else if(  Edge2->NextInAEL == Edge1 )
-  {
-    TEdge* Next = Edge1->NextInAEL;
-    if( Next ) Next->PrevInAEL = Edge2;
-    TEdge* Prev = Edge2->PrevInAEL;
-    if( Prev ) Prev->NextInAEL = Edge1;
-    Edge1->PrevInAEL = Prev;
-    Edge1->NextInAEL = Edge2;
-    Edge2->PrevInAEL = Edge1;
-    Edge2->NextInAEL = Next;
-  }
-  else
-  {
-    TEdge* Next = Edge1->NextInAEL;
-    TEdge* Prev = Edge1->PrevInAEL;
-    Edge1->NextInAEL = Edge2->NextInAEL;
-    if( Edge1->NextInAEL ) Edge1->NextInAEL->PrevInAEL = Edge1;
-    Edge1->PrevInAEL = Edge2->PrevInAEL;
-    if( Edge1->PrevInAEL ) Edge1->PrevInAEL->NextInAEL = Edge1;
-    Edge2->NextInAEL = Next;
-    if( Edge2->NextInAEL ) Edge2->NextInAEL->PrevInAEL = Edge2;
-    Edge2->PrevInAEL = Prev;
-    if( Edge2->PrevInAEL ) Edge2->PrevInAEL->NextInAEL = Edge2;
-  }
-
-  if( !Edge1->PrevInAEL ) m_ActiveEdges = Edge1;
-  else if( !Edge2->PrevInAEL ) m_ActiveEdges = Edge2;
-}
-//------------------------------------------------------------------------------
-
-void Clipper::SwapPositionsInSEL(TEdge *Edge1, TEdge *Edge2)
-{
-  if(  !( Edge1->NextInSEL ) &&  !( Edge1->PrevInSEL ) ) return;
-  if(  !( Edge2->NextInSEL ) &&  !( Edge2->PrevInSEL ) ) return;
-
-  if(  Edge1->NextInSEL == Edge2 )
-  {
-    TEdge* Next = Edge2->NextInSEL;
-    if( Next ) Next->PrevInSEL = Edge1;
-    TEdge* Prev = Edge1->PrevInSEL;
-    if( Prev ) Prev->NextInSEL = Edge2;
-    Edge2->PrevInSEL = Prev;
-    Edge2->NextInSEL = Edge1;
-    Edge1->PrevInSEL = Edge2;
-    Edge1->NextInSEL = Next;
-  }
-  else if(  Edge2->NextInSEL == Edge1 )
-  {
-    TEdge* Next = Edge1->NextInSEL;
-    if( Next ) Next->PrevInSEL = Edge2;
-    TEdge* Prev = Edge2->PrevInSEL;
-    if( Prev ) Prev->NextInSEL = Edge1;
-    Edge1->PrevInSEL = Prev;
-    Edge1->NextInSEL = Edge2;
-    Edge2->PrevInSEL = Edge1;
-    Edge2->NextInSEL = Next;
-  }
-  else
-  {
-    TEdge* Next = Edge1->NextInSEL;
-    TEdge* Prev = Edge1->PrevInSEL;
-    Edge1->NextInSEL = Edge2->NextInSEL;
-    if( Edge1->NextInSEL ) Edge1->NextInSEL->PrevInSEL = Edge1;
-    Edge1->PrevInSEL = Edge2->PrevInSEL;
-    if( Edge1->PrevInSEL ) Edge1->PrevInSEL->NextInSEL = Edge1;
-    Edge2->NextInSEL = Next;
-    if( Edge2->NextInSEL ) Edge2->NextInSEL->PrevInSEL = Edge2;
-    Edge2->PrevInSEL = Prev;
-    if( Edge2->PrevInSEL ) Edge2->PrevInSEL->NextInSEL = Edge2;
-  }
-
-  if( !Edge1->PrevInSEL ) m_SortedEdges = Edge1;
-  else if( !Edge2->PrevInSEL ) m_SortedEdges = Edge2;
-}
-//------------------------------------------------------------------------------
-
-TEdge* GetNextInAEL(TEdge *e, Direction dir)
-{
-  return dir == dLeftToRight ? e->NextInAEL : e->PrevInAEL;
-}
-//------------------------------------------------------------------------------
-
-void GetHorzDirection(TEdge& HorzEdge, Direction& Dir, cInt& Left, cInt& Right)
-{
-  if (HorzEdge.Bot.x < HorzEdge.Top.x)
-  {
-    Left = HorzEdge.Bot.x;
-    Right = HorzEdge.Top.x;
-    Dir = dLeftToRight;
-  } else
-  {
-    Left = HorzEdge.Top.x;
-    Right = HorzEdge.Bot.x;
-    Dir = dRightToLeft;
-  }
-}
-//------------------------------------------------------------------------
-
-/*******************************************************************************
-* Notes: Horizontal edges (HEs) at scanline intersections (ie at the Top or    *
-* Bottom of a scanbeam) are processed as if layered. The order in which HEs    *
-* are processed doesn't matter. HEs intersect with other HE Bot.xs only [#]    *
-* (or they could intersect with Top.xs only, ie EITHER Bot.xs OR Top.xs),      *
-* and with other non-horizontal edges [*]. Once these intersections are        *
-* processed, intermediate HEs then 'promote' the Edge above (NextInLML) into   *
-* the AEL. These 'promoted' edges may in turn intersect [%] with other HEs.    *
-*******************************************************************************/
-
-void Clipper::ProcessHorizontal(TEdge *horzEdge)
-{
-  Direction dir;
-  cInt horzLeft, horzRight;
-  bool IsOpen = (horzEdge->OutIdx >= 0 && m_PolyOuts[horzEdge->OutIdx]->IsOpen);
-
-  GetHorzDirection(*horzEdge, dir, horzLeft, horzRight);
-
-  TEdge* eLastHorz = horzEdge, *eMaxPair = 0;
-  while (eLastHorz->NextInLML && IsHorizontal(*eLastHorz->NextInLML)) 
-    eLastHorz = eLastHorz->NextInLML;
-  if (!eLastHorz->NextInLML)
-    eMaxPair = GetMaximaPair(eLastHorz);
-
-  MaximaList::const_iterator maxIt;
-  MaximaList::const_reverse_iterator maxRit;
-  if (m_Maxima.size() > 0)
-  {
-      //get the first maxima in range (X) ...
-      if (dir == dLeftToRight)
-      {
-          maxIt = m_Maxima.begin();
-          while (maxIt != m_Maxima.end() && *maxIt <= horzEdge->Bot.x) maxIt++;
-          if (maxIt != m_Maxima.end() && *maxIt >= eLastHorz->Top.x)
-              maxIt = m_Maxima.end();
-      }
-      else
-      {
-          maxRit = m_Maxima.rbegin();
-          while (maxRit != m_Maxima.rend() && *maxRit > horzEdge->Bot.x) maxRit++;
-          if (maxRit != m_Maxima.rend() && *maxRit <= eLastHorz->Top.x)
-              maxRit = m_Maxima.rend();
-      }
-  }
-
-  OutPt* op1 = 0;
-
-  for (;;) //loop through consec. horizontal edges
-  {
-		  
-    bool IsLastHorz = (horzEdge == eLastHorz);
-    TEdge* e = GetNextInAEL(horzEdge, dir);
-    while(e)
-    {
-
-        //this code block inserts extra coords into horizontal edges (in output
-        //polygons) whereever maxima touch these horizontal edges. This helps
-        //'simplifying' polygons (ie if the Simplify property is set).
-        if (m_Maxima.size() > 0)
-        {
-            if (dir == dLeftToRight)
-            {
-                while (maxIt != m_Maxima.end() && *maxIt < e->Curr.x) 
-                {
-                  if (horzEdge->OutIdx >= 0 && !IsOpen)
-                    AddOutPt(horzEdge, IntPoint(*maxIt, horzEdge->Bot.y));
-                  maxIt++;
-                }
-            }
-            else
-            {
-                while (maxRit != m_Maxima.rend() && *maxRit > e->Curr.x)
-                {
-                  if (horzEdge->OutIdx >= 0 && !IsOpen)
-                    AddOutPt(horzEdge, IntPoint(*maxRit, horzEdge->Bot.y));
-                  maxRit++;
-                }
-            }
-        };
-
-        if ((dir == dLeftToRight && e->Curr.x > horzRight) ||
-			(dir == dRightToLeft && e->Curr.x < horzLeft)) break;
-
-		//Also break if we've got to the end of an intermediate horizontal edge ...
-		//nb: Smaller Dx's are to the right of larger Dx's ABOVE the horizontal.
-		if (e->Curr.x == horzEdge->Top.x && horzEdge->NextInLML && 
-			e->Dx < horzEdge->NextInLML->Dx) break;
-
-    if (horzEdge->OutIdx >= 0 && !IsOpen)  //note: may be done multiple times
-		{
-            op1 = AddOutPt(horzEdge, e->Curr);
-			TEdge* eNextHorz = m_SortedEdges;
-			while (eNextHorz)
-			{
-				if (eNextHorz->OutIdx >= 0 &&
-					HorzSegmentsOverlap(horzEdge->Bot.x,
-					horzEdge->Top.x, eNextHorz->Bot.x, eNextHorz->Top.x))
-				{
-                    OutPt* op2 = GetLastOutPt(eNextHorz);
-                    AddJoin(op2, op1, eNextHorz->Top);
-				}
-				eNextHorz = eNextHorz->NextInSEL;
-			}
-			AddGhostJoin(op1, horzEdge->Bot);
-		}
-		
-		//OK, so far we're still in range of the horizontal Edge  but make sure
-        //we're at the last of consec. horizontals when matching with eMaxPair
-        if(e == eMaxPair && IsLastHorz)
-        {
-          if (horzEdge->OutIdx >= 0)
-            AddLocalMaxPoly(horzEdge, eMaxPair, horzEdge->Top);
-          DeleteFromAEL(horzEdge);
-          DeleteFromAEL(eMaxPair);
-          return;
-        }
-        
-		if(dir == dLeftToRight)
-        {
-          IntPoint Pt = IntPoint(e->Curr.x, horzEdge->Curr.y);
-          IntersectEdges(horzEdge, e, Pt);
-        }
-        else
-        {
-          IntPoint Pt = IntPoint(e->Curr.x, horzEdge->Curr.y);
-          IntersectEdges( e, horzEdge, Pt);
-        }
-        TEdge* eNext = GetNextInAEL(e, dir);
-        SwapPositionsInAEL( horzEdge, e );
-        e = eNext;
-    } //end while(e)
-
-	//Break out of loop if HorzEdge.NextInLML is not also horizontal ...
-	if (!horzEdge->NextInLML || !IsHorizontal(*horzEdge->NextInLML)) break;
-
-	UpdateEdgeIntoAEL(horzEdge);
-    if (horzEdge->OutIdx >= 0) AddOutPt(horzEdge, horzEdge->Bot);
-    GetHorzDirection(*horzEdge, dir, horzLeft, horzRight);
-
-  } //end for (;;)
-
-  if (horzEdge->OutIdx >= 0 && !op1)
-  {
-      op1 = GetLastOutPt(horzEdge);
-      TEdge* eNextHorz = m_SortedEdges;
-      while (eNextHorz)
-      {
-          if (eNextHorz->OutIdx >= 0 &&
-              HorzSegmentsOverlap(horzEdge->Bot.x,
-              horzEdge->Top.x, eNextHorz->Bot.x, eNextHorz->Top.x))
-          {
-              OutPt* op2 = GetLastOutPt(eNextHorz);
-              AddJoin(op2, op1, eNextHorz->Top);
-          }
-          eNextHorz = eNextHorz->NextInSEL;
-      }
-      AddGhostJoin(op1, horzEdge->Top);
-  }
-
-  if (horzEdge->NextInLML)
-  {
-    if(horzEdge->OutIdx >= 0)
-    {
-      op1 = AddOutPt( horzEdge, horzEdge->Top);
-      UpdateEdgeIntoAEL(horzEdge);
-      if (horzEdge->WindDelta == 0) return;
-      //nb: HorzEdge is no longer horizontal here
-      TEdge* ePrev = horzEdge->PrevInAEL;
-      TEdge* eNext = horzEdge->NextInAEL;
-      if (ePrev && ePrev->Curr.x == horzEdge->Bot.x &&
-        ePrev->Curr.y == horzEdge->Bot.y && ePrev->WindDelta != 0 &&
-        (ePrev->OutIdx >= 0 && ePrev->Curr.y > ePrev->Top.y &&
-        SlopesEqual(*horzEdge, *ePrev, m_UseFullRange)))
-      {
-        OutPt* op2 = AddOutPt(ePrev, horzEdge->Bot);
-        AddJoin(op1, op2, horzEdge->Top);
-      }
-      else if (eNext && eNext->Curr.x == horzEdge->Bot.x &&
-        eNext->Curr.y == horzEdge->Bot.y && eNext->WindDelta != 0 &&
-        eNext->OutIdx >= 0 && eNext->Curr.y > eNext->Top.y &&
-        SlopesEqual(*horzEdge, *eNext, m_UseFullRange))
-      {
-        OutPt* op2 = AddOutPt(eNext, horzEdge->Bot);
-        AddJoin(op1, op2, horzEdge->Top);
-      }
-    }
-    else
-      UpdateEdgeIntoAEL(horzEdge); 
-  }
-  else
-  {
-    if (horzEdge->OutIdx >= 0) AddOutPt(horzEdge, horzEdge->Top);
-    DeleteFromAEL(horzEdge);
-  }
-}
-//------------------------------------------------------------------------------
-
-void Clipper::UpdateEdgeIntoAEL(TEdge *&e)
-{
-  if( !e->NextInLML ) throw
-    clipperException("UpdateEdgeIntoAEL: invalid call");
-
-  e->NextInLML->OutIdx = e->OutIdx;
-  TEdge* AelPrev = e->PrevInAEL;
-  TEdge* AelNext = e->NextInAEL;
-  if (AelPrev) AelPrev->NextInAEL = e->NextInLML;
-  else m_ActiveEdges = e->NextInLML;
-  if (AelNext) AelNext->PrevInAEL = e->NextInLML;
-  e->NextInLML->Side = e->Side;
-  e->NextInLML->WindDelta = e->WindDelta;
-  e->NextInLML->WindCnt = e->WindCnt;
-  e->NextInLML->WindCnt2 = e->WindCnt2;
-  e = e->NextInLML;
-  e->Curr = e->Bot;
-  e->PrevInAEL = AelPrev;
-  e->NextInAEL = AelNext;
-  if (!IsHorizontal(*e)) InsertScanbeam(e->Top.y);
-}
-//------------------------------------------------------------------------------
-
-bool Clipper::ProcessIntersections(const cInt topY)
-{
-  if( !m_ActiveEdges ) return true;
-  try {
-    BuildIntersectList(topY);
-    size_t IlSize = m_IntersectList.size();
-    if (IlSize == 0) return true;
-    if (IlSize == 1 || FixupIntersectionOrder()) ProcessIntersectList();
-    else return false;
-  }
-  catch(...) 
-  {
-    m_SortedEdges = 0;
-    DisposeIntersectNodes();
-    throw clipperException("ProcessIntersections error");
-  }
-  m_SortedEdges = 0;
-  return true;
-}
-//------------------------------------------------------------------------------
-
-void Clipper::DisposeIntersectNodes()
-{
-  for (size_t i = 0; i < m_IntersectList.size(); ++i )
-    delete m_IntersectList[i];
-  m_IntersectList.clear();
-}
-//------------------------------------------------------------------------------
-
-void Clipper::BuildIntersectList(const cInt topY)
-{
-  if ( !m_ActiveEdges ) return;
-
-  //prepare for sorting ...
-  TEdge* e = m_ActiveEdges;
-  m_SortedEdges = e;
-  while( e )
-  {
-    e->PrevInSEL = e->PrevInAEL;
-    e->NextInSEL = e->NextInAEL;
-    e->Curr.x = TopX( *e, topY );
-    e = e->NextInAEL;
-  }
-
-  //bubblesort ...
-  bool isModified;
-  do
-  {
-    isModified = false;
-    e = m_SortedEdges;
-    while( e->NextInSEL )
-    {
-      TEdge *eNext = e->NextInSEL;
-      IntPoint Pt;
-      if(e->Curr.x > eNext->Curr.x)
-      {
-        IntersectPoint(*e, *eNext, Pt);
-        IntersectNode * newNode = new IntersectNode;
-        newNode->Edge1 = e;
-        newNode->Edge2 = eNext;
-        newNode->Pt = Pt;
-        m_IntersectList.push_back(newNode);
-
-        SwapPositionsInSEL(e, eNext);
-        isModified = true;
-      }
-      else
-        e = eNext;
-    }
-    if( e->PrevInSEL ) e->PrevInSEL->NextInSEL = 0;
-    else break;
-  }
-  while ( isModified );
-  m_SortedEdges = 0; //important
-}
-//------------------------------------------------------------------------------
-
-
-void Clipper::ProcessIntersectList()
-{
-  for (size_t i = 0; i < m_IntersectList.size(); ++i)
-  {
-    IntersectNode* iNode = m_IntersectList[i];
-    {
-      IntersectEdges( iNode->Edge1, iNode->Edge2, iNode->Pt);
-      SwapPositionsInAEL( iNode->Edge1 , iNode->Edge2 );
-    }
-    delete iNode;
-  }
-  m_IntersectList.clear();
-}
-//------------------------------------------------------------------------------
-
-bool IntersectListSort(IntersectNode* node1, IntersectNode* node2)
-{
-  return node2->Pt.y < node1->Pt.y;
-}
-//------------------------------------------------------------------------------
-
-inline bool EdgesAdjacent(const IntersectNode &inode)
-{
-  return (inode.Edge1->NextInSEL == inode.Edge2) ||
-    (inode.Edge1->PrevInSEL == inode.Edge2);
-}
-//------------------------------------------------------------------------------
-
-bool Clipper::FixupIntersectionOrder()
-{
-  //pre-condition: intersections are sorted Bottom-most first.
-  //Now it's crucial that intersections are made only between adjacent edges,
-  //so to ensure this the order of intersections may need adjusting ...
-  CopyAELToSEL();
-  std::stable_sort(m_IntersectList.begin(), m_IntersectList.end(), IntersectListSort);
-  size_t cnt = m_IntersectList.size();
-  for (size_t i = 0; i < cnt; ++i) 
-  {
-    if (!EdgesAdjacent(*m_IntersectList[i]))
-    {
-      size_t j = i + 1;
-      while (j < cnt && !EdgesAdjacent(*m_IntersectList[j])) j++;
-      if (j == cnt)  return false;
-      std::swap(m_IntersectList[i], m_IntersectList[j]);
-    }
-    SwapPositionsInSEL(m_IntersectList[i]->Edge1, m_IntersectList[i]->Edge2);
-  }
-  return true;
-}
-//------------------------------------------------------------------------------
-
-void Clipper::DoMaxima(TEdge *e)
-{
-  TEdge* eMaxPair = GetMaximaPair(e);
-  if (!eMaxPair)
-  {
-    if (e->OutIdx >= 0)
-      AddOutPt(e, e->Top);
-    DeleteFromAEL(e);
-    return;
-  }
-
-  TEdge* eNext = e->NextInAEL;
-  while(eNext && eNext != eMaxPair)
-  {
-    IntersectEdges(e, eNext, e->Top);
-    SwapPositionsInAEL(e, eNext);
-    eNext = e->NextInAEL;
-  }
-
-  if(e->OutIdx == Unassigned && eMaxPair->OutIdx == Unassigned)
-  {
-    DeleteFromAEL(e);
-    DeleteFromAEL(eMaxPair);
-  }
-  else if( e->OutIdx >= 0 && eMaxPair->OutIdx >= 0 )
-  {
-    if (e->OutIdx >= 0) AddLocalMaxPoly(e, eMaxPair, e->Top);
-    DeleteFromAEL(e);
-    DeleteFromAEL(eMaxPair);
-  }
-#ifdef use_lines
-  else if (e->WindDelta == 0)
-  {
-    if (e->OutIdx >= 0) 
-    {
-      AddOutPt(e, e->Top);
-      e->OutIdx = Unassigned;
-    }
-    DeleteFromAEL(e);
-
-    if (eMaxPair->OutIdx >= 0)
-    {
-      AddOutPt(eMaxPair, e->Top);
-      eMaxPair->OutIdx = Unassigned;
-    }
-    DeleteFromAEL(eMaxPair);
-  } 
-#endif
-  else throw clipperException("DoMaxima error");
-}
-//------------------------------------------------------------------------------
-
-void Clipper::ProcessEdgesAtTopOfScanbeam(const cInt topY)
-{
-  TEdge* e = m_ActiveEdges;
-  while( e )
-  {
-    //1. process maxima, treating them as if they're 'bent' horizontal edges,
-    //   but exclude maxima with horizontal edges. nb: e can't be a horizontal.
-    bool IsMaximaEdge = IsMaxima(e, topY);
-
-    if(IsMaximaEdge)
-    {
-      TEdge* eMaxPair = GetMaximaPair(e);
-      IsMaximaEdge = (!eMaxPair || !IsHorizontal(*eMaxPair));
-    }
-
-    if(IsMaximaEdge)
-    {
-      if (m_StrictSimple) m_Maxima.push_back(e->Top.x);
-      TEdge* ePrev = e->PrevInAEL;
-      DoMaxima(e);
-      if( !ePrev ) e = m_ActiveEdges;
-      else e = ePrev->NextInAEL;
-    }
-    else
-    {
-      //2. promote horizontal edges, otherwise update Curr.x and Curr.y ...
-      if (IsIntermediate(e, topY) && IsHorizontal(*e->NextInLML))
-      {
-        UpdateEdgeIntoAEL(e);
-        if (e->OutIdx >= 0)
-          AddOutPt(e, e->Bot);
-        AddEdgeToSEL(e);
-      } 
-      else
-      {
-        e->Curr.x = TopX( *e, topY );
-        e->Curr.y = topY;
-      }
-
-      //When StrictlySimple and 'e' is being touched by another edge, then
-      //make sure both edges have a vertex here ...
-      if (m_StrictSimple)
-      {  
-        TEdge* ePrev = e->PrevInAEL;
-        if ((e->OutIdx >= 0) && (e->WindDelta != 0) && ePrev && (ePrev->OutIdx >= 0) &&
-          (ePrev->Curr.x == e->Curr.x) && (ePrev->WindDelta != 0))
-        {
-          IntPoint pt = e->Curr;
-#ifdef use_xyz
-          SetZ(pt, *ePrev, *e);
-#endif
-          OutPt* op = AddOutPt(ePrev, pt);
-          OutPt* op2 = AddOutPt(e, pt);
-          AddJoin(op, op2, pt); //StrictlySimple (type-3) join
-        }
-      }
-
-      e = e->NextInAEL;
-    }
-  }
-
-  //3. Process horizontals at the Top of the scanbeam ...
-  m_Maxima.sort();
-  ProcessHorizontals();
-  m_Maxima.clear();
-
-  //4. Promote intermediate vertices ...
-  e = m_ActiveEdges;
-  while(e)
-  {
-    if(IsIntermediate(e, topY))
-    {
-      OutPt* op = 0;
-      if( e->OutIdx >= 0 ) 
-        op = AddOutPt(e, e->Top);
-      UpdateEdgeIntoAEL(e);
-
-      //if output polygons share an edge, they'll need joining later ...
-      TEdge* ePrev = e->PrevInAEL;
-      TEdge* eNext = e->NextInAEL;
-      if (ePrev && ePrev->Curr.x == e->Bot.x &&
-        ePrev->Curr.y == e->Bot.y && op &&
-        ePrev->OutIdx >= 0 && ePrev->Curr.y > ePrev->Top.y &&
-        SlopesEqual(*e, *ePrev, m_UseFullRange) &&
-        (e->WindDelta != 0) && (ePrev->WindDelta != 0))
-      {
-        OutPt* op2 = AddOutPt(ePrev, e->Bot);
-        AddJoin(op, op2, e->Top);
-      }
-      else if (eNext && eNext->Curr.x == e->Bot.x &&
-        eNext->Curr.y == e->Bot.y && op &&
-        eNext->OutIdx >= 0 && eNext->Curr.y > eNext->Top.y &&
-        SlopesEqual(*e, *eNext, m_UseFullRange) &&
-        (e->WindDelta != 0) && (eNext->WindDelta != 0))
-      {
-        OutPt* op2 = AddOutPt(eNext, e->Bot);
-        AddJoin(op, op2, e->Top);
-      }
-    }
-    e = e->NextInAEL;
-  }
-}
-//------------------------------------------------------------------------------
-
-void Clipper::FixupOutPolyline(OutRec &outrec)
-{
-  OutPt *pp = outrec.Pts;
-  OutPt *lastPP = pp->Prev;
-  while (pp != lastPP)
-  {
-    pp = pp->Next;
-    if (pp->Pt == pp->Prev->Pt)
-    {
-      if (pp == lastPP) lastPP = pp->Prev;
-      OutPt *tmpPP = pp->Prev;
-      tmpPP->Next = pp->Next;
-      pp->Next->Prev = tmpPP;
-      delete pp;
-      pp = tmpPP;
-    }
-  }
-
-  if (pp == pp->Prev)
-  {
-    DisposeOutPts(pp);
-    outrec.Pts = 0;
-    return;
-  }
-}
-//------------------------------------------------------------------------------
-
-void Clipper::FixupOutPolygon(OutRec &outrec)
-{
-    //FixupOutPolygon() - removes duplicate points and simplifies consecutive
-    //parallel edges by removing the middle vertex.
-    OutPt *lastOK = 0;
-    outrec.BottomPt = 0;
-    OutPt *pp = outrec.Pts;
-    bool preserveCol = m_PreserveCollinear || m_StrictSimple;
-
-    for (;;)
-    {
-        if (pp->Prev == pp || pp->Prev == pp->Next)
-        {
-            DisposeOutPts(pp);
-            outrec.Pts = 0;
-            return;
-        }
-
-        //test for duplicate points and collinear edges ...
-        if ((pp->Pt == pp->Next->Pt) || (pp->Pt == pp->Prev->Pt) ||
-            (SlopesEqual(pp->Prev->Pt, pp->Pt, pp->Next->Pt, m_UseFullRange) &&
-            (!preserveCol || !Pt2IsBetweenPt1AndPt3(pp->Prev->Pt, pp->Pt, pp->Next->Pt))))
-        {
-            lastOK = 0;
-            OutPt *tmp = pp;
-            pp->Prev->Next = pp->Next;
-            pp->Next->Prev = pp->Prev;
-            pp = pp->Prev;
-            delete tmp;
-        }
-        else if (pp == lastOK) break;
-        else
-        {
-            if (!lastOK) lastOK = pp;
-            pp = pp->Next;
-        }
-    }
-    outrec.Pts = pp;
-}
-//------------------------------------------------------------------------------
-
-int PointCount(OutPt *Pts)
-{
-    if (!Pts) return 0;
-    int result = 0;
-    OutPt* p = Pts;
-    do
-    {
-        result++;
-        p = p->Next;
-    }
-    while (p != Pts);
-    return result;
-}
-//------------------------------------------------------------------------------
-
-void Clipper::BuildResult(Paths &polys)
-{
-  polys.reserve(m_PolyOuts.size());
-  for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); ++i)
-  {
-    if (!m_PolyOuts[i]->Pts) continue;
-    Path pg;
-    OutPt* p = m_PolyOuts[i]->Pts->Prev;
-    int cnt = PointCount(p);
-    if (cnt < 2) continue;
-    pg.reserve(cnt);
-    for (int j = 0; j < cnt; ++j)
-    {
-      pg.push_back(p->Pt);
-      p = p->Prev;
-    }
-    polys.push_back(pg);
-  }
-}
-//------------------------------------------------------------------------------
-
-void Clipper::BuildResult2(PolyTree& polytree)
-{
-    polytree.Clear();
-    polytree.AllNodes.reserve(m_PolyOuts.size());
-    //add each output polygon/contour to polytree ...
-    for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); i++)
-    {
-        OutRec* outRec = m_PolyOuts[i];
-        int cnt = PointCount(outRec->Pts);
-        if ((outRec->IsOpen && cnt < 2) || (!outRec->IsOpen && cnt < 3)) continue;
-        FixHoleLinkage(*outRec);
-        PolyNode* pn = new PolyNode();
-        //nb: polytree takes ownership of all the PolyNodes
-        polytree.AllNodes.push_back(pn);
-        outRec->PolyNd = pn;
-        pn->Parent = 0;
-        pn->Index = 0;
-        pn->Contour.reserve(cnt);
-        OutPt *op = outRec->Pts->Prev;
-        for (int j = 0; j < cnt; j++)
-        {
-            pn->Contour.push_back(op->Pt);
-            op = op->Prev;
-        }
-    }
-
-    //fixup PolyNode links etc ...
-    polytree.Childs.reserve(m_PolyOuts.size());
-    for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); i++)
-    {
-        OutRec* outRec = m_PolyOuts[i];
-        if (!outRec->PolyNd) continue;
-        if (outRec->IsOpen) 
-        {
-          outRec->PolyNd->m_IsOpen = true;
-          polytree.AddChild(*outRec->PolyNd);
-        }
-        else if (outRec->FirstLeft && outRec->FirstLeft->PolyNd) 
-          outRec->FirstLeft->PolyNd->AddChild(*outRec->PolyNd);
-        else
-          polytree.AddChild(*outRec->PolyNd);
-    }
-}
-//------------------------------------------------------------------------------
-
-void SwapIntersectNodes(IntersectNode &int1, IntersectNode &int2)
-{
-  //just swap the contents (because fIntersectNodes is a single-linked-list)
-  IntersectNode inode = int1; //gets a copy of Int1
-  int1.Edge1 = int2.Edge1;
-  int1.Edge2 = int2.Edge2;
-  int1.Pt = int2.Pt;
-  int2.Edge1 = inode.Edge1;
-  int2.Edge2 = inode.Edge2;
-  int2.Pt = inode.Pt;
-}
-//------------------------------------------------------------------------------
-
-inline bool E2InsertsBeforeE1(TEdge &e1, TEdge &e2)
-{
-  if (e2.Curr.x == e1.Curr.x) 
-  {
-    if (e2.Top.y > e1.Top.y)
-      return e2.Top.x < TopX(e1, e2.Top.y); 
-      else return e1.Top.x > TopX(e2, e1.Top.y);
-  } 
-  else return e2.Curr.x < e1.Curr.x;
-}
-//------------------------------------------------------------------------------
-
-bool GetOverlap(const cInt a1, const cInt a2, const cInt b1, const cInt b2, 
-    cInt& Left, cInt& Right)
-{
-  if (a1 < a2)
-  {
-    if (b1 < b2) {Left = std::max(a1,b1); Right = std::min(a2,b2);}
-    else {Left = std::max(a1,b2); Right = std::min(a2,b1);}
-  } 
-  else
-  {
-    if (b1 < b2) {Left = std::max(a2,b1); Right = std::min(a1,b2);}
-    else {Left = std::max(a2,b2); Right = std::min(a1,b1);}
-  }
-  return Left < Right;
-}
-//------------------------------------------------------------------------------
-
-inline void UpdateOutPtIdxs(OutRec& outrec)
-{  
-  OutPt* op = outrec.Pts;
-  do
-  {
-    op->Idx = outrec.Idx;
-    op = op->Prev;
-  }
-  while(op != outrec.Pts);
-}
-//------------------------------------------------------------------------------
-
-void Clipper::InsertEdgeIntoAEL(TEdge *edge, TEdge* startEdge)
-{
-  if(!m_ActiveEdges)
-  {
-    edge->PrevInAEL = 0;
-    edge->NextInAEL = 0;
-    m_ActiveEdges = edge;
-  }
-  else if(!startEdge && E2InsertsBeforeE1(*m_ActiveEdges, *edge))
-  {
-      edge->PrevInAEL = 0;
-      edge->NextInAEL = m_ActiveEdges;
-      m_ActiveEdges->PrevInAEL = edge;
-      m_ActiveEdges = edge;
-  } 
-  else
-  {
-    if(!startEdge) startEdge = m_ActiveEdges;
-    while(startEdge->NextInAEL  && 
-      !E2InsertsBeforeE1(*startEdge->NextInAEL , *edge))
-        startEdge = startEdge->NextInAEL;
-    edge->NextInAEL = startEdge->NextInAEL;
-    if(startEdge->NextInAEL) startEdge->NextInAEL->PrevInAEL = edge;
-    edge->PrevInAEL = startEdge;
-    startEdge->NextInAEL = edge;
-  }
-}
-//----------------------------------------------------------------------
-
-OutPt* DupOutPt(OutPt* outPt, bool InsertAfter)
-{
-  OutPt* result = new OutPt;
-  result->Pt = outPt->Pt;
-  result->Idx = outPt->Idx;
-  if (InsertAfter)
-  {
-    result->Next = outPt->Next;
-    result->Prev = outPt;
-    outPt->Next->Prev = result;
-    outPt->Next = result;
-  } 
-  else
-  {
-    result->Prev = outPt->Prev;
-    result->Next = outPt;
-    outPt->Prev->Next = result;
-    outPt->Prev = result;
-  }
-  return result;
-}
-//------------------------------------------------------------------------------
-
-bool JoinHorz(OutPt* op1, OutPt* op1b, OutPt* op2, OutPt* op2b,
-  const IntPoint Pt, bool DiscardLeft)
-{
-  Direction Dir1 = (op1->Pt.x > op1b->Pt.x ? dRightToLeft : dLeftToRight);
-  Direction Dir2 = (op2->Pt.x > op2b->Pt.x ? dRightToLeft : dLeftToRight);
-  if (Dir1 == Dir2) return false;
-
-  //When DiscardLeft, we want Op1b to be on the Left of Op1, otherwise we
-  //want Op1b to be on the Right. (And likewise with Op2 and Op2b.)
-  //So, to facilitate this while inserting Op1b and Op2b ...
-  //when DiscardLeft, make sure we're AT or RIGHT of Pt before adding Op1b,
-  //otherwise make sure we're AT or LEFT of Pt. (Likewise with Op2b.)
-  if (Dir1 == dLeftToRight) 
-  {
-    while (op1->Next->Pt.x <= Pt.x && 
-      op1->Next->Pt.x >= op1->Pt.x && op1->Next->Pt.y == Pt.y)  
-        op1 = op1->Next;
-    if (DiscardLeft && (op1->Pt.x != Pt.x)) op1 = op1->Next;
-    op1b = DupOutPt(op1, !DiscardLeft);
-    if (op1b->Pt != Pt) 
-    {
-      op1 = op1b;
-      op1->Pt = Pt;
-      op1b = DupOutPt(op1, !DiscardLeft);
-    }
-  } 
-  else
-  {
-    while (op1->Next->Pt.x >= Pt.x && 
-      op1->Next->Pt.x <= op1->Pt.x && op1->Next->Pt.y == Pt.y) 
-        op1 = op1->Next;
-    if (!DiscardLeft && (op1->Pt.x != Pt.x)) op1 = op1->Next;
-    op1b = DupOutPt(op1, DiscardLeft);
-    if (op1b->Pt != Pt)
-    {
-      op1 = op1b;
-      op1->Pt = Pt;
-      op1b = DupOutPt(op1, DiscardLeft);
-    }
-  }
-
-  if (Dir2 == dLeftToRight)
-  {
-    while (op2->Next->Pt.x <= Pt.x && 
-      op2->Next->Pt.x >= op2->Pt.x && op2->Next->Pt.y == Pt.y)
-        op2 = op2->Next;
-    if (DiscardLeft && (op2->Pt.x != Pt.x)) op2 = op2->Next;
-    op2b = DupOutPt(op2, !DiscardLeft);
-    if (op2b->Pt != Pt)
-    {
-      op2 = op2b;
-      op2->Pt = Pt;
-      op2b = DupOutPt(op2, !DiscardLeft);
-    };
-  } else
-  {
-    while (op2->Next->Pt.x >= Pt.x && 
-      op2->Next->Pt.x <= op2->Pt.x && op2->Next->Pt.y == Pt.y) 
-        op2 = op2->Next;
-    if (!DiscardLeft && (op2->Pt.x != Pt.x)) op2 = op2->Next;
-    op2b = DupOutPt(op2, DiscardLeft);
-    if (op2b->Pt != Pt)
-    {
-      op2 = op2b;
-      op2->Pt = Pt;
-      op2b = DupOutPt(op2, DiscardLeft);
-    };
-  };
-
-  if ((Dir1 == dLeftToRight) == DiscardLeft)
-  {
-    op1->Prev = op2;
-    op2->Next = op1;
-    op1b->Next = op2b;
-    op2b->Prev = op1b;
-  }
-  else
-  {
-    op1->Next = op2;
-    op2->Prev = op1;
-    op1b->Prev = op2b;
-    op2b->Next = op1b;
-  }
-  return true;
-}
-//------------------------------------------------------------------------------
-
-bool Clipper::JoinPoints(Join *j, OutRec* outRec1, OutRec* outRec2)
-{
-  OutPt *op1 = j->OutPt1, *op1b;
-  OutPt *op2 = j->OutPt2, *op2b;
-
-  //There are 3 kinds of joins for output polygons ...
-  //1. Horizontal joins where Join.OutPt1 & Join.OutPt2 are vertices anywhere
-  //along (horizontal) collinear edges (& Join.OffPt is on the same horizontal).
-  //2. Non-horizontal joins where Join.OutPt1 & Join.OutPt2 are at the same
-  //location at the Bottom of the overlapping segment (& Join.OffPt is above).
-  //3. StrictSimple joins where edges touch but are not collinear and where
-  //Join.OutPt1, Join.OutPt2 & Join.OffPt all share the same point.
-  bool isHorizontal = (j->OutPt1->Pt.y == j->OffPt.y);
-
-  if (isHorizontal  && (j->OffPt == j->OutPt1->Pt) &&
-  (j->OffPt == j->OutPt2->Pt))
-  {
-    //Strictly Simple join ...
-    if (outRec1 != outRec2) return false;
-    op1b = j->OutPt1->Next;
-    while (op1b != op1 && (op1b->Pt == j->OffPt)) 
-      op1b = op1b->Next;
-    bool reverse1 = (op1b->Pt.y > j->OffPt.y);
-    op2b = j->OutPt2->Next;
-    while (op2b != op2 && (op2b->Pt == j->OffPt)) 
-      op2b = op2b->Next;
-    bool reverse2 = (op2b->Pt.y > j->OffPt.y);
-    if (reverse1 == reverse2) return false;
-    if (reverse1)
-    {
-      op1b = DupOutPt(op1, false);
-      op2b = DupOutPt(op2, true);
-      op1->Prev = op2;
-      op2->Next = op1;
-      op1b->Next = op2b;
-      op2b->Prev = op1b;
-      j->OutPt1 = op1;
-      j->OutPt2 = op1b;
-      return true;
-    } else
-    {
-      op1b = DupOutPt(op1, true);
-      op2b = DupOutPt(op2, false);
-      op1->Next = op2;
-      op2->Prev = op1;
-      op1b->Prev = op2b;
-      op2b->Next = op1b;
-      j->OutPt1 = op1;
-      j->OutPt2 = op1b;
-      return true;
-    }
-  } 
-  else if (isHorizontal)
-  {
-    //treat horizontal joins differently to non-horizontal joins since with
-    //them we're not yet sure where the overlapping is. OutPt1.Pt & OutPt2.Pt
-    //may be anywhere along the horizontal edge.
-    op1b = op1;
-    while (op1->Prev->Pt.y == op1->Pt.y && op1->Prev != op1b && op1->Prev != op2)
-      op1 = op1->Prev;
-    while (op1b->Next->Pt.y == op1b->Pt.y && op1b->Next != op1 && op1b->Next != op2)
-      op1b = op1b->Next;
-    if (op1b->Next == op1 || op1b->Next == op2) return false; //a flat 'polygon'
-
-    op2b = op2;
-    while (op2->Prev->Pt.y == op2->Pt.y && op2->Prev != op2b && op2->Prev != op1b)
-      op2 = op2->Prev;
-    while (op2b->Next->Pt.y == op2b->Pt.y && op2b->Next != op2 && op2b->Next != op1)
-      op2b = op2b->Next;
-    if (op2b->Next == op2 || op2b->Next == op1) return false; //a flat 'polygon'
-
-    cInt Left, Right;
-    //Op1 --> Op1b & Op2 --> Op2b are the extremites of the horizontal edges
-    if (!GetOverlap(op1->Pt.x, op1b->Pt.x, op2->Pt.x, op2b->Pt.x, Left, Right))
-      return false;
-
-    //DiscardLeftSide: when overlapping edges are joined, a spike will created
-    //which needs to be cleaned up. However, we don't want Op1 or Op2 caught up
-    //on the discard Side as either may still be needed for other joins ...
-    IntPoint Pt;
-    bool DiscardLeftSide;
-    if (op1->Pt.x >= Left && op1->Pt.x <= Right) 
-    {
-      Pt = op1->Pt; DiscardLeftSide = (op1->Pt.x > op1b->Pt.x);
-    } 
-    else if (op2->Pt.x >= Left&& op2->Pt.x <= Right) 
-    {
-      Pt = op2->Pt; DiscardLeftSide = (op2->Pt.x > op2b->Pt.x);
-    } 
-    else if (op1b->Pt.x >= Left && op1b->Pt.x <= Right)
-    {
-      Pt = op1b->Pt; DiscardLeftSide = op1b->Pt.x > op1->Pt.x;
-    } 
-    else
-    {
-      Pt = op2b->Pt; DiscardLeftSide = (op2b->Pt.x > op2->Pt.x);
-    }
-    j->OutPt1 = op1; j->OutPt2 = op2;
-    return JoinHorz(op1, op1b, op2, op2b, Pt, DiscardLeftSide);
-  } else
-  {
-    //nb: For non-horizontal joins ...
-    //    1. Jr.OutPt1.Pt.y == Jr.OutPt2.Pt.y
-    //    2. Jr.OutPt1.Pt > Jr.OffPt.y
-
-    //make sure the polygons are correctly oriented ...
-    op1b = op1->Next;
-    while ((op1b->Pt == op1->Pt) && (op1b != op1)) op1b = op1b->Next;
-    bool Reverse1 = ((op1b->Pt.y > op1->Pt.y) ||
-      !SlopesEqual(op1->Pt, op1b->Pt, j->OffPt, m_UseFullRange));
-    if (Reverse1)
-    {
-      op1b = op1->Prev;
-      while ((op1b->Pt == op1->Pt) && (op1b != op1)) op1b = op1b->Prev;
-      if ((op1b->Pt.y > op1->Pt.y) ||
-        !SlopesEqual(op1->Pt, op1b->Pt, j->OffPt, m_UseFullRange)) return false;
-    };
-    op2b = op2->Next;
-    while ((op2b->Pt == op2->Pt) && (op2b != op2))op2b = op2b->Next;
-    bool Reverse2 = ((op2b->Pt.y > op2->Pt.y) ||
-      !SlopesEqual(op2->Pt, op2b->Pt, j->OffPt, m_UseFullRange));
-    if (Reverse2)
-    {
-      op2b = op2->Prev;
-      while ((op2b->Pt == op2->Pt) && (op2b != op2)) op2b = op2b->Prev;
-      if ((op2b->Pt.y > op2->Pt.y) ||
-        !SlopesEqual(op2->Pt, op2b->Pt, j->OffPt, m_UseFullRange)) return false;
-    }
-
-    if ((op1b == op1) || (op2b == op2) || (op1b == op2b) ||
-      ((outRec1 == outRec2) && (Reverse1 == Reverse2))) return false;
-
-    if (Reverse1)
-    {
-      op1b = DupOutPt(op1, false);
-      op2b = DupOutPt(op2, true);
-      op1->Prev = op2;
-      op2->Next = op1;
-      op1b->Next = op2b;
-      op2b->Prev = op1b;
-      j->OutPt1 = op1;
-      j->OutPt2 = op1b;
-      return true;
-    } else
-    {
-      op1b = DupOutPt(op1, true);
-      op2b = DupOutPt(op2, false);
-      op1->Next = op2;
-      op2->Prev = op1;
-      op1b->Prev = op2b;
-      op2b->Next = op1b;
-      j->OutPt1 = op1;
-      j->OutPt2 = op1b;
-      return true;
-    }
-  }
-}
-//----------------------------------------------------------------------
-
-static OutRec* ParseFirstLeft(OutRec* FirstLeft)
-{
-  while (FirstLeft && !FirstLeft->Pts)
-    FirstLeft = FirstLeft->FirstLeft;
-  return FirstLeft;
-}
-//------------------------------------------------------------------------------
-
-void Clipper::FixupFirstLefts1(OutRec* OldOutRec, OutRec* NewOutRec)
-{ 
-  //tests if NewOutRec contains the polygon before reassigning FirstLeft
-  for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); ++i)
-  {
-    OutRec* outRec = m_PolyOuts[i];
-    if (!outRec->Pts || !outRec->FirstLeft) continue;
-    OutRec* firstLeft = ParseFirstLeft(outRec->FirstLeft);
-    if (firstLeft == OldOutRec)
-    {
-      if (Poly2ContainsPoly1(outRec->Pts, NewOutRec->Pts))
-        outRec->FirstLeft = NewOutRec;
-    }
-  }
-}
-//----------------------------------------------------------------------
-
-void Clipper::FixupFirstLefts2(OutRec* OldOutRec, OutRec* NewOutRec)
-{ 
-  //reassigns FirstLeft WITHOUT testing if NewOutRec contains the polygon
-  for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); ++i)
-  {
-    OutRec* outRec = m_PolyOuts[i];
-    if (outRec->FirstLeft == OldOutRec) outRec->FirstLeft = NewOutRec;
-  }
-}
-//----------------------------------------------------------------------
-
-void Clipper::JoinCommonEdges()
-{
-  for (JoinList::size_type i = 0; i < m_Joins.size(); i++)
-  {
-    Join* join = m_Joins[i];
-
-    OutRec *outRec1 = GetOutRec(join->OutPt1->Idx);
-    OutRec *outRec2 = GetOutRec(join->OutPt2->Idx);
-
-    if (!outRec1->Pts || !outRec2->Pts) continue;
-    if (outRec1->IsOpen || outRec2->IsOpen) continue;
-
-    //get the polygon fragment with the correct hole state (FirstLeft)
-    //before calling JoinPoints() ...
-    OutRec *holeStateRec;
-    if (outRec1 == outRec2) holeStateRec = outRec1;
-    else if (Param1RightOfParam2(outRec1, outRec2)) holeStateRec = outRec2;
-    else if (Param1RightOfParam2(outRec2, outRec1)) holeStateRec = outRec1;
-    else holeStateRec = GetLowermostRec(outRec1, outRec2);
-
-    if (!JoinPoints(join, outRec1, outRec2)) continue;
-
-    if (outRec1 == outRec2)
-    {
-      //instead of joining two polygons, we've just created a new one by
-      //splitting one polygon into two.
-      outRec1->Pts = join->OutPt1;
-      outRec1->BottomPt = 0;
-      outRec2 = CreateOutRec();
-      outRec2->Pts = join->OutPt2;
-
-      //update all OutRec2.Pts Idx's ...
-      UpdateOutPtIdxs(*outRec2);
-
-      //We now need to check every OutRec.FirstLeft pointer. If it points
-      //to OutRec1 it may need to point to OutRec2 instead ...
-      if (m_UsingPolyTree)
-        for (PolyOutList::size_type j = 0; j < m_PolyOuts.size() - 1; j++)
-        {
-          OutRec* oRec = m_PolyOuts[j];
-          if (!oRec->Pts || ParseFirstLeft(oRec->FirstLeft) != outRec1 ||
-            oRec->IsHole == outRec1->IsHole) continue;
-          if (Poly2ContainsPoly1(oRec->Pts, join->OutPt2))
-            oRec->FirstLeft = outRec2;
-        }
-
-      if (Poly2ContainsPoly1(outRec2->Pts, outRec1->Pts))
-      {
-        //outRec2 is contained by outRec1 ...
-        outRec2->IsHole = !outRec1->IsHole;
-        outRec2->FirstLeft = outRec1;
-
-        //fixup FirstLeft pointers that may need reassigning to OutRec1
-        if (m_UsingPolyTree) FixupFirstLefts2(outRec2, outRec1);
-
-        if ((outRec2->IsHole ^ m_ReverseOutput) == (Area(*outRec2) > 0))
-          ReversePolyPtLinks(outRec2->Pts);
-            
-      } else if (Poly2ContainsPoly1(outRec1->Pts, outRec2->Pts))
-      {
-        //outRec1 is contained by outRec2 ...
-        outRec2->IsHole = outRec1->IsHole;
-        outRec1->IsHole = !outRec2->IsHole;
-        outRec2->FirstLeft = outRec1->FirstLeft;
-        outRec1->FirstLeft = outRec2;
-
-        //fixup FirstLeft pointers that may need reassigning to OutRec1
-        if (m_UsingPolyTree) FixupFirstLefts2(outRec1, outRec2);
-
-        if ((outRec1->IsHole ^ m_ReverseOutput) == (Area(*outRec1) > 0))
-          ReversePolyPtLinks(outRec1->Pts);
-      } 
-      else
-      {
-        //the 2 polygons are completely separate ...
-        outRec2->IsHole = outRec1->IsHole;
-        outRec2->FirstLeft = outRec1->FirstLeft;
-
-        //fixup FirstLeft pointers that may need reassigning to OutRec2
-        if (m_UsingPolyTree) FixupFirstLefts1(outRec1, outRec2);
-      }
-     
-    } else
-    {
-      //joined 2 polygons together ...
-
-      outRec2->Pts = 0;
-      outRec2->BottomPt = 0;
-      outRec2->Idx = outRec1->Idx;
-
-      outRec1->IsHole = holeStateRec->IsHole;
-      if (holeStateRec == outRec2) 
-        outRec1->FirstLeft = outRec2->FirstLeft;
-      outRec2->FirstLeft = outRec1;
-
-      //fixup FirstLeft pointers that may need reassigning to OutRec1
-      if (m_UsingPolyTree) FixupFirstLefts2(outRec2, outRec1);
-    }
-  }
-}
-
-//------------------------------------------------------------------------------
-// ClipperOffset support functions ...
-//------------------------------------------------------------------------------
-
-DoublePoint GetUnitNormal(const IntPoint &pt1, const IntPoint &pt2)
-{
-  if(pt2.x == pt1.x && pt2.y == pt1.y) 
-    return DoublePoint(0, 0);
-
-  double Dx = (double)(pt2.x - pt1.x);
-  double dy = (double)(pt2.y - pt1.y);
-  double f = 1 *1.0/ std::sqrt( Dx*Dx + dy*dy );
-  Dx *= f;
-  dy *= f;
-  return DoublePoint(dy, -Dx);
-}
-
-//------------------------------------------------------------------------------
-// ClipperOffset class
-//------------------------------------------------------------------------------
-
-ClipperOffset::ClipperOffset(double miterLimit, double arcTolerance)
-{
-  this->MiterLimit = miterLimit;
-  this->ArcTolerance = arcTolerance;
-  m_lowest.x = -1;
-}
-//------------------------------------------------------------------------------
-
-ClipperOffset::~ClipperOffset()
-{
-  Clear();
-}
-//------------------------------------------------------------------------------
-
-void ClipperOffset::Clear()
-{
-  for (int i = 0; i < m_polyNodes.ChildCount(); ++i)
-    delete m_polyNodes.Childs[i];
-  m_polyNodes.Childs.clear();
-  m_lowest.x = -1;
-}
-//------------------------------------------------------------------------------
-
-void ClipperOffset::AddPath(const Path& path, JoinType joinType, EndType endType)
-{
-  int highI = (int)path.size() - 1;
-  if (highI < 0) return;
-  PolyNode* newNode = new PolyNode();
-  newNode->m_jointype = joinType;
-  newNode->m_endtype = endType;
-
-  //strip duplicate points from path and also get index to the lowest point ...
-  if (endType == etClosedLine || endType == etClosedPolygon)
-    while (highI > 0 && path[0] == path[highI]) highI--;
-  newNode->Contour.reserve(highI + 1);
-  newNode->Contour.push_back(path[0]);
-  int j = 0, k = 0;
-  for (int i = 1; i <= highI; i++)
-    if (newNode->Contour[j] != path[i])
-    {
-      j++;
-      newNode->Contour.push_back(path[i]);
-      if (path[i].y > newNode->Contour[k].y ||
-        (path[i].y == newNode->Contour[k].y &&
-        path[i].x < newNode->Contour[k].x)) k = j;
-    }
-  if (endType == etClosedPolygon && j < 2)
-  {
-    delete newNode;
-    return;
-  }
-  m_polyNodes.AddChild(*newNode);
-
-  //if this path's lowest pt is lower than all the others then update m_lowest
-  if (endType != etClosedPolygon) return;
-  if (m_lowest.x < 0)
-    m_lowest = IntPoint(m_polyNodes.ChildCount() - 1, k);
-  else
-  {
-    IntPoint ip = m_polyNodes.Childs[(int)m_lowest.x]->Contour[(int)m_lowest.y];
-    if (newNode->Contour[k].y > ip.y ||
-      (newNode->Contour[k].y == ip.y &&
-      newNode->Contour[k].x < ip.x))
-      m_lowest = IntPoint(m_polyNodes.ChildCount() - 1, k);
-  }
-}
-//------------------------------------------------------------------------------
-
-void ClipperOffset::AddPaths(const Paths& paths, JoinType joinType, EndType endType)
-{
-  for (Paths::size_type i = 0; i < paths.size(); ++i)
-    AddPath(paths[i], joinType, endType);
-}
-//------------------------------------------------------------------------------
-
-void ClipperOffset::FixOrientations()
-{
-  //fixup orientations of all closed paths if the orientation of the
-  //closed path with the lowermost vertex is wrong ...
-  if (m_lowest.x >= 0 && 
-    !Orientation(m_polyNodes.Childs[(int)m_lowest.x]->Contour))
-  {
-    for (int i = 0; i < m_polyNodes.ChildCount(); ++i)
-    {
-      PolyNode& node = *m_polyNodes.Childs[i];
-      if (node.m_endtype == etClosedPolygon ||
-        (node.m_endtype == etClosedLine && Orientation(node.Contour)))
-          ReversePath(node.Contour);
-    }
-  } else
-  {
-    for (int i = 0; i < m_polyNodes.ChildCount(); ++i)
-    {
-      PolyNode& node = *m_polyNodes.Childs[i];
-      if (node.m_endtype == etClosedLine && !Orientation(node.Contour))
-        ReversePath(node.Contour);
-    }
-  }
-}
-//------------------------------------------------------------------------------
-
-void ClipperOffset::Execute(Paths& solution, double delta)
-{
-  solution.clear();
-  FixOrientations();
-  DoOffset(delta);
-  
-  //now clean up 'corners' ...
-  Clipper clpr;
-  clpr.AddPaths(m_destPolys, ptSubject, true);
-  if (delta > 0)
-  {
-    clpr.Execute(ctUnion, solution, pftPositive, pftPositive);
-  }
-  else
-  {
-    IntRect r = clpr.GetBounds();
-    Path outer(4);
-    outer[0] = IntPoint(r.left - 10, r.bottom + 10);
-    outer[1] = IntPoint(r.right + 10, r.bottom + 10);
-    outer[2] = IntPoint(r.right + 10, r.top - 10);
-    outer[3] = IntPoint(r.left - 10, r.top - 10);
-
-    clpr.AddPath(outer, ptSubject, true);
-    clpr.ReverseSolution(true);
-    clpr.Execute(ctUnion, solution, pftNegative, pftNegative);
-    if (solution.size() > 0) solution.erase(solution.begin());
-  }
-}
-//------------------------------------------------------------------------------
-
-void ClipperOffset::Execute(PolyTree& solution, double delta)
-{
-  solution.Clear();
-  FixOrientations();
-  DoOffset(delta);
-
-  //now clean up 'corners' ...
-  Clipper clpr;
-  clpr.AddPaths(m_destPolys, ptSubject, true);
-  if (delta > 0)
-  {
-    clpr.Execute(ctUnion, solution, pftPositive, pftPositive);
-  }
-  else
-  {
-    IntRect r = clpr.GetBounds();
-    Path outer(4);
-    outer[0] = IntPoint(r.left - 10, r.bottom + 10);
-    outer[1] = IntPoint(r.right + 10, r.bottom + 10);
-    outer[2] = IntPoint(r.right + 10, r.top - 10);
-    outer[3] = IntPoint(r.left - 10, r.top - 10);
-
-    clpr.AddPath(outer, ptSubject, true);
-    clpr.ReverseSolution(true);
-    clpr.Execute(ctUnion, solution, pftNegative, pftNegative);
-    //remove the outer PolyNode rectangle ...
-    if (solution.ChildCount() == 1 && solution.Childs[0]->ChildCount() > 0)
-    {
-      PolyNode* outerNode = solution.Childs[0];
-      solution.Childs.reserve(outerNode->ChildCount());
-      solution.Childs[0] = outerNode->Childs[0];
-      solution.Childs[0]->Parent = outerNode->Parent;
-      for (int i = 1; i < outerNode->ChildCount(); ++i)
-        solution.AddChild(*outerNode->Childs[i]);
-    }
-    else
-      solution.Clear();
-  }
-}
-//------------------------------------------------------------------------------
-
-void ClipperOffset::DoOffset(double delta)
-{
-  m_destPolys.clear();
-  m_delta = delta;
-
-  //if Zero offset, just copy any CLOSED polygons to m_p and return ...
-  if (NEAR_ZERO(delta)) 
-  {
-    m_destPolys.reserve(m_polyNodes.ChildCount());
-    for (int i = 0; i < m_polyNodes.ChildCount(); i++)
-    {
-      PolyNode& node = *m_polyNodes.Childs[i];
-      if (node.m_endtype == etClosedPolygon)
-        m_destPolys.push_back(node.Contour);
-    }
-    return;
-  }
-
-  //see offset_triginometry3.svg in the documentation folder ...
-  if (MiterLimit > 2) m_miterLim = 2/(MiterLimit * MiterLimit);
-  else m_miterLim = 0.5;
-
-  double y;
-  if (ArcTolerance <= 0.0) y = def_arc_tolerance;
-  else if (ArcTolerance > std::fabs(delta) * def_arc_tolerance) 
-    y = std::fabs(delta) * def_arc_tolerance;
-  else y = ArcTolerance;
-  //see offset_triginometry2.svg in the documentation folder ...
-  double steps = pi / std::acos(1 - y / std::fabs(delta));
-  if (steps > std::fabs(delta) * pi) 
-    steps = std::fabs(delta) * pi;  //ie excessive precision check
-  m_sin = std::sin(two_pi / steps);
-  m_cos = std::cos(two_pi / steps);
-  m_StepsPerRad = steps / two_pi;
-  if (delta < 0.0) m_sin = -m_sin;
-
-  m_destPolys.reserve(m_polyNodes.ChildCount() * 2);
-  for (int i = 0; i < m_polyNodes.ChildCount(); i++)
-  {
-    PolyNode& node = *m_polyNodes.Childs[i];
-    m_srcPoly = node.Contour;
-
-    int len = (int)m_srcPoly.size();
-    if (len == 0 || (delta <= 0 && (len < 3 || node.m_endtype != etClosedPolygon)))
-        continue;
-
-    m_destPoly.clear();
-    if (len == 1)
-    {
-      if (node.m_jointype == jtRound)
-      {
-        double X = 1.0, Y = 0.0;
-        for (cInt j = 1; j <= steps; j++)
-        {
-          m_destPoly.push_back(IntPoint(
-            Round(m_srcPoly[0].x + X * delta),
-            Round(m_srcPoly[0].y + Y * delta)));
-          double X2 = X;
-          X = X * m_cos - m_sin * Y;
-          Y = X2 * m_sin + Y * m_cos;
-        }
-      }
-      else
-      {
-        double X = -1.0, Y = -1.0;
-        for (int j = 0; j < 4; ++j)
-        {
-          m_destPoly.push_back(IntPoint(
-            Round(m_srcPoly[0].x + X * delta),
-            Round(m_srcPoly[0].y + Y * delta)));
-          if (X < 0) X = 1;
-          else if (Y < 0) Y = 1;
-          else X = -1;
-        }
-      }
-      m_destPolys.push_back(m_destPoly);
-      continue;
-    }
-    //build m_normals ...
-    m_normals.clear();
-    m_normals.reserve(len);
-    for (int j = 0; j < len - 1; ++j)
-      m_normals.push_back(GetUnitNormal(m_srcPoly[j], m_srcPoly[j + 1]));
-    if (node.m_endtype == etClosedLine || node.m_endtype == etClosedPolygon)
-      m_normals.push_back(GetUnitNormal(m_srcPoly[len - 1], m_srcPoly[0]));
-    else
-      m_normals.push_back(DoublePoint(m_normals[len - 2]));
-
-    if (node.m_endtype == etClosedPolygon)
-    {
-      int k = len - 1;
-      for (int j = 0; j < len; ++j)
-        OffsetPoint(j, k, node.m_jointype);
-      m_destPolys.push_back(m_destPoly);
-    }
-    else if (node.m_endtype == etClosedLine)
-    {
-      int k = len - 1;
-      for (int j = 0; j < len; ++j)
-        OffsetPoint(j, k, node.m_jointype);
-      m_destPolys.push_back(m_destPoly);
-      m_destPoly.clear();
-      //re-build m_normals ...
-      DoublePoint n = m_normals[len -1];
-      for (int j = len - 1; j > 0; j--)
-        m_normals[j] = DoublePoint(-m_normals[j - 1].x, -m_normals[j - 1].y);
-      m_normals[0] = DoublePoint(-n.x, -n.y);
-      k = 0;
-      for (int j = len - 1; j >= 0; j--)
-        OffsetPoint(j, k, node.m_jointype);
-      m_destPolys.push_back(m_destPoly);
-    }
-    else
-    {
-      int k = 0;
-      for (int j = 1; j < len - 1; ++j)
-        OffsetPoint(j, k, node.m_jointype);
-
-      IntPoint pt1;
-      if (node.m_endtype == etOpenButt)
-      {
-        int j = len - 1;
-        pt1 = IntPoint((cInt)Round(m_srcPoly[j].x + m_normals[j].x *
-          delta), (cInt)Round(m_srcPoly[j].y + m_normals[j].y * delta));
-        m_destPoly.push_back(pt1);
-        pt1 = IntPoint((cInt)Round(m_srcPoly[j].x - m_normals[j].x *
-          delta), (cInt)Round(m_srcPoly[j].y - m_normals[j].y * delta));
-        m_destPoly.push_back(pt1);
-      }
-      else
-      {
-        int j = len - 1;
-        k = len - 2;
-        m_sinA = 0;
-        m_normals[j] = DoublePoint(-m_normals[j].x, -m_normals[j].y);
-        if (node.m_endtype == etOpenSquare)
-          DoSquare(j, k);
-        else
-          DoRound(j, k);
-      }
-
-      //re-build m_normals ...
-      for (int j = len - 1; j > 0; j--)
-        m_normals[j] = DoublePoint(-m_normals[j - 1].x, -m_normals[j - 1].y);
-      m_normals[0] = DoublePoint(-m_normals[1].x, -m_normals[1].y);
-
-      k = len - 1;
-      for (int j = k - 1; j > 0; --j) OffsetPoint(j, k, node.m_jointype);
-
-      if (node.m_endtype == etOpenButt)
-      {
-        pt1 = IntPoint((cInt)Round(m_srcPoly[0].x - m_normals[0].x * delta),
-          (cInt)Round(m_srcPoly[0].y - m_normals[0].y * delta));
-        m_destPoly.push_back(pt1);
-        pt1 = IntPoint((cInt)Round(m_srcPoly[0].x + m_normals[0].x * delta),
-          (cInt)Round(m_srcPoly[0].y + m_normals[0].y * delta));
-        m_destPoly.push_back(pt1);
-      }
-      else
-      {
-        k = 1;
-        m_sinA = 0;
-        if (node.m_endtype == etOpenSquare)
-          DoSquare(0, 1);
-        else
-          DoRound(0, 1);
-      }
-      m_destPolys.push_back(m_destPoly);
-    }
-  }
-}
-//------------------------------------------------------------------------------
-
-void ClipperOffset::OffsetPoint(int j, int& k, JoinType jointype)
-{
-  //cross product ...
-  m_sinA = (m_normals[k].x * m_normals[j].y - m_normals[j].x * m_normals[k].y);
-  if (std::fabs(m_sinA * m_delta) < 1.0) 
-  {
-    //dot product ...
-    double cosA = (m_normals[k].x * m_normals[j].x + m_normals[j].y * m_normals[k].y ); 
-    if (cosA > 0) // angle => 0 degrees
-    {
-      m_destPoly.push_back(IntPoint(Round(m_srcPoly[j].x + m_normals[k].x * m_delta),
-        Round(m_srcPoly[j].y + m_normals[k].y * m_delta)));
-      return; 
-    }
-    //else angle => 180 degrees   
-  }
-  else if (m_sinA > 1.0) m_sinA = 1.0;
-  else if (m_sinA < -1.0) m_sinA = -1.0;
-
-  if (m_sinA * m_delta < 0)
-  {
-    m_destPoly.push_back(IntPoint(Round(m_srcPoly[j].x + m_normals[k].x * m_delta),
-      Round(m_srcPoly[j].y + m_normals[k].y * m_delta)));
-    m_destPoly.push_back(m_srcPoly[j]);
-    m_destPoly.push_back(IntPoint(Round(m_srcPoly[j].x + m_normals[j].x * m_delta),
-      Round(m_srcPoly[j].y + m_normals[j].y * m_delta)));
-  }
-  else
-    switch (jointype)
-    {
-      case jtMiter:
-        {
-          double r = 1 + (m_normals[j].x * m_normals[k].x +
-            m_normals[j].y * m_normals[k].y);
-          if (r >= m_miterLim) DoMiter(j, k, r); else DoSquare(j, k);
-          break;
-        }
-      case jtSquare: DoSquare(j, k); break;
-      case jtRound: DoRound(j, k); break;
-    }
-  k = j;
-}
-//------------------------------------------------------------------------------
-
-void ClipperOffset::DoSquare(int j, int k)
-{
-  double dx = std::tan(std::atan2(m_sinA,
-      m_normals[k].x * m_normals[j].x + m_normals[k].y * m_normals[j].y) / 4);
-  m_destPoly.push_back(IntPoint(
-      Round(m_srcPoly[j].x + m_delta * (m_normals[k].x - m_normals[k].y * dx)),
-      Round(m_srcPoly[j].y + m_delta * (m_normals[k].y + m_normals[k].x * dx))));
-  m_destPoly.push_back(IntPoint(
-      Round(m_srcPoly[j].x + m_delta * (m_normals[j].x + m_normals[j].y * dx)),
-      Round(m_srcPoly[j].y + m_delta * (m_normals[j].y - m_normals[j].x * dx))));
-}
-//------------------------------------------------------------------------------
-
-void ClipperOffset::DoMiter(int j, int k, double r)
-{
-  double q = m_delta / r;
-  m_destPoly.push_back(IntPoint(Round(m_srcPoly[j].x + (m_normals[k].x + m_normals[j].x) * q),
-      Round(m_srcPoly[j].y + (m_normals[k].y + m_normals[j].y) * q)));
-}
-//------------------------------------------------------------------------------
-
-void ClipperOffset::DoRound(int j, int k)
-{
-  double a = std::atan2(m_sinA,
-  m_normals[k].x * m_normals[j].x + m_normals[k].y * m_normals[j].y);
-  int steps = std::max((int)Round(m_StepsPerRad * std::fabs(a)), 1);
-
-  double X = m_normals[k].x, Y = m_normals[k].y, X2;
-  for (int i = 0; i < steps; ++i)
-  {
-    m_destPoly.push_back(IntPoint(
-        Round(m_srcPoly[j].x + X * m_delta),
-        Round(m_srcPoly[j].y + Y * m_delta)));
-    X2 = X;
-    X = X * m_cos - m_sin * Y;
-    Y = X2 * m_sin + Y * m_cos;
-  }
-  m_destPoly.push_back(IntPoint(
-  Round(m_srcPoly[j].x + m_normals[j].x * m_delta),
-  Round(m_srcPoly[j].y + m_normals[j].y * m_delta)));
-}
-
-//------------------------------------------------------------------------------
-// Miscellaneous public functions
-//------------------------------------------------------------------------------
-
-void Clipper::DoSimplePolygons()
-{
-  PolyOutList::size_type i = 0;
-  while (i < m_PolyOuts.size()) 
-  {
-    OutRec* outrec = m_PolyOuts[i++];
-    OutPt* op = outrec->Pts;
-    if (!op || outrec->IsOpen) continue;
-    do //for each Pt in Polygon until duplicate found do ...
-    {
-      OutPt* op2 = op->Next;
-      while (op2 != outrec->Pts) 
-      {
-        if ((op->Pt == op2->Pt) && op2->Next != op && op2->Prev != op) 
-        {
-          //split the polygon into two ...
-          OutPt* op3 = op->Prev;
-          OutPt* op4 = op2->Prev;
-          op->Prev = op4;
-          op4->Next = op;
-          op2->Prev = op3;
-          op3->Next = op2;
-
-          outrec->Pts = op;
-          OutRec* outrec2 = CreateOutRec();
-          outrec2->Pts = op2;
-          UpdateOutPtIdxs(*outrec2);
-          if (Poly2ContainsPoly1(outrec2->Pts, outrec->Pts))
-          {
-            //OutRec2 is contained by OutRec1 ...
-            outrec2->IsHole = !outrec->IsHole;
-            outrec2->FirstLeft = outrec;
-            if (m_UsingPolyTree) FixupFirstLefts2(outrec2, outrec);
-          }
-          else
-            if (Poly2ContainsPoly1(outrec->Pts, outrec2->Pts))
-          {
-            //OutRec1 is contained by OutRec2 ...
-            outrec2->IsHole = outrec->IsHole;
-            outrec->IsHole = !outrec2->IsHole;
-            outrec2->FirstLeft = outrec->FirstLeft;
-            outrec->FirstLeft = outrec2;
-            if (m_UsingPolyTree) FixupFirstLefts2(outrec, outrec2);
-            }
-            else
-          {
-            //the 2 polygons are separate ...
-            outrec2->IsHole = outrec->IsHole;
-            outrec2->FirstLeft = outrec->FirstLeft;
-            if (m_UsingPolyTree) FixupFirstLefts1(outrec, outrec2);
-            }
-          op2 = op; //ie get ready for the Next iteration
-        }
-        op2 = op2->Next;
-      }
-      op = op->Next;
-    }
-    while (op != outrec->Pts);
-  }
-}
-//------------------------------------------------------------------------------
-
-void ReversePath(Path& p)
-{
-  std::reverse(p.begin(), p.end());
-}
-//------------------------------------------------------------------------------
-
-void ReversePaths(Paths& p)
-{
-  for (Paths::size_type i = 0; i < p.size(); ++i)
-    ReversePath(p[i]);
-}
-//------------------------------------------------------------------------------
-
-void SimplifyPolygon(const Path &in_poly, Paths &out_polys, PolyFillType fillType)
-{
-  Clipper c;
-  c.StrictlySimple(true);
-  c.AddPath(in_poly, ptSubject, true);
-  c.Execute(ctUnion, out_polys, fillType, fillType);
-}
-//------------------------------------------------------------------------------
-
-void SimplifyPolygons(const Paths &in_polys, Paths &out_polys, PolyFillType fillType)
-{
-  Clipper c;
-  c.StrictlySimple(true);
-  c.AddPaths(in_polys, ptSubject, true);
-  c.Execute(ctUnion, out_polys, fillType, fillType);
-}
-//------------------------------------------------------------------------------
-
-void SimplifyPolygons(Paths &polys, PolyFillType fillType)
-{
-  SimplifyPolygons(polys, polys, fillType);
-}
-//------------------------------------------------------------------------------
-
-inline double DistanceSqrd(const IntPoint& pt1, const IntPoint& pt2)
-{
-  double Dx = ((double)pt1.x - pt2.x);
-  double dy = ((double)pt1.y - pt2.y);
-  return (Dx*Dx + dy*dy);
-}
-//------------------------------------------------------------------------------
-
-double DistanceFromLineSqrd(
-  const IntPoint& pt, const IntPoint& ln1, const IntPoint& ln2)
-{
-  //The equation of a line in general form (Ax + By + C = 0)
-  //given 2 points (x�,y�) & (x�,y�) is ...
-  //(y� - y�)x + (x� - x�)y + (y� - y�)x� - (x� - x�)y� = 0
-  //A = (y� - y�); B = (x� - x�); C = (y� - y�)x� - (x� - x�)y�
-  //perpendicular distance of point (x�,y�) = (Ax� + By� + C)/Sqrt(A� + B�)
-  //see http://en.wikipedia.org/wiki/Perpendicular_distance
-  double A = double(ln1.y - ln2.y);
-  double B = double(ln2.x - ln1.x);
-  double C = A * ln1.x  + B * ln1.y;
-  C = A * pt.x + B * pt.y - C;
-  return (C * C) / (A * A + B * B);
-}
-//---------------------------------------------------------------------------
-
-bool SlopesNearCollinear(const IntPoint& pt1, 
-    const IntPoint& pt2, const IntPoint& pt3, double distSqrd)
-{
-  //this function is more accurate when the point that's geometrically
-  //between the other 2 points is the one that's tested for distance.
-  //ie makes it more likely to pick up 'spikes' ...
-	if (Abs(pt1.x - pt2.x) > Abs(pt1.y - pt2.y))
-	{
-    if ((pt1.x > pt2.x) == (pt1.x < pt3.x))
-      return DistanceFromLineSqrd(pt1, pt2, pt3) < distSqrd;
-    else if ((pt2.x > pt1.x) == (pt2.x < pt3.x))
-      return DistanceFromLineSqrd(pt2, pt1, pt3) < distSqrd;
-		else
-	    return DistanceFromLineSqrd(pt3, pt1, pt2) < distSqrd;
-	}
-	else
-	{
-    if ((pt1.y > pt2.y) == (pt1.y < pt3.y))
-      return DistanceFromLineSqrd(pt1, pt2, pt3) < distSqrd;
-    else if ((pt2.y > pt1.y) == (pt2.y < pt3.y))
-      return DistanceFromLineSqrd(pt2, pt1, pt3) < distSqrd;
-		else
-      return DistanceFromLineSqrd(pt3, pt1, pt2) < distSqrd;
-	}
-}
-//------------------------------------------------------------------------------
-
-bool PointsAreClose(IntPoint pt1, IntPoint pt2, double distSqrd)
-{
-    double Dx = (double)pt1.x - pt2.x;
-    double dy = (double)pt1.y - pt2.y;
-    return ((Dx * Dx) + (dy * dy) <= distSqrd);
-}
-//------------------------------------------------------------------------------
-
-OutPt* ExcludeOp(OutPt* op)
-{
-  OutPt* result = op->Prev;
-  result->Next = op->Next;
-  op->Next->Prev = result;
-  result->Idx = 0;
-  return result;
-}
-//------------------------------------------------------------------------------
-
-void CleanPolygon(const Path& in_poly, Path& out_poly, double distance)
-{
-  //distance = proximity in units/pixels below which vertices
-  //will be stripped. Default ~= sqrt(2).
-  
-  size_t size = in_poly.size();
-  
-  if (size == 0) 
-  {
-    out_poly.clear();
-    return;
-  }
-
-  OutPt* outPts = new OutPt[size];
-  for (size_t i = 0; i < size; ++i)
-  {
-    outPts[i].Pt = in_poly[i];
-    outPts[i].Next = &outPts[(i + 1) % size];
-    outPts[i].Next->Prev = &outPts[i];
-    outPts[i].Idx = 0;
-  }
-
-  double distSqrd = distance * distance;
-  OutPt* op = &outPts[0];
-  while (op->Idx == 0 && op->Next != op->Prev) 
-  {
-    if (PointsAreClose(op->Pt, op->Prev->Pt, distSqrd))
-    {
-      op = ExcludeOp(op);
-      size--;
-    } 
-    else if (PointsAreClose(op->Prev->Pt, op->Next->Pt, distSqrd))
-    {
-      ExcludeOp(op->Next);
-      op = ExcludeOp(op);
-      size -= 2;
-    }
-    else if (SlopesNearCollinear(op->Prev->Pt, op->Pt, op->Next->Pt, distSqrd))
-    {
-      op = ExcludeOp(op);
-      size--;
-    }
-    else
-    {
-      op->Idx = 1;
-      op = op->Next;
-    }
-  }
-
-  if (size < 3) size = 0;
-  out_poly.resize(size);
-  for (size_t i = 0; i < size; ++i)
-  {
-    out_poly[i] = op->Pt;
-    op = op->Next;
-  }
-  delete [] outPts;
-}
-//------------------------------------------------------------------------------
-
-void CleanPolygon(Path& poly, double distance)
-{
-  CleanPolygon(poly, poly, distance);
-}
-//------------------------------------------------------------------------------
-
-void CleanPolygons(const Paths& in_polys, Paths& out_polys, double distance)
-{
-  for (Paths::size_type i = 0; i < in_polys.size(); ++i)
-    CleanPolygon(in_polys[i], out_polys[i], distance);
-}
-//------------------------------------------------------------------------------
-
-void CleanPolygons(Paths& polys, double distance)
-{
-  CleanPolygons(polys, polys, distance);
-}
-//------------------------------------------------------------------------------
-
-void Minkowski(const Path& poly, const Path& path, 
-  Paths& solution, bool isSum, bool isClosed)
-{
-  int delta = (isClosed ? 1 : 0);
-  size_t polyCnt = poly.size();
-  size_t pathCnt = path.size();
-  Paths pp;
-  pp.reserve(pathCnt);
-  if (isSum)
-    for (size_t i = 0; i < pathCnt; ++i)
-    {
-      Path p;
-      p.reserve(polyCnt);
-      for (size_t j = 0; j < poly.size(); ++j)
-        p.push_back(IntPoint(path[i].x + poly[j].x, path[i].y + poly[j].y));
-      pp.push_back(p);
-    }
-  else
-    for (size_t i = 0; i < pathCnt; ++i)
-    {
-      Path p;
-      p.reserve(polyCnt);
-      for (size_t j = 0; j < poly.size(); ++j)
-        p.push_back(IntPoint(path[i].x - poly[j].x, path[i].y - poly[j].y));
-      pp.push_back(p);
-    }
-
-  solution.clear();
-  solution.reserve((pathCnt + delta) * (polyCnt + 1));
-  for (size_t i = 0; i < pathCnt - 1 + delta; ++i)
-    for (size_t j = 0; j < polyCnt; ++j)
-    {
-      Path quad;
-      quad.reserve(4);
-      quad.push_back(pp[i % pathCnt][j % polyCnt]);
-      quad.push_back(pp[(i + 1) % pathCnt][j % polyCnt]);
-      quad.push_back(pp[(i + 1) % pathCnt][(j + 1) % polyCnt]);
-      quad.push_back(pp[i % pathCnt][(j + 1) % polyCnt]);
-      if (!Orientation(quad)) ReversePath(quad);
-      solution.push_back(quad);
-    }
-}
-//------------------------------------------------------------------------------
-
-void MinkowskiSum(const Path& pattern, const Path& path, Paths& solution, bool pathIsClosed)
-{
-  Minkowski(pattern, path, solution, true, pathIsClosed);
-  Clipper c;
-  c.AddPaths(solution, ptSubject, true);
-  c.Execute(ctUnion, solution, pftNonZero, pftNonZero);
-}
-//------------------------------------------------------------------------------
-
-void TranslatePath(const Path& input, Path& output, const IntPoint delta)
-{
-  //precondition: input != output
-  output.resize(input.size());
-  for (size_t i = 0; i < input.size(); ++i)
-    output[i] = IntPoint(input[i].x + delta.x, input[i].y + delta.y);
-}
-//------------------------------------------------------------------------------
-
-void MinkowskiSum(const Path& pattern, const Paths& paths, Paths& solution, bool pathIsClosed)
-{
-  Clipper c;
-  for (size_t i = 0; i < paths.size(); ++i)
-  {
-    Paths tmp;
-    Minkowski(pattern, paths[i], tmp, true, pathIsClosed);
-    c.AddPaths(tmp, ptSubject, true);
-    if (pathIsClosed)
-    {
-      Path tmp2;
-      TranslatePath(paths[i], tmp2, pattern[0]);
-      c.AddPath(tmp2, ptClip, true);
-    }
-  }
-    c.Execute(ctUnion, solution, pftNonZero, pftNonZero);
-}
-//------------------------------------------------------------------------------
-
-void MinkowskiDiff(const Path& poly1, const Path& poly2, Paths& solution)
-{
-  Minkowski(poly1, poly2, solution, false, true);
-  Clipper c;
-  c.AddPaths(solution, ptSubject, true);
-  c.Execute(ctUnion, solution, pftNonZero, pftNonZero);
-}
-//------------------------------------------------------------------------------
-
-enum NodeType {ntAny, ntOpen, ntClosed};
-
-void AddPolyNodeToPaths(const PolyNode& polynode, NodeType nodetype, Paths& paths)
-{
-  bool match = true;
-  if (nodetype == ntClosed) match = !polynode.IsOpen();
-  else if (nodetype == ntOpen) return;
-
-  if (!polynode.Contour.empty() && match)
-    paths.push_back(polynode.Contour);
-  for (int i = 0; i < polynode.ChildCount(); ++i)
-    AddPolyNodeToPaths(*polynode.Childs[i], nodetype, paths);
-}
-//------------------------------------------------------------------------------
-
-void PolyTreeToPaths(const PolyTree& polytree, Paths& paths)
-{
-  paths.resize(0); 
-  paths.reserve(polytree.Total());
-  AddPolyNodeToPaths(polytree, ntAny, paths);
-}
-//------------------------------------------------------------------------------
-
-void ClosedPathsFromPolyTree(const PolyTree& polytree, Paths& paths)
-{
-  paths.resize(0); 
-  paths.reserve(polytree.Total());
-  AddPolyNodeToPaths(polytree, ntClosed, paths);
-}
-//------------------------------------------------------------------------------
-
-void OpenPathsFromPolyTree(PolyTree& polytree, Paths& paths)
-{
-  paths.resize(0); 
-  paths.reserve(polytree.Total());
-  //Open paths are top level only, so ...
-  for (int i = 0; i < polytree.ChildCount(); ++i)
-    if (polytree.Childs[i]->IsOpen())
-      paths.push_back(polytree.Childs[i]->Contour);
-}
-//------------------------------------------------------------------------------
-
-std::ostream& operator <<(std::ostream &s, const IntPoint &p)
-{
-  s << "(" << p.x << "," << p.y << ")";
-  return s;
-}
-//------------------------------------------------------------------------------
-
-std::ostream& operator <<(std::ostream &s, const Path &p)
-{
-  if (p.empty()) return s;
-  Path::size_type last = p.size() -1;
-  for (Path::size_type i = 0; i < last; i++)
-    s << "(" << p[i].x << "," << p[i].y << "), ";
-  s << "(" << p[last].x << "," << p[last].y << ")\n";
-  return s;
-}
-//------------------------------------------------------------------------------
-
-std::ostream& operator <<(std::ostream &s, const Paths &p)
-{
-  for (Paths::size_type i = 0; i < p.size(); i++)
-    s << p[i];
-  s << "\n";
-  return s;
-}
-//------------------------------------------------------------------------------
-
-} //ClipperLib namespace
diff --git a/deps/mapnik/build.py b/deps/mapnik/build.py
index e2bbe21..32afe11 100644
--- a/deps/mapnik/build.py
+++ b/deps/mapnik/build.py
@@ -7,7 +7,6 @@ subdirs =  {
   'sparsehash':'sparsehash',
   'sparsehash/internal':'sparsehash/internal',
   '../agg/include':'agg',
-  '../clipper/include':'agg'
 }
 
 if 'install' in COMMAND_LINE_TARGETS:
diff --git a/docs/contributing.markdown b/docs/contributing.md
similarity index 100%
rename from docs/contributing.markdown
rename to docs/contributing.md
diff --git a/docs/design.markdown b/docs/design.md
similarity index 100%
rename from docs/design.markdown
rename to docs/design.md
diff --git a/fonts/build.py b/fonts/build.py
index 1dbcacf..de8b214 100644
--- a/fonts/build.py
+++ b/fonts/build.py
@@ -1,7 +1,7 @@
 #
 # This file is part of Mapnik (c++ mapping toolkit)
 #
-# Copyright (C) 2013 Artem Pavlenko
+# Copyright (C) 2015 Artem Pavlenko
 #
 # Mapnik is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -17,7 +17,7 @@
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
-# 
+#
 
 import os
 import glob
@@ -32,4 +32,4 @@ if not env['SYSTEM_FONTS']:
     target_path = env['MAPNIK_FONTS_DEST']
     if 'uninstall' not in COMMAND_LINE_TARGETS:
         env.Alias(target='install', source=env.Install(target_path, includes))
-    env['create_uninstall_target'](env, target_path)
\ No newline at end of file
+    env['create_uninstall_target'](env, target_path)
diff --git a/include/build.py b/include/build.py
index 5629841..54bb16b 100644
--- a/include/build.py
+++ b/include/build.py
@@ -1,7 +1,7 @@
 #
 # This file is part of Mapnik (c++ mapping toolkit)
 #
-# Copyright (C) 2013 Artem Pavlenko
+# Copyright (C) 2015 Artem Pavlenko
 #
 # Mapnik is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/agg_helpers.hpp b/include/mapnik/agg_helpers.hpp
index 8e2b1b2..139405c 100644
--- a/include/mapnik/agg_helpers.hpp
+++ b/include/mapnik/agg_helpers.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/agg_pattern_source.hpp b/include/mapnik/agg_pattern_source.hpp
index 1c56739..a000020 100644
--- a/include/mapnik/agg_pattern_source.hpp
+++ b/include/mapnik/agg_pattern_source.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/agg_rasterizer.hpp b/include/mapnik/agg_rasterizer.hpp
index 0232f88..51cf4cd 100644
--- a/include/mapnik/agg_rasterizer.hpp
+++ b/include/mapnik/agg_rasterizer.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/agg_render_marker.hpp b/include/mapnik/agg_render_marker.hpp
index bbe70a4..65e531c 100644
--- a/include/mapnik/agg_render_marker.hpp
+++ b/include/mapnik/agg_render_marker.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -27,6 +27,8 @@
 #include <mapnik/svg/svg_converter.hpp>
 #include <mapnik/vertex_converters.hpp>
 #include <mapnik/box2d.hpp>
+#include <mapnik/safe_cast.hpp>
+#include <mapnik/util/const_rendering_buffer.hpp>
 
 // agg
 #include "agg_color_rgba.h"
@@ -70,7 +72,9 @@ void render_raster_marker(RendererType renb, RasterizerType & ras, image_rgba8 c
                           float scale_factor, bool snap_to_pixels)
 {
     using color_type = agg::rgba8;
-    using pixfmt_pre = agg::pixfmt_rgba32_pre;
+    using const_rendering_buffer = util::rendering_buffer<image_rgba8>;
+    using pixfmt_pre = agg::pixfmt_alpha_blend_rgba<agg::blender_rgba32_pre, const_rendering_buffer, agg::pixel32_type>;
+
     agg::scanline_u8 sl;
     double width  = src.width();
     double height = src.height();
@@ -80,22 +84,22 @@ void render_raster_marker(RendererType renb, RasterizerType & ras, image_rgba8 c
         && (std::fabs(0.0 - tr.shx) < agg::affine_epsilon)
         && (std::fabs(1.0 - tr.sy) < agg::affine_epsilon))
     {
-        agg::rendering_buffer src_buffer((unsigned char *)src.bytes(),src.width(),src.height(),src.row_size());
+        const_rendering_buffer src_buffer(src);
         pixfmt_pre pixf_mask(src_buffer);
         if (snap_to_pixels)
         {
             renb.blend_from(pixf_mask,
                             0,
-                            std::floor(tr.tx + .5),
-                            std::floor(tr.ty + .5),
+                            static_cast<int>(std::floor(tr.tx + .5)),
+                            static_cast<int>(std::floor(tr.ty + .5)),
                             unsigned(255*opacity));
         }
         else
         {
             renb.blend_from(pixf_mask,
                             0,
-                            tr.tx,
-                            tr.ty,
+                            static_cast<int>(tr.tx),
+                            static_cast<int>(tr.ty),
                             unsigned(255*opacity));
         }
     }
@@ -121,11 +125,8 @@ void render_raster_marker(RendererType renb, RasterizerType & ras, image_rgba8 c
         agg::span_allocator<color_type> sa;
         agg::image_filter_lut filter;
         filter.calculate(agg::image_filter_bilinear(), true);
-        agg::rendering_buffer marker_buf((unsigned char *)src.bytes(),
-                                         src.width(),
-                                         src.height(),
-                                         src.row_size());
-        pixfmt_pre pixf(marker_buf);
+        const_rendering_buffer src_buffer(src);
+        pixfmt_pre pixf(src_buffer);
         img_accessor_type ia(pixf);
         agg::trans_affine final_tr(p, 0, 0, width, height);
         if (snap_to_pixels)
diff --git a/include/mapnik/agg_renderer.hpp b/include/mapnik/agg_renderer.hpp
index 4f3996b..776632d 100644
--- a/include/mapnik/agg_renderer.hpp
+++ b/include/mapnik/agg_renderer.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/attribute.hpp b/include/mapnik/attribute.hpp
index 65b87b9..b0cf683 100644
--- a/include/mapnik/attribute.hpp
+++ b/include/mapnik/attribute.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/attribute_collector.hpp b/include/mapnik/attribute_collector.hpp
index 9f2e815..878bfd4 100644
--- a/include/mapnik/attribute_collector.hpp
+++ b/include/mapnik/attribute_collector.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -42,6 +42,9 @@
 // boost
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/algorithm/string/replace.hpp>
 #pragma GCC diagnostic pop
 
@@ -274,8 +277,8 @@ inline void group_attribute_collector::operator() (group_symbolizer const& sym)
     }
 
     // get indexed column names
-    int start = get<value_integer>(sym, keys::start_column);
-    int end = start + get<value_integer>(sym, keys::num_columns);
+    value_integer start = get<value_integer>(sym, keys::start_column);
+    value_integer end = start + get<value_integer>(sym, keys::num_columns);
     for (auto const& col_name : group_columns)
     {
         if (expand_index_columns_ && col_name.find('%') != std::string::npos)
@@ -286,7 +289,7 @@ inline void group_attribute_collector::operator() (group_symbolizer const& sym)
             if (col_name.size() > 1)
             {
                 // Indexed column name. add column name for each index value.
-                for (int col_idx = start; col_idx < end; ++col_idx)
+                for (value_integer col_idx = start; col_idx < end; ++col_idx)
                 {
                     std::string col_idx_str;
                     if (mapnik::util::to_string(col_idx_str,col_idx))
diff --git a/include/mapnik/attribute_descriptor.hpp b/include/mapnik/attribute_descriptor.hpp
index 1656cbb..ff97157 100644
--- a/include/mapnik/attribute_descriptor.hpp
+++ b/include/mapnik/attribute_descriptor.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/boolean.hpp b/include/mapnik/boolean.hpp
index 171cbd7..92751b7 100644
--- a/include/mapnik/boolean.hpp
+++ b/include/mapnik/boolean.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/box2d.hpp b/include/mapnik/box2d.hpp
index e6fc2a9..4471c28 100644
--- a/include/mapnik/box2d.hpp
+++ b/include/mapnik/box2d.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/cairo/cairo_context.hpp b/include/mapnik/cairo/cairo_context.hpp
index f4ca72a..3f065db 100644
--- a/include/mapnik/cairo/cairo_context.hpp
+++ b/include/mapnik/cairo/cairo_context.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -124,12 +124,12 @@ class cairo_pattern : private util::noncopyable
 public:
     explicit cairo_pattern(image_rgba8 const& data, double opacity = 1.0)
     {
-        int pixels = data.width() * data.height();
+        std::size_t pixels = data.width() * data.height();
         const unsigned int *in_ptr = data.data();
         const unsigned int *in_end = in_ptr + pixels;
         unsigned int *out_ptr;
 
-        surface_ = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, data.width(), data.height());
+        surface_ = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, static_cast<int>(data.width()), static_cast<int>(data.height()));
 
         out_ptr = reinterpret_cast<unsigned int *>(cairo_image_surface_get_data(surface_));
 
diff --git a/include/mapnik/cairo/cairo_image_util.hpp b/include/mapnik/cairo/cairo_image_util.hpp
index c0d2341..9f039d6 100644
--- a/include/mapnik/cairo/cairo_image_util.hpp
+++ b/include/mapnik/cairo/cairo_image_util.hpp
@@ -41,8 +41,8 @@ static inline void cairo_image_to_rgba8(mapnik::image_rgba8 & data,
         throw std::runtime_error("Unable to convert this Cairo format to rgba8 image");
     }
 
-    if (cairo_image_surface_get_width(&*surface) != data.width() ||
-        cairo_image_surface_get_height(&*surface) != data.height())
+    if (cairo_image_surface_get_width(&*surface) != static_cast<int>(data.width()) ||
+        cairo_image_surface_get_height(&*surface) != static_cast<int>(data.height()))
     {
         throw std::runtime_error("Mismatch in dimensions: size of image must match side of cairo surface");
     }
diff --git a/include/mapnik/cairo/cairo_render_vector.hpp b/include/mapnik/cairo/cairo_render_vector.hpp
index b529a50..37bd449 100644
--- a/include/mapnik/cairo/cairo_render_vector.hpp
+++ b/include/mapnik/cairo/cairo_render_vector.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/cairo/cairo_renderer.hpp b/include/mapnik/cairo/cairo_renderer.hpp
index 0914d62..a39b4ed 100644
--- a/include/mapnik/cairo/cairo_renderer.hpp
+++ b/include/mapnik/cairo/cairo_renderer.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -165,7 +165,7 @@ public:
     {
         return common_.vars_;
     }
-    
+
     void render_marker(pixel_position const& pos,
                        marker const& marker,
                        agg::trans_affine const& mtx,
diff --git a/include/mapnik/cairo_io.hpp b/include/mapnik/cairo_io.hpp
index c808b99..55b1072 100644
--- a/include/mapnik/cairo_io.hpp
+++ b/include/mapnik/cairo_io.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/color.hpp b/include/mapnik/color.hpp
index 84f03d5..b22a998 100644
--- a/include/mapnik/color.hpp
+++ b/include/mapnik/color.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/color_factory.hpp b/include/mapnik/color_factory.hpp
index 6bc360b..6fdb566 100644
--- a/include/mapnik/color_factory.hpp
+++ b/include/mapnik/color_factory.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/config.hpp b/include/mapnik/config.hpp
index c96948b..6461a6c 100644
--- a/include/mapnik/config.hpp
+++ b/include/mapnik/config.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/config_error.hpp b/include/mapnik/config_error.hpp
index 2f6b3f6..b8bd31f 100644
--- a/include/mapnik/config_error.hpp
+++ b/include/mapnik/config_error.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/coord.hpp b/include/mapnik/coord.hpp
index 040c76b..fcdfa90 100644
--- a/include/mapnik/coord.hpp
+++ b/include/mapnik/coord.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/css_color_grammar.hpp b/include/mapnik/css_color_grammar.hpp
index 7c7942d..4403d34 100644
--- a/include/mapnik/css_color_grammar.hpp
+++ b/include/mapnik/css_color_grammar.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -26,11 +26,15 @@
 // mapnik
 #include <mapnik/color.hpp>
 #include <mapnik/util/hsl.hpp>
+#include <mapnik/safe_cast.hpp>
 
 // boost
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/spirit/include/qi.hpp>
 #include <boost/spirit/include/qi_action.hpp>
 #include <boost/spirit/include/phoenix_core.hpp>
@@ -45,10 +49,10 @@
 
 BOOST_FUSION_ADAPT_ADT(
     mapnik::color,
-    (unsigned, unsigned, obj.red(), obj.set_red(val))
-    (unsigned, unsigned, obj.green(), obj.set_green(val))
-    (unsigned, unsigned, obj.blue(), obj.set_blue(val))
-    (unsigned, unsigned, obj.alpha(), obj.set_alpha(val))
+    (unsigned, unsigned, obj.red(), obj.set_red(mapnik::safe_cast<uint8_t>(val)))
+    (unsigned, unsigned, obj.green(), obj.set_green(mapnik::safe_cast<uint8_t>(val)))
+    (unsigned, unsigned, obj.blue(), obj.set_blue(mapnik::safe_cast<uint8_t>(val)))
+    (unsigned, unsigned, obj.alpha(), obj.set_alpha(mapnik::safe_cast<uint8_t>(val)))
     )
 
 namespace mapnik
@@ -216,15 +220,6 @@ struct named_colors_ : qi::symbols<char,color>
     }
 } ;
 
-// clipper helper
-template <int MIN,int MAX>
-inline int clip_int(int val)
-{
-    if (val < MIN ) return MIN;
-    if (val > MAX ) return MAX;
-    return val;
-}
-
 struct percent_conv_impl
 {
     template <typename T>
@@ -235,7 +230,7 @@ struct percent_conv_impl
 
     unsigned operator() (double val) const
     {
-        return clip_int<0,255>(int((255.0 * val)/100.0 + 0.5));
+        return safe_cast<uint8_t>(std::lround((255.0 * val)/100.0));
     }
 };
 
@@ -249,7 +244,7 @@ struct alpha_conv_impl
 
     unsigned operator() (double val) const
     {
-        return clip_int<0,255>(int((255.0 * val) + 0.5));
+        return safe_cast<uint8_t>(std::lround((255.0 * val)));
     }
 };
 
@@ -284,9 +279,9 @@ struct hsl_conv_impl
         double g = hue_to_rgb(m1, m2, h);
         double b = hue_to_rgb(m1, m2, h - 1.0/3.0);
 
-        c.set_red(clip_int<0,255>(int((255.0 * r) + 0.5)));
-        c.set_green(clip_int<0,255>(int((255.0 * g) + 0.5)));
-        c.set_blue(clip_int<0,255>(int((255.0 * b) + 0.5)));
+        c.set_red(safe_cast<uint8_t>(std::lround(255.0 * r)));
+        c.set_green(safe_cast<uint8_t>(std::lround(255.0 * g)));
+        c.set_blue(safe_cast<uint8_t>(std::lround(255.0 * b)));
     }
 };
 
diff --git a/include/mapnik/css_color_grammar_impl.hpp b/include/mapnik/css_color_grammar_impl.hpp
index 4fe4627..4ce3134 100644
--- a/include/mapnik/css_color_grammar_impl.hpp
+++ b/include/mapnik/css_color_grammar_impl.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/datasource.hpp b/include/mapnik/datasource.hpp
index 0cb9a59..ec14a62 100644
--- a/include/mapnik/datasource.hpp
+++ b/include/mapnik/datasource.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/datasource_cache.hpp b/include/mapnik/datasource_cache.hpp
index a4ff89c..bf951e7 100644
--- a/include/mapnik/datasource_cache.hpp
+++ b/include/mapnik/datasource_cache.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -25,7 +25,7 @@
 
 // mapnik
 #include <mapnik/config.hpp>
-#include <mapnik/utils.hpp>
+#include <mapnik/util/singleton.hpp>
 #include <mapnik/util/noncopyable.hpp>
 
 // stl
@@ -55,7 +55,6 @@ private:
     datasource_cache();
     ~datasource_cache();
     std::map<std::string,std::shared_ptr<PluginInfo> > plugins_;
-    bool registered_;
     std::set<std::string> plugin_directories_;
 };
 
diff --git a/include/mapnik/debug.hpp b/include/mapnik/debug.hpp
index a00bca6..aaccb4f 100644
--- a/include/mapnik/debug.hpp
+++ b/include/mapnik/debug.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -25,7 +25,7 @@
 
 // mapnik (should not depend on anything that need to use this)
 #include <mapnik/config.hpp>
-#include <mapnik/utils.hpp>
+#include <mapnik/util/singleton.hpp>
 #include <mapnik/util/noncopyable.hpp>
 
 // std
diff --git a/include/mapnik/ellipsoid.hpp b/include/mapnik/ellipsoid.hpp
index e1be68c..6f872d4 100644
--- a/include/mapnik/ellipsoid.hpp
+++ b/include/mapnik/ellipsoid.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/enumeration.hpp b/include/mapnik/enumeration.hpp
index 12f3dad..c0cfe1e 100644
--- a/include/mapnik/enumeration.hpp
+++ b/include/mapnik/enumeration.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/evaluate_global_attributes.hpp b/include/mapnik/evaluate_global_attributes.hpp
index 63f0348..3e3d63c 100644
--- a/include/mapnik/evaluate_global_attributes.hpp
+++ b/include/mapnik/evaluate_global_attributes.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/expression.hpp b/include/mapnik/expression.hpp
index 8894507..7b9ca59 100644
--- a/include/mapnik/expression.hpp
+++ b/include/mapnik/expression.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/expression_evaluator.hpp b/include/mapnik/expression_evaluator.hpp
index 1d37bde..6ac0451 100644
--- a/include/mapnik/expression_evaluator.hpp
+++ b/include/mapnik/expression_evaluator.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/expression_grammar.hpp b/include/mapnik/expression_grammar.hpp
index 3dd5fc4..7a71976 100644
--- a/include/mapnik/expression_grammar.hpp
+++ b/include/mapnik/expression_grammar.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -34,6 +34,9 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/spirit/include/qi.hpp>
 #include <boost/spirit/include/support_locals.hpp>
 #include <boost/spirit/include/phoenix_function.hpp>
diff --git a/include/mapnik/expression_grammar_impl.hpp b/include/mapnik/expression_grammar_impl.hpp
index a4d8353..d123b3b 100644
--- a/include/mapnik/expression_grammar_impl.hpp
+++ b/include/mapnik/expression_grammar_impl.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/expression_node.hpp b/include/mapnik/expression_node.hpp
index ea161f0..7731414 100644
--- a/include/mapnik/expression_node.hpp
+++ b/include/mapnik/expression_node.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -86,8 +86,8 @@ struct unary_function_call
 {
     using argument_type = expr_node;
     unary_function_call() = default;
-    unary_function_call(unary_function_impl fun, argument_type const& arg)
-        : fun(fun), arg(arg) {}
+    unary_function_call(unary_function_impl _fun, argument_type const& _arg)
+        : fun(_fun), arg(_arg) {}
 
     unary_function_impl fun;
     argument_type arg;
@@ -97,8 +97,8 @@ struct binary_function_call
 {
     using argument_type = expr_node;
     binary_function_call() = default;
-    binary_function_call(binary_function_impl fun, argument_type const& arg1, argument_type const& arg2)
-        : fun(fun), arg1(arg1), arg2(arg2) {}
+    binary_function_call(binary_function_impl _fun, argument_type const& _arg1, argument_type const& _arg2)
+        : fun(_fun), arg1(_arg1), arg2(_arg2) {}
     binary_function_impl fun;
     argument_type arg1;
     argument_type arg2;
diff --git a/include/mapnik/expression_node_types.hpp b/include/mapnik/expression_node_types.hpp
index 86d12b2..371274a 100644
--- a/include/mapnik/expression_node_types.hpp
+++ b/include/mapnik/expression_node_types.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/expression_string.hpp b/include/mapnik/expression_string.hpp
index afb6331..6efc07e 100644
--- a/include/mapnik/expression_string.hpp
+++ b/include/mapnik/expression_string.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/factory.hpp b/include/mapnik/factory.hpp
index 87b4371..81f2613 100644
--- a/include/mapnik/factory.hpp
+++ b/include/mapnik/factory.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -24,7 +24,7 @@
 #define MAPNIK_FACTORY_HPP
 
 // mapnik
-#include <mapnik/utils.hpp>
+#include <mapnik/util/singleton.hpp>
 
 // stl
 #include <stdexcept>
diff --git a/include/mapnik/feature.hpp b/include/mapnik/feature.hpp
index c4888f3..eb084bc 100644
--- a/include/mapnik/feature.hpp
+++ b/include/mapnik/feature.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -115,13 +115,13 @@ public:
     template <typename T>
     inline void put(context_type::key_type const& key, T const& val)
     {
-        put(key, std::move(value(val)));
+        put(key, value(val));
     }
 
     template <typename T>
     inline void put_new(context_type::key_type const& key, T const& val)
     {
-        put_new(key,std::move(value(val)));
+        put_new(key, value(val));
     }
 
     inline void put(context_type::key_type const& key, value && val)
diff --git a/include/mapnik/feature_factory.hpp b/include/mapnik/feature_factory.hpp
index 57ed6dc..c4a4d56 100644
--- a/include/mapnik/feature_factory.hpp
+++ b/include/mapnik/feature_factory.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/feature_kv_iterator.hpp b/include/mapnik/feature_kv_iterator.hpp
index 5d9b93a..37093a8 100644
--- a/include/mapnik/feature_kv_iterator.hpp
+++ b/include/mapnik/feature_kv_iterator.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/feature_layer_desc.hpp b/include/mapnik/feature_layer_desc.hpp
index 7dd1293..c89d944 100644
--- a/include/mapnik/feature_layer_desc.hpp
+++ b/include/mapnik/feature_layer_desc.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/feature_style_processor.hpp b/include/mapnik/feature_style_processor.hpp
index cc36c01..062c9d6 100644
--- a/include/mapnik/feature_style_processor.hpp
+++ b/include/mapnik/feature_style_processor.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/feature_style_processor_context.hpp b/include/mapnik/feature_style_processor_context.hpp
index 585c746..aca0c8f 100644
--- a/include/mapnik/feature_style_processor_context.hpp
+++ b/include/mapnik/feature_style_processor_context.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/feature_style_processor_impl.hpp b/include/mapnik/feature_style_processor_impl.hpp
index 6e0094b..0c77821 100644
--- a/include/mapnik/feature_style_processor_impl.hpp
+++ b/include/mapnik/feature_style_processor_impl.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -224,7 +224,7 @@ void feature_style_processor<Processor>::prepare_layer(layer_rendering_material
 
     std::vector<std::string> const& style_names = lay.styles();
 
-    unsigned int num_styles = style_names.size();
+    std::size_t num_styles = style_names.size();
     if (num_styles == 0)
     {
         MAPNIK_LOG_DEBUG(feature_style_processor)
@@ -361,7 +361,7 @@ void feature_style_processor<Processor>::prepare_layer(layer_rendering_material
         boost::optional<feature_type_style const&> style=m_.find_style(style_name);
         if (!style)
         {
-            MAPNIK_LOG_DEBUG(feature_style_processor)
+            MAPNIK_LOG_ERROR(feature_style_processor)
                 << "feature_style_processor: Style=" << style_name
                 << " required for layer=" << lay.name() << " does not exist.";
 
diff --git a/include/mapnik/feature_type_style.hpp b/include/mapnik/feature_type_style.hpp
index 0f0d839..68240af 100644
--- a/include/mapnik/feature_type_style.hpp
+++ b/include/mapnik/feature_type_style.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/featureset.hpp b/include/mapnik/featureset.hpp
index e23532a..c6829d1 100644
--- a/include/mapnik/featureset.hpp
+++ b/include/mapnik/featureset.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/filter_featureset.hpp b/include/mapnik/filter_featureset.hpp
index b704625..ee3fa40 100644
--- a/include/mapnik/filter_featureset.hpp
+++ b/include/mapnik/filter_featureset.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/font_engine_freetype.hpp b/include/mapnik/font_engine_freetype.hpp
index 78dc055..33ac450 100644
--- a/include/mapnik/font_engine_freetype.hpp
+++ b/include/mapnik/font_engine_freetype.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/font_set.hpp b/include/mapnik/font_set.hpp
index 8803c99..5df8e35 100644
--- a/include/mapnik/font_set.hpp
+++ b/include/mapnik/font_set.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/function_call.hpp b/include/mapnik/function_call.hpp
index 5453d92..efbaa5f 100644
--- a/include/mapnik/function_call.hpp
+++ b/include/mapnik/function_call.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/geom_util.hpp b/include/mapnik/geom_util.hpp
index e6ad12e..7dbe51f 100644
--- a/include/mapnik/geom_util.hpp
+++ b/include/mapnik/geom_util.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/geometry.hpp b/include/mapnik/geometry.hpp
index a4f5583..970f8dd 100644
--- a/include/mapnik/geometry.hpp
+++ b/include/mapnik/geometry.hpp
@@ -52,7 +52,7 @@ struct point
     }
     friend inline bool operator!= (point<T> const& a, point <T> const& b)
     {
-        return a.x != b.x  || a.y != b.y; 
+        return a.x != b.x  || a.y != b.y;
     }
     value_type x;
     value_type y;
@@ -74,7 +74,7 @@ struct line_string : std::vector<point<T> >
 };
 
 template <typename T>
-struct linear_ring : line_string<T> 
+struct linear_ring : line_string<T>
 {
     linear_ring() = default;
     linear_ring(std::size_t size)
@@ -87,7 +87,7 @@ struct linear_ring : line_string<T>
     linear_ring(line_string<T> const& other)
         : line_string<T>(other) {}
     linear_ring& operator=(linear_ring const&) = default;
-            
+
 };
 
 template <typename T>
@@ -96,6 +96,7 @@ struct polygon
     linear_ring<T> exterior_ring;
     std::vector<linear_ring<T>> interior_rings;
 
+    polygon() = default;
     inline void set_exterior_ring(linear_ring<T> && ring)
     {
         exterior_ring = std::move(ring);
@@ -128,15 +129,29 @@ struct geometry_collection;
 
 struct geometry_empty {};
 
+
+template <typename T>
+using geometry_base = mapnik::util::variant<geometry_empty,
+                                            point<T>,
+                                            line_string<T>,
+                                            polygon<T>,
+                                            multi_point<T>,
+                                            multi_line_string<T>,
+                                            multi_polygon<T>,
+                                            mapnik::util::recursive_wrapper<geometry_collection<T> > >;
 template <typename T>
-using geometry = mapnik::util::variant<geometry_empty,
-                                       point<T>,
-                                       line_string<T>,
-                                       polygon<T>,
-                                       multi_point<T>,
-                                       multi_line_string<T>,
-                                       multi_polygon<T>,
-                                       mapnik::util::recursive_wrapper<geometry_collection<T> > >;
+struct geometry : geometry_base<T>
+{
+    using value_type = T;
+
+    geometry()
+        : geometry_base<T>() {} // empty
+
+    template <typename G>
+    geometry(G && geom)
+        : geometry_base<T>(std::forward<G>(geom)) {}
+
+};
 
 template <typename T>
 struct geometry_collection : std::vector<geometry<T>> {};
diff --git a/include/mapnik/geometry_adapters.hpp b/include/mapnik/geometry_adapters.hpp
index 93076a8..0c7a657 100644
--- a/include/mapnik/geometry_adapters.hpp
+++ b/include/mapnik/geometry_adapters.hpp
@@ -28,6 +28,10 @@
 // undef B0 to workaround https://svn.boost.org/trac/boost/ticket/10467
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
+#pragma GCC diagnostic ignored "-Wunused-parameter"
 #undef B0
 #include <boost/geometry/geometries/register/linestring.hpp>
 #include <boost/geometry/geometries/register/point.hpp>
diff --git a/include/mapnik/geometry_centroid.hpp b/include/mapnik/geometry_centroid.hpp
index 2e7dec1..71d0c07 100644
--- a/include/mapnik/geometry_centroid.hpp
+++ b/include/mapnik/geometry_centroid.hpp
@@ -50,7 +50,7 @@ struct geometry_centroid
         return false;
     }
 
-    result_type operator() (geometry_collection<T> const& collection) const
+    result_type operator() (geometry_collection<T> const&) const
     {
         return false;
     }
diff --git a/include/mapnik/geometry_correct.hpp b/include/mapnik/geometry_correct.hpp
index 8698c12..dcbb2d7 100644
--- a/include/mapnik/geometry_correct.hpp
+++ b/include/mapnik/geometry_correct.hpp
@@ -31,6 +31,9 @@
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wunused-variable"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/geometry/algorithms/correct.hpp>
 #pragma GCC diagnostic pop
 
@@ -72,7 +75,7 @@ struct geometry_correct
     }
 
     template <typename T>
-    result_type operator() (T & geom) const
+    result_type operator() (T &) const
     {
         //no-op
     }
diff --git a/include/mapnik/geometry_reprojection.hpp b/include/mapnik/geometry_reprojection.hpp
index 83a429a..22a334e 100644
--- a/include/mapnik/geometry_reprojection.hpp
+++ b/include/mapnik/geometry_reprojection.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/geometry_reprojection_impl.hpp b/include/mapnik/geometry_reprojection_impl.hpp
index 3ba4b75..7e78635 100644
--- a/include/mapnik/geometry_reprojection_impl.hpp
+++ b/include/mapnik/geometry_reprojection_impl.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -161,7 +161,7 @@ geometry_collection<T> reproject_internal(geometry_collection<T> const & c, proj
     for (auto const& g : c)
     {
 
-        geometry<T> new_g(std::move(reproject_copy(g, proj_trans, n_err)));
+        geometry<T> new_g = reproject_copy(g, proj_trans, n_err);
         if (!new_g.template is<geometry_empty>())
         {
             new_c.emplace_back(std::move(new_g));
@@ -195,7 +195,7 @@ struct geom_reproj_copy_visitor {
     geometry<T> operator() (line_string<T> const& ls)
     {
         geometry<T> geom; // default empty
-        int intial_err = n_err_;
+        unsigned int intial_err = n_err_;
         line_string<T> new_ls = reproject_internal(ls, proj_trans_, n_err_);
         if (n_err_ > intial_err || new_ls.empty()) return geom;
         geom = std::move(new_ls);
diff --git a/include/mapnik/geometry_transform.hpp b/include/mapnik/geometry_transform.hpp
index 5a0c263..a7bb2f1 100644
--- a/include/mapnik/geometry_transform.hpp
+++ b/include/mapnik/geometry_transform.hpp
@@ -114,7 +114,7 @@ struct geometry_transform
         geometry_collection<V> collection_out;
         for (auto const& geom :  collection)
         {
-            collection_out.push_back(std::move((*this)(geom)));
+            collection_out.push_back((*this)(geom));
         }
         return collection_out;
     }
@@ -128,39 +128,39 @@ struct geometry_transform
     template <typename T>
     geometry<V> operator() (point<T> const& geom) const
     {
-        return std::move(transform_geometry<V>(geom, transformer_));
+        return transform_geometry<V>(geom, transformer_);
     }
-    
+
     template <typename T>
     geometry<V> operator() (line_string<T> const& geom) const
     {
-        return std::move(transform_geometry<V>(geom, transformer_));
+        return transform_geometry<V>(geom, transformer_);
     }
-    
+
     template <typename T>
     geometry<V> operator() (polygon<T> const& geom) const
     {
-        return std::move(transform_geometry<V>(geom, transformer_));
+        return transform_geometry<V>(geom, transformer_);
     }
 
     template <typename T>
     geometry<V> operator() (multi_point<T> const& geom) const
     {
-        return std::move(transform_geometry<V>(geom, transformer_));
+        return transform_geometry<V>(geom, transformer_);
     }
-    
+
     template <typename T>
     geometry<V> operator() (multi_line_string<T> const& geom) const
     {
-        return std::move(transform_geometry<V>(geom, transformer_));
+        return transform_geometry<V>(geom, transformer_);
     }
-    
+
     template <typename T>
     geometry<V> operator() (multi_polygon<T> const& geom) const
     {
-        return std::move(transform_geometry<V>(geom, transformer_));
+        return transform_geometry<V>(geom, transformer_);
     }
-    
+
     Transformer const& transformer_;
 };
 
diff --git a/include/mapnik/global.hpp b/include/mapnik/global.hpp
index 4526f05..aa5be35 100644
--- a/include/mapnik/global.hpp
+++ b/include/mapnik/global.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/gradient.hpp b/include/mapnik/gradient.hpp
index a7e628a..eb70be4 100644
--- a/include/mapnik/gradient.hpp
+++ b/include/mapnik/gradient.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/grid/grid.hpp b/include/mapnik/grid/grid.hpp
index a00479e..ab79cdd 100644
--- a/include/mapnik/grid/grid.hpp
+++ b/include/mapnik/grid/grid.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -33,6 +33,7 @@
 #include <mapnik/feature.hpp>
 #include <mapnik/feature_factory.hpp>
 #include <mapnik/util/conversions.hpp>
+#include <mapnik/safe_cast.hpp>
 
 // stl
 #include <map>
@@ -191,12 +192,16 @@ public:
         if (ext0.intersects(ext1))
         {
             box2d<int> box = ext0.intersect(ext1);
-            for (std::size_t y = box.miny(); y < box.maxy(); ++y)
+            std::size_t miny = safe_cast<std::size_t>(box.miny());
+            std::size_t maxy = safe_cast<std::size_t>(box.maxy());
+            std::size_t minx = safe_cast<std::size_t>(box.minx());
+            std::size_t maxx = safe_cast<std::size_t>(box.maxx());
+            for (std::size_t y = miny; y < maxy; ++y)
             {
                 value_type* row_to =  data_.get_row(y);
                 image_rgba8::pixel_type const * row_from = data.get_row(y - y0);
 
-                for (std::size_t x = box.minx(); x < box.maxx(); ++x)
+                for (std::size_t x = minx; x < maxx; ++x)
                 {
                     image_rgba8::pixel_type rgba = row_from[x - x0];
                     unsigned a = (rgba >> 24) & 0xff;
diff --git a/include/mapnik/grid/grid_pixel.hpp b/include/mapnik/grid/grid_pixel.hpp
index 5ef1c78..fda6577 100644
--- a/include/mapnik/grid/grid_pixel.hpp
+++ b/include/mapnik/grid/grid_pixel.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/grid/grid_pixfmt.hpp b/include/mapnik/grid/grid_pixfmt.hpp
index 6f61b99..a26a936 100644
--- a/include/mapnik/grid/grid_pixfmt.hpp
+++ b/include/mapnik/grid/grid_pixfmt.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -24,9 +24,15 @@
 #define MAPNIK_GRID_PIXFMT_HPP
 
 #include <string>
+#include <mapnik/grid/grid_rendering_buffer.hpp>
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include "agg_basics.h"
 #include <mapnik/grid/grid_pixel.hpp>
-#include <mapnik/grid/grid_rendering_buffer.hpp>
+#pragma GCC diagnostic pop
 
 namespace mapnik
 {
diff --git a/include/mapnik/grid/grid_rasterizer.hpp b/include/mapnik/grid/grid_rasterizer.hpp
index cd73813..98a6dd3 100644
--- a/include/mapnik/grid/grid_rasterizer.hpp
+++ b/include/mapnik/grid/grid_rasterizer.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/grid/grid_render_marker.hpp b/include/mapnik/grid/grid_render_marker.hpp
index 79c5ec0..8f345e3 100644
--- a/include/mapnik/grid/grid_render_marker.hpp
+++ b/include/mapnik/grid/grid_render_marker.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2012 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/grid/grid_renderer.hpp b/include/mapnik/grid/grid_renderer.hpp
index 2db7709..cc689e3 100644
--- a/include/mapnik/grid/grid_renderer.hpp
+++ b/include/mapnik/grid/grid_renderer.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/grid/grid_renderer_base.hpp b/include/mapnik/grid/grid_renderer_base.hpp
index 9524b16..462010b 100644
--- a/include/mapnik/grid/grid_renderer_base.hpp
+++ b/include/mapnik/grid/grid_renderer_base.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -23,9 +23,14 @@
 #ifndef MAPNIK_GRID_RENDERER_BASE_HPP
 #define MAPNIK_GRID_RENDERER_BASE_HPP
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include "agg_renderer_base.h"
-#include <mapnik/grid/grid_pixfmt.hpp>
 #include <mapnik/grid/grid_pixel.hpp>
+#pragma GCC diagnostic pop
+#include <mapnik/grid/grid_pixfmt.hpp>
 
 namespace mapnik {
 
diff --git a/include/mapnik/grid/grid_rendering_buffer.hpp b/include/mapnik/grid/grid_rendering_buffer.hpp
index d5031c8..4282e3b 100644
--- a/include/mapnik/grid/grid_rendering_buffer.hpp
+++ b/include/mapnik/grid/grid_rendering_buffer.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/grid/grid_util.hpp b/include/mapnik/grid/grid_util.hpp
index 28d9797..826d2e1 100644
--- a/include/mapnik/grid/grid_util.hpp
+++ b/include/mapnik/grid/grid_util.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/grid/grid_view.hpp b/include/mapnik/grid/grid_view.hpp
index f161eaa..80c539f 100644
--- a/include/mapnik/grid/grid_view.hpp
+++ b/include/mapnik/grid/grid_view.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/group/group_layout.hpp b/include/mapnik/group/group_layout.hpp
index 2087b0b..23811e8 100644
--- a/include/mapnik/group/group_layout.hpp
+++ b/include/mapnik/group/group_layout.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/group/group_layout_manager.hpp b/include/mapnik/group/group_layout_manager.hpp
index 89acf53..38ee30b 100644
--- a/include/mapnik/group/group_layout_manager.hpp
+++ b/include/mapnik/group/group_layout_manager.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/group/group_rule.hpp b/include/mapnik/group/group_rule.hpp
index a0442ce..58f8505 100644
--- a/include/mapnik/group/group_rule.hpp
+++ b/include/mapnik/group/group_rule.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/group/group_symbolizer_helper.hpp b/include/mapnik/group/group_symbolizer_helper.hpp
index b32c9ec..93c7d4f 100644
--- a/include/mapnik/group/group_symbolizer_helper.hpp
+++ b/include/mapnik/group/group_symbolizer_helper.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/group/group_symbolizer_properties.hpp b/include/mapnik/group/group_symbolizer_properties.hpp
index fce1694..f5967b8 100644
--- a/include/mapnik/group/group_symbolizer_properties.hpp
+++ b/include/mapnik/group/group_symbolizer_properties.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/hextree.hpp b/include/mapnik/hextree.hpp
index d98f9e2..4664624 100644
--- a/include/mapnik/hextree.hpp
+++ b/include/mapnik/hextree.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/hit_test_filter.hpp b/include/mapnik/hit_test_filter.hpp
index d81a949..d4b8504 100644
--- a/include/mapnik/hit_test_filter.hpp
+++ b/include/mapnik/hit_test_filter.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/image.hpp b/include/mapnik/image.hpp
index 7567bfc..ec8b1f8 100644
--- a/include/mapnik/image.hpp
+++ b/include/mapnik/image.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/image_any.hpp b/include/mapnik/image_any.hpp
index 2fdac7d..c14d5dd 100644
--- a/include/mapnik/image_any.hpp
+++ b/include/mapnik/image_any.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/image_compositing.hpp b/include/mapnik/image_compositing.hpp
index c3fce8b..2967be7 100644
--- a/include/mapnik/image_compositing.hpp
+++ b/include/mapnik/image_compositing.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/image_copy.hpp b/include/mapnik/image_copy.hpp
index 62e2ab2..8f40ef4 100644
--- a/include/mapnik/image_copy.hpp
+++ b/include/mapnik/image_copy.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/image_filter.hpp b/include/mapnik/image_filter.hpp
index eef8141..37c3327 100644
--- a/include/mapnik/image_filter.hpp
+++ b/include/mapnik/image_filter.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -33,6 +33,9 @@
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wc++11-narrowing"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/gil/gil_all.hpp>
 #pragma GCC diagnostic pop
 
@@ -251,10 +254,10 @@ void apply_convolution_3x3(Src const& src_view, Dst & dst_view, Filter const& fi
     typename Src::x_iterator dst_it = dst_view.row_begin(0);
 
     // top row
-    for (int x = 0 ; x < src_view.width(); ++x)
+    for (std::size_t x = 0 ; x < static_cast<std::size_t>(src_view.width()); ++x)
     {
         (*dst_it)[3] = src_loc[loc11][3]; // Dst.a = Src.a
-        for (int i = 0; i < 3; ++i)
+        for (std::size_t i = 0; i < 3; ++i)
         {
             bits32f p[9];
 
@@ -272,7 +275,7 @@ void apply_convolution_3x3(Src const& src_view, Dst & dst_view, Filter const& fi
                 p[6] = src_loc[loc02][i];
             }
 
-            if ( x == src_view.width()-1)
+            if ( x == static_cast<std::size_t>(src_view.width())-1)
             {
                 p[5] = p[4];
                 p[8] = p[7];
@@ -293,15 +296,15 @@ void apply_convolution_3x3(Src const& src_view, Dst & dst_view, Filter const& fi
         ++dst_it;
     }
     // carrige-return
-    src_loc += point2<std::ptrdiff_t>(-src_view.width(),1);
+    src_loc += point2<std::ptrdiff_t>(-static_cast<std::size_t>(src_view.width()),1);
 
     // 1... height-1 rows
-    for (int y = 1; y<src_view.height()-1; ++y)
+    for (std::size_t y = 1; y<static_cast<std::size_t>(src_view.height())-1; ++y)
     {
-        for (int x = 0; x < src_view.width(); ++x)
+        for (std::size_t x = 0; x < static_cast<std::size_t>(src_view.width()); ++x)
         {
             (*dst_it)[3] = src_loc[loc11][3]; // Dst.a = Src.a
-            for (int i = 0; i < 3; ++i)
+            for (std::size_t i = 0; i < 3; ++i)
             {
                 bits32f p[9];
 
@@ -322,7 +325,7 @@ void apply_convolution_3x3(Src const& src_view, Dst & dst_view, Filter const& fi
                     p[6] = src_loc[loc02][i];
                 }
 
-                if ( x == src_view.width() - 1)
+                if ( x == static_cast<std::size_t>(src_view.width()) - 1)
                 {
                     p[2] = p[1];
                     p[5] = p[4];
@@ -340,15 +343,15 @@ void apply_convolution_3x3(Src const& src_view, Dst & dst_view, Filter const& fi
             ++src_loc.x();
         }
         // carrige-return
-        src_loc += point2<std::ptrdiff_t>(-src_view.width(),1);
+        src_loc += point2<std::ptrdiff_t>(-static_cast<std::size_t>(src_view.width()),1);
     }
 
     // bottom row
-    //src_loc = src_view.xy_at(0,src_view.height()-1);
-    for (int x = 0 ; x < src_view.width(); ++x)
+    //src_loc = src_view.xy_at(0,static_cast<std::size_t>(src_view.height())-1);
+    for (std::size_t x = 0 ; x < static_cast<std::size_t>(src_view.width()); ++x)
     {
         (*dst_it)[3] = src_loc[loc11][3]; // Dst.a = Src.a
-        for (int i = 0; i < 3; ++i)
+        for (std::size_t i = 0; i < 3; ++i)
         {
             bits32f p[9];
 
@@ -366,7 +369,7 @@ void apply_convolution_3x3(Src const& src_view, Dst & dst_view, Filter const& fi
                 p[3] = src_loc[loc01][i];
             }
 
-            if ( x == src_view.width()-1)
+            if ( x == static_cast<std::size_t>(src_view.width())-1)
             {
                 p[2] = p[1];
                 p[5] = p[4];
@@ -428,10 +431,10 @@ void apply_filter(Src & src, color_to_alpha const& op)
     double cr = static_cast<double>(op.color.red())/255.0;
     double cg = static_cast<double>(op.color.green())/255.0;
     double cb = static_cast<double>(op.color.blue())/255.0;
-    for (int y=0; y<src_view.height(); ++y)
+    for (std::size_t y=0; y<static_cast<std::size_t>(src_view.height()); ++y)
     {
-        rgba8_view_t::x_iterator src_it = src_view.row_begin(y);
-        for (int x=0; x<src_view.width(); ++x)
+        rgba8_view_t::x_iterator src_it = src_view.row_begin(static_cast<long>(y));
+        for (std::size_t x=0; x<static_cast<std::size_t>(src_view.width()); ++x)
         {
             uint8_t & r = get_color(src_it[x], red_t());
             uint8_t & g = get_color(src_it[x], green_t());
@@ -489,10 +492,10 @@ void apply_filter(Src & src, colorize_alpha const& op)
         mapnik::filter::color_stop const& stop = op[0];
         mapnik::color const& c = stop.color;
         rgba8_view_t src_view = rgba8_view(src);
-        for (int y=0; y<src_view.height(); ++y)
+        for (std::size_t y=0; y<static_cast<std::size_t>(src_view.height()); ++y)
         {
-            rgba8_view_t::x_iterator src_it = src_view.row_begin(y);
-            for (int x=0; x<src_view.width(); ++x)
+            rgba8_view_t::x_iterator src_it = src_view.row_begin(static_cast<long>(y));
+            for (std::size_t x=0; x<static_cast<std::size_t>(src_view.width()); ++x)
             {
                 uint8_t & r = get_color(src_it[x], red_t());
                 uint8_t & g = get_color(src_it[x], green_t());
@@ -530,10 +533,10 @@ void apply_filter(Src & src, colorize_alpha const& op)
         if (grad_lut.build_lut())
         {
             rgba8_view_t src_view = rgba8_view(src);
-            for (int y=0; y<src_view.height(); ++y)
+            for (std::size_t y=0; y<static_cast<std::size_t>(src_view.height()); ++y)
             {
-                rgba8_view_t::x_iterator src_it = src_view.row_begin(y);
-                for (int x=0; x<src_view.width(); ++x)
+                rgba8_view_t::x_iterator src_it = src_view.row_begin(static_cast<long>(y));
+                for (std::size_t x=0; x<static_cast<std::size_t>(src_view.width()); ++x)
                 {
                     uint8_t & r = get_color(src_it[x], red_t());
                     uint8_t & g = get_color(src_it[x], green_t());
@@ -595,10 +598,10 @@ void apply_filter(Src & src, scale_hsla const& transform)
     if (tinting || set_alpha)
     {
         rgba8_view_t src_view = rgba8_view(src);
-        for (int y=0; y<src_view.height(); ++y)
+        for (std::size_t y=0; y<static_cast<std::size_t>(src_view.height()); ++y)
         {
-            rgba8_view_t::x_iterator src_it = src_view.row_begin(y);
-            for (int x=0; x<src_view.width(); ++x)
+            rgba8_view_t::x_iterator src_it = src_view.row_begin(static_cast<long>(y));
+            for (std::size_t x=0; x<static_cast<std::size_t>(src_view.width()); ++x)
             {
                 uint8_t & r = get_color(src_it[x], red_t());
                 uint8_t & g = get_color(src_it[x], green_t());
@@ -678,10 +681,10 @@ void apply_filter(Src & src, gray const& /*op*/)
 
     rgba8_view_t src_view = rgba8_view(src);
 
-    for (int y=0; y<src_view.height(); ++y)
+    for (std::size_t y=0; y<static_cast<std::size_t>(src_view.height()); ++y)
     {
-        rgba8_view_t::x_iterator src_it = src_view.row_begin(y);
-        for (int x=0; x<src_view.width(); ++x)
+        rgba8_view_t::x_iterator src_it = src_view.row_begin(static_cast<long>(y));
+        for (std::size_t x=0; x<static_cast<std::size_t>(src_view.width()); ++x)
         {
             // formula taken from boost/gil/color_convert.hpp:rgb_to_luminance
             uint8_t & r = get_color(src_it[x], red_t());
@@ -696,22 +699,22 @@ void apply_filter(Src & src, gray const& /*op*/)
 template <typename Src, typename Dst>
 void x_gradient_impl(Src const& src_view, Dst const& dst_view)
 {
-    for (int y=0; y<src_view.height(); ++y)
+    for (std::size_t y=0; y<static_cast<std::size_t>(src_view.height()); ++y)
     {
-        typename Src::x_iterator src_it = src_view.row_begin(y);
-        typename Dst::x_iterator dst_it = dst_view.row_begin(y);
+        typename Src::x_iterator src_it = src_view.row_begin(static_cast<long>(y));
+        typename Dst::x_iterator dst_it = dst_view.row_begin(static_cast<long>(y));
 
         dst_it[0][0] = 128 + (src_it[0][0] - src_it[1][0]) / 2;
         dst_it[0][1] = 128 + (src_it[0][1] - src_it[1][1]) / 2;
         dst_it[0][2] = 128 + (src_it[0][2] - src_it[1][2]) / 2;
 
-        dst_it[dst_view.width()-1][0] = 128 + (src_it[src_view.width()-2][0] - src_it[src_view.width()-1][0]) / 2;
-        dst_it[dst_view.width()-1][1] = 128 + (src_it[src_view.width()-2][1] - src_it[src_view.width()-1][1]) / 2;
-        dst_it[dst_view.width()-1][2] = 128 + (src_it[src_view.width()-2][2] - src_it[src_view.width()-1][2]) / 2;
+        dst_it[dst_view.width()-1][0] = 128 + (src_it[static_cast<std::size_t>(src_view.width())-2][0] - src_it[static_cast<std::size_t>(src_view.width())-1][0]) / 2;
+        dst_it[dst_view.width()-1][1] = 128 + (src_it[static_cast<std::size_t>(src_view.width())-2][1] - src_it[static_cast<std::size_t>(src_view.width())-1][1]) / 2;
+        dst_it[dst_view.width()-1][2] = 128 + (src_it[static_cast<std::size_t>(src_view.width())-2][2] - src_it[static_cast<std::size_t>(src_view.width())-1][2]) / 2;
 
-        dst_it[0][3] = dst_it[src_view.width()-1][3] = 255;
+        dst_it[0][3] = dst_it[static_cast<std::size_t>(src_view.width())-1][3] = 255;
 
-        for (int x=1; x<src_view.width()-1; ++x)
+        for (std::size_t x=1; x<static_cast<std::size_t>(src_view.width())-1; ++x)
         {
             dst_it[x][0] = 128 + (src_it[x-1][0] - src_it[x+1][0]) / 2;
             dst_it[x][1] = 128 + (src_it[x-1][1] - src_it[x+1][1]) / 2;
@@ -743,10 +746,10 @@ void apply_filter(Src & src, invert const& /*op*/)
 
     rgba8_view_t src_view = rgba8_view(src);
 
-    for (int y=0; y<src_view.height(); ++y)
+    for (std::size_t y=0; y<static_cast<std::size_t>(src_view.height()); ++y)
     {
-        rgba8_view_t::x_iterator src_it = src_view.row_begin(y);
-        for (int x=0; x<src_view.width(); ++x)
+        rgba8_view_t::x_iterator src_it = src_view.row_begin(static_cast<long>(y));
+        for (std::size_t x=0; x<static_cast<std::size_t>(src_view.width()); ++x)
         {
             // we only work with premultiplied source,
             // thus all color values must be <= alpha
diff --git a/include/mapnik/image_filter_grammar.hpp b/include/mapnik/image_filter_grammar.hpp
index a7c0bd9..5f2d719 100644
--- a/include/mapnik/image_filter_grammar.hpp
+++ b/include/mapnik/image_filter_grammar.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -27,6 +27,9 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/spirit/include/qi.hpp>
 #include <boost/fusion/include/adapt_struct.hpp>
 #pragma GCC diagnostic pop
diff --git a/include/mapnik/image_filter_grammar_impl.hpp b/include/mapnik/image_filter_grammar_impl.hpp
index c88089f..a9f11d8 100644
--- a/include/mapnik/image_filter_grammar_impl.hpp
+++ b/include/mapnik/image_filter_grammar_impl.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -25,7 +25,10 @@
 #include <mapnik/image_filter_grammar.hpp>
 
 // spirit
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wsign-conversion"
 #include <boost/spirit/include/phoenix.hpp>
+#pragma GCC diagnostic pop
 
 namespace mapnik {
 
diff --git a/include/mapnik/image_filter_types.hpp b/include/mapnik/image_filter_types.hpp
index e4c9df0..5d61d1d 100644
--- a/include/mapnik/image_filter_types.hpp
+++ b/include/mapnik/image_filter_types.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/image_impl.hpp b/include/mapnik/image_impl.hpp
index f4815b7..5a84f9e 100644
--- a/include/mapnik/image_impl.hpp
+++ b/include/mapnik/image_impl.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/image_null.hpp b/include/mapnik/image_null.hpp
index 285a579..c318c76 100644
--- a/include/mapnik/image_null.hpp
+++ b/include/mapnik/image_null.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -42,34 +42,34 @@ public:
 private:
 public:
     image() {}
-    image(int width,
-          int height,
-          bool initialize = true,
-          bool premultiplied = false,
-          bool painted = false) {}
-    image(image<null_t> const& rhs) {}
-    image(image<null_t> && rhs) noexcept {}
-    image<null_t>& operator=(image<null_t> rhs) { return *this; }
+    image(int /*width*/,
+          int /*height*/,
+          bool /*initialize*/ = true,
+          bool /*premultiplied*/ = false,
+          bool /*painted*/ = false) {}
+    image(image<null_t> const&) {}
+    image(image<null_t> &&) noexcept {}
+    image<null_t>& operator=(image<null_t>) { return *this; }
     image<null_t>const& operator=(image<null_t> const& rhs) const { return rhs; }
-    bool operator==(image<null_t> const& rhs) const { return true; }
-    bool operator<(image<null_t> const& rhs) const { return false; }
+    bool operator==(image<null_t> const&) const { return true; }
+    bool operator<(image<null_t> const&) const { return false; }
 
     std::size_t width() const { return 0; }
     std::size_t height() const { return 0; }
     std::size_t size() const { return 0; }
     std::size_t row_size() const { return 0; }
-    void set(pixel_type const& t) { throw std::runtime_error("Can not set values for null image"); }
-    pixel_type& operator() (std::size_t i, std::size_t j) { throw std::runtime_error("Can not get or set values for null image"); }
-    pixel_type const& operator() (std::size_t i, std::size_t j) const { throw std::runtime_error("Can not get or set values for null image"); }
+    void set(pixel_type const&) { throw std::runtime_error("Can not set values for null image"); }
+    pixel_type& operator() (std::size_t, std::size_t) { throw std::runtime_error("Can not get or set values for null image"); }
+    pixel_type const& operator() (std::size_t, std::size_t) const { throw std::runtime_error("Can not get or set values for null image"); }
     unsigned const char* bytes() const { return nullptr; }
     unsigned char* bytes() {return nullptr; }
     double get_offset() const { return 0.0; }
-    void set_offset(double set) {}
+    void set_offset(double) {}
     double get_scaling() const { return 1.0; }
-    void set_scaling(double set) {}
+    void set_scaling(double) {}
     bool get_premultiplied() const { return false; }
-    void set_premultiplied(bool set) {}
-    void painted(bool painted) {}
+    void set_premultiplied(bool) {}
+    void painted(bool) {}
     bool painted() const { return false; }
     image_dtype get_dtype() const { return dtype; }
 };
diff --git a/include/mapnik/image_reader.hpp b/include/mapnik/image_reader.hpp
index 471a08b..a15d7c9 100644
--- a/include/mapnik/image_reader.hpp
+++ b/include/mapnik/image_reader.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/image_scaling.hpp b/include/mapnik/image_scaling.hpp
index 0dd94c9..ad4954e 100644
--- a/include/mapnik/image_scaling.hpp
+++ b/include/mapnik/image_scaling.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/image_scaling_traits.hpp b/include/mapnik/image_scaling_traits.hpp
index 9b78306..e2d0220 100644
--- a/include/mapnik/image_scaling_traits.hpp
+++ b/include/mapnik/image_scaling_traits.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/image_util.hpp b/include/mapnik/image_util.hpp
index 7185d64..1207bb8 100644
--- a/include/mapnik/image_util.hpp
+++ b/include/mapnik/image_util.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -30,6 +30,9 @@
 // boost
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/algorithm/string/predicate.hpp>
 #include <boost/optional.hpp>
 #pragma GCC diagnostic pop
@@ -195,12 +198,6 @@ MAPNIK_DECL void fill (image<gray64s_t>  & data, T const&);
 template <typename T>
 MAPNIK_DECL void fill (image<gray64f_t> & data, T const&);
 
-// SET RECTANGLE
-MAPNIK_DECL void set_rectangle (image_any & dst, image_any const& src, int x = 0, int y = 0);
-
-template <typename T>
-MAPNIK_DECL void set_rectangle (T & dst, T const& src, int x = 0, int y = 0);
-
 // CHECK BOUNDS
 template <typename T>
 inline bool check_bounds (T const& data, std::size_t x, std::size_t y)
diff --git a/include/mapnik/image_util_jpeg.hpp b/include/mapnik/image_util_jpeg.hpp
index 5f77f56..b4d2648 100644
--- a/include/mapnik/image_util_jpeg.hpp
+++ b/include/mapnik/image_util_jpeg.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/image_util_png.hpp b/include/mapnik/image_util_png.hpp
index 06dcde8..e02cb44 100644
--- a/include/mapnik/image_util_png.hpp
+++ b/include/mapnik/image_util_png.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -37,7 +37,7 @@ struct png_saver_pal
   private:
     std::ostream & stream_;
     std::string const& t_;
-    rgba_palette const& pal_; 
+    rgba_palette const& pal_;
 };
 
 struct png_saver
diff --git a/include/mapnik/image_util_tiff.hpp b/include/mapnik/image_util_tiff.hpp
index 5cacc67..39b524d 100644
--- a/include/mapnik/image_util_tiff.hpp
+++ b/include/mapnik/image_util_tiff.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/image_util_webp.hpp b/include/mapnik/image_util_webp.hpp
index 14a2183..6d28138 100644
--- a/include/mapnik/image_util_webp.hpp
+++ b/include/mapnik/image_util_webp.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/image_view.hpp b/include/mapnik/image_view.hpp
index 302cd40..c2f023a 100644
--- a/include/mapnik/image_view.hpp
+++ b/include/mapnik/image_view.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/image_view_any.hpp b/include/mapnik/image_view_any.hpp
index 6ce0fe5..f61e33d 100644
--- a/include/mapnik/image_view_any.hpp
+++ b/include/mapnik/image_view_any.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/image_view_impl.hpp b/include/mapnik/image_view_impl.hpp
index 6fc8517..89ae151 100644
--- a/include/mapnik/image_view_impl.hpp
+++ b/include/mapnik/image_view_impl.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/image_view_null.hpp b/include/mapnik/image_view_null.hpp
index 1ad6c3d..5672c05 100644
--- a/include/mapnik/image_view_null.hpp
+++ b/include/mapnik/image_view_null.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -40,20 +40,20 @@ public:
     image_view() {}
     ~image_view() {};
 
-    image_view(image_view<image_null> const& rhs) {}
-    image_view<image_null> & operator=(image_view<image_null> const& rhs) { return *this; }
-    bool operator==(image_view<image_null> const& rhs) const { return true; }
-    bool operator<(image_view<image_null> const& rhs) const { return false; }
+    image_view(image_view<image_null> const&) {}
+    image_view<image_null> & operator=(image_view<image_null> const&) { return *this; }
+    bool operator==(image_view<image_null> const&) const { return true; }
+    bool operator<(image_view<image_null> const&) const { return false; }
 
     std::size_t x() const { return 0; }
     std::size_t y() const { return 0; }
     std::size_t width() const { return 0; }
     std::size_t height() const { return 0; }
-    pixel_type operator() (std::size_t i, std::size_t j) const { throw std::runtime_error("Can not get from a null image view"); }
+    pixel_type operator() (std::size_t, std::size_t) const { throw std::runtime_error("Can not get from a null image view"); }
     std::size_t size() const { return 0; }
     std::size_t row_size() const { return 0; }
-    const pixel_type* get_row(std::size_t row) const { return nullptr; }
-    const pixel_type* get_row(std::size_t row, std::size_t x0) const { return nullptr; }
+    const pixel_type* get_row(std::size_t) const { return nullptr; }
+    const pixel_type* get_row(std::size_t, std::size_t) const { return nullptr; }
     bool get_premultiplied() const { return false; }
     double get_offset() const { return 0.0; }
     double get_scaling() const { return 1.0; }
diff --git a/include/mapnik/internal/dump_xml.hpp b/include/mapnik/internal/dump_xml.hpp
deleted file mode 100644
index f807590..0000000
--- a/include/mapnik/internal/dump_xml.hpp
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef DUMP_XML_HPP
-#define DUMP_XML_HPP
-#include <mapnik/xml_node.hpp>
-
-namespace mapnik
-{
-
-// Debug dump ptree XML representation.
-
-void dump_xml(xml_node const& xml, unsigned level=0)
-{
-    std::string indent;
-    unsigned i;
-    for (i=0; i<level; i++)
-    {
-        indent += "    ";
-    }
-    xml_node::attribute_map const& attr_map = xml.get_attributes();
-    std::cerr << indent <<"[" << xml.name();
-    for (auto const& attr : attr_map)
-    {
-        std::cerr << " (" << attr.first << ", " << attr.second.value << ", " << attr.second.processed << ")";
-    }
-    std::cerr << "]" << "\n";
-    if (xml.is_text()) std::cerr << indent << "text: '" << xml.text() << "'\n";
-    for (auto const& child : xml)
-    {
-        dump_xml(child, level+1);
-    }
-    std::cerr << indent << "[/" << xml.name() << "]" << "\n";
-}
-
-}
-#endif // DUMP_XML_HPP
diff --git a/include/mapnik/jpeg_io.hpp b/include/mapnik/jpeg_io.hpp
index 2c3c284..06a0bc3 100644
--- a/include/mapnik/jpeg_io.hpp
+++ b/include/mapnik/jpeg_io.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/json/error_handler.hpp b/include/mapnik/json/error_handler.hpp
index 74b0aa4..2f38f62 100644
--- a/include/mapnik/json/error_handler.hpp
+++ b/include/mapnik/json/error_handler.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -25,7 +25,10 @@
 
 #include <string>
 #include <sstream>
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wsign-conversion"
 #include <boost/spirit/home/support/info.hpp>
+#pragma GCC diagnostic pop
 
 namespace mapnik { namespace json {
 
diff --git a/include/mapnik/json/extract_bounding_box_grammar.hpp b/include/mapnik/json/extract_bounding_box_grammar.hpp
index 0cc3733..2183fe5 100644
--- a/include/mapnik/json/extract_bounding_box_grammar.hpp
+++ b/include/mapnik/json/extract_bounding_box_grammar.hpp
@@ -32,6 +32,9 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/spirit/include/qi.hpp>
 #include <boost/spirit/include/phoenix_function.hpp>
 #include <boost/fusion/adapted/std_tuple.hpp>
diff --git a/include/mapnik/json/feature_collection_grammar.hpp b/include/mapnik/json/feature_collection_grammar.hpp
index 2089cfe..5c13f8c 100644
--- a/include/mapnik/json/feature_collection_grammar.hpp
+++ b/include/mapnik/json/feature_collection_grammar.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/json/feature_collection_grammar_impl.hpp b/include/mapnik/json/feature_collection_grammar_impl.hpp
index 0275b47..8f73918 100644
--- a/include/mapnik/json/feature_collection_grammar_impl.hpp
+++ b/include/mapnik/json/feature_collection_grammar_impl.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/json/feature_generator.hpp b/include/mapnik/json/feature_generator.hpp
index 0d3fcb8..f24df4e 100644
--- a/include/mapnik/json/feature_generator.hpp
+++ b/include/mapnik/json/feature_generator.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/json/feature_generator_grammar.hpp b/include/mapnik/json/feature_generator_grammar.hpp
index 3852c7b..9eaa3bb 100644
--- a/include/mapnik/json/feature_generator_grammar.hpp
+++ b/include/mapnik/json/feature_generator_grammar.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -84,8 +84,8 @@ template <typename T>
 struct get_id
 {
     using feature_type = T;
-    using result_type = int;
-    int operator() (feature_type const& f) const
+    using result_type = mapnik::value_integer;
+    result_type operator() (feature_type const& f) const
     {
         return f.id();
     }
diff --git a/include/mapnik/json/feature_generator_grammar_impl.hpp b/include/mapnik/json/feature_generator_grammar_impl.hpp
index 7147bd8..f819baa 100644
--- a/include/mapnik/json/feature_generator_grammar_impl.hpp
+++ b/include/mapnik/json/feature_generator_grammar_impl.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/json/feature_grammar.hpp b/include/mapnik/json/feature_grammar.hpp
index 08eb39d..59261d7 100644
--- a/include/mapnik/json/feature_grammar.hpp
+++ b/include/mapnik/json/feature_grammar.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -31,10 +31,13 @@
 #include <mapnik/value.hpp>
 #include <mapnik/json/generic_json.hpp>
 #include <mapnik/json/value_converters.hpp>
-// spirit::qi
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wsign-conversion"
 #include <boost/spirit/include/qi.hpp>
 #include <boost/spirit/include/phoenix.hpp>
 #include <boost/spirit/include/support_line_pos_iterator.hpp>
+#pragma GCC diagnostic pop
 
 namespace mapnik { namespace json {
 
diff --git a/include/mapnik/json/feature_grammar_impl.hpp b/include/mapnik/json/feature_grammar_impl.hpp
index c7f50bb..409925a 100644
--- a/include/mapnik/json/feature_grammar_impl.hpp
+++ b/include/mapnik/json/feature_grammar_impl.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/json/feature_parser.hpp b/include/mapnik/json/feature_parser.hpp
index 3e5b2b3..433d19e 100644
--- a/include/mapnik/json/feature_parser.hpp
+++ b/include/mapnik/json/feature_parser.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/json/generic_json.hpp b/include/mapnik/json/generic_json.hpp
index 16124ad..adc1990 100644
--- a/include/mapnik/json/generic_json.hpp
+++ b/include/mapnik/json/generic_json.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -30,6 +30,9 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/spirit/include/qi.hpp>
 #include <boost/spirit/include/phoenix.hpp>
 #pragma GCC diagnostic pop
diff --git a/include/mapnik/json/geometry_generator_grammar.hpp b/include/mapnik/json/geometry_generator_grammar.hpp
index a26de5b..01b6318 100644
--- a/include/mapnik/json/geometry_generator_grammar.hpp
+++ b/include/mapnik/json/geometry_generator_grammar.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -32,6 +32,9 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/spirit/include/karma.hpp>
 #include <boost/spirit/include/phoenix_function.hpp>
 #include <boost/math/special_functions/trunc.hpp> // for vc++ and android whose c++11 libs lack std::trunc
diff --git a/include/mapnik/json/geometry_grammar.hpp b/include/mapnik/json/geometry_grammar.hpp
index 2414557..4bc25c9 100644
--- a/include/mapnik/json/geometry_grammar.hpp
+++ b/include/mapnik/json/geometry_grammar.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/json/geometry_grammar_impl.hpp b/include/mapnik/json/geometry_grammar_impl.hpp
index 71188a7..9fa7df9 100644
--- a/include/mapnik/json/geometry_grammar_impl.hpp
+++ b/include/mapnik/json/geometry_grammar_impl.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/json/geometry_parser.hpp b/include/mapnik/json/geometry_parser.hpp
index 941abb0..c83901d 100644
--- a/include/mapnik/json/geometry_parser.hpp
+++ b/include/mapnik/json/geometry_parser.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/json/geometry_util.hpp b/include/mapnik/json/geometry_util.hpp
index 36c4175..6e8fb67 100644
--- a/include/mapnik/json/geometry_util.hpp
+++ b/include/mapnik/json/geometry_util.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/json/positions_grammar.hpp b/include/mapnik/json/positions_grammar.hpp
index 2a70306..b7d65d0 100644
--- a/include/mapnik/json/positions_grammar.hpp
+++ b/include/mapnik/json/positions_grammar.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -33,6 +33,9 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/spirit/include/qi.hpp>
 #include <boost/spirit/include/phoenix_function.hpp>
 #include <boost/fusion/adapted/std_tuple.hpp>
diff --git a/include/mapnik/json/positions_grammar_impl.hpp b/include/mapnik/json/positions_grammar_impl.hpp
index d90843c..7737e46 100644
--- a/include/mapnik/json/positions_grammar_impl.hpp
+++ b/include/mapnik/json/positions_grammar_impl.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/json/properties_generator_grammar.hpp b/include/mapnik/json/properties_generator_grammar.hpp
index e52b55e..781d807 100644
--- a/include/mapnik/json/properties_generator_grammar.hpp
+++ b/include/mapnik/json/properties_generator_grammar.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -28,6 +28,12 @@
 #include <mapnik/feature_kv_iterator.hpp>
 
 // boost
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/spirit/include/karma.hpp>
 #include <boost/spirit/include/phoenix.hpp>
 #include <boost/spirit/include/phoenix_function.hpp>
@@ -37,6 +43,7 @@
 #include <boost/fusion/adapted/std_tuple.hpp>
 #include <boost/fusion/include/at.hpp>
 #include <boost/fusion/include/cons.hpp>
+#pragma GCC diagnostic pop
 
 namespace mapnik { namespace json {
 
diff --git a/include/mapnik/json/properties_generator_grammar_impl.hpp b/include/mapnik/json/properties_generator_grammar_impl.hpp
index 197f000..eff4565 100644
--- a/include/mapnik/json/properties_generator_grammar_impl.hpp
+++ b/include/mapnik/json/properties_generator_grammar_impl.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/json/symbolizer_grammar.hpp b/include/mapnik/json/symbolizer_grammar.hpp
index bd34af0..494b81f 100644
--- a/include/mapnik/json/symbolizer_grammar.hpp
+++ b/include/mapnik/json/symbolizer_grammar.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/json/topojson_grammar.hpp b/include/mapnik/json/topojson_grammar.hpp
index e3db099..1cc967e 100644
--- a/include/mapnik/json/topojson_grammar.hpp
+++ b/include/mapnik/json/topojson_grammar.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -33,6 +33,9 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/spirit/include/qi.hpp>
 #include <boost/spirit/include/phoenix_function.hpp>
 #pragma GCC diagnostic pop
diff --git a/include/mapnik/json/topojson_grammar_impl.hpp b/include/mapnik/json/topojson_grammar_impl.hpp
index d939d4b..f20fbf9 100644
--- a/include/mapnik/json/topojson_grammar_impl.hpp
+++ b/include/mapnik/json/topojson_grammar_impl.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/json/topojson_utils.hpp b/include/mapnik/json/topojson_utils.hpp
index 9055218..5558bde 100644
--- a/include/mapnik/json/topojson_utils.hpp
+++ b/include/mapnik/json/topojson_utils.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -83,7 +83,7 @@ struct bounding_box_visitor
         {
             index_type index = line.ring;
             index_type arc_index = index < 0 ? std::abs(index) - 1 : index;
-            if (arc_index < num_arcs_)
+            if (arc_index >= 0 && arc_index < static_cast<int>(num_arcs_))
             {
                 bool first = true;
                 double px = 0, py = 0;
@@ -121,7 +121,7 @@ struct bounding_box_visitor
             for (auto index : multi_line.rings)
             {
                 index_type arc_index = index < 0 ? std::abs(index) - 1 : index;
-                if (arc_index < num_arcs_)
+                if (arc_index >= 0 && arc_index < static_cast<int>(num_arcs_))
                 {
                     double px = 0, py = 0;
                     auto const& arcs = topo_.arcs[arc_index];
@@ -161,7 +161,7 @@ struct bounding_box_visitor
                 for (auto index : ring)
                 {
                     index_type arc_index = index < 0 ? std::abs(index) - 1 : index;
-                    if (arc_index < num_arcs_)
+                    if (arc_index >= 0 && arc_index < static_cast<int>(num_arcs_))
                     {
                         double px = 0, py = 0;
                         auto const& arcs = topo_.arcs[arc_index];
@@ -206,7 +206,7 @@ struct bounding_box_visitor
                     for (auto index : ring)
                     {
                         index_type arc_index = index < 0 ? std::abs(index) - 1 : index;
-                        if (arc_index < num_arcs_)
+                        if (arc_index >= 0 && arc_index < static_cast<int>(num_arcs_))
                         {
                             double px = 0, py = 0;
                             auto const& arcs = topo_.arcs[arc_index];
diff --git a/include/mapnik/json/topology.hpp b/include/mapnik/json/topology.hpp
index 12e0f9a..3cfc2d3 100644
--- a/include/mapnik/json/topology.hpp
+++ b/include/mapnik/json/topology.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -26,9 +26,12 @@
 #include <mapnik/json/generic_json.hpp>
 #include <mapnik/util/variant.hpp>
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wshadow"
 #include <boost/fusion/include/adapt_struct.hpp>
 #include <boost/fusion/adapted/std_tuple.hpp>
 #include <boost/optional.hpp>
+#pragma GCC diagnostic pop
 
 #include <tuple>
 #include <vector>
diff --git a/include/mapnik/json/value_converters.hpp b/include/mapnik/json/value_converters.hpp
index 9bbc24e..384ecb8 100644
--- a/include/mapnik/json/value_converters.hpp
+++ b/include/mapnik/json/value_converters.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/label_collision_detector.hpp b/include/mapnik/label_collision_detector.hpp
index a33747b..6dce9ff 100644
--- a/include/mapnik/label_collision_detector.hpp
+++ b/include/mapnik/label_collision_detector.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -78,7 +78,7 @@ public:
         tree_t::query_iterator end = tree_.query_end();
         for ( ;itr != end; ++itr)
         {
-            if (itr->intersects(box)) return false;
+            if (itr->get().intersects(box)) return false;
         }
         tree_.insert(box,box);
         return true;
@@ -108,7 +108,7 @@ public:
 
         for ( ;itr != end; ++itr)
         {
-            if (itr->intersects(box)) return false;
+            if (itr->get().intersects(box)) return false;
         }
         return true;
     }
@@ -155,7 +155,7 @@ public:
 
         for ( ;itr != end; ++itr)
         {
-            if (itr->box.intersects(box)) return false;
+            if (itr->get().box.intersects(box)) return false;
         }
 
         return true;
@@ -173,7 +173,7 @@ public:
 
         for (;itr != end; ++itr)
         {
-            if (itr->box.intersects(margin_box))
+            if (itr->get().box.intersects(margin_box))
             {
                 return false;
             }
@@ -201,7 +201,7 @@ public:
 
         for ( ;itr != end; ++itr)
         {
-            if (itr->box.intersects(margin_box) || (text == itr->text && itr->box.intersects(repeat_box)))
+            if (itr->get().box.intersects(margin_box) || (text == itr->get().text && itr->get().box.intersects(repeat_box)))
             {
                 return false;
             }
diff --git a/include/mapnik/layer.hpp b/include/mapnik/layer.hpp
index 4b4e9f8..a00b488 100644
--- a/include/mapnik/layer.hpp
+++ b/include/mapnik/layer.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/load_map.hpp b/include/mapnik/load_map.hpp
index 5696a9e..30a04eb 100644
--- a/include/mapnik/load_map.hpp
+++ b/include/mapnik/load_map.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/make_unique.hpp b/include/mapnik/make_unique.hpp
index ea2974c..f6fd4a2 100644
--- a/include/mapnik/make_unique.hpp
+++ b/include/mapnik/make_unique.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/map.hpp b/include/mapnik/map.hpp
index ee1c7a3..23ea96a 100644
--- a/include/mapnik/map.hpp
+++ b/include/mapnik/map.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/mapped_memory_cache.hpp b/include/mapnik/mapped_memory_cache.hpp
index 3673c15..f41c2e8 100644
--- a/include/mapnik/mapped_memory_cache.hpp
+++ b/include/mapnik/mapped_memory_cache.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -25,7 +25,7 @@
 
 // mapnik
 #include <mapnik/config.hpp>
-#include <mapnik/utils.hpp>
+#include <mapnik/util/singleton.hpp>
 #include <mapnik/util/noncopyable.hpp>
 
 // boost
diff --git a/include/mapnik/marker.hpp b/include/mapnik/marker.hpp
index 3eaaebe..6f7cbf0 100644
--- a/include/mapnik/marker.hpp
+++ b/include/mapnik/marker.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -49,7 +49,7 @@ using image_ptr = std::shared_ptr<image_any>;
 struct marker_rgba8
 {
 public:
-    marker_rgba8() 
+    marker_rgba8()
         : bitmap_data_(4,4,true,true)
     {
         // create default OGC 4x4 black pixel
@@ -58,7 +58,7 @@ public:
 
     marker_rgba8(image_rgba8 const & data)
         : bitmap_data_(data) {}
-    
+
     marker_rgba8(image_rgba8 && data)
         : bitmap_data_(std::move(data)) {}
 
@@ -70,19 +70,19 @@ public:
 
     box2d<double> bounding_box() const
     {
-        double width = bitmap_data_.width();
-        double height = bitmap_data_.height();
-        return box2d<double>(0, 0, width, height);
+        std::size_t width = bitmap_data_.width();
+        std::size_t height = bitmap_data_.height();
+        return box2d<double>(static_cast<double>(0), static_cast<double>(0), static_cast<double>(width), static_cast<double>(height));
     }
 
-    inline std::size_t width() const
+    inline double width() const
     {
-        return bitmap_data_.width();
+        return static_cast<double>(bitmap_data_.width());
     }
 
-    inline std::size_t height() const
+    inline double height() const
     {
-        return bitmap_data_.height();
+        return static_cast<double>(bitmap_data_.height());
     }
 
     image_rgba8 const& get_data() const
@@ -132,7 +132,7 @@ private:
 
 };
 
-struct marker_null 
+struct marker_null
 {
     marker_null() = default;
 public:
@@ -150,7 +150,7 @@ public:
     }
 };
 
-using marker_base = util::variant<marker_null, 
+using marker_base = util::variant<marker_null,
                                   marker_rgba8,
                                   marker_svg>;
 namespace detail {
@@ -169,7 +169,7 @@ struct get_marker_width_visitor
     template <typename T>
     double operator()(T const& data) const
     {
-        return static_cast<double>(data.width());
+        return data.width();
     }
 };
 
@@ -178,7 +178,7 @@ struct get_marker_height_visitor
     template <typename T>
     double operator()(T const& data) const
     {
-        return static_cast<double>(data.height());
+        return data.height();
     }
 };
 
diff --git a/include/mapnik/marker_cache.hpp b/include/mapnik/marker_cache.hpp
index d685cc9..47aa555 100644
--- a/include/mapnik/marker_cache.hpp
+++ b/include/mapnik/marker_cache.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -24,13 +24,13 @@
 #define MAPNIK_MARKER_CACHE_HPP
 
 // mapnik
-#include <mapnik/utils.hpp>
+#include <mapnik/util/singleton.hpp>
 #include <mapnik/config.hpp>
 #include <mapnik/util/noncopyable.hpp>
 
-// boost
-#include <boost/unordered_map.hpp>
+#include <unordered_map>
 #include <memory>
+#include <string>
 
 namespace mapnik
 {
@@ -46,9 +46,9 @@ private:
     marker_cache();
     ~marker_cache();
     bool insert_marker(std::string const& key, marker && path);
-    boost::unordered_map<std::string, std::shared_ptr<mapnik::marker const> > marker_cache_;
+    std::unordered_map<std::string, std::shared_ptr<mapnik::marker const> > marker_cache_;
     bool insert_svg(std::string const& name, std::string const& svg_string);
-    boost::unordered_map<std::string,std::string> svg_cache_;
+    std::unordered_map<std::string,std::string> svg_cache_;
 public:
     std::string known_svg_prefix_;
     std::string known_image_prefix_;
diff --git a/include/mapnik/marker_helpers.hpp b/include/mapnik/marker_helpers.hpp
index 15dca62..e6fdfa2 100644
--- a/include/mapnik/marker_helpers.hpp
+++ b/include/mapnik/marker_helpers.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -24,12 +24,11 @@
 #define MAPNIK_MARKER_HELPERS_HPP
 
 #include <mapnik/feature.hpp>
-#include <mapnik/color.hpp>
 #include <mapnik/geometry.hpp>
 #include <mapnik/geometry_type.hpp>
 #include <mapnik/geometry_centroid.hpp>
 #include <mapnik/symbolizer.hpp>
-#include <mapnik/svg/svg_converter.hpp>
+#include <mapnik/svg/svg_path_attributes.hpp>
 #include <mapnik/marker.hpp> // for svg_storage_type
 #include <mapnik/markers_placement.hpp>
 #include <mapnik/attribute.hpp>
@@ -47,8 +46,6 @@ namespace mapnik {
 
 struct clip_poly_tag;
 
-namespace svg { struct path_attributes; }
-
 using svg_attribute_type = agg::pod_bvector<svg::path_attributes>;
 
 template <typename Detector>
diff --git a/include/mapnik/markers_placement.hpp b/include/mapnik/markers_placement.hpp
index 1472e6e..3e7e3e4 100644
--- a/include/mapnik/markers_placement.hpp
+++ b/include/mapnik/markers_placement.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/markers_placements/interior.hpp b/include/mapnik/markers_placements/interior.hpp
index 9fbc14c..93b5e34 100644
--- a/include/mapnik/markers_placements/interior.hpp
+++ b/include/mapnik/markers_placements/interior.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/markers_placements/line.hpp b/include/mapnik/markers_placements/line.hpp
index c8017b5..fe2c2bd 100644
--- a/include/mapnik/markers_placements/line.hpp
+++ b/include/mapnik/markers_placements/line.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/markers_placements/point.hpp b/include/mapnik/markers_placements/point.hpp
index 37cda84..65b95ce 100644
--- a/include/mapnik/markers_placements/point.hpp
+++ b/include/mapnik/markers_placements/point.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/markers_placements/vertext_first.hpp b/include/mapnik/markers_placements/vertext_first.hpp
index 7c149eb..bcdac2b 100644
--- a/include/mapnik/markers_placements/vertext_first.hpp
+++ b/include/mapnik/markers_placements/vertext_first.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/markers_placements/vertext_last.hpp b/include/mapnik/markers_placements/vertext_last.hpp
index 1c85c95..4d57130 100644
--- a/include/mapnik/markers_placements/vertext_last.hpp
+++ b/include/mapnik/markers_placements/vertext_last.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/memory.hpp b/include/mapnik/memory.hpp
deleted file mode 100644
index c4bff29..0000000
--- a/include/mapnik/memory.hpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/*****************************************************************************
- *
- * This file is part of Mapnik (c++ mapping toolkit)
- *
- * Copyright (C) 2014 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_MEMORY_HPP
-#define MAPNIK_MEMORY_HPP
-
-#include <new>
-
-namespace mapnik
-{
-class MemoryUtils
-{
-public:
-    static size_t alignPointerSize(size_t ptrSize);
-private:
-    MemoryUtils();
-    MemoryUtils(const MemoryUtils&);
-    MemoryUtils& operator=(const MemoryUtils&);
-};
-
-class MemoryManager
-{
-public:
-    virtual void* allocate(size_t size)=0;
-    virtual void deallocate(void* p)=0;
-    virtual ~MemoryManager();
-protected:
-    MemoryManager();                      // {}
-private:
-    MemoryManager(const MemoryManager&);
-    MemoryManager& operator=(const MemoryManager&);
-};
-
-class Object
-{
-public:
-    void* operator new(size_t size);
-    void* operator new(size_t size, MemoryManager* manager);
-    void operator delete(void* p);
-    void operator delete(void* p, MemoryManager* manager);
-protected:
-    virtual ~Object() {}
-    Object() {}
-    Object(const Object&) {}
-protected:
-    Object& operator=(const Object&)
-    {
-        return *this;
-    }
-};
-
-template <typename Geometry>
-class geometry_pool
-{
-public:
-    void* allocate()
-    {
-        return ::operator new(sizeof(Geometry));
-    }
-    void deallocate(void* p)
-    {
-        ::operator delete(p);
-    }
-};
-
-}
-#endif // MAPNIK_MEMORY_HPP
diff --git a/include/mapnik/memory_datasource.hpp b/include/mapnik/memory_datasource.hpp
index 83fdba6..a6ab918 100644
--- a/include/mapnik/memory_datasource.hpp
+++ b/include/mapnik/memory_datasource.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/memory_featureset.hpp b/include/mapnik/memory_featureset.hpp
index 5193c8c..cc5005b 100644
--- a/include/mapnik/memory_featureset.hpp
+++ b/include/mapnik/memory_featureset.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/miniz_png.hpp b/include/mapnik/miniz_png.hpp
index 0414c32..6c46e44 100644
--- a/include/mapnik/miniz_png.hpp
+++ b/include/mapnik/miniz_png.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/octree.hpp b/include/mapnik/octree.hpp
index ea813c8..007e696 100644
--- a/include/mapnik/octree.hpp
+++ b/include/mapnik/octree.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/offset_converter.hpp b/include/mapnik/offset_converter.hpp
index ad9d73d..51d43e3 100644
--- a/include/mapnik/offset_converter.hpp
+++ b/include/mapnik/offset_converter.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -29,6 +29,7 @@
 #include <mapnik/global.hpp>
 #include <mapnik/config.hpp>
 #include <mapnik/vertex.hpp>
+#include <mapnik/vertex_cache.hpp>
 
 // stl
 #include <cmath>
@@ -39,20 +40,20 @@ namespace mapnik
 {
 
 template <typename Geometry>
-struct MAPNIK_DECL offset_converter
+struct offset_converter
 {
     using size_type = std::size_t;
 
     offset_converter(Geometry & geom)
         : geom_(geom)
         , offset_(0.0)
-        , threshold_(8.0)
+        , threshold_(5.0)
         , half_turn_segments_(16)
         , status_(initial)
         , pre_first_(vertex2d::no_init)
         , pre_(vertex2d::no_init)
         , cur_(vertex2d::no_init)
-        {}
+    {}
 
     enum status
     {
@@ -246,8 +247,8 @@ private:
      */
     void displace(vertex2d & v, double a) const
     {
-        v.x += offset_ * std::sin(a);
-        v.y -= offset_ * std::cos(a);
+        v.x -= offset_ * std::sin(a);
+        v.y += offset_ * std::cos(a);
     }
 
     /**
@@ -255,8 +256,8 @@ private:
      */
     void displace(vertex2d & v, vertex2d const& u, double a) const
     {
-        v.x = u.x + offset_ * std::sin(a);
-        v.y = u.y - offset_ * std::cos(a);
+        v.x = u.x - offset_ * std::sin(a);
+        v.y = u.y + offset_ * std::cos(a);
         v.cmd = u.cmd;
     }
 
@@ -265,8 +266,27 @@ private:
         double sa = offset_ * std::sin(a);
         double ca = offset_ * std::cos(a);
         double h = std::tan(0.5 * (b - a));
-        v.x = v.x + sa + h * ca;
-        v.y = v.y - ca + h * sa;
+        double hsa = h * sa;
+        double hca = h * ca;
+        double abs_offset = std::abs(offset_);
+        if (hsa > 1.0 * abs_offset)
+        {
+            hsa = 1.0 * abs_offset;
+        }
+        else if (hsa < -1.0 * abs_offset)
+        {
+            hsa = -1.0 * abs_offset;
+        }
+        if (hca > 1.0 * abs_offset)
+        {
+            hca = 1.0 * abs_offset;
+        }
+        else if (hca < -1.0 * abs_offset)
+        {
+            hca = -1.0 * abs_offset;
+        }
+        v.x = v.x - sa - hca;
+        v.y = v.y + ca - hsa;
     }
 
     status init_vertices()
@@ -275,13 +295,61 @@ private:
         {
             return status_;
         }
-
+        vertex2d v0(vertex2d::no_init);
         vertex2d v1(vertex2d::no_init);
         vertex2d v2(vertex2d::no_init);
         vertex2d w(vertex2d::no_init);
-
-        v1.cmd = geom_.vertex(&v1.x, &v1.y);
-        v2.cmd = geom_.vertex(&v2.x, &v2.y);
+        vertex2d start(vertex2d::no_init);
+        vertex2d start_v2(vertex2d::no_init);
+        std::vector<vertex2d> points;
+        std::vector<vertex2d> close_points;
+        bool is_polygon = false;
+        std::size_t cpt = 0;
+        v0.cmd = geom_.vertex(&v0.x, &v0.y);
+        v1 = v0;
+        // PUSH INITIAL
+        points.push_back(v0);
+        if (v0.cmd == SEG_END) // not enough vertices in source
+        {
+            return status_ = process;
+        }
+        start = v0;
+        while ((v0.cmd = geom_.vertex(&v0.x, &v0.y)) != SEG_END)
+        {
+            if (v0.cmd == SEG_CLOSE)
+            {
+                is_polygon = true;
+                auto & prev = points.back();
+                if (prev.x == start.x && prev.y == start.y)
+                {
+                    prev.x = v0.x; // hack
+                    prev.y = v0.y;
+                    prev.cmd = SEG_CLOSE; // account for dupes (line_to(move_to) + close_path) in agg poly clipper
+                    std::size_t size = points.size();
+                    if (size > 1) close_points.push_back(points[size - 2]);
+                    else close_points.push_back(prev);
+                    continue;
+                }
+                else
+                {
+                    close_points.push_back(v1);
+                }
+            }
+            else if (v0.cmd == SEG_MOVETO)
+            {
+                start = v0;
+            }
+            v1 = v0;
+            points.push_back(v0);
+        }
+        // Push SEG_END
+        points.push_back(vertex2d(v0.x,v0.y,SEG_END));
+        std::size_t i = 0;
+        v1 = points[i++];
+        v2 = points[i++];
+        v0.cmd = v1.cmd;
+        v0.x = v1.x;
+        v0.y = v1.y;
 
         if (v2.cmd == SEG_END) // not enough vertices in source
         {
@@ -289,59 +357,161 @@ private:
         }
 
         double angle_a = 0;
-        double angle_b = std::atan2((v2.y - v1.y), (v2.x - v1.x));
+        // The vector parts from v1 to v0.
+        double v_x1x0 = 0;
+        double v_y1y0 = 0;
+        // The vector parts from v1 to v2;
+        double v_x1x2 = v2.x - v1.x;
+        double v_y1y2 = v2.y - v1.y;
+
+        if (is_polygon)
+        {
+            v_x1x0 = close_points[cpt].x - v1.x;
+            v_y1y0 = close_points[cpt].y - v1.y;
+            cpt++;
+            angle_a = std::atan2(-v_y1y0, -v_x1x0);
+        }
+        // dot product
+        double dot;
+        // determinate
+        double det;
+        double angle_b = std::atan2(v_y1y2, v_x1x2);
+        // Angle between the two vectors
         double joint_angle;
+        double curve_angle;
 
-        // first vertex
-        displace(v1, angle_b);
-        push_vertex(v1);
+        if (!is_polygon)
+        {
+            // first vertex
+            displace(v1, angle_b);
+            push_vertex(v1);
+        }
+        else
+        {
+            dot = v_x1x0 * v_x1x2 + v_y1y0 * v_y1y2;      // dot product
+            det = v_x1x0 * v_y1y2 - v_y1y0 * v_x1x2;      // determinant
+
+            joint_angle = std::atan2(det, dot);  // atan2(y, x) or atan2(sin, cos)
+            if (joint_angle < 0) joint_angle = joint_angle + 2 * M_PI;
+            joint_angle = std::fmod(joint_angle, 2 * M_PI);
+
+            if (offset_ > 0.0)
+            {
+                joint_angle = 2 * M_PI - joint_angle;
+            }
+
+            int bulge_steps = 0;
+
+            if (std::abs(joint_angle) > M_PI)
+            {
+                curve_angle = explement_reflex_angle(angle_b - angle_a);
+                // Bulge steps should be determined by the inverse of the joint angle.
+                double half_turns = half_turn_segments_ * std::fabs(curve_angle);
+                bulge_steps = 1 + static_cast<int>(std::floor(half_turns / M_PI));
+            }
+
+            if (bulge_steps == 0)
+            {
+                displace2(v1, angle_a, angle_b);
+                push_vertex(v1);
+            }
+            else
+            {
+                displace(v1, angle_b);
+                push_vertex(v1);
+            }
+        }
 
         // Sometimes when the first segment is too short, it causes ugly
         // curls at the beginning of the line. To avoid this, we make up
         // a fake vertex two offset-lengths before the first, and expect
         // intersection detection smoothes it out.
-        pre_first_ = v1;
-        displace(pre_first_, -2 * std::fabs(offset_), 0, angle_b);
-        start_ = pre_first_;
-        while ((v1 = v2, v2.cmd = geom_.vertex(&v2.x, &v2.y)) != SEG_END)
+        if (!is_polygon)
         {
-            if (v2.cmd == SEG_MOVETO)
+            pre_first_ = v1;
+            displace(pre_first_, -2 * std::fabs(offset_), 0, angle_b);
+            start_ = pre_first_;
+        }
+        else
+        {
+            pre_first_ = v0;
+            start_ = pre_first_;
+        }
+        start_v2.x = v2.x;
+        start_v2.y = v2.y;
+        bool continue_loop = true;
+        while (i < points.size())
+        {
+            v1 = v2;
+            v2 = points[i++];
+            if (v1.cmd == SEG_MOVETO)
             {
-                start_ = v2;
+                if (is_polygon)
+                {
+                    v1.x = start_.x;
+                    v1.y = start_.y;
+                    if (cpt < close_points.size())
+                    {
+                        v_x1x2 = v1.x - close_points[cpt].x;
+                        v_y1y2 = v1.y - close_points[cpt].y;
+                        cpt++;
+                    }
+                    start_v2.x = v2.x;
+                    start_v2.y = v2.y;
+                }
+            }
+            if (is_polygon && v2.cmd == SEG_MOVETO)
+            {
+                start_.x = v2.x;
+                start_.y = v2.y;
+                v2.x = start_v2.x;
+                v2.y = start_v2.y;
+            }
+            else if (v2.cmd == SEG_END)
+            {
+                if (!is_polygon) break;
+                continue_loop = false;
+                v2.x = start_v2.x;
+                v2.y = start_v2.y;
             }
             else if (v2.cmd == SEG_CLOSE)
             {
                 v2.x = start_.x;
                 v2.y = start_.y;
             }
-            angle_a = angle_b;
-            angle_b = std::atan2((v2.y - v1.y), (v2.x - v1.x));
-            joint_angle = explement_reflex_angle(angle_b - angle_a);
 
-            double half_turns = half_turn_segments_ * std::fabs(joint_angle);
-            int bulge_steps = 0;
+            // Switch the previous vector's direction as the origin has changed
+            v_x1x0 = -v_x1x2;
+            v_y1y0 = -v_y1y2;
+            // Calculate new angle_a
+            angle_a = std::atan2(v_y1y2, v_x1x2);
+
+            // Calculate the new vector
+            v_x1x2 = v2.x - v1.x;
+            v_y1y2 = v2.y - v1.y;
+            // Calculate the new angle_b
+            angle_b = std::atan2(v_y1y2, v_x1x2);
+
+            dot = v_x1x0 * v_x1x2 + v_y1y0 * v_y1y2;      // dot product
+            det = v_x1x0 * v_y1y2 - v_y1y0 * v_x1x2;      // determinant
 
-            if (offset_ < 0.0)
+            joint_angle = std::atan2(det, dot);  // atan2(y, x) or atan2(sin, cos)
+            if (joint_angle < 0) joint_angle = joint_angle + 2 * M_PI;
+            joint_angle = std::fmod(joint_angle, 2 * M_PI);
+
+            if (offset_ > 0.0)
             {
-                if (joint_angle > 0.0)
-                {
-                    joint_angle = joint_angle - 2 * M_PI;
-                }
-                else
-                {
-                    bulge_steps = 1 + static_cast<int>(std::floor(half_turns / M_PI));
-                }
+                joint_angle = 2 * M_PI - joint_angle;
             }
-            else
+
+            int bulge_steps = 0;
+
+            if (std::abs(joint_angle) > M_PI)
             {
-                if (joint_angle < 0.0)
-                {
-                    joint_angle = joint_angle + 2 * M_PI;
-                }
-                else
-                {
-                    bulge_steps = 1 + static_cast<int>(std::floor(half_turns / M_PI));
-                }
+                curve_angle = explement_reflex_angle(angle_b - angle_a);
+                // Bulge steps should be determined by the inverse of the joint angle.
+                double half_turns = half_turn_segments_ * std::fabs(curve_angle);
+                bulge_steps = 1 + static_cast<int>(std::floor(half_turns / M_PI));
             }
 
             #ifdef MAPNIK_LOG
@@ -360,24 +530,49 @@ private:
                     << " degrees ((< with " << bulge_steps << " segments";
             }
             #endif
-
-            displace(w, v1, angle_a);
-            push_vertex(w);
-
-            for (int s = 0; ++s < bulge_steps;)
+            if (v1.cmd == SEG_MOVETO)
+            {
+                if (bulge_steps == 0)
+                {
+                    displace2(v1, angle_a, angle_b);
+                    push_vertex(v1);
+                }
+                else
+                {
+                    displace(v1, angle_b);
+                    push_vertex(v1);
+                }
+            }
+            else
             {
-                displace(w, v1, angle_a + (joint_angle * s) / bulge_steps);
-                push_vertex(w);
+                if (bulge_steps == 0)
+                {
+                    displace2(v1, angle_a, angle_b);
+                    push_vertex(v1);
+                }
+                else
+                {
+                    displace(w, v1, angle_a);
+                    w.cmd = SEG_LINETO;
+                    push_vertex(w);
+                    for (int s = 0; ++s < bulge_steps;)
+                    {
+                        displace(w, v1, angle_a + (curve_angle * s) / bulge_steps);
+                        w.cmd = SEG_LINETO;
+                        push_vertex(w);
+                    }
+                    displace(v1, angle_b);
+                    push_vertex(v1);
+                }
             }
+        }
 
+        // last vertex
+        if (!is_polygon)
+        {
             displace(v1, angle_b);
             push_vertex(v1);
         }
-
-        // last vertex
-        displace(v1, angle_b);
-        push_vertex(v1);
-
         // initialization finished
         return status_ = process;
     }
diff --git a/include/mapnik/palette.hpp b/include/mapnik/palette.hpp
index cf21338..377967a 100644
--- a/include/mapnik/palette.hpp
+++ b/include/mapnik/palette.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -30,13 +30,16 @@
 
 #define USE_DENSE_HASH_MAP
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wsign-conversion"
 #ifdef USE_DENSE_HASH_MAP
-    #include <mapnik/sparsehash/dense_hash_map>
-    using rgba_hash_table = google::dense_hash_map<unsigned int, unsigned char>;
+#include <mapnik/sparsehash/dense_hash_map>
+using rgba_hash_table = google::dense_hash_map<unsigned int, unsigned char>;
 #else
-    #include <boost/unordered_map.hpp>
-    using rgba_hash_table = boost::unordered_map<unsigned int, unsigned char>;
+#include <unordered_map>
+using rgba_hash_table = std::unordered_map<unsigned int, unsigned char>;
 #endif
+#pragma GCC diagnostic pop
 
 // stl
 #include <vector>
diff --git a/include/mapnik/params.hpp b/include/mapnik/params.hpp
index 8407667..fc59289 100644
--- a/include/mapnik/params.hpp
+++ b/include/mapnik/params.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/params_impl.hpp b/include/mapnik/params_impl.hpp
index c262cac..469a936 100644
--- a/include/mapnik/params_impl.hpp
+++ b/include/mapnik/params_impl.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -33,6 +33,9 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/optional.hpp>
 #include <boost/lexical_cast.hpp>
 #pragma GCC diagnostic pop
@@ -71,7 +74,7 @@ struct extract_value<value_bool>
             return boost::optional<value_bool>(result);
         return boost::optional<value_bool>();
     }
-    
+
     static inline boost::optional<value_bool> do_extract_from_bool(value_bool const& source)
     {
         return boost::optional<value_bool>(source);
@@ -150,7 +153,7 @@ struct extract_value<std::string>
     {
         return boost::optional<std::string>(source);
     }
-    
+
     static inline boost::optional<std::string> do_extract_from_bool(value_bool const& source)
     {
         if (source) {
@@ -188,7 +191,7 @@ struct value_extractor_visitor
         var_ = detail::param_cast<T>(val);
 
     }
-    
+
     void operator() (value_bool const& val) const
     {
         var_ = detail::param_cast<T>(val);
diff --git a/include/mapnik/parse_path.hpp b/include/mapnik/parse_path.hpp
index 0667e90..e5b5882 100644
--- a/include/mapnik/parse_path.hpp
+++ b/include/mapnik/parse_path.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/parse_transform.hpp b/include/mapnik/parse_transform.hpp
index 7baef79..68e605c 100644
--- a/include/mapnik/parse_transform.hpp
+++ b/include/mapnik/parse_transform.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/path.hpp b/include/mapnik/path.hpp
index b57fe50..6d25346 100644
--- a/include/mapnik/path.hpp
+++ b/include/mapnik/path.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -124,7 +124,7 @@ struct vertex_adapter : private util::noncopyable
 
     unsigned vertex(double* x, double* y) const
     {
-        return path_.cont_.get_vertex(itr_++,x,y);
+        return path_.cont_.get_vertex(static_cast<unsigned>(itr_++),x,y);
     }
 
     unsigned vertex(std::size_t index, double* x, double* y) const
diff --git a/include/mapnik/path_expression.hpp b/include/mapnik/path_expression.hpp
index 296348b..b3dde7d 100644
--- a/include/mapnik/path_expression.hpp
+++ b/include/mapnik/path_expression.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/path_expression_grammar.hpp b/include/mapnik/path_expression_grammar.hpp
index f39947e..04d422a 100644
--- a/include/mapnik/path_expression_grammar.hpp
+++ b/include/mapnik/path_expression_grammar.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -30,6 +30,9 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/spirit/include/qi.hpp>
 #pragma GCC diagnostic pop
 
diff --git a/include/mapnik/path_expression_grammar_impl.hpp b/include/mapnik/path_expression_grammar_impl.hpp
index 4801d20..bc2fcfb 100644
--- a/include/mapnik/path_expression_grammar_impl.hpp
+++ b/include/mapnik/path_expression_grammar_impl.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/pixel_position.hpp b/include/mapnik/pixel_position.hpp
index 40d00ac..93cdb4f 100644
--- a/include/mapnik/pixel_position.hpp
+++ b/include/mapnik/pixel_position.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/pixel_types.hpp b/include/mapnik/pixel_types.hpp
index 68e7ede..b0d6304 100644
--- a/include/mapnik/pixel_types.hpp
+++ b/include/mapnik/pixel_types.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/plugin.hpp b/include/mapnik/plugin.hpp
index 4be5f4f..a3428de 100644
--- a/include/mapnik/plugin.hpp
+++ b/include/mapnik/plugin.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/png_io.hpp b/include/mapnik/png_io.hpp
index 9a35a29..1b075b1 100644
--- a/include/mapnik/png_io.hpp
+++ b/include/mapnik/png_io.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/pool.hpp b/include/mapnik/pool.hpp
index 59e8661..ecd16eb 100644
--- a/include/mapnik/pool.hpp
+++ b/include/mapnik/pool.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -24,7 +24,7 @@
 #define MAPNIK_POOL_HPP
 
 // mapnik
-#include <mapnik/utils.hpp>
+#include <mapnik/util/singleton.hpp>
 #include <mapnik/util/noncopyable.hpp>
 
 // boost
diff --git a/include/mapnik/proj_strategy.hpp b/include/mapnik/proj_strategy.hpp
index 688e6d3..9bfd2e1 100644
--- a/include/mapnik/proj_strategy.hpp
+++ b/include/mapnik/proj_strategy.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -31,6 +31,9 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/geometry/core/coordinate_type.hpp>
 #include <boost/geometry/core/access.hpp>
 #include <boost/numeric/conversion/cast.hpp>
@@ -63,7 +66,7 @@ struct proj_strategy
         boost::geometry::set<1>(p2, static_cast<p2_type>(y));
         return true;
     }
-    
+
     template <typename P1, typename P2>
     inline P2 execute(P1 const& p1, bool & status) const
     {
@@ -92,7 +95,7 @@ struct proj_backward_strategy
         boost::geometry::set<1>(p2, static_cast<p2_type>(y));
         return true;
     }
-    
+
     template <typename P1, typename P2>
     inline P2 execute(P1 const& p1, bool & status) const
     {
diff --git a/include/mapnik/proj_transform.hpp b/include/mapnik/proj_transform.hpp
index fa27b63..3247a15 100644
--- a/include/mapnik/proj_transform.hpp
+++ b/include/mapnik/proj_transform.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/projection.hpp b/include/mapnik/projection.hpp
index 5267dd7..cb4284f 100644
--- a/include/mapnik/projection.hpp
+++ b/include/mapnik/projection.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/ptree_helpers.hpp b/include/mapnik/ptree_helpers.hpp
index fe1a1de..3062d71 100644
--- a/include/mapnik/ptree_helpers.hpp
+++ b/include/mapnik/ptree_helpers.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/quad_tree.hpp b/include/mapnik/quad_tree.hpp
index d8d4054..d46faa2 100644
--- a/include/mapnik/quad_tree.hpp
+++ b/include/mapnik/quad_tree.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -26,14 +26,7 @@
 // mapnik
 #include <mapnik/box2d.hpp>
 #include <mapnik/util/noncopyable.hpp>
-
-// boost
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#pragma GCC diagnostic ignored "-Wunused-local-typedef"
-#include <boost/ptr_container/ptr_vector.hpp>
-#pragma GCC diagnostic pop
-
+#include <mapnik/make_unique.hpp>
 // stl
 #include <algorithm>
 #include <vector>
@@ -86,17 +79,16 @@ class quad_tree : util::noncopyable
         ~node () {}
     };
 
-    using nodes_t = boost::ptr_vector<node>;
+    using nodes_t = std::vector<std::unique_ptr<node> >;
     using cont_t = typename node::cont_t;
     using node_data_iterator = typename cont_t::iterator;
 
 public:
     using iterator = typename nodes_t::iterator;
     using const_iterator = typename nodes_t::const_iterator;
-    using result_t = typename boost::ptr_vector<T,boost::view_clone_allocator>;
+    using result_t = typename std::vector<std::reference_wrapper<T> >;
     using query_iterator = typename result_t::iterator;
 
-
     explicit quad_tree(box2d<double> const& ext,
                        unsigned int max_depth = 8,
                        double ratio = 0.55)
@@ -105,8 +97,8 @@ public:
           query_result_(),
           nodes_()
     {
-        nodes_.push_back(new node(ext));
-        root_ = &nodes_[0];
+        nodes_.push_back(std::make_unique<node>(ext));
+        root_ = nodes_[0].get();
     }
 
     void insert(T data, box2d<double> const& box)
@@ -118,7 +110,7 @@ public:
     query_iterator query_in_box(box2d<double> const& box)
     {
         query_result_.clear();
-        query_node(box,query_result_,root_);
+        query_node(box, query_result_, root_);
         return query_result_.begin();
     }
 
@@ -142,8 +134,8 @@ public:
     {
         box2d<double> ext = root_->extent_;
         nodes_.clear();
-        nodes_.push_back(new node(ext));
-        root_ = &nodes_[0];
+        nodes_.push_back(std::make_unique<node>(ext));
+        root_ = nodes_[0].get();
     }
 
     box2d<double> const& extent() const
@@ -160,12 +152,9 @@ private:
             box2d<double> const& node_extent = node_->extent();
             if (box.intersects(node_extent))
             {
-                node_data_iterator i=node_->begin();
-                node_data_iterator end=node_->end();
-                while ( i!=end)
+                for (auto & n : *node_)
                 {
-                    result.push_back(&(*i));
-                    ++i;
+                    result.push_back(std::ref(n));
                 }
                 for (int k = 0; k < 4; ++k)
                 {
@@ -186,14 +175,14 @@ private:
             box2d<double> const& node_extent = n->extent();
             box2d<double> ext[4];
             split_box(node_extent,ext);
-            for (int i=0;i<4;++i)
+            for (int i = 0; i < 4; ++i)
             {
                 if (ext[i].contains(box))
                 {
                     if (!n->children_[i])
                     {
-                        nodes_.push_back(new node(ext[i]));
-                        n->children_[i]=&nodes_.back();
+                        nodes_.push_back(std::make_unique<node>(ext[i]));
+                        n->children_[i]=nodes_.back().get();
                     }
                     do_insert_data(data,box,n->children_[i],depth);
                     return;
@@ -205,8 +194,6 @@ private:
 
     void split_box(box2d<double> const& node_extent,box2d<double> * ext)
     {
-        //coord2d c=node_extent.center();
-
         double width=node_extent.width();
         double height=node_extent.height();
 
diff --git a/include/mapnik/query.hpp b/include/mapnik/query.hpp
index 4c9455e..5d5a6e7 100644
--- a/include/mapnik/query.hpp
+++ b/include/mapnik/query.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/raster.hpp b/include/mapnik/raster.hpp
index a4b26cb..311c06c 100644
--- a/include/mapnik/raster.hpp
+++ b/include/mapnik/raster.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/raster_colorizer.hpp b/include/mapnik/raster_colorizer.hpp
index 63e2d07..c1e83ab 100644
--- a/include/mapnik/raster_colorizer.hpp
+++ b/include/mapnik/raster_colorizer.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/renderer_common.hpp b/include/mapnik/renderer_common.hpp
index ab74956..2134438 100644
--- a/include/mapnik/renderer_common.hpp
+++ b/include/mapnik/renderer_common.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/renderer_common/clipping_extent.hpp b/include/mapnik/renderer_common/clipping_extent.hpp
index b8dd70b..aabacf3 100644
--- a/include/mapnik/renderer_common/clipping_extent.hpp
+++ b/include/mapnik/renderer_common/clipping_extent.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/renderer_common/pattern_alignment.hpp b/include/mapnik/renderer_common/pattern_alignment.hpp
index 53084b8..12f746d 100644
--- a/include/mapnik/renderer_common/pattern_alignment.hpp
+++ b/include/mapnik/renderer_common/pattern_alignment.hpp
@@ -51,7 +51,7 @@ struct apply_local_alignment
     }
 
     template <typename Adapter>
-    void operator() (Adapter & va)
+    void operator() (Adapter &)
     {
         // no-op
     }
diff --git a/include/mapnik/renderer_common/process_building_symbolizer.hpp b/include/mapnik/renderer_common/process_building_symbolizer.hpp
index 809d36a..6b0a94f 100644
--- a/include/mapnik/renderer_common/process_building_symbolizer.hpp
+++ b/include/mapnik/renderer_common/process_building_symbolizer.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/renderer_common/process_group_symbolizer.hpp b/include/mapnik/renderer_common/process_group_symbolizer.hpp
index c072ca5..d593b8e 100644
--- a/include/mapnik/renderer_common/process_group_symbolizer.hpp
+++ b/include/mapnik/renderer_common/process_group_symbolizer.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -47,8 +47,6 @@
 
 namespace mapnik {
 
-class proj_transform;
-struct glyph_info;
 class text_symbolizer_helper;
 
 using svg::svg_path_adapter;
@@ -95,7 +93,7 @@ struct virtual_renderer_common : private util::noncopyable
 // This should allow us to re-use as much as possible of the
 // existing symbolizer layout and rendering code while still
 // being able to interpose our own decisions about whether
-// a collision has occured or not.
+// a collision has occurred or not.
 
 // Thunk for rendering a particular instance of a point - this
 // stores all the arguments necessary to re-render this point
@@ -117,13 +115,7 @@ struct vector_marker_render_thunk  : util::noncopyable
                                composite_mode_e comp_op,
                                bool snap_to_pixels);
 
-    vector_marker_render_thunk(vector_marker_render_thunk && rhs)
-      : src_(std::move(rhs.src_)),
-        attrs_(std::move(rhs.attrs_)),
-        tr_(std::move(rhs.tr_)),
-        opacity_(std::move(rhs.opacity_)),
-        comp_op_(std::move(rhs.comp_op_)),
-        snap_to_pixels_(std::move(rhs.snap_to_pixels_)) {}
+    vector_marker_render_thunk(vector_marker_render_thunk && rhs);
 };
 
 struct raster_marker_render_thunk  : util::noncopyable
@@ -140,12 +132,7 @@ struct raster_marker_render_thunk  : util::noncopyable
                                composite_mode_e comp_op,
                                bool snap_to_pixels);
 
-    raster_marker_render_thunk(raster_marker_render_thunk && rhs)
-      : src_(rhs.src_),
-        tr_(std::move(rhs.tr_)),
-        opacity_(std::move(rhs.opacity_)),
-        comp_op_(std::move(rhs.comp_op_)),
-        snap_to_pixels_(std::move(rhs.snap_to_pixels_)) {}
+    raster_marker_render_thunk(raster_marker_render_thunk && rhs);
 };
 
 using helper_ptr = std::unique_ptr<text_symbolizer_helper>;
@@ -164,12 +151,7 @@ struct text_render_thunk : util::noncopyable
                       double opacity, composite_mode_e comp_op,
                       halo_rasterizer_enum halo_rasterizer);
 
-    text_render_thunk(text_render_thunk && rhs)
-      : helper_(std::move(rhs.helper_)),
-        placements_(std::move(rhs.placements_)),
-        opacity_(std::move(rhs.opacity_)),
-        comp_op_(std::move(rhs.comp_op_)),
-        halo_rasterizer_(std::move(rhs.halo_rasterizer_)) {}
+    text_render_thunk(text_render_thunk && rhs);
 
 };
 
@@ -229,7 +211,7 @@ void render_offset_placements(placements_list const& placements,
                               pixel_position const& offset,
                               F render_text) {
 
-    for (glyph_positions_ptr glyphs : placements)
+    for (auto const& glyphs : placements)
     {
         // move the glyphs to the correct offset
         pixel_position base_point = glyphs->get_base_point();
@@ -298,9 +280,9 @@ void render_group_symbolizer(group_symbolizer const& sym,
 
     // run feature or sub feature through the group rules & symbolizers
     // for each index value in the range
-    int start = get<value_integer>(sym, keys::start_column);
-    int end = start + get<value_integer>(sym, keys::num_columns);
-    for (int col_idx = start; col_idx < end; ++col_idx)
+    value_integer start = get<value_integer>(sym, keys::start_column);
+    value_integer end = start + get<value_integer>(sym, keys::num_columns);
+    for (value_integer col_idx = start; col_idx < end; ++col_idx)
     {
         // create sub feature with indexed column values
         feature_ptr sub_feature = feature_factory::create(sub_feature_ctx, col_idx);
@@ -313,7 +295,7 @@ void render_group_symbolizer(group_symbolizer const& sym,
                 if (col_name.size() == 1)
                 {
                     // column name is '%' by itself, so give the index as the value
-                    sub_feature->put(col_name, (value_integer)col_idx);
+                    sub_feature->put(col_name, col_idx);
                 }
                 else
                 {
@@ -359,10 +341,10 @@ void render_group_symbolizer(group_symbolizer const& sym,
                 render_thunk_extractor extractor(bounds, thunks, *sub_feature, common.vars_, prj_trans,
                                                  virtual_renderer, clipping_extent);
 
-                for (auto const& sym : *rule)
+                for (auto const& _sym : *rule)
                 {
                     // TODO: construct layout and obtain bounding box
-                    util::apply_visitor(extractor, sym);
+                    util::apply_visitor(extractor, _sym);
                 }
 
                 // add the bounding box to the layout manager
@@ -395,7 +377,7 @@ void render_group_symbolizer(group_symbolizer const& sym,
             rpt_key_expr = get<expression_ptr>(sym, keys::repeat_key);
         }
 
-        // evalute the repeat key with the matched sub feature if we have one
+        // evaluate the repeat key with the matched sub feature if we have one
         if (rpt_key_expr)
         {
             rpt_key_value = util::apply_visitor(evaluate<Feature,value_type,attributes>(*match_feature,common.vars_),
diff --git a/include/mapnik/renderer_common/process_markers_symbolizer.hpp b/include/mapnik/renderer_common/process_markers_symbolizer.hpp
index 3bc1f31..16e18ec 100644
--- a/include/mapnik/renderer_common/process_markers_symbolizer.hpp
+++ b/include/mapnik/renderer_common/process_markers_symbolizer.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -118,9 +118,9 @@ struct render_marker_symbolizer_visitor
             if (clip) // optional clip (default: true)
             {
                 geometry::geometry_types type = geometry::geometry_type(feature_.get_geometry());
-                if (type == geometry::geometry_types::Polygon)
+                if (type == geometry::geometry_types::Polygon || type == geometry::geometry_types::MultiPolygon)
                     converter.template set<clip_poly_tag>();
-                else if (type == geometry::geometry_types::LineString)
+                else if (type == geometry::geometry_types::LineString || type == geometry::geometry_types::MultiLineString)
                     converter.template set<clip_line_tag>();
             }
 
@@ -223,9 +223,9 @@ struct render_marker_symbolizer_visitor
         if (clip) // optional clip (default: true)
         {
             geometry::geometry_types type = geometry::geometry_type(feature_.get_geometry());
-            if (type == geometry::geometry_types::Polygon)
+            if (type == geometry::geometry_types::Polygon || type == geometry::geometry_types::MultiPolygon)
                 converter.template set<clip_poly_tag>();
-            else if (type == geometry::geometry_types::LineString)
+            else if (type == geometry::geometry_types::LineString || type == geometry::geometry_types::MultiLineString)
                 converter.template set<clip_line_tag>();
         }
         converter.template set<transform_tag>(); //always transform
diff --git a/include/mapnik/renderer_common/process_point_symbolizer.hpp b/include/mapnik/renderer_common/process_point_symbolizer.hpp
index 7cfe9f2..12ffba5 100644
--- a/include/mapnik/renderer_common/process_point_symbolizer.hpp
+++ b/include/mapnik/renderer_common/process_point_symbolizer.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -46,9 +46,9 @@ void render_point_symbolizer(point_symbolizer const &sym,
 {
     std::string filename = get<std::string,keys::file>(sym,feature, common.vars_);
     std::shared_ptr<mapnik::marker const> mark = filename.empty()
-       ? std::make_shared<mapnik::marker const>(std::move(mapnik::marker_rgba8()))
+       ? std::make_shared<mapnik::marker const>(mapnik::marker_rgba8())
        : marker_cache::instance().find(filename, true);
-    
+
     if (!mark->is<mapnik::marker_null>())
     {
         value_double opacity = get<value_double,keys::opacity>(sym, feature, common.vars_);
@@ -69,17 +69,25 @@ void render_point_symbolizer(point_symbolizer const &sym,
 
         mapnik::geometry::geometry<double> const& geometry = feature.get_geometry();
         mapnik::geometry::point<double> pt;
-        if (placement == CENTROID_POINT_PLACEMENT)
+        geometry::geometry_types type = geometry::geometry_type(geometry);
+        if (placement == CENTROID_POINT_PLACEMENT ||
+            type == geometry::geometry_types::Point ||
+            type == geometry::geometry_types::MultiPoint)
         {
             if (!geometry::centroid(geometry, pt)) return;
         }
-        else if (mapnik::geometry::geometry_type(geometry) == mapnik::geometry::geometry_types::Polygon)
+        else if (type == mapnik::geometry::geometry_types::Polygon)
         {
             auto const& poly = mapnik::util::get<geometry::polygon<double> >(geometry);
             geometry::polygon_vertex_adapter<double> va(poly);
             if (!label::interior_position(va ,pt.x, pt.y))
                 return;
         }
+        else
+        {
+            MAPNIK_LOG_WARN(point_symbolizer) << "TODO: unhandled geometry type for point symbolizer";
+            return;
+        }
         double x = pt.x;
         double y = pt.y;
         double z = 0;
diff --git a/include/mapnik/renderer_common/process_polygon_symbolizer.hpp b/include/mapnik/renderer_common/process_polygon_symbolizer.hpp
index 60c7810..99f1243 100644
--- a/include/mapnik/renderer_common/process_polygon_symbolizer.hpp
+++ b/include/mapnik/renderer_common/process_polygon_symbolizer.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/renderer_common/process_raster_symbolizer.hpp b/include/mapnik/renderer_common/process_raster_symbolizer.hpp
index 3ef8b19..5646785 100644
--- a/include/mapnik/renderer_common/process_raster_symbolizer.hpp
+++ b/include/mapnik/renderer_common/process_raster_symbolizer.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -53,7 +53,8 @@ struct image_dispatcher
                           double scale_x, double scale_y,
                           scaling_method_e method, double filter_factor,
                           double opacity, composite_mode_e comp_op,
-                          raster_symbolizer const& sym, feature_impl const& feature, F & composite, boost::optional<double> const& nodata)
+                          raster_symbolizer const& sym, feature_impl const& feature,
+                          F & composite, boost::optional<double> const& nodata, bool need_scaling)
         : start_x_(start_x),
           start_y_(start_y),
           width_(width),
@@ -67,25 +68,40 @@ struct image_dispatcher
         sym_(sym),
         feature_(feature),
         composite_(composite),
-        nodata_(nodata) {}
+        nodata_(nodata),
+        need_scaling_(need_scaling) {}
 
-    void operator() (image_null const& data_in) const {}  //no-op
+    void operator() (image_null const&) const {}  //no-op
     void operator() (image_rgba8 const& data_in) const
     {
-        image_rgba8 data_out(width_, height_, true, true);
-        scale_image_agg(data_out, data_in,  method_, scale_x_, scale_y_, 0.0, 0.0, filter_factor_);
-        composite_(data_out, comp_op_, opacity_, start_x_, start_y_);
+        if (need_scaling_)
+        {
+            image_rgba8 data_out(width_, height_, true, true);
+            scale_image_agg(data_out, data_in,  method_, scale_x_, scale_y_, 0.0, 0.0, filter_factor_);
+            composite_(data_out, comp_op_, opacity_, start_x_, start_y_);
+        }
+        else
+        {
+            composite_(data_in, comp_op_, opacity_, start_x_, start_y_);
+        }
     }
 
     template <typename T>
     void operator() (T const& data_in) const
     {
         using image_type = T;
-        image_type data_out(width_, height_);
-        scale_image_agg(data_out, data_in,  method_, scale_x_, scale_y_, 0.0, 0.0, filter_factor_);
         image_rgba8 dst(width_, height_);
         raster_colorizer_ptr colorizer = get<raster_colorizer_ptr>(sym_, keys::colorizer);
-        if (colorizer) colorizer->colorize(dst, data_out, nodata_, feature_);
+        if (need_scaling_)
+        {
+            image_type data_out(width_, height_);
+            scale_image_agg(data_out, data_in,  method_, scale_x_, scale_y_, 0.0, 0.0, filter_factor_);
+            if (colorizer) colorizer->colorize(dst, data_out, nodata_, feature_);
+        }
+        else
+        {
+            if (colorizer) colorizer->colorize(dst, data_in, nodata_, feature_);
+        }
         premultiply_alpha(dst);
         composite_(dst, comp_op_, opacity_, start_x_, start_y_);
     }
@@ -104,6 +120,7 @@ private:
     feature_impl const& feature_;
     composite_function & composite_;
     boost::optional<double> const& nodata_;
+    bool need_scaling_;
 };
 
 template <typename F>
@@ -135,7 +152,7 @@ struct image_warp_dispatcher
         composite_(composite),
         nodata_(nodata) {}
 
-    void operator() (image_null const& data_in) const {} //no-op
+    void operator() (image_null const&) const {} //no-op
 
     void operator() (image_rgba8 const& data_in) const
     {
@@ -231,24 +248,15 @@ void render_raster_symbolizer(raster_symbolizer const& sym,
                 double image_ratio_x = ext.width() / source->data_.width();
                 double image_ratio_y = ext.height() / source->data_.height();
                 double eps = 1e-5;
-                if ( (std::fabs(image_ratio_x - 1.0) <= eps) &&
-                     (std::fabs(image_ratio_y - 1.0) <= eps) &&
-                     (std::abs(start_x) <= eps) &&
-                     (std::abs(start_y) <= eps) )
-                {
-                    if (source->data_.is<image_rgba8>())
-                    {
-                        composite(util::get<image_rgba8>(source->data_), comp_op, opacity, start_x, start_y);
-                    }
-                }
-                else
-                {
-                    detail::image_dispatcher<F> dispatcher(start_x, start_y, raster_width, raster_height,
-                                                                image_ratio_x, image_ratio_y,
-                                                                scaling_method, source->get_filter_factor(),
-                                                                opacity, comp_op, sym, feature, composite, source->nodata());
-                    util::apply_visitor(dispatcher, source->data_);
-                }
+                bool scale = (std::fabs(image_ratio_x - 1.0) > eps) ||
+                     (std::fabs(image_ratio_y - 1.0) > eps) ||
+                     (std::abs(start_x) > eps) ||
+                     (std::abs(start_y) > eps);
+                detail::image_dispatcher<F> dispatcher(start_x, start_y, raster_width, raster_height,
+                                                            image_ratio_x, image_ratio_y,
+                                                            scaling_method, source->get_filter_factor(),
+                                                            opacity, comp_op, sym, feature, composite, source->nodata(), scale);
+                util::apply_visitor(dispatcher, source->data_);
             }
         }
     }
diff --git a/include/mapnik/renderer_common/render_pattern.hpp b/include/mapnik/renderer_common/render_pattern.hpp
index ffa3140..acb9897 100644
--- a/include/mapnik/renderer_common/render_pattern.hpp
+++ b/include/mapnik/renderer_common/render_pattern.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/request.hpp b/include/mapnik/request.hpp
index e351f57..74c0851 100644
--- a/include/mapnik/request.hpp
+++ b/include/mapnik/request.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/rule.hpp b/include/mapnik/rule.hpp
index e32210e..1c98eaf 100644
--- a/include/mapnik/rule.hpp
+++ b/include/mapnik/rule.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/rule_cache.hpp b/include/mapnik/rule_cache.hpp
index 44a3406..3d6f7d0 100644
--- a/include/mapnik/rule_cache.hpp
+++ b/include/mapnik/rule_cache.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/safe_cast.hpp b/include/mapnik/safe_cast.hpp
new file mode 100644
index 0000000..d897303
--- /dev/null
+++ b/include/mapnik/safe_cast.hpp
@@ -0,0 +1,154 @@
+/*****************************************************************************
+ *
+ * This file is part of Mapnik (c++ mapping toolkit)
+ *
+ * Copyright (C) 2015 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_SAFE_CAST_HPP
+#define MAPNIK_SAFE_CAST_HPP
+
+#include <limits>
+#include <type_traits>
+#include <cstdint>
+
+namespace mapnik {
+
+namespace detail {
+
+template<typename T, typename S, typename E = void>
+struct numeric_compare;
+
+template<typename T, typename S>
+struct numeric_compare_same_sign
+{
+    using sizeup = typename std::conditional<sizeof(T) >= sizeof(S), T, S>::type;
+
+    static inline bool less(T t, S s) {
+        return static_cast<sizeup>(t) < static_cast<sizeup>(s);
+    }
+
+    static inline bool greater(T t, S s) {
+        return static_cast<sizeup>(t) > static_cast<sizeup>(s);
+    }
+};
+
+template<typename T, typename S>
+struct numeric_compare<T,S,typename std::enable_if<!std::is_floating_point<T>::value && !std::is_floating_point<S>::value &&
+                                                   ((std::is_unsigned<T>::value && std::is_unsigned<S>::value)
+                                                    || (std::is_signed<T>::value && std::is_signed<S>::value))>
+    ::type> : numeric_compare_same_sign<T,S>
+{};
+
+
+template<typename T, typename S>
+struct numeric_compare<T,S,typename std::enable_if<!std::is_floating_point<T>::value && !std::is_floating_point<S>::value &&
+                                                   std::is_integral<T>::value && std::is_signed<T>::value && std::is_unsigned<S>::value>::type>
+{
+    static inline bool less(T t, S s) {
+        return (t < static_cast<T>(0)) ? true : static_cast<std::uint64_t>(t) < static_cast<std::uint64_t>(s);
+    }
+
+    static inline bool greater(T t, S s) {
+        return (t < static_cast<T>(0)) ? false : static_cast<std::uint64_t>(t) > static_cast<std::uint64_t>(s);
+    }
+};
+
+template<typename T, typename S>
+struct numeric_compare<T,S,typename std::enable_if<!std::is_floating_point<T>::value && !std::is_floating_point<S>::value &&
+                                                   std::is_integral<T>::value && std::is_unsigned<T>::value && std::is_signed<S>::value>::type>
+{
+    static inline bool less(T t, S s) {
+        return (s < static_cast<S>(0)) ? false : static_cast<std::uint64_t>(t) < static_cast<std::uint64_t>(s);
+    }
+
+    static inline bool greater(T t, S s) {
+        return (s < static_cast<S>(0)) ? true : static_cast<std::uint64_t>(t) > static_cast<std::uint64_t>(s);
+    }
+};
+
+template<typename T, typename S>
+struct numeric_compare<T,S,typename std::enable_if<std::is_floating_point<T>::value && std::is_floating_point<S>::value>::type>
+{
+    static inline bool less(T t, S s) {
+        return t < s;
+    }
+
+    static inline bool greater(T t, S s) {
+        return t > s;
+    }
+};
+
+template<typename T, typename S>
+struct numeric_compare<T,S,typename std::enable_if<
+        (std::is_floating_point<T>::value && std::is_integral<S>::value) ||
+        (std::is_integral<T>::value && std::is_floating_point<S>::value)>::type>
+{
+    static inline bool less(T t, S s) {
+        return numeric_compare<double,double>::less(static_cast<double>(t),static_cast<double>(s));
+    }
+
+    static inline bool greater(T t, S s) {
+        return numeric_compare<double,double>::greater(static_cast<double>(t),static_cast<double>(s));
+    }
+};
+
+// floats
+template <typename T, typename Enable = void>
+struct bounds
+{
+    static const T lowest() { return static_cast<T>(-std::numeric_limits<T>::max());}
+    static const T highest() { return std::numeric_limits<T>::max();}
+};
+
+// integers
+template <typename T>
+struct bounds<T, typename std::enable_if<std::numeric_limits<T>::is_integer>::type >
+{
+    static const T lowest() { return std::numeric_limits<T>::min();}
+    static const T highest() { return std::numeric_limits<T>::max();}
+};
+
+} // ns detail
+
+
+template <typename T, typename S>
+inline T safe_cast(S s)
+{
+    static const auto max_val = detail::bounds<T>::highest();
+    static const auto min_val = detail::bounds<T>::lowest();
+
+    if (detail::numeric_compare<S,T>::greater(s,max_val))
+    {
+        return max_val;
+    }
+    else if (detail::numeric_compare<S,T>::less(s,min_val))
+    {
+        return min_val;
+    }
+    else
+    {
+        return static_cast<T>(s);
+    }
+}
+
+} // ns mapnik
+
+
+
+#endif // MAPNIK_SAFE_CAST_HPP
diff --git a/include/mapnik/save_map.hpp b/include/mapnik/save_map.hpp
index 8945320..80317b3 100644
--- a/include/mapnik/save_map.hpp
+++ b/include/mapnik/save_map.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/scale_denominator.hpp b/include/mapnik/scale_denominator.hpp
index e4aaee9..fb09cef 100644
--- a/include/mapnik/scale_denominator.hpp
+++ b/include/mapnik/scale_denominator.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/segment.hpp b/include/mapnik/segment.hpp
index 2cf1039..4463382 100644
--- a/include/mapnik/segment.hpp
+++ b/include/mapnik/segment.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/simplify_converter.hpp b/include/mapnik/simplify_converter.hpp
index e9a88c4..e217eba 100644
--- a/include/mapnik/simplify_converter.hpp
+++ b/include/mapnik/simplify_converter.hpp
@@ -90,7 +90,7 @@ struct sleeve
 };
 
 template <typename Geometry>
-struct MAPNIK_DECL simplify_converter
+struct simplify_converter
 {
 public:
     simplify_converter(Geometry & geom)
diff --git a/include/mapnik/span_image_filter.hpp b/include/mapnik/span_image_filter.hpp
index c84ee04..d99c21a 100644
--- a/include/mapnik/span_image_filter.hpp
+++ b/include/mapnik/span_image_filter.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/sql_utils.hpp b/include/mapnik/sql_utils.hpp
index f45af6c..d90a55f 100644
--- a/include/mapnik/sql_utils.hpp
+++ b/include/mapnik/sql_utils.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -30,6 +30,9 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/algorithm/string/replace.hpp>
 #pragma GCC diagnostic pop
 
diff --git a/include/mapnik/sse.hpp b/include/mapnik/sse.hpp
index d68684c..603af7c 100644
--- a/include/mapnik/sse.hpp
+++ b/include/mapnik/sse.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -28,7 +28,7 @@
 
 #define ROUND_DOWN(x, s) ((x) & ~((s)-1))
 
-typedef union 
+typedef union
 {
     __m128i v;
     int32_t i32[4];
diff --git a/include/mapnik/svg/geometry_svg_generator.hpp b/include/mapnik/svg/geometry_svg_generator.hpp
index 1aa056e..e70166f 100644
--- a/include/mapnik/svg/geometry_svg_generator.hpp
+++ b/include/mapnik/svg/geometry_svg_generator.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -37,6 +37,9 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/spirit/include/karma.hpp>
 #include <boost/spirit/include/phoenix_core.hpp>
 #include <boost/spirit/include/phoenix_operator.hpp>
diff --git a/include/mapnik/svg/geometry_svg_generator_impl.hpp b/include/mapnik/svg/geometry_svg_generator_impl.hpp
index 4424fbe..57df89f 100644
--- a/include/mapnik/svg/geometry_svg_generator_impl.hpp
+++ b/include/mapnik/svg/geometry_svg_generator_impl.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/svg/output/svg_generator.hpp b/include/mapnik/svg/output/svg_generator.hpp
index 42c4bb4..1b3f18d 100644
--- a/include/mapnik/svg/output/svg_generator.hpp
+++ b/include/mapnik/svg/output/svg_generator.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/svg/output/svg_output_attributes.hpp b/include/mapnik/svg/output/svg_output_attributes.hpp
index 1de9769..00deeea 100644
--- a/include/mapnik/svg/output/svg_output_attributes.hpp
+++ b/include/mapnik/svg/output/svg_output_attributes.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/svg/output/svg_output_grammars.hpp b/include/mapnik/svg/output/svg_output_grammars.hpp
index f3ef886..3a47e43 100644
--- a/include/mapnik/svg/output/svg_output_grammars.hpp
+++ b/include/mapnik/svg/output/svg_output_grammars.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -40,6 +40,9 @@ namespace mapnik { namespace svg {
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/spirit/include/karma_nonterminal.hpp>
 #include <boost/spirit/include/karma_rule.hpp>
 #include <boost/fusion/adapted/struct.hpp>
diff --git a/include/mapnik/svg/output/svg_output_grammars_impl.hpp b/include/mapnik/svg/output/svg_output_grammars_impl.hpp
index 892fdf9..41f6928 100644
--- a/include/mapnik/svg/output/svg_output_grammars_impl.hpp
+++ b/include/mapnik/svg/output/svg_output_grammars_impl.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -30,6 +30,9 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/spirit/include/karma.hpp>
 #include <boost/fusion/include/std_pair.hpp>
 #pragma GCC diagnostic pop
diff --git a/include/mapnik/svg/output/svg_path_iterator.hpp b/include/mapnik/svg/output/svg_path_iterator.hpp
index a56a175..b773888 100644
--- a/include/mapnik/svg/output/svg_path_iterator.hpp
+++ b/include/mapnik/svg/output/svg_path_iterator.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/svg/output/svg_renderer.hpp b/include/mapnik/svg/output/svg_renderer.hpp
index fe4fc65..037ec0d 100644
--- a/include/mapnik/svg/output/svg_renderer.hpp
+++ b/include/mapnik/svg/output/svg_renderer.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/svg/svg_converter.hpp b/include/mapnik/svg/svg_converter.hpp
index ddde41d..0066a1f 100644
--- a/include/mapnik/svg/svg_converter.hpp
+++ b/include/mapnik/svg/svg_converter.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -27,6 +27,7 @@
 #include <mapnik/svg/svg_path_attributes.hpp>
 #include <mapnik/svg/svg_path_adapter.hpp>
 #include <mapnik/util/noncopyable.hpp>
+#include <mapnik/safe_cast.hpp>
 
 // agg
 #include "agg_path_storage.h"
@@ -57,8 +58,8 @@ public:
 
     void begin_path()
     {
-        unsigned idx = source_.start_new_path();
-        attributes_.add(path_attributes(cur_attr(), idx));
+        std::size_t idx = source_.start_new_path();
+        attributes_.add(path_attributes(cur_attr(), safe_cast<unsigned>(idx)));
     }
 
     void end_path()
@@ -91,7 +92,7 @@ public:
         double y2 = 0.0;
         if(source_.total_vertices())
         {
-            source_.vertex(source_.total_vertices() - 1, &x2, &y2);
+            source_.vertex(safe_cast<unsigned>(source_.total_vertices() - 1), &x2, &y2);
             if(rel) x += x2;
             source_.line_to(x, y2);
         }
@@ -103,7 +104,7 @@ public:
         double y2 = 0.0;
         if(source_.total_vertices())
         {
-            source_.vertex(source_.total_vertices() - 1, &x2, &y2);
+            source_.vertex(safe_cast<unsigned>(source_.total_vertices() - 1), &x2, &y2);
             if(rel) y += y2;
             source_.line_to(x2, y);
         }
diff --git a/include/mapnik/svg/svg_parser.hpp b/include/mapnik/svg/svg_parser.hpp
index 5198bfd..ef9eafc 100644
--- a/include/mapnik/svg/svg_parser.hpp
+++ b/include/mapnik/svg/svg_parser.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -24,6 +24,7 @@
 #define MAPNIK_SVG_PARSER_HPP
 
 // mapnik
+#include <mapnik/config.hpp>
 #include <mapnik/svg/svg_path_attributes.hpp>
 #include <mapnik/svg/svg_converter.hpp>
 #include <mapnik/svg/svg_path_adapter.hpp>
@@ -35,7 +36,7 @@
 
 namespace  mapnik { namespace svg {
 
-    class svg_parser : private util::noncopyable
+    class MAPNIK_DECL svg_parser : private util::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 72fa29a..9577171 100644
--- a/include/mapnik/svg/svg_path_adapter.hpp
+++ b/include/mapnik/svg/svg_path_adapter.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -26,6 +26,8 @@
 // mapnik
 #include <mapnik/util/noncopyable.hpp>
 #include <mapnik/box2d.hpp>
+#include <mapnik/safe_cast.hpp>
+
 // agg
 #include "agg_math.h"
 #include "agg_array.h"
@@ -53,7 +55,7 @@ public:
 
     // Make path functions
     //--------------------------------------------------------------------
-    unsigned start_new_path();
+    std::size_t start_new_path();
 
     void move_to(double x, double y);
     void move_rel(double dx, double dy);
@@ -112,7 +114,7 @@ public:
     const container_type& vertices() const { return vertices_; }
     container_type& vertices()       { return vertices_; }
 
-    unsigned total_vertices() const;
+    std::size_t total_vertices() const;
 
     void rel_to_abs(double* x, double* y) const;
 
@@ -263,7 +265,7 @@ private:
 
 //------------------------------------------------------------------------
 template<class VC>
-unsigned path_adapter<VC>::start_new_path()
+std::size_t path_adapter<VC>::start_new_path()
 {
     if(!is_stop(vertices_.last_command()))
     {
@@ -547,7 +549,7 @@ inline void path_adapter<VC>::close_polygon(unsigned flags)
 
 //------------------------------------------------------------------------
 template<class VC>
-inline unsigned path_adapter<VC>::total_vertices() const
+inline std::size_t path_adapter<VC>::total_vertices() const
 {
     return vertices_.total_vertices();
 }
@@ -886,7 +888,7 @@ public:
     {
         return vertices_.size() ?
             vertices_[vertices_.size() - 1].cmd :
-            (unsigned)path_cmd_stop;
+            path_cmd_stop;
     }
 
     unsigned last_vertex(double* x, double* y) const
@@ -896,7 +898,7 @@ public:
             *x = *y = 0.0;
             return path_cmd_stop;
         }
-        return vertex(vertices_.size() - 1, x, y);
+        return vertex(safe_cast<unsigned>(vertices_.size() - 1), x, y);
     }
 
     unsigned prev_vertex(double* x, double* y) const
@@ -906,7 +908,7 @@ public:
             *x = *y = 0.0;
             return path_cmd_stop;
         }
-        return vertex(vertices_.size() - 2, x, y);
+        return vertex(safe_cast<unsigned>(vertices_.size() - 2), x, y);
     }
 
     double last_x() const
diff --git a/include/mapnik/svg/svg_path_attributes.hpp b/include/mapnik/svg/svg_path_attributes.hpp
index 29194ba..7e180fd 100644
--- a/include/mapnik/svg/svg_path_attributes.hpp
+++ b/include/mapnik/svg/svg_path_attributes.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/svg/svg_path_commands.hpp b/include/mapnik/svg/svg_path_commands.hpp
index 905f262..105b4ca 100644
--- a/include/mapnik/svg/svg_path_commands.hpp
+++ b/include/mapnik/svg/svg_path_commands.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -30,6 +30,9 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/spirit/include/qi.hpp>
 #include <boost/spirit/include/phoenix_function.hpp>
 #include <boost/spirit/include/phoenix_core.hpp>
diff --git a/include/mapnik/svg/svg_path_grammar.hpp b/include/mapnik/svg/svg_path_grammar.hpp
index 1710b61..431bf0a 100644
--- a/include/mapnik/svg/svg_path_grammar.hpp
+++ b/include/mapnik/svg/svg_path_grammar.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/svg/svg_path_parser.hpp b/include/mapnik/svg/svg_path_parser.hpp
index e72ad1a..35303f9 100644
--- a/include/mapnik/svg/svg_path_parser.hpp
+++ b/include/mapnik/svg/svg_path_parser.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/svg/svg_points_grammar.hpp b/include/mapnik/svg/svg_points_grammar.hpp
index e993d35..dbaed84 100644
--- a/include/mapnik/svg/svg_points_grammar.hpp
+++ b/include/mapnik/svg/svg_points_grammar.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/svg/svg_renderer_agg.hpp b/include/mapnik/svg/svg_renderer_agg.hpp
index 569f3fa..ad24cb9 100644
--- a/include/mapnik/svg/svg_renderer_agg.hpp
+++ b/include/mapnik/svg/svg_renderer_agg.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -27,10 +27,16 @@
 #include <mapnik/svg/svg_path_attributes.hpp>
 #include <mapnik/gradient.hpp>
 #include <mapnik/box2d.hpp>
+#include <mapnik/value_types.hpp>
 #include <mapnik/util/noncopyable.hpp>
 
 #if defined(GRID_RENDERER)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <mapnik/grid/grid_pixel.hpp>
+#pragma GCC diagnostic pop
 #endif
 
 // agg
@@ -341,7 +347,7 @@ public:
     void render_id(Rasterizer& ras,
                    Scanline& sl,
                    Renderer& ren,
-                   int feature_id,
+                   mapnik::value_integer feature_id,
                    agg::trans_affine const& mtx,
                    double /*opacity*/,
                    box2d<double> const& /*symbol_bbox*/)
diff --git a/include/mapnik/svg/svg_storage.hpp b/include/mapnik/svg/svg_storage.hpp
index c3618b6..c360ecf 100644
--- a/include/mapnik/svg/svg_storage.hpp
+++ b/include/mapnik/svg/svg_storage.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/svg/svg_transform_grammar.hpp b/include/mapnik/svg/svg_transform_grammar.hpp
index ce5563d..e0f5231 100644
--- a/include/mapnik/svg/svg_transform_grammar.hpp
+++ b/include/mapnik/svg/svg_transform_grammar.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -33,6 +33,9 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/spirit/include/qi.hpp>
 #include <boost/spirit/include/phoenix_function.hpp>
 #include <boost/spirit/include/phoenix_core.hpp>
diff --git a/include/mapnik/symbolizer.hpp b/include/mapnik/symbolizer.hpp
index 8a4745a..40283b9 100644
--- a/include/mapnik/symbolizer.hpp
+++ b/include/mapnik/symbolizer.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/symbolizer_base.hpp b/include/mapnik/symbolizer_base.hpp
index 39a78a2..f960752 100644
--- a/include/mapnik/symbolizer_base.hpp
+++ b/include/mapnik/symbolizer_base.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/symbolizer_default_values.hpp b/include/mapnik/symbolizer_default_values.hpp
index c793acb..b70ea19 100644
--- a/include/mapnik/symbolizer_default_values.hpp
+++ b/include/mapnik/symbolizer_default_values.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/symbolizer_dispatch.hpp b/include/mapnik/symbolizer_dispatch.hpp
index 213a388..52f65bc 100644
--- a/include/mapnik/symbolizer_dispatch.hpp
+++ b/include/mapnik/symbolizer_dispatch.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -100,9 +100,7 @@ template<typename T0,typename T1>
 struct has_process
 {
     using processor_impl_type = typename T0::processor_impl_type;
-    BOOST_STATIC_CONSTANT(bool
-                          , value = sizeof(has_process_helper<processor_impl_type,T1>(0)) == sizeof(yes_tag)
-        );
+    constexpr static bool value = (sizeof(has_process_helper<processor_impl_type,T1>(0)) == sizeof(yes_tag));
 };
 
 }
diff --git a/include/mapnik/symbolizer_enumerations.hpp b/include/mapnik/symbolizer_enumerations.hpp
index 09ec17d..7a3e72f 100644
--- a/include/mapnik/symbolizer_enumerations.hpp
+++ b/include/mapnik/symbolizer_enumerations.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/symbolizer_hash.hpp b/include/mapnik/symbolizer_hash.hpp
index feadf02..9c2baa4 100644
--- a/include/mapnik/symbolizer_hash.hpp
+++ b/include/mapnik/symbolizer_hash.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/symbolizer_keys.hpp b/include/mapnik/symbolizer_keys.hpp
index ec8649d..15919dc 100644
--- a/include/mapnik/symbolizer_keys.hpp
+++ b/include/mapnik/symbolizer_keys.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/symbolizer_utils.hpp b/include/mapnik/symbolizer_utils.hpp
index 00a4f02..358628b 100644
--- a/include/mapnik/symbolizer_utils.hpp
+++ b/include/mapnik/symbolizer_utils.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -461,8 +461,8 @@ struct set_symbolizer_property_impl<Symbolizer, T, true>
                     auto result = pre_evaluate_expression<value>(*val);
                     if (std::get<1>(result))
                     {
-                        boost::optional<value_type> enum_val = detail::enum_traits<value_type>::from_string(std::get<0>(result).to_string());
-                        if (enum_val)
+                        boost::optional<value_type> enum_val2 = detail::enum_traits<value_type>::from_string(std::get<0>(result).to_string());
+                        if (enum_val2)
                         {
                             put(sym, key, *enum_val);
                         }
diff --git a/include/mapnik/text/evaluated_format_properties_ptr.hpp b/include/mapnik/text/evaluated_format_properties_ptr.hpp
index 8ead5f6..4728651 100644
--- a/include/mapnik/text/evaluated_format_properties_ptr.hpp
+++ b/include/mapnik/text/evaluated_format_properties_ptr.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/text/face.hpp b/include/mapnik/text/face.hpp
index 31dd45a..9c50beb 100644
--- a/include/mapnik/text/face.hpp
+++ b/include/mapnik/text/face.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -87,7 +87,7 @@ public:
     void set_character_sizes(double size);
     void set_unscaled_character_sizes();
 
-    unsigned size() const { return faces_.size(); }
+    std::size_t size() const { return faces_.size(); }
     iterator begin() { return faces_.begin(); }
     iterator end() { return faces_.end(); }
 private:
diff --git a/include/mapnik/text/font_feature_settings.hpp b/include/mapnik/text/font_feature_settings.hpp
index 9fd6259..9d945fb 100644
--- a/include/mapnik/text/font_feature_settings.hpp
+++ b/include/mapnik/text/font_feature_settings.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/text/font_library.hpp b/include/mapnik/text/font_library.hpp
index fc5959a..163aad3 100644
--- a/include/mapnik/text/font_library.hpp
+++ b/include/mapnik/text/font_library.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/text/formatting/base.hpp b/include/mapnik/text/formatting/base.hpp
index efda3d6..da47d5d 100644
--- a/include/mapnik/text/formatting/base.hpp
+++ b/include/mapnik/text/formatting/base.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/text/formatting/format.hpp b/include/mapnik/text/formatting/format.hpp
index 3725986..c540abd 100644
--- a/include/mapnik/text/formatting/format.hpp
+++ b/include/mapnik/text/formatting/format.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/text/formatting/layout.hpp b/include/mapnik/text/formatting/layout.hpp
index 1ea1810..dd7f4b0 100644
--- a/include/mapnik/text/formatting/layout.hpp
+++ b/include/mapnik/text/formatting/layout.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/text/formatting/list.hpp b/include/mapnik/text/formatting/list.hpp
index 79314cf..45c4217 100644
--- a/include/mapnik/text/formatting/list.hpp
+++ b/include/mapnik/text/formatting/list.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/text/formatting/registry.hpp b/include/mapnik/text/formatting/registry.hpp
index 5ad22dd..7328d2b 100644
--- a/include/mapnik/text/formatting/registry.hpp
+++ b/include/mapnik/text/formatting/registry.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -23,7 +23,7 @@
 #define FORMATTING_REGISTRY_HPP
 
 // mapnik
-#include <mapnik/utils.hpp>
+#include <mapnik/util/singleton.hpp>
 #include <mapnik/text/formatting/base.hpp>
 #include <mapnik/text/text_properties.hpp>
 #include <mapnik/util/noncopyable.hpp>
diff --git a/include/mapnik/text/formatting/text.hpp b/include/mapnik/text/formatting/text.hpp
index 214b3cf..0122885 100644
--- a/include/mapnik/text/formatting/text.hpp
+++ b/include/mapnik/text/formatting/text.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/text/glyph_info.hpp b/include/mapnik/text/glyph_info.hpp
index 4b82ffb..3950f9d 100644
--- a/include/mapnik/text/glyph_info.hpp
+++ b/include/mapnik/text/glyph_info.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/text/glyph_positions.hpp b/include/mapnik/text/glyph_positions.hpp
index c75cea3..604de8c 100644
--- a/include/mapnik/text/glyph_positions.hpp
+++ b/include/mapnik/text/glyph_positions.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -82,7 +82,6 @@ public:
     void set_marker(marker_info_ptr marker, pixel_position const& marker_pos);
     marker_info_ptr get_marker() const;
     pixel_position const& marker_pos() const;
-    box2d<double> const & bbox() const;
 private:
     std::vector<glyph_position> data_;
     pixel_position base_point_;
@@ -90,7 +89,7 @@ private:
     pixel_position marker_pos_;
     box2d<double> bbox_;
 };
-using glyph_positions_ptr = std::shared_ptr<glyph_positions>;
+using glyph_positions_ptr = std::unique_ptr<glyph_positions>;
 
 using placements_list = std::list<glyph_positions_ptr>;
 }
diff --git a/include/mapnik/text/harfbuzz_shaper.hpp b/include/mapnik/text/harfbuzz_shaper.hpp
index 8bb37b1..8c4b830 100644
--- a/include/mapnik/text/harfbuzz_shaper.hpp
+++ b/include/mapnik/text/harfbuzz_shaper.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -28,6 +28,7 @@
 #include <mapnik/text/text_line.hpp>
 #include <mapnik/text/face.hpp>
 #include <mapnik/text/font_feature_settings.hpp>
+#include <mapnik/safe_cast.hpp>
 
 // stl
 #include <list>
@@ -66,7 +67,7 @@ static void shape_text(text_line & line,
 {
     unsigned start = line.first_char();
     unsigned end = line.last_char();
-    size_t length = end - start;
+    std::size_t length = end - start;
     if (!length) return;
 
     std::list<text_item> const& list = itemizer.itemize(start, end);
@@ -75,7 +76,7 @@ static void shape_text(text_line & line,
 
     auto hb_buffer_deleter = [](hb_buffer_t * buffer) { hb_buffer_destroy(buffer);};
     const std::unique_ptr<hb_buffer_t, decltype(hb_buffer_deleter)> buffer(hb_buffer_create(),hb_buffer_deleter);
-    hb_buffer_pre_allocate(buffer.get(), length);
+    hb_buffer_pre_allocate(buffer.get(), safe_cast<int>(length));
     mapnik::value_unicode_string const& text = itemizer.text();
 
     for (auto const& text_item : list)
@@ -86,15 +87,16 @@ static void shape_text(text_line & line,
         std::size_t num_faces = face_set->size();
         std::size_t pos = 0;
         font_feature_settings const& ff_settings = text_item.format_->ff_settings;
+        int ff_count = safe_cast<int>(ff_settings.count());
         for (auto const& face : *face_set)
         {
             ++pos;
             hb_buffer_clear_contents(buffer.get());
-            hb_buffer_add_utf16(buffer.get(), uchar_to_utf16(text.getBuffer()), text.length(), text_item.start, text_item.end - text_item.start);
+            hb_buffer_add_utf16(buffer.get(), uchar_to_utf16(text.getBuffer()), text.length(), text_item.start, static_cast<int>(text_item.end - text_item.start));
             hb_buffer_set_direction(buffer.get(), (text_item.dir == UBIDI_RTL)?HB_DIRECTION_RTL:HB_DIRECTION_LTR);
             hb_buffer_set_script(buffer.get(), _icu_script_to_script(text_item.script));
             hb_font_t *font(hb_ft_font_create(face->get_face(), nullptr));
-            hb_shape(font, buffer.get(), ff_settings.get_features(), ff_settings.count());
+            hb_shape(font, buffer.get(), ff_settings.get_features(), ff_count);
             hb_font_destroy(font);
 
             unsigned num_glyphs = hb_buffer_get_length(buffer.get());
@@ -121,7 +123,7 @@ static void shape_text(text_line & line,
             double max_glyph_height = 0;
             for (unsigned i=0; i<num_glyphs; ++i)
             {
-                auto const& pos = positions[i];
+                auto const& gpos = positions[i];
                 auto const& glyph = glyphs[i];
                 unsigned char_index = glyph.cluster;
                 glyph_info g(glyph.codepoint,char_index,text_item.format_);
@@ -130,8 +132,8 @@ static void shape_text(text_line & line,
                     g.face = face;
                     g.scale_multiplier = size / face->get_face()->units_per_EM;
                     //Overwrite default advance with better value provided by HarfBuzz
-                    g.unscaled_advance = pos.x_advance;
-                    g.offset.set(pos.x_offset * g.scale_multiplier, pos.y_offset * g.scale_multiplier);
+                    g.unscaled_advance = gpos.x_advance;
+                    g.offset.set(gpos.x_offset * g.scale_multiplier, gpos.y_offset * g.scale_multiplier);
                     double tmp_height = g.height();
                     if (tmp_height > max_glyph_height) max_glyph_height = tmp_height;
                     width_map[char_index] += g.advance();
diff --git a/include/mapnik/text/icu_shaper.hpp b/include/mapnik/text/icu_shaper.hpp
index e672eaa..dedeafd 100644
--- a/include/mapnik/text/icu_shaper.hpp
+++ b/include/mapnik/text/icu_shaper.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/text/itemizer.hpp b/include/mapnik/text/itemizer.hpp
index 0b28bc3..fe036ad 100644
--- a/include/mapnik/text/itemizer.hpp
+++ b/include/mapnik/text/itemizer.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -86,8 +86,8 @@ public:
 private:
     template<typename T> struct run : util::noncopyable
     {
-        run(T const& data, unsigned start, unsigned end)
-            :  start(start), end(end), data(data) {}
+        run(T const& _data, unsigned _start, unsigned _end)
+            :  start(_start), end(_end), data(_data) {}
         unsigned start;
         unsigned end;
         T data;
diff --git a/include/mapnik/text/placement_finder.hpp b/include/mapnik/text/placement_finder.hpp
index 9a6c439..f2bd36d 100644
--- a/include/mapnik/text/placement_finder.hpp
+++ b/include/mapnik/text/placement_finder.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -75,7 +75,7 @@ private:
     // Checks for collision.
     bool collision(box2d<double> const& box, const value_unicode_string &repeat_key, bool line_placement) const;
     // Adds marker to glyph_positions and to collision detector. Returns false if there is a collision.
-    bool add_marker(glyph_positions_ptr glyphs, pixel_position const& pos) const;
+    bool add_marker(glyph_positions_ptr & glyphs, pixel_position const& pos) const;
     // Maps upright==auto, left-only and right-only to left,right to simplify processing.
     // angle = angle of at start of line (to estimate best option for upright==auto)
     text_upright_e simplify_upright(text_upright_e upright, double angle) const;
@@ -99,8 +99,8 @@ private:
     box2d<double> marker_box_;
     bool marker_unlocked_;
     pixel_position marker_displacement_;
-    double move_dx_ = 0.0;
-    horizontal_alignment_e horizontal_alignment_ = H_LEFT;
+    double move_dx_;
+    horizontal_alignment_e horizontal_alignment_;
 };
 
 }//ns mapnik
diff --git a/include/mapnik/text/placement_finder_impl.hpp b/include/mapnik/text/placement_finder_impl.hpp
index 9bf7256..7392389 100644
--- a/include/mapnik/text/placement_finder_impl.hpp
+++ b/include/mapnik/text/placement_finder_impl.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/text/placements/base.hpp b/include/mapnik/text/placements/base.hpp
index 06c6cce..f83a547 100644
--- a/include/mapnik/text/placements/base.hpp
+++ b/include/mapnik/text/placements/base.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/text/placements/dummy.hpp b/include/mapnik/text/placements/dummy.hpp
index 18d81fe..036c5bd 100644
--- a/include/mapnik/text/placements/dummy.hpp
+++ b/include/mapnik/text/placements/dummy.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/text/placements/list.hpp b/include/mapnik/text/placements/list.hpp
index 1fa4c87..c21a4d8 100644
--- a/include/mapnik/text/placements/list.hpp
+++ b/include/mapnik/text/placements/list.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -38,7 +38,7 @@ public:
     virtual void add_expressions(expression_set & output) const;
     text_symbolizer_properties & add();
     text_symbolizer_properties & get(unsigned i);
-    unsigned size() const;
+    std::size_t size() const;
     static text_placements_ptr from_xml(xml_node const& xml, fontset_map const& fontsets, bool is_shield);
 private:
     std::vector<text_symbolizer_properties> list_;
diff --git a/include/mapnik/text/placements/registry.hpp b/include/mapnik/text/placements/registry.hpp
index eadfdb3..f8d8aef 100644
--- a/include/mapnik/text/placements/registry.hpp
+++ b/include/mapnik/text/placements/registry.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -23,7 +23,7 @@
 #define PLACEMENTS_REGISTRY_HPP
 
 // mapnik
-#include <mapnik/utils.hpp>
+#include <mapnik/util/singleton.hpp>
 #include <mapnik/text/placements/base.hpp>
 #include <mapnik/util/noncopyable.hpp>
 
diff --git a/include/mapnik/text/placements/simple.hpp b/include/mapnik/text/placements/simple.hpp
index 2a9b983..a489bea 100644
--- a/include/mapnik/text/placements/simple.hpp
+++ b/include/mapnik/text/placements/simple.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/text/properties_util.hpp b/include/mapnik/text/properties_util.hpp
index a28a23f..0fff84e 100644
--- a/include/mapnik/text/properties_util.hpp
+++ b/include/mapnik/text/properties_util.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/text/renderer.hpp b/include/mapnik/text/renderer.hpp
index ac8bcb4..a0b521d 100644
--- a/include/mapnik/text/renderer.hpp
+++ b/include/mapnik/text/renderer.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/text/scrptrun.hpp b/include/mapnik/text/scrptrun.hpp
index c8acec6..e4c607f 100644
--- a/include/mapnik/text/scrptrun.hpp
+++ b/include/mapnik/text/scrptrun.hpp
@@ -23,15 +23,15 @@
 
 struct ScriptRecord
 {
-    UChar32 startChar;
-    UChar32 endChar;
-    UScriptCode scriptCode;
+    UChar32 startChar = 0;
+    UChar32 endChar = 0;
+    UScriptCode scriptCode = USCRIPT_INVALID_CODE;
 };
 
 struct ParenStackEntry
 {
-    int32_t pairIndex;
-    UScriptCode scriptCode;
+    int32_t pairIndex = 0;
+    UScriptCode scriptCode = USCRIPT_INVALID_CODE;
 };
 
 class ScriptRun : public UObject {
diff --git a/include/mapnik/text/symbolizer_helpers.hpp b/include/mapnik/text/symbolizer_helpers.hpp
index ce31a04..714d566 100644
--- a/include/mapnik/text/symbolizer_helpers.hpp
+++ b/include/mapnik/text/symbolizer_helpers.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -90,7 +90,7 @@ protected:
     view_transform const& t_;
     box2d<double> dims_;
     box2d<double> const& query_extent_;
-    float scale_factor_;
+    double scale_factor_;
 
     //Processing
     // Remaining geometries to be processed.
diff --git a/include/mapnik/text/text_layout.hpp b/include/mapnik/text/text_layout.hpp
index 360c518..2e59cdc 100644
--- a/include/mapnik/text/text_layout.hpp
+++ b/include/mapnik/text/text_layout.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/text/text_line.hpp b/include/mapnik/text/text_line.hpp
index dd3cfee..1bd02db 100644
--- a/include/mapnik/text/text_line.hpp
+++ b/include/mapnik/text/text_line.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/text/text_properties.hpp b/include/mapnik/text/text_properties.hpp
index 90711a4..654921e 100644
--- a/include/mapnik/text/text_properties.hpp
+++ b/include/mapnik/text/text_properties.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/tiff_io.hpp b/include/mapnik/tiff_io.hpp
index fd3a753..df2b25a 100644
--- a/include/mapnik/tiff_io.hpp
+++ b/include/mapnik/tiff_io.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/timer.hpp b/include/mapnik/timer.hpp
index 22a67a3..8111ff6 100644
--- a/include/mapnik/timer.hpp
+++ b/include/mapnik/timer.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/tolerance_iterator.hpp b/include/mapnik/tolerance_iterator.hpp
index 041cb11..2b9512c 100644
--- a/include/mapnik/tolerance_iterator.hpp
+++ b/include/mapnik/tolerance_iterator.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/transform_expression.hpp b/include/mapnik/transform_expression.hpp
index d73554b..9714b1e 100644
--- a/include/mapnik/transform_expression.hpp
+++ b/include/mapnik/transform_expression.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -53,9 +53,6 @@ struct matrix_node
     expr_node e_;
     expr_node f_;
 
-    explicit matrix_node(double const* m)
-        : a_(m[0]), b_(m[1]), c_(m[2]), d_(m[3]), e_(m[4]), f_(m[5]) {}
-
     template <typename T>
     explicit matrix_node(T const& m)
         : a_(m.sx), b_(m.shy), c_(m.shx), d_(m.sy), e_(m.tx), f_(m.ty) {}
diff --git a/include/mapnik/transform_expression_grammar.hpp b/include/mapnik/transform_expression_grammar.hpp
index 6772c80..f3945f3 100644
--- a/include/mapnik/transform_expression_grammar.hpp
+++ b/include/mapnik/transform_expression_grammar.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/transform_expression_grammar_impl.hpp b/include/mapnik/transform_expression_grammar_impl.hpp
index 59ca57a..f72126e 100644
--- a/include/mapnik/transform_expression_grammar_impl.hpp
+++ b/include/mapnik/transform_expression_grammar_impl.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/transform_path_adapter.hpp b/include/mapnik/transform_path_adapter.hpp
index bf056a1..cb68e91 100644
--- a/include/mapnik/transform_path_adapter.hpp
+++ b/include/mapnik/transform_path_adapter.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/transform_processor.hpp b/include/mapnik/transform_processor.hpp
index 58f7e7c..fd45ecc 100644
--- a/include/mapnik/transform_processor.hpp
+++ b/include/mapnik/transform_processor.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/unicode.hpp b/include/mapnik/unicode.hpp
index 89526f5..59401ab 100644
--- a/include/mapnik/unicode.hpp
+++ b/include/mapnik/unicode.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/util/const_rendering_buffer.hpp b/include/mapnik/util/const_rendering_buffer.hpp
new file mode 100644
index 0000000..360eea5
--- /dev/null
+++ b/include/mapnik/util/const_rendering_buffer.hpp
@@ -0,0 +1,58 @@
+/*****************************************************************************
+ *
+ * This file is part of Mapnik (c++ mapping toolkit)
+ *
+ * Copyright (C) 2015 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_CONST_RENDERING_BUFFER_HPP
+#define MAPNIK_CONST_RENDERING_BUFFER_HPP
+
+#include <mapnik/safe_cast.hpp>
+
+#include "agg_basics.h"
+
+#include <cstdint>
+
+namespace mapnik { namespace util {
+
+// non-mutable rendering_buffer implementation
+template <typename T>
+struct rendering_buffer
+{
+    using image_type = T;
+    using pixel_type = typename image_type::pixel_type;
+    using row_data = agg::const_row_info<uint8_t>;
+
+    rendering_buffer(T const& data)
+        : data_(data) {}
+
+    uint8_t const* buf() const { return data_.bytes(); }
+    std::size_t width() const { return data_.width();}
+    std::size_t height() const { return data_.height();}
+    int stride() const { return data_.row_size();}
+    uint8_t const* row_ptr(int, int y, unsigned) {return row_ptr(y);}
+    uint8_t const* row_ptr(int y) const { return reinterpret_cast<std::uint8_t const*>(data_.get_row(static_cast<std::size_t>(y))); }
+    row_data row (int y) const { return row_data(0, safe_cast<int>(data_.width() - 1), row_ptr(y)); }
+    image_type const& data_;
+};
+
+
+}}
+
+#endif // MAPNIK_CONST_RENDERING_BUFFER_HPP
\ No newline at end of file
diff --git a/include/mapnik/util/container_adapter.hpp b/include/mapnik/util/container_adapter.hpp
index 5ebf09b..e07d709 100644
--- a/include/mapnik/util/container_adapter.hpp
+++ b/include/mapnik/util/container_adapter.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -31,6 +31,9 @@
 // boost
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/spirit/include/support_container.hpp>
 #pragma GCC diagnostic pop
 
diff --git a/include/mapnik/util/conversions.hpp b/include/mapnik/util/conversions.hpp
index bf59b25..284d20e 100644
--- a/include/mapnik/util/conversions.hpp
+++ b/include/mapnik/util/conversions.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/util/dasharray_parser.hpp b/include/mapnik/util/dasharray_parser.hpp
index e5079b2..0ef1ae8 100644
--- a/include/mapnik/util/dasharray_parser.hpp
+++ b/include/mapnik/util/dasharray_parser.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/util/feature_to_geojson.hpp b/include/mapnik/util/feature_to_geojson.hpp
index fbf2aa5..ad3c0a7 100644
--- a/include/mapnik/util/feature_to_geojson.hpp
+++ b/include/mapnik/util/feature_to_geojson.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/util/featureset_buffer.hpp b/include/mapnik/util/featureset_buffer.hpp
index 842cc8e..8689a41 100644
--- a/include/mapnik/util/featureset_buffer.hpp
+++ b/include/mapnik/util/featureset_buffer.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/util/file_io.hpp b/include/mapnik/util/file_io.hpp
index ff9f37e..d3ffe90 100644
--- a/include/mapnik/util/file_io.hpp
+++ b/include/mapnik/util/file_io.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -24,10 +24,9 @@
 #define MAPNIK_FILE_IO_HPP
 
 // mapnik
-#include <mapnik/utils.hpp>
 #include <mapnik/make_unique.hpp>
 #include <mapnik/util/noncopyable.hpp>
-//#include <mapnik/config.hpp>
+#include <mapnik/util/utf_conv_win.hpp>
 
 // stl
 #include <cstdio>
diff --git a/include/mapnik/util/fs.hpp b/include/mapnik/util/fs.hpp
index 3e01b96..03905cb 100644
--- a/include/mapnik/util/fs.hpp
+++ b/include/mapnik/util/fs.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/util/geometry_to_ds_type.hpp b/include/mapnik/util/geometry_to_ds_type.hpp
index 4d89cc0..58fc89d 100644
--- a/include/mapnik/util/geometry_to_ds_type.hpp
+++ b/include/mapnik/util/geometry_to_ds_type.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/util/geometry_to_geojson.hpp b/include/mapnik/util/geometry_to_geojson.hpp
index beffda7..5cccb09 100644
--- a/include/mapnik/util/geometry_to_geojson.hpp
+++ b/include/mapnik/util/geometry_to_geojson.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/util/geometry_to_svg.hpp b/include/mapnik/util/geometry_to_svg.hpp
index af55897..9efb551 100644
--- a/include/mapnik/util/geometry_to_svg.hpp
+++ b/include/mapnik/util/geometry_to_svg.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/util/geometry_to_wkb.hpp b/include/mapnik/util/geometry_to_wkb.hpp
index 397baee..bb9d05b 100644
--- a/include/mapnik/util/geometry_to_wkb.hpp
+++ b/include/mapnik/util/geometry_to_wkb.hpp
@@ -141,7 +141,7 @@ wkb_buffer_ptr point_wkb( geometry::point<double> const& pt, wkbByteOrder byte_o
     write(ss, pt.x, 8, byte_order);
     write(ss, pt.y, 8, byte_order);
     assert(ss.good());
-    return std::move(wkb);
+    return wkb;
 }
 
 wkb_buffer_ptr line_string_wkb(geometry::line_string<double> const& line, wkbByteOrder byte_order)
@@ -161,7 +161,7 @@ wkb_buffer_ptr line_string_wkb(geometry::line_string<double> const& line, wkbByt
         write(ss, pt.y, 8, byte_order);
     }
     assert(ss.good());
-    return std::move(wkb);
+    return wkb;
 }
 
 wkb_buffer_ptr polygon_wkb( geometry::polygon<double> const& poly, wkbByteOrder byte_order)
@@ -199,7 +199,7 @@ wkb_buffer_ptr polygon_wkb( geometry::polygon<double> const& poly, wkbByteOrder
     }
 
     assert(ss.good());
-    return std::move(wkb);
+    return wkb;
 }
 
 wkb_buffer_ptr multi_point_wkb( geometry::multi_point<double> const& multi_pt, wkbByteOrder byte_order)
@@ -218,7 +218,7 @@ wkb_buffer_ptr multi_point_wkb( geometry::multi_point<double> const& multi_pt, w
         write(ss, pt.y, 8, byte_order);
     }
     assert(ss.good());
-    return std::move(wkb);
+    return wkb;
 }
 
 
@@ -296,7 +296,7 @@ wkb_buffer_ptr multi_geom_wkb(MultiGeometry const& multi_geom, wkbByteOrder byte
         ss.write(wkb->buffer(), wkb->size());
     }
 
-    return std::move(multi_wkb);
+    return multi_wkb;
 }
 } // ns detail
 
@@ -305,7 +305,7 @@ using wkb_buffer_ptr = detail::wkb_buffer_ptr;
 template<typename GeometryType>
 wkb_buffer_ptr to_wkb(GeometryType const& geom, wkbByteOrder byte_order )
 {
-    return std::move(detail::geometry_to_wkb(byte_order)(geom));
+    return detail::geometry_to_wkb(byte_order)(geom);
 }
 
 }}
diff --git a/include/mapnik/util/geometry_to_wkt.hpp b/include/mapnik/util/geometry_to_wkt.hpp
index 0e65d7c..3c81ef4 100644
--- a/include/mapnik/util/geometry_to_wkt.hpp
+++ b/include/mapnik/util/geometry_to_wkt.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -35,7 +35,7 @@ namespace mapnik { namespace util {
 inline bool to_wkt(std::string & wkt,  mapnik::geometry::geometry<double> const& geom)
 {
     using sink_type = std::back_insert_iterator<std::string>;
-    static const mapnik::wkt::wkt_generator_grammar<sink_type, mapnik::geometry::geometry<double>, double > generator;
+    static const mapnik::wkt::wkt_generator_grammar<sink_type, mapnik::geometry::geometry<double>> generator;
     sink_type sink(wkt);
     return boost::spirit::karma::generate(sink, generator, geom);
 }
@@ -43,7 +43,7 @@ inline bool to_wkt(std::string & wkt,  mapnik::geometry::geometry<double> const&
 inline bool to_wkt(std::string & wkt,  mapnik::geometry::geometry<std::int64_t> const& geom)
 {
     using sink_type = std::back_insert_iterator<std::string>;
-    static const mapnik::wkt::wkt_generator_grammar_int<sink_type, mapnik::geometry::geometry<std::int64_t>, std::int64_t > generator;
+    static const mapnik::wkt::wkt_generator_grammar<sink_type, mapnik::geometry::geometry<std::int64_t>> generator;
     sink_type sink(wkt);
     return boost::spirit::karma::generate(sink, generator, geom);
 }
diff --git a/include/mapnik/util/hsl.hpp b/include/mapnik/util/hsl.hpp
index e0b2d59..d060da9 100644
--- a/include/mapnik/util/hsl.hpp
+++ b/include/mapnik/util/hsl.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -59,7 +59,7 @@ inline double hue_to_rgb(double m1, double m2, double h)
 
 inline void hsl2rgb(double h, double s, double l,
                     double & r, double & g, double & b) {
-    if (!s) {
+    if (s == 0.0) {
         r = g = b = l;
     }
     else
diff --git a/include/mapnik/util/noncopyable.hpp b/include/mapnik/util/noncopyable.hpp
index e80fb4e..1cd4a4a 100644
--- a/include/mapnik/util/noncopyable.hpp
+++ b/include/mapnik/util/noncopyable.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/util/path_iterator.hpp b/include/mapnik/util/path_iterator.hpp
index 840e63a..319c346 100644
--- a/include/mapnik/util/path_iterator.hpp
+++ b/include/mapnik/util/path_iterator.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -111,7 +111,7 @@ private:
 
     void increment()
     {
-        std::get<0>(v_) = vertices_->cont_.get_vertex(pos_++, &std::get<1>(v_), &std::get<2>(v_));
+        std::get<0>(v_) = vertices_->cont_.get_vertex(static_cast<unsigned>(pos_++), &std::get<1>(v_), &std::get<2>(v_));
     }
 
     bool equal( path_iterator const& other) const
diff --git a/include/mapnik/util/recursive_wrapper.hpp b/include/mapnik/util/recursive_wrapper.hpp
index 7a212e8..16a670f 100644
--- a/include/mapnik/util/recursive_wrapper.hpp
+++ b/include/mapnik/util/recursive_wrapper.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/utils.hpp b/include/mapnik/util/singleton.hpp
similarity index 60%
rename from include/mapnik/utils.hpp
rename to include/mapnik/util/singleton.hpp
index a306f1c..2c40406 100644
--- a/include/mapnik/utils.hpp
+++ b/include/mapnik/util/singleton.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -20,8 +20,8 @@
  *
  *****************************************************************************/
 
-#ifndef MAPNIK_UTILS_HPP
-#define MAPNIK_UTILS_HPP
+#ifndef MAPNIK_UTIL_SINGLETON_HPP
+#define MAPNIK_UTIL_SINGLETON_HPP
 
 #include <mapnik/config.hpp>
 
@@ -29,10 +29,9 @@
 #include <stdexcept> // std::runtime_error
 #include <cstdlib> // std::atexit
 #include <new> // operator new
-
-#ifdef MAPNIK_THREADSAFE
+#include <type_traits>
+#include <atomic>
 #include <mutex>
-#endif
 
 namespace mapnik
 {
@@ -55,26 +54,13 @@ template <typename T>
 class CreateStatic
 {
 private:
-    union MaxAlign
-    {
-        char t_[sizeof(T)];
-        short int shortInt_;
-        int int_;
-        long int longInt_;
-        float float_;
-        double double_;
-        long double longDouble_;
-        struct Test;
-        int Test::* pMember_;
-        int (Test::*pMemberFn_)(int);
-    };
-
+    using storage_type = typename std::aligned_storage<sizeof(T), alignof(T)>::type;
 public:
 
     static T* create()
     {
-        static MaxAlign staticMemory;
-        return new(&staticMemory) T;
+        static storage_type static_memory;
+        return new(&static_memory) T;
     }
     static void destroy(volatile T* obj)
     {
@@ -88,43 +74,41 @@ template <typename T,
           template <typename U> class CreatePolicy=CreateStatic> class MAPNIK_DECL singleton
 {
 #else
-template <typename T,
-          template <typename U> class CreatePolicy=CreateStatic> class singleton
-{
-#endif
-    friend class CreatePolicy<T>;
-    static T* pInstance_;
-    static bool destroyed_;
-    singleton(const singleton &rhs);
-    singleton& operator=(const singleton&);
-
-    static void onDeadReference()
+    template <typename T,
+              template <typename U> class CreatePolicy=CreateStatic> class singleton
     {
-        throw std::runtime_error("dead reference!");
-    }
+#endif
+        friend class CreatePolicy<T>;
+        static std::atomic<T*> pInstance_;
+        static bool destroyed_;
+        singleton(const singleton &rhs);
+        singleton& operator=(const singleton&);
 
-    static void DestroySingleton()
-    {
-        CreatePolicy<T>::destroy(pInstance_);
-        pInstance_ = 0;
-        destroyed_ = true;
-    }
+        static void onDeadReference()
+        {
+            throw std::runtime_error("dead reference!");
+        }
 
-protected:
+        static void DestroySingleton()
+        {
+            CreatePolicy<T>::destroy(pInstance_);
+            pInstance_ = 0;
+            destroyed_ = true;
+        }
 
-#ifdef MAPNIK_THREADSAFE
+    protected:
         static std::mutex mutex_;
-#endif
         singleton() {}
+
     public:
         static T& instance()
         {
-            if (! pInstance_)
+            T * tmp = pInstance_.load(std::memory_order_acquire);
+            if (tmp == nullptr)
             {
-#ifdef MAPNIK_THREADSAFE
                 std::lock_guard<std::mutex> lock(mutex_);
-#endif
-                if (! pInstance_)
+                tmp = pInstance_.load(std::memory_order_relaxed);
+                if (tmp == nullptr)
                 {
                     if (destroyed_)
                     {
@@ -133,37 +117,23 @@ protected:
                     }
                     else
                     {
-                        pInstance_ = CreatePolicy<T>::create();
-
+                        tmp = CreatePolicy<T>::create();
+                        pInstance_.store(tmp, std::memory_order_release);
                         // register destruction
                         std::atexit(&DestroySingleton);
                     }
                 }
             }
-            return *pInstance_;
+            return *tmp;
         }
-};
+    };
 
-#ifdef MAPNIK_THREADSAFE
     template <typename T,
               template <typename U> class CreatePolicy> std::mutex singleton<T,CreatePolicy>::mutex_;
-#endif
-
     template <typename T,
-              template <typename U> class CreatePolicy> T* singleton<T,CreatePolicy>::pInstance_=0;
+              template <typename U> class CreatePolicy> std::atomic<T*> singleton<T,CreatePolicy>::pInstance_;
     template <typename T,
-              template <typename U> class CreatePolicy> bool singleton<T,CreatePolicy>::destroyed_=false;
-
-
-#ifdef _WINDOWS
-
-// UTF8 <--> UTF16 conversion routines
-
-MAPNIK_DECL std::string utf16_to_utf8(std::wstring const& wstr);
-MAPNIK_DECL std::wstring utf8_to_utf16(std::string const& str);
-
-#endif  // _WINDOWS
-
+              template <typename U> class CreatePolicy> bool singleton<T,CreatePolicy>::destroyed_ = false;
 }
 
-#endif // MAPNIK_UTILS_HPP
+#endif // MAPNIK_UTIL_SINGLETON_HPP
diff --git a/include/mapnik/util/timer.hpp b/include/mapnik/util/timer.hpp
index 8f74878..e29a8ea 100644
--- a/include/mapnik/util/timer.hpp
+++ b/include/mapnik/util/timer.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/util/trim.hpp b/include/mapnik/util/trim.hpp
index cc4816d..6032033 100644
--- a/include/mapnik/util/trim.hpp
+++ b/include/mapnik/util/trim.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/save_map.hpp b/include/mapnik/util/utf_conv_win.hpp
similarity index 74%
copy from include/mapnik/save_map.hpp
copy to include/mapnik/util/utf_conv_win.hpp
index 8945320..68e28ec 100644
--- a/include/mapnik/save_map.hpp
+++ b/include/mapnik/util/utf_conv_win.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -20,21 +20,24 @@
  *
  *****************************************************************************/
 
-#ifndef MAPNIK_SAVE_MAP_HPP
-#define MAPNIK_SAVE_MAP_HPP
+#ifndef MAPNIK_UTIL_UTF_CONV_WIN_HPP
+#define MAPNIK_UTIL_UTF_CONV_WIN_HPP
 
+#ifdef _WINDOWS
 // mapnik
 #include <mapnik/config.hpp>
-
 // stl
 #include <string>
 
 namespace mapnik
 {
-class Map;
 
-MAPNIK_DECL void save_map(Map const& map, std::string const& filename, bool explicit_defaults = false);
-MAPNIK_DECL std::string save_map_to_string(Map const& map, bool explicit_defaults = false);
+// UTF8 <--> UTF16 conversion routines
+
+    MAPNIK_DECL std::string utf16_to_utf8(std::wstring const& wstr);
+    MAPNIK_DECL std::wstring utf8_to_utf16(std::string const& str);
+
 }
+#endif  // _WINDOWS
 
-#endif // MAPNIK_SAVE_MAP_HPP
+#endif // MAPNIK_UTIL_UTF_CONV_WIN_HPP
diff --git a/include/mapnik/util/variant_io.hpp b/include/mapnik/util/variant_io.hpp
index cf08079..8839a7e 100644
--- a/include/mapnik/util/variant_io.hpp
+++ b/include/mapnik/util/variant_io.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/value.hpp b/include/mapnik/value.hpp
index 83d396a..8a59b83 100644
--- a/include/mapnik/value.hpp
+++ b/include/mapnik/value.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -751,7 +751,7 @@ struct to_unicode
         util::to_string(str,val);
         return value_unicode_string(str.c_str());
     }
-    
+
     value_unicode_string operator() (value_bool val) const
     {
         if (val) {
@@ -833,7 +833,7 @@ public:
 
     template <typename T>
     value ( T && val)
-        : value_base(std::move(typename detail::mapnik_value_type<T>::type(val))) {}
+        : value_base(typename detail::mapnik_value_type<T>::type(val)) {}
 
     value & operator=( value const& other) = default;
 
@@ -958,7 +958,6 @@ inline std::size_t hash_value(value const& val)
 } // namespace value_adl_barrier
 
 using value_adl_barrier::value;
-using value_adl_barrier::operator<<;
 
 namespace detail {
 
@@ -990,4 +989,18 @@ inline bool value::is_null() const
 
 } // namespace mapnik
 
+// support for std::unordered_xxx
+namespace std
+{
+template <>
+struct hash<mapnik::value>
+{
+    size_t operator()(mapnik::value const& val) const
+    {
+        return mapnik::mapnik_hash_value(val);
+    }
+};
+
+}
+
 #endif // MAPNIK_VALUE_HPP
diff --git a/include/mapnik/value_error.hpp b/include/mapnik/value_error.hpp
index 1edc541..68df622 100644
--- a/include/mapnik/value_error.hpp
+++ b/include/mapnik/value_error.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/value_hash.hpp b/include/mapnik/value_hash.hpp
index 0933f06..4c12bbe 100644
--- a/include/mapnik/value_hash.hpp
+++ b/include/mapnik/value_hash.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -51,7 +51,7 @@ struct value_hasher
 
     std::size_t operator() (value_unicode_string const& val) const
     {
-        return val.hashCode();
+        return static_cast<std::size_t>(val.hashCode());
     }
 
     template <class T>
diff --git a/include/mapnik/value_types.hpp b/include/mapnik/value_types.hpp
index fdaa99e..a250b49 100644
--- a/include/mapnik/value_types.hpp
+++ b/include/mapnik/value_types.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/version.hpp b/include/mapnik/version.hpp
index 8030c5c..47a200e 100644
--- a/include/mapnik/version.hpp
+++ b/include/mapnik/version.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -23,7 +23,7 @@
 #ifndef MAPNIK_VERSION_HPP
 #define MAPNIK_VERSION_HPP
 
-#define MAPNIK_VERSION_IS_RELEASE 0
+#define MAPNIK_VERSION_IS_RELEASE 1
 
 #define MAPNIK_MAJOR_VERSION 3
 #define MAPNIK_MINOR_VERSION 0
diff --git a/include/mapnik/vertex.hpp b/include/mapnik/vertex.hpp
index 597526d..b05f362 100644
--- a/include/mapnik/vertex.hpp
+++ b/include/mapnik/vertex.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/vertex_cache.hpp b/include/mapnik/vertex_cache.hpp
index 094101a..a0a32e9 100644
--- a/include/mapnik/vertex_cache.hpp
+++ b/include/mapnik/vertex_cache.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -47,7 +47,7 @@ class MAPNIK_DECL vertex_cache : util::noncopyable
 {
     struct segment
     {
-        segment(double x, double y, double length) : pos(x, y), length(length) {}
+        segment(double x, double y, double _length) : pos(x, y), length(_length) {}
         pixel_position pos; //Last point of this segment, first point is implicitly defined by the previous segement in this vector
         double length;
     };
diff --git a/include/mapnik/vertex_converters.hpp b/include/mapnik/vertex_converters.hpp
index 13c07d8..f10f720 100644
--- a/include/mapnik/vertex_converters.hpp
+++ b/include/mapnik/vertex_converters.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -278,7 +278,7 @@ template <typename Dispatcher, typename Current, typename... ConverterTypes>
 struct converters_helper<Dispatcher,Current,ConverterTypes...>
 {
     template <typename Converter>
-    static void set(Dispatcher & disp, int state)
+    static void set(Dispatcher & disp, std::size_t state)
     {
         if (std::is_same<Converter,Current>::value)
         {
@@ -323,15 +323,15 @@ template <typename Dispatcher>
 struct converters_helper<Dispatcher>
 {
     template <typename Converter>
-    static void set(Dispatcher &, int) {}
+    static void set(Dispatcher &, std::size_t) {}
     template <typename Geometry, typename Processor>
-    static void forward(Dispatcher & disp, Geometry & geom, Processor & proc)
+    static void forward(Dispatcher &, Geometry & geom, Processor & proc)
     {
         proc.add_path(geom);
     }
 };
 
-template <typename Args, int NUM_CONV>
+template <typename Args, std::size_t NUM_CONV>
 struct dispatcher : util::noncopyable
 {
     using this_type = dispatcher;
@@ -345,23 +345,23 @@ struct dispatcher : util::noncopyable
         std::fill(vec_.begin(), vec_.end(), 0);
     }
 
-    std::array<unsigned, NUM_CONV> vec_;
+    std::array<std::size_t, NUM_CONV> vec_;
     args_type args_;
 };
 
 struct arguments : util::noncopyable
 {
-    arguments(box2d<double> const& bbox, symbolizer_base const& sym, view_transform const& tr,
-              proj_transform const& prj_trans, agg::trans_affine const& affine_trans, feature_impl const& feature,
-              attributes const& vars, double scale_factor)
-        : bbox(bbox),
-          sym(sym),
-          tr(tr),
-          prj_trans(prj_trans),
-          affine_trans(affine_trans),
-          feature(feature),
-          vars(vars),
-          scale_factor(scale_factor) {}
+    arguments(box2d<double> const& _bbox, symbolizer_base const& _sym, view_transform const& _tr,
+              proj_transform const& _prj_trans, agg::trans_affine const& _affine_trans, feature_impl const& _feature,
+              attributes const& _vars, double _scale_factor)
+        : bbox(_bbox),
+          sym(_sym),
+          tr(_tr),
+          prj_trans(_prj_trans),
+          affine_trans(_affine_trans),
+          feature(_feature),
+          vars(_vars),
+          scale_factor(_scale_factor) {}
 
     box2d<double> const& bbox;
     symbolizer_base const& sym;
diff --git a/include/mapnik/vertex_vector.hpp b/include/mapnik/vertex_vector.hpp
index a25afc2..67e30fc 100644
--- a/include/mapnik/vertex_vector.hpp
+++ b/include/mapnik/vertex_vector.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/view_strategy.hpp b/include/mapnik/view_strategy.hpp
index 7bddb9b..0d1125b 100644
--- a/include/mapnik/view_strategy.hpp
+++ b/include/mapnik/view_strategy.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -25,11 +25,11 @@
 
 // mapnik
 #include <mapnik/view_transform.hpp>
-
+#include <mapnik/safe_cast.hpp>
 // boost
 #include <boost/geometry/core/coordinate_type.hpp>
 #include <boost/geometry/core/access.hpp>
-#include <boost/numeric/conversion/cast.hpp>
+
 
 namespace mapnik
 {
@@ -46,8 +46,8 @@ struct view_strategy
         double x = boost::geometry::get<0>(p1);
         double y = boost::geometry::get<1>(p1);
         tr_.forward(&x,&y);
-        boost::geometry::set<0>(p2, boost::numeric_cast<coordinate_type>(x));
-        boost::geometry::set<1>(p2, boost::numeric_cast<coordinate_type>(y));
+        boost::geometry::set<0>(p2, safe_cast<coordinate_type>(x));
+        boost::geometry::set<1>(p2, safe_cast<coordinate_type>(y));
         return true;
     }
 
diff --git a/include/mapnik/view_transform.hpp b/include/mapnik/view_transform.hpp
index e293eb6..2f5108c 100644
--- a/include/mapnik/view_transform.hpp
+++ b/include/mapnik/view_transform.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/warp.hpp b/include/mapnik/warp.hpp
index 262164e..0bf3332 100644
--- a/include/mapnik/warp.hpp
+++ b/include/mapnik/warp.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/webp_io.hpp b/include/mapnik/webp_io.hpp
index 3caf281..4b5c541 100644
--- a/include/mapnik/webp_io.hpp
+++ b/include/mapnik/webp_io.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/well_known_srs.hpp b/include/mapnik/well_known_srs.hpp
index 41d4cac..eeb478e 100644
--- a/include/mapnik/well_known_srs.hpp
+++ b/include/mapnik/well_known_srs.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -92,7 +92,7 @@ static inline bool merc2lonlat(double * x, double * y , int point_count)
 
 static inline bool lonlat2merc(geometry::line_string<double> & ls)
 {
-    for(auto & p : ls) 
+    for(auto & p : ls)
     {
         if (p.x > 180) p.x = 180;
         else if (p.x < -180) p.x = -180;
diff --git a/include/mapnik/wkb.hpp b/include/mapnik/wkb.hpp
index 3247804..ac90df7 100644
--- a/include/mapnik/wkb.hpp
+++ b/include/mapnik/wkb.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/wkt/wkt_factory.hpp b/include/mapnik/wkt/wkt_factory.hpp
index 3e2ece1..14f509d 100644
--- a/include/mapnik/wkt/wkt_factory.hpp
+++ b/include/mapnik/wkt/wkt_factory.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/include/mapnik/wkt/wkt_generator_grammar.hpp b/include/mapnik/wkt/wkt_generator_grammar.hpp
index fc8e700..e4a3969 100644
--- a/include/mapnik/wkt/wkt_generator_grammar.hpp
+++ b/include/mapnik/wkt/wkt_generator_grammar.hpp
@@ -33,6 +33,9 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/spirit/include/karma.hpp>
 #include <boost/spirit/include/phoenix_function.hpp>
 #include <boost/math/special_functions/trunc.hpp> // for vc++ and android whose c++11 libs lack std::trunc
@@ -86,66 +89,52 @@ struct wkt_coordinate_policy : karma::real_policies<T>
     }
 };
 
-}
+template <typename T>
+struct coordinate_generator;
 
-template <typename OutputIterator, typename Geometry, typename T>
-struct wkt_generator_grammar :
-    karma::grammar<OutputIterator, Geometry const& ()>
+template <>
+struct coordinate_generator<double>
 {
-    wkt_generator_grammar();
-    // rules
-    karma::rule<OutputIterator, Geometry const&()> geometry;
-    karma::rule<OutputIterator, karma::locals<mapnik::geometry::geometry_types>, Geometry const&() > geometry_dispatch;
-    karma::rule<OutputIterator, geometry::geometry<T> const&()> point;
-    karma::rule<OutputIterator, geometry::point<T> const&()> point_coord;
-    karma::rule<OutputIterator, geometry::geometry<T> const&()> linestring;
-    karma::rule<OutputIterator, geometry::line_string<T> const&()> linestring_coord;
-    karma::rule<OutputIterator, geometry::geometry<T> const&()> polygon;
-    karma::rule<OutputIterator, geometry::polygon<T> const&()> polygon_coord;
-    karma::rule<OutputIterator, geometry::linear_ring<T> const&()> exterior_ring_coord;
-    karma::rule<OutputIterator, std::vector<geometry::linear_ring<T> > const&()> interior_ring_coord;
-    karma::rule<OutputIterator, geometry::geometry<T> const& ()> multi_point;
-    karma::rule<OutputIterator, geometry::multi_point<T> const& ()> multi_point_coord;
-    karma::rule<OutputIterator, geometry::geometry<T> const& ()> multi_linestring;
-    karma::rule<OutputIterator, geometry::multi_line_string<T> const& ()> multi_linestring_coord;
-    karma::rule<OutputIterator, geometry::geometry<T> const& ()> multi_polygon;
-    karma::rule<OutputIterator, geometry::multi_polygon<T> const& ()> multi_polygon_coord;
-    karma::rule<OutputIterator, geometry::geometry<T> const& ()> geometry_collection;
-    karma::rule<OutputIterator, geometry::geometry_collection<T> const& ()> geometries;
-    boost::phoenix::function<detail::get_type<Geometry> > geometry_type;
-    karma::symbols<mapnik::geometry::geometry_types, char const*> empty;
-    //
-    karma::real_generator<T, detail::wkt_coordinate_policy<T> > coordinate;
+    using generator = karma::real_generator<double, detail::wkt_coordinate_policy<double> >;
+};
+
+template <>
+struct coordinate_generator<std::int64_t>
+{
+    using generator = karma::int_generator<std::int64_t>;
 };
 
-template <typename OutputIterator, typename Geometry, typename T>
-struct wkt_generator_grammar_int :
+}
+
+template <typename OutputIterator, typename Geometry>
+struct wkt_generator_grammar :
     karma::grammar<OutputIterator, Geometry const& ()>
 {
-    wkt_generator_grammar_int();
+    using coord_type = typename Geometry::value_type;
+    wkt_generator_grammar();
     // rules
     karma::rule<OutputIterator, Geometry const&()> geometry;
     karma::rule<OutputIterator, karma::locals<mapnik::geometry::geometry_types>, Geometry const&() > geometry_dispatch;
-    karma::rule<OutputIterator, geometry::geometry<T> const&()> point;
-    karma::rule<OutputIterator, geometry::point<T> const&()> point_coord;
-    karma::rule<OutputIterator, geometry::geometry<T> const&()> linestring;
-    karma::rule<OutputIterator, geometry::line_string<T> const&()> linestring_coord;
-    karma::rule<OutputIterator, geometry::geometry<T> const&()> polygon;
-    karma::rule<OutputIterator, geometry::polygon<T> const&()> polygon_coord;
-    karma::rule<OutputIterator, geometry::linear_ring<T> const&()> exterior_ring_coord;
-    karma::rule<OutputIterator, std::vector<geometry::linear_ring<T> > const&()> interior_ring_coord;
-    karma::rule<OutputIterator, geometry::geometry<T> const& ()> multi_point;
-    karma::rule<OutputIterator, geometry::multi_point<T> const& ()> multi_point_coord;
-    karma::rule<OutputIterator, geometry::geometry<T> const& ()> multi_linestring;
-    karma::rule<OutputIterator, geometry::multi_line_string<T> const& ()> multi_linestring_coord;
-    karma::rule<OutputIterator, geometry::geometry<T> const& ()> multi_polygon;
-    karma::rule<OutputIterator, geometry::multi_polygon<T> const& ()> multi_polygon_coord;
-    karma::rule<OutputIterator, geometry::geometry<T> const& ()> geometry_collection;
-    karma::rule<OutputIterator, geometry::geometry_collection<T> const& ()> geometries;
+    karma::rule<OutputIterator, geometry::geometry<coord_type> const&()> point;
+    karma::rule<OutputIterator, geometry::point<coord_type> const&()> point_coord;
+    karma::rule<OutputIterator, geometry::geometry<coord_type> const&()> linestring;
+    karma::rule<OutputIterator, geometry::line_string<coord_type> const&()> linestring_coord;
+    karma::rule<OutputIterator, geometry::geometry<coord_type> const&()> polygon;
+    karma::rule<OutputIterator, geometry::polygon<coord_type> const&()> polygon_coord;
+    karma::rule<OutputIterator, geometry::linear_ring<coord_type> const&()> exterior_ring_coord;
+    karma::rule<OutputIterator, std::vector<geometry::linear_ring<coord_type> > const&()> interior_ring_coord;
+    karma::rule<OutputIterator, geometry::geometry<coord_type> const& ()> multi_point;
+    karma::rule<OutputIterator, geometry::multi_point<coord_type> const& ()> multi_point_coord;
+    karma::rule<OutputIterator, geometry::geometry<coord_type> const& ()> multi_linestring;
+    karma::rule<OutputIterator, geometry::multi_line_string<coord_type> const& ()> multi_linestring_coord;
+    karma::rule<OutputIterator, geometry::geometry<coord_type> const& ()> multi_polygon;
+    karma::rule<OutputIterator, geometry::multi_polygon<coord_type> const& ()> multi_polygon_coord;
+    karma::rule<OutputIterator, geometry::geometry<coord_type> const& ()> geometry_collection;
+    karma::rule<OutputIterator, geometry::geometry_collection<coord_type> const& ()> geometries;
     boost::phoenix::function<detail::get_type<Geometry> > geometry_type;
     karma::symbols<mapnik::geometry::geometry_types, char const*> empty;
     //
-    karma::int_generator<T> coordinate;
+    typename detail::coordinate_generator<coord_type>::generator coordinate;
 };
 
 }}
diff --git a/include/mapnik/wkt/wkt_generator_grammar_impl.hpp b/include/mapnik/wkt/wkt_generator_grammar_impl.hpp
index 64624b2..7205db6 100644
--- a/include/mapnik/wkt/wkt_generator_grammar_impl.hpp
+++ b/include/mapnik/wkt/wkt_generator_grammar_impl.hpp
@@ -28,8 +28,8 @@
 
 namespace mapnik { namespace wkt {
 
-template <typename OutputIterator, typename Geometry, typename T>
-wkt_generator_grammar<OutputIterator, Geometry,T>::wkt_generator_grammar()
+template <typename OutputIterator, typename Geometry>
+wkt_generator_grammar<OutputIterator, Geometry>::wkt_generator_grammar()
     : wkt_generator_grammar::base_type(geometry)
 {
     boost::spirit::karma::_val_type _val;
@@ -113,89 +113,4 @@ wkt_generator_grammar<OutputIterator, Geometry,T>::wkt_generator_grammar()
 
 }
 
-template <typename OutputIterator, typename Geometry, typename T>
-wkt_generator_grammar_int<OutputIterator, Geometry,T>::wkt_generator_grammar_int()
-    : wkt_generator_grammar_int::base_type(geometry)
-{
-    boost::spirit::karma::_val_type _val;
-    boost::spirit::karma::_1_type _1;
-    boost::spirit::karma::_a_type _a;
-    boost::spirit::karma::lit_type lit;
-    boost::spirit::karma::uint_type uint_;
-    boost::spirit::karma::eps_type eps;
-
-    empty.add
-        (geometry::geometry_types::Point, "POINT EMPTY")
-        (geometry::geometry_types::LineString, "LINESTRING EMPTY")
-        (geometry::geometry_types::Polygon, "POLYGON EMPTY")
-        (geometry::geometry_types::MultiPoint, "MULTIPOINT EMPTY")
-        (geometry::geometry_types::MultiLineString, "MULTILINESTRING EMPTY")
-        (geometry::geometry_types::MultiPolygon, "MULTIPOLYGON EMPTY")
-        (geometry::geometry_types::GeometryCollection, "GEOMETRYCOLLECTION EMPTY")
-        ;
-
-    geometry = geometry_dispatch.alias()
-        ;
-
-    geometry_dispatch = eps[_a = geometry_type(_val)] <<
-        (&uint_(geometry::geometry_types::Point)[_1 = _a]
-         << point)
-        |
-        (&uint_(geometry::geometry_types::LineString)[_1 = _a]
-         << (linestring | empty[_1 = _a]))
-        |
-        (&uint_(geometry::geometry_types::Polygon)[_1 = _a]
-         << (polygon | empty[_1 = _a]))
-        |
-        (&uint_(geometry::geometry_types::MultiPoint)[_1 = _a]
-         << ( multi_point | empty[_1 = _a]))
-        |
-        (&uint_(geometry::geometry_types::MultiLineString)[_1 = _a]
-         << (multi_linestring | empty[_1 = _a]))
-        |
-        (&uint_(geometry::geometry_types::MultiPolygon)[_1 = _a]
-         << (multi_polygon | empty[_1 = _a]))
-        |
-        (&uint_(geometry::geometry_types::GeometryCollection)[_1 = _a]
-         << (geometry_collection | empty[_1 = _a]))
-        |
-        (&uint_(geometry::geometry_types::Unknown)[_1 = _a]
-         << lit("POINT EMPTY")) // special case for geometry_empty as mapnik::geometry::point<double> can't be empty
-        ;
-
-    point = lit("POINT(") << point_coord << lit(")")
-        ;
-    linestring = lit("LINESTRING(") << linestring_coord << lit(")")
-        ;
-    polygon = lit("POLYGON(") << polygon_coord << lit(")")
-        ;
-    multi_point = lit("MULTIPOINT(") << multi_point_coord << lit(")")
-        ;
-    multi_linestring = lit("MULTILINESTRING(") << multi_linestring_coord << lit(")")
-        ;
-    multi_polygon = lit("MULTIPOLYGON(") << multi_polygon_coord << lit(")")
-        ;
-    geometry_collection = lit("GEOMETRYCOLLECTION(") << geometries  << lit(")")
-        ;
-    point_coord = coordinate << lit(' ') << coordinate
-        ;
-    linestring_coord = point_coord % lit(',')
-        ;
-    polygon_coord = lit('(') << exterior_ring_coord << lit(')') << interior_ring_coord
-        ;
-    exterior_ring_coord = linestring_coord.alias()
-        ;
-    interior_ring_coord =  *(lit(",(") << exterior_ring_coord << lit(')'))
-        ;
-    multi_point_coord = linestring_coord.alias()
-        ;
-    multi_linestring_coord = (lit('(') << linestring_coord  << lit(')')) % lit(',')
-        ;
-    multi_polygon_coord = (lit('(') << polygon_coord << lit(')')) % lit(',')
-        ;
-    geometries =  geometry % lit(',')
-        ;
-
-}
-
 }}
diff --git a/include/mapnik/wkt/wkt_grammar.hpp b/include/mapnik/wkt/wkt_grammar.hpp
index b056663..43c5334 100644
--- a/include/mapnik/wkt/wkt_grammar.hpp
+++ b/include/mapnik/wkt/wkt_grammar.hpp
@@ -29,6 +29,9 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/assert.hpp>
 #include <boost/spirit/include/qi.hpp>
 #include <boost/spirit/include/phoenix_function.hpp>
diff --git a/include/mapnik/xml_attribute_cast.hpp b/include/mapnik/xml_attribute_cast.hpp
index 1a3cb98..5140fde 100644
--- a/include/mapnik/xml_attribute_cast.hpp
+++ b/include/mapnik/xml_attribute_cast.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -37,7 +37,10 @@
 #include <mapnik/text/font_feature_settings.hpp>
 
 // boost
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wsign-conversion"
 #include <boost/optional.hpp>
+#pragma GCC diagnostic pop
 
 // stl
 #include <string>
@@ -109,8 +112,8 @@ struct do_xml_attribute_cast<unsigned>
     static inline boost::optional<unsigned> xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source)
     {
         int result;
-        if (mapnik::util::string2int(source, result))
-            return boost::optional<unsigned>(result);
+        if (mapnik::util::string2int(source, result) && result >= 0)
+            return boost::optional<unsigned>(static_cast<unsigned>(result));
         return boost::optional<unsigned>();
     }
 };
@@ -166,7 +169,7 @@ struct do_xml_attribute_cast<mapnik::enumeration<T,MAX> >
 template <>
 struct do_xml_attribute_cast<mapnik::color>
 {
-    static inline boost::optional<mapnik::color> xml_attribute_cast_impl(xml_tree const& tree, std::string const& source)
+    static inline boost::optional<mapnik::color> xml_attribute_cast_impl(xml_tree const&, std::string const& source)
     {
         return parse_color(source);
     }
@@ -176,7 +179,7 @@ struct do_xml_attribute_cast<mapnik::color>
 template <>
 struct do_xml_attribute_cast<std::string>
 {
-    static inline boost::optional<std::string> xml_attribute_cast_impl(xml_tree const& /*tree*/, std::string const& source)
+    static inline boost::optional<std::string> xml_attribute_cast_impl(xml_tree const&, std::string const& source)
     {
         return boost::optional<std::string>(source);
     }
@@ -206,7 +209,7 @@ struct do_xml_attribute_cast<mapnik::expression_ptr>
 template <>
 struct do_xml_attribute_cast<mapnik::font_feature_settings>
 {
-    static inline boost::optional<mapnik::font_feature_settings> xml_attribute_cast_impl(xml_tree const& tree, std::string const& source)
+    static inline boost::optional<mapnik::font_feature_settings> xml_attribute_cast_impl(xml_tree const&, std::string const& source)
     {
         return mapnik::font_feature_settings(source);
     }
diff --git a/include/mapnik/xml_loader.hpp b/include/mapnik/xml_loader.hpp
index 2bc8f4a..5fe98af 100644
--- a/include/mapnik/xml_loader.hpp
+++ b/include/mapnik/xml_loader.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -23,14 +23,17 @@
 #ifndef MAPNIK_LIBXML2_LOADER_HPP
 #define MAPNIK_LIBXML2_LOADER_HPP
 
+// mapnik
+#include <mapnik/config.hpp> // for MAPNIK_DECL
+
 // stl
 #include <string>
 
 namespace mapnik
 {
-class xml_node;
-void read_xml(std::string const & filename, xml_node &node);
-void read_xml_string(std::string const & str, xml_node &node, std::string const & base_path="");
+class MAPNIK_DECL xml_node;
+MAPNIK_DECL void read_xml(std::string const & filename, xml_node &node);
+MAPNIK_DECL void read_xml_string(std::string const & str, xml_node &node, std::string const & base_path="");
 }
 
 #endif // MAPNIK_LIBXML2_LOADER_HPP
diff --git a/include/mapnik/xml_node.hpp b/include/mapnik/xml_node.hpp
index 28be9ff..1c36021 100644
--- a/include/mapnik/xml_node.hpp
+++ b/include/mapnik/xml_node.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -23,6 +23,9 @@
 #ifndef MAPNIK_XML_NODE_H
 #define MAPNIK_XML_NODE_H
 
+//mapnik
+#include <mapnik/config.hpp> // for MAPNIK_DECL
+
 //boost
 #include <boost/optional.hpp>
 
@@ -34,9 +37,9 @@
 
 namespace mapnik
 {
-class xml_tree;
+class MAPNIK_DECL xml_tree;
 
-class xml_attribute
+class MAPNIK_DECL xml_attribute
 {
 public:
     xml_attribute(const char * value_);
@@ -44,7 +47,7 @@ public:
     mutable bool processed;
 };
 
-class node_not_found: public std::exception
+class MAPNIK_DECL node_not_found: public std::exception
 {
 public:
     node_not_found(std::string const& node_name);
@@ -56,7 +59,7 @@ protected:
     mutable std::string msg_;
 };
 
-class attribute_not_found: public std::exception
+class MAPNIK_DECL attribute_not_found: public std::exception
 {
 public:
     attribute_not_found(std::string const& node_name, std::string const& attribute_name);
@@ -69,7 +72,7 @@ protected:
     mutable std::string msg_;
 };
 
-class more_than_one_child: public std::exception
+class MAPNIK_DECL more_than_one_child: public std::exception
 {
 public:
     more_than_one_child(std::string const& node_name);
@@ -81,7 +84,7 @@ protected:
     mutable std::string msg_;
 };
 
-class xml_node
+class MAPNIK_DECL xml_node
 {
 public:
     using const_iterator = std::list<xml_node>::const_iterator;
diff --git a/include/mapnik/xml_tree.hpp b/include/mapnik/xml_tree.hpp
index 9cb29a8..535d967 100644
--- a/include/mapnik/xml_tree.hpp
+++ b/include/mapnik/xml_tree.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -33,10 +33,10 @@
 namespace mapnik
 {
 
-class xml_tree
+class MAPNIK_DECL xml_tree
 {
 public:
-    xml_tree(std::string const& encoding="utf8");
+    xml_tree();
     void set_filename(std::string const& fn);
     std::string const& filename() const;
     xml_node &root();
diff --git a/mason_latest.sh b/mason_latest.sh
index cc4a970..62a0c94 100755
--- a/mason_latest.sh
+++ b/mason_latest.sh
@@ -24,11 +24,9 @@ function mason_compile {
         done;
     fi;
     python -c "data=open('$MASON_PREFIX/bin/mapnik-config','r').read();open('$MASON_PREFIX/bin/mapnik-config','w').write(data.replace('$HERE','.'))"
-    mkdir -p ${MASON_PREFIX}/share/gdal
-    mkdir -p ${MASON_PREFIX}/share/proj
     mkdir -p ${MASON_PREFIX}/share/icu
-    cp -r $GDAL_DATA/ ${MASON_PREFIX}/share/gdal/
-    cp -r $PROJ_LIB/ ${MASON_PREFIX}/share/proj/
+    cp -r $GDAL_DATA ${MASON_PREFIX}/share/
+    cp -r $PROJ_LIB ${MASON_PREFIX}/share/
     cp -r $ICU_DATA/*dat ${MASON_PREFIX}/share/icu/
     find ${MASON_PREFIX} -name "*.pyc" -exec rm {} \;
 }
diff --git a/plugins/input/csv/build.py b/plugins/input/csv/build.py
index 174deda..d1f3716 100644
--- a/plugins/input/csv/build.py
+++ b/plugins/input/csv/build.py
@@ -1,7 +1,7 @@
 #
 # This file is part of Mapnik (c++ mapping toolkit)
 #
-# Copyright (C) 2013 Artem Pavlenko
+# Copyright (C) 2015 Artem Pavlenko
 #
 # Mapnik is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/csv/csv_datasource.cpp b/plugins/input/csv/csv_datasource.cpp
index 934e579..fef1a51 100644
--- a/plugins/input/csv/csv_datasource.cpp
+++ b/plugins/input/csv/csv_datasource.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -29,7 +29,7 @@
 
 // mapnik
 #include <mapnik/debug.hpp>
-#include <mapnik/utils.hpp>
+#include <mapnik/util/utf_conv_win.hpp>
 #include <mapnik/unicode.hpp>
 #include <mapnik/feature_layer_desc.hpp>
 #include <mapnik/feature_factory.hpp>
@@ -266,21 +266,21 @@ void csv_datasource::parse_csv(T & stream,
 
     using Tokenizer = boost::tokenizer< escape_type >;
 
-    int line_number(1);
+    int line_number = 1;
     bool has_wkt_field = false;
     bool has_json_field = false;
     bool has_lat_field = false;
     bool has_lon_field = false;
-    unsigned wkt_idx(0);
-    unsigned json_idx(0);
-    unsigned lat_idx(0);
-    unsigned lon_idx(0);
+    unsigned wkt_idx = 0;
+    unsigned json_idx = 0;
+    unsigned lat_idx = 0;
+    unsigned lon_idx = 0;
 
     if (!manual_headers_.empty())
     {
         Tokenizer tok(manual_headers_, grammer);
         Tokenizer::iterator beg = tok.begin();
-        unsigned idx(0);
+        unsigned idx = 0;
         for (; beg != tok.end(); ++beg)
         {
             std::string val = mapnik::util::trim_copy(*beg);
@@ -413,15 +413,13 @@ void csv_datasource::parse_csv(T & stream,
         throw mapnik::datasource_exception("CSV Plugin: could not detect column headers with the name of wkt, geojson, x/y, or latitude/longitude - this is required for reading geometry data");
     }
 
-    mapnik::value_integer feature_count(0);
+    mapnik::value_integer feature_count = 0;
     bool extent_started = false;
 
     std::size_t num_headers = headers_.size();
 
-    for (std::size_t i = 0; i < headers_.size(); ++i)
-    {
-        ctx_->push(headers_[i]);
-    }
+    std::for_each(headers_.begin(), headers_.end(),
+                  [ & ](std::string const& header){ ctx_->push(header); });
 
     mapnik::transcoder tr(desc_.get_encoding());
 
@@ -498,8 +496,8 @@ void csv_datasource::parse_csv(T & stream,
 
             // NOTE: we use ++feature_count here because feature id's should start at 1;
             mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx_,++feature_count));
-            double x(0);
-            double y(0);
+            double x = 0;
+            double y = 0;
             bool parsed_x = false;
             bool parsed_y = false;
             bool parsed_wkt = false;
diff --git a/plugins/input/csv/csv_datasource.hpp b/plugins/input/csv/csv_datasource.hpp
index e26c437..7881af8 100644
--- a/plugins/input/csv/csv_datasource.hpp
+++ b/plugins/input/csv/csv_datasource.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/csv/csv_utils.hpp b/plugins/input/csv/csv_utils.hpp
index 3ec8c9f..c55065e 100644
--- a/plugins/input/csv/csv_utils.hpp
+++ b/plugins/input/csv/csv_utils.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -26,6 +26,7 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
 #include <boost/algorithm/string.hpp>
 #pragma GCC diagnostic pop
 
diff --git a/plugins/input/gdal/build.py b/plugins/input/gdal/build.py
index 506385a..6c80de2 100644
--- a/plugins/input/gdal/build.py
+++ b/plugins/input/gdal/build.py
@@ -1,7 +1,7 @@
 #
 # This file is part of Mapnik (c++ mapping toolkit)
 #
-# Copyright (C) 2013 Artem Pavlenko
+# Copyright (C) 2015 Artem Pavlenko
 #
 # Mapnik is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -17,7 +17,7 @@
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
-# 
+#
 
 Import ('plugin_base')
 Import ('env')
diff --git a/plugins/input/gdal/gdal_datasource.cpp b/plugins/input/gdal/gdal_datasource.cpp
index 187d6aa..8a06a92 100644
--- a/plugins/input/gdal/gdal_datasource.cpp
+++ b/plugins/input/gdal/gdal_datasource.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/gdal/gdal_datasource.hpp b/plugins/input/gdal/gdal_datasource.hpp
index f2403c3..7e7b221 100644
--- a/plugins/input/gdal/gdal_datasource.hpp
+++ b/plugins/input/gdal/gdal_datasource.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/gdal/gdal_featureset.cpp b/plugins/input/gdal/gdal_featureset.cpp
index 514b979..968fc6d 100644
--- a/plugins/input/gdal/gdal_featureset.cpp
+++ b/plugins/input/gdal/gdal_featureset.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/gdal/gdal_featureset.hpp b/plugins/input/gdal/gdal_featureset.hpp
index 04f24ed..b909211 100644
--- a/plugins/input/gdal/gdal_featureset.hpp
+++ b/plugins/input/gdal/gdal_featureset.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/geojson/build.py b/plugins/input/geojson/build.py
index faa3e9f..7435be5 100644
--- a/plugins/input/geojson/build.py
+++ b/plugins/input/geojson/build.py
@@ -1,7 +1,7 @@
 #
 # This file is part of Mapnik (c++ mapping toolkit)
 #
-# Copyright (C) 2013 Artem Pavlenko
+# Copyright (C) 2015 Artem Pavlenko
 #
 # Mapnik is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/geojson/geojson_datasource.cpp b/plugins/input/geojson/geojson_datasource.cpp
index c30d258..e1ebb47 100644
--- a/plugins/input/geojson/geojson_datasource.cpp
+++ b/plugins/input/geojson/geojson_datasource.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -30,6 +30,9 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
 #include <boost/algorithm/string.hpp>
 #include <boost/spirit/include/qi.hpp>
 #pragma GCC diagnostic pop
@@ -37,7 +40,7 @@
 // mapnik
 #include <mapnik/boolean.hpp>
 #include <mapnik/unicode.hpp>
-#include <mapnik/utils.hpp>
+#include <mapnik/util/utf_conv_win.hpp>
 #include <mapnik/feature.hpp>
 #include <mapnik/feature_factory.hpp>
 #include <mapnik/feature_kv_iterator.hpp>
@@ -55,7 +58,11 @@
 #include <mapnik/json/extract_bounding_box_grammar_impl.hpp>
 
 #if defined(SHAPE_MEMORY_MAPPED_FILE)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
 #include <boost/interprocess/mapped_region.hpp>
+#pragma GCC diagnostic pop
 #include <mapnik/mapped_memory_cache.hpp>
 #endif
 
@@ -210,12 +217,11 @@ void geojson_datasource::initialise_index(Iterator start, Iterator end)
             extent_ = box;
             // parse first feature to extract attributes schema.
             // NOTE: this doesn't yield correct answer for geoJSON in general, just an indication
-            Iterator itr = start + geometry_index.first;
-            Iterator end = itr + geometry_index.second;
+            Iterator itr2 = start + geometry_index.first;
+            Iterator end2 = itr2 + geometry_index.second;
             mapnik::context_ptr ctx = std::make_shared<mapnik::context_type>();
             mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx,1));
-            boost::spirit::standard::space_type space;
-            if (!boost::spirit::qi::phrase_parse(itr, end, (geojson_datasource_static_feature_grammar)(boost::phoenix::ref(*feature)), space))
+            if (!boost::spirit::qi::phrase_parse(itr2, end2, (geojson_datasource_static_feature_grammar)(boost::phoenix::ref(*feature)), space))
             {
                 throw std::runtime_error("Failed to parse geojson feature");
             }
@@ -351,13 +357,13 @@ boost::optional<mapnik::datasource_geometry_t> geojson_datasource::get_geometry_
             std::fread(json.data(), size, 1, file.get());
 
             using chr_iterator_type = char const*;
-            chr_iterator_type start = json.data();
-            chr_iterator_type end = start + json.size();
+            chr_iterator_type start2 = json.data();
+            chr_iterator_type end2 = start2 + json.size();
 
             using namespace boost::spirit;
             standard::space_type space;
             mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx,1));
-            if (!qi::phrase_parse(start, end, (geojson_datasource_static_feature_grammar)(boost::phoenix::ref(*feature)), space))
+            if (!qi::phrase_parse(start2, end2, (geojson_datasource_static_feature_grammar)(boost::phoenix::ref(*feature)), space))
             {
                 throw std::runtime_error("Failed to parse geojson feature");
             }
diff --git a/plugins/input/geojson/geojson_datasource.hpp b/plugins/input/geojson/geojson_datasource.hpp
index c9b320d..870f649 100644
--- a/plugins/input/geojson/geojson_datasource.hpp
+++ b/plugins/input/geojson/geojson_datasource.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -39,6 +39,9 @@
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wunused-variable"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/version.hpp>
 #include <boost/geometry/index/rtree.hpp>
 #pragma GCC diagnostic pop
diff --git a/plugins/input/geojson/geojson_featureset.cpp b/plugins/input/geojson/geojson_featureset.cpp
index 20fb415..1976f03 100644
--- a/plugins/input/geojson/geojson_featureset.cpp
+++ b/plugins/input/geojson/geojson_featureset.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/geojson/geojson_featureset.hpp b/plugins/input/geojson/geojson_featureset.hpp
index 1af2da7..e055b97 100644
--- a/plugins/input/geojson/geojson_featureset.hpp
+++ b/plugins/input/geojson/geojson_featureset.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/geojson/large_geojson_featureset.cpp b/plugins/input/geojson/large_geojson_featureset.cpp
index f3922b2..1df7dce 100644
--- a/plugins/input/geojson/large_geojson_featureset.cpp
+++ b/plugins/input/geojson/large_geojson_featureset.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -25,7 +25,7 @@
 #include <mapnik/feature_factory.hpp>
 #include <mapnik/json/geometry_grammar.hpp>
 #include <mapnik/json/feature_grammar.hpp>
-#include <mapnik/utils.hpp>
+#include <mapnik/util/utf_conv_win.hpp>
 // stl
 #include <string>
 #include <vector>
diff --git a/plugins/input/geojson/large_geojson_featureset.hpp b/plugins/input/geojson/large_geojson_featureset.hpp
index 71116ae..a67eec5 100644
--- a/plugins/input/geojson/large_geojson_featureset.hpp
+++ b/plugins/input/geojson/large_geojson_featureset.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/occi/build.py b/plugins/input/occi/build.py
index 4db36eb..e0aeb7b 100644
--- a/plugins/input/occi/build.py
+++ b/plugins/input/occi/build.py
@@ -1,7 +1,7 @@
 #
 # This file is part of Mapnik (c++ mapping toolkit)
 #
-# Copyright (C) 2013 Artem Pavlenko
+# Copyright (C) 2015 Artem Pavlenko
 #
 # Mapnik is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/occi/occi_datasource.cpp b/plugins/input/occi/occi_datasource.cpp
index fcfe785..1c28092 100644
--- a/plugins/input/occi/occi_datasource.cpp
+++ b/plugins/input/occi/occi_datasource.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/occi/occi_datasource.hpp b/plugins/input/occi/occi_datasource.hpp
index 27151ff..0affc33 100644
--- a/plugins/input/occi/occi_datasource.hpp
+++ b/plugins/input/occi/occi_datasource.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/occi/occi_featureset.cpp b/plugins/input/occi/occi_featureset.cpp
index 1c01140..0a0b942 100644
--- a/plugins/input/occi/occi_featureset.cpp
+++ b/plugins/input/occi/occi_featureset.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/occi/occi_featureset.hpp b/plugins/input/occi/occi_featureset.hpp
index 9203423..13445dd 100644
--- a/plugins/input/occi/occi_featureset.hpp
+++ b/plugins/input/occi/occi_featureset.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/occi/occi_types.cpp b/plugins/input/occi/occi_types.cpp
index 6fb69aa..4396706 100644
--- a/plugins/input/occi/occi_types.cpp
+++ b/plugins/input/occi/occi_types.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software, you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/occi/occi_types.hpp b/plugins/input/occi/occi_types.hpp
index 752246a..cc8cd41 100644
--- a/plugins/input/occi/occi_types.hpp
+++ b/plugins/input/occi/occi_types.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software, you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -25,7 +25,7 @@
 
 // mapnik
 #include <mapnik/debug.hpp>
-#include <mapnik/utils.hpp>
+#include <mapnik/util/singleton.hpp>
 
 // occi
 #include <occi.h>
diff --git a/plugins/input/ogr/build.py b/plugins/input/ogr/build.py
index 9c4101b..908cf19 100644
--- a/plugins/input/ogr/build.py
+++ b/plugins/input/ogr/build.py
@@ -1,7 +1,7 @@
 #
 # This file is part of Mapnik (c++ mapping toolkit)
 #
-# Copyright (C) 2013 Artem Pavlenko
+# Copyright (C) 2015 Artem Pavlenko
 #
 # Mapnik is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/ogr/ogr_converter.cpp b/plugins/input/ogr/ogr_converter.cpp
index 8f22aaf..f2eb602 100644
--- a/plugins/input/ogr/ogr_converter.cpp
+++ b/plugins/input/ogr/ogr_converter.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -107,8 +107,7 @@ mapnik::geometry::multi_line_string<double> ogr_converter::convert_multilinestri
     geom.reserve(num_geometries);
     for (int i = 0; i < num_geometries; ++i)
     {
-        geom.emplace_back(std::move(
-            convert_linestring(static_cast<OGRLineString*>(ogr_geom->getGeometryRef(i)))));
+        geom.emplace_back(convert_linestring(static_cast<OGRLineString*>(ogr_geom->getGeometryRef(i))));
     }
     return geom;
 }
@@ -150,8 +149,7 @@ mapnik::geometry::multi_polygon<double> ogr_converter::convert_multipolygon(OGRM
     geom.reserve(num_geometries);
     for (int i = 0; i < num_geometries; ++i)
     {
-        geom.emplace_back(std::move(
-            convert_polygon(static_cast<OGRPolygon*>(ogr_geom->getGeometryRef(i)))));
+        geom.emplace_back(convert_polygon(static_cast<OGRPolygon*>(ogr_geom->getGeometryRef(i))));
     }
     return geom;
 }
@@ -166,7 +164,7 @@ mapnik::geometry::geometry_collection<double> ogr_converter::convert_collection(
         OGRGeometry* g = ogr_geom->getGeometryRef(i);
         if (g != nullptr)
         {
-            geom.emplace_back(std::move(convert_geometry(g)));
+            geom.emplace_back(convert_geometry(g));
         }
     }
     return geom;
diff --git a/plugins/input/ogr/ogr_converter.hpp b/plugins/input/ogr/ogr_converter.hpp
index e3e2bb3..8b7f909 100644
--- a/plugins/input/ogr/ogr_converter.hpp
+++ b/plugins/input/ogr/ogr_converter.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/ogr/ogr_datasource.cpp b/plugins/input/ogr/ogr_datasource.cpp
index dc6247a..9e2b081 100644
--- a/plugins/input/ogr/ogr_datasource.cpp
+++ b/plugins/input/ogr/ogr_datasource.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -31,7 +31,7 @@
 #include <mapnik/boolean.hpp>
 #include <mapnik/geom_util.hpp>
 #include <mapnik/timer.hpp>
-#include <mapnik/utils.hpp>
+#include <mapnik/util/utf_conv_win.hpp>
 #include <mapnik/util/trim.hpp>
 
 // boost
@@ -330,7 +330,6 @@ void ogr_datasource::init(mapnik::parameters const& params)
 
             const std::string fld_name = fld->GetNameRef();
             const OGRFieldType type_oid = fld->GetType();
-
             switch (type_oid)
             {
             case OFTInteger:
diff --git a/plugins/input/ogr/ogr_datasource.hpp b/plugins/input/ogr/ogr_datasource.hpp
index ddd74b7..f98aebf 100644
--- a/plugins/input/ogr/ogr_datasource.hpp
+++ b/plugins/input/ogr/ogr_datasource.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -41,7 +41,10 @@
 #include <string>
 
 // ogr
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wshadow"
 #include <ogrsf_frmts.h>
+#pragma GCC diagnostic pop
 #include "ogr_layer_ptr.hpp"
 
 class ogr_datasource : public mapnik::datasource
diff --git a/plugins/input/ogr/ogr_featureset.cpp b/plugins/input/ogr/ogr_featureset.cpp
index 1a50024..3d46fcf 100644
--- a/plugins/input/ogr/ogr_featureset.cpp
+++ b/plugins/input/ogr/ogr_featureset.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -125,6 +125,9 @@ feature_ptr ogr_featureset::next()
             switch (type_oid)
             {
             case OFTInteger:
+#if GDAL_VERSION_MAJOR >= 2
+            case OFTInteger64:
+#endif
             {
                 feature->put<mapnik::value_integer>( fld_name, poFeature->GetFieldAsInteger(i));
                 break;
@@ -144,6 +147,9 @@ feature_ptr ogr_featureset::next()
             }
 
             case OFTIntegerList:
+#if GDAL_VERSION_MAJOR >= 2
+            case OFTInteger64List:
+#endif
             case OFTRealList:
             case OFTStringList:
             case OFTWideStringList: // deprecated !
diff --git a/plugins/input/ogr/ogr_featureset.hpp b/plugins/input/ogr/ogr_featureset.hpp
index 9dfd729..ca7a57a 100644
--- a/plugins/input/ogr/ogr_featureset.hpp
+++ b/plugins/input/ogr/ogr_featureset.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -29,11 +29,11 @@
 #include <mapnik/unicode.hpp>
 #include <mapnik/geom_util.hpp>
 
-// boost
-
-
 // ogr
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wshadow"
 #include <ogrsf_frmts.h>
+#pragma GCC diagnostic pop
 
 class ogr_featureset : public mapnik::Featureset
 {
diff --git a/plugins/input/ogr/ogr_index.hpp b/plugins/input/ogr/ogr_index.hpp
index b30c92a..e661d21 100644
--- a/plugins/input/ogr/ogr_index.hpp
+++ b/plugins/input/ogr/ogr_index.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/ogr/ogr_index_featureset.cpp b/plugins/input/ogr/ogr_index_featureset.cpp
index 265ded3..c59ef29 100644
--- a/plugins/input/ogr/ogr_index_featureset.cpp
+++ b/plugins/input/ogr/ogr_index_featureset.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -35,8 +35,12 @@
 // boost
 #ifdef SHAPE_MEMORY_MAPPED_FILE
 #include <mapnik/mapped_memory_cache.hpp>
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
 #include <boost/interprocess/mapped_region.hpp>
 #include <boost/interprocess/streams/bufferstream.hpp>
+#pragma GCC diagnostic pop
 #endif
 
 // ogr
diff --git a/plugins/input/ogr/ogr_index_featureset.hpp b/plugins/input/ogr/ogr_index_featureset.hpp
index 440743e..93d3a32 100644
--- a/plugins/input/ogr/ogr_index_featureset.hpp
+++ b/plugins/input/ogr/ogr_index_featureset.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/ogr/ogr_layer_ptr.hpp b/plugins/input/ogr/ogr_layer_ptr.hpp
index 07c55c3..28df28b 100644
--- a/plugins/input/ogr/ogr_layer_ptr.hpp
+++ b/plugins/input/ogr/ogr_layer_ptr.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/osm/basiccurl.cpp b/plugins/input/osm/basiccurl.cpp
index 77cab5e..fd83614 100755
--- a/plugins/input/osm/basiccurl.cpp
+++ b/plugins/input/osm/basiccurl.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/osm/build.py b/plugins/input/osm/build.py
index 3a0dffe..061fc85 100644
--- a/plugins/input/osm/build.py
+++ b/plugins/input/osm/build.py
@@ -1,7 +1,7 @@
 #
 # This file is part of Mapnik (c++ mapping toolkit)
 #
-# Copyright (C) 2013 Artem Pavlenko
+# Copyright (C) 2015 Artem Pavlenko
 #
 # Mapnik is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/osm/dataset_deliverer.cpp b/plugins/input/osm/dataset_deliverer.cpp
index 4920cab..6d7fe31 100644
--- a/plugins/input/osm/dataset_deliverer.cpp
+++ b/plugins/input/osm/dataset_deliverer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/osm/osm.cpp b/plugins/input/osm/osm.cpp
index f822a31..76d3bac 100644
--- a/plugins/input/osm/osm.cpp
+++ b/plugins/input/osm/osm.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/osm/osm_datasource.cpp b/plugins/input/osm/osm_datasource.cpp
index 3f52897..4bbe1bf 100644
--- a/plugins/input/osm/osm_datasource.cpp
+++ b/plugins/input/osm/osm_datasource.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/osm/osm_datasource.hpp b/plugins/input/osm/osm_datasource.hpp
index 3a2f0af..1bd8bb3 100644
--- a/plugins/input/osm/osm_datasource.hpp
+++ b/plugins/input/osm/osm_datasource.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/osm/osm_featureset.cpp b/plugins/input/osm/osm_featureset.cpp
index 71c44ec..46e7966 100644
--- a/plugins/input/osm/osm_featureset.cpp
+++ b/plugins/input/osm/osm_featureset.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/osm/osm_featureset.hpp b/plugins/input/osm/osm_featureset.hpp
index 48c0ff5..7eed2e6 100644
--- a/plugins/input/osm/osm_featureset.hpp
+++ b/plugins/input/osm/osm_featureset.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/pgraster/build.py b/plugins/input/pgraster/build.py
index 9f1f40f..9d26665 100644
--- a/plugins/input/pgraster/build.py
+++ b/plugins/input/pgraster/build.py
@@ -1,7 +1,7 @@
 #
 # This file is part of Mapnik (c++ mapping toolkit)
 #
-# Copyright (C) 2013 Artem Pavlenko
+# Copyright (C) 2015 Artem Pavlenko
 #
 # Mapnik is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/pgraster/pgraster_datasource.cpp b/plugins/input/pgraster/pgraster_datasource.cpp
index 9e393bc..fb2c4b0 100644
--- a/plugins/input/pgraster/pgraster_datasource.cpp
+++ b/plugins/input/pgraster/pgraster_datasource.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/pgraster/pgraster_datasource.hpp b/plugins/input/pgraster/pgraster_datasource.hpp
index 9d1931f..221f196 100644
--- a/plugins/input/pgraster/pgraster_datasource.hpp
+++ b/plugins/input/pgraster/pgraster_datasource.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/pgraster/pgraster_featureset.cpp b/plugins/input/pgraster/pgraster_featureset.cpp
index 3ab87bb..e2d4ccb 100644
--- a/plugins/input/pgraster/pgraster_featureset.cpp
+++ b/plugins/input/pgraster/pgraster_featureset.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/pgraster/pgraster_featureset.hpp b/plugins/input/pgraster/pgraster_featureset.hpp
index 55aba59..25319b3 100644
--- a/plugins/input/pgraster/pgraster_featureset.hpp
+++ b/plugins/input/pgraster/pgraster_featureset.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/pgraster/pgraster_wkb_reader.cpp b/plugins/input/pgraster/pgraster_wkb_reader.cpp
index 0e544f3..0320fe1 100644
--- a/plugins/input/pgraster/pgraster_wkb_reader.cpp
+++ b/plugins/input/pgraster/pgraster_wkb_reader.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -36,9 +36,7 @@
 #include <mapnik/util/conversions.hpp>
 #include <mapnik/util/trim.hpp>
 #include <mapnik/box2d.hpp> // for box2d
-
-// boost
-#include <boost/bind.hpp>
+#include <functional>
 
 #include <cstdint>
 
@@ -229,27 +227,27 @@ mapnik::raster_ptr pgraster_wkb_reader::read_indexed(mapnik::box2d<double> const
       // mapnik does not support signed anyway
     case PT_8BUI:
       return read_data_band(bbox, width_, height_, hasnodata,
-                     boost::bind(read_uint8, &ptr_));
+                     std::bind(read_uint8, &ptr_));
       break;
     case PT_16BSI:
       // mapnik does not support signed anyway
     case PT_16BUI:
       return read_data_band(bbox, width_, height_, hasnodata,
-                     boost::bind(read_uint16, &ptr_, endian_));
+                     std::bind(read_uint16, &ptr_, endian_));
       break;
     case PT_32BSI:
       // mapnik does not support signed anyway
     case PT_32BUI:
       return read_data_band(bbox, width_, height_, hasnodata,
-                     boost::bind(read_uint32, &ptr_, endian_));
+                     std::bind(read_uint32, &ptr_, endian_));
       break;
     case PT_32BF:
       return read_data_band(bbox, width_, height_, hasnodata,
-                     boost::bind(read_float32, &ptr_, endian_));
+                     std::bind(read_float32, &ptr_, endian_));
       break;
     case PT_64BF:
       return read_data_band(bbox, width_, height_, hasnodata,
-                     boost::bind(read_float64, &ptr_, endian_));
+                     std::bind(read_float64, &ptr_, endian_));
       break;
     default:
       std::ostringstream err;
@@ -320,19 +318,19 @@ mapnik::raster_ptr pgraster_wkb_reader::read_grayscale(mapnik::box2d<double> con
       // mapnik does not support signed anyway
     case PT_8BUI:
       return read_grayscale_band(bbox, width_, height_, hasnodata,
-                          boost::bind(read_uint8, &ptr_));
+                          std::bind(read_uint8, &ptr_));
       break;
     case PT_16BSI:
       // mapnik does not support signed anyway
     case PT_16BUI:
       return read_grayscale_band(bbox, width_, height_, hasnodata,
-                          boost::bind(read_uint16, &ptr_, endian_));
+                          std::bind(read_uint16, &ptr_, endian_));
       break;
     case PT_32BSI:
       // mapnik does not support signed anyway
     case PT_32BUI:
       return read_grayscale_band(bbox, width_, height_, hasnodata,
-                          boost::bind(read_uint32, &ptr_, endian_));
+                          std::bind(read_uint32, &ptr_, endian_));
       break;
     default:
       std::ostringstream err;
diff --git a/plugins/input/pgraster/pgraster_wkb_reader.hpp b/plugins/input/pgraster/pgraster_wkb_reader.hpp
index b0ec7f8..02a22bc 100644
--- a/plugins/input/pgraster/pgraster_wkb_reader.hpp
+++ b/plugins/input/pgraster/pgraster_wkb_reader.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/postgis/asyncresultset.hpp b/plugins/input/postgis/asyncresultset.hpp
index b1bc912..9c30d57 100644
--- a/plugins/input/postgis/asyncresultset.hpp
+++ b/plugins/input/postgis/asyncresultset.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
-  * Copyright (C) 2014 Artem Pavlenko
+  * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/postgis/build.py b/plugins/input/postgis/build.py
index 676fbf2..9b8ecd9 100644
--- a/plugins/input/postgis/build.py
+++ b/plugins/input/postgis/build.py
@@ -1,7 +1,7 @@
 #
 # This file is part of Mapnik (c++ mapping toolkit)
 #
-# Copyright (C) 2013 Artem Pavlenko
+# Copyright (C) 2015 Artem Pavlenko
 #
 # Mapnik is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/postgis/connection.hpp b/plugins/input/postgis/connection.hpp
index 18009e5..3d33a2d 100644
--- a/plugins/input/postgis/connection.hpp
+++ b/plugins/input/postgis/connection.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/postgis/connection_manager.hpp b/plugins/input/postgis/connection_manager.hpp
index 6427190..37c547f 100644
--- a/plugins/input/postgis/connection_manager.hpp
+++ b/plugins/input/postgis/connection_manager.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -27,7 +27,7 @@
 
 // mapnik
 #include <mapnik/pool.hpp>
-#include <mapnik/utils.hpp>
+#include <mapnik/util/singleton.hpp>
 
 // boost
 #include <memory>
diff --git a/plugins/input/postgis/cursorresultset.hpp b/plugins/input/postgis/cursorresultset.hpp
index fa071b3..63bb942 100644
--- a/plugins/input/postgis/cursorresultset.hpp
+++ b/plugins/input/postgis/cursorresultset.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/postgis/numeric2string.hpp b/plugins/input/postgis/numeric2string.hpp
index 0f988c9..76c204f 100644
--- a/plugins/input/postgis/numeric2string.hpp
+++ b/plugins/input/postgis/numeric2string.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/postgis/postgis_datasource.cpp b/plugins/input/postgis/postgis_datasource.cpp
index acb9655..9477c04 100644
--- a/plugins/input/postgis/postgis_datasource.cpp
+++ b/plugins/input/postgis/postgis_datasource.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/postgis/postgis_datasource.hpp b/plugins/input/postgis/postgis_datasource.hpp
index 7537bf6..84bcfe5 100644
--- a/plugins/input/postgis/postgis_datasource.hpp
+++ b/plugins/input/postgis/postgis_datasource.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/postgis/postgis_featureset.cpp b/plugins/input/postgis/postgis_featureset.cpp
index d256e86..9dda45d 100644
--- a/plugins/input/postgis/postgis_featureset.cpp
+++ b/plugins/input/postgis/postgis_featureset.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/postgis/postgis_featureset.hpp b/plugins/input/postgis/postgis_featureset.hpp
index 6f5fff4..1dc2b3f 100644
--- a/plugins/input/postgis/postgis_featureset.hpp
+++ b/plugins/input/postgis/postgis_featureset.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/postgis/resultset.hpp b/plugins/input/postgis/resultset.hpp
index b93ce64..915a596 100644
--- a/plugins/input/postgis/resultset.hpp
+++ b/plugins/input/postgis/resultset.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/raster/build.py b/plugins/input/raster/build.py
index 20f65b2..324a2a9 100644
--- a/plugins/input/raster/build.py
+++ b/plugins/input/raster/build.py
@@ -1,7 +1,7 @@
 #
 # This file is part of Mapnik (c++ mapping toolkit)
 #
-# Copyright (C) 2013 Artem Pavlenko
+# Copyright (C) 2015 Artem Pavlenko
 #
 # Mapnik is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/raster/raster_datasource.cpp b/plugins/input/raster/raster_datasource.cpp
index e1a7c29..96f5938 100644
--- a/plugins/input/raster/raster_datasource.cpp
+++ b/plugins/input/raster/raster_datasource.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/raster/raster_datasource.hpp b/plugins/input/raster/raster_datasource.hpp
index 0cb7ad4..7ff0990 100644
--- a/plugins/input/raster/raster_datasource.hpp
+++ b/plugins/input/raster/raster_datasource.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/raster/raster_featureset.cpp b/plugins/input/raster/raster_featureset.cpp
index 4bf9557..93f4b8d 100644
--- a/plugins/input/raster/raster_featureset.cpp
+++ b/plugins/input/raster/raster_featureset.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/raster/raster_featureset.hpp b/plugins/input/raster/raster_featureset.hpp
index fed7bba..0076892 100644
--- a/plugins/input/raster/raster_featureset.hpp
+++ b/plugins/input/raster/raster_featureset.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/raster/raster_info.cpp b/plugins/input/raster/raster_info.cpp
index 9b04983..54b17c4 100644
--- a/plugins/input/raster/raster_info.cpp
+++ b/plugins/input/raster/raster_info.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/raster/raster_info.hpp b/plugins/input/raster/raster_info.hpp
index 2bf5ba9..f020842 100644
--- a/plugins/input/raster/raster_info.hpp
+++ b/plugins/input/raster/raster_info.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/rasterlite/build.py b/plugins/input/rasterlite/build.py
index 7100b1e..779a489 100644
--- a/plugins/input/rasterlite/build.py
+++ b/plugins/input/rasterlite/build.py
@@ -1,7 +1,7 @@
 #
 # This file is part of Mapnik (c++ mapping toolkit)
 #
-# Copyright (C) 2013 Artem Pavlenko
+# Copyright (C) 2015 Artem Pavlenko
 #
 # Mapnik is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/rasterlite/rasterlite_datasource.cpp b/plugins/input/rasterlite/rasterlite_datasource.cpp
index f370f19..0261018 100644
--- a/plugins/input/rasterlite/rasterlite_datasource.cpp
+++ b/plugins/input/rasterlite/rasterlite_datasource.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/rasterlite/rasterlite_datasource.hpp b/plugins/input/rasterlite/rasterlite_datasource.hpp
index dcb1a13..dd30446 100644
--- a/plugins/input/rasterlite/rasterlite_datasource.hpp
+++ b/plugins/input/rasterlite/rasterlite_datasource.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/rasterlite/rasterlite_featureset.cpp b/plugins/input/rasterlite/rasterlite_featureset.cpp
index 97912b7..270a87e 100644
--- a/plugins/input/rasterlite/rasterlite_featureset.cpp
+++ b/plugins/input/rasterlite/rasterlite_featureset.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/rasterlite/rasterlite_featureset.hpp b/plugins/input/rasterlite/rasterlite_featureset.hpp
index cf7973f..cb251c8 100644
--- a/plugins/input/rasterlite/rasterlite_featureset.hpp
+++ b/plugins/input/rasterlite/rasterlite_featureset.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/rasterlite/rasterlite_include.hpp b/plugins/input/rasterlite/rasterlite_include.hpp
index 4662e84..b6a9dd2 100644
--- a/plugins/input/rasterlite/rasterlite_include.hpp
+++ b/plugins/input/rasterlite/rasterlite_include.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/shape/build.py b/plugins/input/shape/build.py
index 4ef3368..097d602 100644
--- a/plugins/input/shape/build.py
+++ b/plugins/input/shape/build.py
@@ -1,7 +1,7 @@
 #
 # This file is part of Mapnik (c++ mapping toolkit)
 #
-# Copyright (C) 2013 Artem Pavlenko
+# Copyright (C) 2015 Artem Pavlenko
 #
 # Mapnik is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/shape/dbf_test.cpp b/plugins/input/shape/dbf_test.cpp
index b9917a9..c5e22f5 100644
--- a/plugins/input/shape/dbf_test.cpp
+++ b/plugins/input/shape/dbf_test.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/shape/dbfile.cpp b/plugins/input/shape/dbfile.cpp
index 5b1c76e..9211657 100644
--- a/plugins/input/shape/dbfile.cpp
+++ b/plugins/input/shape/dbfile.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -22,7 +22,7 @@
 // mapnik
 #include <mapnik/value_types.hpp>
 #include <mapnik/global.hpp>
-#include <mapnik/utils.hpp>
+#include <mapnik/util/utf_conv_win.hpp>
 #include <mapnik/unicode.hpp>
 #include <mapnik/util/trim.hpp>
 
@@ -32,6 +32,9 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
 #include <boost/spirit/include/qi.hpp>
 #ifdef SHAPE_MEMORY_MAPPED_FILE
 #include <boost/interprocess/mapped_region.hpp>
@@ -190,7 +193,7 @@ void dbf_file::add_attribute(int col, mapnik::transcoder const& tr, mapnik::feat
                 const char *itr = record_+fields_[col].offset_;
                 const char *end = itr + fields_[col].length_;
                 ascii::space_type space;
-                qi::double_type double_;
+                static qi::double_type double_;
                 if (qi::phrase_parse(itr,end,double_,space,val))
                 {
                     f.put(name,val);
@@ -202,8 +205,8 @@ void dbf_file::add_attribute(int col, mapnik::transcoder const& tr, mapnik::feat
                 const char *itr = record_+fields_[col].offset_;
                 const char *end = itr + fields_[col].length_;
                 ascii::space_type space;
-                qi::int_type int_;
-                if (qi::phrase_parse(itr,end,int_,space,val))
+                static qi::int_parser<mapnik::value_integer,10,1,-1> numeric_parser;
+                if (qi::phrase_parse(itr, end, numeric_parser, space, val))
                 {
                     f.put(name,val);
                 }
diff --git a/plugins/input/shape/dbfile.hpp b/plugins/input/shape/dbfile.hpp
index 75e77d3..358d737 100644
--- a/plugins/input/shape/dbfile.hpp
+++ b/plugins/input/shape/dbfile.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -29,11 +29,11 @@
 #include <mapnik/unicode.hpp>
 #ifdef SHAPE_MEMORY_MAPPED_FILE
 #include <mapnik/mapped_memory_cache.hpp>
-#endif
-
-
-// boost
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wshadow"
 #include <boost/interprocess/streams/bufferstream.hpp>
+#pragma GCC diagnostic pop
+#endif
 
 // stl
 #include <vector>
diff --git a/plugins/input/shape/shape_datasource.cpp b/plugins/input/shape/shape_datasource.cpp
index 152e107..05e24a4 100644
--- a/plugins/input/shape/shape_datasource.cpp
+++ b/plugins/input/shape/shape_datasource.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -37,7 +37,7 @@
 #include <mapnik/make_unique.hpp>
 #include <mapnik/util/fs.hpp>
 #include <mapnik/global.hpp>
-#include <mapnik/utils.hpp>
+#include <mapnik/util/utf_conv_win.hpp>
 #include <mapnik/boolean.hpp>
 #include <mapnik/util/conversions.hpp>
 #include <mapnik/geom_util.hpp>
diff --git a/plugins/input/shape/shape_datasource.hpp b/plugins/input/shape/shape_datasource.hpp
index 586496b..f702036 100644
--- a/plugins/input/shape/shape_datasource.hpp
+++ b/plugins/input/shape/shape_datasource.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/shape/shape_featureset.cpp b/plugins/input/shape/shape_featureset.cpp
index 6367cbf..8a2b164 100644
--- a/plugins/input/shape/shape_featureset.cpp
+++ b/plugins/input/shape/shape_featureset.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/shape/shape_featureset.hpp b/plugins/input/shape/shape_featureset.hpp
index 4ce235e..a047bae 100644
--- a/plugins/input/shape/shape_featureset.hpp
+++ b/plugins/input/shape/shape_featureset.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/shape/shape_index_featureset.cpp b/plugins/input/shape/shape_index_featureset.cpp
index 89628fa..fdd7513 100644
--- a/plugins/input/shape/shape_index_featureset.cpp
+++ b/plugins/input/shape/shape_index_featureset.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/shape/shape_index_featureset.hpp b/plugins/input/shape/shape_index_featureset.hpp
index d62d8ed..cf52aa0 100644
--- a/plugins/input/shape/shape_index_featureset.hpp
+++ b/plugins/input/shape/shape_index_featureset.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/shape/shape_io.cpp b/plugins/input/shape/shape_io.cpp
index 889fe28..7f14982 100644
--- a/plugins/input/shape/shape_io.cpp
+++ b/plugins/input/shape/shape_io.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -109,12 +109,9 @@ mapnik::geometry::geometry<double> shape_io::read_polyline(shape_file::record_ty
     }
     else
     {
-        std::vector<int> parts(num_parts);
-        for (int i = 0; i < num_parts; ++i)
-        {
-            parts[i] = record.read_ndr_integer();
-        }
-
+        std::vector<int> parts;
+        parts.resize(num_parts);
+        std::for_each(parts.begin(), parts.end(), [&](int & part) { part = record.read_ndr_integer();});
         int start, end;
         mapnik::geometry::multi_line_string<double> multi_line;
         for (int k = 0; k < num_parts; ++k)
@@ -151,21 +148,18 @@ mapnik::geometry::geometry<double> shape_io::read_polygon(shape_file::record_typ
     int num_parts = record.read_ndr_integer();
     int num_points = record.read_ndr_integer();
 
-    std::vector<int> parts(num_parts);
-
-    for (int i = 0; i < num_parts; ++i)
-    {
-        parts[i] = record.read_ndr_integer();
-    }
-
-    mapnik::geometry::multi_polygon<double> multi_poly;
+    std::vector<int> parts;
+    parts.resize(num_parts);
+    std::for_each(parts.begin(), parts.end(), [&](int & part) { part = record.read_ndr_integer();});
     mapnik::geometry::polygon<double> poly;
+    mapnik::geometry::multi_polygon<double> multi_poly;
     for (int k = 0; k < num_parts; ++k)
     {
         int start = parts[k];
         int end;
         if (k == num_parts - 1) end = num_points;
         else end = parts[k + 1];
+
         mapnik::geometry::linear_ring<double> ring;
         ring.reserve(end - start);
         for (int j = start; j < end; ++j)
@@ -189,11 +183,14 @@ mapnik::geometry::geometry<double> shape_io::read_polygon(shape_file::record_typ
             poly.add_hole(std::move(ring));
         }
     }
+
     if (multi_poly.size() > 0) // multi
     {
         multi_poly.emplace_back(std::move(poly));
         geom = std::move(multi_poly);
-    } else {
+    }
+    else
+    {
         geom = std::move(poly);
     }
     mapnik::geometry::correct(geom);
diff --git a/plugins/input/shape/shape_io.hpp b/plugins/input/shape/shape_io.hpp
index ebf31da..497dbda 100644
--- a/plugins/input/shape/shape_io.hpp
+++ b/plugins/input/shape/shape_io.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/shape/shape_utils.cpp b/plugins/input/shape/shape_utils.cpp
index 9495fda..af7aa53 100644
--- a/plugins/input/shape/shape_utils.cpp
+++ b/plugins/input/shape/shape_utils.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/shape/shape_utils.hpp b/plugins/input/shape/shape_utils.hpp
index eda62a8..edb2222 100644
--- a/plugins/input/shape/shape_utils.hpp
+++ b/plugins/input/shape/shape_utils.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/shape/shapefile.hpp b/plugins/input/shape/shapefile.hpp
index 3e35544..3f70e3a 100644
--- a/plugins/input/shape/shapefile.hpp
+++ b/plugins/input/shape/shapefile.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -31,12 +31,16 @@
 
 // mapnik
 #include <mapnik/global.hpp>
-#include <mapnik/utils.hpp>
+#include <mapnik/util/utf_conv_win.hpp>
 #include <mapnik/box2d.hpp>
 #ifdef SHAPE_MEMORY_MAPPED_FILE
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
 #include <boost/interprocess/mapped_region.hpp>
-#include <mapnik/mapped_memory_cache.hpp>
 #include <boost/interprocess/streams/bufferstream.hpp>
+#pragma GCC diagnostic pop
+#include <mapnik/mapped_memory_cache.hpp>
 #endif
 #include <mapnik/util/noncopyable.hpp>
 
@@ -72,8 +76,8 @@ template <typename Tag>
 struct shape_record
 {
     typename Tag::data_type data;
-    size_t size;
-    mutable size_t pos;
+    std::size_t size;
+    mutable std::size_t pos;
 
     explicit shape_record(size_t size_)
         : data(Tag::alloc(size_)),
@@ -129,6 +133,8 @@ struct shape_record
     {
         return (size - pos);
     }
+
+    std::size_t length() {return size;}
 };
 
 class shape_file : mapnik::util::noncopyable
diff --git a/plugins/input/shape/shp_index.hpp b/plugins/input/shape/shp_index.hpp
index bb033e9..6c32305 100644
--- a/plugins/input/shape/shp_index.hpp
+++ b/plugins/input/shape/shp_index.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/sqlite/build.py b/plugins/input/sqlite/build.py
index 3136dca..b3a4a3e 100644
--- a/plugins/input/sqlite/build.py
+++ b/plugins/input/sqlite/build.py
@@ -1,7 +1,7 @@
 #
 # This file is part of Mapnik (c++ mapping toolkit)
 #
-# Copyright (C) 2013 Artem Pavlenko
+# Copyright (C) 2015 Artem Pavlenko
 #
 # Mapnik is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/sqlite/sqlite_connection.hpp b/plugins/input/sqlite/sqlite_connection.hpp
index c7bd11f..27a2fe2 100644
--- a/plugins/input/sqlite/sqlite_connection.hpp
+++ b/plugins/input/sqlite/sqlite_connection.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/sqlite/sqlite_datasource.cpp b/plugins/input/sqlite/sqlite_datasource.cpp
index 9c837bd..036e31a 100644
--- a/plugins/input/sqlite/sqlite_datasource.cpp
+++ b/plugins/input/sqlite/sqlite_datasource.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/sqlite/sqlite_datasource.hpp b/plugins/input/sqlite/sqlite_datasource.hpp
index ae21326..eab71e9 100644
--- a/plugins/input/sqlite/sqlite_datasource.hpp
+++ b/plugins/input/sqlite/sqlite_datasource.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/sqlite/sqlite_featureset.cpp b/plugins/input/sqlite/sqlite_featureset.cpp
index e6ee0d4..99a44db 100644
--- a/plugins/input/sqlite/sqlite_featureset.cpp
+++ b/plugins/input/sqlite/sqlite_featureset.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/sqlite/sqlite_featureset.hpp b/plugins/input/sqlite/sqlite_featureset.hpp
index 12f3ee0..dc16867 100644
--- a/plugins/input/sqlite/sqlite_featureset.hpp
+++ b/plugins/input/sqlite/sqlite_featureset.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/sqlite/sqlite_prepared.hpp b/plugins/input/sqlite/sqlite_prepared.hpp
index cf81842..db1355d 100644
--- a/plugins/input/sqlite/sqlite_prepared.hpp
+++ b/plugins/input/sqlite/sqlite_prepared.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/sqlite/sqlite_resultset.hpp b/plugins/input/sqlite/sqlite_resultset.hpp
index aebd031..6046387 100644
--- a/plugins/input/sqlite/sqlite_resultset.hpp
+++ b/plugins/input/sqlite/sqlite_resultset.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/sqlite/sqlite_utils.hpp b/plugins/input/sqlite/sqlite_utils.hpp
index b38dd06..c96f640 100644
--- a/plugins/input/sqlite/sqlite_utils.hpp
+++ b/plugins/input/sqlite/sqlite_utils.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -31,7 +31,6 @@
 
 // mapnik
 #include <mapnik/debug.hpp>
-#include <mapnik/utils.hpp>
 #include <mapnik/datasource.hpp>
 #include <mapnik/params.hpp>
 #include <mapnik/sql_utils.hpp>
diff --git a/plugins/input/topojson/build.py b/plugins/input/topojson/build.py
index 19abd86..9f7b955 100644
--- a/plugins/input/topojson/build.py
+++ b/plugins/input/topojson/build.py
@@ -1,7 +1,7 @@
 #
 # This file is part of Mapnik (c++ mapping toolkit)
 #
-# Copyright (C) 2013 Artem Pavlenko
+# Copyright (C) 2015 Artem Pavlenko
 #
 # Mapnik is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/topojson/topojson_datasource.cpp b/plugins/input/topojson/topojson_datasource.cpp
index cd9c327..225a767 100644
--- a/plugins/input/topojson/topojson_datasource.cpp
+++ b/plugins/input/topojson/topojson_datasource.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/plugins/input/topojson/topojson_datasource.hpp b/plugins/input/topojson/topojson_datasource.hpp
index fff936d..214d40e 100644
--- a/plugins/input/topojson/topojson_datasource.hpp
+++ b/plugins/input/topojson/topojson_datasource.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -39,6 +39,9 @@
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wunused-variable"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/geometry/geometries/geometries.hpp>
 #include <boost/geometry.hpp>
 #include <boost/version.hpp>
diff --git a/plugins/input/topojson/topojson_featureset.cpp b/plugins/input/topojson/topojson_featureset.cpp
index ed53932..b82304b 100644
--- a/plugins/input/topojson/topojson_featureset.cpp
+++ b/plugins/input/topojson/topojson_featureset.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -132,8 +132,8 @@ struct feature_generator
         {
             index_type index = line.ring;
             index_type arc_index = index < 0 ? std::abs(index) - 1 : index;
-            if (arc_index < num_arcs_)
-            {            
+            if (arc_index >= 0 && arc_index < static_cast<int>(num_arcs_))
+            {
                 auto const& arcs = topo_.arcs[arc_index];
                 double px = 0, py = 0;
                 mapnik::geometry::line_string<double> line_string;
@@ -168,7 +168,7 @@ struct feature_generator
             for (auto const& index : multi_line.rings)
             {
                 index_type arc_index = index < 0 ? std::abs(index) - 1 : index;
-                if (arc_index < num_arcs_)
+                if (arc_index >= 0 && arc_index < static_cast<int>(num_arcs_))
                 {
                     hit = true;
                     double px = 0, py = 0;
@@ -192,7 +192,7 @@ struct feature_generator
             if (hit)
             {
                 feature->set_geometry(std::move(multi_line_string));
-                assign_properties(*feature, multi_line, tr_);                
+                assign_properties(*feature, multi_line, tr_);
             }
         }
         return feature;
@@ -216,7 +216,7 @@ struct feature_generator
                     double px = 0, py = 0;
                     bool reverse = index < 0;
                     index_type arc_index = reverse ? std::abs(index) - 1 : index;
-                    if (arc_index < num_arcs_)
+                    if (arc_index >= 0 && arc_index < static_cast<int>(num_arcs_))
                     {
                         hit = true;
                         auto const& arcs = topo_.arcs[arc_index];
@@ -267,7 +267,7 @@ struct feature_generator
             {
                 mapnik::geometry::correct(polygon);
                 feature->set_geometry(std::move(polygon));
-                assign_properties(*feature, poly, tr_);                
+                assign_properties(*feature, poly, tr_);
             }
         }
         return feature;
@@ -296,7 +296,7 @@ struct feature_generator
                         double px = 0, py = 0;
                         bool reverse = index < 0;
                         index_type arc_index = reverse ? std::abs(index) - 1 : index;
-                        if (arc_index < num_arcs_)
+                        if (arc_index >= 0 && arc_index < static_cast<int>(num_arcs_))
                         {
                             hit = true;
                             auto const& arcs = topo_.arcs[arc_index];
@@ -350,7 +350,7 @@ struct feature_generator
             {
                 mapnik::geometry::correct(multi_polygon);
                 feature->set_geometry(std::move(multi_polygon));
-                assign_properties(*feature, multi_poly, tr_);                
+                assign_properties(*feature, multi_poly, tr_);
             }
         }
         return feature;
diff --git a/plugins/input/topojson/topojson_featureset.hpp b/plugins/input/topojson/topojson_featureset.hpp
index f6dc224..44f8335 100644
--- a/plugins/input/topojson/topojson_featureset.hpp
+++ b/plugins/input/topojson/topojson_featureset.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/agg/agg_renderer.cpp b/src/agg/agg_renderer.cpp
index 67723d0..56e1710 100644
--- a/src/agg/agg_renderer.cpp
+++ b/src/agg/agg_renderer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -128,16 +128,16 @@ struct setup_agg_bg_visitor
     void operator() (marker_rgba8 const& marker)
     {
         mapnik::image_rgba8 const& bg_image = marker.get_data();
-        int w = bg_image.width();
-        int h = bg_image.height();
+        std::size_t w = bg_image.width();
+        std::size_t h = bg_image.height();
         if ( w > 0 && h > 0)
         {
             // repeat background-image both vertically and horizontally
-            unsigned x_steps = static_cast<unsigned>(std::ceil(common_.width_/double(w)));
-            unsigned y_steps = static_cast<unsigned>(std::ceil(common_.height_/double(h)));
-            for (unsigned x=0;x<x_steps;++x)
+            std::size_t x_steps = static_cast<std::size_t>(std::ceil(common_.width_/double(w)));
+            std::size_t y_steps = static_cast<std::size_t>(std::ceil(common_.height_/double(h)));
+            for (std::size_t x=0;x<x_steps;++x)
             {
-                for (unsigned y=0;y<y_steps;++y)
+                for (std::size_t y=0;y<y_steps;++y)
                 {
                     composite(pixmap_, bg_image, mode_, opacity_, x*w, y*h);
                 }
diff --git a/src/agg/process_building_symbolizer.cpp b/src/agg/process_building_symbolizer.cpp
index 8bbdbd4..aabba77 100644
--- a/src/agg/process_building_symbolizer.cpp
+++ b/src/agg/process_building_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/agg/process_debug_symbolizer.cpp b/src/agg/process_debug_symbolizer.cpp
index 9f03639..c56add9 100644
--- a/src/agg/process_debug_symbolizer.cpp
+++ b/src/agg/process_debug_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -214,6 +214,14 @@ void agg_renderer<T0,T1>::process(debug_symbolizer const& sym,
 
     debug_symbolizer_mode_enum mode = get<debug_symbolizer_mode_enum>(sym, keys::mode, feature, common_.vars_, DEBUG_SYM_MODE_COLLISION);
 
+    ras_ptr->reset();
+    if (gamma_method_ != GAMMA_POWER || gamma_ != 1.0)
+    {
+        ras_ptr->gamma(agg::gamma_power());
+        gamma_method_ = GAMMA_POWER;
+        gamma_ = 1.0;
+    }
+
     if (mode == DEBUG_SYM_MODE_RINGS)
     {
         RingRenderer<buffer_type> renderer(*ras_ptr,*current_buffer_,common_.t_,prj_trans);
@@ -222,11 +230,9 @@ void agg_renderer<T0,T1>::process(debug_symbolizer const& sym,
     }
     else if (mode == DEBUG_SYM_MODE_COLLISION)
     {
-        typename detector_type::query_iterator itr = common_.detector_->begin();
-        typename detector_type::query_iterator end = common_.detector_->end();
-        for ( ;itr!=end; ++itr)
+        for (auto const& n : *common_.detector_)
         {
-            draw_rect(pixmap_, itr->box);
+            draw_rect(pixmap_, n.get().box);
         }
     }
     else if (mode == DEBUG_SYM_MODE_VERTEX)
diff --git a/src/agg/process_dot_symbolizer.cpp b/src/agg/process_dot_symbolizer.cpp
index 8e19aa9..322bfea 100644
--- a/src/agg/process_dot_symbolizer.cpp
+++ b/src/agg/process_dot_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -111,6 +111,12 @@ void agg_renderer<T0,T1>::process(dot_symbolizer const& sym,
     double opacity = get<double>(sym, keys::opacity, feature, common_.vars_, 1.0);
     color const& fill = get<mapnik::color>(sym, keys::fill, feature, common_.vars_, mapnik::color(128,128,128));
     ras_ptr->reset();
+    if (gamma_method_ != GAMMA_POWER || gamma_ != 1.0)
+    {
+        ras_ptr->gamma(agg::gamma_power());
+        gamma_method_ = GAMMA_POWER;
+        gamma_ = 1.0;
+    }
     agg::rendering_buffer buf(current_buffer_->bytes(),current_buffer_->width(),current_buffer_->height(),current_buffer_->row_size());
     using blender_type = agg::comp_op_adaptor_rgba_pre<agg::rgba8, agg::order_rgba>;
     using pixfmt_comp_type = agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer>;
diff --git a/src/agg/process_group_symbolizer.cpp b/src/agg/process_group_symbolizer.cpp
index a0cf894..68c54f2 100644
--- a/src/agg/process_group_symbolizer.cpp
+++ b/src/agg/process_group_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -120,7 +120,7 @@ struct thunk_renderer<image_rgba8>
         render_offset_placements(
             thunk.placements_,
             offset_,
-            [&] (glyph_positions_ptr glyphs)
+            [&] (glyph_positions_ptr const& glyphs)
             {
                 marker_info_ptr mark = glyphs->get_marker();
                 if (mark)
diff --git a/src/agg/process_line_pattern_symbolizer.cpp b/src/agg/process_line_pattern_symbolizer.cpp
index 03ce251..7cdd166 100644
--- a/src/agg/process_line_pattern_symbolizer.cpp
+++ b/src/agg/process_line_pattern_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -108,7 +108,9 @@ struct agg_renderer_process_visitor_l
         pattern_source source(image, opacity);
         pattern_type pattern (filter,source);
         renderer_type ren(ren_base, pattern);
-        ren.clip_box(0,0,common_.width_,common_.height_);
+        double half_stroke = std::max(marker.width()/2.0,marker.height()/2.0);
+        int rast_clip_padding = static_cast<int>(std::round(half_stroke));
+        ren.clip_box(-rast_clip_padding,-rast_clip_padding,common_.width_+rast_clip_padding,common_.height_+rast_clip_padding);
         rasterizer_type ras(ren);
 
         agg::trans_affine tr;
@@ -119,7 +121,6 @@ struct agg_renderer_process_visitor_l
         if (clip)
         {
             double padding = (double)(common_.query_extent_.width()/pixmap_.width());
-            double half_stroke = marker.width()/2.0;
             if (half_stroke > 1)
                 padding *= half_stroke;
             if (std::fabs(offset) > 0)
@@ -177,7 +178,9 @@ struct agg_renderer_process_visitor_l
         pattern_source source(image, opacity);
         pattern_type pattern (filter,source);
         renderer_type ren(ren_base, pattern);
-        ren.clip_box(0,0,common_.width_,common_.height_);
+        double half_stroke = std::max(marker.width()/2.0,marker.height()/2.0);
+        int rast_clip_padding = static_cast<int>(std::round(half_stroke));
+        ren.clip_box(-rast_clip_padding,-rast_clip_padding,common_.width_+rast_clip_padding,common_.height_+rast_clip_padding);
         rasterizer_type ras(ren);
 
         agg::trans_affine tr;
@@ -188,7 +191,6 @@ struct agg_renderer_process_visitor_l
         if (clip)
         {
             double padding = (double)(common_.query_extent_.width()/pixmap_.width());
-            double half_stroke = marker.width()/2.0;
             if (half_stroke > 1)
                 padding *= half_stroke;
             if (std::fabs(offset) > 0)
@@ -235,6 +237,13 @@ void  agg_renderer<T0,T1>::process(line_pattern_symbolizer const& sym,
 
     std::string filename = get<std::string, keys::file>(sym, feature, common_.vars_);
     if (filename.empty()) return;
+    ras_ptr->reset();
+    if (gamma_method_ != GAMMA_POWER || gamma_ != 1.0)
+    {
+        ras_ptr->gamma(agg::gamma_power());
+        gamma_method_ = GAMMA_POWER;
+        gamma_ = 1.0;
+    }
     std::shared_ptr<mapnik::marker const> marker = marker_cache::instance().find(filename, true);
     agg_renderer_process_visitor_l<buffer_type> visitor(common_,
                                          pixmap_,
diff --git a/src/agg/process_line_symbolizer.cpp b/src/agg/process_line_symbolizer.cpp
index 7397141..b3a01c7 100644
--- a/src/agg/process_line_symbolizer.cpp
+++ b/src/agg/process_line_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -31,6 +31,7 @@
 #include <mapnik/vertex_processor.hpp>
 #include <mapnik/renderer_common/clipping_extent.hpp>
 #include <mapnik/renderer_common/apply_vertex_converter.hpp>
+#include <mapnik/geometry_type.hpp>
 // agg
 #include "agg_basics.h"
 #include "agg_rendering_buffer.h"
@@ -164,12 +165,19 @@ void agg_renderer<T0,T1>::process(line_symbolizer const& sym,
         rasterizer_type ras(ren);
         set_join_caps_aa(sym, ras, feature, common_.vars_);
 
-        using vertex_converter_type = vertex_converter<clip_line_tag, transform_tag,
+        using vertex_converter_type = vertex_converter<clip_line_tag, clip_poly_tag, transform_tag,
                                                        affine_transform_tag,
                                                        simplify_tag, smooth_tag,
                                                        offset_transform_tag>;
         vertex_converter_type converter(clip_box,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_);
-        if (clip) converter.set<clip_line_tag>(); // optional clip (default: true)
+        if (clip)
+        {
+            geometry::geometry_types type = geometry::geometry_type(feature.get_geometry());
+            if (type == geometry::geometry_types::Polygon || type == geometry::geometry_types::MultiPolygon)
+                converter.template set<clip_poly_tag>();
+            else if (type == geometry::geometry_types::LineString || type == geometry::geometry_types::MultiLineString)
+                converter.template set<clip_line_tag>();
+        }
         converter.set<transform_tag>(); // always transform
         if (std::fabs(offset) > 0.0) converter.set<offset_transform_tag>(); // parallel offset
         converter.set<affine_transform_tag>(); // optional affine transform
@@ -183,14 +191,20 @@ void agg_renderer<T0,T1>::process(line_symbolizer const& sym,
     }
     else
     {
-        using vertex_converter_type = vertex_converter<clip_line_tag, transform_tag,
+        using vertex_converter_type = vertex_converter<clip_line_tag, clip_poly_tag, transform_tag,
                                                        affine_transform_tag,
                                                        simplify_tag, smooth_tag,
                                                        offset_transform_tag,
                                                        dash_tag, stroke_tag>;
         vertex_converter_type converter(clip_box, sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_);
-
-        if (clip) converter.set<clip_line_tag>(); // optional clip (default: true)
+        if (clip)
+        {
+            geometry::geometry_types type = geometry::geometry_type(feature.get_geometry());
+            if (type == geometry::geometry_types::Polygon || type == geometry::geometry_types::MultiPolygon)
+                converter.template set<clip_poly_tag>();
+            else if (type == geometry::geometry_types::LineString || type == geometry::geometry_types::MultiLineString)
+                converter.template set<clip_line_tag>();
+        }
         converter.set<transform_tag>(); // always transform
         if (std::fabs(offset) > 0.0) converter.set<offset_transform_tag>(); // parallel offset
         converter.set<affine_transform_tag>(); // optional affine transform
diff --git a/src/agg/process_markers_symbolizer.cpp b/src/agg/process_markers_symbolizer.cpp
index 27489d3..ab06ed3 100644
--- a/src/agg/process_markers_symbolizer.cpp
+++ b/src/agg/process_markers_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/agg/process_point_symbolizer.cpp b/src/agg/process_point_symbolizer.cpp
index cabae6d..8dc40f1 100644
--- a/src/agg/process_point_symbolizer.cpp
+++ b/src/agg/process_point_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/agg/process_polygon_pattern_symbolizer.cpp b/src/agg/process_polygon_pattern_symbolizer.cpp
index a69d266..386adee 100644
--- a/src/agg/process_polygon_pattern_symbolizer.cpp
+++ b/src/agg/process_polygon_pattern_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/agg/process_polygon_symbolizer.cpp b/src/agg/process_polygon_symbolizer.cpp
index 31a61d3..9af6d4a 100644
--- a/src/agg/process_polygon_symbolizer.cpp
+++ b/src/agg/process_polygon_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/agg/process_raster_symbolizer.cpp b/src/agg/process_raster_symbolizer.cpp
index 7d5cd4b..0105e9b 100644
--- a/src/agg/process_raster_symbolizer.cpp
+++ b/src/agg/process_raster_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -51,7 +51,7 @@ void agg_renderer<T0,T1>::process(raster_symbolizer const& sym,
 {
     render_raster_symbolizer(
         sym, feature, prj_trans, common_,
-        [&](image_rgba8 & target, composite_mode_e comp_op, double opacity,
+        [&](image_rgba8 const & target, composite_mode_e comp_op, double opacity,
             int start_x, int start_y) {
             composite(*current_buffer_, target,
                       comp_op, opacity, start_x, start_y);
diff --git a/src/agg/process_shield_symbolizer.cpp b/src/agg/process_shield_symbolizer.cpp
index 1327be4..67fe8de 100644
--- a/src/agg/process_shield_symbolizer.cpp
+++ b/src/agg/process_shield_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -60,7 +60,7 @@ void  agg_renderer<T0,T1>::process(shield_symbolizer const& sym,
     double opacity = get<double>(sym,keys::opacity, feature, common_.vars_, 1.0);
 
     placements_list const& placements = helper.get();
-    for (glyph_positions_ptr glyphs : placements)
+    for (auto const& glyphs : placements)
     {
         marker_info_ptr mark = glyphs->get_marker();
         if (mark)
diff --git a/src/agg/process_text_symbolizer.cpp b/src/agg/process_text_symbolizer.cpp
index c697d05..078a7ab 100644
--- a/src/agg/process_text_symbolizer.cpp
+++ b/src/agg/process_text_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -58,18 +58,16 @@ void agg_renderer<T0,T1>::process(text_symbolizer const& sym,
                               common_.scale_factor_,
                               common_.font_manager_.get_stroker());
 
-    { // halo transform
-        agg::trans_affine halo_transform;
-        auto transform = get_optional<transform_type>(sym, keys::halo_transform);
-        if (transform)
-        {
-            evaluate_transform(halo_transform, feature, common_.vars_, *transform);
-            ren.set_halo_transform(halo_transform);
-        }
+    auto halo_transform = get_optional<transform_type>(sym, keys::halo_transform);
+    if (halo_transform)
+    {
+        agg::trans_affine halo_affine_transform;
+        evaluate_transform(halo_affine_transform, feature, common_.vars_, *halo_transform);
+        ren.set_halo_transform(halo_affine_transform);
     }
 
     placements_list const& placements = helper.get();
-    for (glyph_positions_ptr glyphs : placements)
+    for (auto const& glyphs : placements)
     {
         ren.render(*glyphs);
     }
diff --git a/src/box2d.cpp b/src/box2d.cpp
index edea1b5..a39857d 100644
--- a/src/box2d.cpp
+++ b/src/box2d.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -22,6 +22,7 @@
 
 // mapnik
 #include <mapnik/box2d.hpp>
+#include <mapnik/safe_cast.hpp>
 
 // stl
 #include <stdexcept>
@@ -32,6 +33,8 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/fusion/include/adapt_adt.hpp>
 #include <boost/spirit/include/qi.hpp>
 #include <boost/spirit/include/support_adapt_adt_attributes.hpp>
@@ -43,10 +46,10 @@
 BOOST_FUSION_ADAPT_TPL_ADT(
     (T),
     (mapnik::box2d)(T),
-    (T, T, obj.minx(), obj.set_minx(val))
-    (T, T, obj.miny(), obj.set_miny(val))
-    (T, T, obj.maxx(), obj.set_maxx(val))
-    (T, T, obj.maxy(), obj.set_maxy(val)))
+    (T, T, obj.minx(), obj.set_minx(mapnik::safe_cast<T>(val)))
+    (T, T, obj.miny(), obj.set_miny(mapnik::safe_cast<T>(val)))
+    (T, T, obj.maxx(), obj.set_maxx(mapnik::safe_cast<T>(val)))
+    (T, T, obj.maxy(), obj.set_maxy(mapnik::safe_cast<T>(val))))
 
 namespace mapnik
 {
diff --git a/src/build.py b/src/build.py
index a7a812b..520a347 100644
--- a/src/build.py
+++ b/src/build.py
@@ -1,7 +1,7 @@
 #
 # This file is part of Mapnik (c++ mapping toolkit)
 #
-# Copyright (C) 2013 Artem Pavlenko
+# Copyright (C) 2015 Artem Pavlenko
 #
 # Mapnik is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -192,7 +192,6 @@ source = Split(
     layer.cpp
     map.cpp
     load_map.cpp
-    memory.cpp
     palette.cpp
     marker_helpers.cpp
     transform_expression_grammar.cpp
@@ -341,12 +340,6 @@ source += Split(
     """
     )
 
-# clipper
-source += Split(
-    """
-     ../deps/clipper/src/clipper.cpp
-    """)
-
 if env['RUNTIME_LINK'] == "static":
     source += glob.glob('../deps/agg/src/' + '*.cpp')
 
diff --git a/src/cairo/cairo_context.cpp b/src/cairo/cairo_context.cpp
index fe35c3a..c8ba13c 100644
--- a/src/cairo/cairo_context.cpp
+++ b/src/cairo/cairo_context.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -28,8 +28,8 @@
 #include <mapnik/text/face.hpp>
 
 #include <cairo-ft.h>
+#include <vector>
 
-#include <valarray>
 namespace mapnik {
 
 cairo_face::cairo_face(std::shared_ptr<font_library> const& library, face_ptr const& face)
@@ -227,17 +227,13 @@ void cairo_context::set_line_width(double width)
 
 void cairo_context::set_dash(dash_array const& dashes, double scale_factor)
 {
-    std::valarray<double> d(dashes.size() * 2);
-    dash_array::const_iterator itr = dashes.begin();
-    dash_array::const_iterator end = dashes.end();
-    int index = 0;
-
-    for (; itr != end; ++itr)
+    std::vector<double> d;
+    d.reserve(dashes.size() * 2);
+    for (auto const& dash : dashes)
     {
-        d[index++] = itr->first * scale_factor;
-        d[index++] = itr->second * scale_factor;
+        d.emplace_back(dash.first * scale_factor);
+        d.emplace_back(dash.second * scale_factor);
     }
-
     cairo_set_dash(cairo_.get() , &d[0], static_cast<int>(d.size()), 0/*offset*/);
     check_object_status_and_throw_exception(*this);
 }
@@ -465,8 +461,8 @@ void cairo_context::add_text(glyph_positions const& pos,
         matrix.y0 = 0;
         set_font_matrix(matrix);
         set_font_face(manager, glyph.face);
-        pixel_position pos = glyph_pos.pos + glyph.offset.rotate(glyph_pos.rot);
-        glyph_path(glyph.glyph_index, pixel_position(sx + pos.x, sy - pos.y));
+        pixel_position new_pos = glyph_pos.pos + glyph.offset.rotate(glyph_pos.rot);
+        glyph_path(glyph.glyph_index, pixel_position(sx + new_pos.x, sy - new_pos.y));
         set_line_width(2.0 * halo_radius);
         set_line_join(ROUND_JOIN);
         set_color(glyph.format->halo_fill, glyph.format->halo_opacity);
@@ -486,9 +482,9 @@ void cairo_context::add_text(glyph_positions const& pos,
         matrix.y0 = 0;
         set_font_matrix(matrix);
         set_font_face(manager, glyph.face);
-        pixel_position pos = glyph_pos.pos + glyph.offset.rotate(glyph_pos.rot);
+        pixel_position new_pos = glyph_pos.pos + glyph.offset.rotate(glyph_pos.rot);
         set_color(glyph.format->fill, glyph.format->text_opacity);
-        show_glyph(glyph.glyph_index, pixel_position(sx + pos.x, sy - pos.y));
+        show_glyph(glyph.glyph_index, pixel_position(sx + new_pos.x, sy - new_pos.y));
     }
 
 }
diff --git a/src/cairo/cairo_render_vector.cpp b/src/cairo/cairo_render_vector.cpp
index cfe86d6..160002d 100644
--- a/src/cairo/cairo_render_vector.cpp
+++ b/src/cairo/cairo_render_vector.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/cairo/cairo_renderer.cpp b/src/cairo/cairo_renderer.cpp
index b4293af..1772307 100644
--- a/src/cairo/cairo_renderer.cpp
+++ b/src/cairo/cairo_renderer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -110,16 +110,16 @@ struct setup_marker_visitor
     void operator() (marker_rgba8 const& marker)
     {
         mapnik::image_rgba8 const& bg_image = marker.get_data();
-        int w = bg_image.width();
-        int h = bg_image.height();
+        std::size_t w = bg_image.width();
+        std::size_t h = bg_image.height();
         if ( w > 0 && h > 0)
         {
             // repeat background-image both vertically and horizontally
-            unsigned x_steps = unsigned(std::ceil(common_.width_/double(w)));
-            unsigned y_steps = unsigned(std::ceil(common_.height_/double(h)));
-            for (unsigned x=0;x<x_steps;++x)
+            std::size_t x_steps = std::size_t(std::ceil(common_.width_/double(w)));
+            std::size_t y_steps = std::size_t(std::ceil(common_.height_/double(h)));
+            for (std::size_t x=0;x<x_steps;++x)
             {
-                for (unsigned y=0;y<y_steps;++y)
+                for (std::size_t y=0;y<y_steps;++y)
                 {
                     agg::trans_affine matrix = agg::trans_affine_translation(
                                                    x*w,
@@ -191,13 +191,13 @@ void cairo_renderer<T>::end_layer_processing(layer const&)
 }
 
 template <typename T>
-void cairo_renderer<T>::start_style_processing(feature_type_style const& st)
+void cairo_renderer<T>::start_style_processing(feature_type_style const&)
 {
     MAPNIK_LOG_DEBUG(cairo_renderer) << "cairo_renderer:start style processing";
 }
 
 template <typename T>
-void cairo_renderer<T>::end_style_processing(feature_type_style const& st)
+void cairo_renderer<T>::end_style_processing(feature_type_style const&)
 {
     MAPNIK_LOG_DEBUG(cairo_renderer) << "cairo_renderer:end style processing";
 }
diff --git a/src/cairo/process_building_symbolizer.cpp b/src/cairo/process_building_symbolizer.cpp
index edb647b..5444143 100644
--- a/src/cairo/process_building_symbolizer.cpp
+++ b/src/cairo/process_building_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/cairo/process_debug_symbolizer.cpp b/src/cairo/process_debug_symbolizer.cpp
index ff84dc8..c60794b 100644
--- a/src/cairo/process_debug_symbolizer.cpp
+++ b/src/cairo/process_debug_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -106,11 +106,9 @@ void cairo_renderer<T>::process(debug_symbolizer const& sym,
 
     if (mode == DEBUG_SYM_MODE_COLLISION)
     {
-        typename detector_type::query_iterator itr = common_.detector_->begin();
-        typename detector_type::query_iterator end = common_.detector_->end();
-        for ( ;itr!=end; ++itr)
+        for (auto & n : *common_.detector_)
         {
-            render_debug_box(context_, itr->box);
+            render_debug_box(context_, n.get().box);
         }
     }
     else if (mode == DEBUG_SYM_MODE_VERTEX)
diff --git a/src/cairo/process_group_symbolizer.cpp b/src/cairo/process_group_symbolizer.cpp
index ef688b6..d32afcf 100644
--- a/src/cairo/process_group_symbolizer.cpp
+++ b/src/cairo/process_group_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -95,7 +95,7 @@ struct thunk_renderer
         render_offset_placements(
             thunk.placements_,
             offset_,
-            [&] (glyph_positions_ptr glyphs)
+            [&] (glyph_positions_ptr const& glyphs)
             {
                 marker_info_ptr mark = glyphs->get_marker();
                 if (mark)
diff --git a/src/cairo/process_line_pattern_symbolizer.cpp b/src/cairo/process_line_pattern_symbolizer.cpp
index ff7dd01..4ec6357 100644
--- a/src/cairo/process_line_pattern_symbolizer.cpp
+++ b/src/cairo/process_line_pattern_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -43,8 +43,8 @@ struct cairo_renderer_process_visitor_l
     cairo_renderer_process_visitor_l(renderer_common const& common,
                                    line_pattern_symbolizer const& sym,
                                    mapnik::feature_impl & feature,
-                                   unsigned & width,
-                                   unsigned & height)
+                                   std::size_t & width,
+                                   std::size_t & height)
         : common_(common),
           sym_(sym),
           feature_(feature),
@@ -81,8 +81,8 @@ struct cairo_renderer_process_visitor_l
     renderer_common const& common_;
     line_pattern_symbolizer const& sym_;
     mapnik::feature_impl & feature_;
-    unsigned & width_;
-    unsigned & height_;
+    std::size_t & width_;
+    std::size_t & height_;
 };
 
 template <typename T>
@@ -106,8 +106,8 @@ void cairo_renderer<T>::process(line_pattern_symbolizer const& sym,
 
     if (marker->is<mapnik::marker_null>()) return;
 
-    unsigned width = marker->width();
-    unsigned height = marker->height();
+    std::size_t width = marker->width();
+    std::size_t height = marker->height();
 
     cairo_save_restore guard(context_);
     context_.set_operator(comp_op);
diff --git a/src/cairo/process_line_symbolizer.cpp b/src/cairo/process_line_symbolizer.cpp
index 6021bbf..ed64d5c 100644
--- a/src/cairo/process_line_symbolizer.cpp
+++ b/src/cairo/process_line_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -29,6 +29,7 @@
 #include <mapnik/vertex_converters.hpp>
 #include <mapnik/vertex_processor.hpp>
 #include <mapnik/renderer_common/apply_vertex_converter.hpp>
+#include <mapnik/geometry_type.hpp>
 
 namespace mapnik
 {
@@ -82,6 +83,7 @@ void cairo_renderer<T>::process(line_symbolizer const& sym,
         clipping_extent.pad(padding);
     }
     using vertex_converter_type =  vertex_converter<clip_line_tag,
+                                                    clip_poly_tag,
                                                     transform_tag,
                                                     affine_transform_tag,
                                                     simplify_tag, smooth_tag,
@@ -89,7 +91,14 @@ void cairo_renderer<T>::process(line_symbolizer const& sym,
 
     vertex_converter_type converter(clipping_extent,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_);
 
-    if (clip) converter.set<clip_line_tag>(); // optional clip (default: true)
+    if (clip)
+    {
+        geometry::geometry_types type = geometry::geometry_type(feature.get_geometry());
+        if (type == geometry::geometry_types::Polygon || type == geometry::geometry_types::MultiPolygon)
+            converter.template set<clip_poly_tag>();
+        else if (type == geometry::geometry_types::LineString || type == geometry::geometry_types::MultiLineString)
+            converter.template set<clip_line_tag>();
+    }
     converter.set<transform_tag>(); // always transform
     if (std::fabs(offset) > 0.0) converter.set<offset_transform_tag>(); // parallel offset
     converter.set<affine_transform_tag>(); // optional affine transform
diff --git a/src/cairo/process_markers_symbolizer.cpp b/src/cairo/process_markers_symbolizer.cpp
index 3cfb394..faffd3d 100644
--- a/src/cairo/process_markers_symbolizer.cpp
+++ b/src/cairo/process_markers_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -59,7 +59,7 @@ struct vector_markers_dispatch_cairo  : public vector_markers_dispatch<Detector>
                                   double scale_factor,
                                   feature_impl & feature,
                                   mapnik::attributes const& vars,
-                                  bool snap_to_pixels,
+                                  bool /* snap_to_pixels */, // only used in agg renderer currently
                                   RendererContext const& renderer_context)
     : vector_markers_dispatch<Detector>(src, marker_trans, sym, detector, scale_factor, feature, vars),
         path_(path),
diff --git a/src/cairo/process_point_symbolizer.cpp b/src/cairo/process_point_symbolizer.cpp
index 349a198..b0ffefb 100644
--- a/src/cairo/process_point_symbolizer.cpp
+++ b/src/cairo/process_point_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/cairo/process_polygon_pattern_symbolizer.cpp b/src/cairo/process_polygon_pattern_symbolizer.cpp
index 08030f7..760a425 100644
--- a/src/cairo/process_polygon_pattern_symbolizer.cpp
+++ b/src/cairo/process_polygon_pattern_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/cairo/process_polygon_symbolizer.cpp b/src/cairo/process_polygon_symbolizer.cpp
index 90ca5c9..b2558a4 100644
--- a/src/cairo/process_polygon_symbolizer.cpp
+++ b/src/cairo/process_polygon_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/cairo/process_raster_symbolizer.cpp b/src/cairo/process_raster_symbolizer.cpp
index 7915ebb..2b6fdc5 100644
--- a/src/cairo/process_raster_symbolizer.cpp
+++ b/src/cairo/process_raster_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -43,7 +43,7 @@ void cairo_renderer<T>::process(raster_symbolizer const& sym,
     cairo_save_restore guard(context_);
     render_raster_symbolizer(
         sym, feature, prj_trans, common_,
-        [&](image_rgba8 &target, composite_mode_e comp_op, double opacity,
+        [&](image_rgba8 const & target, composite_mode_e comp_op, double opacity,
             int start_x, int start_y) {
             context_.set_operator(comp_op);
             context_.add_image(start_x, start_y, target, opacity);
diff --git a/src/cairo/process_text_symbolizer.cpp b/src/cairo/process_text_symbolizer.cpp
index 1975114..06b56cb 100644
--- a/src/cairo/process_text_symbolizer.cpp
+++ b/src/cairo/process_text_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -55,7 +55,7 @@ void cairo_renderer<T>::process(shield_symbolizer const& sym,
     double opacity = get<double>(sym,keys::opacity,feature, common_.vars_, 1.0);
 
     placements_list const &placements = helper.get();
-    for (glyph_positions_ptr glyphs : placements)
+    for (auto const& glyphs : placements)
     {
         marker_info_ptr mark = glyphs->get_marker();
         if (mark) {
@@ -93,7 +93,7 @@ void cairo_renderer<T>::process(text_symbolizer const& sym,
     composite_mode_e halo_comp_op = get<composite_mode_e>(sym, keys::halo_comp_op, feature, common_.vars_,  src_over);
 
     placements_list const& placements = helper.get();
-    for (glyph_positions_ptr glyphs : placements)
+    for (auto const& glyphs : placements)
     {
         context_.add_text(*glyphs, face_manager_, comp_op, halo_comp_op, common_.scale_factor_);
     }
diff --git a/src/cairo_io.cpp b/src/cairo_io.cpp
index d8e9655..96152cc 100644
--- a/src/cairo_io.cpp
+++ b/src/cairo_io.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/color.cpp b/src/color.cpp
index 75204ce..b385877 100644
--- a/src/color.cpp
+++ b/src/color.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -32,6 +32,9 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/spirit/include/karma.hpp>
 #include <boost/spirit/include/phoenix_statement.hpp>
 #include <boost/spirit/include/phoenix_core.hpp>
diff --git a/src/color_factory.cpp b/src/color_factory.cpp
index 38257ec..d13a895 100644
--- a/src/color_factory.cpp
+++ b/src/color_factory.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/conversions.cpp b/src/conversions.cpp
index 83bdd5f..995d0f4 100644
--- a/src/conversions.cpp
+++ b/src/conversions.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -33,6 +33,9 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/spirit/include/qi.hpp>
 #ifdef MAPNIK_KARMA_TO_STRING
   #include <boost/spirit/include/karma.hpp>
diff --git a/src/css_color_grammar.cpp b/src/css_color_grammar.cpp
index a08e129..2e9f60c 100644
--- a/src/css_color_grammar.cpp
+++ b/src/css_color_grammar.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/dasharray_parser.cpp b/src/dasharray_parser.cpp
index 6d432de..4899319 100644
--- a/src/dasharray_parser.cpp
+++ b/src/dasharray_parser.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -26,6 +26,8 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/spirit/include/qi.hpp>
 #include <boost/spirit/include/phoenix_core.hpp>
 #include <boost/spirit/include/phoenix_operator.hpp>
diff --git a/src/datasource_cache.cpp b/src/datasource_cache.cpp
index 97d6550..eb2cfd0 100644
--- a/src/datasource_cache.cpp
+++ b/src/datasource_cache.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -28,7 +28,6 @@
 #include <mapnik/params.hpp>
 #include <mapnik/plugin.hpp>
 #include <mapnik/util/fs.hpp>
-#include <mapnik/utils.hpp>
 
 // boost
 #pragma GCC diagnostic push
diff --git a/src/datasource_cache_static.cpp b/src/datasource_cache_static.cpp
index 15f76bf..ba79d1d 100644
--- a/src/datasource_cache_static.cpp
+++ b/src/datasource_cache_static.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -28,12 +28,12 @@
 #include <mapnik/params.hpp>
 
 // boost
-#include <boost/unordered_map.hpp>
 #include <boost/assign/list_of.hpp>
 #endif
 
 // stl
 #include <stdexcept>
+#include <unordered_map>
 
 // static plugin linkage
 #ifdef MAPNIK_STATIC_PLUGINS
@@ -88,7 +88,7 @@ datasource_ptr ds_generator(parameters const& params)
 }
 
 typedef datasource_ptr (*ds_generator_ptr)(parameters const& params);
-using datasource_map = boost::unordered_map<std::string, ds_generator_ptr>;
+using datasource_map = std::unordered_map<std::string, ds_generator_ptr>;
 
 static datasource_map ds_map = boost::assign::map_list_of
     #if defined(MAPNIK_STATIC_PLUGIN_CSV)
diff --git a/src/debug.cpp b/src/debug.cpp
index 4a519cd..1a90df5 100644
--- a/src/debug.cpp
+++ b/src/debug.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/expression.cpp b/src/expression.cpp
index b8f430a..f4bdeeb 100644
--- a/src/expression.cpp
+++ b/src/expression.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/expression_grammar.cpp b/src/expression_grammar.cpp
index 2aa47e6..09234a0 100644
--- a/src/expression_grammar.cpp
+++ b/src/expression_grammar.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/expression_node.cpp b/src/expression_node.cpp
index 3eef360..43a4059 100644
--- a/src/expression_node.cpp
+++ b/src/expression_node.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -23,12 +23,16 @@
 #include <mapnik/expression_node.hpp>
 #include <mapnik/value_types.hpp>
 #include <mapnik/util/noncopyable.hpp>
+#include <mapnik/safe_cast.hpp>
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wsign-conversion"
 #if defined(BOOST_REGEX_HAS_ICU)
 #include <boost/regex/icu.hpp>
 #else
 #include <boost/regex.hpp>
 #endif
+#pragma GCC diagnostic pop
 
 namespace mapnik
 {
@@ -91,7 +95,7 @@ std::string regex_match_node::to_string() const
     auto const& pattern = impl_.get()->pattern_;
 #if defined(BOOST_REGEX_HAS_ICU)
     std::string utf8;
-    value_unicode_string ustr = value_unicode_string::fromUTF32( &pattern.str()[0], pattern.str().length());
+    value_unicode_string ustr = value_unicode_string::fromUTF32( &pattern.str()[0], safe_cast<int>(pattern.str().length()));
     to_utf8(ustr,utf8);
     str_ += utf8;
 #else
@@ -138,7 +142,7 @@ std::string regex_replace_node::to_string() const
     auto const& format = impl_.get()->format_;
 #if defined(BOOST_REGEX_HAS_ICU)
     std::string utf8;
-    value_unicode_string ustr = value_unicode_string::fromUTF32( &pattern.str()[0], pattern.str().length());
+    value_unicode_string ustr = value_unicode_string::fromUTF32( &pattern.str()[0], safe_cast<int>(pattern.str().length()));
     to_utf8(ustr,utf8);
     str_ += utf8;
     str_ +="','";
diff --git a/src/expression_string.cpp b/src/expression_string.cpp
index 6fe3920..0f904ee 100644
--- a/src/expression_string.cpp
+++ b/src/expression_string.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/feature_kv_iterator.cpp b/src/feature_kv_iterator.cpp
index ae2543d..8fdba82 100644
--- a/src/feature_kv_iterator.cpp
+++ b/src/feature_kv_iterator.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/feature_style_processor.cpp b/src/feature_style_processor.cpp
index 94bfa6b..c041016 100644
--- a/src/feature_style_processor.cpp
+++ b/src/feature_style_processor.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/feature_type_style.cpp b/src/feature_type_style.cpp
index 4ee54e2..a2ddb33 100644
--- a/src/feature_type_style.cpp
+++ b/src/feature_type_style.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/font_engine_freetype.cpp b/src/font_engine_freetype.cpp
index 1c87f87..8f62842 100644
--- a/src/font_engine_freetype.cpp
+++ b/src/font_engine_freetype.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -27,7 +27,7 @@
 #include <mapnik/text/face.hpp>
 #include <mapnik/util/fs.hpp>
 #include <mapnik/util/file_io.hpp>
-#include <mapnik/utils.hpp>
+#include <mapnik/util/singleton.hpp>
 #include <mapnik/make_unique.hpp>
 
 // boost
@@ -136,12 +136,12 @@ bool freetype_engine::register_font_impl(std::string const& file_name,
                 auto range = font_file_mapping.equal_range(name);
                 if (range.first == range.second) // the key was previously absent; insert a pair
                 {
-                    font_file_mapping.emplace_hint(range.first,name,std::move(std::make_pair(i,file_name)));
+                    font_file_mapping.emplace_hint(range.first, name, std::make_pair(i,file_name));
                 }
                 else // the key was present, replace the associated value
                 { /* some action with value range.first->second about to be overwritten here */
                     MAPNIK_LOG_WARN(font_engine_freetype) << "registering new " << name << " at '" << file_name << "'";
-                    range.first->second = std::move(std::make_pair(i,file_name)); // replace value
+                    range.first->second = std::make_pair(i,file_name); // replace value
                 }
                 success = true;
             }
@@ -340,7 +340,7 @@ face_ptr freetype_engine::create_face(std::string const& family_name,
 #ifdef MAPNIK_THREADSAFE
             std::lock_guard<std::mutex> lock(mutex_);
 #endif
-            auto result = global_memory_fonts.emplace(itr->second.second, std::make_pair(std::move(file.data()),file.size()));
+            auto result = global_memory_fonts.emplace(itr->second.second, std::make_pair(file.data(),file.size()));
             FT_Face face;
             FT_Error error = FT_New_Memory_Face(library.get(),
                                                 reinterpret_cast<FT_Byte const*>(result.first->second.first.get()), // data
diff --git a/src/font_set.cpp b/src/font_set.cpp
index 89f46b0..9236cac 100644
--- a/src/font_set.cpp
+++ b/src/font_set.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/fs.cpp b/src/fs.cpp
index 6554724..9c87d97 100644
--- a/src/fs.cpp
+++ b/src/fs.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -21,7 +21,7 @@
  *****************************************************************************/
 
 // mapnik
-#include <mapnik/utils.hpp>
+#include <mapnik/util/utf_conv_win.hpp>
 #include <mapnik/util/fs.hpp>
 
 // boost
diff --git a/src/function_call.cpp b/src/function_call.cpp
index 99b1435..e813dee 100644
--- a/src/function_call.cpp
+++ b/src/function_call.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/geometry_reprojection.cpp b/src/geometry_reprojection.cpp
index 0bdde2f..7cd3ff0 100644
--- a/src/geometry_reprojection.cpp
+++ b/src/geometry_reprojection.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/gradient.cpp b/src/gradient.cpp
index 912739e..ddf6658 100644
--- a/src/gradient.cpp
+++ b/src/gradient.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/grid/grid.cpp b/src/grid/grid.cpp
index 279ac4c..b0d3d59 100644
--- a/src/grid/grid.cpp
+++ b/src/grid/grid.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/grid/grid_renderer.cpp b/src/grid/grid_renderer.cpp
index e484442..93afb5b 100644
--- a/src/grid/grid_renderer.cpp
+++ b/src/grid/grid_renderer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -131,9 +131,9 @@ struct grid_render_marker_visitor
     grid_render_marker_visitor(buffer_type & pixmap,
                                std::unique_ptr<grid_rasterizer> const& ras_ptr,
                                renderer_common const& common,
-                               mapnik::feature_impl const& feature, 
-                               pixel_position const& pos, 
-                               agg::trans_affine const& tr, 
+                               mapnik::feature_impl const& feature,
+                               pixel_position const& pos,
+                               agg::trans_affine const& tr,
                                double opacity)
         : pixmap_(pixmap),
           ras_ptr_(ras_ptr),
@@ -208,23 +208,23 @@ struct grid_render_marker_visitor
                                   boost::math::iround(pos_.y - cy));
         }
     }
-           
+
   private:
     buffer_type & pixmap_;
     std::unique_ptr<grid_rasterizer> const& ras_ptr_;
     renderer_common const& common_;
-    mapnik::feature_impl const& feature_; 
+    mapnik::feature_impl const& feature_;
     pixel_position const& pos_;
     agg::trans_affine const& tr_;
     double opacity_;
 };
 
 template <typename T>
-void grid_renderer<T>::render_marker(mapnik::feature_impl const& feature, 
-                                     pixel_position const& pos, 
-                                     marker const& marker, 
-                                     agg::trans_affine const& tr, 
-                                     double opacity, 
+void grid_renderer<T>::render_marker(mapnik::feature_impl const& feature,
+                                     pixel_position const& pos,
+                                     marker const& marker,
+                                     agg::trans_affine const& tr,
+                                     double opacity,
                                      composite_mode_e /*comp_op*/)
 {
     grid_render_marker_visitor<buffer_type> visitor(pixmap_,
diff --git a/src/grid/process_building_symbolizer.cpp b/src/grid/process_building_symbolizer.cpp
index 48c2320..e6649da 100644
--- a/src/grid/process_building_symbolizer.cpp
+++ b/src/grid/process_building_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/grid/process_group_symbolizer.cpp b/src/grid/process_group_symbolizer.cpp
index e74140d..a672f6b 100644
--- a/src/grid/process_group_symbolizer.cpp
+++ b/src/grid/process_group_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -120,7 +120,7 @@ struct thunk_renderer
         render_raster_marker(ren, ras_, thunk.src_, feature_, offset_tr, thunk.opacity_);
         pixmap_.add_feature(feature_);
     }
-    
+
     void operator()(text_render_thunk const &thunk) const
     {
         text_renderer_type ren(pixmap_, thunk.comp_op_, common_.scale_factor_);
@@ -129,7 +129,7 @@ struct thunk_renderer
         render_offset_placements(
             thunk.placements_,
             offset_,
-            [&] (glyph_positions_ptr glyphs)
+            [&] (glyph_positions_ptr const& glyphs)
             {
                 marker_info_ptr mark = glyphs->get_marker();
                 if (mark)
diff --git a/src/grid/process_line_pattern_symbolizer.cpp b/src/grid/process_line_pattern_symbolizer.cpp
index 620d7dd..d34f6e8 100644
--- a/src/grid/process_line_pattern_symbolizer.cpp
+++ b/src/grid/process_line_pattern_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -82,7 +82,7 @@ void grid_renderer<T>::process(line_pattern_symbolizer const& sym,
 
     ras_ptr->reset();
 
-    int stroke_width = mark->width();
+    std::size_t stroke_width = mark->width();
 
     agg::trans_affine tr;
     auto transform = get_optional<transform_type>(sym, keys::geometry_transform);
@@ -116,8 +116,9 @@ void grid_renderer<T>::process(line_pattern_symbolizer const& sym,
     put<value_double>(line, keys::smooth, value_double(smooth));
 
     using vertex_converter_type = vertex_converter<clip_line_tag, transform_tag,
-                                                   offset_transform_tag, affine_transform_tag,
-                                                   simplify_tag, smooth_tag, stroke_tag>;
+                                                   affine_transform_tag,
+                                                   simplify_tag,smooth_tag,
+                                                   offset_transform_tag,stroke_tag>;
     vertex_converter_type converter(clipping_extent,line,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_);
     if (clip) converter.set<clip_line_tag>(); // optional clip (default: true)
     converter.set<transform_tag>(); // always transform
diff --git a/src/grid/process_line_symbolizer.cpp b/src/grid/process_line_symbolizer.cpp
index f40439c..c569f6b 100644
--- a/src/grid/process_line_symbolizer.cpp
+++ b/src/grid/process_line_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -31,6 +31,7 @@
 #include <mapnik/vertex_converters.hpp>
 #include <mapnik/vertex_processor.hpp>
 #include <mapnik/renderer_common/apply_vertex_converter.hpp>
+#include <mapnik/geometry_type.hpp>
 // agg
 #include "agg_rasterizer_scanline_aa.h"
 #include "agg_renderer_scanline.h"
@@ -89,12 +90,21 @@ void grid_renderer<T>::process(line_symbolizer const& sym,
         padding *= common_.scale_factor_;
         clipping_extent.pad(padding);
     }
-    using vertex_converter_type = vertex_converter<clip_line_tag, transform_tag,
-                                                   offset_transform_tag, affine_transform_tag,
-                                                   simplify_tag, smooth_tag, dash_tag, stroke_tag>;
+    using vertex_converter_type = vertex_converter<clip_line_tag, clip_poly_tag, transform_tag,
+                                                   affine_transform_tag,
+                                                   simplify_tag, smooth_tag,
+                                                   offset_transform_tag,
+                                                   dash_tag, stroke_tag>;
 
     vertex_converter_type converter(clipping_extent,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_);
-    if (clip) converter.set<clip_line_tag>(); // optional clip (default: true)
+    if (clip)
+    {
+        geometry::geometry_types type = geometry::geometry_type(feature.get_geometry());
+        if (type == geometry::geometry_types::Polygon || type == geometry::geometry_types::MultiPolygon)
+            converter.template set<clip_poly_tag>();
+        else if (type == geometry::geometry_types::LineString || type == geometry::geometry_types::MultiLineString)
+            converter.template set<clip_line_tag>();
+    }
     converter.set<transform_tag>(); // always transform
     if (std::fabs(offset) > 0.0) converter.set<offset_transform_tag>(); // parallel offset
     converter.set<affine_transform_tag>(); // optional affine transform
diff --git a/src/grid/process_markers_symbolizer.cpp b/src/grid/process_markers_symbolizer.cpp
index cda2c7d..b79807e 100644
--- a/src/grid/process_markers_symbolizer.cpp
+++ b/src/grid/process_markers_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/grid/process_point_symbolizer.cpp b/src/grid/process_point_symbolizer.cpp
index ded8503..731291d 100644
--- a/src/grid/process_point_symbolizer.cpp
+++ b/src/grid/process_point_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/grid/process_polygon_pattern_symbolizer.cpp b/src/grid/process_polygon_pattern_symbolizer.cpp
index cdd5aff..604c0c2 100644
--- a/src/grid/process_polygon_pattern_symbolizer.cpp
+++ b/src/grid/process_polygon_pattern_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/grid/process_polygon_symbolizer.cpp b/src/grid/process_polygon_symbolizer.cpp
index 30f072f..3e1f089 100644
--- a/src/grid/process_polygon_symbolizer.cpp
+++ b/src/grid/process_polygon_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/grid/process_raster_symbolizer.cpp b/src/grid/process_raster_symbolizer.cpp
index aff12a4..9e392a7 100644
--- a/src/grid/process_raster_symbolizer.cpp
+++ b/src/grid/process_raster_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/grid/process_shield_symbolizer.cpp b/src/grid/process_shield_symbolizer.cpp
index 68935c6..7819893 100644
--- a/src/grid/process_shield_symbolizer.cpp
+++ b/src/grid/process_shield_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -64,7 +64,7 @@ void  grid_renderer<T>::process(shield_symbolizer const& sym,
     placements_list const& placements = helper.get();
     value_integer feature_id = feature.id();
 
-    for (glyph_positions_ptr glyphs : placements)
+    for (auto const& glyphs : placements)
     {
         marker_info_ptr mark = glyphs->get_marker();
         if (mark)
diff --git a/src/grid/process_text_symbolizer.cpp b/src/grid/process_text_symbolizer.cpp
index 921ce1d..3df4ad2 100644
--- a/src/grid/process_text_symbolizer.cpp
+++ b/src/grid/process_text_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -54,20 +54,19 @@ void grid_renderer<T>::process(text_symbolizer const& sym,
     grid_text_renderer<T> ren(pixmap_,
                               comp_op,
                               common_.scale_factor_);
-    { // halo transform
-        agg::trans_affine halo_transform;
-        auto transform = get_optional<transform_type>(sym, keys::halo_transform);
-        if (transform)
-        {
-            evaluate_transform(halo_transform, feature, common_.vars_, *transform);
-            ren.set_halo_transform(halo_transform);
-        }
+
+    auto halo_transform = get_optional<transform_type>(sym, keys::halo_transform);
+    if (halo_transform)
+    {
+        agg::trans_affine halo_affine_transform;
+        evaluate_transform(halo_affine_transform, feature, common_.vars_, *halo_transform);
+        ren.set_halo_transform(halo_affine_transform);
     }
 
     placements_list const& placements = helper.get();
     value_integer feature_id = feature.id();
 
-    for (glyph_positions_ptr glyphs : placements)
+    for (auto const& glyphs : placements)
     {
         ren.render(*glyphs, feature_id);
         placement_found = true;
diff --git a/src/group/group_layout_manager.cpp b/src/group/group_layout_manager.cpp
index 7c6f7b8..fe00e7d 100644
--- a/src/group/group_layout_manager.cpp
+++ b/src/group/group_layout_manager.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -23,6 +23,7 @@
 // mapnik
 #include <mapnik/group/group_layout_manager.hpp>
 #include <mapnik/util/variant.hpp>
+#include <mapnik/safe_cast.hpp>
 
 // std
 #include <cmath>
@@ -85,7 +86,7 @@ struct process_layout
         }
 
         bound_box layout_box;
-        size_t middle_ifirst = (member_boxes_.size() - 1) >> 1;
+        int middle_ifirst = safe_cast<int>((member_boxes_.size() - 1) >> 1);
         int top_i = 0;
         int bottom_i = 0;
         if (middle_ifirst % 2 == 0)
@@ -102,8 +103,8 @@ struct process_layout
 
         while (bottom_i >= 0 && top_i >= 0 && top_i < static_cast<int>(member_offsets_.size()))
         {
-            layout_box.expand_to_include(make_horiz_pair(top_i, layout_box.miny() - y_margin, -1, x_margin, layout.get_max_difference()));
-            layout_box.expand_to_include(make_horiz_pair(bottom_i, layout_box.maxy() + y_margin, 1, x_margin, layout.get_max_difference()));
+            layout_box.expand_to_include(make_horiz_pair(static_cast<std::size_t>(top_i), layout_box.miny() - y_margin, -1, x_margin, layout.get_max_difference()));
+            layout_box.expand_to_include(make_horiz_pair(static_cast<std::size_t>(bottom_i), layout_box.maxy() + y_margin, 1, x_margin, layout.get_max_difference()));
             top_i -= 2;
             bottom_i += 2;
         }
diff --git a/src/group/group_rule.cpp b/src/group/group_rule.cpp
index 4ea7d9c..a1a6bf9 100644
--- a/src/group/group_rule.cpp
+++ b/src/group/group_rule.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/group/group_symbolizer_helper.cpp b/src/group/group_symbolizer_helper.cpp
index 338e541..a8e453a 100644
--- a/src/group/group_symbolizer_helper.cpp
+++ b/src/group/group_symbolizer_helper.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/image.cpp b/src/image.cpp
index 408b29c..caa0a8f 100644
--- a/src/image.cpp
+++ b/src/image.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/image_any.cpp b/src/image_any.cpp
index ef62a4f..5ba0c39 100644
--- a/src/image_any.cpp
+++ b/src/image_any.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -237,31 +237,31 @@ MAPNIK_DECL image_any create_image_any(int width,
     switch (type)
     {
     case image_dtype_gray8:
-        return image_any(std::move(image_gray8(width, height, initialize, premultiplied, painted)));
+        return image_any(image_gray8(width, height, initialize, premultiplied, painted));
     case image_dtype_gray8s:
-        return image_any(std::move(image_gray8s(width, height, initialize, premultiplied, painted)));
+        return image_any(image_gray8s(width, height, initialize, premultiplied, painted));
     case image_dtype_gray16:
-        return image_any(std::move(image_gray16(width, height, initialize, premultiplied, painted)));
+        return image_any(image_gray16(width, height, initialize, premultiplied, painted));
     case image_dtype_gray16s:
-        return image_any(std::move(image_gray16s(width, height, initialize, premultiplied, painted)));
+        return image_any(image_gray16s(width, height, initialize, premultiplied, painted));
     case image_dtype_gray32:
-        return image_any(std::move(image_gray32(width, height, initialize, premultiplied, painted)));
+        return image_any(image_gray32(width, height, initialize, premultiplied, painted));
     case image_dtype_gray32s:
-        return image_any(std::move(image_gray32s(width, height, initialize, premultiplied, painted)));
+        return image_any(image_gray32s(width, height, initialize, premultiplied, painted));
     case image_dtype_gray32f:
-        return image_any(std::move(image_gray32f(width, height, initialize, premultiplied, painted)));
+        return image_any(image_gray32f(width, height, initialize, premultiplied, painted));
     case image_dtype_gray64:
-        return image_any(std::move(image_gray64(width, height, initialize, premultiplied, painted)));
+        return image_any(image_gray64(width, height, initialize, premultiplied, painted));
     case image_dtype_gray64s:
-        return image_any(std::move(image_gray64s(width, height, initialize, premultiplied, painted)));
+        return image_any(image_gray64s(width, height, initialize, premultiplied, painted));
     case image_dtype_gray64f:
-        return image_any(std::move(image_gray64f(width, height, initialize, premultiplied, painted)));
+        return image_any(image_gray64f(width, height, initialize, premultiplied, painted));
     case image_dtype_null:
-        return image_any(std::move(image_null()));
+        return image_any(image_null());
     case image_dtype_rgba8:
     case IMAGE_DTYPE_MAX:
     default:
-        return image_any(std::move(image_rgba8(width, height, initialize, premultiplied, painted)));
+        return image_any(image_rgba8(width, height, initialize, premultiplied, painted));
     }
 }
 
diff --git a/src/image_compositing.cpp b/src/image_compositing.cpp
index 5483325..83684e4 100644
--- a/src/image_compositing.cpp
+++ b/src/image_compositing.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -24,11 +24,15 @@
 #include <mapnik/image_compositing.hpp>
 #include <mapnik/image.hpp>
 #include <mapnik/image_any.hpp>
+#include <mapnik/safe_cast.hpp>
+#include <mapnik/util/const_rendering_buffer.hpp>
 
 // boost
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
 #pragma GCC diagnostic ignored "-Wredeclared-class-member"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/assign/list_of.hpp>
 #include <boost/bimap.hpp>
 #pragma GCC diagnostic pop
@@ -123,31 +127,6 @@ For example, if you generate some pattern with AGG (premultiplied) and would lik
 
 */
 
-namespace detail {
-
-// non-mutable rendering_buffer implementation
-template <typename T>
-struct rendering_buffer
-{
-    using image_type = T;
-    using pixel_type = typename image_type::pixel_type;
-    using row_data = agg::const_row_info<uint8_t>;
-
-    rendering_buffer(T const& data)
-        : data_(data) {}
-
-    uint8_t const* buf() const { return data_.bytes(); }
-    unsigned width() const { return data_.width();}
-    unsigned height() const { return data_.height();}
-    int stride() const { return data_.row_size();}
-    uint8_t const* row_ptr(int, int y, unsigned) {return row_ptr(y);}
-    uint8_t const* row_ptr(int y) const { return reinterpret_cast<uint8_t const*>(data_.get_row(y)); }
-    row_data row (int y) const { return row_data(0, data_.width() - 1, row_ptr(y)); }
-    image_type const& data_;
-};
-
-} // end detail ns
-
 template <>
 MAPNIK_DECL void composite(image_rgba8 & dst, image_rgba8 const& src, composite_mode_e mode,
                float opacity,
@@ -156,16 +135,16 @@ MAPNIK_DECL void composite(image_rgba8 & dst, image_rgba8 const& src, composite_
 {
     using color = agg::rgba8;
     using order = agg::order_rgba;
-    using const_rendering_buffer = detail::rendering_buffer<image_rgba8>;
+    using const_rendering_buffer = util::rendering_buffer<image_rgba8>;
     using blender_type = agg::comp_op_adaptor_rgba_pre<color, order>;
     using pixfmt_type = agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer>;
     using renderer_type = agg::renderer_base<pixfmt_type>;
 
-    agg::rendering_buffer dst_buffer(dst.bytes(),dst.width(),dst.height(),dst.row_size());
+    agg::rendering_buffer dst_buffer(dst.bytes(),safe_cast<unsigned>(dst.width()),safe_cast<unsigned>(dst.height()),safe_cast<int>(dst.row_size()));
     const_rendering_buffer src_buffer(src);
     pixfmt_type pixf(dst_buffer);
     pixf.comp_op(static_cast<agg::comp_op_e>(mode));
-    agg::pixfmt_alpha_blend_rgba<agg::blender_rgba32, const_rendering_buffer, agg::pixel32_type> pixf_mask(src_buffer);
+    agg::pixfmt_alpha_blend_rgba<agg::blender_rgba32_pre, const_rendering_buffer, agg::pixel32_type> pixf_mask(src_buffer);
 #ifdef MAPNIK_DEBUG
     if (!src.get_premultiplied())
     {
@@ -177,21 +156,21 @@ MAPNIK_DECL void composite(image_rgba8 & dst, image_rgba8 const& src, composite_
     }
 #endif
     renderer_type ren(pixf);
-    ren.blend_from(pixf_mask,0,dx,dy,unsigned(255*opacity));
+    ren.blend_from(pixf_mask,0,dx,dy,safe_cast<agg::cover_type>(255*opacity));
 }
 
 template <>
-MAPNIK_DECL void composite(image_gray32f & dst, image_gray32f const& src, composite_mode_e mode,
-               float opacity,
+MAPNIK_DECL void composite(image_gray32f & dst, image_gray32f const& src, composite_mode_e /*mode*/,
+               float /*opacity*/,
                int dx,
                int dy)
 {
-    using const_rendering_buffer = detail::rendering_buffer<image_gray32f>;
+    using const_rendering_buffer = util::rendering_buffer<image_gray32f>;
     using src_pixfmt_type = agg::pixfmt_alpha_blend_gray<agg::blender_gray<agg::gray32>, const_rendering_buffer, 1, 0>;
     using dst_pixfmt_type = agg::pixfmt_alpha_blend_gray<agg::blender_gray<agg::gray32>, agg::rendering_buffer, 1, 0>;
     using renderer_type = agg::renderer_base<dst_pixfmt_type>;
 
-    agg::rendering_buffer dst_buffer(dst.bytes(),dst.width(),dst.height(),dst.width());
+    agg::rendering_buffer dst_buffer(dst.bytes(),safe_cast<unsigned>(dst.width()),safe_cast<unsigned>(dst.height()),safe_cast<int>(dst.width()));
     const_rendering_buffer src_buffer(src);
     dst_pixfmt_type pixf(dst_buffer);
     src_pixfmt_type pixf_mask(src_buffer);
diff --git a/src/image_copy.cpp b/src/image_copy.cpp
index f676cee..01225c2 100644
--- a/src/image_copy.cpp
+++ b/src/image_copy.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -24,13 +24,7 @@
 #include <mapnik/image_copy.hpp>
 #include <mapnik/image.hpp>
 #include <mapnik/image_any.hpp>
-
-// boost
-#include <boost/numeric/conversion/cast.hpp>
-
-using boost::numeric_cast;
-using boost::numeric::positive_overflow;
-using boost::numeric::negative_overflow;
+#include <mapnik/safe_cast.hpp>
 
 namespace mapnik
 {
@@ -42,8 +36,8 @@ template <typename T0>
 struct visitor_image_copy
 {
     using dst_type = typename T0::pixel_type;
-    
-    T0 operator() (image_null const&) 
+
+    T0 operator() (image_null const&)
     {
         throw std::runtime_error("Can not cast a null image");
     }
@@ -52,27 +46,16 @@ struct visitor_image_copy
     {
         return T0(src);
     }
-    
+
     template <typename T1>
     T0 operator() (T1 const& src)
     {
-        T0 dst(src.width(), src.height(), false);
-        for (unsigned y = 0; y < dst.height(); ++y)
+        T0 dst(safe_cast<int>(src.width()), safe_cast<int>(src.height()), false);
+        for (std::size_t y = 0; y < dst.height(); ++y)
         {
-            for (unsigned x = 0; x < dst.width(); ++x)
+            for (std::size_t x = 0; x < dst.width(); ++x)
             {
-                try
-                {
-                    dst(x,y) = numeric_cast<dst_type>(src(x,y));
-                }
-                catch(negative_overflow&)
-                {
-                    dst(x,y) = std::numeric_limits<dst_type>::min();
-                }
-                catch(positive_overflow&) 
-                {
-                    dst(x,y) = std::numeric_limits<dst_type>::max();
-                }
+                dst(x,y) = safe_cast<dst_type>(src(x,y));
             }
         }
         return T0(std::move(dst));
@@ -83,11 +66,11 @@ template <typename T0>
 struct visitor_image_copy_so
 {
     using dst_type = typename T0::pixel_type;
-    
+
     visitor_image_copy_so(double offset, double scaling)
         : offset_(offset), scaling_(scaling) {}
 
-    T0 operator() (image_null const&) 
+    T0 operator() (image_null const&)
     {
         throw std::runtime_error("Can not cast a null image");
     }
@@ -101,38 +84,27 @@ struct visitor_image_copy_so
         else
         {
             T0 dst(src);
-            dst.set_scaling(scaling_); 
-            dst.set_offset(offset_); 
+            dst.set_scaling(scaling_);
+            dst.set_offset(offset_);
             return T0(std::move(dst));
         }
     }
-    
+
     template <typename T1>
     T0 operator() (T1 const& src)
     {
         double src_offset = src.get_offset();
         double src_scaling = src.get_scaling();
-        T0 dst(src.width(), src.height(), false);
+        T0 dst(safe_cast<int>(src.width()), safe_cast<int>(src.height()), false);
         dst.set_scaling(scaling_);
         dst.set_offset(offset_);
-        for (unsigned y = 0; y < dst.height(); ++y)
+        for (std::size_t y = 0; y < dst.height(); ++y)
         {
-            for (unsigned x = 0; x < dst.width(); ++x)
+            for (std::size_t x = 0; x < dst.width(); ++x)
             {
-                double scaled_src_val = (numeric_cast<double>(src(x,y)) * src_scaling) + src_offset;
+                double scaled_src_val = (safe_cast<double>(src(x,y)) * src_scaling) + src_offset;
                 double dst_val = (scaled_src_val - offset_) / scaling_;
-                try
-                {
-                    dst(x,y) = numeric_cast<dst_type>(dst_val);
-                }
-                catch(negative_overflow&)
-                {
-                    dst(x,y) = std::numeric_limits<dst_type>::min();
-                }
-                catch(positive_overflow&) 
-                {
-                    dst(x,y) = std::numeric_limits<dst_type>::max();
-                }
+                dst(x,y) = safe_cast<dst_type>(dst_val);
             }
         }
         return T0(std::move(dst));
@@ -327,27 +299,27 @@ MAPNIK_DECL image_any image_copy(image_any const& data, image_dtype type, double
     switch (type)
     {
         case image_dtype_rgba8:
-            return image_any(std::move(image_copy<image_rgba8>(data, offset, scaling)));
+            return image_any(image_copy<image_rgba8>(data, offset, scaling));
         case image_dtype_gray8:
-            return image_any(std::move(image_copy<image_gray8>(data, offset, scaling)));
+            return image_any(image_copy<image_gray8>(data, offset, scaling));
         case image_dtype_gray8s:
-            return image_any(std::move(image_copy<image_gray8s>(data, offset, scaling)));
+            return image_any(image_copy<image_gray8s>(data, offset, scaling));
         case image_dtype_gray16:
-            return image_any(std::move(image_copy<image_gray16>(data, offset, scaling)));
+            return image_any(image_copy<image_gray16>(data, offset, scaling));
         case image_dtype_gray16s:
-            return image_any(std::move(image_copy<image_gray16s>(data, offset, scaling)));
+            return image_any(image_copy<image_gray16s>(data, offset, scaling));
         case image_dtype_gray32:
-            return image_any(std::move(image_copy<image_gray32>(data, offset, scaling)));
+            return image_any(image_copy<image_gray32>(data, offset, scaling));
         case image_dtype_gray32s:
-            return image_any(std::move(image_copy<image_gray32s>(data, offset, scaling)));
+            return image_any(image_copy<image_gray32s>(data, offset, scaling));
         case image_dtype_gray32f:
-            return image_any(std::move(image_copy<image_gray32f>(data, offset, scaling)));
+            return image_any(image_copy<image_gray32f>(data, offset, scaling));
         case image_dtype_gray64:
-            return image_any(std::move(image_copy<image_gray64>(data, offset, scaling)));
+            return image_any(image_copy<image_gray64>(data, offset, scaling));
         case image_dtype_gray64s:
-            return image_any(std::move(image_copy<image_gray64s>(data, offset, scaling)));
+            return image_any(image_copy<image_gray64s>(data, offset, scaling));
         case image_dtype_gray64f:
-            return image_any(std::move(image_copy<image_gray64f>(data, offset, scaling)));
+            return image_any(image_copy<image_gray64f>(data, offset, scaling));
         case image_dtype_null:
             throw std::runtime_error("Can not cast a null image");
         case IMAGE_DTYPE_MAX:
diff --git a/src/image_filter_types.cpp b/src/image_filter_types.cpp
index 0b28b07..2212db9 100644
--- a/src/image_filter_types.cpp
+++ b/src/image_filter_types.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -29,6 +29,9 @@
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
 #pragma GCC diagnostic ignored "-Wmissing-field-initializers"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/spirit/include/karma.hpp>
 #pragma GCC diagnostic pop
 
diff --git a/src/image_options.cpp b/src/image_options.cpp
index 0c102ae..3b1b1fe 100644
--- a/src/image_options.cpp
+++ b/src/image_options.cpp
@@ -21,8 +21,16 @@
  *****************************************************************************/
 
 #include <mapnik/image_options.hpp>
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/spirit/include/qi.hpp>
 #include <boost/fusion/include/std_pair.hpp>
+#pragma GCC diagnostic pop
 
 namespace mapnik { namespace detail {
 
diff --git a/src/image_reader.cpp b/src/image_reader.cpp
index e3e708b..d0ec815 100644
--- a/src/image_reader.cpp
+++ b/src/image_reader.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/image_scaling.cpp b/src/image_scaling.cpp
index 6b9f9bc..dd3dceb 100644
--- a/src/image_scaling.cpp
+++ b/src/image_scaling.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -31,6 +31,8 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
 #pragma GCC diagnostic ignored "-Wredeclared-class-member"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/assign/list_of.hpp>
 #include <boost/bimap.hpp>
 #pragma GCC diagnostic pop
diff --git a/src/image_util.cpp b/src/image_util.cpp
index 0f3951a..7f86fdb 100644
--- a/src/image_util.cpp
+++ b/src/image_util.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -35,6 +35,7 @@
 #include <mapnik/box2d.hpp>
 #include <mapnik/util/variant.hpp>
 #include <mapnik/debug.hpp>
+#include <mapnik/safe_cast.hpp>
 #ifdef SSE_MATH
 #include <mapnik/sse.hpp>
 
@@ -51,16 +52,9 @@
 #include <sstream>
 #include <algorithm>
 
-// boost
-#include <boost/numeric/conversion/cast.hpp>
-
 namespace mapnik
 {
 
-using boost::numeric_cast;
-using boost::numeric::positive_overflow;
-using boost::numeric::negative_overflow;
-
 template <typename T>
 MAPNIK_DECL std::string save_to_string(T const& image,
                                        std::string const& type,
@@ -374,6 +368,13 @@ template MAPNIK_DECL void save_to_file<image_view_any> (image_view_any const&,
                                                         std::string const&,
                                                         rgba_palette const& palette);
 
+template MAPNIK_DECL std::string save_to_string<image_view_rgba8> (image_view_rgba8 const&,
+                                                                 std::string const&);
+
+template MAPNIK_DECL std::string save_to_string<image_view_rgba8> (image_view_rgba8 const&,
+                                                                 std::string const&,
+                                                                 rgba_palette const& palette);
+
 template MAPNIK_DECL std::string save_to_string<image_view_any> (image_view_any const&,
                                                                  std::string const&);
 
@@ -495,7 +496,7 @@ struct premultiply_visitor
     {
         if (!data.get_premultiplied())
         {
-            agg::rendering_buffer buffer(data.bytes(),data.width(),data.height(),data.row_size());
+            agg::rendering_buffer buffer(data.bytes(),safe_cast<unsigned>(data.width()),safe_cast<unsigned>(data.height()),safe_cast<int>(data.row_size()));
             agg::pixfmt_rgba32 pixf(buffer);
             pixf.premultiply();
             data.set_premultiplied(true);
@@ -517,7 +518,7 @@ struct demultiply_visitor
     {
         if (data.get_premultiplied())
         {
-            agg::rendering_buffer buffer(data.bytes(),data.width(),data.height(),data.row_size());
+            agg::rendering_buffer buffer(data.bytes(),safe_cast<unsigned>(data.width()),safe_cast<unsigned>(data.height()),safe_cast<int>(data.row_size()));
             agg::pixfmt_rgba32_pre pixf(buffer);
             pixf.demultiply();
             data.set_premultiplied(false);
@@ -647,12 +648,12 @@ struct visitor_apply_opacity
             for (std::size_t x = 0; x < data.width(); ++x)
             {
                 pixel_type rgba = row_to[x];
-                pixel_type a = static_cast<pixel_type>(((rgba >> 24) & 0xff) * opacity_);
+                pixel_type a = static_cast<pixel_type>(((rgba >> 24u) & 0xff) * opacity_);
                 pixel_type r = rgba & 0xff;
-                pixel_type g = (rgba >> 8 ) & 0xff;
-                pixel_type b = (rgba >> 16) & 0xff;
+                pixel_type g = (rgba >> 8u ) & 0xff;
+                pixel_type b = (rgba >> 16u) & 0xff;
 
-                row_to[x] = (a << 24)| (b << 16) |  (g << 8) | (r) ;
+                row_to[x] = (a << 24u) | (b << 16u) |  (g << 8u) | (r) ;
             }
         }
     }
@@ -719,13 +720,13 @@ struct visitor_set_grayscale_to_alpha
             {
                 pixel_type rgba = row_from[x];
                 pixel_type r = rgba & 0xff;
-                pixel_type g = (rgba >> 8 ) & 0xff;
-                pixel_type b = (rgba >> 16) & 0xff;
+                pixel_type g = (rgba >> 8u) & 0xff;
+                pixel_type b = (rgba >> 16u) & 0xff;
 
                 // magic numbers for grayscale
                 pixel_type a = static_cast<pixel_type>(std::ceil((r * .3) + (g * .59) + (b * .11)));
 
-                row_from[x] = (a << 24)| (255 << 16) |  (255 << 8) | (255) ;
+                row_from[x] = (a << 24u) | (255 << 16u) |  (255 << 8u) | (255u) ;
             }
         }
     }
@@ -758,7 +759,10 @@ struct visitor_set_grayscale_to_alpha_c
                 // magic numbers for grayscale
                 pixel_type a = static_cast<pixel_type>(std::ceil((r * .3) + (g * .59) + (b * .11)));
 
-                row_from[x] = (a << 24)| (c_.blue() << 16) |  (c_.green() << 8) | (c_.red()) ;
+                row_from[x] = static_cast<unsigned>(a << 24u) |
+                              static_cast<unsigned>(c_.blue() << 16u) |
+                              static_cast<unsigned>(c_.green() << 8u) |
+                              static_cast<unsigned>(c_.red() );
             }
         }
     }
@@ -936,20 +940,7 @@ struct visitor_fill
     void operator() (T2 & data) const
     {
         using pixel_type = typename T2::pixel_type;
-        pixel_type val;
-        try
-        {
-            val = numeric_cast<pixel_type>(val_);
-        }
-        catch(negative_overflow&)
-        {
-            val = std::numeric_limits<pixel_type>::min();
-        }
-        catch(positive_overflow&)
-        {
-            val = std::numeric_limits<pixel_type>::max();
-        }
-        data.set(val);
+        data.set(safe_cast<pixel_type>(val_));
     }
 
 private:
@@ -1211,99 +1202,6 @@ template MAPNIK_DECL void fill(image_gray64f &, int8_t const&);
 template MAPNIK_DECL void fill(image_gray64f &, float const&);
 template MAPNIK_DECL void fill(image_gray64f &, double const&);
 
-namespace detail {
-
-struct visitor_set_rectangle
-{
-    visitor_set_rectangle(image_any const & src, std::size_t x0, std::size_t y0)
-        : src_(src), x0_(x0), y0_(y0) {}
-
-    void operator()(image_rgba8 & dst) const
-    {
-        using pixel_type = image_rgba8::pixel_type;
-        image_rgba8 src = util::get<image_rgba8>(src_);
-        box2d<int> ext0(0,0,dst.width(),dst.height());
-        box2d<int> ext1(x0_,y0_,x0_+src.width(),y0_+src.height());
-
-        if (ext0.intersects(ext1))
-        {
-            box2d<int> box = ext0.intersect(ext1);
-            for (std::size_t y = box.miny(); y < box.maxy(); ++y)
-            {
-                pixel_type* row_to =  dst.get_row(y);
-                pixel_type const * row_from = src.get_row(y-y0_);
-
-                for (std::size_t x = box.minx(); x < box.maxx(); ++x)
-                {
-                    if (row_from[x-x0_] & 0xff000000) // Don't change if alpha == 0
-                    {
-                        row_to[x] = row_from[x-x0_];
-                    }
-                }
-            }
-        }
-    }
-
-    void operator() (image_null &) const
-    {
-        throw std::runtime_error("Set rectangle not support for null images");
-    }
-
-    template <typename T>
-    void operator() (T & dst) const
-    {
-        using pixel_type = typename T::pixel_type;
-        T src = util::get<T>(src_);
-        box2d<int> ext0(0,0,dst.width(),dst.height());
-        box2d<int> ext1(x0_,y0_,x0_+src.width(),y0_+src.height());
-
-        if (ext0.intersects(ext1))
-        {
-            box2d<int> box = ext0.intersect(ext1);
-            for (std::size_t y = box.miny(); y < box.maxy(); ++y)
-            {
-                pixel_type* row_to =  dst.get_row(y);
-                pixel_type const * row_from = src.get_row(y-y0_);
-
-                for (std::size_t x = box.minx(); x < box.maxx(); ++x)
-                {
-                    row_to[x] = row_from[x-x0_];
-                }
-            }
-        }
-    }
-private:
-    image_any const& src_;
-    std::size_t x0_;
-    std::size_t y0_;
-};
-
-} // end detail ns
-
-MAPNIK_DECL void set_rectangle(image_any & dst, image_any const& src, std::size_t x, std::size_t y)
-{
-    util::apply_visitor(detail::visitor_set_rectangle(src, x, y), dst);
-}
-
-template <typename T>
-MAPNIK_DECL void set_rectangle (T & dst, T const& src, std::size_t x, std::size_t y)
-{
-    detail::visitor_set_rectangle visit(src, x, y);
-    visit(dst);
-}
-
-template MAPNIK_DECL void set_rectangle(image_rgba8 &, image_rgba8 const&, std::size_t, std::size_t);
-template MAPNIK_DECL void set_rectangle(image_gray8 &, image_gray8 const&, std::size_t, std::size_t);
-template MAPNIK_DECL void set_rectangle(image_gray8s &, image_gray8s const&, std::size_t, std::size_t);
-template MAPNIK_DECL void set_rectangle(image_gray16 &, image_gray16 const&, std::size_t, std::size_t);
-template MAPNIK_DECL void set_rectangle(image_gray16s &, image_gray16s const&, std::size_t, std::size_t);
-template MAPNIK_DECL void set_rectangle(image_gray32 &, image_gray32 const&, std::size_t, std::size_t);
-template MAPNIK_DECL void set_rectangle(image_gray32s &, image_gray32s const&, std::size_t, std::size_t);
-template MAPNIK_DECL void set_rectangle(image_gray32f &, image_gray32f const&, std::size_t, std::size_t);
-template MAPNIK_DECL void set_rectangle(image_gray64 &, image_gray64 const&, std::size_t, std::size_t);
-template MAPNIK_DECL void set_rectangle(image_gray64s &, image_gray64s const&, std::size_t, std::size_t);
-template MAPNIK_DECL void set_rectangle(image_gray64f &, image_gray64f const&, std::size_t, std::size_t);
-
 namespace detail
 {
 
@@ -1329,9 +1227,10 @@ struct visitor_composite_pixel
         if (mapnik::check_bounds(data, x_, y_))
         {
             image_rgba8::pixel_type rgba = data(x_,y_);
-            value_type ca = static_cast<unsigned>(((c_ >> 24) & 0xff) * opacity_);
-            value_type cb = (c_ >> 16 ) & 0xff;
-            value_type cg = (c_ >> 8) & 0xff;
+            // TODO use std::round for consistent rounding
+            value_type ca = safe_cast<value_type>(((c_ >> 24u) & 0xff) * opacity_);
+            value_type cb = (c_ >> 16u) & 0xff;
+            value_type cg = (c_ >> 8u) & 0xff;
             value_type cr = (c_ & 0xff);
             blender_type::blend_pix(comp_op_, reinterpret_cast<value_type*>(&rgba), cr, cg, cb, ca, cover_);
             data(x_,y_) = rgba;
@@ -1339,7 +1238,7 @@ struct visitor_composite_pixel
     }
 
     template <typename T>
-    void operator() (T & data) const
+    void operator() (T &) const
     {
         throw std::runtime_error("Composite pixel is not supported for this data type");
     }
@@ -1349,7 +1248,7 @@ private:
     composite_mode_e comp_op_;
     std::size_t const x_;
     std::size_t const y_;
-    int const c_;
+    unsigned const c_;
     unsigned const cover_;
 
 };
@@ -1392,22 +1291,9 @@ struct visitor_set_pixel
     void operator() (T2 & data) const
     {
         using pixel_type = typename T2::pixel_type;
-        pixel_type val;
-        try
-        {
-            val = numeric_cast<pixel_type>(val_);
-        }
-        catch(negative_overflow&)
-        {
-            val = std::numeric_limits<pixel_type>::min();
-        }
-        catch(positive_overflow&)
-        {
-            val = std::numeric_limits<pixel_type>::max();
-        }
         if (check_bounds(data, x_, y_))
         {
-            data(x_, y_) = val;
+            data(x_, y_) = safe_cast<pixel_type>(val_);
         }
     }
 
@@ -1699,20 +1585,7 @@ struct visitor_get_pixel
         using pixel_type = T1;
         if (check_bounds(data, x_, y_))
         {
-            T1 val;
-            try
-            {
-                val = numeric_cast<T1>(data(x_,y_));
-            }
-            catch(negative_overflow&)
-            {
-                val = std::numeric_limits<T1>::min();
-            }
-            catch(positive_overflow&)
-            {
-                val = std::numeric_limits<T1>::max();
-            }
-            return val;
+            return safe_cast<T1>(data(x_, y_));
         }
         else
         {
@@ -2220,7 +2093,7 @@ struct visitor_view_to_stream
         for (std::size_t i=0;i<view.height();i++)
         {
             os_.write(reinterpret_cast<const char*>(view.get_row(i)),
-                      view.row_size());
+                      safe_cast<std::streamsize>(view.row_size()));
         }
     }
 
@@ -2389,11 +2262,11 @@ MAPNIK_DECL std::size_t compare<image_rgba8>(image_rgba8 const& im1, image_rgba8
                 unsigned rgba = row_from[x];
                 unsigned rgba2 = row_from2[x];
                 unsigned r = rgba & 0xff;
-                unsigned g = (rgba >> 8 ) & 0xff;
-                unsigned b = (rgba >> 16) & 0xff;
+                unsigned g = (rgba >> 8u) & 0xff;
+                unsigned b = (rgba >> 16u) & 0xff;
                 unsigned r2 = rgba2 & 0xff;
-                unsigned g2 = (rgba2 >> 8 ) & 0xff;
-                unsigned b2 = (rgba2 >> 16) & 0xff;
+                unsigned g2 = (rgba2 >> 8u) & 0xff;
+                unsigned b2 = (rgba2 >> 16u) & 0xff;
                 if (std::abs(static_cast<int>(r - r2)) > static_cast<int>(threshold) ||
                     std::abs(static_cast<int>(g - g2)) > static_cast<int>(threshold) ||
                     std::abs(static_cast<int>(b - b2)) > static_cast<int>(threshold)) {
@@ -2401,8 +2274,8 @@ MAPNIK_DECL std::size_t compare<image_rgba8>(image_rgba8 const& im1, image_rgba8
                     continue;
                 }
                 if (alpha) {
-                    unsigned a = (rgba >> 24) & 0xff;
-                    unsigned a2 = (rgba2 >> 24) & 0xff;
+                    unsigned a = (rgba >> 24u) & 0xff;
+                    unsigned a2 = (rgba2 >> 24u) & 0xff;
                     if (std::abs(static_cast<int>(a - a2)) > static_cast<int>(threshold)) {
                         ++difference;
                         continue;
@@ -2427,11 +2300,11 @@ MAPNIK_DECL std::size_t compare<image_rgba8>(image_rgba8 const& im1, image_rgba8
             unsigned rgba = row_from[x];
             unsigned rgba2 = row_from2[x];
             unsigned r = rgba & 0xff;
-            unsigned g = (rgba >> 8 ) & 0xff;
-            unsigned b = (rgba >> 16) & 0xff;
+            unsigned g = (rgba >> 8u) & 0xff;
+            unsigned b = (rgba >> 16u) & 0xff;
             unsigned r2 = rgba2 & 0xff;
-            unsigned g2 = (rgba2 >> 8 ) & 0xff;
-            unsigned b2 = (rgba2 >> 16) & 0xff;
+            unsigned g2 = (rgba2 >> 8u) & 0xff;
+            unsigned b2 = (rgba2 >> 16u) & 0xff;
             if (std::abs(static_cast<int>(r - r2)) > static_cast<int>(threshold) ||
                 std::abs(static_cast<int>(g - g2)) > static_cast<int>(threshold) ||
                 std::abs(static_cast<int>(b - b2)) > static_cast<int>(threshold)) {
@@ -2439,8 +2312,8 @@ MAPNIK_DECL std::size_t compare<image_rgba8>(image_rgba8 const& im1, image_rgba8
                 continue;
             }
             if (alpha) {
-                unsigned a = (rgba >> 24) & 0xff;
-                unsigned a2 = (rgba2 >> 24) & 0xff;
+                unsigned a = (rgba >> 24u) & 0xff;
+                unsigned a2 = (rgba2 >> 24u) & 0xff;
                 if (std::abs(static_cast<int>(a - a2)) > static_cast<int>(threshold)) {
                     ++difference;
                     continue;
diff --git a/src/image_util_jpeg.cpp b/src/image_util_jpeg.cpp
index 14fbd0f..22d6ed4 100644
--- a/src/image_util_jpeg.cpp
+++ b/src/image_util_jpeg.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/image_util_png.cpp b/src/image_util_png.cpp
index 8c11f2a..f2b0517 100644
--- a/src/image_util_png.cpp
+++ b/src/image_util_png.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -216,8 +216,6 @@ void process_rgba8_png_pal(T const& image,
     handle_png_options(t, opts);
     if (pal.valid())
     {
-        png_options opts;
-        handle_png_options(t,opts);
         save_as_png8_pal(stream, image, pal, opts);
     }
     else if (opts.paletted)
diff --git a/src/image_util_tiff.cpp b/src/image_util_tiff.cpp
index 3ac72fc..68ef9d9 100644
--- a/src/image_util_tiff.cpp
+++ b/src/image_util_tiff.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/image_util_webp.cpp b/src/image_util_webp.cpp
index c521e1c..c7b96ac 100644
--- a/src/image_util_webp.cpp
+++ b/src/image_util_webp.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/image_view.cpp b/src/image_view.cpp
index 680e54e..44e4d77 100644
--- a/src/image_view.cpp
+++ b/src/image_view.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/image_view_any.cpp b/src/image_view_any.cpp
index 8bf89b4..6fbbd7b 100644
--- a/src/image_view_any.cpp
+++ b/src/image_view_any.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -47,7 +47,7 @@ struct get_view_height_visitor
 struct get_view_size_visitor
 {
     template <typename T>
-    unsigned operator()(T const& data) const
+    std::size_t operator()(T const& data) const
     {
         return data.size();
     }
@@ -65,7 +65,7 @@ struct get_view_dtype_visitor
 struct get_view_row_size_visitor
 {
     template <typename T>
-    unsigned operator()(T const& data) const
+    std::size_t operator()(T const& data) const
     {
         return data.row_size();
     }
diff --git a/src/jpeg_reader.cpp b/src/jpeg_reader.cpp
index 2134694..4a6284c 100644
--- a/src/jpeg_reader.cpp
+++ b/src/jpeg_reader.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -206,8 +206,11 @@ void jpeg_reader<T>::attach_stream (j_decompress_ptr cinfo, input_stream* in)
 }
 
 template <typename T>
-void jpeg_reader<T>::on_error(j_common_ptr /*cinfo*/)
+void jpeg_reader<T>::on_error(j_common_ptr cinfo)
 {
+    char buffer[JMSG_LENGTH_MAX];
+    (*cinfo->err->format_message)(cinfo, buffer);
+    throw image_reader_exception(std::string("JPEG Reader: libjpeg could not read image: ") + buffer);
 }
 
 template <typename T>
diff --git a/src/json/build.py b/src/json/build.py
index 2e6902f..390465d 100644
--- a/src/json/build.py
+++ b/src/json/build.py
@@ -1,7 +1,7 @@
 #
 # This file is part of Mapnik (c++ mapping toolkit)
 #
-# Copyright (C) 2014 Artem Pavlenko
+# Copyright (C) 2015 Artem Pavlenko
 #
 # Mapnik is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
diff --git a/src/json/mapnik_json_feature_collection_grammar.cpp b/src/json/mapnik_json_feature_collection_grammar.cpp
index 9e13d94..5f598f5 100644
--- a/src/json/mapnik_json_feature_collection_grammar.cpp
+++ b/src/json/mapnik_json_feature_collection_grammar.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/json/mapnik_json_feature_grammar.cpp b/src/json/mapnik_json_feature_grammar.cpp
index 3742dfd..1aa6c7e 100644
--- a/src/json/mapnik_json_feature_grammar.cpp
+++ b/src/json/mapnik_json_feature_grammar.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/json/mapnik_json_generator_grammar.cpp b/src/json/mapnik_json_generator_grammar.cpp
index 10b1382..2b0171f 100644
--- a/src/json/mapnik_json_generator_grammar.cpp
+++ b/src/json/mapnik_json_generator_grammar.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/json/mapnik_json_geometry_grammar.cpp b/src/json/mapnik_json_geometry_grammar.cpp
index 73456fa..f2b96f2 100644
--- a/src/json/mapnik_json_geometry_grammar.cpp
+++ b/src/json/mapnik_json_geometry_grammar.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/json/mapnik_topojson_grammar.cpp b/src/json/mapnik_topojson_grammar.cpp
index 81d6552..e70f7c5 100644
--- a/src/json/mapnik_topojson_grammar.cpp
+++ b/src/json/mapnik_topojson_grammar.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/layer.cpp b/src/layer.cpp
index 1a9cf83..442026b 100644
--- a/src/layer.cpp
+++ b/src/layer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/libxml2_loader.cpp b/src/libxml2_loader.cpp
index 70ca728..3c90407 100644
--- a/src/libxml2_loader.cpp
+++ b/src/libxml2_loader.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/load_map.cpp b/src/load_map.cpp
index 75ab4ea..44d1276 100644
--- a/src/load_map.cpp
+++ b/src/load_map.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -80,7 +80,7 @@ using boost::optional;
 
 constexpr unsigned name2int(const char *str, int off = 0)
 {
-    return !str[off] ? 5381 : (name2int(str, off+1)*33) ^ str[off];
+    return !str[off] ? 5381 : (name2int(str, off+1)*33) ^ static_cast<unsigned>(str[off]);
 }
 
 class map_parser : util::noncopyable
@@ -129,6 +129,7 @@ private:
     void find_unused_nodes_recursive(xml_node const& node, std::string & error_text);
     std::string ensure_relative_to_xml(boost::optional<std::string> const& opt_path);
     void ensure_exists(std::string const& file_path);
+    void check_styles(Map const & map) const throw (config_error);
     boost::optional<color> get_opt_color_attr(boost::property_tree::ptree const& node,
                                               std::string const& name);
 
@@ -143,22 +144,19 @@ private:
     std::string xml_base_path_;
 };
 
-//#include <mapnik/internal/dump_xml.hpp>
+
 void load_map(Map & map, std::string const& filename, bool strict, std::string base_path)
 {
-    // TODO - use xml encoding?
-    xml_tree tree("utf8");
+    xml_tree tree;
     tree.set_filename(filename);
     read_xml(filename, tree.root());
     map_parser parser(map, strict, filename);
     parser.parse_map(map, tree.root(), base_path);
-    //dump_xml(tree.root());
 }
 
 void load_map_string(Map & map, std::string const& str, bool strict, std::string base_path)
 {
-    // TODO - use xml encoding?
-    xml_tree tree("utf8");
+    xml_tree tree;
     if (!base_path.empty())
     {
         read_xml_string(str, tree.root(), base_path); // accept base_path passed into function
@@ -237,7 +235,7 @@ void map_parser::parse_map(Map & map, xml_node const& node, std::string const& b
             }
             map.set_srs(srs);
 
-            optional<unsigned> buffer_size = map_node.get_opt_attr<unsigned>("buffer-size");
+            optional<int> buffer_size = map_node.get_opt_attr<int>("buffer-size");
             if (buffer_size)
             {
                 map.set_buffer_size(*buffer_size);
@@ -328,6 +326,10 @@ void map_parser::parse_map(Map & map, xml_node const& node, std::string const& b
         throw config_error("Not a map file. Node 'Map' not found.");
     }
     find_unused_nodes(node);
+    if (strict_)
+    {
+        check_styles(map);
+    }
 }
 
 void map_parser::parse_map_include(Map & map, xml_node const& node)
@@ -644,7 +646,7 @@ void map_parser::parse_layer(Map & map, xml_node const& node)
             lyr.set_group_by(* group_by);
         }
 
-        optional<unsigned> buffer_size = node.get_opt_attr<unsigned>("buffer-size");
+        optional<int> buffer_size = node.get_opt_attr<int>("buffer-size");
         if (buffer_size)
         {
             lyr.set_buffer_size(*buffer_size);
@@ -1685,4 +1687,19 @@ void map_parser::find_unused_nodes_recursive(xml_node const& node, std::string &
     }
 }
 
+void map_parser::check_styles(Map const & map) const throw (config_error)
+{
+    for (auto const & layer : map.layers())
+    {
+        for (auto const & style : layer.styles())
+        {
+            if (!map.find_style(style))
+            {
+                throw config_error("Unable to process some data while parsing '" + filename_ +
+                    "': Style '" + style + "' required for layer '" + layer.name() + "'.");
+            }
+        }
+    }
+}
+
 } // end of namespace mapnik
diff --git a/src/map.cpp b/src/map.cpp
index c8e1da1..a891ebd 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -309,7 +309,7 @@ bool Map::load_fonts()
         mapnik::util::file file(file_path);
         if (file.open())
         {
-            auto item = font_memory_cache_.emplace(file_path, std::make_pair(std::move(file.data()),file.size()));
+            auto item = font_memory_cache_.emplace(file_path, std::make_pair(file.data(),file.size()));
             if (item.second) result = true;
         }
     }
diff --git a/src/mapped_memory_cache.cpp b/src/mapped_memory_cache.cpp
index c589681..abe08d1 100644
--- a/src/mapped_memory_cache.cpp
+++ b/src/mapped_memory_cache.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -29,8 +29,12 @@
 
 // boost
 #include <boost/assert.hpp>
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
 #include <boost/interprocess/mapped_region.hpp>
 #include <boost/interprocess/file_mapping.hpp>
+#pragma GCC diagnostic pop
 
 namespace mapnik
 {
diff --git a/src/marker_cache.cpp b/src/marker_cache.cpp
index e0fe08d..3f8f939 100644
--- a/src/marker_cache.cpp
+++ b/src/marker_cache.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -72,8 +72,7 @@ void marker_cache::clear()
 #ifdef MAPNIK_THREADSAFE
     std::lock_guard<std::mutex> lock(mutex_);
 #endif
-    using iterator_type = boost::unordered_map<std::string, std::shared_ptr<mapnik::marker const> >::const_iterator;
-    iterator_type itr = marker_cache_.begin();
+    auto itr = marker_cache_.begin();
     while(itr != marker_cache_.end())
     {
         if (!is_uri(itr->first))
@@ -100,8 +99,7 @@ bool marker_cache::is_image_uri(std::string const& path)
 bool marker_cache::insert_svg(std::string const& name, std::string const& svg_string)
 {
     std::string key = known_svg_prefix_ + name;
-    using iterator_type = boost::unordered_map<std::string, std::string>::const_iterator;
-    iterator_type itr = svg_cache_.find(key);
+    auto itr = svg_cache_.find(key);
     if (itr == svg_cache_.end())
     {
         return svg_cache_.emplace(key,svg_string).second;
@@ -128,13 +126,13 @@ struct visitor_create_marker
         return mapnik::marker(mapnik::marker_rgba8(data));
     }
 
-    marker operator() (image_null & data)
+    marker operator() (image_null &)
     {
         throw std::runtime_error("Can not make marker from null image data type");
     }
 
     template <typename T>
-    marker operator() (T & data)
+    marker operator() (T &)
     {
         throw std::runtime_error("Can not make marker from this data type");
     }
@@ -153,8 +151,7 @@ std::shared_ptr<mapnik::marker const> marker_cache::find(std::string const& uri,
 #ifdef MAPNIK_THREADSAFE
     std::lock_guard<std::mutex> lock(mutex_);
 #endif
-    using iterator_type = boost::unordered_map<std::string, std::shared_ptr<mapnik::marker const> >::const_iterator;
-    iterator_type itr = marker_cache_.find(uri);
+    auto itr = marker_cache_.find(uri);
     if (itr != marker_cache_.end())
     {
         return itr->second;
@@ -165,7 +162,7 @@ std::shared_ptr<mapnik::marker const> marker_cache::find(std::string const& uri,
         // if uri references a built-in marker
         if (is_svg_uri(uri))
         {
-            boost::unordered_map<std::string, std::string>::const_iterator mark_itr = svg_cache_.find(uri);
+            auto mark_itr = svg_cache_.find(uri);
             if (mark_itr == svg_cache_.end())
             {
                 MAPNIK_LOG_ERROR(marker_cache) << "Marker does not exist: " << uri;
@@ -186,12 +183,12 @@ std::shared_ptr<mapnik::marker const> marker_cache::find(std::string const& uri,
             marker_path->set_dimensions(svg.width(),svg.height());
             if (update_cache)
             {
-                auto emplace_result = marker_cache_.emplace(uri,std::make_shared<mapnik::marker const>(std::move(mapnik::marker_svg(marker_path))));
+                auto emplace_result = marker_cache_.emplace(uri,std::make_shared<mapnik::marker const>(mapnik::marker_svg(marker_path)));
                 return emplace_result.first->second;
             }
             else
             {
-                return std::make_shared<mapnik::marker const>(std::move(mapnik::marker_svg(marker_path)));
+                return std::make_shared<mapnik::marker const>(mapnik::marker_svg(marker_path));
             }
         }
         // otherwise assume file-based
@@ -218,12 +215,12 @@ std::shared_ptr<mapnik::marker const> marker_cache::find(std::string const& uri,
                 marker_path->set_dimensions(svg.width(),svg.height());
                 if (update_cache)
                 {
-                    auto emplace_result = marker_cache_.emplace(uri,std::make_shared<mapnik::marker const>(std::move(mapnik::marker_svg(marker_path))));
+                    auto emplace_result = marker_cache_.emplace(uri,std::make_shared<mapnik::marker const>(mapnik::marker_svg(marker_path)));
                     return emplace_result.first->second;
                 }
                 else
                 {
-                    return std::make_shared<mapnik::marker const>(std::move(mapnik::marker_svg(marker_path)));
+                    return std::make_shared<mapnik::marker const>(mapnik::marker_svg(marker_path));
                 }
             }
             else
@@ -240,14 +237,14 @@ std::shared_ptr<mapnik::marker const> marker_cache::find(std::string const& uri,
                     {
                         auto emplace_result = marker_cache_.emplace(uri,
                                 std::make_shared<mapnik::marker const>(
-                                    std::move(util::apply_visitor(detail::visitor_create_marker(), im))
+                                    util::apply_visitor(detail::visitor_create_marker(), im)
                                 ));
                         return emplace_result.first->second;
                     }
                     else
                     {
                         return std::make_shared<mapnik::marker const>(
-                                std::move(util::apply_visitor(detail::visitor_create_marker(), im))
+                            util::apply_visitor(detail::visitor_create_marker(), im)
                         );
                     }
                 }
diff --git a/src/marker_helpers.cpp b/src/marker_helpers.cpp
index bdc70fa..cf37cdb 100644
--- a/src/marker_helpers.cpp
+++ b/src/marker_helpers.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -22,6 +22,7 @@
 
 // mapnik
 #include <mapnik/marker_helpers.hpp>
+#include <mapnik/svg/svg_converter.hpp>
 
 #include "agg_ellipse.h"
 #include "agg_color_rgba.h"
diff --git a/src/memory.cpp b/src/memory.cpp
deleted file mode 100644
index 6f4351d..0000000
--- a/src/memory.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/*****************************************************************************
- *
- * This file is part of Mapnik (c++ mapping toolkit)
- *
- * Copyright (C) 2014 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
- *
- *****************************************************************************/
-
-// mapnik
-#include <mapnik/debug.hpp>
-#include <mapnik/memory.hpp>
-
-#include <cassert>
-
-namespace mapnik
-{
-void* Object::operator new(size_t size)
-{
-    void* block=::operator new (size);
-    return (char*) block;
-}
-
-void* Object::operator new(size_t size,MemoryManager* manager)
-{
-    assert(manager);
-    size_t headerSize=MemoryUtils::alignPointerSize(sizeof(MemoryManager*));
-    void* const block=manager->allocate(headerSize+size);
-    *(MemoryManager**)block=manager;
-    return (char*)block+headerSize;
-}
-
-void Object::operator delete(void* p)
-{
-    ::operator delete(p);
-}
-
-void Object::operator delete(void* , MemoryManager* )
-{
-    //MAPNIK_LOG_DEBUG(memory) << "operator delete with Manager " << std::hex << p << " " << manager;
-}
-
-inline size_t MemoryUtils::alignPointerSize(size_t ptrSize)
-{
-    size_t alignment=(sizeof(void*) >= sizeof(double)) ? sizeof(void*) : sizeof(double);
-    size_t current=ptrSize % alignment;
-    return (current==0)?ptrSize:(ptrSize+alignment-current);
-}
-}
diff --git a/src/memory_datasource.cpp b/src/memory_datasource.cpp
index eb107d3..c30f674 100644
--- a/src/memory_datasource.cpp
+++ b/src/memory_datasource.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/miniz_png.cpp b/src/miniz_png.cpp
index 1837301..fb26585 100644
--- a/src/miniz_png.cpp
+++ b/src/miniz_png.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -30,9 +30,14 @@
 #define MINIZ_NO_ARCHIVE_APIS
 #define MINIZ_NO_ZLIB_COMPATIBLE_NAMES
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 extern "C" {
 #include "miniz.c"
 }
+#pragma GCC diagnostic pop
+
 // zlib
 #include <zlib.h>
 
diff --git a/src/palette.cpp b/src/palette.cpp
index 803e0ef..54e4346 100644
--- a/src/palette.cpp
+++ b/src/palette.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/params.cpp b/src/params.cpp
index 014a5c2..8d3a2c8 100644
--- a/src/params.cpp
+++ b/src/params.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/parse_path.cpp b/src/parse_path.cpp
index 0064f3a..a3d67c2 100644
--- a/src/parse_path.cpp
+++ b/src/parse_path.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/parse_transform.cpp b/src/parse_transform.cpp
index c940301..e2daaf4 100644
--- a/src/parse_transform.cpp
+++ b/src/parse_transform.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/plugin.cpp b/src/plugin.cpp
index b803a50..7b05728 100644
--- a/src/plugin.cpp
+++ b/src/plugin.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/png_reader.cpp b/src/png_reader.cpp
index 08619ec..03968c0 100644
--- a/src/png_reader.cpp
+++ b/src/png_reader.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/proj_transform.cpp b/src/proj_transform.cpp
index b2cb37d..a08b4d7 100644
--- a/src/proj_transform.cpp
+++ b/src/proj_transform.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -26,7 +26,6 @@
 #include <mapnik/projection.hpp>
 #include <mapnik/proj_transform.hpp>
 #include <mapnik/coord.hpp>
-#include <mapnik/utils.hpp>
 
 #ifdef MAPNIK_USE_PROJ4
 // proj4
@@ -164,6 +163,13 @@ bool proj_transform::forward (double * x, double * y , double * z, int point_cou
         return false;
     }
 
+    for(int j=0; j<point_count; j++) {
+        if (x[j] == HUGE_VAL || y[j] == HUGE_VAL)
+        {
+            return false;
+        }
+    }
+
     if (is_dest_longlat_)
     {
         int i;
@@ -206,6 +212,13 @@ bool proj_transform::backward (double * x, double * y , double * z, int point_co
         return false;
     }
 
+    for(int j=0; j<point_count; j++) {
+        if (x[j] == HUGE_VAL || y[j] == HUGE_VAL)
+        {
+            return false;
+        }
+    }
+
     if (is_source_longlat_)
     {
         int i;
@@ -233,7 +246,7 @@ unsigned int proj_transform::backward (geometry::line_string<double> & ls) const
 {
     std::size_t size = ls.size();
     if (size == 0) return 0;
-    
+
     if (is_source_equal_dest_)
         return 0;
 
@@ -247,7 +260,7 @@ unsigned int proj_transform::backward (geometry::line_string<double> & ls) const
         lonlat2merc(ls);
         return 0;
     }
-    
+
     geometry::point<double> * ptr = ls.data();
     double * x = reinterpret_cast<double*>(ptr);
     double * y = x + 1;
@@ -270,7 +283,7 @@ bool proj_transform::forward (box2d<double> & box) const
     double lry = box.miny();
     double lrx = box.maxx();
     double urx = box.maxx();
-    double uly = box.maxy(); 
+    double uly = box.maxy();
     double ury = box.maxy();
     double z = 0.0;
     if (!forward(llx,lly,z))
@@ -304,7 +317,7 @@ bool proj_transform::backward (box2d<double> & box) const
     double lry = box.miny();
     double lrx = box.maxx();
     double urx = box.maxx();
-    double uly = box.maxy(); 
+    double uly = box.maxy();
     double ury = box.maxy();
     double z = 0.0;
     if (!backward(llx,lly,z))
@@ -326,8 +339,7 @@ bool proj_transform::backward (box2d<double> & box) const
     return true;
 }
 
-/* Returns points in clockwise order. This allows us to do anti-meridian checks.
- */
+// Returns points in clockwise order. This allows us to do anti-meridian checks.
 void envelope_points(std::vector< coord<double,2> > & coords, box2d<double>& env, int points)
 {
     double width = env.width();
@@ -358,7 +370,7 @@ void envelope_points(std::vector< coord<double,2> > & coords, box2d<double>& env
     }
 }
 
-/* determine if an ordered sequence of coordinates is in clockwise order */
+// determine if an ordered sequence of coordinates is in clockwise order
 bool is_clockwise(const std::vector< coord<double,2> > & coords)
 {
     int n = coords.size();
@@ -385,12 +397,12 @@ box2d<double> calculate_bbox(std::vector<coord<double,2> > & points) {
 }
 
 
-/* More robust, but expensive, bbox transform
- * in the face of proj4 out of bounds conditions.
- * Can result in 20 -> 10 r/s performance hit.
- * Alternative is to provide proper clipping box
- * in the target srs by setting map 'maximum-extent'
- */
+// More robust, but expensive, bbox transform
+// in the face of proj4 out of bounds conditions.
+// Can result in 20 -> 10 r/s performance hit.
+// Alternative is to provide proper clipping box
+// in the target srs by setting map 'maximum-extent'
+
 bool proj_transform::backward(box2d<double>& env, int points) const
 {
     if (is_source_equal_dest_)
@@ -413,15 +425,15 @@ bool proj_transform::backward(box2d<double>& env, int points) const
     }
 
     box2d<double> result = calculate_bbox(coords);
-    if (is_source_longlat_ && !is_clockwise(coords)) {
-        /* we've gone to a geographic CS, and our clockwise envelope has
-         * changed into an anticlockwise one. This means we've crossed the antimeridian, and
-         * need to expand the X direction to +/-180 to include all the data. Once we can deal
-         * with multiple bboxes in queries we can improve.
-         */
-         double miny = result.miny();
-         result.expand_to_include(-180.0, miny);
-         result.expand_to_include(180.0, miny);
+    if (is_source_longlat_ && !is_clockwise(coords))
+    {
+        // we've gone to a geographic CS, and our clockwise envelope has
+        // changed into an anticlockwise one. This means we've crossed the antimeridian, and
+        // need to expand the X direction to +/-180 to include all the data. Once we can deal
+        // with multiple bboxes in queries we can improve.
+        double miny = result.miny();
+        result.expand_to_include(-180.0, miny);
+        result.expand_to_include(180.0, miny);
     }
 
     env.re_center(result.center().x, result.center().y);
@@ -454,15 +466,15 @@ bool proj_transform::forward(box2d<double>& env, int points) const
 
     box2d<double> result = calculate_bbox(coords);
 
-    if (is_dest_longlat_ && !is_clockwise(coords)) {
-        /* we've gone to a geographic CS, and our clockwise envelope has
-         * changed into an anticlockwise one. This means we've crossed the antimeridian, and
-         * need to expand the X direction to +/-180 to include all the data. Once we can deal
-         * with multiple bboxes in queries we can improve.
-         */
-         double miny = result.miny();
-         result.expand_to_include(-180.0, miny);
-         result.expand_to_include(180.0, miny);
+    if (is_dest_longlat_ && !is_clockwise(coords))
+    {
+        // we've gone to a geographic CS, and our clockwise envelope has
+        // changed into an anticlockwise one. This means we've crossed the antimeridian, and
+        // need to expand the X direction to +/-180 to include all the data. Once we can deal
+        // with multiple bboxes in queries we can improve.
+        double miny = result.miny();
+        result.expand_to_include(-180.0, miny);
+        result.expand_to_include(180.0, miny);
     }
 
     env.re_center(result.center().x, result.center().y);
diff --git a/src/projection.cpp b/src/projection.cpp
index 81e2427..07f78ba 100644
--- a/src/projection.cpp
+++ b/src/projection.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -22,7 +22,6 @@
 
 // mapnik
 #include <mapnik/projection.hpp>
-#include <mapnik/utils.hpp>
 #include <mapnik/util/trim.hpp>
 #include <mapnik/well_known_srs.hpp>
 
diff --git a/src/rapidxml_loader.cpp b/src/rapidxml_loader.cpp
index 841fa9f..c0a631f 100644
--- a/src/rapidxml_loader.cpp
+++ b/src/rapidxml_loader.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -26,13 +26,13 @@
 
 // mapnik
 #include <mapnik/config_error.hpp>
-#include <mapnik/utils.hpp>
 #include <mapnik/util/fs.hpp>
 #include <mapnik/xml_loader.hpp>
 #include <boost/property_tree/detail/xml_parser_read_rapidxml.hpp>
 #include <mapnik/xml_node.hpp>
 #include <mapnik/util/trim.hpp>
 #include <mapnik/util/noncopyable.hpp>
+#include <mapnik/util/utf_conv_win.hpp>
 
 // stl
 #include <iostream>
@@ -138,7 +138,11 @@ private:
         {
             if (cur_node->value_size() > 0) // Don't add empty text nodes
             {
-                node.add_child(cur_node->value(), 0, true);
+                // parsed text values should have leading and trailing
+                // whitespace trimmed.
+                std::string trimmed = cur_node->value();
+                mapnik::util::trim(trimmed);
+                node.add_child(trimmed.c_str(), 0, true);
             }
         }
         break;
diff --git a/src/raster_colorizer.cpp b/src/raster_colorizer.cpp
index a48dbdf..22d3ee8 100644
--- a/src/raster_colorizer.cpp
+++ b/src/raster_colorizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/renderer_common.cpp b/src/renderer_common.cpp
index ecba136..37223e3 100644
--- a/src/renderer_common.cpp
+++ b/src/renderer_common.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -25,6 +25,7 @@
 #include <mapnik/map.hpp>
 #include <mapnik/request.hpp>
 #include <mapnik/attribute.hpp>
+#include <mapnik/safe_cast.hpp>
 
 namespace mapnik {
 
diff --git a/src/renderer_common/process_group_symbolizer.cpp b/src/renderer_common/process_group_symbolizer.cpp
index bac2631..ebef914 100644
--- a/src/renderer_common/process_group_symbolizer.cpp
+++ b/src/renderer_common/process_group_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -37,6 +37,15 @@ vector_marker_render_thunk::vector_marker_render_thunk(svg_path_ptr const& src,
       comp_op_(comp_op), snap_to_pixels_(snap_to_pixels)
 {}
 
+vector_marker_render_thunk::vector_marker_render_thunk(vector_marker_render_thunk && rhs)
+  : src_(std::move(rhs.src_)),
+    attrs_(std::move(rhs.attrs_)),
+    tr_(std::move(rhs.tr_)),
+    opacity_(std::move(rhs.opacity_)),
+    comp_op_(std::move(rhs.comp_op_)),
+    snap_to_pixels_(std::move(rhs.snap_to_pixels_)) {}
+
+
 raster_marker_render_thunk::raster_marker_render_thunk(image_rgba8 const& src,
                                                        agg::trans_affine const& marker_trans,
                                                        double opacity,
@@ -46,6 +55,14 @@ raster_marker_render_thunk::raster_marker_render_thunk(image_rgba8 const& src,
       snap_to_pixels_(snap_to_pixels)
 {}
 
+raster_marker_render_thunk::raster_marker_render_thunk(raster_marker_render_thunk && rhs)
+      : src_(rhs.src_),
+        tr_(std::move(rhs.tr_)),
+        opacity_(std::move(rhs.opacity_)),
+        comp_op_(std::move(rhs.comp_op_)),
+        snap_to_pixels_(std::move(rhs.snap_to_pixels_)) {}
+
+
 text_render_thunk::text_render_thunk(helper_ptr && helper,
                                      double opacity, composite_mode_e comp_op,
                                      halo_rasterizer_enum halo_rasterizer)
@@ -56,6 +73,13 @@ text_render_thunk::text_render_thunk(helper_ptr && helper,
       halo_rasterizer_(halo_rasterizer)
 {}
 
+text_render_thunk::text_render_thunk(text_render_thunk && rhs)
+      : helper_(std::move(rhs.helper_)),
+        placements_(std::move(rhs.placements_)),
+        opacity_(std::move(rhs.opacity_)),
+        comp_op_(std::move(rhs.comp_op_)),
+        halo_rasterizer_(std::move(rhs.halo_rasterizer_)) {}
+
 namespace detail {
 
 template <typename Detector, typename RendererContext>
@@ -195,11 +219,11 @@ void render_thunk_extractor::update_box() const
     {
         if (box_.width() > 0 && box_.height() > 0)
         {
-            box_.expand_to_include(label.box);
+            box_.expand_to_include(label.get().box);
         }
         else
         {
-            box_ = label.box;
+            box_ = label.get().box;
         }
     }
 
diff --git a/src/renderer_common/render_pattern.cpp b/src/renderer_common/render_pattern.cpp
index 67ddbe5..06477d4 100644
--- a/src/renderer_common/render_pattern.cpp
+++ b/src/renderer_common/render_pattern.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/request.cpp b/src/request.cpp
index 46fc220..f74f62c 100644
--- a/src/request.cpp
+++ b/src/request.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/rule.cpp b/src/rule.cpp
index 55a1ba2..2fec472 100644
--- a/src/rule.cpp
+++ b/src/rule.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/save_map.cpp b/src/save_map.cpp
index 42314d0..d757f9e 100644
--- a/src/save_map.cpp
+++ b/src/save_map.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -52,11 +52,12 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
 #include <boost/algorithm/string.hpp>
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#include <boost/property_tree/ptree.hpp>
+#include <boost/property_tree/xml_parser.hpp>
 #pragma GCC diagnostic pop
 #include <boost/optional.hpp>
 #include <boost/version.hpp>
-#include <boost/property_tree/ptree.hpp>
-#include <boost/property_tree/xml_parser.hpp>
 
 // stl
 #include <iostream>
@@ -87,12 +88,12 @@ void serialize_text_placements(ptree & node, text_placements_ptr const& p, bool
     {
         set_attr(node, "placement-type", "list");
         //dfl = last properties passed as default so only attributes that change are actually written
-        text_symbolizer_properties *dfl = &(list->defaults);
+        text_symbolizer_properties *dfl2 = &(list->defaults);
         for (unsigned i=0; i < list->size(); ++i)
         {
             ptree & placement_node = node.push_back(ptree::value_type("Placement", ptree()))->second;
-            list->get(i).to_xml(placement_node, explicit_defaults, *dfl);
-            dfl = &(list->get(i));
+            list->get(i).to_xml(placement_node, explicit_defaults, *dfl2);
+            dfl2 = &(list->get(i));
         }
     }
 }
@@ -464,13 +465,12 @@ void serialize_fontset( ptree & map_node, std::string const& name, font_set cons
 
     set_attr(fontset_node, "name", name);
 
-    for (auto const& name : fontset.get_face_names())
+    for (auto const& face_name : fontset.get_face_names())
     {
         ptree & font_node = fontset_node.push_back(
             ptree::value_type("Font", ptree()))->second;
-        set_attr(font_node, "face-name", name);
+        set_attr(font_node, "face-name", face_name);
     }
-
 }
 
 void serialize_datasource( ptree & layer_node, datasource_ptr datasource)
@@ -506,63 +506,63 @@ void serialize_parameters( ptree & map_node, mapnik::parameters const& params)
     }
 }
 
-void serialize_layer( ptree & map_node, const layer & layer, bool explicit_defaults )
+void serialize_layer( ptree & map_node, layer const& lyr, bool explicit_defaults )
 {
     ptree & layer_node = map_node.push_back(
         ptree::value_type("Layer", ptree()))->second;
 
-    if ( layer.name() != "" )
+    if ( lyr.name() != "" )
     {
-        set_attr( layer_node, "name", layer.name() );
+        set_attr( layer_node, "name", lyr.name() );
     }
 
-    if ( layer.srs() != "" )
+    if ( lyr.srs() != "" )
     {
-        set_attr( layer_node, "srs", layer.srs() );
+        set_attr( layer_node, "srs", lyr.srs() );
     }
 
-    if ( !layer.active() || explicit_defaults )
+    if ( !lyr.active() || explicit_defaults )
     {
-        set_attr/*<bool>*/( layer_node, "status", layer.active() );
+        set_attr/*<bool>*/( layer_node, "status", lyr.active() );
     }
 
-    if ( layer.clear_label_cache() || explicit_defaults )
+    if ( lyr.clear_label_cache() || explicit_defaults )
     {
-        set_attr/*<bool>*/( layer_node, "clear-label-cache", layer.clear_label_cache() );
+        set_attr/*<bool>*/( layer_node, "clear-label-cache", lyr.clear_label_cache() );
     }
 
-    if ( layer.minimum_scale_denominator() )
+    if ( lyr.minimum_scale_denominator() != 0 || explicit_defaults )
     {
-        set_attr( layer_node, "minimum_scale_denominator", layer.minimum_scale_denominator() );
+        set_attr( layer_node, "minimum_scale_denominator", lyr.minimum_scale_denominator() );
     }
 
-    if ( layer.maximum_scale_denominator() != std::numeric_limits<double>::max() )
+    if ( lyr.maximum_scale_denominator() != std::numeric_limits<double>::max() || explicit_defaults )
     {
-        set_attr( layer_node, "maximum_scale_denominator", layer.maximum_scale_denominator() );
+        set_attr( layer_node, "maximum_scale_denominator", lyr.maximum_scale_denominator() );
     }
 
-    if ( layer.queryable() || explicit_defaults )
+    if ( lyr.queryable() || explicit_defaults )
     {
-        set_attr( layer_node, "queryable", layer.queryable() );
+        set_attr( layer_node, "queryable", lyr.queryable() );
     }
 
-    if ( layer.cache_features() || explicit_defaults )
+    if ( lyr.cache_features() || explicit_defaults )
     {
-        set_attr/*<bool>*/( layer_node, "cache-features", layer.cache_features() );
+        set_attr/*<bool>*/( layer_node, "cache-features", lyr.cache_features() );
     }
 
-    if ( layer.group_by() != "" || explicit_defaults )
+    if ( lyr.group_by() != "" || explicit_defaults )
     {
-        set_attr( layer_node, "group-by", layer.group_by() );
+        set_attr( layer_node, "group-by", lyr.group_by() );
     }
 
-    boost::optional<int> const& buffer_size = layer.buffer_size();
+    boost::optional<int> const& buffer_size = lyr.buffer_size();
     if ( buffer_size || explicit_defaults)
     {
         set_attr( layer_node, "buffer-size", *buffer_size );
     }
 
-    optional<box2d<double> > const& maximum_extent = layer.maximum_extent();
+    optional<box2d<double> > const& maximum_extent = lyr.maximum_extent();
     if ( maximum_extent)
     {
         std::ostringstream s;
@@ -572,7 +572,7 @@ void serialize_layer( ptree & map_node, const layer & layer, bool explicit_defau
         set_attr( layer_node, "maximum-extent", s.str() );
     }
 
-    for (auto const& name : layer.styles())
+    for (auto const& name : lyr.styles())
     {
         boost::property_tree::ptree & style_node = layer_node.push_back(
             boost::property_tree::ptree::value_type("StyleName",
@@ -580,7 +580,7 @@ void serialize_layer( ptree & map_node, const layer & layer, bool explicit_defau
         style_node.put_value(name);
     }
 
-    datasource_ptr datasource = layer.datasource();
+    datasource_ptr datasource = lyr.datasource();
     if ( datasource )
     {
         serialize_datasource( layer_node, datasource );
diff --git a/src/scale_denominator.cpp b/src/scale_denominator.cpp
index f7a6220..7e7b2f1 100644
--- a/src/scale_denominator.cpp
+++ b/src/scale_denominator.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/simplify.cpp b/src/simplify.cpp
index e501367..97eae92 100644
--- a/src/simplify.cpp
+++ b/src/simplify.cpp
@@ -5,6 +5,8 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
 #pragma GCC diagnostic ignored "-Wredeclared-class-member"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/assign/list_of.hpp>
 #include <boost/bimap.hpp>
 #pragma GCC diagnostic pop
diff --git a/src/svg/output/process_line_symbolizer.cpp b/src/svg/output/process_line_symbolizer.cpp
index 4640a37..5db205e 100644
--- a/src/svg/output/process_line_symbolizer.cpp
+++ b/src/svg/output/process_line_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/svg/output/process_polygon_symbolizer.cpp b/src/svg/output/process_polygon_symbolizer.cpp
index 18bfaae..c5a1f87 100644
--- a/src/svg/output/process_polygon_symbolizer.cpp
+++ b/src/svg/output/process_polygon_symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -35,7 +35,7 @@ namespace mapnik
 template <typename T>
 void svg_renderer<T>::process(polygon_symbolizer const& sym,
                               mapnik::feature_impl &,
-                              proj_transform const& prj_trans)
+                              proj_transform const&)
 {
     path_attributes_.set_fill_color(get<mapnik::color>(sym, keys::fill, mapnik::color(128,128,128)));
     path_attributes_.set_fill_opacity(get<value_double>(sym,keys::fill_opacity, 1.0));
diff --git a/src/svg/output/process_symbolizers.cpp b/src/svg/output/process_symbolizers.cpp
index a7ca1c0..6ff486f 100644
--- a/src/svg/output/process_symbolizers.cpp
+++ b/src/svg/output/process_symbolizers.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -35,7 +35,7 @@
 #include <mapnik/geometry_transform.hpp>
 #include <mapnik/geometry_to_path.hpp>
 #include <mapnik/util/geometry_to_ds_type.hpp>
-
+#include <mapnik/safe_cast.hpp>
 // boost
 #include <boost/spirit/include/karma.hpp>
 
@@ -59,8 +59,8 @@ struct coord_transformer
         calc_type z = 0.0;
         if (!prj_trans_.backward(x, y, z)) return false;
         tr_.forward(&x,&y);
-        boost::geometry::set<0>(p2, boost::numeric_cast<coordinate_type>(x));
-        boost::geometry::set<1>(p2, boost::numeric_cast<coordinate_type>(y));
+        boost::geometry::set<0>(p2, safe_cast<coordinate_type>(x));
+        boost::geometry::set<1>(p2, safe_cast<coordinate_type>(y));
         return true;
     }
 
diff --git a/src/svg/output/svg_generator.cpp b/src/svg/output/svg_generator.cpp
index d6556ea..4196961 100644
--- a/src/svg/output/svg_generator.cpp
+++ b/src/svg/output/svg_generator.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -28,7 +28,14 @@
 #include <mapnik/svg/output/svg_output_grammars.hpp>
 
 // boost
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/spirit/include/karma.hpp>
+#pragma GCC diagnostic pop
 
 namespace mapnik { namespace svg {
 
diff --git a/src/svg/output/svg_output_attributes.cpp b/src/svg/output/svg_output_attributes.cpp
index fb0b6a7..bf05d87 100644
--- a/src/svg/output/svg_output_attributes.cpp
+++ b/src/svg/output/svg_output_attributes.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/svg/output/svg_output_grammars.cpp b/src/svg/output/svg_output_grammars.cpp
index cc0d514..398c41a 100644
--- a/src/svg/output/svg_output_grammars.cpp
+++ b/src/svg/output/svg_output_grammars.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/svg/output/svg_renderer.cpp b/src/svg/output/svg_renderer.cpp
index 4525cae..c110e5e 100644
--- a/src/svg/output/svg_renderer.cpp
+++ b/src/svg/output/svg_renderer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/svg/svg_parser.cpp b/src/svg/svg_parser.cpp
index a6fa1ee..1ef103c 100644
--- a/src/svg/svg_parser.cpp
+++ b/src/svg/svg_parser.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -25,6 +25,7 @@
 #include <mapnik/svg/svg_parser.hpp>
 #include <mapnik/svg/svg_path_parser.hpp>
 #include <mapnik/config_error.hpp>
+#include <mapnik/safe_cast.hpp>
 
 #include "agg_ellipse.h"
 #include "agg_rounded_rect.h"
@@ -34,6 +35,7 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
 #include <boost/spirit/include/qi.hpp>
 #include <boost/spirit/include/phoenix_core.hpp>
 #include <boost/spirit/include/phoenix_operator.hpp>
@@ -1075,7 +1077,7 @@ void svg_parser::parse(std::string const& filename)
 
 void svg_parser::parse_from_string(std::string const& svg)
 {
-    xmlTextReaderPtr reader = xmlReaderForMemory(svg.c_str(),svg.size(),nullptr,nullptr,
+    xmlTextReaderPtr reader = xmlReaderForMemory(svg.c_str(),safe_cast<int>(svg.size()),nullptr,nullptr,
         (XML_PARSE_NOBLANKS | XML_PARSE_NOCDATA | XML_PARSE_NOERROR | XML_PARSE_NOWARNING));
     if (reader == nullptr)
     {
diff --git a/src/svg/svg_path_parser.cpp b/src/svg/svg_path_parser.cpp
index d694734..ba0ce07 100644
--- a/src/svg/svg_path_parser.cpp
+++ b/src/svg/svg_path_parser.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/svg/svg_points_parser.cpp b/src/svg/svg_points_parser.cpp
index b02dafa..99de4c9 100644
--- a/src/svg/svg_points_parser.cpp
+++ b/src/svg/svg_points_parser.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/svg/svg_transform_parser.cpp b/src/svg/svg_transform_parser.cpp
index ed6e7f6..f41b7b1 100644
--- a/src/svg/svg_transform_parser.cpp
+++ b/src/svg/svg_transform_parser.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/symbolizer.cpp b/src/symbolizer.cpp
index bce44a1..6d3109f 100644
--- a/src/symbolizer.cpp
+++ b/src/symbolizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/symbolizer_enumerations.cpp b/src/symbolizer_enumerations.cpp
index e17fa1b..94227df 100644
--- a/src/symbolizer_enumerations.cpp
+++ b/src/symbolizer_enumerations.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/symbolizer_keys.cpp b/src/symbolizer_keys.cpp
index 099832d..fa5c73d 100644
--- a/src/symbolizer_keys.cpp
+++ b/src/symbolizer_keys.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/text/face.cpp b/src/text/face.cpp
index 3e14aa6..10afa65 100644
--- a/src/text/face.cpp
+++ b/src/text/face.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/text/font_feature_settings.cpp b/src/text/font_feature_settings.cpp
index 67473b5..581c085 100644
--- a/src/text/font_feature_settings.cpp
+++ b/src/text/font_feature_settings.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -29,6 +29,7 @@
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
 #pragma GCC diagnostic ignored "-Wmissing-field-initializers"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
 #include <boost/spirit/include/qi.hpp>
 #include <boost/version.hpp>
 #pragma GCC diagnostic pop
diff --git a/src/text/font_library.cpp b/src/text/font_library.cpp
index 0e19b8c..2bdb4ba 100644
--- a/src/text/font_library.cpp
+++ b/src/text/font_library.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -22,6 +22,7 @@
 
 // mapnik
 #include <mapnik/text/font_library.hpp>
+#include <mapnik/safe_cast.hpp>
 
 // stl
 #include <cstdlib>
@@ -37,19 +38,19 @@ extern "C"
 
 namespace {
 
-void* _Alloc_Func(FT_Memory memory, long size)
+void* _Alloc_Func(FT_Memory, long size)
 {
-    return std::malloc(size);
+    return std::malloc(mapnik::safe_cast<std::size_t>(size));
 }
 
-void _Free_Func(FT_Memory memory, void *block)
+void _Free_Func(FT_Memory, void *block)
 {
     std::free(block);
 }
 
-void* _Realloc_Func(FT_Memory memory, long cur_size, long new_size, void* block)
+void* _Realloc_Func(FT_Memory, long /*cur_size*/, long new_size, void* block)
 {
-    return std::realloc(block, new_size);
+    return std::realloc(block, mapnik::safe_cast<std::size_t>(new_size));
 }
 
 }
@@ -64,7 +65,7 @@ font_library::font_library()
     memory_->free = _Free_Func;
     memory_->realloc = _Realloc_Func;
     FT_Error error = FT_New_Library(&*memory_, &library_);
-    if (error) throw std::runtime_error("can not initalize FreeType2 library");
+    if (error) throw std::runtime_error("can not initialize FreeType2 library");
     FT_Add_Default_Modules(library_);
 }
 
diff --git a/src/text/formatting/base.cpp b/src/text/formatting/base.cpp
index a1e16db..8d8f0a1 100644
--- a/src/text/formatting/base.cpp
+++ b/src/text/formatting/base.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/text/formatting/format.cpp b/src/text/formatting/format.cpp
index e8c14e1..8e0fef5 100644
--- a/src/text/formatting/format.cpp
+++ b/src/text/formatting/format.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/text/formatting/layout.cpp b/src/text/formatting/layout.cpp
index a5b59a8..19da033 100644
--- a/src/text/formatting/layout.cpp
+++ b/src/text/formatting/layout.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/text/formatting/list.cpp b/src/text/formatting/list.cpp
index c8f444f..89e9d23 100644
--- a/src/text/formatting/list.cpp
+++ b/src/text/formatting/list.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/text/formatting/registry.cpp b/src/text/formatting/registry.cpp
index bf49c56..6114f97 100644
--- a/src/text/formatting/registry.cpp
+++ b/src/text/formatting/registry.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/text/formatting/text.cpp b/src/text/formatting/text.cpp
index 8247bd2..c24aab1 100644
--- a/src/text/formatting/text.cpp
+++ b/src/text/formatting/text.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -46,7 +46,7 @@ void text_node::to_xml(ptree & xml) const
     new_node.put_value(to_expression_string(*text_));
 }
 
-node_ptr text_node::from_xml(xml_node const& xml, fontset_map const& fontsets)
+node_ptr text_node::from_xml(xml_node const& xml, fontset_map const&)
 {
     return std::make_shared<text_node>(xml.get_value<expression_ptr>());
 }
diff --git a/src/text/glyph_positions.cpp b/src/text/glyph_positions.cpp
index e950f4e..da3b300 100644
--- a/src/text/glyph_positions.cpp
+++ b/src/text/glyph_positions.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/text/itemizer.cpp b/src/text/itemizer.cpp
index 5058bfd..9f01035 100644
--- a/src/text/itemizer.cpp
+++ b/src/text/itemizer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/text/placement_finder.cpp b/src/text/placement_finder.cpp
index ff44147..7c09e56 100644
--- a/src/text/placement_finder.cpp
+++ b/src/text/placement_finder.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -59,7 +59,11 @@ placement_finder::placement_finder(feature_impl const& feature,
       placements_(),
       has_marker_(false),
       marker_(),
-      marker_box_() {}
+      marker_box_(),
+      marker_unlocked_(false),
+      marker_displacement_(),
+      move_dx_(0.0),
+      horizontal_alignment_(H_LEFT) {}
 
 bool placement_finder::next_position()
 {
@@ -114,7 +118,7 @@ text_upright_e placement_finder::simplify_upright(text_upright_e upright, double
 
 bool placement_finder::find_point_placement(pixel_position const& pos)
 {
-    glyph_positions_ptr glyphs = std::make_shared<glyph_positions>();
+    glyph_positions_ptr glyphs = std::make_unique<glyph_positions>();
     std::vector<box2d<double> > bboxes;
 
     glyphs->reserve(layouts_.glyphs_count());
@@ -178,11 +182,26 @@ bool placement_finder::find_point_placement(pixel_position const& pos)
     // add_marker first checks for collision and then updates the detector.
     if (has_marker_ && !add_marker(glyphs, pos)) return false;
 
-    for (box2d<double> const& bbox : bboxes)
+    box2d<double> label_box;
+    bool first = true;
+    for (box2d<double> const& box : bboxes)
+    {
+        if (first)
+        {
+            label_box = box;
+            first = false;
+        }
+        else
+        {
+            label_box.expand_to_include(box);
+        }
+        detector_.insert(box, layouts_.text());
+    }
+    // do not render text off the canvas
+    if (extent_.intersects(label_box))
     {
-        detector_.insert(bbox, layouts_.text());
+        placements_.push_back(std::move(glyphs));
     }
-    placements_.push_back(glyphs);
 
     return true;
 }
@@ -196,7 +215,7 @@ bool placement_finder::single_line_placement(vertex_cache &pp, text_upright_e or
     vertex_cache::scoped_state begin(pp);
     text_upright_e real_orientation = simplify_upright(orientation, pp.angle());
 
-    glyph_positions_ptr glyphs = std::make_shared<glyph_positions>();
+    glyph_positions_ptr glyphs = std::make_unique<glyph_positions>();
     std::vector<box2d<double> > bboxes;
     glyphs->reserve(layouts_.glyphs_count());
     bboxes.reserve(layouts_.glyphs_count());
@@ -209,7 +228,8 @@ bool placement_finder::single_line_placement(vertex_cache &pp, text_upright_e or
         pixel_position align_offset = layout.alignment_offset();
         pixel_position const& layout_displacement = layout.displacement();
         double sign = (real_orientation == UPRIGHT_LEFT) ? -1 : 1;
-        double offset = layout_displacement.y + 0.5 * sign * layout.height();
+        //double offset = 0 - (layout_displacement.y + 0.5 * sign * layout.height());
+        double offset = layout_displacement.y - 0.5 * sign * layout.height();
         double adjust_character_spacing = .0;
         double layout_width = layout.width();
         bool adjust = layout.horizontal_alignment() == H_ADJUST;
@@ -228,7 +248,7 @@ bool placement_finder::single_line_placement(vertex_cache &pp, text_upright_e or
         {
             // Only subtract half the line height here and half at the end because text is automatically
             // centered on the line
-            offset -= sign * line.height()/2;
+            offset += sign * line.height()/2;
             vertex_cache & off_pp = pp.get_offseted(offset, sign * layout_width);
             vertex_cache::scoped_state off_state(off_pp); // TODO: Remove this when a clean implementation in vertex_cache::get_offseted is done
             double line_width = adjust ? (line.glyphs_width() + line.space_count() * adjust_character_spacing) : line.width();
@@ -296,7 +316,7 @@ bool placement_finder::single_line_placement(vertex_cache &pp, text_upright_e or
                 glyphs->emplace_back(glyph, pos, rot);
             }
             // See comment above
-            offset -= sign * line.height()/2;
+            offset += sign * line.height()/2;
         }
     }
 
@@ -321,11 +341,26 @@ bool placement_finder::single_line_placement(vertex_cache &pp, text_upright_e or
         return single_line_placement(pp, real_orientation == UPRIGHT_RIGHT ? UPRIGHT_LEFT : UPRIGHT_RIGHT);
     }
 
+    box2d<double> label_box;
+    bool first = true;
     for (box2d<double> const& box : bboxes)
     {
+        if (first)
+        {
+            label_box = box;
+            first = false;
+        }
+        else
+        {
+            label_box.expand_to_include(box);
+        }
         detector_.insert(box, layouts_.text());
     }
-    placements_.push_back(glyphs);
+    // do not render text off the canvas
+    if (extent_.intersects(label_box))
+    {
+        placements_.push_back(std::move(glyphs));
+    }
 
     return true;
 }
@@ -364,9 +399,7 @@ bool placement_finder::collision(const box2d<double> &box, const value_unicode_s
         margin = (text_props_->margin != 0 ? text_props_->margin : text_props_->minimum_distance) * scale_factor_;
         repeat_distance = text_props_->repeat_distance * scale_factor_;
     }
-    return !detector_.extent().intersects(box)
-        ||
-        (text_props_->avoid_edges && !extent_.contains(box))
+    return (text_props_->avoid_edges && !extent_.contains(box))
         ||
         (text_props_->minimum_padding > 0 &&
          !extent_.contains(box + (scale_factor_ * text_props_->minimum_padding)))
@@ -387,7 +420,7 @@ void placement_finder::set_marker(marker_info_ptr m, box2d<double> box, bool mar
 }
 
 
-bool placement_finder::add_marker(glyph_positions_ptr glyphs, pixel_position const& pos) const
+bool placement_finder::add_marker(glyph_positions_ptr & glyphs, pixel_position const& pos) const
 {
     pixel_position real_pos = (marker_unlocked_ ? pos : glyphs->get_base_point()) + marker_displacement_;
     box2d<double> bbox = marker_box_;
diff --git a/src/text/placements/base.cpp b/src/text/placements/base.cpp
index 0e70b1c..861c566 100644
--- a/src/text/placements/base.cpp
+++ b/src/text/placements/base.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/text/placements/dummy.cpp b/src/text/placements/dummy.cpp
index 569b5df..dd51db8 100644
--- a/src/text/placements/dummy.cpp
+++ b/src/text/placements/dummy.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -33,7 +33,7 @@ bool text_placement_info_dummy::next() const
 }
 
 text_placement_info_ptr text_placements_dummy::get_placement_info(
-    double scale_factor, feature_impl const& feature, attributes const& vars) const
+    double scale_factor, feature_impl const&, attributes const&) const
 {
     return std::make_shared<text_placement_info_dummy>(this, scale_factor);
 }
diff --git a/src/text/placements/list.cpp b/src/text/placements/list.cpp
index 1c40b68..65c729b 100644
--- a/src/text/placements/list.cpp
+++ b/src/text/placements/list.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -65,7 +65,7 @@ text_symbolizer_properties & text_placements_list::get(unsigned i)
 }
 
 
-text_placement_info_ptr text_placements_list::get_placement_info(double scale_factor, feature_impl const& feature, attributes const& vars) const
+text_placement_info_ptr text_placements_list::get_placement_info(double scale_factor, feature_impl const&, attributes const&) const
 {
     return std::make_shared<text_placement_info_list>(this, scale_factor);
 }
@@ -83,7 +83,7 @@ void text_placements_list::add_expressions(expression_set & output) const
     }
 }
 
-unsigned text_placements_list::size() const
+std::size_t text_placements_list::size() const
 {
     return list_.size();
 }
diff --git a/src/text/placements/registry.cpp b/src/text/placements/registry.cpp
index c7a655b..e24131d 100644
--- a/src/text/placements/registry.cpp
+++ b/src/text/placements/registry.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/text/placements/simple.cpp b/src/text/placements/simple.cpp
index 693b0ba..59e4407 100644
--- a/src/text/placements/simple.cpp
+++ b/src/text/placements/simple.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -35,6 +35,8 @@
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
 #pragma GCC diagnostic ignored "-Wmissing-field-initializers"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#pragma GCC diagnostic ignored "-Wconversion"
 #include <boost/spirit/include/qi.hpp>
 #include <boost/spirit/include/phoenix_core.hpp>
 #include <boost/spirit/include/phoenix_stl.hpp>
@@ -185,7 +187,7 @@ namespace detail {
         }
 
         template <typename T>
-        std::string operator() (T const& val) const
+        std::string operator() (T const&) const
         {
             return "";
         }
diff --git a/src/text/properties_util.cpp b/src/text/properties_util.cpp
index ca76efd..e08d4fd 100644
--- a/src/text/properties_util.cpp
+++ b/src/text/properties_util.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/text/renderer.cpp b/src/text/renderer.cpp
index 25566e9..227c35d 100644
--- a/src/text/renderer.cpp
+++ b/src/text/renderer.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -92,13 +92,12 @@ void text_renderer::prepare_glyphs(glyph_positions const& positions)
 template <typename T>
 void composite_bitmap(T & pixmap, FT_Bitmap *bitmap, unsigned rgba, int x, int y, double opacity, composite_mode_e comp_op)
 {
-    int x_max=x+bitmap->width;
-    int y_max=y+bitmap->rows;
-    int i,p,j,q;
+    int x_max = x + bitmap->width;
+    int y_max = y + bitmap->rows;
 
-    for (i=x,p=0;i<x_max;++i,++p)
+    for (int i = x, p = 0; i < x_max; ++i, ++p)
     {
-        for (j=y,q=0;j<y_max;++j,++q)
+        for (int j = y, q = 0; j < y_max; ++j, ++q)
         {
             unsigned gray=bitmap->buffer[q*bitmap->width+p];
             if (gray)
diff --git a/src/text/symbolizer_helpers.cpp b/src/text/symbolizer_helpers.cpp
index 7b15599..99c7c03 100644
--- a/src/text/symbolizer_helpers.cpp
+++ b/src/text/symbolizer_helpers.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -59,7 +59,7 @@ struct apply_vertex_placement
     {
         double label_x, label_y, z = 0;
         va.rewind(0);
-        for (auto cmd = va.vertex(&label_x, &label_y); cmd != SEG_END;)
+        for (unsigned cmd; (cmd = va.vertex(&label_x, &label_y)) != SEG_END; )
         {
             if (cmd != SEG_CLOSE)
             {
@@ -90,14 +90,30 @@ struct split_multi_geometries
     {
         for ( auto const& pt : multi_pt )
         {
-            cont_.push_back(std::move(base_symbolizer_helper::geometry_cref(std::cref(pt))));
+            cont_.push_back(base_symbolizer_helper::geometry_cref(std::cref(pt)));
         }
     }
+    void operator() (geometry::line_string<double> const& line) const
+    {
+        if (minimum_path_length_ > 0)
+        {
+            box2d<double> bbox = t_.forward(geometry::envelope(line), prj_trans_);
+            if (bbox.width() >= minimum_path_length_)
+            {
+                cont_.push_back(base_symbolizer_helper::geometry_cref(std::cref(line)));
+            }
+        }
+        else
+        {
+            cont_.push_back(base_symbolizer_helper::geometry_cref(std::cref(line)));
+        }
+    }
+
     void operator() (geometry::multi_line_string<double> const& multi_line) const
     {
         for ( auto const& line : multi_line )
         {
-            cont_.push_back(std::move(base_symbolizer_helper::geometry_cref(std::cref(line))));
+            (*this)(line);
         }
     }
 
@@ -108,12 +124,12 @@ struct split_multi_geometries
             box2d<double> bbox = t_.forward(geometry::envelope(poly), prj_trans_);
             if (bbox.width() >= minimum_path_length_)
             {
-                cont_.push_back(std::move(base_symbolizer_helper::geometry_cref(std::cref(poly))));
+                cont_.push_back(base_symbolizer_helper::geometry_cref(std::cref(poly)));
             }
         }
         else
         {
-            cont_.push_back(std::move(base_symbolizer_helper::geometry_cref(std::cref(poly))));
+            cont_.push_back(base_symbolizer_helper::geometry_cref(std::cref(poly)));
         }
     }
 
@@ -136,7 +152,7 @@ struct split_multi_geometries
     template <typename Geometry>
     void operator() (Geometry const& geom) const
     {
-        cont_.push_back(std::move(base_symbolizer_helper::geometry_cref(std::cref(geom))));
+        cont_.push_back(base_symbolizer_helper::geometry_cref(std::cref(geom)));
     }
 
     container_type & cont_;
@@ -182,6 +198,7 @@ struct largest_bbox_first
     bool operator() (base_symbolizer_helper::geometry_cref const& g0,
                      base_symbolizer_helper::geometry_cref const& g1) const
     {
+        // TODO - this has got to be expensive! Can we cache bbox's if there are repeated calls to same geom?
         box2d<double> b0 = geometry::envelope(g0);
         box2d<double> b1 = geometry::envelope(g1);
         return b0.width() * b0.height() > b1.width() * b1.height();
@@ -190,18 +207,26 @@ struct largest_bbox_first
 
 void base_symbolizer_helper::initialize_geometries() const
 {
-    bool largest_box_only = text_props_->largest_bbox_only;
     double minimum_path_length = text_props_->minimum_path_length;
+    auto const& geom = feature_.get_geometry();
     util::apply_visitor(detail::split_multi_geometries<geometry_container_type>
-                        (geometries_to_process_, t_, prj_trans_, minimum_path_length ), feature_.get_geometry());
-    // FIXME: return early if geometries_to_process_.empty() ?
-    if (largest_box_only)
+                        (geometries_to_process_, t_, prj_trans_, minimum_path_length ), geom);
+    if (!geometries_to_process_.empty())
     {
-        geometries_to_process_.sort(largest_bbox_first());
+        auto type = geometry::geometry_type(geom);
+        if (type == geometry::geometry_types::Polygon ||
+            type == geometry::geometry_types::MultiPolygon)
+        {
+            bool largest_box_only = text_props_->largest_bbox_only;
+            if (largest_box_only)
+            {
+                geometries_to_process_.sort(largest_bbox_first());
+                geo_itr_ = geometries_to_process_.begin();
+                geometries_to_process_.erase(++geo_itr_, geometries_to_process_.end());
+            }
+        }
         geo_itr_ = geometries_to_process_.begin();
-        geometries_to_process_.erase(++geo_itr_, geometries_to_process_.end());
     }
-    geo_itr_ = geometries_to_process_.begin();
 }
 
 void base_symbolizer_helper::initialize_points() const
@@ -236,30 +261,30 @@ void base_symbolizer_helper::initialize_points() const
             // https://github.com/mapnik/mapnik/issues/1350
             auto type = geometry::geometry_type(geom);
 
-            // FIXME: how to handle MultiLineString?
+            // note: split_multi_geometries is called above so the only likely types are:
+            // Point, LineString, and Polygon.
             if (type == geometry::geometry_types::LineString)
             {
                 auto const& line = mapnik::util::get<geometry::line_string<double> >(geom);
                 geometry::line_string_vertex_adapter<double> va(line);
                 success = label::middle_point(va, label_x,label_y);
             }
-            else if (how_placed == POINT_PLACEMENT)
+            else if (how_placed == POINT_PLACEMENT || type == geometry::geometry_types::Point)
             {
                 geometry::point<double> pt;
-                geometry::centroid(geom, pt);
-                label_x = pt.x;
-                label_y = pt.y;
-                success = true;
-            }
-            else if (how_placed == INTERIOR_PLACEMENT) // polygon
-            {
-                if (type == geometry::geometry_types::Polygon)
+                if (geometry::centroid(geom, pt))
                 {
-                    auto const& poly = mapnik::util::get<geometry::polygon<double> >(geom);
-                    geometry::polygon_vertex_adapter<double> va(poly);
-                    success = label::interior_position(va, label_x, label_y);
+                    label_x = pt.x;
+                    label_y = pt.y;
+                    success = true;
                 }
             }
+            else if (how_placed == INTERIOR_PLACEMENT && type == geometry::geometry_types::Polygon)
+            {
+                auto const& poly = mapnik::util::get<geometry::polygon<double> >(geom);
+                geometry::polygon_vertex_adapter<double> va(poly);
+                success = label::interior_position(va, label_x, label_y);
+            }
             else
             {
                 MAPNIK_LOG_ERROR(symbolizer_helpers) << "ERROR: Unknown placement type in initialize_points()";
@@ -342,7 +367,7 @@ public:
     }
 
     template <typename T>
-    bool operator()(T const & geo) const
+    bool operator()(T const&) const
     {
         return false;
     }
diff --git a/src/text/text_layout.cpp b/src/text/text_layout.cpp
index fd2fdc5..ff37d28 100644
--- a/src/text/text_layout.cpp
+++ b/src/text/text_layout.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -214,12 +214,12 @@ void text_layout::break_line_icu(std::pair<unsigned, unsigned> && line_limits)
     shape_text(line);
 
     double scaled_wrap_width = wrap_width_ * scale_factor_;
-    if (!scaled_wrap_width || line.width() < scaled_wrap_width)
+    if (scaled_wrap_width <= 0 || line.width() < scaled_wrap_width)
     {
         add_line(std::move(line));
         return;
     }
-    if (text_ratio_)
+    if (text_ratio_ > 0)
     {
         double wrap_at;
         double string_width = line.width();
diff --git a/src/text/text_line.cpp b/src/text/text_line.cpp
index f66af1b..f228e5b 100644
--- a/src/text/text_line.cpp
+++ b/src/text/text_line.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -59,7 +59,7 @@ void text_line::add_glyph(glyph_info && glyph, double scale_factor_)
         glyphs_width_ = advance;
         space_count_ = 0;
     }
-    else if (advance)
+    else if (advance > 0)
     {
         // Only add character spacing if the character is not a zero-width part of a cluster.
         width_ += advance + glyphs_.back().format->character_spacing  * scale_factor_;
diff --git a/src/text/text_properties.cpp b/src/text/text_properties.cpp
index b1e9dd7..4b08c10 100644
--- a/src/text/text_properties.cpp
+++ b/src/text/text_properties.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/tiff_reader.cpp b/src/tiff_reader.cpp
index e257723..dbafdf0 100644
--- a/src/tiff_reader.cpp
+++ b/src/tiff_reader.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -169,14 +169,14 @@ private:
     tiff_reader(const tiff_reader&);
     tiff_reader& operator=(const tiff_reader&);
     void init();
-    void read_generic(unsigned x,unsigned y,image_rgba8& image);
-    void read_stripped(unsigned x,unsigned y,image_rgba8& image);
+    void read_generic(std::size_t x,std::size_t y,image_rgba8& image);
+    void read_stripped(std::size_t x,std::size_t y,image_rgba8& image);
 
     template <typename ImageData>
-    void read_tiled(unsigned x,unsigned y, ImageData & image);
+    void read_tiled(std::size_t x,std::size_t y, ImageData & image);
 
     template <typename ImageData>
-    image_any read_any_gray(unsigned x, unsigned y, unsigned width, unsigned height);
+    image_any read_any_gray(std::size_t x, std::size_t y, std::size_t width, std::size_t height);
 
     TIFF* open(std::istream & input);
 };
@@ -379,21 +379,21 @@ void tiff_reader<T>::read(unsigned x,unsigned y,image_rgba8& image)
 {
     if (read_method_==stripped)
     {
-        read_stripped(x,y,image);
+        read_stripped(static_cast<std::size_t>(x),static_cast<std::size_t>(y),image);
     }
     else if (read_method_==tiled)
     {
-        read_tiled(x,y,image);
+        read_tiled(static_cast<std::size_t>(x),static_cast<std::size_t>(y),image);
     }
     else
     {
-        read_generic(x,y,image);
+        read_generic(static_cast<std::size_t>(x),static_cast<std::size_t>(y),image);
     }
 }
 
 template <typename T>
 template <typename ImageData>
-image_any tiff_reader<T>::read_any_gray(unsigned x0, unsigned y0, unsigned width, unsigned height)
+image_any tiff_reader<T>::read_any_gray(std::size_t x0, std::size_t y0, std::size_t width, std::size_t height)
 {
     using image_type = ImageData;
     using pixel_type = typename image_type::pixel_type;
@@ -410,10 +410,10 @@ image_any tiff_reader<T>::read_any_gray(unsigned x0, unsigned y0, unsigned width
         {
             image_type data(width, height);
             std::size_t block_size = rows_per_strip_ > 0 ? rows_per_strip_ : tile_height_ ;
-            std::ptrdiff_t start_y = y0 - y0 % block_size;
-            std::ptrdiff_t end_y = std::min(y0 + height, static_cast<unsigned>(height_));
-            std::ptrdiff_t start_x = x0;
-            std::ptrdiff_t end_x = std::min(x0 + width, static_cast<unsigned>(width_));
+            std::size_t start_y = y0 - y0 % block_size;
+            std::size_t end_y = std::min(y0 + height, height_);
+            std::size_t start_x = x0;
+            std::size_t end_x = std::min(x0 + width, width_);
             std::size_t element_size = sizeof(pixel_type);
             std::size_t size_to_allocate = (TIFFScanlineSize(tif) + element_size - 1)/element_size;
             const std::unique_ptr<pixel_type[]> scanline(new pixel_type[size_to_allocate]);
@@ -454,7 +454,7 @@ struct tiff_reader_traits
 {
     using image_type = T;
     using pixel_type = typename image_type::pixel_type;
-    static bool read_tile(TIFF * tif, unsigned x, unsigned y, pixel_type* buf, std::size_t tile_width, std::size_t tile_height)
+    static bool read_tile(TIFF * tif, std::size_t x, std::size_t y, pixel_type* buf, std::size_t tile_width, std::size_t tile_height)
     {
         return (TIFFReadEncodedTile(tif, TIFFComputeTile(tif, x,y,0,0), buf, tile_width * tile_height * sizeof(pixel_type)) != -1);
     }
@@ -465,11 +465,11 @@ template <>
 struct tiff_reader_traits<image_rgba8>
 {
     using pixel_type = std::uint32_t;
-    static bool read_tile(TIFF * tif, unsigned x0, unsigned y0, pixel_type* buf, std::size_t tile_width, std::size_t tile_height)
+    static bool read_tile(TIFF * tif, std::size_t x0, std::size_t y0, pixel_type* buf, std::size_t tile_width, std::size_t tile_height)
     {
         if (TIFFReadRGBATile(tif, x0, y0, buf) != -1)
         {
-            for (unsigned y = 0; y < tile_height/2; ++y)
+            for (std::size_t y = 0; y < tile_height/2; ++y)
             {
                 std::swap_ranges(buf + y * tile_width, buf + (y + 1) * tile_width, buf + (tile_height - y - 1) * tile_width);
             }
@@ -482,12 +482,14 @@ struct tiff_reader_traits<image_rgba8>
 }
 
 template <typename T>
-image_any tiff_reader<T>::read(unsigned x0, unsigned y0, unsigned width, unsigned height)
+image_any tiff_reader<T>::read(unsigned x, unsigned y, unsigned width, unsigned height)
 {
     if (width > 10000 || height > 10000)
     {
         throw image_reader_exception("Can't allocate tiff > 10000x10000");
     }
+    std::size_t x0 = static_cast<std::size_t>(x);
+    std::size_t y0 = static_cast<std::size_t>(y);
     switch (photometric_)
     {
     case PHOTOMETRIC_MINISBLACK:
@@ -597,7 +599,7 @@ image_any tiff_reader<T>::read(unsigned x0, unsigned y0, unsigned width, unsigne
 }
 
 template <typename T>
-void tiff_reader<T>::read_generic(unsigned, unsigned, image_rgba8& image)
+void tiff_reader<T>::read_generic(std::size_t, std::size_t, image_rgba8& image)
 {
     TIFF* tif = open(stream_);
     if (tif)
@@ -608,7 +610,7 @@ void tiff_reader<T>::read_generic(unsigned, unsigned, image_rgba8& image)
 
 template <typename T>
 template <typename ImageData>
-void tiff_reader<T>::read_tiled(unsigned x0,unsigned y0, ImageData & image)
+void tiff_reader<T>::read_tiled(std::size_t x0,std::size_t y0, ImageData & image)
 {
     using pixel_type = typename detail::tiff_reader_traits<ImageData>::pixel_type;
 
@@ -616,31 +618,31 @@ void tiff_reader<T>::read_tiled(unsigned x0,unsigned y0, ImageData & image)
     if (tif)
     {
         std::unique_ptr<pixel_type[]> buf(new pixel_type[tile_width_*tile_height_]);
-        int width = image.width();
-        int height = image.height();
-        int start_y = (y0 / tile_height_) * tile_height_;
-        int end_y = ((y0 + height) / tile_height_ + 1) * tile_height_;
-        int start_x = (x0 / tile_width_) * tile_width_;
-        int end_x = ((x0 + width) / tile_width_ + 1) * tile_width_;
-        end_y = std::min(end_y, int(height_));
-        end_x = std::min(end_x, int(width_));
-
-        for (int y = start_y; y < end_y; y += tile_height_)
+        std::size_t width = image.width();
+        std::size_t height = image.height();
+        std::size_t start_y = (y0 / tile_height_) * tile_height_;
+        std::size_t end_y = ((y0 + height) / tile_height_ + 1) * tile_height_;
+        std::size_t start_x = (x0 / tile_width_) * tile_width_;
+        std::size_t end_x = ((x0 + width) / tile_width_ + 1) * tile_width_;
+        end_y = std::min(end_y, height_);
+        end_x = std::min(end_x, width_);
+
+        for (std::size_t y = start_y; y < end_y; y += tile_height_)
         {
-            int ty0 = std::max(y0, static_cast<unsigned>(y)) - y;
-            int ty1 = std::min(height + y0, static_cast<unsigned>(y + tile_height_)) - y;
+            std::size_t ty0 = std::max(y0, y) - y;
+            std::size_t ty1 = std::min(height + y0, y + tile_height_) - y;
 
-            for (int x = start_x; x < end_x; x += tile_width_)
+            for (std::size_t x = start_x; x < end_x; x += tile_width_)
             {
                 if (!detail::tiff_reader_traits<ImageData>::read_tile(tif, x, y, buf.get(), tile_width_, tile_height_))
                 {
                     MAPNIK_LOG_DEBUG(tiff_reader) <<  "read_tile(...) failed at " << x << "/" << y << " for " << width_ << "/" << height_ << "\n";
                     break;
                 }
-                int tx0 = std::max(x0, static_cast<unsigned>(x));
-                int tx1 = std::min(width + x0, static_cast<unsigned>(x + tile_width_));
-                int row = y + ty0 - y0;
-                for (int ty = ty0; ty < ty1; ++ty, ++row)
+                std::size_t tx0 = std::max(x0, x);
+                std::size_t tx1 = std::min(width + x0, x + tile_width_);
+                std::size_t row = y + ty0 - y0;
+                for (std::size_t ty = ty0; ty < ty1; ++ty, ++row)
                 {
                     image.set_row(row, tx0 - x0, tx1 - x0, &buf[ty * tile_width_ + tx0 - x]);
                 }
@@ -651,23 +653,23 @@ void tiff_reader<T>::read_tiled(unsigned x0,unsigned y0, ImageData & image)
 
 
 template <typename T>
-void tiff_reader<T>::read_stripped(unsigned x0,unsigned y0,image_rgba8& image)
+void tiff_reader<T>::read_stripped(std::size_t x0,std::size_t y0,image_rgba8& image)
 {
     TIFF* tif = open(stream_);
     if (tif)
     {
         image_rgba8 strip(width_,rows_per_strip_,false);
-        int width=image.width();
-        int height=image.height();
+        std::size_t width=image.width();
+        std::size_t height=image.height();
 
-        unsigned start_y=(y0/rows_per_strip_)*rows_per_strip_;
-        unsigned end_y=std::min(y0+height, static_cast<unsigned>(height_));
-        int tx0,tx1,ty0,ty1;
+        std::size_t start_y=(y0/rows_per_strip_)*rows_per_strip_;
+        std::size_t end_y=std::min(y0+height, height_);
+        std::size_t tx0,tx1,ty0,ty1;
 
         tx0=x0;
-        tx1=std::min(width+x0,static_cast<unsigned>(width_));
-        int row = 0;
-        for (unsigned y=start_y; y < end_y; y+=rows_per_strip_)
+        tx1=std::min(width+x0,width_);
+        std::size_t row = 0;
+        for (std::size_t y=start_y; y < end_y; y+=rows_per_strip_)
         {
             ty0 = std::max(y0,y)-y;
             ty1 = std::min(end_y,y+rows_per_strip_)-y;
@@ -677,8 +679,8 @@ void tiff_reader<T>::read_stripped(unsigned x0,unsigned y0,image_rgba8& image)
                 MAPNIK_LOG_DEBUG(tiff_reader) << "TIFFReadRGBAStrip failed at " << y << " for " << width_ << "/" << height_ << "\n";
                 break;
             }
-            // This is in reverse becauase the TIFFReadRGBAStrip reads inverted
-            for (unsigned ty = ty1; ty > ty0; --ty)
+            // This is in reverse because the TIFFReadRGBAStrip reads inverted
+            for (std::size_t ty = ty1; ty > ty0; --ty)
             {
                 image.set_row(row,tx0-x0,tx1-x0,&strip.data()[(ty-1)*width_+tx0]);
                 ++row;
diff --git a/src/transform_expression.cpp b/src/transform_expression.cpp
index e065ddc..34c7048 100644
--- a/src/transform_expression.cpp
+++ b/src/transform_expression.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/transform_expression_grammar.cpp b/src/transform_expression_grammar.cpp
index 767730d..170b0a8 100644
--- a/src/transform_expression_grammar.cpp
+++ b/src/transform_expression_grammar.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/unicode.cpp b/src/unicode.cpp
index f6c059f..cf36f55 100644
--- a/src/unicode.cpp
+++ b/src/unicode.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/utils.cpp b/src/util/utf_conv_win.cpp
similarity index 96%
rename from src/utils.cpp
rename to src/util/utf_conv_win.cpp
index f694faa..7bfcbc2 100644
--- a/src/utils.cpp
+++ b/src/util/utf_conv_win.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -22,7 +22,7 @@
 
 #ifdef _WINDOWS
 // windows specific methods for UTF8 from/to UTF16
-#include <mapnik/utils.hpp>
+#include <mapnik/util/utf_conv_win.hpp>
 #include <string>
 #include <vector>
 #define NOMINMAX
diff --git a/src/vertex_cache.cpp b/src/vertex_cache.cpp
index d5a18a3..c0d5758 100644
--- a/src/vertex_cache.cpp
+++ b/src/vertex_cache.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -155,8 +155,14 @@ vertex_cache & vertex_cache::get_offseted(double offset, double region_width)
 
     // find the point on the offset line closest to the current position,
     // which we'll use to make the offset line aligned to this one.
-    double seek = offseted_line->position_closest_to(current_position_);
+    // TODO: `position_closest_to` is disable since it is too expensive:
+    // https://github.com/mapnik/mapnik/issues/2937
+    //double seek = offseted_line->position_closest_to(current_position_);
+    double seek = (position_ + region_width/2.0) * offseted_line->length() / length() - region_width/2.0;
+    if (seek < 0) seek = 0;
+    if (seek > offseted_line->length()) seek = offseted_line->length();
     offseted_line->move(seek);
+
     return *offseted_line;
 }
 
diff --git a/src/warp.cpp b/src/warp.cpp
index f3c168c..5729748 100644
--- a/src/warp.cpp
+++ b/src/warp.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/webp_reader.cpp b/src/webp_reader.cpp
index b13627e..fbd0460 100644
--- a/src/webp_reader.cpp
+++ b/src/webp_reader.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/well_known_srs.cpp b/src/well_known_srs.cpp
index 8aaf7ab..d3296ef 100644
--- a/src/well_known_srs.cpp
+++ b/src/well_known_srs.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/src/wkb.cpp b/src/wkb.cpp
index 87cd305..19b31ca 100644
--- a/src/wkb.cpp
+++ b/src/wkb.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -124,72 +124,72 @@ public:
         switch (type)
         {
         case wkbPoint:
-            geom = std::move(read_point());
+            geom = read_point();
             break;
         case wkbLineString:
-            geom = std::move(read_linestring());
+            geom = read_linestring();
             break;
         case wkbPolygon:
-            geom = std::move(read_polygon());
+            geom = read_polygon();
             break;
         case wkbMultiPoint:
-            geom = std::move(read_multipoint());
+            geom = read_multipoint();
             break;
         case wkbMultiLineString:
-            geom = std::move(read_multilinestring());
+            geom = read_multilinestring();
             break;
         case wkbMultiPolygon:
-            geom = std::move(read_multipolygon());
+            geom = read_multipolygon();
             break;
         case wkbGeometryCollection:
-            geom = std::move(read_collection());
+            geom = read_collection();
             break;
         case wkbPointZ:
         case wkbPointM:
-            geom = std::move(read_point<true>());
+            geom = read_point<true>();
             break;
         case wkbPointZM:
-            geom = std::move(read_point<true,true>());
+            geom = read_point<true,true>();
             break;
         case wkbLineStringZ:
         case wkbLineStringM:
-            geom = std::move(read_linestring<true>());
+            geom = read_linestring<true>();
             break;
         case wkbLineStringZM:
-            geom = std::move(read_linestring<true,true>());
+            geom = read_linestring<true,true>();
             break;
         case wkbPolygonZ:
         case wkbPolygonM:
-            geom = std::move(read_polygon<true>());
+            geom = read_polygon<true>();
             break;
         case wkbPolygonZM:
-            geom = std::move(read_polygon<true,true>());
+            geom = read_polygon<true,true>();
             break;
         case wkbMultiPointZ:
         case wkbMultiPointM:
-            geom = std::move(read_multipoint<true>());
+            geom = read_multipoint<true>();
             break;
         case wkbMultiPointZM:
-            geom = std::move(read_multipoint<true,true>());
+            geom = read_multipoint<true,true>();
             break;
         case wkbMultiLineStringZ:
         case wkbMultiLineStringM:
-            geom = std::move(read_multilinestring<true>());
+            geom = read_multilinestring<true>();
             break;
         case wkbMultiLineStringZM:
-            geom = std::move(read_multilinestring<true,true>());
+            geom = read_multilinestring<true,true>();
             break;
         case wkbMultiPolygonZ:
         case wkbMultiPolygonM:
-            geom = std::move(read_multipolygon<true>());
+            geom = read_multipolygon<true>();
             break;
         case wkbMultiPolygonZM:
-            geom = std::move(read_multipolygon<true,true>());
+            geom = read_multipolygon<true,true>();
             break;
         case wkbGeometryCollectionZ:
         case wkbGeometryCollectionM:
         case wkbGeometryCollectionZM:
-            geom = std::move(read_collection());
+            geom = read_collection();
             break;
         default:
             break;
@@ -307,7 +307,7 @@ private:
         for (int i = 0; i < num_lines; ++i)
         {
             pos_ += 5;
-            multi_line.push_back(std::move(read_linestring<M, Z>()));
+            multi_line.push_back(read_linestring<M, Z>());
         }
         return multi_line;
     }
@@ -345,7 +345,7 @@ private:
         for (int i = 0; i < num_polys; ++i)
         {
             pos_ += 5;
-            multi_poly.push_back(std::move(read_polygon<M, Z>()));
+            multi_poly.push_back(read_polygon<M, Z>());
         }
         return multi_poly;
     }
@@ -357,7 +357,7 @@ private:
         for (int i = 0; i < num_geometries; ++i)
         {
             pos_ += 1; // skip byte order
-            collection.push_back(std::move(read()));
+            collection.push_back(read());
          }
         return collection;
      }
diff --git a/src/wkt/build.py b/src/wkt/build.py
index 88ac36a..e925cf4 100644
--- a/src/wkt/build.py
+++ b/src/wkt/build.py
@@ -1,7 +1,7 @@
 #
 # This file is part of Mapnik (c++ mapping toolkit)
 #
-# Copyright (C) 2014 Artem Pavlenko
+# Copyright (C) 2015 Artem Pavlenko
 #
 # Mapnik is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -17,7 +17,7 @@
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
-# 
+#
 
 import os
 from glob import glob
diff --git a/src/wkt/mapnik_wkt_generator_grammar.cpp b/src/wkt/mapnik_wkt_generator_grammar.cpp
index 780c08a..07813fc 100644
--- a/src/wkt/mapnik_wkt_generator_grammar.cpp
+++ b/src/wkt/mapnik_wkt_generator_grammar.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -27,7 +27,7 @@
 namespace mapnik { namespace wkt {
 
 using sink_type = std::back_insert_iterator<std::string>;
-template struct wkt_generator_grammar<sink_type, mapnik::geometry::geometry<double>, double >;
-template struct wkt_generator_grammar_int<sink_type, mapnik::geometry::geometry<std::int64_t>, std::int64_t >;
+template struct wkt_generator_grammar<sink_type, mapnik::geometry::geometry<double>>;
+template struct wkt_generator_grammar<sink_type, mapnik::geometry::geometry<std::int64_t>>;
 
 }}
diff --git a/src/xml_tree.cpp b/src/xml_tree.cpp
index 410a2bc..e342e68 100644
--- a/src/xml_tree.cpp
+++ b/src/xml_tree.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -68,6 +68,7 @@ struct name_trait
 DEFINE_NAME_TRAIT( double, "double")
 DEFINE_NAME_TRAIT( float, "float")
 DEFINE_NAME_TRAIT( unsigned, "unsigned")
+DEFINE_NAME_TRAIT( int, "int")
 DEFINE_NAME_TRAIT( boolean_type, "boolean_type")
 #ifdef BIGINT
 DEFINE_NAME_TRAIT( mapnik::value_integer, "long long" )
@@ -98,7 +99,7 @@ struct name_trait< mapnik::enumeration<ENUM, MAX> >
     }
 };
 
-xml_tree::xml_tree(std::string const& encoding)
+xml_tree::xml_tree()
     : node_(*this, "<root>"),
       file_()
 {
@@ -413,6 +414,7 @@ std::string xml_node::line_to_string() const
 
 compile_get_opt_attr(boolean_type);
 compile_get_opt_attr(std::string);
+compile_get_opt_attr(int);
 compile_get_opt_attr(unsigned);
 compile_get_opt_attr(mapnik::value_integer);
 compile_get_opt_attr(float);
diff --git a/test/unit/run.cpp b/test/cleanup.hpp
similarity index 60%
copy from test/unit/run.cpp
copy to test/cleanup.hpp
index 74b0715..264a6b5 100644
--- a/test/unit/run.cpp
+++ b/test/cleanup.hpp
@@ -1,24 +1,39 @@
-#define CATCH_CONFIG_RUNNER
-#include "catch.hpp"
+#ifndef TEST_MEMORY_CLEANUP
+#define TEST_MEMORY_CLEANUP
 
-#include <libxml/parser.h> // for xmlInitParser(), xmlCleanupParser()
+#include <libxml/parser.h>
+#include <libxml/entities.h>
+#include <libxml/globals.h>
+
+#if defined(HAVE_CAIRO)
 #include <cairo.h>
-#include <unicode/uclean.h>
+#endif
 
+#include <unicode/uclean.h>
 #ifdef MAPNIK_USE_PROJ4
 #include <proj_api.h>
 #endif
 
-int main (int argc, char* const argv[])
+namespace testing {
+
+inline void run_cleanup()
 {
-    int result = Catch::Session().run( argc, argv );
     // only call this once, on exit
     // to make sure valgrind output is clean
     // http://xmlsoft.org/xmlmem.html
+    xmlCleanupCharEncodingHandlers();
+    xmlCleanupEncodingAliases();
+    xmlCleanupGlobals();
     xmlCleanupParser();
+    xmlCleanupThreads();
+    xmlCleanupInputCallbacks();
+    xmlCleanupOutputCallbacks();
+    xmlCleanupMemory();
 
+#if defined(HAVE_CAIRO)
     // http://cairographics.org/manual/cairo-Error-handling.html#cairo-debug-reset-static-data
     cairo_debug_reset_static_data();
+#endif
 
     // http://icu-project.org/apiref/icu4c/uclean_8h.html#a93f27d0ddc7c196a1da864763f2d8920
     u_cleanup();
@@ -30,7 +45,9 @@ int main (int argc, char* const argv[])
  #endif
     // https://trac.osgeo.org/proj/wiki/ProjAPI#EnvironmentFunctions
     pj_deallocate_grids();
-#endif
+#endif    
+}
 
-    return result;
 }
+
+#endif
\ No newline at end of file
diff --git a/test/standalone/csv_test.cpp b/test/standalone/csv_test.cpp
index 242bb10..2023f67 100644
--- a/test/standalone/csv_test.cpp
+++ b/test/standalone/csv_test.cpp
@@ -10,7 +10,7 @@
 #include <mapnik/expression.hpp>
 #include <mapnik/expression_evaluator.hpp>
 #include <mapnik/debug.hpp>
-
+#include <mapnik/util/fs.hpp>
 #include <boost/filesystem.hpp>
 #include <boost/range/iterator_range_core.hpp>
 #include <boost/format.hpp>
@@ -31,15 +31,6 @@ void add_csv_files(bfs::path dir, std::vector<bfs::path> &csv_files) {
   }
 }
 
-bool operator==(mapnik::attribute_descriptor const &a,
-                mapnik::attribute_descriptor const &b) {
-  return ((a.get_name() == b.get_name()) &&
-          (a.get_type() == b.get_type()) &&
-          (a.is_primary_key() == b.is_primary_key()) &
-          (a.get_size() == b.get_size()) &&
-          (a.get_precision() == b.get_precision()));
-}
-
 mapnik::datasource_ptr get_csv_ds(std::string const &file_name, bool strict = true) {
   mapnik::parameters params;
   params["type"] = std::string("csv");
@@ -166,519 +157,526 @@ void require_geometry(mapnik::feature_ptr feature,
 }
 } // anonymous namespace
 
-const bool registered = mapnik::datasource_cache::instance().register_datasources("./plugins/input/");
+static const std::string csv_plugin("./plugins/input/csv.input");
 
-TEST_CASE("csv") {
-  REQUIRE(registered);
-
-  // make the tests silent since we intentially test error conditions that are noisy
-  auto const severity = mapnik::logger::instance().get_severity();
-  mapnik::logger::instance().set_severity(mapnik::logger::none);
-
-  // check the CSV datasource is loaded
-  const std::vector<std::string> plugin_names =
-    mapnik::datasource_cache::instance().plugin_names();
-  const bool have_csv_plugin =
-    std::find(plugin_names.begin(), plugin_names.end(), "csv") != plugin_names.end();
-
-  SECTION("broken files") {
-    if (have_csv_plugin) {
-      std::vector<bfs::path> broken;
-      add_csv_files("test/data/csv/fails", broken);
-      add_csv_files("test/data/csv/warns", broken);
-      broken.emplace_back("test/data/csv/fails/does_not_exist.csv");
-
-      for (auto const &path : broken) {
-        REQUIRE_THROWS(get_csv_ds(path.native()));
-      }
-    }
-  } // END SECTION
+const bool registered = mapnik::datasource_cache::instance().register_datasources(csv_plugin);
 
-  SECTION("good files") {
-    if (have_csv_plugin) {
-      std::vector<bfs::path> good;
-      add_csv_files("test/data/csv", good);
-      add_csv_files("test/data/csv/warns", good);
+TEST_CASE("csv") {
 
-      for (auto const &path : good) {
-        auto ds = get_csv_ds(path.native(), false);
-        // require a non-null pointer returned
+  if (mapnik::util::exists(csv_plugin))
+  {
+
+      REQUIRE(registered);
+
+      // make the tests silent since we intentially test error conditions that are noisy
+      auto const severity = mapnik::logger::instance().get_severity();
+      mapnik::logger::instance().set_severity(mapnik::logger::none);
+
+      // check the CSV datasource is loaded
+      const std::vector<std::string> plugin_names =
+        mapnik::datasource_cache::instance().plugin_names();
+      const bool have_csv_plugin =
+        std::find(plugin_names.begin(), plugin_names.end(), "csv") != plugin_names.end();
+
+      SECTION("broken files") {
+        if (have_csv_plugin) {
+          std::vector<bfs::path> broken;
+          add_csv_files("test/data/csv/fails", broken);
+          add_csv_files("test/data/csv/warns", broken);
+          broken.emplace_back("test/data/csv/fails/does_not_exist.csv");
+
+          for (auto const &path : broken) {
+            REQUIRE_THROWS(get_csv_ds(path.native()));
+          }
+        }
+      } // END SECTION
+
+      SECTION("good files") {
+        if (have_csv_plugin) {
+          std::vector<bfs::path> good;
+          add_csv_files("test/data/csv", good);
+          add_csv_files("test/data/csv/warns", good);
+
+          for (auto const &path : good) {
+            auto ds = get_csv_ds(path.native(), false);
+            // require a non-null pointer returned
+            REQUIRE(bool(ds));
+          }
+        }
+      } // END SECTION
+
+      SECTION("lon/lat detection") {
+        for (auto const &lon_name : {std::string("lon"), std::string("lng")}) {
+          auto ds = get_csv_ds((boost::format("test/data/csv/%1%_lat.csv") % lon_name).str());
+          auto fields = ds->get_descriptor().get_descriptors();
+          require_field_names(fields, {lon_name, "lat"});
+          require_field_types(fields, {mapnik::Integer, mapnik::Integer});
+
+          CHECK(ds->get_geometry_type() == mapnik::datasource_geometry_t::Point);
+
+          mapnik::query query(ds->envelope());
+          for (auto const &field : fields) {
+            query.add_property_name(field.get_name());
+          }
+          auto features = ds->features(query);
+          auto feature = features->next();
+
+          require_attributes(feature, {
+              attr { lon_name, mapnik::value_integer(0) },
+              attr { "lat", mapnik::value_integer(0) }
+            });
+        }
+      } // END SECTION
+
+      SECTION("type detection") {
+        auto ds = get_csv_ds("test/data/csv/nypd.csv");
+        auto fields = ds->get_descriptor().get_descriptors();
+        require_field_names(fields, {"Precinct", "Phone", "Address", "City", "geo_longitude", "geo_latitude", "geo_accuracy"});
+        require_field_types(fields, {mapnik::String, mapnik::String, mapnik::String, mapnik::String, mapnik::Double, mapnik::Double, mapnik::String});
+
+        CHECK(ds->get_geometry_type() == mapnik::datasource_geometry_t::Point);
+        CHECK(count_features(all_features(ds)) == 2);
+
+        auto feature = all_features(ds)->next();
+        require_attributes(feature, {
+              attr { "City", mapnik::value_unicode_string("New York, NY") }
+            , attr { "geo_accuracy", mapnik::value_unicode_string("house") }
+            , attr { "Phone", mapnik::value_unicode_string("(212) 334-0711") }
+            , attr { "Address", mapnik::value_unicode_string("19 Elizabeth Street") }
+            , attr { "Precinct", mapnik::value_unicode_string("5th Precinct") }
+            , attr { "geo_longitude", mapnik::value_integer(-70) }
+            , attr { "geo_latitude", mapnik::value_integer(40) }
+          });
+      } // END SECTION
+
+      SECTION("skipping blank rows") {
+        auto ds = get_csv_ds("test/data/csv/blank_rows.csv");
+        auto fields = ds->get_descriptor().get_descriptors();
+        require_field_names(fields, {"x", "y", "name"});
+        require_field_types(fields, {mapnik::Integer, mapnik::Integer, mapnik::String});
+
+        CHECK(ds->get_geometry_type() == mapnik::datasource_geometry_t::Point);
+        CHECK(count_features(all_features(ds)) == 2);
+      } // END SECTION
+
+      SECTION("empty rows") {
+        auto ds = get_csv_ds("test/data/csv/empty_rows.csv");
+        auto fields = ds->get_descriptor().get_descriptors();
+        require_field_names(fields, {"x", "y", "text", "date", "integer", "boolean", "float", "time", "datetime", "empty_column"});
+        require_field_types(fields, {mapnik::Integer, mapnik::Integer, mapnik::String, mapnik::String, mapnik::Integer, mapnik::Boolean, mapnik::Double, mapnik::String, mapnik::String, mapnik::String});
+
+        CHECK(ds->get_geometry_type() == mapnik::datasource_geometry_t::Point);
+        CHECK(count_features(all_features(ds)) == 4);
+
+        auto featureset = all_features(ds);
+        auto feature = featureset->next();
+        require_attributes(feature, {
+              attr { "x", mapnik::value_integer(0) }
+            , attr { "empty_column", mapnik::value_unicode_string("") }
+            , attr { "text", mapnik::value_unicode_string("a b") }
+            , attr { "float", mapnik::value_double(1.0) }
+            , attr { "datetime", mapnik::value_unicode_string("1971-01-01T04:14:00") }
+            , attr { "y", mapnik::value_integer(0) }
+            , attr { "boolean", mapnik::value_bool(true) }
+            , attr { "time", mapnik::value_unicode_string("04:14:00") }
+            , attr { "date", mapnik::value_unicode_string("1971-01-01") }
+            , attr { "integer", mapnik::value_integer(40) }
+          });
+
+        while (bool(feature = featureset->next())) {
+          CHECK(feature->size() == 10);
+          CHECK(feature->get("empty_column") == mapnik::value_unicode_string(""));
+        }
+      } // END SECTION
+
+      SECTION("slashes") {
+        auto ds = get_csv_ds("test/data/csv/has_attributes_with_slashes.csv");
+        auto fields = ds->get_descriptor().get_descriptors();
+        require_field_names(fields, {"x", "y", "name"});
+        // NOTE: y column is integer, even though a double value is used below in the test?
+        require_field_types(fields, {mapnik::Integer, mapnik::Integer, mapnik::String});
+        
+        auto featureset = all_features(ds);
+        require_attributes(featureset->next(), {
+              attr{"x", 0}
+            , attr{"y", 0}
+            , attr{"name", mapnik::value_unicode_string("a/a") } });
+        require_attributes(featureset->next(), {
+              attr{"x", 1}
+            , attr{"y", 4}
+            , attr{"name", mapnik::value_unicode_string("b/b") } });
+        require_attributes(featureset->next(), {
+              attr{"x", 10}
+            , attr{"y", 2.5}
+            , attr{"name", mapnik::value_unicode_string("c/c") } });
+      } // END SECTION
+
+      SECTION("wkt field") {
+        using mapnik::geometry::geometry_types;
+
+        auto ds = get_csv_ds("test/data/csv/wkt.csv");
+        auto fields = ds->get_descriptor().get_descriptors();
+        require_field_names(fields, {"type"});
+        require_field_types(fields, {mapnik::String});
+        
+        auto featureset = all_features(ds);
+        require_geometry(featureset->next(), 1, geometry_types::Point);
+        require_geometry(featureset->next(), 1, geometry_types::LineString);
+        require_geometry(featureset->next(), 1, geometry_types::Polygon);
+        require_geometry(featureset->next(), 1, geometry_types::Polygon);
+        require_geometry(featureset->next(), 4, geometry_types::MultiPoint);
+        require_geometry(featureset->next(), 2, geometry_types::MultiLineString);
+        require_geometry(featureset->next(), 2, geometry_types::MultiPolygon);
+        require_geometry(featureset->next(), 2, geometry_types::MultiPolygon);
+      } // END SECTION
+
+      SECTION("handling of missing header") {
+        // TODO: does this mean 'missing_header.csv' should be in the warnings
+        // subdirectory, since it doesn't work in strict mode?
+        auto ds = get_csv_ds("test/data/csv/missing_header.csv", false);
+        auto fields = ds->get_descriptor().get_descriptors();
+        require_field_names(fields, {"one", "two", "x", "y", "_4", "aftermissing"});
+        auto feature = all_features(ds)->next();
+        REQUIRE(feature);
+        REQUIRE(feature->has_key("_4"));
+        CHECK(feature->get("_4") == mapnik::value_unicode_string("missing"));
+      } // END SECTION
+
+      SECTION("handling of headers that are numbers") {
+        auto ds = get_csv_ds("test/data/csv/numbers_for_headers.csv");
+        auto fields = ds->get_descriptor().get_descriptors();
+        require_field_names(fields, {"x", "y", "1990", "1991", "1992"});
+        auto feature = all_features(ds)->next();
+        require_attributes(feature, {
+              attr{"x", 0}
+            , attr{"y", 0}
+            , attr{"1990", 1}
+            , attr{"1991", 2}
+            , attr{"1992", 3}
+          });
+        auto expression = mapnik::parse_expression("[1991]=2");
+        REQUIRE(bool(expression));
+        auto value = mapnik::util::apply_visitor(
+          mapnik::evaluate<mapnik::feature_impl, mapnik::value_type, mapnik::attributes>(
+            *feature, mapnik::attributes()), *expression);
+        CHECK(value == true);
+      } // END SECTION
+
+      SECTION("quoted numbers") {
+        using ustring = mapnik::value_unicode_string;
+
+        auto ds = get_csv_ds("test/data/csv/quoted_numbers.csv");
+        auto fields = ds->get_descriptor().get_descriptors();
+        require_field_names(fields, {"x", "y", "label"});
+        auto featureset = all_features(ds);
+
+        require_attributes(featureset->next(), {
+            attr{"x", 0}, attr{"y", 0}, attr{"label", ustring("0,0") } });
+        require_attributes(featureset->next(), {
+            attr{"x", 5}, attr{"y", 5}, attr{"label", ustring("5,5") } });
+        require_attributes(featureset->next(), {
+            attr{"x", 0}, attr{"y", 5}, attr{"label", ustring("0,5") } });
+        require_attributes(featureset->next(), {
+            attr{"x", 5}, attr{"y", 0}, attr{"label", ustring("5,0") } });
+        require_attributes(featureset->next(), {
+            attr{"x", 2.5}, attr{"y", 2.5}, attr{"label", ustring("2.5,2.5") } });
+
+      } // END SECTION
+
+      SECTION("reading newlines") {
+        for (auto const &platform : {std::string("windows"), std::string("mac")}) {
+          std::string file_name = (boost::format("test/data/csv/%1%_newlines.csv") % platform).str();
+          auto ds = get_csv_ds(file_name);
+          auto fields = ds->get_descriptor().get_descriptors();
+          require_field_names(fields, {"x", "y", "z"});
+          require_attributes(all_features(ds)->next(), {
+              attr{"x", 1}, attr{"y", 10}, attr{"z", 9999.9999} });
+        }
+      } // END SECTION
+
+      SECTION("mixed newlines") {
+        using ustring = mapnik::value_unicode_string;
+
+        for (auto const &file : {
+                std::string("test/data/csv/mac_newlines_with_unix_inline.csv")
+              , std::string("test/data/csv/mac_newlines_with_unix_inline_escaped.csv")
+              , std::string("test/data/csv/windows_newlines_with_unix_inline.csv")
+              , std::string("test/data/csv/windows_newlines_with_unix_inline_escaped.csv")
+              }) {
+          auto ds = get_csv_ds(file);
+          auto fields = ds->get_descriptor().get_descriptors();
+          require_field_names(fields, {"x", "y", "line"});
+          require_attributes(all_features(ds)->next(), {
+                attr{"x", 0}, attr{"y", 0}
+              , attr{"line", ustring("many\n  lines\n  of text\n  with unix newlines")} });
+        }
+      } // END SECTION
+
+      SECTION("tabs") {
+        auto ds = get_csv_ds("test/data/csv/tabs_in_csv.csv");
+        auto fields = ds->get_descriptor().get_descriptors();
+        require_field_names(fields, {"x", "y", "z"});
+        require_attributes(all_features(ds)->next(), {
+            attr{"x", -122}, attr{"y", 48}, attr{"z", 0} });
+      } // END SECTION
+
+      SECTION("separators") {
+        using ustring = mapnik::value_unicode_string;
+
+        for (auto const &file : {
+                std::string("test/data/csv/pipe_delimiters.csv")
+              , std::string("test/data/csv/semicolon_delimiters.csv")
+                  }) {
+          auto ds = get_csv_ds(file);
+          auto fields = ds->get_descriptor().get_descriptors();
+          require_field_names(fields, {"x", "y", "z"});
+          require_attributes(all_features(ds)->next(), {
+              attr{"x", 0}, attr{"y", 0}, attr{"z", ustring("hello")} });
+        }
+      } // END SECTION
+
+      SECTION("null and bool keywords are empty strings") {
+        using ustring = mapnik::value_unicode_string;
+
+        auto ds = get_csv_ds("test/data/csv/nulls_and_booleans_as_strings.csv");
+        auto fields = ds->get_descriptor().get_descriptors();
+        require_field_names(fields, {"x", "y", "null", "boolean"});
+        require_field_types(fields, {mapnik::Integer, mapnik::Integer, mapnik::String, mapnik::Boolean});
+
+        auto featureset = all_features(ds);
+        require_attributes(featureset->next(), {
+            attr{"x", 0}, attr{"y", 0}, attr{"null", ustring("null")}, attr{"boolean", true}});
+        require_attributes(featureset->next(), {
+            attr{"x", 0}, attr{"y", 0}, attr{"null", ustring("")}, attr{"boolean", false}});
+      } // END SECTION
+
+      SECTION("nonexistent query fields throw") {
+        auto ds = get_csv_ds("test/data/csv/lon_lat.csv");
+        auto fields = ds->get_descriptor().get_descriptors();
+        require_field_names(fields, {"lon", "lat"});
+        require_field_types(fields, {mapnik::Integer, mapnik::Integer});
+
+        mapnik::query query(ds->envelope());
+        for (auto const &field : fields) {
+          query.add_property_name(field.get_name());
+        }
+        // also add an invalid one, triggering throw
+        query.add_property_name("bogus");
+
+        REQUIRE_THROWS(ds->features(query));
+      } // END SECTION
+
+      SECTION("leading zeros mean strings") {
+        using ustring = mapnik::value_unicode_string;
+
+        auto ds = get_csv_ds("test/data/csv/leading_zeros.csv");
+        auto fields = ds->get_descriptor().get_descriptors();
+        require_field_names(fields, {"x", "y", "fips"});
+        require_field_types(fields, {mapnik::Integer, mapnik::Integer, mapnik::String});
+
+        auto featureset = all_features(ds);
+        require_attributes(featureset->next(), {
+            attr{"x", 0}, attr{"y", 0}, attr{"fips", ustring("001")}});
+        require_attributes(featureset->next(), {
+            attr{"x", 0}, attr{"y", 0}, attr{"fips", ustring("003")}});
+        require_attributes(featureset->next(), {
+            attr{"x", 0}, attr{"y", 0}, attr{"fips", ustring("005")}});
+      } // END SECTION
+
+      SECTION("advanced geometry detection") {
+        using row = std::pair<std::string, mapnik::datasource_geometry_t>;
+
+        for (row r : {
+              row{"point", mapnik::datasource_geometry_t::Point}
+            , row{"poly", mapnik::datasource_geometry_t::Polygon}
+            , row{"multi_poly", mapnik::datasource_geometry_t::Polygon}
+            , row{"line", mapnik::datasource_geometry_t::LineString}
+          }) {
+          std::string file_name = (boost::format("test/data/csv/%1%_wkt.csv") % r.first).str();
+          auto ds = get_csv_ds(file_name);
+          CHECK(ds->get_geometry_type() == r.second);
+        }
+      } // END SECTION
+
+      SECTION("creation of CSV from in-memory strings") {
+        using ustring = mapnik::value_unicode_string;
+
+        for (auto const &name : {std::string("Winthrop, WA"), std::string(u8"Qu\u00e9bec")}) {
+          std::string csv_string =
+            (boost::format(
+              "wkt,Name\n"
+              "\"POINT (120.15 48.47)\",\"%1%\"\n"
+              ) % name).str();
+
+          mapnik::parameters params;
+          params["type"] = std::string("csv");
+          params["inline"] = csv_string;
+          auto ds = mapnik::datasource_cache::instance().create(params);
+          REQUIRE(bool(ds));
+
+          auto feature = all_features(ds)->next();
+          REQUIRE(bool(feature));
+          REQUIRE(feature->has_key("Name"));
+          CHECK(feature->get("Name") == ustring(name.c_str()));
+        }
+      } // END SECTION
+
+      SECTION("geojson quoting") {
+        using mapnik::geometry::geometry_types;
+
+        for (auto const &file : {
+                std::string("test/data/csv/geojson_double_quote_escape.csv")
+              , std::string("test/data/csv/geojson_single_quote.csv")
+              , std::string("test/data/csv/geojson_2x_double_quote_filebakery_style.csv")
+                  }) {
+          auto ds = get_csv_ds(file);
+          auto fields = ds->get_descriptor().get_descriptors();
+          require_field_names(fields, {"type"});
+          require_field_types(fields, {mapnik::String});
+        
+          auto featureset = all_features(ds);
+          require_geometry(featureset->next(), 1, geometry_types::Point);
+          require_geometry(featureset->next(), 1, geometry_types::LineString);
+          require_geometry(featureset->next(), 1, geometry_types::Polygon);
+          require_geometry(featureset->next(), 1, geometry_types::Polygon);
+          require_geometry(featureset->next(), 4, geometry_types::MultiPoint);
+          require_geometry(featureset->next(), 2, geometry_types::MultiLineString);
+          require_geometry(featureset->next(), 2, geometry_types::MultiPolygon);
+          require_geometry(featureset->next(), 2, geometry_types::MultiPolygon);
+        }
+      } // END SECTION
+
+      SECTION("blank undelimited rows are still parsed") {
+        using ustring = mapnik::value_unicode_string;
+
+        // TODO: does this mean this CSV file should be in the warnings
+        // subdirectory, since it doesn't work in strict mode?
+        auto ds = get_csv_ds("test/data/csv/more_headers_than_column_values.csv", false);
+        auto fields = ds->get_descriptor().get_descriptors();
+        require_field_names(fields, {"x", "y", "one", "two", "three"});
+        require_field_types(fields, {mapnik::Integer, mapnik::Integer, mapnik::String, mapnik::String, mapnik::String});
+
+        require_attributes(all_features(ds)->next(), {
+            attr{"x", 0}, attr{"y", 0}, attr{"one", ustring("")}, attr{"two", ustring("")}, attr{"three", ustring("")} });
+      } // END SECTION
+
+      SECTION("fewer headers than rows throws") {
+        REQUIRE_THROWS(get_csv_ds("test/data/csv/more_column_values_than_headers.csv"));
+      } // END SECTION
+
+      SECTION("feature ID only incremented for valid rows") {
+        auto ds = get_csv_ds("test/data/csv/warns/feature_id_counting.csv", false);
+        auto fs = all_features(ds);
+
+        // first
+        auto feature = fs->next();
+        REQUIRE(bool(feature));
+        CHECK(feature->id() == 1);
+
+        // second, should have skipped bogus one
+        feature = fs->next();
+        REQUIRE(bool(feature));
+        CHECK(feature->id() == 2);
+
+        feature = fs->next();
+        CHECK(!feature);
+      } // END SECTION
+
+      SECTION("dynamically defining headers") {
+        using ustring = mapnik::value_unicode_string;
+        using row = std::pair<std::string, std::size_t>;
+
+        for (auto const &r : {
+              row{"test/data/csv/fails/needs_headers_two_lines.csv", 2}
+            , row{"test/data/csv/fails/needs_headers_one_line.csv", 1}
+            , row{"test/data/csv/fails/needs_headers_one_line_no_newline.csv", 1}
+          }) {
+          mapnik::parameters params;
+          params["type"] = std::string("csv");
+          params["file"] = r.first;
+          params["headers"] = "x,y,name";
+          auto ds = mapnik::datasource_cache::instance().create(params);
+          REQUIRE(bool(ds));
+
+          auto fields = ds->get_descriptor().get_descriptors();
+          require_field_names(fields, {"x", "y", "name"});
+          require_field_types(fields, {mapnik::Integer, mapnik::Integer, mapnik::String});
+          require_attributes(all_features(ds)->next(), {
+              attr{"x", 0}, attr{"y", 0}, attr{"name", ustring("data_name")} });
+          REQUIRE(count_features(all_features(ds)) == r.second);
+        }
+      } // END SECTION
+
+    #pragma GCC diagnostic push
+    #pragma GCC diagnostic ignored "-Wlong-long"
+      SECTION("64bit int fields work") {
+        auto ds = get_csv_ds("test/data/csv/64bit_int.csv");
+        auto fields = ds->get_descriptor().get_descriptors();
+        require_field_names(fields, {"x", "y", "bigint"});
+        require_field_types(fields, {mapnik::Integer, mapnik::Integer, mapnik::Integer});
+
+        auto fs = all_features(ds);
+        auto feature = fs->next();
+        require_attributes(feature, {
+            attr{"x", 0}, attr{"y", 0}, attr{"bigint", 2147483648} });
+
+        feature = fs->next();
+        require_attributes(feature, {
+            attr{"x", 0}, attr{"y", 0}, attr{"bigint", 9223372036854775807ll} });
+        require_attributes(feature, {
+            attr{"x", 0}, attr{"y", 0}, attr{"bigint", 0x7FFFFFFFFFFFFFFFll} });
+      } // END SECTION
+    #pragma GCC diagnostic pop
+
+      SECTION("various number types") {
+        auto ds = get_csv_ds("test/data/csv/number_types.csv");
+        auto fields = ds->get_descriptor().get_descriptors();
+        require_field_names(fields, {"x", "y", "floats"});
+        require_field_types(fields, {mapnik::Integer, mapnik::Integer, mapnik::Double});
+
+        auto fs = all_features(ds);
+        for (double d : { .0, +.0, 1e-06, -1e-06, 0.000001, 1.234e+16, 1.234e+16 }) {
+          auto feature = fs->next();
+          REQUIRE(bool(feature));
+          CHECK(feature->get("floats").get<mapnik::value_double>() == Approx(d));
+        }
+      } // END SECTION
+
+      SECTION("manually supplied extent") {
+        std::string csv_string("wkt,Name\n");
+        mapnik::parameters params;
+        params["type"] = std::string("csv");
+        params["inline"] = csv_string;
+        params["extent"] = "-180,-90,180,90";
+        auto ds = mapnik::datasource_cache::instance().create(params);
         REQUIRE(bool(ds));
-      }
-    }
-  } // END SECTION
-
-  SECTION("lon/lat detection") {
-    for (auto const &lon_name : {std::string("lon"), std::string("lng")}) {
-      auto ds = get_csv_ds((boost::format("test/data/csv/%1%_lat.csv") % lon_name).str());
-      auto fields = ds->get_descriptor().get_descriptors();
-      require_field_names(fields, {lon_name, "lat"});
-      require_field_types(fields, {mapnik::Integer, mapnik::Integer});
-
-      CHECK(ds->get_geometry_type() == mapnik::datasource_geometry_t::Point);
-
-      mapnik::query query(ds->envelope());
-      for (auto const &field : fields) {
-        query.add_property_name(field.get_name());
-      }
-      auto features = ds->features(query);
-      auto feature = features->next();
-
-      require_attributes(feature, {
-          attr { lon_name, mapnik::value_integer(0) },
-          attr { "lat", mapnik::value_integer(0) }
-        });
-    }
-  } // END SECTION
-
-  SECTION("type detection") {
-    auto ds = get_csv_ds("test/data/csv/nypd.csv");
-    auto fields = ds->get_descriptor().get_descriptors();
-    require_field_names(fields, {"Precinct", "Phone", "Address", "City", "geo_longitude", "geo_latitude", "geo_accuracy"});
-    require_field_types(fields, {mapnik::String, mapnik::String, mapnik::String, mapnik::String, mapnik::Double, mapnik::Double, mapnik::String});
-
-    CHECK(ds->get_geometry_type() == mapnik::datasource_geometry_t::Point);
-    CHECK(count_features(all_features(ds)) == 2);
-
-    auto feature = all_features(ds)->next();
-    require_attributes(feature, {
-          attr { "City", mapnik::value_unicode_string("New York, NY") }
-        , attr { "geo_accuracy", mapnik::value_unicode_string("house") }
-        , attr { "Phone", mapnik::value_unicode_string("(212) 334-0711") }
-        , attr { "Address", mapnik::value_unicode_string("19 Elizabeth Street") }
-        , attr { "Precinct", mapnik::value_unicode_string("5th Precinct") }
-        , attr { "geo_longitude", mapnik::value_integer(-70) }
-        , attr { "geo_latitude", mapnik::value_integer(40) }
-      });
-  } // END SECTION
-
-  SECTION("skipping blank rows") {
-    auto ds = get_csv_ds("test/data/csv/blank_rows.csv");
-    auto fields = ds->get_descriptor().get_descriptors();
-    require_field_names(fields, {"x", "y", "name"});
-    require_field_types(fields, {mapnik::Integer, mapnik::Integer, mapnik::String});
-
-    CHECK(ds->get_geometry_type() == mapnik::datasource_geometry_t::Point);
-    CHECK(count_features(all_features(ds)) == 2);
-  } // END SECTION
-
-  SECTION("empty rows") {
-    auto ds = get_csv_ds("test/data/csv/empty_rows.csv");
-    auto fields = ds->get_descriptor().get_descriptors();
-    require_field_names(fields, {"x", "y", "text", "date", "integer", "boolean", "float", "time", "datetime", "empty_column"});
-    require_field_types(fields, {mapnik::Integer, mapnik::Integer, mapnik::String, mapnik::String, mapnik::Integer, mapnik::Boolean, mapnik::Double, mapnik::String, mapnik::String, mapnik::String});
-
-    CHECK(ds->get_geometry_type() == mapnik::datasource_geometry_t::Point);
-    CHECK(count_features(all_features(ds)) == 4);
-
-    auto featureset = all_features(ds);
-    auto feature = featureset->next();
-    require_attributes(feature, {
-          attr { "x", mapnik::value_integer(0) }
-        , attr { "empty_column", mapnik::value_unicode_string("") }
-        , attr { "text", mapnik::value_unicode_string("a b") }
-        , attr { "float", mapnik::value_double(1.0) }
-        , attr { "datetime", mapnik::value_unicode_string("1971-01-01T04:14:00") }
-        , attr { "y", mapnik::value_integer(0) }
-        , attr { "boolean", mapnik::value_bool(true) }
-        , attr { "time", mapnik::value_unicode_string("04:14:00") }
-        , attr { "date", mapnik::value_unicode_string("1971-01-01") }
-        , attr { "integer", mapnik::value_integer(40) }
-      });
-
-    while (bool(feature = featureset->next())) {
-      CHECK(feature->size() == 10);
-      CHECK(feature->get("empty_column") == mapnik::value_unicode_string(""));
-    }
-  } // END SECTION
-
-  SECTION("slashes") {
-    auto ds = get_csv_ds("test/data/csv/has_attributes_with_slashes.csv");
-    auto fields = ds->get_descriptor().get_descriptors();
-    require_field_names(fields, {"x", "y", "name"});
-    // NOTE: y column is integer, even though a double value is used below in the test?
-    require_field_types(fields, {mapnik::Integer, mapnik::Integer, mapnik::String});
-    
-    auto featureset = all_features(ds);
-    require_attributes(featureset->next(), {
-          attr{"x", 0}
-        , attr{"y", 0}
-        , attr{"name", mapnik::value_unicode_string("a/a") } });
-    require_attributes(featureset->next(), {
-          attr{"x", 1}
-        , attr{"y", 4}
-        , attr{"name", mapnik::value_unicode_string("b/b") } });
-    require_attributes(featureset->next(), {
-          attr{"x", 10}
-        , attr{"y", 2.5}
-        , attr{"name", mapnik::value_unicode_string("c/c") } });
-  } // END SECTION
-
-  SECTION("wkt field") {
-    using mapnik::geometry::geometry_types;
-
-    auto ds = get_csv_ds("test/data/csv/wkt.csv");
-    auto fields = ds->get_descriptor().get_descriptors();
-    require_field_names(fields, {"type"});
-    require_field_types(fields, {mapnik::String});
-    
-    auto featureset = all_features(ds);
-    require_geometry(featureset->next(), 1, geometry_types::Point);
-    require_geometry(featureset->next(), 1, geometry_types::LineString);
-    require_geometry(featureset->next(), 1, geometry_types::Polygon);
-    require_geometry(featureset->next(), 1, geometry_types::Polygon);
-    require_geometry(featureset->next(), 4, geometry_types::MultiPoint);
-    require_geometry(featureset->next(), 2, geometry_types::MultiLineString);
-    require_geometry(featureset->next(), 2, geometry_types::MultiPolygon);
-    require_geometry(featureset->next(), 2, geometry_types::MultiPolygon);
-  } // END SECTION
-
-  SECTION("handling of missing header") {
-    // TODO: does this mean 'missing_header.csv' should be in the warnings
-    // subdirectory, since it doesn't work in strict mode?
-    auto ds = get_csv_ds("test/data/csv/missing_header.csv", false);
-    auto fields = ds->get_descriptor().get_descriptors();
-    require_field_names(fields, {"one", "two", "x", "y", "_4", "aftermissing"});
-    auto feature = all_features(ds)->next();
-    REQUIRE(feature);
-    REQUIRE(feature->has_key("_4"));
-    CHECK(feature->get("_4") == mapnik::value_unicode_string("missing"));
-  } // END SECTION
-
-  SECTION("handling of headers that are numbers") {
-    auto ds = get_csv_ds("test/data/csv/numbers_for_headers.csv");
-    auto fields = ds->get_descriptor().get_descriptors();
-    require_field_names(fields, {"x", "y", "1990", "1991", "1992"});
-    auto feature = all_features(ds)->next();
-    require_attributes(feature, {
-          attr{"x", 0}
-        , attr{"y", 0}
-        , attr{"1990", 1}
-        , attr{"1991", 2}
-        , attr{"1992", 3}
-      });
-    auto expression = mapnik::parse_expression("[1991]=2");
-    REQUIRE(bool(expression));
-    auto value = mapnik::util::apply_visitor(
-      mapnik::evaluate<mapnik::feature_impl, mapnik::value_type, mapnik::attributes>(
-        *feature, mapnik::attributes()), *expression);
-    CHECK(value == true);
-  } // END SECTION
-
-  SECTION("quoted numbers") {
-    using ustring = mapnik::value_unicode_string;
-
-    auto ds = get_csv_ds("test/data/csv/quoted_numbers.csv");
-    auto fields = ds->get_descriptor().get_descriptors();
-    require_field_names(fields, {"x", "y", "label"});
-    auto featureset = all_features(ds);
-
-    require_attributes(featureset->next(), {
-        attr{"x", 0}, attr{"y", 0}, attr{"label", ustring("0,0") } });
-    require_attributes(featureset->next(), {
-        attr{"x", 5}, attr{"y", 5}, attr{"label", ustring("5,5") } });
-    require_attributes(featureset->next(), {
-        attr{"x", 0}, attr{"y", 5}, attr{"label", ustring("0,5") } });
-    require_attributes(featureset->next(), {
-        attr{"x", 5}, attr{"y", 0}, attr{"label", ustring("5,0") } });
-    require_attributes(featureset->next(), {
-        attr{"x", 2.5}, attr{"y", 2.5}, attr{"label", ustring("2.5,2.5") } });
-
-  } // END SECTION
-
-  SECTION("reading newlines") {
-    for (auto const &platform : {std::string("windows"), std::string("mac")}) {
-      std::string file_name = (boost::format("test/data/csv/%1%_newlines.csv") % platform).str();
-      auto ds = get_csv_ds(file_name);
-      auto fields = ds->get_descriptor().get_descriptors();
-      require_field_names(fields, {"x", "y", "z"});
-      require_attributes(all_features(ds)->next(), {
-          attr{"x", 1}, attr{"y", 10}, attr{"z", 9999.9999} });
-    }
-  } // END SECTION
 
-  SECTION("mixed newlines") {
-    using ustring = mapnik::value_unicode_string;
+        auto box = ds->envelope();
+        CHECK(box.minx() == -180);
+        CHECK(box.miny() ==  -90);
+        CHECK(box.maxx() ==  180);
+        CHECK(box.maxy() ==   90);
+      } // END SECTION
+
+      SECTION("inline geojson") {
+        std::string csv_string = "geojson\n'{\"coordinates\":[-92.22568,38.59553],\"type\":\"Point\"}'";
+        mapnik::parameters params;
+        params["type"] = std::string("csv");
+        params["inline"] = csv_string;
+        auto ds = mapnik::datasource_cache::instance().create(params);
+        REQUIRE(bool(ds));
 
-    for (auto const &file : {
-            std::string("test/data/csv/mac_newlines_with_unix_inline.csv")
-          , std::string("test/data/csv/mac_newlines_with_unix_inline_escaped.csv")
-          , std::string("test/data/csv/windows_newlines_with_unix_inline.csv")
-          , std::string("test/data/csv/windows_newlines_with_unix_inline_escaped.csv")
-          }) {
-      auto ds = get_csv_ds(file);
-      auto fields = ds->get_descriptor().get_descriptors();
-      require_field_names(fields, {"x", "y", "line"});
-      require_attributes(all_features(ds)->next(), {
-            attr{"x", 0}, attr{"y", 0}
-          , attr{"line", ustring("many\n  lines\n  of text\n  with unix newlines")} });
-    }
-  } // END SECTION
-
-  SECTION("tabs") {
-    auto ds = get_csv_ds("test/data/csv/tabs_in_csv.csv");
-    auto fields = ds->get_descriptor().get_descriptors();
-    require_field_names(fields, {"x", "y", "z"});
-    require_attributes(all_features(ds)->next(), {
-        attr{"x", -122}, attr{"y", 48}, attr{"z", 0} });
-  } // END SECTION
-
-  SECTION("separators") {
-    using ustring = mapnik::value_unicode_string;
-
-    for (auto const &file : {
-            std::string("test/data/csv/pipe_delimiters.csv")
-          , std::string("test/data/csv/semicolon_delimiters.csv")
-              }) {
-      auto ds = get_csv_ds(file);
-      auto fields = ds->get_descriptor().get_descriptors();
-      require_field_names(fields, {"x", "y", "z"});
-      require_attributes(all_features(ds)->next(), {
-          attr{"x", 0}, attr{"y", 0}, attr{"z", ustring("hello")} });
-    }
-  } // END SECTION
-
-  SECTION("null and bool keywords are empty strings") {
-    using ustring = mapnik::value_unicode_string;
-
-    auto ds = get_csv_ds("test/data/csv/nulls_and_booleans_as_strings.csv");
-    auto fields = ds->get_descriptor().get_descriptors();
-    require_field_names(fields, {"x", "y", "null", "boolean"});
-    require_field_types(fields, {mapnik::Integer, mapnik::Integer, mapnik::String, mapnik::Boolean});
-
-    auto featureset = all_features(ds);
-    require_attributes(featureset->next(), {
-        attr{"x", 0}, attr{"y", 0}, attr{"null", ustring("null")}, attr{"boolean", true}});
-    require_attributes(featureset->next(), {
-        attr{"x", 0}, attr{"y", 0}, attr{"null", ustring("")}, attr{"boolean", false}});
-  } // END SECTION
-
-  SECTION("nonexistent query fields throw") {
-    auto ds = get_csv_ds("test/data/csv/lon_lat.csv");
-    auto fields = ds->get_descriptor().get_descriptors();
-    require_field_names(fields, {"lon", "lat"});
-    require_field_types(fields, {mapnik::Integer, mapnik::Integer});
-
-    mapnik::query query(ds->envelope());
-    for (auto const &field : fields) {
-      query.add_property_name(field.get_name());
-    }
-    // also add an invalid one, triggering throw
-    query.add_property_name("bogus");
-
-    REQUIRE_THROWS(ds->features(query));
-  } // END SECTION
-
-  SECTION("leading zeros mean strings") {
-    using ustring = mapnik::value_unicode_string;
-
-    auto ds = get_csv_ds("test/data/csv/leading_zeros.csv");
-    auto fields = ds->get_descriptor().get_descriptors();
-    require_field_names(fields, {"x", "y", "fips"});
-    require_field_types(fields, {mapnik::Integer, mapnik::Integer, mapnik::String});
-
-    auto featureset = all_features(ds);
-    require_attributes(featureset->next(), {
-        attr{"x", 0}, attr{"y", 0}, attr{"fips", ustring("001")}});
-    require_attributes(featureset->next(), {
-        attr{"x", 0}, attr{"y", 0}, attr{"fips", ustring("003")}});
-    require_attributes(featureset->next(), {
-        attr{"x", 0}, attr{"y", 0}, attr{"fips", ustring("005")}});
-  } // END SECTION
-
-  SECTION("advanced geometry detection") {
-    using row = std::pair<std::string, mapnik::datasource_geometry_t>;
-
-    for (row r : {
-          row{"point", mapnik::datasource_geometry_t::Point}
-        , row{"poly", mapnik::datasource_geometry_t::Polygon}
-        , row{"multi_poly", mapnik::datasource_geometry_t::Polygon}
-        , row{"line", mapnik::datasource_geometry_t::LineString}
-      }) {
-      std::string file_name = (boost::format("test/data/csv/%1%_wkt.csv") % r.first).str();
-      auto ds = get_csv_ds(file_name);
-      CHECK(ds->get_geometry_type() == r.second);
-    }
-  } // END SECTION
-
-  SECTION("creation of CSV from in-memory strings") {
-    using ustring = mapnik::value_unicode_string;
-
-    for (auto const &name : {std::string("Winthrop, WA"), std::string(u8"Qu\u00e9bec")}) {
-      std::string csv_string =
-        (boost::format(
-          "wkt,Name\n"
-          "\"POINT (120.15 48.47)\",\"%1%\"\n"
-          ) % name).str();
-
-      mapnik::parameters params;
-      params["type"] = std::string("csv");
-      params["inline"] = csv_string;
-      auto ds = mapnik::datasource_cache::instance().create(params);
-      REQUIRE(bool(ds));
-
-      auto feature = all_features(ds)->next();
-      REQUIRE(bool(feature));
-      REQUIRE(feature->has_key("Name"));
-      CHECK(feature->get("Name") == ustring(name.c_str()));
-    }
-  } // END SECTION
+        auto fields = ds->get_descriptor().get_descriptors();
+        require_field_names(fields, {});
 
-  SECTION("geojson quoting") {
-    using mapnik::geometry::geometry_types;
+        // TODO: this originally had the following comment:
+        //   - re-enable after https://github.com/mapnik/mapnik/issues/2319 is fixed
+        // but that seems to have been merged and tested separately?
+        auto fs = all_features(ds);
+        auto feat = fs->next();
+        CHECK(feature_count(feat->get_geometry()) == 1);
+      } // END SECTION
 
-    for (auto const &file : {
-            std::string("test/data/csv/geojson_double_quote_escape.csv")
-          , std::string("test/data/csv/geojson_single_quote.csv")
-          , std::string("test/data/csv/geojson_2x_double_quote_filebakery_style.csv")
-              }) {
-      auto ds = get_csv_ds(file);
-      auto fields = ds->get_descriptor().get_descriptors();
-      require_field_names(fields, {"type"});
-      require_field_types(fields, {mapnik::String});
-    
-      auto featureset = all_features(ds);
-      require_geometry(featureset->next(), 1, geometry_types::Point);
-      require_geometry(featureset->next(), 1, geometry_types::LineString);
-      require_geometry(featureset->next(), 1, geometry_types::Polygon);
-      require_geometry(featureset->next(), 1, geometry_types::Polygon);
-      require_geometry(featureset->next(), 4, geometry_types::MultiPoint);
-      require_geometry(featureset->next(), 2, geometry_types::MultiLineString);
-      require_geometry(featureset->next(), 2, geometry_types::MultiPolygon);
-      require_geometry(featureset->next(), 2, geometry_types::MultiPolygon);
-    }
-  } // END SECTION
-
-  SECTION("blank undelimited rows are still parsed") {
-    using ustring = mapnik::value_unicode_string;
-
-    // TODO: does this mean this CSV file should be in the warnings
-    // subdirectory, since it doesn't work in strict mode?
-    auto ds = get_csv_ds("test/data/csv/more_headers_than_column_values.csv", false);
-    auto fields = ds->get_descriptor().get_descriptors();
-    require_field_names(fields, {"x", "y", "one", "two", "three"});
-    require_field_types(fields, {mapnik::Integer, mapnik::Integer, mapnik::String, mapnik::String, mapnik::String});
-
-    require_attributes(all_features(ds)->next(), {
-        attr{"x", 0}, attr{"y", 0}, attr{"one", ustring("")}, attr{"two", ustring("")}, attr{"three", ustring("")} });
-  } // END SECTION
-
-  SECTION("fewer headers than rows throws") {
-    REQUIRE_THROWS(get_csv_ds("test/data/csv/more_column_values_than_headers.csv"));
-  } // END SECTION
-
-  SECTION("feature ID only incremented for valid rows") {
-    auto ds = get_csv_ds("test/data/csv/warns/feature_id_counting.csv", false);
-    auto fs = all_features(ds);
-
-    // first
-    auto feature = fs->next();
-    REQUIRE(bool(feature));
-    CHECK(feature->id() == 1);
-
-    // second, should have skipped bogus one
-    feature = fs->next();
-    REQUIRE(bool(feature));
-    CHECK(feature->id() == 2);
-
-    feature = fs->next();
-    CHECK(!feature);
-  } // END SECTION
-
-  SECTION("dynamically defining headers") {
-    using ustring = mapnik::value_unicode_string;
-    using row = std::pair<std::string, std::size_t>;
-
-    for (auto const &r : {
-          row{"test/data/csv/fails/needs_headers_two_lines.csv", 2}
-        , row{"test/data/csv/fails/needs_headers_one_line.csv", 1}
-        , row{"test/data/csv/fails/needs_headers_one_line_no_newline.csv", 1}
-      }) {
-      mapnik::parameters params;
-      params["type"] = std::string("csv");
-      params["file"] = r.first;
-      params["headers"] = "x,y,name";
-      auto ds = mapnik::datasource_cache::instance().create(params);
-      REQUIRE(bool(ds));
-
-      auto fields = ds->get_descriptor().get_descriptors();
-      require_field_names(fields, {"x", "y", "name"});
-      require_field_types(fields, {mapnik::Integer, mapnik::Integer, mapnik::String});
-      require_attributes(all_features(ds)->next(), {
-          attr{"x", 0}, attr{"y", 0}, attr{"name", ustring("data_name")} });
-      REQUIRE(count_features(all_features(ds)) == r.second);
-    }
-  } // END SECTION
-
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wlong-long"
-  SECTION("64bit int fields work") {
-    auto ds = get_csv_ds("test/data/csv/64bit_int.csv");
-    auto fields = ds->get_descriptor().get_descriptors();
-    require_field_names(fields, {"x", "y", "bigint"});
-    require_field_types(fields, {mapnik::Integer, mapnik::Integer, mapnik::Integer});
-
-    auto fs = all_features(ds);
-    auto feature = fs->next();
-    require_attributes(feature, {
-        attr{"x", 0}, attr{"y", 0}, attr{"bigint", 2147483648} });
-
-    feature = fs->next();
-    require_attributes(feature, {
-        attr{"x", 0}, attr{"y", 0}, attr{"bigint", 9223372036854775807ll} });
-    require_attributes(feature, {
-        attr{"x", 0}, attr{"y", 0}, attr{"bigint", 0x7FFFFFFFFFFFFFFFll} });
-  } // END SECTION
-#pragma GCC diagnostic pop
-
-  SECTION("various number types") {
-    auto ds = get_csv_ds("test/data/csv/number_types.csv");
-    auto fields = ds->get_descriptor().get_descriptors();
-    require_field_names(fields, {"x", "y", "floats"});
-    require_field_types(fields, {mapnik::Integer, mapnik::Integer, mapnik::Double});
-
-    auto fs = all_features(ds);
-    for (double d : { .0, +.0, 1e-06, -1e-06, 0.000001, 1.234e+16, 1.234e+16 }) {
-      auto feature = fs->next();
-      REQUIRE(bool(feature));
-      CHECK(feature->get("floats").get<mapnik::value_double>() == Approx(d));
-    }
-  } // END SECTION
-
-  SECTION("manually supplied extent") {
-    std::string csv_string("wkt,Name\n");
-    mapnik::parameters params;
-    params["type"] = std::string("csv");
-    params["inline"] = csv_string;
-    params["extent"] = "-180,-90,180,90";
-    auto ds = mapnik::datasource_cache::instance().create(params);
-    REQUIRE(bool(ds));
-
-    auto box = ds->envelope();
-    CHECK(box.minx() == -180);
-    CHECK(box.miny() ==  -90);
-    CHECK(box.maxx() ==  180);
-    CHECK(box.maxy() ==   90);
-  } // END SECTION
-
-  SECTION("inline geojson") {
-    std::string csv_string = "geojson\n'{\"coordinates\":[-92.22568,38.59553],\"type\":\"Point\"}'";
-    mapnik::parameters params;
-    params["type"] = std::string("csv");
-    params["inline"] = csv_string;
-    auto ds = mapnik::datasource_cache::instance().create(params);
-    REQUIRE(bool(ds));
-
-    auto fields = ds->get_descriptor().get_descriptors();
-    require_field_names(fields, {});
-
-    // TODO: this originally had the following comment:
-    //   - re-enable after https://github.com/mapnik/mapnik/issues/2319 is fixed
-    // but that seems to have been merged and tested separately?
-    auto fs = all_features(ds);
-    auto feat = fs->next();
-    CHECK(feature_count(feat->get_geometry()) == 1);
-  } // END SECTION
-
-  mapnik::logger::instance().set_severity(severity);
+      mapnik::logger::instance().set_severity(severity);
+  }
 } // END TEST CASE
diff --git a/test/unit/color/css_color.cpp b/test/unit/color/css_color.cpp
new file mode 100644
index 0000000..38e1518
--- /dev/null
+++ b/test/unit/color/css_color.cpp
@@ -0,0 +1,38 @@
+#include "catch.hpp"
+#include <mapnik/css_color_grammar.hpp>
+#include <mapnik/safe_cast.hpp>
+
+TEST_CASE("css color") {
+
+    SECTION("conversions")
+    {
+        mapnik::percent_conv_impl conv;
+        CHECK( conv(1.0) == 3 );
+        CHECK( conv(60.0) == 153 );
+        // should not overflow on invalid input
+        CHECK( conv(100000.0) == 255 );
+        CHECK( conv(-100000.0) == 0 );
+
+        mapnik::alpha_conv_impl conv2;
+        CHECK( conv2(0.5) == 128 );
+        CHECK( conv2(1.0) == 255 );
+        // should not overflow on invalid input
+        CHECK( conv2(60.0) == 255 );
+        CHECK( conv2(100000.0) == 255 );
+        CHECK( conv2(-100000.0) == 0 );
+
+        mapnik::hsl_conv_impl conv3;
+        mapnik::color c;
+        conv3(c, 1.0, 1.0, 1.0);
+        CHECK( c.alpha() == 255 );
+        CHECK( c.red() == 3 );
+        CHECK( c.green() == 3 );
+        CHECK( c.blue() == 3 );
+        // invalid
+        conv3(c, -1, -1, -1);
+        CHECK( c.alpha() == 255 ); // should not be touched by hsl converter
+        CHECK( c.red() == 0 );
+        CHECK( c.green() == 0 );
+        CHECK( c.blue() == 0 );
+    }
+}
\ No newline at end of file
diff --git a/test/unit/core/conversions_test.cpp b/test/unit/core/conversions_test.cpp
index 08819b2..0b42d85 100644
--- a/test/unit/core/conversions_test.cpp
+++ b/test/unit/core/conversions_test.cpp
@@ -2,11 +2,14 @@
 
 #include <mapnik/value_types.hpp>
 #include <mapnik/value.hpp>
+#include <mapnik/unicode.hpp>
 #include <mapnik/util/conversions.hpp>
+
 #include <iostream>
 #include <vector>
 #include <algorithm>
-#include <boost/unordered_map.hpp>
+#include <unordered_map>
+#include <sstream>
 
 #if defined(_MSC_VER) && _MSC_VER < 1900
 #include <cstdio>
@@ -283,12 +286,20 @@ SECTION("to string") {
         REQUIRE( val == true );
 
         // mapnik::value hashability
-        using values_container = boost::unordered_map<mapnik::value, unsigned>;
+        using values_container = std::unordered_map<mapnik::value, unsigned>;
         values_container vc;
         mapnik::value val2(1);
         vc[val2] = 1;
         REQUIRE( vc[1] == static_cast<int>(1) );
 
+        // mapnik::value << to ostream
+        std::stringstream s;
+        mapnik::transcoder tr("utf-8");
+        mapnik::value_unicode_string ustr = tr.transcode("hello world!");
+        mapnik::value streamable(ustr);
+        s << streamable;
+        CHECK( s.str() == std::string("hello world!") );
+
     }
     catch (std::exception const & ex)
     {
@@ -297,4 +308,4 @@ SECTION("to string") {
     }
 }
 
-}
\ No newline at end of file
+}
diff --git a/test/unit/core/copy_move_test.cpp b/test/unit/core/copy_move_test.cpp
index 3b38ae7..6905379 100644
--- a/test/unit/core/copy_move_test.cpp
+++ b/test/unit/core/copy_move_test.cpp
@@ -4,6 +4,7 @@
 #include <mapnik/color.hpp>
 #include <mapnik/datasource.hpp>
 #include <mapnik/datasource_cache.hpp>
+#include <mapnik/util/fs.hpp>
 
 #include <vector>
 #include <algorithm>
@@ -19,55 +20,59 @@ SECTION("layers") {
     {
         mapnik::Map m0(100,100);
         mapnik::Map m2(200,100);
-        mapnik::datasource_cache::instance().register_datasources("plugins/input/shape.input");
-        mapnik::parameters p;
-        p["type"]="shape";
-        p["file"]="demo/data/boundaries";
-        p["encoding"]="latin1";
-        auto ds0 = mapnik::datasource_cache::instance().create(p);
-
-        auto ds1 = ds0; // shared ptr copy
-        REQUIRE( (ds1 == ds0) );
-        REQUIRE( !(*ds1 != *ds0) );
-        REQUIRE( (ds1.get() == ds0.get()) );
-        ds1 = mapnik::datasource_cache::instance().create(p); // new with the same parameters
-        REQUIRE( (ds1 != ds0) );
-        REQUIRE( (*ds1 == *ds0) );
-        auto ds2 = std::move(ds1);
-        REQUIRE( (ds2 != ds0) );
-        REQUIRE( (*ds2 == *ds0) );
-
-        // mapnik::layer
-        mapnik::layer l0("test-layer");
-        l0.set_datasource(ds0);
-
-        mapnik::layer l1 = l0; // copy assignment
-        REQUIRE( (l1 == l0) );
-        mapnik::layer l2(l0); // copy ctor
-        REQUIRE( (l2 == l0) );
-        mapnik::layer l3(mapnik::layer("test-layer")); // move ctor
-        l3.set_datasource(ds2);
-
-        REQUIRE( (l3 == l0) );
-        mapnik::layer l4 = std::move(l3);
-        REQUIRE( (l4 == l0) ); // move assignment
-
-        m0.add_layer(l4);
-        m0.set_background(mapnik::color("skyblue"));
-        m2.set_background(mapnik::color("skyblue"));
-
-        auto m1 = m0; //copy
-
-        REQUIRE( (m0 == m1) );
-        REQUIRE( (m0 != m2) );
-
-        m2 = m1; // copy
-        REQUIRE( (m2 == m1) );
-        m2 = std::move(m1);
-        REQUIRE( (m2 == m0) );
-        REQUIRE( (m1 != m0) );
-
-        REQUIRE( (m0 == m2) );
+        std::string shape_plugin("./plugins/input/shape.input");
+        if (mapnik::util::exists(shape_plugin))
+        {
+            mapnik::datasource_cache::instance().register_datasources("plugins/input/shape.input");
+            mapnik::parameters p;
+            p["type"]="shape";
+            p["file"]="demo/data/boundaries";
+            p["encoding"]="latin1";
+            auto ds0 = mapnik::datasource_cache::instance().create(p);
+
+            auto ds1 = ds0; // shared ptr copy
+            REQUIRE( (ds1 == ds0) );
+            REQUIRE( !(*ds1 != *ds0) );
+            REQUIRE( (ds1.get() == ds0.get()) );
+            ds1 = mapnik::datasource_cache::instance().create(p); // new with the same parameters
+            REQUIRE( (ds1 != ds0) );
+            REQUIRE( (*ds1 == *ds0) );
+            auto ds2 = std::move(ds1);
+            REQUIRE( (ds2 != ds0) );
+            REQUIRE( (*ds2 == *ds0) );
+
+            // mapnik::layer
+            mapnik::layer l0("test-layer");
+            l0.set_datasource(ds0);
+
+            mapnik::layer l1 = l0; // copy assignment
+            REQUIRE( (l1 == l0) );
+            mapnik::layer l2(l0); // copy ctor
+            REQUIRE( (l2 == l0) );
+            mapnik::layer l3(mapnik::layer("test-layer")); // move ctor
+            l3.set_datasource(ds2);
+
+            REQUIRE( (l3 == l0) );
+            mapnik::layer l4 = std::move(l3);
+            REQUIRE( (l4 == l0) ); // move assignment
+
+            m0.add_layer(l4);
+            m0.set_background(mapnik::color("skyblue"));
+            m2.set_background(mapnik::color("skyblue"));
+
+            auto m1 = m0; //copy
+
+            REQUIRE( (m0 == m1) );
+            REQUIRE( (m0 != m2) );
+
+            m2 = m1; // copy
+            REQUIRE( (m2 == m1) );
+            m2 = std::move(m1);
+            REQUIRE( (m2 == m0) );
+            REQUIRE( (m1 != m0) );
+
+            REQUIRE( (m0 == m2) );
+        }
     }
     catch (std::exception const & ex)
     {
diff --git a/test/unit/core/exceptions_test.cpp b/test/unit/core/exceptions_test.cpp
index b3492d1..3324600 100644
--- a/test/unit/core/exceptions_test.cpp
+++ b/test/unit/core/exceptions_test.cpp
@@ -54,7 +54,7 @@ SECTION("handling") {
     mapnik::Map map(256,256);
     mapnik::rule r;
     r.set_filter(mapnik::parse_expression("[foo]='bar'"));
-    r.append(std::move(mapnik::markers_symbolizer()));
+    r.append(mapnik::markers_symbolizer());
     mapnik::feature_type_style style;
     style.add_rule(std::move(r));
     map.insert_style("style", std::move(style));
diff --git a/test/unit/geometry/geometry_envelope_test.cpp b/test/unit/geometry/geometry_envelope_test.cpp
index 1898f0a..0b7087c 100644
--- a/test/unit/geometry/geometry_envelope_test.cpp
+++ b/test/unit/geometry/geometry_envelope_test.cpp
@@ -20,7 +20,7 @@ SECTION("envelope_test - double") {
     }
     {
         // Test empty geom
-        geometry<double> geom(std::move(mapnik::geometry::geometry_empty()));
+        geometry<double> geom = mapnik::geometry::geometry_empty();
         mapnik::box2d<double> bbox = mapnik::geometry::envelope(geom);
         REQUIRE_FALSE( bbox.valid() );
     }
diff --git a/test/unit/geometry/geometry_reprojection.cpp b/test/unit/geometry/geometry_reprojection.cpp
index 1c604d2..1a52129 100644
--- a/test/unit/geometry/geometry_reprojection.cpp
+++ b/test/unit/geometry/geometry_reprojection.cpp
@@ -45,7 +45,7 @@ SECTION("test_projection_4326_3857 - Empty Geometry in Geometry Variant") {
     mapnik::projection dest("+init=epsg:3857");
     mapnik::proj_transform proj_trans(source, dest);
     {
-        geometry<double> geom(std::move(geometry_empty()));
+        geometry<double> geom = geometry_empty();
         unsigned int err = 0;
         // Test Standard Transform
         geometry<double> new_geom = reproject_copy(geom, proj_trans, err);
@@ -160,7 +160,7 @@ SECTION("test_projection_4326_3857 - Point Geometry Variant Object") {
     }
     {
         geometry<double> geom3(point<double>(-97.552175, 35.522895));
-        // Transform in place 
+        // Transform in place
         REQUIRE(reproject(geom3, proj_trans1));
         assert_g_equal(geom3, geom2);
         // Transform in place reverse - back
@@ -317,7 +317,7 @@ SECTION("test_projection_4326_3857 - Line_String Geometry Variant Object") {
         assert_g_equal(geom3, geom1);
     }
 } // End Section
-    
+
 SECTION("test_projection_4326_3857 - Polygon Geometry Object") {
     using namespace mapnik::geometry;
     mapnik::projection source("+init=epsg:4326");
@@ -787,7 +787,7 @@ SECTION("test_projection_4326_3857 - Multi_Line_String Geometry Variant Object")
         assert_g_equal(geom3, geom1);
     }
 } // End Section
-    
+
 SECTION("test_projection_4326_3857 - Multi_Polygon Geometry Object") {
     using namespace mapnik::geometry;
     mapnik::projection source("+init=epsg:4326");
@@ -969,7 +969,7 @@ SECTION("test_projection_4326_3857 - Multi_Polygon Geometry Variant Object") {
         assert_g_equal(geom3, geom1);
     }
 } // END SECTION
-    
+
 SECTION("test_projection_4326_3857 - Geometry Collection Object") {
     using namespace mapnik::geometry;
     mapnik::projection source("+init=epsg:4326");
diff --git a/test/unit/geometry/geometry_strategy_test.cpp b/test/unit/geometry/geometry_strategy_test.cpp
index a5fe01f..50acb72 100644
--- a/test/unit/geometry/geometry_strategy_test.cpp
+++ b/test/unit/geometry/geometry_strategy_test.cpp
@@ -62,7 +62,7 @@ SECTION("proj and view strategy") {
         // Test that both work grouped together passing in geometry
         using sg_type = strategy_group<mapnik::proj_strategy, mapnik::view_strategy >;
         sg_type sg(ps, vs);
-        geometry<double> p1(std::move(point<double>(-97.553098,35.523105)));
+        geometry<double> p1(point<double>(-97.553098,35.523105));
         point<double> r1(58.6287 , 100.945);
         geometry<double> p2 = transform<double>(p1, sg);
         REQUIRE(p2.is<point<double> >());
@@ -73,7 +73,7 @@ SECTION("proj and view strategy") {
         // Test that it works pulling back int
         using sg_type = strategy_group<mapnik::proj_strategy, mapnik::view_strategy >;
         sg_type sg(ps, vs);
-        geometry<double> p1(std::move(point<double>(-97.553098,35.523105)));
+        geometry<double> p1(point<double>(-97.553098,35.523105));
         point<std::int64_t> r1(58 , 100);
         geometry<std::int64_t> p2 = transform<std::int64_t>(p1, sg);
         REQUIRE(p2.is<point<std::int64_t> >());
@@ -85,7 +85,7 @@ SECTION("proj and view strategy") {
         mapnik::geometry::scale_rounding_strategy ss(16);
         using sg_type = strategy_group<mapnik::proj_strategy, mapnik::view_strategy, mapnik::geometry::scale_rounding_strategy >;
         sg_type sg(ps, vs, ss);
-        geometry<double> p1(std::move(point<double>(-97.553098,35.523105)));
+        geometry<double> p1(point<double>(-97.553098,35.523105));
         point<std::int64_t> r1(938 , 1615);
         geometry<std::int64_t> p2 = transform<std::int64_t>(p1, sg);
         REQUIRE(p2.is<point<std::int64_t> >());
@@ -97,7 +97,7 @@ SECTION("proj and view strategy") {
         mapnik::geometry::scale_strategy ss(1.0/16.0);
         using sg_type = strategy_group_first<mapnik::geometry::scale_strategy, mapnik::unview_strategy, mapnik::proj_strategy >;
         sg_type sg(ss, uvs, ps_rev);
-        geometry<std::int64_t> p1(std::move(point<std::int64_t>(938 , 1615)));
+        geometry<std::int64_t> p1(point<std::int64_t>(938 , 1615));
         point<double> r1(-97.5586 , 35.5322);
         geometry<double> p2 = transform<double>(p1, sg);
         REQUIRE(p2.is<point<double> >());
@@ -109,7 +109,7 @@ SECTION("proj and view strategy") {
         mapnik::geometry::scale_rounding_strategy ss(16, 20);
         using sg_type = strategy_group<mapnik::proj_strategy, mapnik::view_strategy, mapnik::geometry::scale_rounding_strategy >;
         sg_type sg(ps, vs, ss);
-        geometry<double> p1(std::move(point<double>(-97.553098,35.523105)));
+        geometry<double> p1(point<double>(-97.553098,35.523105));
         point<std::int64_t> r1(958 , 1635);
         geometry<std::int64_t> p2 = transform<std::int64_t>(p1, sg);
         REQUIRE(p2.is<point<std::int64_t> >());
@@ -121,7 +121,7 @@ SECTION("proj and view strategy") {
         mapnik::geometry::scale_strategy ss(1.0/16.0, -20.0/16.0);
         using sg_type = strategy_group_first<mapnik::geometry::scale_strategy, mapnik::unview_strategy, mapnik::proj_strategy >;
         sg_type sg(ss, uvs, ps_rev);
-        geometry<std::int64_t> p1(std::move(point<std::int64_t>(958 , 1635)));
+        geometry<std::int64_t> p1(point<std::int64_t>(958 , 1635));
         point<double> r1(-97.5586 , 35.5322);
         geometry<double> p2 = transform<double>(p1, sg);
         REQUIRE(p2.is<point<double> >());
@@ -133,22 +133,22 @@ SECTION("proj and view strategy") {
 
 SECTION("scaling strategies - double to double") {
     using namespace mapnik::geometry;
- 
-    {   
+
+    {
         scale_strategy ss(10.0);
         point<double> p(-90.3, 35.5);
         point<double> r(-903.0, 355.0);
         point<double> o = transform<double>(p, ss);
         assert_g_equal(r, o);
     }
-    {   
+    {
         scale_strategy ss(0.5, -2.0);
         point<double> p(-90.3, 35.5);
         point<double> r(-47.15, 15.75);
         point<double> o = transform<double>(p, ss);
         assert_g_equal(r, o);
     }
-    {   
+    {
         scale_rounding_strategy ss(0.5, -2.0);
         point<double> p(-90.3, 35.5);
         point<double> r(-47.0, 16.0);
@@ -160,22 +160,22 @@ SECTION("scaling strategies - double to double") {
 
 SECTION("scaling strategies - double to int64") {
     using namespace mapnik::geometry;
- 
-    {   
+
+    {
         scale_strategy ss(10.0);
         point<double> p(-90.31, 35.58);
         point<std::int64_t> r(-903, 355);
         point<std::int64_t> o = transform<std::int64_t>(p, ss);
         assert_g_equal(r, o);
     }
-    {   
+    {
         scale_strategy ss(0.5, -2.0);
         point<double> p(-90.3, 35.5);
         point<std::int64_t> r(-47, 15);
         point<std::int64_t> o = transform<std::int64_t>(p, ss);
         assert_g_equal(r, o);
     }
-    {   
+    {
         scale_rounding_strategy ss(0.5, -2.0);
         point<double> p(-90.3, 35.5);
         point<std::int64_t> r(-47, 16);
@@ -185,5 +185,3 @@ SECTION("scaling strategies - double to int64") {
 } // END SECTION
 
 } // END TEST CASE
-
-
diff --git a/test/unit/imaging/image.cpp b/test/unit/imaging/image.cpp
index d2c908e..ee70a67 100644
--- a/test/unit/imaging/image.cpp
+++ b/test/unit/imaging/image.cpp
@@ -1,6 +1,7 @@
 #include "catch.hpp"
 
 // mapnik
+#include <mapnik/value.hpp>
 #include <mapnik/image_any.hpp>
 #include <mapnik/color.hpp>
 #include <mapnik/image_view_any.hpp>
diff --git a/test/unit/imaging/image_io_test.cpp b/test/unit/imaging/image_io_test.cpp
index 8772ef3..d0a984d 100644
--- a/test/unit/imaging/image_io_test.cpp
+++ b/test/unit/imaging/image_io_test.cpp
@@ -26,6 +26,21 @@ SECTION("readers") {
         type = mapnik::type_from_filename(should_throw);
         REQUIRE( type );
         REQUIRE_THROWS(std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type)));
+
+        // actually a png so jpeg reader should throw
+        should_throw = "./test/data/images/landusepattern.jpg";
+        REQUIRE( mapnik::util::exists( should_throw ) );
+        type = mapnik::type_from_filename(should_throw);
+        REQUIRE( type );
+        try
+        {
+            std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type));
+            REQUIRE(false);
+        }
+        catch (std::exception const& ex)
+        {
+            REQUIRE( std::string(ex.what()) == std::string("JPEG Reader: libjpeg could not read image: Not a JPEG file: starts with 0x89 0x50") );
+        }
 #endif
 
         REQUIRE_THROWS(mapnik::image_rgba8 im(-10,-10)); // should throw rather than overflow
diff --git a/test/unit/imaging/image_painted_test.cpp b/test/unit/imaging/image_painted_test.cpp
index b567d5e..a1fbbc9 100644
--- a/test/unit/imaging/image_painted_test.cpp
+++ b/test/unit/imaging/image_painted_test.cpp
@@ -8,6 +8,7 @@
 #include <mapnik/datasource_cache.hpp>
 #include <mapnik/agg_renderer.hpp>
 #include <mapnik/expression.hpp>
+#include <mapnik/util/fs.hpp>
 
 TEST_CASE("image") {
 
@@ -17,47 +18,51 @@ SECTION("painting") {
 
     try
     {
-        datasource_cache::instance().register_datasources("plugins/input/csv.input");
+        std::string csv_plugin("./plugins/input/csv.input");
+        if (mapnik::util::exists(csv_plugin))
+        {
+            datasource_cache::instance().register_datasources(csv_plugin);
 
-        Map m(256, 256);
+            Map m(256, 256);
 
-        feature_type_style lines_style;
-        {
-            rule r;
-            line_symbolizer line_sym;
-            r.append(std::move(line_sym));
-            lines_style.add_rule(std::move(r));
-        }
-        m.insert_style("lines", std::move(lines_style));
+            feature_type_style lines_style;
+            {
+                rule r;
+                line_symbolizer line_sym;
+                r.append(std::move(line_sym));
+                lines_style.add_rule(std::move(r));
+            }
+            m.insert_style("lines", std::move(lines_style));
 
-        feature_type_style markers_style;
-        {
-            rule r;
-            r.set_filter(parse_expression("False"));
-            markers_symbolizer mark_sym;
-            r.append(std::move(mark_sym));
-            markers_style.add_rule(std::move(r));
-        }
-        m.insert_style("markers", std::move(markers_style));
+            feature_type_style markers_style;
+            {
+                rule r;
+                r.set_filter(parse_expression("False"));
+                markers_symbolizer mark_sym;
+                r.append(std::move(mark_sym));
+                markers_style.add_rule(std::move(r));
+            }
+            m.insert_style("markers", std::move(markers_style));
 
-        parameters p;
-        p["type"] = "csv";
-        p["separator"] = "|";
-        p["inline"] = "wkt\nLINESTRING(-10  0, 0 20, 10 0, 15 5)";
+            parameters p;
+            p["type"] = "csv";
+            p["separator"] = "|";
+            p["inline"] = "wkt\nLINESTRING(-10  0, 0 20, 10 0, 15 5)";
 
-        layer lyr("layer");
-        lyr.set_datasource(datasource_cache::instance().create(p));
-        lyr.add_style("lines");
-        lyr.add_style("markers");
-        m.add_layer(lyr);
+            layer lyr("layer");
+            lyr.set_datasource(datasource_cache::instance().create(p));
+            lyr.add_style("lines");
+            lyr.add_style("markers");
+            m.add_layer(lyr);
 
-        m.zoom_all();
+            m.zoom_all();
 
-        image_rgba8 image(m.width(), m.height());
-        agg_renderer<image_rgba8> ren(m, image);
-        ren.apply();
+            image_rgba8 image(m.width(), m.height());
+            agg_renderer<image_rgba8> ren(m, image);
+            ren.apply();
 
-        REQUIRE(image.painted() == true);
+            REQUIRE(image.painted() == true);
+        }
     }
     catch (std::exception const & ex)
     {
diff --git a/test/unit/imaging/image_set_pixel.cpp b/test/unit/imaging/image_set_pixel.cpp
new file mode 100644
index 0000000..ed7ceaf
--- /dev/null
+++ b/test/unit/imaging/image_set_pixel.cpp
@@ -0,0 +1,28 @@
+#include "catch.hpp"
+
+// mapnik
+#include <mapnik/image_any.hpp>
+#include <mapnik/image_view_any.hpp>
+#include <mapnik/color.hpp>
+#include <mapnik/image_util.hpp>
+
+
+TEST_CASE("image set_pixel") {
+
+SECTION("test gray32") {
+    mapnik::image_gray32 im(256,256);
+    mapnik::set_pixel(im, 0, 0, -1);
+    auto pixel = mapnik::get_pixel<mapnik::image_gray32::pixel_type>(im, 0, 0);
+    INFO( pixel );
+    CHECK( pixel == 0 );
+}
+
+SECTION("test gray8s") {
+    mapnik::image_gray8s im(256,256);
+    mapnik::set_pixel(im, 0, 0, std::numeric_limits<mapnik::image_gray8s::pixel_type>::max()+1);
+    auto pixel = mapnik::get_pixel<mapnik::image_gray8s::pixel_type>(im, 0, 0);
+    INFO( pixel );
+    CHECK( (int)pixel == (int)std::numeric_limits<mapnik::image_gray8s::pixel_type>::max() );
+}
+
+}
\ No newline at end of file
diff --git a/test/unit/imaging/tiff_io.cpp b/test/unit/imaging/tiff_io.cpp
index badf830..2e31d56 100644
--- a/test/unit/imaging/tiff_io.cpp
+++ b/test/unit/imaging/tiff_io.cpp
@@ -1,5 +1,8 @@
 
-#if defined(HAVE_TIFF)
+// disabled on windows due to https://github.com/mapnik/mapnik/issues/2838
+// TODO - get to the bottom of why including `tiff_reader.cpp` breaks windows
+// or re-write image_readers to allow `#include tiff_reader.hpp`
+#if !defined(_MSC_VER) && defined(HAVE_TIFF)
 
 #include "catch.hpp"
 
diff --git a/test/unit/numerics/safe_cast.cpp b/test/unit/numerics/safe_cast.cpp
new file mode 100644
index 0000000..b6cba62
--- /dev/null
+++ b/test/unit/numerics/safe_cast.cpp
@@ -0,0 +1,59 @@
+#include "catch.hpp"
+#include <mapnik/safe_cast.hpp>
+
+#define CAST_ASSERT(numeric_type)                                  \
+    using limit = std::numeric_limits<numeric_type>;                      \
+    auto min_value = static_cast<std::intmax_t>(limit::min())-1;          \
+    auto max_value = static_cast<std::intmax_t>(limit::max())+1;          \
+    CHECK( limit::min() == mapnik::safe_cast<numeric_type>(min_value) ); \
+    CHECK( limit::max() == mapnik::safe_cast<numeric_type>(max_value) ); \
+
+#define CAST_ASSERT2(numeric_type)                                 \
+    using limit = std::numeric_limits<numeric_type>;                      \
+    auto min_value = static_cast<std::intmax_t>(limit::min());            \
+    auto max_value = static_cast<std::intmax_t>(limit::max());            \
+    CHECK( limit::min() == mapnik::safe_cast<numeric_type>(min_value) ); \
+    CHECK( limit::max() == mapnik::safe_cast<numeric_type>(max_value) ); \
+
+#define CAST_ASSERT3(numeric_type)                                 \
+    using limit = std::numeric_limits<numeric_type>;                      \
+    auto min_value = static_cast<std::intmax_t>(limit::min())-1;          \
+    auto max_value = static_cast<std::uintmax_t>(limit::max());            \
+    CHECK( limit::min() == mapnik::safe_cast<numeric_type>(min_value) ); \
+    CHECK( limit::max() == mapnik::safe_cast<numeric_type>(max_value) ); \
+
+#define CAST_ASSERT4(numeric_type)                                 \
+    using limit = std::numeric_limits<numeric_type>;                      \
+    auto min_value = static_cast<double>(-limit::max())-1;          \
+    auto max_value = static_cast<double>(limit::max());            \
+    CHECK( -limit::max() == mapnik::safe_cast<numeric_type>(min_value) ); \
+    CHECK( limit::max() == mapnik::safe_cast<numeric_type>(max_value) ); \
+
+TEST_CASE("saturated cast") {
+
+    SECTION("int8")   { CAST_ASSERT(std::int8_t);   }
+    SECTION("int16")  { CAST_ASSERT(std::int16_t);  }
+    SECTION("int32")  { CAST_ASSERT(std::int32_t);  }
+
+    SECTION("int64")  { CAST_ASSERT2(std::int64_t);  }
+    SECTION("intmax") { CAST_ASSERT2(std::intmax_t); }
+    SECTION("intptr") { CAST_ASSERT2(std::intptr_t); }
+
+    SECTION("uint8")   { CAST_ASSERT(std::uint8_t);   }
+    SECTION("uint16")  { CAST_ASSERT(std::uint16_t);  }
+    SECTION("uint32")  { CAST_ASSERT(std::uint32_t);  }
+
+    SECTION("uint64")  { CAST_ASSERT3(std::uint64_t);  }
+    SECTION("uintmax") { CAST_ASSERT3(std::uintmax_t); }
+    SECTION("uintptr") { CAST_ASSERT3(std::uintptr_t); }
+
+    SECTION("float") { CAST_ASSERT4(float); }
+
+    SECTION("freeform") {
+
+        CHECK( static_cast<std::size_t>(0) == mapnik::safe_cast<std::size_t>(-1) );
+        CHECK( static_cast<std::uint64_t>(0) == mapnik::safe_cast<std::uint64_t>(-1) );
+        CHECK( static_cast<unsigned long long>(0) == mapnik::safe_cast<unsigned long long>(-1) );
+    }
+
+}
\ No newline at end of file
diff --git a/test/unit/projection/proj_transform.cpp b/test/unit/projection/proj_transform.cpp
index 618b57d..d2a3789 100644
--- a/test/unit/projection/proj_transform.cpp
+++ b/test/unit/projection/proj_transform.cpp
@@ -4,6 +4,12 @@
 #include <mapnik/proj_transform.hpp>
 #include <mapnik/box2d.hpp>
 
+#ifdef MAPNIK_USE_PROJ4
+// proj4
+#include <proj_api.h>
+#endif
+
+
 TEST_CASE("projection transform")
 {
 
@@ -33,6 +39,84 @@ SECTION("Test bounding box transforms - 4326 to 3857")
     CHECK(bbox.maxx() == Approx(maxx));
     CHECK(bbox.maxy() == Approx(maxy));
 
-} // END SECTION
+}
+
+
+#if defined(MAPNIK_USE_PROJ4) && PJ_VERSION >= 480
+SECTION("test pj_transform failure behavior")
+{
+    mapnik::projection proj_4269("+init=epsg:4269");
+    mapnik::projection proj_3857("+init=epsg:3857");
+    mapnik::proj_transform prj_trans(proj_4269, proj_3857);
+    mapnik::proj_transform prj_trans2(proj_3857, proj_4269);
+
+    auto proj_ctx0 = pj_ctx_alloc();
+    REQUIRE( proj_ctx0 != nullptr );
+    auto proj0 = pj_init_plus_ctx(proj_ctx0, proj_4269.params().c_str());
+    REQUIRE( proj0 != nullptr );
+
+    auto proj_ctx1 = pj_ctx_alloc();
+    REQUIRE( proj_ctx1 != nullptr );
+    auto proj1 = pj_init_plus_ctx(proj_ctx1, proj_3857.params().c_str());
+    REQUIRE( proj1 != nullptr );
+
+    // first test valid values directly against proj
+    double x = -180.0;
+    double y = -60.0;
+    x *= DEG_TO_RAD;
+    y *= DEG_TO_RAD;
+    CHECK( x == Approx(-3.1415926536) );
+    CHECK( y == Approx(-1.0471975512) );
+    CHECK( 0 == pj_transform(proj0, proj1, 1, 0, &x, &y, nullptr) );
+    CHECK( x == Approx(-20037508.3427892439) );
+    CHECK( y == Approx(-8399737.8896366451) );
+
+    // now test mapnik class
+    double x0 = -180.0;
+    double y0 = -60.0;
+    CHECK( prj_trans.forward(&x0,&y0,nullptr,1,1) );
+    CHECK( x0 == Approx(-20037508.3427892439) );
+    CHECK( y0 == Approx(-8399737.8896366451) );
+    double x1 = -180.0;
+    double y1 = -60.0;
+    CHECK( prj_trans2.backward(&x1,&y1,nullptr,1,1) );
+    CHECK( x1 == Approx(-20037508.3427892439) );
+    CHECK( y1 == Approx(-8399737.8896366451) );
+
+    // longitude value outside the value range for mercator
+    x = -181.0;
+    y = -91.0;
+    x *= DEG_TO_RAD;
+    y *= DEG_TO_RAD;
+    CHECK( x == Approx(-3.1590459461) );
+    CHECK( y == Approx(-1.5882496193) );
+    CHECK( 0 == pj_transform(proj0, proj1, 1, 0, &x, &y, nullptr) );
+    CHECK( std::isinf(x) );
+    CHECK( std::isinf(y) );
+
+    // now test mapnik class
+    double x2 = -181.0;
+    double y2 = -91.0;
+    CHECK( false == prj_trans.forward(&x2,&y2,nullptr,1,1) );
+    CHECK( std::isinf(x2) );
+    CHECK( std::isinf(y2) );
+    double x3 = -181.0;
+    double y3 = -91.0;
+    CHECK( false == prj_trans2.backward(&x3,&y3,nullptr,1,1) );
+    CHECK( std::isinf(x3) );
+    CHECK( std::isinf(y3) );
+
+    // cleanup
+    pj_ctx_free(proj_ctx0);
+    proj_ctx0 = nullptr;
+    pj_free(proj0);
+    proj0 = nullptr;
+    pj_ctx_free(proj_ctx1);
+    proj_ctx1 = nullptr;
+    pj_free(proj1);
+    proj1 = nullptr;
+}
+
+#endif
 
-} // END TEST CASE
+}
diff --git a/test/unit/run.cpp b/test/unit/run.cpp
index 74b0715..15ad099 100644
--- a/test/unit/run.cpp
+++ b/test/unit/run.cpp
@@ -1,36 +1,13 @@
 #define CATCH_CONFIG_RUNNER
 #include "catch.hpp"
 
-#include <libxml/parser.h> // for xmlInitParser(), xmlCleanupParser()
-#include <cairo.h>
-#include <unicode/uclean.h>
-
-#ifdef MAPNIK_USE_PROJ4
-#include <proj_api.h>
-#endif
+#include "cleanup.hpp" // run_cleanup()
 
 int main (int argc, char* const argv[])
 {
     int result = Catch::Session().run( argc, argv );
-    // only call this once, on exit
-    // to make sure valgrind output is clean
-    // http://xmlsoft.org/xmlmem.html
-    xmlCleanupParser();
-
-    // http://cairographics.org/manual/cairo-Error-handling.html#cairo-debug-reset-static-data
-    cairo_debug_reset_static_data();
-
-    // http://icu-project.org/apiref/icu4c/uclean_8h.html#a93f27d0ddc7c196a1da864763f2d8920
-    u_cleanup();
 
-#ifdef MAPNIK_USE_PROJ4
-    // http://trac.osgeo.org/proj/ticket/149
- #if PJ_VERSION >= 480
-    pj_clear_initcache();
- #endif
-    // https://trac.osgeo.org/proj/wiki/ProjAPI#EnvironmentFunctions
-    pj_deallocate_grids();
-#endif
+    testing::run_cleanup();
 
     return result;
 }
diff --git a/test/unit/serialization/xml_parser_trim.cpp b/test/unit/serialization/xml_parser_trim.cpp
new file mode 100644
index 0000000..f79c755
--- /dev/null
+++ b/test/unit/serialization/xml_parser_trim.cpp
@@ -0,0 +1,45 @@
+#include "catch.hpp"
+
+#include <mapnik/debug.hpp>
+#include <mapnik/value.hpp>
+#include <mapnik/xml_tree.hpp>
+#include <mapnik/xml_loader.hpp>
+#include <mapnik/attribute.hpp>
+
+TEST_CASE("xml parser") {
+
+  SECTION("trims whitespace") {
+
+    // simple and non-valid mapnik XML reduced from the empty_parameter2.xml
+    // test case. this is to check that the xml parsing routine is trimming
+    // whitespace from text nodes as part of the parsing operation.
+    const std::string xml("<Map>"
+                          "  <Layer>"
+                          "    <Datasource>"
+                          "      <Parameter name=\"empty\"><![CDATA[ ]]></Parameter>"
+                          "    </Datasource>"
+                          "  </Layer>"
+                          "</Map>");
+
+    mapnik::xml_tree tree;
+    tree.set_filename("xml_datasource_parameter_trim.cpp");
+    REQUIRE_NOTHROW(read_xml_string(xml, tree.root(), ""));
+
+    REQUIRE(tree.root().has_child("Map"));
+    mapnik::xml_node const &map = tree.root().get_child("Map");
+
+    REQUIRE(map.has_child("Layer"));
+    mapnik::xml_node const &layer = map.get_child("Layer");
+
+    REQUIRE(layer.has_child("Datasource"));
+    mapnik::xml_node const &datasource = layer.get_child("Datasource");
+
+    REQUIRE(datasource.has_child("Parameter"));
+    mapnik::xml_node const &parameter = datasource.get_child("Parameter");
+
+    // parser should call mapnik::util::trim on the text content and
+    // this should result in an empty text string in the parameter.
+    REQUIRE(parameter.get_text() == "");
+  }
+}
+
diff --git a/test/unit/vertex_adapter/line_offset_test.cpp b/test/unit/vertex_adapter/line_offset_test.cpp
index 8d02502..6e32f72 100644
--- a/test/unit/vertex_adapter/line_offset_test.cpp
+++ b/test/unit/vertex_adapter/line_offset_test.cpp
@@ -116,16 +116,16 @@ void test_offset_curve(double const &offset) {
     off_vc.reset(); off_vc.next_subpath();
 
     while (vc.move(dx)) {
-        double pos = vc.linear_position();
-        double off_pos = off_vc.position_closest_to(vc.current_position());
+        double mpos = vc.linear_position();
+        double moff_pos = off_vc.position_closest_to(vc.current_position());
         {
             mapnik::vertex_cache::scoped_state s(off_vc);
-            off_vc.move(off_pos);
+            off_vc.move(moff_pos);
             auto eps = (1.001 * offset);
             auto actual = dist(vc.current_position(), off_vc.current_position());
             REQUIRE(actual < eps);
         }
-        REQUIRE(std::abs((pos / vc.length()) - (off_pos / off_vc.length())) < 1.0e-3);
+        REQUIRE(std::abs((mpos / vc.length()) - (moff_pos / off_vc.length())) < 1.0e-3);
     }
 }
 
@@ -154,10 +154,10 @@ void test_s_shaped_curve(double const &offset) {
     off_vc.reset(); off_vc.next_subpath();
 
     while (vc.move(dx)) {
-        double off_pos = off_vc.position_closest_to(vc.current_position());
+        double moff_pos = off_vc.position_closest_to(vc.current_position());
         {
             mapnik::vertex_cache::scoped_state s(off_vc);
-            off_vc.move(off_pos);
+            off_vc.move(moff_pos);
             REQUIRE(dist(vc.current_position(), off_vc.current_position()) < (1.002 * offset));
         }
     }
diff --git a/test/unit/vertex_adapter/offset_converter.cpp b/test/unit/vertex_adapter/offset_converter.cpp
new file mode 100644
index 0000000..b4b7d73
--- /dev/null
+++ b/test/unit/vertex_adapter/offset_converter.cpp
@@ -0,0 +1,398 @@
+#include "catch.hpp"
+
+// mapnik
+#include <mapnik/global.hpp>
+#include <mapnik/coord.hpp>
+#include <mapnik/vertex.hpp>
+#include <mapnik/offset_converter.hpp>
+
+// stl
+#include <stdexcept>
+#include <iostream>
+#include <fstream>
+#include <vector>
+#include <tuple>
+#include <algorithm>
+
+namespace offset_test {
+
+struct fake_path
+{
+    using coord_type = std::tuple<double, double, unsigned>;
+    using cont_type = std::vector<coord_type>;
+    cont_type vertices_;
+    cont_type::iterator itr_;
+
+    fake_path(std::initializer_list<double> l)
+        : fake_path(l.begin(), l.size()) {
+    }
+
+    fake_path(std::vector<double> const &v, bool make_invalid = false)
+        : fake_path(v.begin(), v.size(), make_invalid) {
+    }
+
+    template <typename Itr>
+    fake_path(Itr itr, size_t sz, bool make_invalid = false) {
+        size_t num_coords = sz >> 1;
+        if (make_invalid)
+        {
+            num_coords++;
+        }
+        vertices_.reserve(num_coords);
+        if (make_invalid)
+        {
+            vertices_.push_back(std::make_tuple(0,0,mapnik::SEG_END));
+        }
+
+        for (size_t i = 0; i < num_coords; ++i) {
+            double x = *itr++;
+            double y = *itr++;
+            unsigned cmd = (i == 0) ? mapnik::SEG_MOVETO : mapnik::SEG_LINETO;
+            vertices_.push_back(std::make_tuple(x, y, cmd));
+        }
+        itr_ = vertices_.begin();
+    }
+
+    unsigned vertex(double *x, double *y) {
+        if (itr_ == vertices_.end()) {
+            return mapnik::SEG_END;
+        }
+        *x = std::get<0>(*itr_);
+        *y = std::get<1>(*itr_);
+        unsigned cmd = std::get<2>(*itr_);
+        ++itr_;
+        return cmd;
+    }
+
+    void rewind(unsigned) {
+        itr_ = vertices_.begin();
+    }
+};
+
+static double DELTA_BUFF = 0.5;
+
+double dist(double x0, double y0, double x1, double y1)
+{
+    double dx = x0 - x1;
+    double dy = y0 - y1;
+    return std::sqrt(dx*dx + dy*dy);
+}
+
+void test_null_segment(double const &offset)
+{
+    fake_path path = {};
+    mapnik::offset_converter<fake_path> off_path_new(path);
+    off_path_new.set_offset(offset);
+    double x0 = 0;
+    double y0 = 0;
+    REQUIRE(off_path_new.vertex(&x0, &y0) == mapnik::SEG_END);
+    REQUIRE(off_path_new.vertex(&x0, &y0) == mapnik::SEG_END);
+    REQUIRE(off_path_new.vertex(&x0, &y0) == mapnik::SEG_END);
+}
+
+void test_invalid_segment(double const &offset)
+{
+    std::vector<double> v_path = {1, 1, 1, 2};
+    fake_path path(v_path, true);
+    mapnik::offset_converter<fake_path> off_path_new(path);
+    off_path_new.set_offset(offset);
+    double x0 = 0;
+    double y0 = 0;
+    REQUIRE(off_path_new.vertex(&x0, &y0) == mapnik::SEG_END);
+    REQUIRE(off_path_new.vertex(&x0, &y0) == mapnik::SEG_END);
+    REQUIRE(off_path_new.vertex(&x0, &y0) == mapnik::SEG_END);
+}
+
+
+void test_simple_segment(double const &offset)
+{
+    fake_path path = {0, 0, 1, 0}, off_path = {0, offset, 1, offset};
+    mapnik::offset_converter<fake_path> off_path_new(path);
+    off_path_new.set_offset(offset);
+
+    double x0, y0, x1, y1;
+    unsigned cmd0 = off_path_new.vertex(&x0, &y0);
+    unsigned cmd1 = off_path.vertex(&x1,&y1);
+    double d = dist(x0, y0, x1, y1);
+    while (true) {
+        if (d > (std::abs(offset) + DELTA_BUFF))
+        {
+            cmd0 = off_path_new.vertex(&x0,&y0);
+            REQUIRE(cmd0 != mapnik::SEG_END);
+            d = dist(x0, y0, x1, y1);
+            REQUIRE(d <= (std::abs(offset) + DELTA_BUFF));
+        }
+        else
+        {
+            REQUIRE(d <= (std::abs(offset) + DELTA_BUFF));
+            
+        }
+        
+        cmd1 = off_path.vertex(&x1,&y1);
+        if (cmd1 == mapnik::SEG_END) break;
+        d = dist(x0, y0, x1, y1);
+        bool done = false;
+        while (d <= (std::abs(offset) + DELTA_BUFF))
+        {
+            CHECK(true);
+            cmd0 = off_path_new.vertex(&x0,&y0);
+            if (cmd0 == mapnik::SEG_END)
+            {
+                done = true;
+                break;
+            }
+        }
+        if (done) break;
+    }
+}
+
+void test_straight_line(double const &offset) {
+    fake_path path = {0, 0, 1, 0, 9, 0, 10, 0},
+        off_path = {0, offset, 1, offset, 9, offset, 10, offset};
+    mapnik::offset_converter<fake_path> off_path_new(path);
+    off_path_new.set_offset(offset);
+
+    double x0, y0, x1, y1;
+    unsigned cmd0 = off_path_new.vertex(&x0, &y0);
+    unsigned cmd1 = off_path.vertex(&x1,&y1);
+    double d = dist(x0, y0, x1, y1);
+    while (true) {
+        if (d > (std::abs(offset) + DELTA_BUFF))
+        {
+            cmd0 = off_path_new.vertex(&x0,&y0);
+            REQUIRE(cmd0 != mapnik::SEG_END);
+            d = dist(x0, y0, x1, y1);
+            REQUIRE(d <= (std::abs(offset) + DELTA_BUFF));
+        }
+        else
+        {
+            REQUIRE(d <= (std::abs(offset) + DELTA_BUFF));
+            
+        }
+        
+        cmd1 = off_path.vertex(&x1,&y1);
+        d = dist(x0, y0, x1, y1);
+        bool done = false;
+        while (d <= (std::abs(offset) + DELTA_BUFF))
+        {
+            CHECK(true);
+            cmd0 = off_path_new.vertex(&x0,&y0);
+            if (cmd0 == mapnik::SEG_END)
+            {
+                done = true;
+                break;
+            }
+        }
+        if (done) break;
+    }
+}
+
+void test_offset_curve(double const &offset) {
+    const double r = (1.0 + offset);
+
+    std::vector<double> pos, off_pos;
+    const size_t max_i = 1000;
+    for (size_t i = 0; i <= max_i; ++i) {
+        double x = M_PI * double(i) / max_i;
+        pos.push_back(-std::cos(x)); pos.push_back(std::sin(x));
+        off_pos.push_back(-r * std::cos(x)); off_pos.push_back(r * std::sin(x));
+    }
+
+    fake_path path(pos), off_path(off_pos);
+    mapnik::offset_converter<fake_path> off_path_new(path);
+    off_path_new.set_offset(offset);
+
+    double x0, y0, x1, y1;
+    unsigned cmd0 = off_path_new.vertex(&x0, &y0);
+    unsigned cmd1 = off_path.vertex(&x1,&y1);
+    double d = dist(x0, y0, x1, y1);
+    while (true) {
+        if (d > (std::abs(offset) + DELTA_BUFF))
+        {
+            cmd0 = off_path_new.vertex(&x0,&y0);
+            REQUIRE(cmd0 != mapnik::SEG_END);
+            d = dist(x0, y0, x1, y1);
+            REQUIRE(d <= (std::abs(offset) + DELTA_BUFF));
+        }
+        else
+        {
+            REQUIRE(d <= (std::abs(offset) + DELTA_BUFF));
+            
+        }
+        
+        cmd1 = off_path.vertex(&x1,&y1);
+        d = dist(x0, y0, x1, y1);
+        bool done = false;
+        while (d <= (std::abs(offset) + DELTA_BUFF))
+        {
+            CHECK(true);
+            cmd0 = off_path_new.vertex(&x0,&y0);
+            if (cmd0 == mapnik::SEG_END)
+            {
+                done = true;
+                break;
+            }
+        }
+        if (done) break;
+    }
+}
+
+void test_s_shaped_curve(double const &offset) {
+    const double r = (1.0 + offset);
+    const double r2 = (1.0 - offset);
+
+    std::vector<double> pos, off_pos;
+    const size_t max_i = 1000;
+    for (size_t i = 0; i <= max_i; ++i) {
+        double x = M_PI * double(i) / max_i;
+        pos.push_back(-std::cos(x) - 1); pos.push_back(std::sin(x));
+        off_pos.push_back(-r * std::cos(x) - 1); off_pos.push_back(r * std::sin(x));
+    }
+    for (size_t i = 0; i <= max_i; ++i) {
+        double x = M_PI * double(i) / max_i;
+        pos.push_back(-std::cos(x) + 1); pos.push_back(-std::sin(x));
+        off_pos.push_back(-r2 * std::cos(x) + 1); off_pos.push_back(-r2 * std::sin(x));
+    }
+
+    fake_path path(pos), off_path(off_pos);
+    mapnik::offset_converter<fake_path> off_path_new(path);
+    off_path_new.set_offset(offset);
+
+    double x0, y0, x1, y1;
+    unsigned cmd0 = off_path_new.vertex(&x0, &y0);
+    unsigned cmd1 = off_path.vertex(&x1,&y1);
+    double d = dist(x0, y0, x1, y1);
+    while (true) {
+        if (d > (std::abs(offset) + DELTA_BUFF))
+        {
+            cmd0 = off_path_new.vertex(&x0,&y0);
+            REQUIRE(cmd0 != mapnik::SEG_END);
+            d = dist(x0, y0, x1, y1);
+            REQUIRE(d <= (std::abs(offset) + DELTA_BUFF));
+        }
+        else
+        {
+            REQUIRE(d <= (std::abs(offset) + DELTA_BUFF));
+            
+        }
+        
+        cmd1 = off_path.vertex(&x1,&y1);
+        d = dist(x0, y0, x1, y1);
+        bool done = false;
+        while (d <= (std::abs(offset) + DELTA_BUFF))
+        {
+            CHECK(true);
+            cmd0 = off_path_new.vertex(&x0,&y0);
+            if (cmd0 == mapnik::SEG_END)
+            {
+                done = true;
+                break;
+            }
+        }
+        if (done) break;
+    }
+}
+
+} // END NS
+
+TEST_CASE("offset converter") {
+
+SECTION("null segment") {
+    try {
+
+        std::vector<double> offsets = { 1, -1 };
+        for (double offset : offsets) {
+            // test simple straight line segment - should be easy to
+            // find the correspondance here.
+            offset_test::test_null_segment(offset);
+        }
+    }
+    catch (std::exception const& ex)
+    {
+        std::cerr << ex.what() << "\n";
+        REQUIRE(false);
+    }
+}
+
+SECTION("invalid segment") {
+    try {
+
+        std::vector<double> offsets = { 1, -1 };
+        for (double offset : offsets) {
+            // test simple straight line segment - should be easy to
+            // find the correspondance here.
+            offset_test::test_invalid_segment(offset);
+        }
+    }
+    catch (std::exception const& ex)
+    {
+        std::cerr << ex.what() << "\n";
+        REQUIRE(false);
+    }
+}
+
+
+SECTION("simple segment") {
+    try {
+
+        std::vector<double> offsets = { 1, -1 };
+        for (double offset : offsets) {
+            // test simple straight line segment - should be easy to
+            // find the correspondance here.
+            offset_test::test_simple_segment(offset);
+        }
+    }
+    catch (std::exception const& ex)
+    {
+        std::cerr << ex.what() << "\n";
+        REQUIRE(false);
+    }
+}
+
+SECTION("straight line") {
+    try {
+
+        std::vector<double> offsets = { 1, -1 };
+        for (double offset : offsets) {
+            // test straight line consisting of more than one segment.
+            offset_test::test_straight_line(offset);
+        }
+    }
+    catch (std::exception const& ex)
+    {
+        std::cerr << ex.what() << "\n";
+        REQUIRE(false);
+    }
+}
+
+SECTION("curve") {
+    try {
+
+        std::vector<double> offsets = { 1, -1 };
+        for (double offset : offsets) {
+            offset_test::test_offset_curve(offset);
+        }
+    }
+    catch (std::exception const& ex)
+    {
+        std::cerr << ex.what() << "\n";
+        REQUIRE(false);
+    }
+}
+
+SECTION("s curve") {
+    try {
+
+        std::vector<double> offsets = { 1, -1 };
+        for (double offset : offsets) {
+            offset_test::test_s_shaped_curve(offset);
+        }
+    }
+    catch (std::exception const& ex)
+    {
+        std::cerr << ex.what() << "\n";
+        REQUIRE(false);
+    }
+}
+
+}
diff --git a/test/visual/compare_images.hpp b/test/visual/compare_images.hpp
deleted file mode 100644
index d227d78..0000000
--- a/test/visual/compare_images.hpp
+++ /dev/null
@@ -1,53 +0,0 @@
-/*****************************************************************************
- *
- * This file is part of Mapnik (c++ mapping toolkit)
- *
- * Copyright (C) 2015 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 COMPARE_IMAGES_HPP
-#define COMPARE_IMAGES_HPP
-
-// stl
-#include <memory>
-
-// mapnik
-#include <mapnik/image_util.hpp>
-#include <mapnik/image_reader.hpp>
-
-namespace visual_tests
-{
-
-template <typename Image>
-unsigned compare_images(Image const & actual, std::string const & reference)
-{
-    std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(reference, "png"));
-    if (!reader.get())
-    {
-        throw mapnik::image_reader_exception("Failed to load: " + reference);
-    }
-
-    mapnik::image_any ref_image_any = reader->read(0, 0, reader->width(), reader->height());
-    Image const & reference_image = mapnik::util::get<Image>(ref_image_any);
-
-    return mapnik::compare(actual, reference_image, 0, true);
-}
-
-}
-
-#endif
diff --git a/test/visual/config.hpp b/test/visual/config.hpp
index 48e6359..0dac1d9 100644
--- a/test/visual/config.hpp
+++ b/test/visual/config.hpp
@@ -26,6 +26,7 @@
 // stl
 #include <vector>
 #include <string>
+#include <chrono>
 
 // boost
 #include <boost/filesystem.hpp>
@@ -35,21 +36,23 @@ namespace visual_tests
 
 struct map_size
 {
-    map_size(int width, int height) : width(width), height(height) { }
+    map_size(std::size_t _width, std::size_t _height) : width(_width), height(_height) { }
     map_size() { }
-    unsigned width;
-    unsigned height;
+    std::size_t width = 0;
+    std::size_t height = 0;
 };
 
 struct config
 {
     config() : status(true),
                scales({ 1.0, 2.0 }),
-               sizes({ { 500, 100 } }) { }
+               sizes({ { 500, 100 } }),
+               tiles({ { 1, 1 } }) { }
 
     bool status;
     std::vector<double> scales;
     std::vector<map_size> sizes;
+    std::vector<map_size> tiles;
 };
 
 enum result_state : std::uint8_t
@@ -66,11 +69,13 @@ struct result
     result_state state;
     std::string renderer_name;
     map_size size;
+    map_size tiles;
     double scale_factor;
     boost::filesystem::path actual_image_path;
     boost::filesystem::path reference_image_path;
     std::string error_message;
     unsigned diff;
+    std::chrono::high_resolution_clock::duration duration;
 };
 
 using result_list = std::vector<result>;
diff --git a/test/visual/map_sizes_grammar.hpp b/test/visual/map_sizes_grammar.hpp
index 2946422..10d3350 100644
--- a/test/visual/map_sizes_grammar.hpp
+++ b/test/visual/map_sizes_grammar.hpp
@@ -27,7 +27,9 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-parameter"
 #pragma GCC diagnostic ignored "-Wunused-local-typedef"
+#pragma GCC diagnostic ignored "-Wshadow"
 #pragma GCC diagnostic ignored "-Wmissing-field-initializers"
+#pragma GCC diagnostic ignored "-Wsign-conversion"
 #include <boost/spirit/include/qi.hpp>
 #include <boost/spirit/include/phoenix.hpp>
 #pragma GCC diagnostic pop
diff --git a/test/visual/renderer.hpp b/test/visual/renderer.hpp
index 6d99c3a..6ad9791 100644
--- a/test/visual/renderer.hpp
+++ b/test/visual/renderer.hpp
@@ -23,17 +23,20 @@
 #ifndef RENDERER_HPP
 #define RENDERER_HPP
 
-#include "compare_images.hpp"
-
 // stl
 #include <sstream>
 #include <iomanip>
 #include <fstream>
+#include <memory>
 
 // mapnik
 #include <mapnik/map.hpp>
+#include <mapnik/image_util.hpp>
+#include <mapnik/image_reader.hpp>
 #include <mapnik/agg_renderer.hpp>
+#if defined(GRID_RENDERER)
 #include <mapnik/grid/grid_renderer.hpp>
+#endif
 #if defined(HAVE_CAIRO)
 #include <mapnik/cairo/cairo_renderer.hpp>
 #include <mapnik/cairo/cairo_image_util.hpp>
@@ -54,10 +57,20 @@ struct renderer_base
     using image_type = ImageType;
 
     static constexpr const char * ext = ".png";
+    static constexpr const bool support_tiles = true;
 
     unsigned compare(image_type const & actual, boost::filesystem::path const& reference) const
     {
-        return compare_images(actual, reference.string());
+        std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(reference.string(), "png"));
+        if (!reader.get())
+        {
+            throw mapnik::image_reader_exception("Failed to load: " + reference.string());
+        }
+
+        mapnik::image_any ref_image_any = reader->read(0, 0, reader->width(), reader->height());
+        ImageType const & reference_image = mapnik::util::get<ImageType>(ref_image_any);
+
+        return mapnik::compare(actual, reference_image, 0, true);
     }
 
     void save(image_type const & image, boost::filesystem::path const& path) const
@@ -104,6 +117,7 @@ struct svg_renderer : renderer_base<std::string>
 {
     static constexpr const char * name = "svg";
     static constexpr const char * ext = ".svg";
+    static constexpr const bool support_tiles = false;
 
     image_type render(mapnik::Map const & map, double scale_factor) const
     {
@@ -123,7 +137,7 @@ struct svg_renderer : renderer_base<std::string>
         }
         std::string expected(std::istreambuf_iterator<char>(stream.rdbuf()),(std::istreambuf_iterator<char>()));
         stream.close();
-        return std::fabs(actual.size() - expected.size());
+        return std::max(actual.size(), expected.size()) - std::min(actual.size(), expected.size());
     }
 
     void save(image_type const & image, boost::filesystem::path const& path) const
@@ -140,6 +154,7 @@ struct svg_renderer : renderer_base<std::string>
 };
 #endif
 
+#if defined(GRID_RENDERER)
 struct grid_renderer : renderer_base<mapnik::image_rgba8>
 {
     static constexpr const char * name = "grid";
@@ -186,20 +201,78 @@ struct grid_renderer : renderer_base<mapnik::image_rgba8>
         return image;
     }
 };
+#endif
+
+template <typename T>
+void set_rectangle(T const & src, T & dst, std::size_t x, std::size_t y)
+{
+    mapnik::box2d<int> ext0(0, 0, dst.width(), dst.height());
+    mapnik::box2d<int> ext1(x, y, x + src.width(), y + src.height());
+
+    if (ext0.intersects(ext1))
+    {
+        mapnik::box2d<int> box = ext0.intersect(ext1);
+        for (std::size_t pix_y = box.miny(); pix_y < static_cast<std::size_t>(box.maxy()); ++pix_y)
+        {
+            typename T::pixel_type * row_to =  dst.get_row(pix_y);
+            typename T::pixel_type const * row_from = src.get_row(pix_y - y);
+
+            for (std::size_t pix_x = box.minx(); pix_x < static_cast<std::size_t>(box.maxx()); ++pix_x)
+            {
+                row_to[pix_x] = row_from[pix_x - x];
+            }
+        }
+    }
+}
 
 template <typename Renderer>
 class renderer
 {
 public:
-    renderer(boost::filesystem::path const & output_dir, boost::filesystem::path const & reference_dir, bool overwrite)
-        : ren(), output_dir(output_dir), reference_dir(reference_dir), overwrite(overwrite)
+    using renderer_type = Renderer;
+    using image_type = typename Renderer::image_type;
+
+    renderer(boost::filesystem::path const & _output_dir, boost::filesystem::path const & _reference_dir, bool _overwrite)
+        : ren(), output_dir(_output_dir), reference_dir(_reference_dir), overwrite(_overwrite)
+    {
+    }
+
+    image_type render(mapnik::Map const & map, double scale_factor) const
     {
+        return ren.render(map, scale_factor);
+    }
+
+    image_type render(mapnik::Map & map, double scale_factor, map_size const & tiles) const
+    {
+        mapnik::box2d<double> box = map.get_current_extent();
+        image_type image(map.width(), map.height());
+        map.resize(image.width() / tiles.width, image.height() / tiles.height);
+        double tile_box_width = box.width() / tiles.width;
+        double tile_box_height = box.height() / tiles.height;
+        for (std::size_t tile_y = 0; tile_y < tiles.height; tile_y++)
+        {
+            for (std::size_t tile_x = 0; tile_x < tiles.width; tile_x++)
+            {
+                mapnik::box2d<double> tile_box(
+                    box.minx() + tile_x * tile_box_width,
+                    box.miny() + tile_y * tile_box_height,
+                    box.minx() + (tile_x + 1) * tile_box_width,
+                    box.miny() + (tile_y + 1) * tile_box_height);
+                map.zoom_to_box(tile_box);
+                image_type tile(ren.render(map, scale_factor));
+                set_rectangle(tile, image, tile_x * tile.width(), (tiles.height - 1 - tile_y) * tile.height());
+            }
+        }
+        return image;
     }
 
-    result test(std::string const & name, mapnik::Map const & map, double scale_factor) const
+    result report(image_type const & image,
+                  std::string const & name,
+                  map_size const & size,
+                  map_size const & tiles,
+                  double scale_factor) const
     {
-        typename Renderer::image_type image(ren.render(map, scale_factor));
-        boost::filesystem::path reference = reference_dir / image_file_name(name, map.width(), map.height(), scale_factor, true, Renderer::ext);
+        boost::filesystem::path reference = reference_dir / image_file_name(name, size, tiles, scale_factor, true);
         bool reference_exists = boost::filesystem::exists(reference);
         result res;
 
@@ -207,14 +280,15 @@ public:
         res.name = name;
         res.renderer_name = Renderer::name;
         res.scale_factor = scale_factor;
-        res.size = map_size(map.width(), map.height());
+        res.size = size;
+        res.tiles = tiles;
         res.reference_image_path = reference;
         res.diff = reference_exists ? ren.compare(image, reference) : 0;
 
         if (res.diff)
         {
             boost::filesystem::create_directories(output_dir);
-            boost::filesystem::path path = output_dir / image_file_name(name, map.width(), map.height(), scale_factor, false, Renderer::ext);
+            boost::filesystem::path path = output_dir / image_file_name(name, size, tiles, scale_factor, false);
             res.actual_image_path = path;
             res.state = STATE_FAIL;
             ren.save(image, path);
@@ -231,16 +305,23 @@ public:
 
 private:
     std::string image_file_name(std::string const & test_name,
-                                double width,
-                                double height,
+                                map_size const & size,
+                                map_size const & tiles,
                                 double scale_factor,
-                                bool reference,
-                                std::string const& ext) const
+                                bool reference) const
     {
         std::stringstream s;
-        s << test_name << '-' << width << '-' << height << '-'
-          << std::fixed << std::setprecision(1) << scale_factor
-          << '-' << Renderer::name << (reference ? "-reference" : "") << ext;
+        s << test_name << '-' << size.width << '-' << size.height << '-';
+        if (tiles.width > 1 || tiles.height > 1)
+        {
+            s << tiles.width << 'x' << tiles.height << '-';
+        }
+        s << std::fixed << std::setprecision(1) << scale_factor << '-' << Renderer::name;
+        if (reference)
+        {
+            s << "-reference";
+        }
+        s << Renderer::ext;
         return s.str();
     }
 
diff --git a/test/visual/report.cpp b/test/visual/report.cpp
index aeca371..105ba06 100644
--- a/test/visual/report.cpp
+++ b/test/visual/report.cpp
@@ -32,8 +32,12 @@ namespace visual_tests
 
 void console_report::report(result const & r)
 {
-    s << '"' << r.name << '-' << r.size.width << '-' << r.size.height << '-' << std::fixed <<
-        std::setprecision(1) << r.scale_factor << "\" with " << r.renderer_name << "... ";
+    s << '"' << r.name << '-' << r.size.width << '-' << r.size.height;
+    if (r.tiles.width > 1 || r.tiles.height > 1)
+    {
+        s << '-' << r.tiles.width << 'x' << r.tiles.height;
+    }
+    s << '-' << std::fixed << std::setprecision(1) << r.scale_factor << "\" with " << r.renderer_name << "... ";
 
     switch (r.state)
     {
@@ -51,6 +55,11 @@ void console_report::report(result const & r)
             break;
     }
 
+    if (show_duration)
+    {
+        s << " (" << std::chrono::duration_cast<std::chrono::milliseconds>(r.duration).count() << " milliseconds)";
+    }
+
     s << std::endl;
 }
 
diff --git a/test/visual/report.hpp b/test/visual/report.hpp
index cdccad2..1a7a3c4 100644
--- a/test/visual/report.hpp
+++ b/test/visual/report.hpp
@@ -36,11 +36,11 @@ namespace visual_tests
 class console_report
 {
 public:
-    console_report() : s(std::clog)
+    console_report(bool _show_duration) : s(std::clog), show_duration(_show_duration)
     {
     }
 
-    console_report(std::ostream & s) : s(s)
+    console_report(std::ostream & _s) : s(_s)
     {
     }
 
@@ -49,12 +49,13 @@ public:
 
 protected:
     std::ostream & s;
+    bool show_duration;
 };
 
 class console_short_report : public console_report
 {
 public:
-    console_short_report() : console_report()
+    console_short_report() : console_report(false)
     {
     }
 
@@ -68,7 +69,7 @@ public:
 class html_report
 {
 public:
-    html_report(std::ostream & s) : s(s)
+    html_report(std::ostream & _s) : s(_s)
     {
     }
 
diff --git a/test/visual/run.cpp b/test/visual/run.cpp
index 89e7b0a..4444869 100644
--- a/test/visual/run.cpp
+++ b/test/visual/run.cpp
@@ -29,12 +29,18 @@
 // boost
 #include <boost/program_options.hpp>
 
-#include <libxml/parser.h> // for xmlInitParser(), xmlCleanupParser()
-#include <cairo.h>
-#include <unicode/uclean.h>
+#include "cleanup.hpp" // run_cleanup()
 
-#ifdef MAPNIK_USE_PROJ4
-#include <proj_api.h>
+#ifdef MAPNIK_LOG
+using log_levels_map = std::map<std::string, mapnik::logger::severity_type>;
+
+log_levels_map log_levels
+{
+    { "debug", mapnik::logger::severity_type::debug },
+    { "warn",  mapnik::logger::severity_type::warn },
+    { "error", mapnik::logger::severity_type::error },
+    { "none",  mapnik::logger::severity_type::none }
+};
 #endif
 
 int main(int argc, char** argv)
@@ -47,6 +53,8 @@ int main(int argc, char** argv)
         ("help,h", "produce usage message")
         ("verbose,v", "verbose output")
         ("overwrite,o", "overwrite reference image")
+        ("duration,d", "output rendering duration")
+        ("iterations,i", po::value<std::size_t>()->default_value(1), "number of iterations for benchmarking")
         ("jobs,j", po::value<std::size_t>()->default_value(1), "number of parallel threads")
         ("styles-dir", po::value<std::string>()->default_value("test/data-visual/styles"), "directory with styles")
         ("images-dir", po::value<std::string>()->default_value("test/data-visual/images"), "directory with reference images")
@@ -55,6 +63,11 @@ int main(int argc, char** argv)
         ("styles", po::value<std::vector<std::string>>(), "selected styles to test")
         ("fonts", po::value<std::string>()->default_value("fonts"), "font search path")
         ("plugins", po::value<std::string>()->default_value("plugins/input"), "input plugins search path")
+#ifdef MAPNIK_LOG
+        ("log", po::value<std::string>()->default_value(std::find_if(log_levels.begin(), log_levels.end(),
+             [](log_levels_map::value_type const & level) { return level.second == mapnik::logger::get_severity(); } )->first),
+             "log level (debug, warn, error, none)")
+#endif
         ;
 
     po::positional_options_description p;
@@ -69,6 +82,20 @@ int main(int argc, char** argv)
         return 1;
     }
 
+#ifdef MAPNIK_LOG
+    std::string log_level(vm["log"].as<std::string>());
+    log_levels_map::const_iterator level_iter = log_levels.find(log_level);
+    if (level_iter == log_levels.end())
+    {
+        std::cerr << "Error: Unknown log level: " << log_level << std::endl;
+        return 1;
+    }
+    else
+    {
+        mapnik::logger::set_severity(level_iter->second);
+    }
+#endif
+
     mapnik::freetype_engine::register_fonts(vm["fonts"].as<std::string>(), true);
     mapnik::datasource_cache::instance().register_datasources(vm["plugins"].as<std::string>());
 
@@ -83,8 +110,11 @@ int main(int argc, char** argv)
                output_dir,
                vm["images-dir"].as<std::string>(),
                vm.count("overwrite"),
+               vm["iterations"].as<std::size_t>(),
                vm["jobs"].as<std::size_t>());
-    report_type report = vm.count("verbose") ? report_type((console_report())) : report_type((console_short_report()));
+    bool show_duration = vm.count("duration");
+    bool verbose = vm.count("verbose") | show_duration;
+    report_type report(verbose ? report_type((console_report(show_duration))) : report_type((console_short_report())));
     result_list results;
 
     try
@@ -111,25 +141,7 @@ int main(int argc, char** argv)
         html_summary(results, output_dir);
     }
 
-    // only call this once, on exit
-    // to make sure valgrind output is clean
-    // http://xmlsoft.org/xmlmem.html
-    xmlCleanupParser();
-
-    // http://cairographics.org/manual/cairo-Error-handling.html#cairo-debug-reset-static-data
-    cairo_debug_reset_static_data();
-
-    // http://icu-project.org/apiref/icu4c/uclean_8h.html#a93f27d0ddc7c196a1da864763f2d8920
-    u_cleanup();
-
-#ifdef MAPNIK_USE_PROJ4
-    // http://trac.osgeo.org/proj/ticket/149
- #if PJ_VERSION >= 480
-    pj_clear_initcache();
- #endif
-    // https://trac.osgeo.org/proj/wiki/ProjAPI#EnvironmentFunctions
-    pj_deallocate_grids();
-#endif
+    testing::run_cleanup();
 
     return failed_count;
 }
diff --git a/test/visual/runner.cpp b/test/visual/runner.cpp
index 317c7cf..45dc366 100644
--- a/test/visual/runner.cpp
+++ b/test/visual/runner.cpp
@@ -34,32 +34,97 @@ namespace visual_tests
 class renderer_visitor
 {
 public:
-    renderer_visitor(std::string const & name, mapnik::Map const & map, double scale_factor)
-        : name_(name), map_(map), scale_factor_(scale_factor)
+    renderer_visitor(std::string const & name,
+                     mapnik::Map & map,
+                     map_size const & tiles,
+                     double scale_factor,
+                     result_list & results,
+                     report_type & report,
+                     std::size_t iterations)
+        : name_(name),
+          map_(map),
+          tiles_(tiles),
+          scale_factor_(scale_factor),
+          results_(results),
+          report_(report),
+          iterations_(iterations)
     {
     }
 
-    template <typename T>
-    result operator()(T const & renderer) const
+    template <typename T, typename std::enable_if<T::renderer_type::support_tiles>::type* = nullptr>
+    void operator()(T const & renderer)
+    {
+        test(renderer);
+    }
+
+    template <typename T, typename std::enable_if<!T::renderer_type::support_tiles>::type* = nullptr>
+    void operator()(T const & renderer)
     {
-        return renderer.test(name_, map_, scale_factor_);
+        if (tiles_.width == 1 && tiles_.height == 1)
+        {
+            test(renderer);
+        }
     }
 
 private:
+    template <typename T>
+    void test(T const & renderer)
+    {
+        map_size size { map_.width(), map_.height() };
+        std::chrono::high_resolution_clock::time_point start(std::chrono::high_resolution_clock::now());
+        for (std::size_t i = iterations_ ; i > 0; i--)
+        {
+            typename T::image_type image(render(renderer));
+            if (i == 1)
+            {
+                std::chrono::high_resolution_clock::time_point end(std::chrono::high_resolution_clock::now());
+                result r(renderer.report(image, name_, size, tiles_, scale_factor_));
+                r.duration = end - start;
+                mapnik::util::apply_visitor(report_visitor(r), report_);
+                results_.push_back(std::move(r));
+            }
+        }
+    }
+
+    template <typename T, typename std::enable_if<T::renderer_type::support_tiles>::type* = nullptr>
+    typename T::image_type render(T const & renderer)
+    {
+        if (tiles_.width == 1 && tiles_.height == 1)
+        {
+            return renderer.render(map_, scale_factor_);
+        }
+        else
+        {
+            return renderer.render(map_, scale_factor_, tiles_);
+        }
+    }
+
+    template <typename T, typename std::enable_if<!T::renderer_type::support_tiles>::type* = nullptr>
+    typename T::image_type render(T const & renderer)
+    {
+        return renderer.render(map_, scale_factor_);
+    }
+
     std::string const & name_;
-    mapnik::Map const & map_;
+    mapnik::Map & map_;
+    map_size const & tiles_;
     double scale_factor_;
+    result_list & results_;
+    report_type & report_;
+    std::size_t iterations_;
 };
 
 runner::runner(runner::path_type const & styles_dir,
                runner::path_type const & output_dir,
                runner::path_type const & reference_dir,
                bool overwrite,
+               std::size_t iterations,
                std::size_t jobs)
     : styles_dir_(styles_dir),
       output_dir_(output_dir),
       reference_dir_(reference_dir),
       jobs_(jobs),
+      iterations_(iterations),
       renderers_{ renderer<agg_renderer>(output_dir_, reference_dir_, overwrite)
 #if defined(HAVE_CAIRO)
                   ,renderer<cairo_renderer>(output_dir_, reference_dir_, overwrite)
@@ -67,7 +132,9 @@ runner::runner(runner::path_type const & styles_dir,
 #if defined(SVG_RENDERER)
                   ,renderer<svg_renderer>(output_dir_, reference_dir_, overwrite)
 #endif
+#if defined(GRID_RENDERER)
                   ,renderer<grid_renderer>(output_dir_, reference_dir_, overwrite)
+#endif
                 }
 {
 }
@@ -171,12 +238,12 @@ result_list runner::test_range(files_iterator begin, files_iterator end, std::re
 
 result_list runner::test_one(runner::path_type const& style_path, config cfg, report_type & report) const
 {
-    mapnik::Map m(cfg.sizes.front().width, cfg.sizes.front().height);
+    mapnik::Map map(cfg.sizes.front().width, cfg.sizes.front().height);
     result_list results;
 
     try
     {
-        mapnik::load_map(m, style_path.string(), true);
+        mapnik::load_map(map, style_path.string(), true);
     }
     catch (std::exception const& ex)
     {
@@ -189,7 +256,7 @@ result_list runner::test_one(runner::path_type const& style_path, config cfg, re
         throw;
     }
 
-    mapnik::parameters const & params = m.get_extra_parameters();
+    mapnik::parameters const & params = map.get_extra_parameters();
 
     boost::optional<mapnik::value_integer> status = params.get<mapnik::value_integer>("status", cfg.status);
 
@@ -206,32 +273,52 @@ result_list runner::test_one(runner::path_type const& style_path, config cfg, re
         parse_map_sizes(*sizes, cfg.sizes);
     }
 
-    std::string name(style_path.stem().string());
+    boost::optional<std::string> tiles = params.get<std::string>("tiles");
 
-    for (map_size const & size : cfg.sizes)
+    if (tiles)
     {
-        m.resize(size.width, size.height);
+        cfg.tiles.clear();
+        parse_map_sizes(*tiles, cfg.tiles);
+    }
 
-        boost::optional<std::string> bbox_string = params.get<std::string>("bbox");
+    boost::optional<std::string> bbox_string = params.get<std::string>("bbox");
+    mapnik::box2d<double> box;
 
-        if (bbox_string)
-        {
-            mapnik::box2d<double> bbox;
-            bbox.from_string(*bbox_string);
-            m.zoom_to_box(bbox);
-        }
-        else
-        {
-            m.zoom_all();
-        }
+    if (bbox_string)
+    {
+        box.from_string(*bbox_string);
+    }
 
-        for (double const & scale_factor : cfg.scales)
+    std::string name(style_path.stem().string());
+
+    for (auto const & size : cfg.sizes)
+    {
+        for (auto const & scale_factor : cfg.scales)
         {
-            for(auto const& ren : renderers_)
+            for (auto const & tiles_count : cfg.tiles)
             {
-                result r = mapnik::util::apply_visitor(renderer_visitor(name, m, scale_factor), ren);
-                results.emplace_back(r);
-                mapnik::util::apply_visitor(report_visitor(r), report);
+                if (!tiles_count.width || !tiles_count.height)
+                {
+                    throw std::runtime_error("Cannot render zero tiles.");
+                }
+                if (size.width % tiles_count.width || size.height % tiles_count.height)
+                {
+                    throw std::runtime_error("Tile size is not an integer.");
+                }
+
+                for (auto const & ren : renderers_)
+                {
+                    map.resize(size.width, size.height);
+                    if (box.valid())
+                    {
+                        map.zoom_to_box(box);
+                    }
+                    else
+                    {
+                        map.zoom_all();
+                    }
+                    mapnik::util::apply_visitor(renderer_visitor(name, map, tiles_count, scale_factor, results, report, iterations_), ren);
+                }
             }
         }
     }
diff --git a/test/visual/runner.hpp b/test/visual/runner.hpp
index 5a4fd39..a4c91ba 100644
--- a/test/visual/runner.hpp
+++ b/test/visual/runner.hpp
@@ -42,7 +42,10 @@ class runner
 #if defined(SVG_RENDERER)
                                                 ,renderer<svg_renderer>
 #endif
-                                                ,renderer<grid_renderer>>;
+#if defined(GRID_RENDERER)
+                                                ,renderer<grid_renderer>
+#endif
+                                                >;
     using path_type = boost::filesystem::path;
     using files_iterator = std::vector<path_type>::const_iterator;
 
@@ -51,6 +54,7 @@ public:
            path_type const & output_dir,
            path_type const & reference_dir,
            bool overwrite,
+           std::size_t iterations,
            std::size_t jobs);
 
     result_list test_all(report_type & report) const;
@@ -67,6 +71,7 @@ private:
     const path_type output_dir_;
     const path_type reference_dir_;
     const std::size_t jobs_;
+    const std::size_t iterations_;
     const renderer_type renderers_[boost::mpl::size<renderer_type::types>::value];
 };
 
diff --git a/utils/geometry_to_wkb/main.cpp b/utils/geometry_to_wkb/main.cpp
index 1b0056a..71ac5b3 100644
--- a/utils/geometry_to_wkb/main.cpp
+++ b/utils/geometry_to_wkb/main.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/utils/mapnik-config/build.py b/utils/mapnik-config/build.py
index 987dd25..60974e7 100644
--- a/utils/mapnik-config/build.py
+++ b/utils/mapnik-config/build.py
@@ -1,7 +1,7 @@
 #
 # This file is part of Mapnik (c++ mapping toolkit)
 #
-# Copyright (C) 2013 Artem Pavlenko
+# Copyright (C) 2015 Artem Pavlenko
 #
 # Mapnik is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -67,12 +67,12 @@ cxxflags = ' '.join(config_env['LIBMAPNIK_CXXFLAGS'])
 
 defines = ' '.join(config_env['LIBMAPNIK_DEFINES'])
 
-dep_includes = ''.join([' -I%s' % i for i in config_env['CPPPATH'] if not i.startswith('#')])
+dep_includes = ''.join([' -I${NODE_CONFIG_PREFIX:-""}%s' % i for i in config_env['CPPPATH'] if not i.startswith('#')])
 
 dep_includes += ' '
 
 if config_env['HAS_CAIRO']:
-    dep_includes += ''.join([' -I%s' % i for i in env['CAIRO_CPPPATHS'] if not i.startswith('#')])
+    dep_includes += ''.join([' -I${NODE_CONFIG_PREFIX:-""}%s' % i for i in env['CAIRO_CPPPATHS'] if not i.startswith('#')])
 
 ldflags = ''.join([' -L%s' % i for i in config_env['LIBPATH'] if not i.startswith('#')])
 ldflags += config_env['LIBMAPNIK_LINKFLAGS']
diff --git a/utils/ogrindex/build.py b/utils/ogrindex/build.py
index 4e115f9..68a4c04 100644
--- a/utils/ogrindex/build.py
+++ b/utils/ogrindex/build.py
@@ -1,7 +1,7 @@
 #
 # This file is part of Mapnik (c++ mapping toolkit)
 #
-# Copyright (C) 2013 Artem Pavlenko
+# Copyright (C) 2015 Artem Pavlenko
 #
 # Mapnik is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -17,7 +17,7 @@
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
-# 
+#
 
 import os
 import glob
@@ -32,7 +32,7 @@ source = Split(
     """
     )
 
-headers = ['#plugins/input/ogr'] + env['CPPPATH'] 
+headers = ['#plugins/input/ogr'] + env['CPPPATH']
 
 program_env['LIBS'] = [env['PLUGINS']['ogr']['lib']]
 
diff --git a/utils/ogrindex/ogrindex.cpp b/utils/ogrindex/ogrindex.cpp
index 7e34a65..3e7fd50 100644
--- a/utils/ogrindex/ogrindex.cpp
+++ b/utils/ogrindex/ogrindex.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/utils/pgsql2sqlite/build.py b/utils/pgsql2sqlite/build.py
index a150e02..45d9003 100644
--- a/utils/pgsql2sqlite/build.py
+++ b/utils/pgsql2sqlite/build.py
@@ -1,7 +1,7 @@
 #
 # This file is part of Mapnik (c++ mapping toolkit)
 #
-# Copyright (C) 2013 Artem Pavlenko
+# Copyright (C) 2015 Artem Pavlenko
 #
 # Mapnik is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -17,7 +17,7 @@
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
-# 
+#
 
 
 import os
diff --git a/utils/pgsql2sqlite/main.cpp b/utils/pgsql2sqlite/main.cpp
index 63d9b50..39ced62 100644
--- a/utils/pgsql2sqlite/main.cpp
+++ b/utils/pgsql2sqlite/main.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/utils/pgsql2sqlite/pgsql2sqlite.hpp b/utils/pgsql2sqlite/pgsql2sqlite.hpp
index 78db58f..5c5a640 100644
--- a/utils/pgsql2sqlite/pgsql2sqlite.hpp
+++ b/utils/pgsql2sqlite/pgsql2sqlite.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/utils/pgsql2sqlite/sqlite.cpp b/utils/pgsql2sqlite/sqlite.cpp
index 61ef5b3..95c67b8 100644
--- a/utils/pgsql2sqlite/sqlite.cpp
+++ b/utils/pgsql2sqlite/sqlite.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/utils/pgsql2sqlite/sqlite.hpp b/utils/pgsql2sqlite/sqlite.hpp
index fcafe21..07d2128 100644
--- a/utils/pgsql2sqlite/sqlite.hpp
+++ b/utils/pgsql2sqlite/sqlite.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/utils/shapeindex/build.py b/utils/shapeindex/build.py
index b769cda..9f7de74 100644
--- a/utils/shapeindex/build.py
+++ b/utils/shapeindex/build.py
@@ -1,7 +1,7 @@
 #
 # This file is part of Mapnik (c++ mapping toolkit)
 #
-# Copyright (C) 2013 Artem Pavlenko
+# Copyright (C) 2015 Artem Pavlenko
 #
 # Mapnik is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -17,7 +17,7 @@
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
-# 
+#
 
 import os
 import glob
@@ -33,7 +33,7 @@ source = Split(
     """
     )
 
-headers = ['#plugins/input/shape'] + env['CPPPATH'] 
+headers = ['#plugins/input/shape'] + env['CPPPATH']
 
 boost_program_options = 'boost_program_options%s' % env['BOOST_APPEND']
 boost_system = 'boost_system%s' % env['BOOST_APPEND']
@@ -52,4 +52,4 @@ if 'uninstall' not in COMMAND_LINE_TARGETS:
     env.Install(os.path.join(env['INSTALL_PREFIX'],'bin'), shapeindex)
     env.Alias('install', os.path.join(env['INSTALL_PREFIX'],'bin'))
 
-env['create_uninstall_target'](env, os.path.join(env['INSTALL_PREFIX'],'bin','shapeindex'))
\ No newline at end of file
+env['create_uninstall_target'](env, os.path.join(env['INSTALL_PREFIX'],'bin','shapeindex'))
diff --git a/utils/shapeindex/quadtree.hpp b/utils/shapeindex/quadtree.hpp
index 0ad2fd6..440ce50 100644
--- a/utils/shapeindex/quadtree.hpp
+++ b/utils/shapeindex/quadtree.hpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/utils/shapeindex/shapeindex.cpp b/utils/shapeindex/shapeindex.cpp
index bcf4a57..435daba 100644
--- a/utils/shapeindex/shapeindex.cpp
+++ b/utils/shapeindex/shapeindex.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
diff --git a/utils/svg2png/build.py b/utils/svg2png/build.py
index 71725ff..2f3adcb 100644
--- a/utils/svg2png/build.py
+++ b/utils/svg2png/build.py
@@ -1,7 +1,7 @@
 #
 # This file is part of Mapnik (c++ mapping toolkit)
 #
-# Copyright (C) 2013 Artem Pavlenko
+# Copyright (C) 2015 Artem Pavlenko
 #
 # Mapnik is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -17,7 +17,7 @@
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
-# 
+#
 
 import os
 import glob
diff --git a/utils/svg2png/svg2png.cpp b/utils/svg2png/svg2png.cpp
index a5e8418..7e3aca5 100644
--- a/utils/svg2png/svg2png.cpp
+++ b/utils/svg2png/svg2png.cpp
@@ -2,7 +2,7 @@
  *
  * This file is part of Mapnik (c++ mapping toolkit)
  *
- * Copyright (C) 2014 Artem Pavlenko
+ * Copyright (C) 2015 Artem Pavlenko
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/mapnik.git



More information about the Pkg-grass-devel mailing list