From 97f520c7cf920da90ed5b8e087fc58ce688d7144 Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Tue, 14 Nov 2017 10:08:35 +0100 Subject: [PATCH] cleanup --- include/mapnik/geometry/fusion_adapted.hpp | 10 -- .../json/extract_bounding_boxes_x3_config.hpp | 2 - include/mapnik/json/geometry_grammar_x3.hpp | 51 ------ .../mapnik/json/geometry_grammar_x3_def.hpp | 161 ------------------ src/build.py | 2 +- src/json/build.py | 23 ++- 6 files changed, 23 insertions(+), 226 deletions(-) delete mode 100644 include/mapnik/json/geometry_grammar_x3.hpp delete mode 100644 include/mapnik/json/geometry_grammar_x3_def.hpp diff --git a/include/mapnik/geometry/fusion_adapted.hpp b/include/mapnik/geometry/fusion_adapted.hpp index b093747fd..bca211e3b 100644 --- a/include/mapnik/geometry/fusion_adapted.hpp +++ b/include/mapnik/geometry/fusion_adapted.hpp @@ -39,14 +39,4 @@ BOOST_FUSION_ADAPT_STRUCT( (std::int64_t, y) ) -//BOOST_FUSION_ADAPT_STRUCT( -// mapnik::geometry::polygon, -// (mapnik::geometry::linear_ring const&, exterior_ring) -// (mapnik::geometry::polygon::rings_container const& , interior_rings)) - -//BOOST_FUSION_ADAPT_STRUCT( -// mapnik::geometry::polygon, -// (mapnik::geometry::linear_ring const&, exterior_ring) -// (mapnik::geometry::polygon::rings_container const& , interior_rings)) - #endif // MAPNIK_GEOMETRY_FUSION_ADAPTED_HPP diff --git a/include/mapnik/json/extract_bounding_boxes_x3_config.hpp b/include/mapnik/json/extract_bounding_boxes_x3_config.hpp index 8de409928..84ad66e93 100644 --- a/include/mapnik/json/extract_bounding_boxes_x3_config.hpp +++ b/include/mapnik/json/extract_bounding_boxes_x3_config.hpp @@ -59,7 +59,6 @@ struct extract_positions auto offset = std::distance(start_, r.begin()); auto size = std::distance(r.begin(), r.end()); boxes_.emplace_back(std::make_pair(box_type(b.minx(), b.miny(), b.maxx(), b.maxy()), std::make_pair(offset, size))); - //boxes_.emplace_back(std::make_tuple(bbox,offset, size)); } } Iterator start_; @@ -82,7 +81,6 @@ struct feature_callback_tag; namespace x3 = boost::spirit::x3; using space_type = x3::standard::space_type; -//using iterator_type = char const*; using phrase_parse_context_type = x3::phrase_parse_context::type; diff --git a/include/mapnik/json/geometry_grammar_x3.hpp b/include/mapnik/json/geometry_grammar_x3.hpp deleted file mode 100644 index b8c023caa..000000000 --- a/include/mapnik/json/geometry_grammar_x3.hpp +++ /dev/null @@ -1,51 +0,0 @@ -/***************************************************************************** - * - * This file is part of Mapnik (c++ mapping toolkit) - * - * Copyright (C) 2017 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_GEOMETRY_GRAMMAR_X3_HPP -#define MAPNIK_GEOMETRY_GRAMMAR_X3_HPP - -// mapnik -#include // for geometry_type - -#pragma GCC diagnostic push -#include -#include -#pragma GCC diagnostic pop - -// mapnik -#include - -namespace mapnik { namespace json { namespace grammar { - -namespace x3 = boost::spirit::x3; - -using geometry_grammar_type = x3::rule>; - -BOOST_SPIRIT_DECLARE(geometry_grammar_type); - -} - -grammar::geometry_grammar_type const& geometry_grammar(); - -}} - -#endif // MAPNIK_GEOMETRY_GRAMMAR_X3_HPP diff --git a/include/mapnik/json/geometry_grammar_x3_def.hpp b/include/mapnik/json/geometry_grammar_x3_def.hpp deleted file mode 100644 index 64ee27a1e..000000000 --- a/include/mapnik/json/geometry_grammar_x3_def.hpp +++ /dev/null @@ -1,161 +0,0 @@ -/***************************************************************************** - * - * This file is part of Mapnik (c++ mapping toolkit) - * - * Copyright (C) 2017 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_JSON_GEOMETRY_GRAMMAR_X3_DEF_HPP -#define MAPNIK_JSON_GEOMETRY_GRAMMAR_X3_DEF_HPP - -// mapnik -#include -#include -#include -#include -#include -#include -#include -#include -// boost -#include - -namespace mapnik { namespace json { namespace grammar { - -namespace x3 = boost::spirit::x3; -using x3::lit; -using x3::_pass; -using x3::omit; - -auto create_geometry = [](auto const& ctx) -{ - auto const& attr = _attr(ctx); - mapnik::json::create_geometry_impl()(_val(ctx), std::get<0>(attr), std::get<1>(attr)); -}; - -auto assign_element = [] (auto const& ctx) -{ - _val(ctx) = std::move(_attr(ctx)); -}; - -namespace { -template -struct assign_geometry_element_visitor : util::noncopyable -{ - assign_geometry_element_visitor(T & t) - : t_(t) {} - - void operator() (int const& type) - { - std::get<0>(t_) = type; - } - void operator () (::mapnik::json::positions const& p) - { - std::get<1>(t_) = p; - } - - T & t_; -}; - -} - -auto assign_geometry_element = [] (auto const& ctx) -{ - assign_geometry_element_visitor v(_val(ctx)); - mapnik::util::apply_visitor(v, _attr(ctx)); -}; - -auto assign_collection = [] (auto const& ctx) -{ - auto & val = _val(ctx); - std::get<0>(val) = 7; //GeometryCollection - std::get<1>(val) = std::move(_attr(ctx)); -}; - -auto push_geometry = [] (auto const& ctx) -{ - _val(ctx).emplace_back(std::move(_attr(ctx))); -}; - -// start rule -geometry_grammar_type const geometry("Geometry"); -// rules -x3::rule> const geometry_element("Geometry Element"); -x3::rule> const geometry_tuple("Geometry Tuple"); -x3::rule> const geometry_collection("Geometry Collection"); -// import positions rule -namespace { auto const& pos = positions_grammar(); } -// import generic JSON key:value rule -namespace { auto const& json_key_value = generic_json_key_value(); } - -struct geometry_type_ : x3::symbols -{ - geometry_type_() - { - add - ("\"Point\"",1) - ("\"LineString\"",2) - ("\"Polygon\"",3) - ("\"MultiPoint\"",4) - ("\"MultiLineString\"",5) - ("\"MultiPolygon\"",6) - ("\"GeometryCollection\"",7) - ; - } -} geometry_type; - -auto const geometry_def = (lit('{') > (geometry_tuple)[create_geometry] > lit('}')) | lit("null") - ; - -auto const geometry_tuple_def = geometry_element[assign_geometry_element] % lit(',') - ; - -auto const geometry_element_def = - (lit("\"type\"") > lit(":") > geometry_type[assign_element]) - | - (lit("\"coordinates\"") > lit(':') > pos[assign_element]) - | - (lit("\"geometries\"") > lit(':') > lit('[') > geometry_collection[assign_collection] > lit(']')) - | - omit[json_key_value] - ; - -auto const geometry_collection_def = geometry[push_geometry] % lit(',') - ; - -BOOST_SPIRIT_DEFINE( - geometry, - geometry_element, - geometry_tuple, - geometry_collection - ); - -}}} - -namespace mapnik { namespace json { -grammar::geometry_grammar_type const& geometry_grammar() -{ - return grammar::geometry; -} -}} - - -#endif // MAPNIK_JSON_GEOMETRY_GRAMMAR_X3_DEF_HPP diff --git a/src/build.py b/src/build.py index f80af2637..5a8fb227e 100644 --- a/src/build.py +++ b/src/build.py @@ -153,6 +153,7 @@ else: # unix, non-macos source = Split( """ expression_grammar_x3.cpp + css_color_grammar_x3.cpp fs.cpp request.cpp well_known_srs.cpp @@ -229,7 +230,6 @@ source = Split( svg/svg_transform_parser.cpp svg/svg_path_grammar_x3.cpp warp.cpp - css_color_grammar_x3.cpp vertex_cache.cpp vertex_adapters.cpp text/font_library.cpp diff --git a/src/json/build.py b/src/json/build.py index 390465df5..578277d9d 100644 --- a/src/json/build.py +++ b/src/json/build.py @@ -27,7 +27,28 @@ lib_env = env.Clone() lib_env.Append(CXXFLAGS='-fPIC') name = "mapnik-json" -lib = lib_env.StaticLibrary(name, glob('./' + '*.cpp'), LIBS=[]) + +source = Split( + """ + unicode_string_grammar_x3.cpp + positions_grammar_x3.cpp + generic_json_grammar_x3.cpp + feature_grammar_x3.cpp + geojson_grammar_x3.cpp + topojson_grammar_x3.cpp + mapnik_json_generator_grammar.cpp + parse_feature.cpp + feature_from_geojson.cpp + geometry_from_geojson.cpp + mapnik_feature_to_geojson.cpp + mapnik_geometry_to_geojson.cpp + extract_bounding_boxes_x3.cpp + """ + ) + +lib = lib_env.StaticLibrary(name, source, LIBS=[]) + + target = os.path.join(env['MAPNIK_LIB_BASE_DEST'], env.subst('${LIBPREFIX}%s${LIBSUFFIX}' % name)) result = env.InstallAs(target=target, source=lib) env.Alias(target='install', source=result)