re-use feature_collection_grammar
This commit is contained in:
parent
3f5344ca82
commit
61c05bfb45
1 changed files with 6 additions and 8 deletions
|
@ -145,24 +145,22 @@ geojson_datasource::geojson_datasource(parameters const& params)
|
|||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
using base_iterator_type = std::istreambuf_iterator<char>;
|
||||
const mapnik::transcoder tr("utf8");
|
||||
const mapnik::json::feature_collection_grammar<boost::spirit::multi_pass<base_iterator_type>,mapnik::feature_impl> fc_grammar(tr);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void geojson_datasource::parse_geojson(T & stream)
|
||||
{
|
||||
using base_iterator_type = std::istreambuf_iterator<char>;
|
||||
boost::spirit::multi_pass<base_iterator_type> begin =
|
||||
boost::spirit::make_default_multi_pass(base_iterator_type(stream));
|
||||
|
||||
boost::spirit::multi_pass<base_iterator_type> end =
|
||||
boost::spirit::make_default_multi_pass(base_iterator_type());
|
||||
|
||||
// FIXME - for perf we need to declare grammar as 'static const'
|
||||
// but we cannot because then all features will interact only with the first context_ptr
|
||||
// created in the process which leads to very odd bugs
|
||||
|
||||
mapnik::transcoder tr("utf8");
|
||||
mapnik::json::feature_collection_grammar<boost::spirit::multi_pass<base_iterator_type>,mapnik::feature_impl> fc_grammar(tr);
|
||||
boost::spirit::standard_wide::space_type space;
|
||||
|
||||
mapnik::context_ptr ctx = std::make_shared<mapnik::context_type>();
|
||||
bool result = boost::spirit::qi::phrase_parse(begin, end, (fc_grammar)(boost::phoenix::ref(ctx)), space, features_);
|
||||
if (!result)
|
||||
|
|
Loading…
Reference in a new issue