[core] Add minzoom to GeoJSONOptions
This commit is contained in:
committed by
Asheem Mamoowala
parent
64c75b442c
commit
8fae8a1645
@@ -14,6 +14,16 @@ struct Converter<GeoJSONOptions> {
|
||||
optional<GeoJSONOptions> operator()(const V& value, Error& error) const {
|
||||
GeoJSONOptions options;
|
||||
|
||||
const auto minzoomValue = objectMember(value, "minzoom");
|
||||
if (minzoomValue) {
|
||||
if (toNumber(*minzoomValue)) {
|
||||
options.minzoom = static_cast<uint8_t>(*toNumber(*minzoomValue));
|
||||
} else {
|
||||
error = { "GeoJSON source minzoom value must be a number" };
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
const auto maxzoomValue = objectMember(value, "maxzoom");
|
||||
if (maxzoomValue) {
|
||||
if (toNumber(*maxzoomValue)) {
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace style {
|
||||
|
||||
struct GeoJSONOptions {
|
||||
// GeoJSON-VT options
|
||||
uint8_t minzoom = 0;
|
||||
uint8_t maxzoom = 18;
|
||||
uint16_t buffer = 128;
|
||||
double tolerance = 0.375;
|
||||
|
||||
@@ -71,7 +71,7 @@ GeoJSONSource::Impl::Impl(const Impl& other, const GeoJSON& geoJSON)
|
||||
GeoJSONSource::Impl::~Impl() = default;
|
||||
|
||||
Range<uint8_t> GeoJSONSource::Impl::getZoomRange() const {
|
||||
return { 0, options.maxzoom };
|
||||
return { options.minzoom, options.maxzoom };
|
||||
}
|
||||
|
||||
GeoJSONData* GeoJSONSource::Impl::getData() const {
|
||||
|
||||
@@ -33,6 +33,7 @@ TEST(GeoJSONOptions, RetainsDefaults) {
|
||||
GeoJSONOptions defaults;
|
||||
|
||||
// GeoJSON-VT
|
||||
ASSERT_EQ(converted.minzoom, defaults.minzoom);
|
||||
ASSERT_EQ(converted.maxzoom, defaults.maxzoom);
|
||||
ASSERT_EQ(converted.buffer, defaults.buffer);
|
||||
ASSERT_EQ(converted.tolerance, defaults.tolerance);
|
||||
@@ -61,6 +62,7 @@ TEST(GeoJSONOptions, FullConversion) {
|
||||
GeoJSONOptions converted = *convert<GeoJSONOptions>(raw, error);
|
||||
|
||||
// GeoJSON-VT
|
||||
ASSERT_EQ(converted.minzoom, 0);
|
||||
ASSERT_EQ(converted.maxzoom, 1);
|
||||
ASSERT_EQ(converted.buffer, 2);
|
||||
ASSERT_EQ(converted.tolerance, 3);
|
||||
|
||||
Reference in New Issue
Block a user