diff options
author | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2017-10-18 13:11:31 -0700 |
---|---|---|
committer | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2017-10-18 14:58:29 -0700 |
commit | 90a7cf87a32f6787e57e3852ac9d3015d8112621 (patch) | |
tree | 9f4d18736ee976b0071b54dd0610b8ac0a22a14f /deps | |
parent | 1c633072fcea7ad153ab6f8ec40dd72d83541ead (diff) | |
download | qtlocation-mapboxgl-90a7cf87a32f6787e57e3852ac9d3015d8112621.tar.gz |
Bump Mapbox GL Native
mapbox-gl-native @ 10f7af19ce1ec61f37459f9cd75e2a0c89a0c790
Diffstat (limited to 'deps')
-rw-r--r-- | deps/geojson/0.4.2/include/mapbox/geojson.hpp (renamed from deps/geojson/0.4.0/include/mapbox/geojson.hpp) | 0 | ||||
-rw-r--r-- | deps/geojson/0.4.2/include/mapbox/geojson/rapidjson.hpp (renamed from deps/geojson/0.4.0/include/mapbox/geojson/rapidjson.hpp) | 0 | ||||
-rw-r--r-- | deps/geojson/0.4.2/include/mapbox/geojson_impl.hpp (renamed from deps/geojson/0.4.0/include/mapbox/geojson_impl.hpp) | 20 | ||||
-rw-r--r-- | deps/geojsonvt/6.3.0/include/mapbox/geojsonvt.hpp (renamed from deps/geojsonvt/6.2.1/include/mapbox/geojsonvt.hpp) | 59 | ||||
-rw-r--r-- | deps/geojsonvt/6.3.0/include/mapbox/geojsonvt/clip.hpp (renamed from deps/geojsonvt/6.2.1/include/mapbox/geojsonvt/clip.hpp) | 0 | ||||
-rw-r--r-- | deps/geojsonvt/6.3.0/include/mapbox/geojsonvt/convert.hpp (renamed from deps/geojsonvt/6.2.1/include/mapbox/geojsonvt/convert.hpp) | 0 | ||||
-rw-r--r-- | deps/geojsonvt/6.3.0/include/mapbox/geojsonvt/simplify.hpp (renamed from deps/geojsonvt/6.2.1/include/mapbox/geojsonvt/simplify.hpp) | 0 | ||||
-rw-r--r-- | deps/geojsonvt/6.3.0/include/mapbox/geojsonvt/tile.hpp (renamed from deps/geojsonvt/6.2.1/include/mapbox/geojsonvt/tile.hpp) | 0 | ||||
-rw-r--r-- | deps/geojsonvt/6.3.0/include/mapbox/geojsonvt/types.hpp (renamed from deps/geojsonvt/6.2.1/include/mapbox/geojsonvt/types.hpp) | 0 | ||||
-rw-r--r-- | deps/geojsonvt/6.3.0/include/mapbox/geojsonvt/wrap.hpp (renamed from deps/geojsonvt/6.2.1/include/mapbox/geojsonvt/wrap.hpp) | 0 |
10 files changed, 56 insertions, 23 deletions
diff --git a/deps/geojson/0.4.0/include/mapbox/geojson.hpp b/deps/geojson/0.4.2/include/mapbox/geojson.hpp index 4b62751e15..4b62751e15 100644 --- a/deps/geojson/0.4.0/include/mapbox/geojson.hpp +++ b/deps/geojson/0.4.2/include/mapbox/geojson.hpp diff --git a/deps/geojson/0.4.0/include/mapbox/geojson/rapidjson.hpp b/deps/geojson/0.4.2/include/mapbox/geojson/rapidjson.hpp index 360eefd010..360eefd010 100644 --- a/deps/geojson/0.4.0/include/mapbox/geojson/rapidjson.hpp +++ b/deps/geojson/0.4.2/include/mapbox/geojson/rapidjson.hpp diff --git a/deps/geojson/0.4.0/include/mapbox/geojson_impl.hpp b/deps/geojson/0.4.2/include/mapbox/geojson_impl.hpp index 2ffd420dbb..48d81e4114 100644 --- a/deps/geojson/0.4.0/include/mapbox/geojson_impl.hpp +++ b/deps/geojson/0.4.2/include/mapbox/geojson_impl.hpp @@ -6,6 +6,9 @@ #include <rapidjson/document.h> #include <rapidjson/writer.h> #include <rapidjson/stringbuffer.h> +#include <rapidjson/error/en.h> + +#include <sstream> namespace mapbox { namespace geojson { @@ -170,13 +173,11 @@ feature convert<feature>(const rapidjson_value &json) { } auto const &prop_itr = json.FindMember("properties"); - - if (prop_itr == json_end) - throw error("Feature must have a properties property"); - - const auto &json_props = prop_itr->value; - if (!json_props.IsNull()) { - result.properties = convert<prop_map>(json_props); + if (prop_itr != json_end) { + const auto &json_props = prop_itr->value; + if (!json_props.IsNull()) { + result.properties = convert<prop_map>(json_props); + } } return result; @@ -227,6 +228,11 @@ template <class T> T parse(const std::string &json) { rapidjson_document d; d.Parse(json.c_str()); + if (d.HasParseError()) { + std::stringstream message; + message << d.GetErrorOffset() << " - " << rapidjson::GetParseError_En(d.GetParseError()); + throw error(message.str()); + } return convert<T>(d); } diff --git a/deps/geojsonvt/6.2.1/include/mapbox/geojsonvt.hpp b/deps/geojsonvt/6.3.0/include/mapbox/geojsonvt.hpp index b758be3929..ee1bbbca8d 100644 --- a/deps/geojsonvt/6.2.1/include/mapbox/geojsonvt.hpp +++ b/deps/geojsonvt/6.3.0/include/mapbox/geojsonvt.hpp @@ -13,11 +13,11 @@ namespace mapbox { namespace geojsonvt { -using geometry = mapbox::geometry::geometry<double>; -using feature = mapbox::geometry::feature<double>; -using feature_collection = mapbox::geometry::feature_collection<double>; +using geometry = mapbox::geometry::geometry<double>; +using feature = mapbox::geometry::feature<double>; +using feature_collection = mapbox::geometry::feature_collection<double>; using geometry_collection = mapbox::geometry::geometry_collection<double>; -using geojson = mapbox::util::variant<geometry, feature, feature_collection>; +using geojson = mapbox::util::variant<geometry, feature, feature_collection>; struct ToFeatureCollection { feature_collection operator()(const feature_collection& value) const { @@ -31,7 +31,18 @@ struct ToFeatureCollection { } }; -struct Options { +struct TileOptions { + // simplification tolerance (higher means simpler) + double tolerance = 3; + + // tile extent + uint16_t extent = 4096; + + // tile buffer on each side + uint16_t buffer = 64; +}; + +struct Options : TileOptions { // max zoom to preserve detail on uint8_t maxZoom = 18; @@ -43,15 +54,6 @@ struct Options { // whether to tile solid square tiles further bool solidChildren = false; - - // simplification tolerance (higher means simpler) - double tolerance = 3; - - // tile extent - uint16_t extent = 4096; - - // tile buffer on each side - uint16_t buffer = 64; }; const Tile empty_tile{}; @@ -60,6 +62,31 @@ inline uint64_t toID(uint8_t z, uint32_t x, uint32_t y) { return (((1ull << z) * y + x) * 32) + z; } +inline const Tile geoJSONToTile(const geojson& geojson_, + uint8_t z, + uint32_t x, + uint32_t y, + const TileOptions& options = TileOptions(), + bool wrap = false, + bool clip = false) { + + const auto features_ = geojson::visit(geojson_, ToFeatureCollection{}); + auto z2 = 1u << z; + auto tolerance = (options.tolerance / options.extent) / z2; + auto features = detail::convert(features_, tolerance); + if (wrap) { + features = detail::wrap(features, double(options.buffer) / options.extent); + } + if (clip) { + const double p = options.buffer / options.extent; + + const auto left = detail::clip<0>(features, (x - p) / z2, (x + 1 + p) / z2, -1, 2); + features = detail::clip<1>(left, (y - p) / z2, (y + 1 + p) / z2, -1, 2); + } + return detail::InternalTile({ features, z, x, y, options.extent, options.buffer, tolerance }) + .tile; +} + class GeoJSONVT { public: const Options options; @@ -68,7 +95,7 @@ public: const Options& options_ = Options()) : options(options_) { - const uint32_t z2 = std::pow(2, options.maxZoom); + const uint32_t z2 = 1u << options.maxZoom; auto converted = detail::convert(features_, (options.tolerance / options.extent) / z2); auto features = detail::wrap(converted, double(options.buffer) / options.extent); @@ -88,7 +115,7 @@ public: if (z > options.maxZoom) throw std::runtime_error("Requested zoom higher than maxZoom: " + std::to_string(z)); - const uint32_t z2 = std::pow(2, z); + const uint32_t z2 = 1u << z; const uint32_t x = ((x_ % z2) + z2) % z2; // wrap tile x coordinate const uint64_t id = toID(z, x, y); diff --git a/deps/geojsonvt/6.2.1/include/mapbox/geojsonvt/clip.hpp b/deps/geojsonvt/6.3.0/include/mapbox/geojsonvt/clip.hpp index 212e2979d0..212e2979d0 100644 --- a/deps/geojsonvt/6.2.1/include/mapbox/geojsonvt/clip.hpp +++ b/deps/geojsonvt/6.3.0/include/mapbox/geojsonvt/clip.hpp diff --git a/deps/geojsonvt/6.2.1/include/mapbox/geojsonvt/convert.hpp b/deps/geojsonvt/6.3.0/include/mapbox/geojsonvt/convert.hpp index ba28f449b3..ba28f449b3 100644 --- a/deps/geojsonvt/6.2.1/include/mapbox/geojsonvt/convert.hpp +++ b/deps/geojsonvt/6.3.0/include/mapbox/geojsonvt/convert.hpp diff --git a/deps/geojsonvt/6.2.1/include/mapbox/geojsonvt/simplify.hpp b/deps/geojsonvt/6.3.0/include/mapbox/geojsonvt/simplify.hpp index be0165b0f1..be0165b0f1 100644 --- a/deps/geojsonvt/6.2.1/include/mapbox/geojsonvt/simplify.hpp +++ b/deps/geojsonvt/6.3.0/include/mapbox/geojsonvt/simplify.hpp diff --git a/deps/geojsonvt/6.2.1/include/mapbox/geojsonvt/tile.hpp b/deps/geojsonvt/6.3.0/include/mapbox/geojsonvt/tile.hpp index ccb230bb9c..ccb230bb9c 100644 --- a/deps/geojsonvt/6.2.1/include/mapbox/geojsonvt/tile.hpp +++ b/deps/geojsonvt/6.3.0/include/mapbox/geojsonvt/tile.hpp diff --git a/deps/geojsonvt/6.2.1/include/mapbox/geojsonvt/types.hpp b/deps/geojsonvt/6.3.0/include/mapbox/geojsonvt/types.hpp index b54357a7b9..b54357a7b9 100644 --- a/deps/geojsonvt/6.2.1/include/mapbox/geojsonvt/types.hpp +++ b/deps/geojsonvt/6.3.0/include/mapbox/geojsonvt/types.hpp diff --git a/deps/geojsonvt/6.2.1/include/mapbox/geojsonvt/wrap.hpp b/deps/geojsonvt/6.3.0/include/mapbox/geojsonvt/wrap.hpp index 495ccc5800..495ccc5800 100644 --- a/deps/geojsonvt/6.2.1/include/mapbox/geojsonvt/wrap.hpp +++ b/deps/geojsonvt/6.3.0/include/mapbox/geojsonvt/wrap.hpp |