Merge branch 'master' into geometry-refactor
This commit is contained in:
commit
38bff90a99
14 changed files with 92 additions and 112 deletions
|
@ -144,28 +144,6 @@ extract_bounding_box_grammar<Iterator, Boxes, ErrorHandler>::extract_bounding_bo
|
|||
rings_array = lit('[') >> rings(_r1) % lit(',') > lit(']')
|
||||
;
|
||||
|
||||
// generic json types
|
||||
json.value = json.object | json.array | json.string_ | json.number
|
||||
;
|
||||
|
||||
json.key_value = json.string_ >> lit(':') >> json.value
|
||||
;
|
||||
|
||||
json.object = lit('{') >> json.key_value % lit(',') >> lit('}')
|
||||
;
|
||||
|
||||
json.array = lit('[')
|
||||
>> json.value >> *(lit(',') >> json.value)
|
||||
>> lit(']')
|
||||
;
|
||||
|
||||
json.number = json.strict_double
|
||||
| json.int__
|
||||
| lit("true")
|
||||
| lit("false")
|
||||
| lit("null")
|
||||
;
|
||||
|
||||
coords.name("Coordinates");
|
||||
pos.name("Position");
|
||||
ring.name("Ring");
|
||||
|
|
|
@ -35,7 +35,6 @@ feature_grammar<Iterator,FeatureType,ErrorHandler>::feature_grammar(mapnik::tran
|
|||
qi::lit_type lit;
|
||||
qi::long_long_type long_long;
|
||||
qi::double_type double_;
|
||||
qi::_val_type _val;
|
||||
qi::_1_type _1;
|
||||
qi::_2_type _2;
|
||||
qi::_3_type _3;
|
||||
|
@ -49,30 +48,6 @@ feature_grammar<Iterator,FeatureType,ErrorHandler>::feature_grammar(mapnik::tran
|
|||
using phoenix::new_;
|
||||
using phoenix::construct;
|
||||
|
||||
// generic json types
|
||||
json_.value = json_.object | json_.array | json_.string_ | json_.number
|
||||
;
|
||||
|
||||
json_.key_value = json_.string_ > lit(':') > json_.value
|
||||
;
|
||||
|
||||
json_.object = lit('{')
|
||||
> -(json_.key_value % lit(','))
|
||||
> lit('}')
|
||||
;
|
||||
|
||||
json_.array = lit('[')
|
||||
> -(json_.value % lit(','))
|
||||
> lit(']')
|
||||
;
|
||||
|
||||
json_.number = json_.strict_double[_val = json_.double_converter(_1)]
|
||||
| json_.int__[_val = json_.integer_converter(_1)]
|
||||
| lit("true") [_val = true]
|
||||
| lit ("false") [_val = false]
|
||||
| lit("null")[_val = construct<value_null>()]
|
||||
;
|
||||
|
||||
// geojson types
|
||||
feature_type = lit("\"type\"") > lit(':') > lit("\"Feature\"")
|
||||
;
|
||||
|
|
|
@ -129,7 +129,7 @@ struct push_esc
|
|||
}
|
||||
};
|
||||
|
||||
template< typename Iterator >
|
||||
template< typename Iterator>
|
||||
unicode_string<Iterator>::unicode_string()
|
||||
: unicode_string::base_type(double_quoted)
|
||||
{
|
||||
|
@ -175,8 +175,9 @@ unicode_string<Iterator>::unicode_string()
|
|||
}
|
||||
|
||||
template <typename Iterator>
|
||||
struct generic_json
|
||||
struct generic_json : qi::grammar<Iterator, json_value(), space_type>
|
||||
{
|
||||
generic_json();
|
||||
qi::rule<Iterator, json_value(), space_type> value;
|
||||
qi::int_parser<mapnik::value_integer, 10, 1, -1> int__;
|
||||
unicode_string<Iterator> string_;
|
||||
|
|
|
@ -52,31 +52,6 @@ geometry_grammar<Iterator, ErrorHandler>::geometry_grammar()
|
|||
using phoenix::push_back;
|
||||
|
||||
start = geometry.alias() | lit("null");
|
||||
|
||||
// generic json types
|
||||
json_.value = json_.object | json_.array | json_.string_ | json_.number
|
||||
;
|
||||
|
||||
json_.key_value = json_.string_ > lit(':') > json_.value
|
||||
;
|
||||
|
||||
json_.object = lit('{')
|
||||
> -(json_.key_value % lit(','))
|
||||
> lit('}')
|
||||
;
|
||||
|
||||
json_.array = lit('[')
|
||||
> -(json_.value % lit(','))
|
||||
> lit(']')
|
||||
;
|
||||
|
||||
json_.number = json_.strict_double
|
||||
| json_.int__
|
||||
| lit("true")
|
||||
| lit ("false")
|
||||
| lit("null")
|
||||
;
|
||||
|
||||
geometry = lit('{')[_a = 0]
|
||||
> (((lit("\"type\"") > lit(':') > geometry_type_dispatch[_a = _1])
|
||||
|
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
// mapnik
|
||||
#include <mapnik/util/variant.hpp>
|
||||
#include <mapnik/json/positions.hpp>
|
||||
#include <mapnik/json/generic_json.hpp>
|
||||
#include <mapnik/json/error_handler.hpp>
|
||||
#include <mapnik/geometry.hpp>
|
||||
#pragma GCC diagnostic push
|
||||
|
@ -38,6 +37,8 @@
|
|||
namespace mapnik { namespace json {
|
||||
|
||||
namespace qi = boost::spirit::qi;
|
||||
namespace standard = boost::spirit::standard;
|
||||
using space_type = standard::space_type;
|
||||
|
||||
template <typename Iterator, typename ErrorHandler = error_handler<Iterator> >
|
||||
struct positions_grammar :
|
||||
|
|
|
@ -94,7 +94,6 @@ topojson_grammar<Iterator, ErrorHandler>::topojson_grammar()
|
|||
using qi::fail;
|
||||
using qi::on_error;
|
||||
using phoenix::push_back;
|
||||
using phoenix::construct;
|
||||
|
||||
geometry_type_dispatch.add
|
||||
("\"Point\"",1)
|
||||
|
@ -109,29 +108,6 @@ topojson_grammar<Iterator, ErrorHandler>::topojson_grammar()
|
|||
// error handler
|
||||
boost::phoenix::function<ErrorHandler> const error_handler;
|
||||
boost::phoenix::function<create_geometry_impl> const create_geometry;
|
||||
// generic JSON types
|
||||
json.value = json.object | json.array | json.string_ | json.number
|
||||
;
|
||||
|
||||
json.key_value = json.string_ > lit(':') > json.value
|
||||
;
|
||||
|
||||
json.object = lit('{')
|
||||
> -(json.key_value % lit(','))
|
||||
> lit('}')
|
||||
;
|
||||
|
||||
json.array = lit('[')
|
||||
> -(json.value % lit(','))
|
||||
> lit(']')
|
||||
;
|
||||
|
||||
json.number = json.strict_double[_val = json.double_converter(_1)]
|
||||
| json.int__[_val = json.integer_converter(_1)]
|
||||
| lit("true")[_val = true]
|
||||
| lit("false")[_val = false]
|
||||
| lit("null")[_val = construct<value_null>()]
|
||||
;
|
||||
|
||||
// topo json
|
||||
topology = lit('{') >> lit("\"type\"") >> lit(':') >> lit("\"Topology\"")
|
||||
|
|
|
@ -93,7 +93,7 @@ public:
|
|||
|
||||
//! \brief Set the stop value
|
||||
//! \param[in] value The stop value
|
||||
inline void set_value(float value) { value_ = value; }
|
||||
inline void set_value(float v) { value_ = v; }
|
||||
|
||||
//! \brief Get the stop value
|
||||
//! \return The stop value
|
||||
|
@ -205,7 +205,7 @@ public:
|
|||
//!
|
||||
//! \param[in] value Input value
|
||||
//! \return color associated with the value
|
||||
unsigned get_color(float value) const;
|
||||
unsigned get_color(float v) const;
|
||||
|
||||
|
||||
//! \brief Set the epsilon value for exact mode
|
||||
|
|
|
@ -149,6 +149,7 @@ namespace std
|
|||
{
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wpragmas"
|
||||
#pragma GCC diagnostic ignored "-Wmismatched-tags"
|
||||
|
||||
template <>
|
||||
|
|
|
@ -160,7 +160,7 @@ topojson_datasource::topojson_datasource(parameters const& params)
|
|||
}
|
||||
if (!inline_string_.empty())
|
||||
{
|
||||
parse_topojson(inline_string_);
|
||||
parse_topojson(inline_string_.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -172,20 +172,22 @@ topojson_datasource::topojson_datasource(parameters const& params)
|
|||
std::string file_buffer;
|
||||
file_buffer.resize(file.size());
|
||||
std::fread(&file_buffer[0], file.size(), 1, file.get());
|
||||
parse_topojson(file_buffer);
|
||||
parse_topojson(file_buffer.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
using base_iterator_type = std::string::const_iterator;
|
||||
const mapnik::topojson::topojson_grammar<base_iterator_type> g;
|
||||
using iterator_type = const char*;
|
||||
const mapnik::topojson::topojson_grammar<iterator_type> g;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void topojson_datasource::parse_topojson(T const& buffer)
|
||||
{
|
||||
boost::spirit::standard::space_type space;
|
||||
bool result = boost::spirit::qi::phrase_parse(buffer.begin(), buffer.end(), g, space, topo_);
|
||||
auto itr = buffer;
|
||||
auto end = buffer + std::strlen(buffer);
|
||||
bool result = boost::spirit::qi::phrase_parse(itr, end, g, space, topo_);
|
||||
if (!result)
|
||||
{
|
||||
throw mapnik::datasource_exception("topojson_datasource: Failed parse TopoJSON file '" + filename_ + "'");
|
||||
|
|
63
src/json/generic_json.cpp
Normal file
63
src/json/generic_json.cpp
Normal file
|
@ -0,0 +1,63 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include <mapnik/json/generic_json.hpp>
|
||||
|
||||
namespace mapnik { namespace json {
|
||||
|
||||
template <typename Iterator>
|
||||
generic_json<Iterator>::generic_json()
|
||||
: generic_json::base_type(value)
|
||||
{
|
||||
qi::lit_type lit;
|
||||
qi::_val_type _val;
|
||||
qi::_1_type _1;
|
||||
using phoenix::construct;
|
||||
// generic json types
|
||||
value = object | array | string_ | number
|
||||
;
|
||||
|
||||
key_value = string_ > lit(':') > value
|
||||
;
|
||||
|
||||
object = lit('{')
|
||||
> -(key_value % lit(','))
|
||||
> lit('}')
|
||||
;
|
||||
|
||||
array = lit('[')
|
||||
> -(value % lit(','))
|
||||
> lit(']')
|
||||
;
|
||||
|
||||
number = strict_double[_val = double_converter(_1)]
|
||||
| int__[_val = integer_converter(_1)]
|
||||
| lit("true") [_val = true]
|
||||
| lit ("false") [_val = false]
|
||||
| lit("null")[_val = construct<value_null>()]
|
||||
;
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
using iterator_type = char const*;
|
||||
template struct mapnik::json::generic_json<iterator_type>;
|
|
@ -24,5 +24,5 @@
|
|||
#include <mapnik/json/topojson_grammar_impl.hpp>
|
||||
#include <string>
|
||||
|
||||
using iterator_type = std::string::const_iterator;
|
||||
using iterator_type = char const*;
|
||||
template struct mapnik::topojson::topojson_grammar<iterator_type> ;
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit db7989be3a8b636c60c79356b9ba9ca579faa01d
|
||||
Subproject commit 61f0d314b989a345df9515d5bc1472c8d5362990
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
namespace {
|
||||
|
||||
using iterator_type = std::string::const_iterator;
|
||||
using iterator_type = char const*;
|
||||
const mapnik::topojson::topojson_grammar<iterator_type> grammar;
|
||||
|
||||
bool parse_topology(std::string const& filename, mapnik::topojson::topology & topo)
|
||||
|
@ -42,8 +42,8 @@ bool parse_topology(std::string const& filename, mapnik::topojson::topology & to
|
|||
std::fread(&buffer[0], buffer.size(), 1, file.get());
|
||||
if (!file) return false;
|
||||
boost::spirit::standard::space_type space;
|
||||
iterator_type itr = buffer.begin();
|
||||
iterator_type end = buffer.end();
|
||||
iterator_type itr = buffer.c_str();
|
||||
iterator_type end = itr + buffer.length();
|
||||
bool result = boost::spirit::qi::phrase_parse(itr, end, grammar, space, topo);
|
||||
return (result && (itr == end));
|
||||
}
|
||||
|
|
|
@ -80,7 +80,15 @@ def write_config(configuration,template,config_file):
|
|||
os.chmod(config_file,0755)
|
||||
except: pass
|
||||
|
||||
cxxflags = ' '.join(config_env['LIBMAPNIK_CXXFLAGS'])
|
||||
|
||||
cxxflags_raw = config_env['LIBMAPNIK_CXXFLAGS'];
|
||||
# strip clang specific flags to avoid breaking gcc
|
||||
# while it is not recommended to mix compilers, this nevertheless
|
||||
# makes it easier to compile apps with gcc and mapnik-config against mapnik built with clang
|
||||
to_remove = ['-Wno-unsequenced','-Wno-unknown-warning-option','-Wtautological-compare','-Wheader-hygiene']
|
||||
cxxflags_cleaned = [item for item in config_env['LIBMAPNIK_CXXFLAGS'] if item not in to_remove];
|
||||
|
||||
cxxflags = ' '.join(cxxflags_cleaned)
|
||||
|
||||
defines = ' '.join(config_env['LIBMAPNIK_DEFINES'])
|
||||
|
||||
|
|
Loading…
Reference in a new issue