fallback to default properties instead of not rendering when we don't have a style
refs #272
This commit is contained in:
@@ -128,6 +128,7 @@ struct IconClass : public GenericClass {
|
||||
};
|
||||
|
||||
struct IconProperties : public GenericProperties {
|
||||
inline IconProperties() : GenericProperties() {}
|
||||
float size = 0;
|
||||
Color color = {{ 1, 1, 1, 1 }};
|
||||
std::string image;
|
||||
@@ -147,6 +148,7 @@ struct LineClass : public GenericClass {
|
||||
};
|
||||
|
||||
struct LineProperties : public GenericProperties {
|
||||
inline LineProperties() : GenericProperties() {}
|
||||
float width = 0;
|
||||
float offset = 0;
|
||||
Color color = {{ 0, 0, 0, 1 }};
|
||||
@@ -164,6 +166,7 @@ struct FillClass : public GenericClass {
|
||||
};
|
||||
|
||||
struct FillProperties : public GenericProperties {
|
||||
inline FillProperties() : GenericProperties() {}
|
||||
Winding winding = Winding::NonZero;
|
||||
bool antialias = true;
|
||||
Color fill_color = {{ 0, 0, 0, 1 }};
|
||||
@@ -187,6 +190,7 @@ struct TextClass : public GenericClass {
|
||||
};
|
||||
|
||||
struct TextProperties : public GenericProperties {
|
||||
inline TextProperties() : GenericProperties() {}
|
||||
Color color = {{ 0, 0, 0, 1 }};
|
||||
Color halo = {{ 1, 1, 1, 0.75 }};
|
||||
float halo_radius = 0.25f;
|
||||
@@ -202,6 +206,7 @@ struct BackgroundClass : public GenericClass {
|
||||
};
|
||||
|
||||
struct BackgroundProperties : public GenericProperties {
|
||||
inline BackgroundProperties() : GenericProperties() {}
|
||||
Color color = {{ 1, 1, 1, 1 }};
|
||||
};
|
||||
|
||||
@@ -209,6 +214,7 @@ struct RasterClass : public GenericClass {
|
||||
};
|
||||
|
||||
struct RasterProperties : public GenericProperties {
|
||||
inline RasterProperties() : GenericProperties() {}
|
||||
};
|
||||
|
||||
struct CompositeClass : public GenericClass {
|
||||
@@ -219,6 +225,12 @@ struct CompositeProperties : public GenericProperties {
|
||||
};
|
||||
|
||||
|
||||
const IconProperties defaultIconProperties;
|
||||
const LineProperties defaultLineProperties;
|
||||
const FillProperties defaultFillProperties;
|
||||
const TextProperties defaultTextProperties;
|
||||
const BackgroundProperties defaultBackgroundProperties;
|
||||
const RasterProperties defaultRasterProperties;
|
||||
const CompositeProperties defaultCompositeProperties;
|
||||
|
||||
}
|
||||
|
||||
@@ -591,7 +591,11 @@ typename Styles::const_iterator find_style(const Styles &styles, const LayerDesc
|
||||
template <typename Styles>
|
||||
bool is_invisible(const Styles &styles, const LayerDescription &layer_desc) {
|
||||
auto it = find_style(styles, layer_desc);
|
||||
if (it == styles.end()) { return true; }
|
||||
if (it == styles.end()) {
|
||||
// We don't have a style, so we fall back to the default style which is
|
||||
// always visible.
|
||||
return false;
|
||||
}
|
||||
return !it->second.isVisible();
|
||||
}
|
||||
|
||||
|
||||
@@ -146,9 +146,10 @@ void Painter::renderFill(FillBucket& bucket, const std::string& layer_name, cons
|
||||
|
||||
const std::unordered_map<std::string, FillProperties> &fill_properties = map.getStyle().computed.fills;
|
||||
const std::unordered_map<std::string, FillProperties>::const_iterator fill_properties_it = fill_properties.find(layer_name);
|
||||
if (fill_properties_it == fill_properties.end()) return;
|
||||
|
||||
const FillProperties& properties = fill_properties_it->second;
|
||||
const FillProperties &properties = fill_properties_it != fill_properties.end()
|
||||
? fill_properties_it->second
|
||||
: defaultFillProperties;
|
||||
if (!properties.enabled) return;
|
||||
|
||||
|
||||
|
||||
@@ -13,9 +13,10 @@ void Painter::renderIcon(IconBucket& bucket, const std::string& layer_name, cons
|
||||
|
||||
const std::unordered_map<std::string, IconProperties> &icon_properties = map.getStyle().computed.icons;
|
||||
const std::unordered_map<std::string, IconProperties>::const_iterator icon_properties_it = icon_properties.find(layer_name);
|
||||
if (icon_properties_it == icon_properties.end()) return;
|
||||
|
||||
const IconProperties& properties = icon_properties_it->second;
|
||||
const IconProperties &properties = icon_properties_it != icon_properties.end()
|
||||
? icon_properties_it->second
|
||||
: defaultIconProperties;
|
||||
if (!properties.enabled) return;
|
||||
|
||||
Color color = properties.color;
|
||||
|
||||
@@ -11,9 +11,10 @@ void Painter::renderLine(LineBucket& bucket, const std::string& layer_name, cons
|
||||
|
||||
const std::unordered_map<std::string, LineProperties> &line_properties = map.getStyle().computed.lines;
|
||||
const std::unordered_map<std::string, LineProperties>::const_iterator line_properties_it = line_properties.find(layer_name);
|
||||
if (line_properties_it == line_properties.end()) return;
|
||||
|
||||
const LineProperties& properties = line_properties_it->second;
|
||||
const LineProperties &properties = line_properties_it != line_properties.end()
|
||||
? line_properties_it->second
|
||||
: defaultLineProperties;
|
||||
if (!properties.enabled) return;
|
||||
|
||||
float width = properties.width;
|
||||
|
||||
@@ -9,9 +9,10 @@ void Painter::renderRaster(RasterBucket& bucket, const std::string& layer_name,
|
||||
|
||||
const std::unordered_map<std::string, RasterProperties> &raster_properties = map.getStyle().computed.rasters;
|
||||
const std::unordered_map<std::string, RasterProperties>::const_iterator raster_properties_it = raster_properties.find(layer_name);
|
||||
if (raster_properties_it == raster_properties.end()) return;
|
||||
|
||||
const RasterProperties& properties = raster_properties_it->second;
|
||||
const RasterProperties &properties = raster_properties_it != raster_properties.end()
|
||||
? raster_properties_it->second
|
||||
: defaultRasterProperties;
|
||||
if (!properties.enabled) return;
|
||||
|
||||
depthMask(false);
|
||||
|
||||
@@ -12,9 +12,10 @@ void Painter::renderText(TextBucket& bucket, const std::string& layer_name, cons
|
||||
|
||||
const std::unordered_map<std::string, TextProperties> &text_properties = map.getStyle().computed.texts;
|
||||
const std::unordered_map<std::string, TextProperties>::const_iterator text_properties_it = text_properties.find(layer_name);
|
||||
if (text_properties_it == text_properties.end()) return;
|
||||
|
||||
const TextProperties& properties = text_properties_it->second;
|
||||
const TextProperties &properties = text_properties_it != text_properties.end()
|
||||
? text_properties_it->second
|
||||
: defaultTextProperties;
|
||||
if (!properties.enabled) return;
|
||||
|
||||
mat4 exMatrix;
|
||||
|
||||
Reference in New Issue
Block a user