mirror of
https://github.com/mapnik/mapnik.git
synced 2025-12-08 20:13:09 +00:00
Merge branch 'master' of https://github.com/mapnik/mapnik into 3x-msvs
This commit is contained in:
commit
d577ef8719
@ -189,7 +189,6 @@ private:
|
||||
unsigned height_;
|
||||
bool owns_data_;
|
||||
T *pData_;
|
||||
ImageData& operator=(ImageData const&);
|
||||
};
|
||||
|
||||
using image_data_32 = ImageData<unsigned>;
|
||||
|
||||
@ -43,10 +43,18 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
double next_x, next_y;
|
||||
double x0, y0;
|
||||
double x1, y1;
|
||||
unsigned command0, command1 = agg::path_cmd_stop;
|
||||
unsigned command0 = this->locator_.vertex(&x0, &y0);
|
||||
|
||||
if (agg::is_stop(command0))
|
||||
{
|
||||
this->done_ = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
double next_x, next_y;
|
||||
double x1 = x0, y1 = y0;
|
||||
unsigned command1 = command0;
|
||||
|
||||
while (!agg::is_stop(command0 = this->locator_.vertex(&next_x, &next_y)))
|
||||
{
|
||||
@ -57,13 +65,6 @@ public:
|
||||
y0 = next_y;
|
||||
}
|
||||
|
||||
// If path stopped on the very firts vertex.
|
||||
if (agg::is_stop(command1))
|
||||
{
|
||||
this->done_ = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
x = x0;
|
||||
y = y0;
|
||||
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
// boost
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/spirit/include/support_multi_pass.hpp>
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/unicode.hpp>
|
||||
@ -49,7 +48,6 @@
|
||||
#include <mapnik/json/geometry_grammar_impl.hpp>
|
||||
|
||||
#include <boost/spirit/include/qi.hpp>
|
||||
#include <boost/spirit/include/support_multi_pass.hpp>
|
||||
|
||||
using mapnik::datasource;
|
||||
using mapnik::parameters;
|
||||
@ -127,43 +125,41 @@ geojson_datasource::geojson_datasource(parameters const& params)
|
||||
}
|
||||
if (!inline_string_.empty())
|
||||
{
|
||||
std::istringstream in(inline_string_);
|
||||
parse_geojson(in);
|
||||
parse_geojson(inline_string_);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined (_WINDOWS)
|
||||
std::ifstream in(mapnik::utf8_to_utf16(filename_),std::ios_base::in | std::ios_base::binary);
|
||||
#ifdef _WINDOWS
|
||||
std::unique_ptr<std::FILE, int (*)(std::FILE *)> file(_wfopen(mapnik::utf8_to_utf16(filename_).c_str(), L"rb"), fclose);
|
||||
#else
|
||||
std::ifstream in(filename_.c_str(),std::ios_base::in | std::ios_base::binary);
|
||||
std::unique_ptr<std::FILE, int (*)(std::FILE *)> file(std::fopen(filename_.c_str(),"rb"), std::fclose);
|
||||
#endif
|
||||
if (!in.is_open())
|
||||
if (file == nullptr)
|
||||
{
|
||||
throw mapnik::datasource_exception("GeoJSON Plugin: could not open: '" + filename_ + "'");
|
||||
}
|
||||
parse_geojson(in);
|
||||
in.close();
|
||||
std::fseek(file.get(), 0, SEEK_END);
|
||||
std::size_t file_size = std::ftell(file.get());
|
||||
std::fseek(file.get(), 0, SEEK_SET);
|
||||
std::string file_buffer;
|
||||
file_buffer.resize(file_size);
|
||||
std::fread(&file_buffer[0], file_size, 1, file.get());
|
||||
parse_geojson(file_buffer);
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
using base_iterator_type = std::istreambuf_iterator<char>;
|
||||
using base_iterator_type = std::string::const_iterator;
|
||||
const mapnik::transcoder tr("utf8");
|
||||
const mapnik::json::feature_collection_grammar<boost::spirit::multi_pass<base_iterator_type>,mapnik::feature_impl> fc_grammar(tr);
|
||||
const mapnik::json::feature_collection_grammar<base_iterator_type,mapnik::feature_impl> fc_grammar(tr);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void geojson_datasource::parse_geojson(T & stream)
|
||||
void geojson_datasource::parse_geojson(T const& buffer)
|
||||
{
|
||||
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());
|
||||
|
||||
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_);
|
||||
bool result = boost::spirit::qi::phrase_parse(buffer.begin(), buffer.end(), (fc_grammar)(boost::phoenix::ref(ctx)), space, features_);
|
||||
if (!result)
|
||||
{
|
||||
if (!inline_string_.empty()) throw mapnik::datasource_exception("geojson_datasource: Failed parse GeoJSON file from in-memory string");
|
||||
|
||||
@ -82,7 +82,7 @@ public:
|
||||
mapnik::layer_descriptor get_descriptor() const;
|
||||
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
|
||||
template <typename T>
|
||||
void parse_geojson(T & stream);
|
||||
void parse_geojson(T const& buffer);
|
||||
private:
|
||||
mapnik::datasource::datasource_t type_;
|
||||
mapnik::layer_descriptor desc_;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user