Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Commit f329420

Browse files
authored
[core] add raster-dem source type and hillshade layer type (#10642)
1 parent 2d15aed commit f329420

File tree

84 files changed

+4661
-56
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+4661
-56
lines changed

cmake/core-files.cmake

+28
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ set(MBGL_CORE_FILES
4444
# geometry
4545
src/mbgl/geometry/anchor.hpp
4646
src/mbgl/geometry/debug_font_data.hpp
47+
src/mbgl/geometry/dem_data.cpp
48+
src/mbgl/geometry/dem_data.hpp
4749
src/mbgl/geometry/feature_index.cpp
4850
src/mbgl/geometry/feature_index.hpp
4951
src/mbgl/geometry/line_atlas.cpp
@@ -144,6 +146,10 @@ set(MBGL_CORE_FILES
144146
src/mbgl/programs/fill_extrusion_program.hpp
145147
src/mbgl/programs/fill_program.cpp
146148
src/mbgl/programs/fill_program.hpp
149+
src/mbgl/programs/hillshade_prepare_program.cpp
150+
src/mbgl/programs/hillshade_prepare_program.hpp
151+
src/mbgl/programs/hillshade_program.cpp
152+
src/mbgl/programs/hillshade_program.hpp
147153
src/mbgl/programs/line_program.cpp
148154
src/mbgl/programs/line_program.hpp
149155
src/mbgl/programs/program.hpp
@@ -219,6 +225,8 @@ set(MBGL_CORE_FILES
219225
src/mbgl/renderer/buckets/fill_bucket.hpp
220226
src/mbgl/renderer/buckets/fill_extrusion_bucket.cpp
221227
src/mbgl/renderer/buckets/fill_extrusion_bucket.hpp
228+
src/mbgl/renderer/buckets/hillshade_bucket.cpp
229+
src/mbgl/renderer/buckets/hillshade_bucket.hpp
222230
src/mbgl/renderer/buckets/line_bucket.cpp
223231
src/mbgl/renderer/buckets/line_bucket.hpp
224232
src/mbgl/renderer/buckets/raster_bucket.cpp
@@ -237,6 +245,8 @@ set(MBGL_CORE_FILES
237245
src/mbgl/renderer/layers/render_fill_extrusion_layer.hpp
238246
src/mbgl/renderer/layers/render_fill_layer.cpp
239247
src/mbgl/renderer/layers/render_fill_layer.hpp
248+
src/mbgl/renderer/layers/render_hillshade_layer.cpp
249+
src/mbgl/renderer/layers/render_hillshade_layer.hpp
240250
src/mbgl/renderer/layers/render_line_layer.cpp
241251
src/mbgl/renderer/layers/render_line_layer.hpp
242252
src/mbgl/renderer/layers/render_raster_layer.cpp
@@ -251,6 +261,8 @@ set(MBGL_CORE_FILES
251261
src/mbgl/renderer/sources/render_geojson_source.hpp
252262
src/mbgl/renderer/sources/render_image_source.cpp
253263
src/mbgl/renderer/sources/render_image_source.hpp
264+
src/mbgl/renderer/sources/render_raster_dem_source.cpp
265+
src/mbgl/renderer/sources/render_raster_dem_source.hpp
254266
src/mbgl/renderer/sources/render_raster_source.cpp
255267
src/mbgl/renderer/sources/render_raster_source.hpp
256268
src/mbgl/renderer/sources/render_vector_source.cpp
@@ -285,6 +297,10 @@ set(MBGL_CORE_FILES
285297
src/mbgl/shaders/fill_outline_pattern.hpp
286298
src/mbgl/shaders/fill_pattern.cpp
287299
src/mbgl/shaders/fill_pattern.hpp
300+
src/mbgl/shaders/hillshade.cpp
301+
src/mbgl/shaders/hillshade.hpp
302+
src/mbgl/shaders/hillshade_prepare.cpp
303+
src/mbgl/shaders/hillshade_prepare.hpp
288304
src/mbgl/shaders/line.cpp
289305
src/mbgl/shaders/line.hpp
290306
src/mbgl/shaders/line_pattern.cpp
@@ -479,6 +495,7 @@ set(MBGL_CORE_FILES
479495
include/mbgl/style/layers/custom_layer.hpp
480496
include/mbgl/style/layers/fill_extrusion_layer.hpp
481497
include/mbgl/style/layers/fill_layer.hpp
498+
include/mbgl/style/layers/hillshade_layer.hpp
482499
include/mbgl/style/layers/line_layer.hpp
483500
include/mbgl/style/layers/raster_layer.hpp
484501
include/mbgl/style/layers/symbol_layer.hpp
@@ -505,6 +522,11 @@ set(MBGL_CORE_FILES
505522
src/mbgl/style/layers/fill_layer_impl.hpp
506523
src/mbgl/style/layers/fill_layer_properties.cpp
507524
src/mbgl/style/layers/fill_layer_properties.hpp
525+
src/mbgl/style/layers/hillshade_layer.cpp
526+
src/mbgl/style/layers/hillshade_layer_impl.cpp
527+
src/mbgl/style/layers/hillshade_layer_impl.hpp
528+
src/mbgl/style/layers/hillshade_layer_properties.cpp
529+
src/mbgl/style/layers/hillshade_layer_properties.hpp
508530
src/mbgl/style/layers/line_layer.cpp
509531
src/mbgl/style/layers/line_layer_impl.cpp
510532
src/mbgl/style/layers/line_layer_impl.hpp
@@ -525,6 +547,7 @@ set(MBGL_CORE_FILES
525547
include/mbgl/style/sources/custom_geometry_source.hpp
526548
include/mbgl/style/sources/geojson_source.hpp
527549
include/mbgl/style/sources/image_source.hpp
550+
include/mbgl/style/sources/raster_dem_source.hpp
528551
include/mbgl/style/sources/raster_source.hpp
529552
include/mbgl/style/sources/vector_source.hpp
530553
src/mbgl/style/sources/custom_geometry_source.cpp
@@ -536,6 +559,7 @@ set(MBGL_CORE_FILES
536559
src/mbgl/style/sources/image_source.cpp
537560
src/mbgl/style/sources/image_source_impl.cpp
538561
src/mbgl/style/sources/image_source_impl.hpp
562+
src/mbgl/style/sources/raster_dem_source.cpp
539563
src/mbgl/style/sources/raster_source.cpp
540564
src/mbgl/style/sources/raster_source_impl.cpp
541565
src/mbgl/style/sources/raster_source_impl.hpp
@@ -587,6 +611,10 @@ set(MBGL_CORE_FILES
587611
src/mbgl/tile/geometry_tile_data.hpp
588612
src/mbgl/tile/geometry_tile_worker.cpp
589613
src/mbgl/tile/geometry_tile_worker.hpp
614+
src/mbgl/tile/raster_dem_tile.cpp
615+
src/mbgl/tile/raster_dem_tile.hpp
616+
src/mbgl/tile/raster_dem_tile_worker.cpp
617+
src/mbgl/tile/raster_dem_tile_worker.hpp
590618
src/mbgl/tile/raster_tile.cpp
591619
src/mbgl/tile/raster_tile.hpp
592620
src/mbgl/tile/raster_tile_worker.cpp

cmake/test-files.cmake

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ set(MBGL_TEST_FILES
2121
test/api/recycle_map.cpp
2222
test/api/zoom_history.cpp
2323

24+
# geometry
25+
test/geometry/dem_data.test.cpp
26+
2427
# gl
2528
test/gl/bucket.test.cpp
2629
test/gl/context.test.cpp
@@ -123,6 +126,7 @@ set(MBGL_TEST_FILES
123126
test/tile/custom_geometry_tile.test.cpp
124127
test/tile/geojson_tile.test.cpp
125128
test/tile/geometry_tile_data.test.cpp
129+
test/tile/raster_dem_tile.test.cpp
126130
test/tile/raster_tile.test.cpp
127131
test/tile/tile_coordinate.test.cpp
128132
test/tile/tile_id.test.cpp

include/mbgl/style/layer.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class LineLayer;
1919
class CircleLayer;
2020
class SymbolLayer;
2121
class RasterLayer;
22+
class HillshadeLayer;
2223
class BackgroundLayer;
2324
class CustomLayer;
2425
class FillExtrusionLayer;
@@ -86,6 +87,8 @@ class Layer : public mbgl::util::noncopyable {
8687
return std::forward<V>(visitor)(*as<RasterLayer>());
8788
case LayerType::Background:
8889
return std::forward<V>(visitor)(*as<BackgroundLayer>());
90+
case LayerType::Hillshade:
91+
return std::forward<V>(visitor)(*as<HillshadeLayer>());
8992
case LayerType::Custom:
9093
return std::forward<V>(visitor)(*as<CustomLayer>());
9194
case LayerType::FillExtrusion:

include/mbgl/style/layer_type.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ enum class LayerType {
99
Circle,
1010
Symbol,
1111
Raster,
12+
Hillshade,
1213
Background,
1314
Custom,
1415
FillExtrusion,
1516
};
1617

1718
} // namespace style
18-
} // namespace mbgl
19+
} // namespace mbgl
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// This file is generated. Do not edit.
2+
3+
#pragma once
4+
5+
#include <mbgl/style/layer.hpp>
6+
#include <mbgl/style/filter.hpp>
7+
#include <mbgl/style/property_value.hpp>
8+
#include <mbgl/style/data_driven_property_value.hpp>
9+
10+
#include <mbgl/util/color.hpp>
11+
12+
namespace mbgl {
13+
namespace style {
14+
15+
class TransitionOptions;
16+
17+
class HillshadeLayer : public Layer {
18+
public:
19+
HillshadeLayer(const std::string& layerID, const std::string& sourceID);
20+
~HillshadeLayer() final;
21+
22+
// Source
23+
const std::string& getSourceID() const;
24+
25+
// Visibility
26+
void setVisibility(VisibilityType) final;
27+
28+
// Zoom range
29+
void setMinZoom(float) final;
30+
void setMaxZoom(float) final;
31+
32+
// Paint properties
33+
34+
static PropertyValue<float> getDefaultHillshadeIlluminationDirection();
35+
PropertyValue<float> getHillshadeIlluminationDirection() const;
36+
void setHillshadeIlluminationDirection(PropertyValue<float>);
37+
void setHillshadeIlluminationDirectionTransition(const TransitionOptions&);
38+
TransitionOptions getHillshadeIlluminationDirectionTransition() const;
39+
40+
static PropertyValue<HillshadeIlluminationAnchorType> getDefaultHillshadeIlluminationAnchor();
41+
PropertyValue<HillshadeIlluminationAnchorType> getHillshadeIlluminationAnchor() const;
42+
void setHillshadeIlluminationAnchor(PropertyValue<HillshadeIlluminationAnchorType>);
43+
void setHillshadeIlluminationAnchorTransition(const TransitionOptions&);
44+
TransitionOptions getHillshadeIlluminationAnchorTransition() const;
45+
46+
static PropertyValue<float> getDefaultHillshadeExaggeration();
47+
PropertyValue<float> getHillshadeExaggeration() const;
48+
void setHillshadeExaggeration(PropertyValue<float>);
49+
void setHillshadeExaggerationTransition(const TransitionOptions&);
50+
TransitionOptions getHillshadeExaggerationTransition() const;
51+
52+
static PropertyValue<Color> getDefaultHillshadeShadowColor();
53+
PropertyValue<Color> getHillshadeShadowColor() const;
54+
void setHillshadeShadowColor(PropertyValue<Color>);
55+
void setHillshadeShadowColorTransition(const TransitionOptions&);
56+
TransitionOptions getHillshadeShadowColorTransition() const;
57+
58+
static PropertyValue<Color> getDefaultHillshadeHighlightColor();
59+
PropertyValue<Color> getHillshadeHighlightColor() const;
60+
void setHillshadeHighlightColor(PropertyValue<Color>);
61+
void setHillshadeHighlightColorTransition(const TransitionOptions&);
62+
TransitionOptions getHillshadeHighlightColorTransition() const;
63+
64+
static PropertyValue<Color> getDefaultHillshadeAccentColor();
65+
PropertyValue<Color> getHillshadeAccentColor() const;
66+
void setHillshadeAccentColor(PropertyValue<Color>);
67+
void setHillshadeAccentColorTransition(const TransitionOptions&);
68+
TransitionOptions getHillshadeAccentColorTransition() const;
69+
70+
// Private implementation
71+
72+
class Impl;
73+
const Impl& impl() const;
74+
75+
Mutable<Impl> mutableImpl() const;
76+
HillshadeLayer(Immutable<Impl>);
77+
std::unique_ptr<Layer> cloneRef(const std::string& id) const final;
78+
};
79+
80+
template <>
81+
inline bool Layer::is<HillshadeLayer>() const {
82+
return getType() == LayerType::Hillshade;
83+
}
84+
85+
} // namespace style
86+
} // namespace mbgl

include/mbgl/style/layers/layer.hpp.ejs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public:
3535
<% if (type !== 'background') { -%>
3636
// Source
3737
const std::string& getSourceID() const;
38-
<% if (type !== 'raster') { -%>
38+
<% if (type !== 'raster' && type !== 'hillshade') { -%>
3939
const std::string& getSourceLayer() const;
4040
void setSourceLayer(const std::string& sourceLayer);
4141

include/mbgl/style/source.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace style {
1717

1818
class VectorSource;
1919
class RasterSource;
20+
class RasterDEMSource;
2021
class GeoJSONSource;
2122
class SourceObserver;
2223

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#pragma once
2+
3+
#include <mbgl/style/sources/raster_source.hpp>
4+
#include <mbgl/util/tileset.hpp>
5+
#include <mbgl/util/variant.hpp>
6+
7+
namespace mbgl {
8+
9+
class AsyncRequest;
10+
11+
namespace style {
12+
13+
class RasterDEMSource : public RasterSource {
14+
public:
15+
RasterDEMSource(std::string id, variant<std::string, Tileset> urlOrTileset, uint16_t tileSize);
16+
17+
};
18+
19+
template <>
20+
inline bool Source::is<RasterDEMSource>() const {
21+
return getType() == SourceType::RasterDEM;
22+
}
23+
24+
} // namespace style
25+
} // namespace mbgl

include/mbgl/style/sources/raster_source.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ namespace style {
1212

1313
class RasterSource : public Source {
1414
public:
15-
RasterSource(std::string id, variant<std::string, Tileset> urlOrTileset, uint16_t tileSize);
16-
~RasterSource() final;
15+
RasterSource(std::string id, variant<std::string, Tileset> urlOrTileset, uint16_t tileSize, SourceType sourceType = SourceType::Raster);
16+
~RasterSource() override;
1717

1818
const variant<std::string, Tileset>& getURLOrTileset() const;
1919
optional<std::string> getURL() const;

include/mbgl/style/types.hpp

+6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace style {
1010
enum class SourceType : uint8_t {
1111
Vector,
1212
Raster,
13+
RasterDEM,
1314
GeoJSON,
1415
Video,
1516
Annotations,
@@ -37,6 +38,11 @@ enum class LineJoinType : uint8_t {
3738
FlipBevel
3839
};
3940

41+
enum class HillshadeIlluminationAnchorType : bool {
42+
Map,
43+
Viewport
44+
};
45+
4046
enum class TranslateAnchorType : bool {
4147
Map,
4248
Viewport

0 commit comments

Comments
 (0)