[core, android] Factor JSON string conversions
This adds a `convertJSON` template, to be used like: Error error optional<Foo> foo = convertJSON<Foo>(string, error); Internally, it parses the string with RapidJSON and then calls `convert<Foo>(parsed, error)`. While here, rationalize GeoJSON converters and fix error handling for Tileset conversion in OfflineDownload.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include <mbgl/util/constants.hpp>
|
||||
#include <mbgl/util/logging.hpp>
|
||||
#include <mbgl/util/url.hpp>
|
||||
#include <mbgl/util/tileset.hpp>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
@@ -170,6 +171,15 @@ canonicalizeTileURL(const std::string& str, const SourceType type, const uint16_
|
||||
return result;
|
||||
}
|
||||
|
||||
void canonicalizeTileset(Tileset& tileset, const std::string& sourceURL, SourceType type, uint16_t tileSize) {
|
||||
// TODO: Remove this hack by delivering proper URLs in the TileJSON to begin with.
|
||||
if (isMapboxURL(sourceURL)) {
|
||||
for (auto& url : tileset.tiles) {
|
||||
url = canonicalizeTileURL(url, type, tileSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const uint64_t DEFAULT_OFFLINE_TILE_COUNT_LIMIT = 6000;
|
||||
|
||||
} // end namespace mapbox
|
||||
|
||||
Reference in New Issue
Block a user