diff --git a/plugins/input/topojson/topojson_datasource.cpp b/plugins/input/topojson/topojson_datasource.cpp index 2cfad1fb8..67bae443b 100644 --- a/plugins/input/topojson/topojson_datasource.cpp +++ b/plugins/input/topojson/topojson_datasource.cpp @@ -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 g; +using iterator_type = const char*; +const mapnik::topojson::topojson_grammar g; } template 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_ + "'"); diff --git a/src/json/generic_json.cpp b/src/json/generic_json.cpp index 92cd908b5..7fb2e9fd3 100644 --- a/src/json/generic_json.cpp +++ b/src/json/generic_json.cpp @@ -61,4 +61,3 @@ generic_json::generic_json() using iterator_type = char const*; template struct mapnik::json::generic_json; -template struct mapnik::json::generic_json; diff --git a/src/json/mapnik_topojson_grammar.cpp b/src/json/mapnik_topojson_grammar.cpp index e70f7c590..e4b9dca32 100644 --- a/src/json/mapnik_topojson_grammar.cpp +++ b/src/json/mapnik_topojson_grammar.cpp @@ -24,5 +24,5 @@ #include #include -using iterator_type = std::string::const_iterator; +using iterator_type = char const*; template struct mapnik::topojson::topojson_grammar ; diff --git a/test/unit/datasource/topojson.cpp b/test/unit/datasource/topojson.cpp index 41d9b1908..7bf155e33 100644 --- a/test/unit/datasource/topojson.cpp +++ b/test/unit/datasource/topojson.cpp @@ -31,7 +31,7 @@ namespace { -using iterator_type = std::string::const_iterator; +using iterator_type = char const*; const mapnik::topojson::topojson_grammar 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)); }