diff --git a/include/llmr/style/properties.hpp b/include/llmr/style/properties.hpp index b8ffcfad6..d0bc3b2d4 100644 --- a/include/llmr/style/properties.hpp +++ b/include/llmr/style/properties.hpp @@ -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; } diff --git a/src/map/map.cpp b/src/map/map.cpp index 60a7aa78d..71ce0e938 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -591,7 +591,11 @@ typename Styles::const_iterator find_style(const Styles &styles, const LayerDesc template 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(); } diff --git a/src/renderer/painter_fill.cpp b/src/renderer/painter_fill.cpp index cd7b0780d..d0ba2a8de 100644 --- a/src/renderer/painter_fill.cpp +++ b/src/renderer/painter_fill.cpp @@ -146,9 +146,10 @@ void Painter::renderFill(FillBucket& bucket, const std::string& layer_name, cons const std::unordered_map &fill_properties = map.getStyle().computed.fills; const std::unordered_map::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; diff --git a/src/renderer/painter_icon.cpp b/src/renderer/painter_icon.cpp index 382312c12..51bb88fb2 100644 --- a/src/renderer/painter_icon.cpp +++ b/src/renderer/painter_icon.cpp @@ -13,9 +13,10 @@ void Painter::renderIcon(IconBucket& bucket, const std::string& layer_name, cons const std::unordered_map &icon_properties = map.getStyle().computed.icons; const std::unordered_map::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; diff --git a/src/renderer/painter_line.cpp b/src/renderer/painter_line.cpp index 2788a8bb1..71692c74c 100644 --- a/src/renderer/painter_line.cpp +++ b/src/renderer/painter_line.cpp @@ -11,9 +11,10 @@ void Painter::renderLine(LineBucket& bucket, const std::string& layer_name, cons const std::unordered_map &line_properties = map.getStyle().computed.lines; const std::unordered_map::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; diff --git a/src/renderer/painter_raster.cpp b/src/renderer/painter_raster.cpp index de0d35261..f1943bb49 100644 --- a/src/renderer/painter_raster.cpp +++ b/src/renderer/painter_raster.cpp @@ -9,9 +9,10 @@ void Painter::renderRaster(RasterBucket& bucket, const std::string& layer_name, const std::unordered_map &raster_properties = map.getStyle().computed.rasters; const std::unordered_map::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); diff --git a/src/renderer/painter_text.cpp b/src/renderer/painter_text.cpp index bd1709a96..148fe7d53 100644 --- a/src/renderer/painter_text.cpp +++ b/src/renderer/painter_text.cpp @@ -12,9 +12,10 @@ void Painter::renderText(TextBucket& bucket, const std::string& layer_name, cons const std::unordered_map &text_properties = map.getStyle().computed.texts; const std::unordered_map::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;