Skip to content

Commit abded91

Browse files
committed
Merge branch 'main' of https://github.com/CesiumGS/cesium-native into ownership
2 parents 488eb2d + 9741cf2 commit abded91

11 files changed

Lines changed: 436 additions & 53 deletions

File tree

CHANGES.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
# Change Log
22

3-
### v0.59.0 - 2026-03-31
3+
### v0.60.0 - 2026-05-01
4+
5+
##### Additions :tada:
6+
7+
- Added `BoundingRegionBuilder::expandToIncludeBoundingRegion`.
8+
9+
##### Fixes :wrench:
10+
11+
- Fixed a bug in `CesiumRasterOverlays::GeoJsonDocumentRasterOverlay` where styles set on geometry objects within a FeatureCollection were not applied. The FeatureCollection visitor now checks the geometry's style instead of the Feature wrapper's style, and the fallback chain correctly consults the collection-level style.
12+
13+
### v0.59.0 - 2026-04-01
414

515
##### Breaking Changes :mega:
616

CesiumGeospatial/include/CesiumGeospatial/BoundingRegionBuilder.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,17 @@ class CESIUMGEOSPATIAL_API BoundingRegionBuilder {
8282
*/
8383
bool expandToIncludeGlobeRectangle(const GlobeRectangle& rectangle);
8484

85+
/**
86+
* @brief Expands the bounding region to include the given bounding region.
87+
*
88+
* The region will be kept as small as possible.
89+
*
90+
* @param region The region to be included in the region.
91+
* @returns True if the region was modified, or false if the region already
92+
* contained the region.
93+
*/
94+
bool expandToIncludeBoundingRegion(const BoundingRegion& region);
95+
8596
private:
8697
/**
8798
* @brief When a position's latitude is within this distance in radians from

CesiumGeospatial/src/BoundingRegionBuilder.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,25 @@ bool BoundingRegionBuilder::expandToIncludeGlobeRectangle(
145145
return modified;
146146
}
147147

148+
bool BoundingRegionBuilder::expandToIncludeBoundingRegion(
149+
const BoundingRegion& region) {
150+
bool modified = false;
151+
152+
if (expandToIncludeGlobeRectangle(region.getRectangle())) {
153+
modified = true;
154+
}
155+
156+
if (region.getMinimumHeight() < this->_minimumHeight) {
157+
this->_minimumHeight = region.getMinimumHeight();
158+
modified = true;
159+
}
160+
161+
if (region.getMaximumHeight() > this->_maximumHeight) {
162+
this->_maximumHeight = region.getMaximumHeight();
163+
modified = true;
164+
}
165+
166+
return modified;
167+
}
168+
148169
} // namespace CesiumGeospatial

CesiumGeospatial/test/TestBoundingRegionBuilder.cpp

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <CesiumGeospatial/BoundingRegion.h>
12
#include <CesiumGeospatial/BoundingRegionBuilder.h>
23
#include <CesiumGeospatial/Ellipsoid.h>
34
#include <CesiumGeospatial/GlobeRectangle.h>
@@ -183,3 +184,107 @@ TEST_CASE("BoundingRegionBuilder::expandToIncludeGlobeRectangle") {
183184
Math::Epsilon15));
184185
}
185186
}
187+
188+
TEST_CASE("BoundingRegionBuilder::expandToIncludeBoundingRegion") {
189+
SUBCASE("expands to include rectangle") {
190+
BoundingRegionBuilder builder;
191+
bool modified = builder.expandToIncludeBoundingRegion(
192+
BoundingRegion(GlobeRectangle(0.1, 0.2, 0.3, 0.4), -1.0, 2.0));
193+
BoundingRegion region = builder.toRegion();
194+
CHECK(BoundingRegion::equalsEpsilon(
195+
region,
196+
BoundingRegion(GlobeRectangle(0.1, 0.2, 0.3, 0.4), -1.0, 2.0),
197+
Math::Epsilon15));
198+
CHECK(modified);
199+
200+
SUBCASE("does nothing if the rectangle is already included") {
201+
modified = builder.expandToIncludeBoundingRegion(
202+
BoundingRegion(GlobeRectangle(0.15, 0.25, 0.25, 0.35), -1.0, 2.0));
203+
region = builder.toRegion();
204+
CHECK(BoundingRegion::equalsEpsilon(
205+
region,
206+
BoundingRegion(GlobeRectangle(0.1, 0.2, 0.3, 0.4), -1.0, 2.0),
207+
Math::Epsilon15));
208+
CHECK_FALSE(modified);
209+
}
210+
211+
SUBCASE("expands to include rectangle") {
212+
modified = builder.expandToIncludeBoundingRegion(
213+
BoundingRegion(GlobeRectangle(0.05, 0.15, 0.35, 0.45), -1.0, 2.0));
214+
region = builder.toRegion();
215+
CHECK(BoundingRegion::equalsEpsilon(
216+
region,
217+
BoundingRegion(GlobeRectangle(0.05, 0.15, 0.35, 0.45), -1.0, 2.0),
218+
Math::Epsilon15));
219+
CHECK(modified);
220+
}
221+
}
222+
223+
SUBCASE("expands to include min height") {
224+
BoundingRegionBuilder builder;
225+
bool modified = builder.expandToIncludeBoundingRegion(
226+
BoundingRegion(GlobeRectangle(0.1, 0.2, 0.3, 0.4), -1.0, 2.0));
227+
BoundingRegion region = builder.toRegion();
228+
CHECK(BoundingRegion::equalsEpsilon(
229+
region,
230+
BoundingRegion(GlobeRectangle(0.1, 0.2, 0.3, 0.4), -1.0, 2.0),
231+
Math::Epsilon15));
232+
CHECK(modified);
233+
234+
SUBCASE("does nothing if min height is already included") {
235+
modified = builder.expandToIncludeBoundingRegion(
236+
BoundingRegion(GlobeRectangle(0.1, 0.2, 0.3, 0.4), -0.5, 2.0));
237+
region = builder.toRegion();
238+
CHECK(BoundingRegion::equalsEpsilon(
239+
region,
240+
BoundingRegion(GlobeRectangle(0.1, 0.2, 0.3, 0.4), -1.0, 2.0),
241+
Math::Epsilon15));
242+
CHECK_FALSE(modified);
243+
}
244+
245+
SUBCASE("expands to include min height") {
246+
modified = builder.expandToIncludeBoundingRegion(
247+
BoundingRegion(GlobeRectangle(0.1, 0.2, 0.3, 0.4), -1.5, 2.0));
248+
region = builder.toRegion();
249+
CHECK(BoundingRegion::equalsEpsilon(
250+
region,
251+
BoundingRegion(GlobeRectangle(0.1, 0.2, 0.3, 0.4), -1.5, 2.0),
252+
Math::Epsilon15));
253+
CHECK(modified);
254+
}
255+
}
256+
257+
SUBCASE("expands to include max height") {
258+
BoundingRegionBuilder builder;
259+
bool modified = builder.expandToIncludeBoundingRegion(
260+
BoundingRegion(GlobeRectangle(0.1, 0.2, 0.3, 0.4), -1.0, 2.0));
261+
BoundingRegion region = builder.toRegion();
262+
CHECK(BoundingRegion::equalsEpsilon(
263+
region,
264+
BoundingRegion(GlobeRectangle(0.1, 0.2, 0.3, 0.4), -1.0, 2.0),
265+
Math::Epsilon15));
266+
CHECK(modified);
267+
268+
SUBCASE("does nothing if max height is already included") {
269+
modified = builder.expandToIncludeBoundingRegion(
270+
BoundingRegion(GlobeRectangle(0.1, 0.2, 0.3, 0.4), -1.0, 1.5));
271+
region = builder.toRegion();
272+
CHECK(BoundingRegion::equalsEpsilon(
273+
region,
274+
BoundingRegion(GlobeRectangle(0.1, 0.2, 0.3, 0.4), -1.0, 2.0),
275+
Math::Epsilon15));
276+
CHECK_FALSE(modified);
277+
}
278+
279+
SUBCASE("expands to include max height") {
280+
modified = builder.expandToIncludeBoundingRegion(
281+
BoundingRegion(GlobeRectangle(0.1, 0.2, 0.3, 0.4), -1.0, 2.5));
282+
region = builder.toRegion();
283+
CHECK(BoundingRegion::equalsEpsilon(
284+
region,
285+
BoundingRegion(GlobeRectangle(0.1, 0.2, 0.3, 0.4), -1.0, 2.5),
286+
Math::Epsilon15));
287+
CHECK(modified);
288+
}
289+
}
290+
}

CesiumNativeTests/CMakeLists.txt

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ set(cesium_native_targets
2525
CesiumUtility
2626
)
2727

28-
if(NOT CESIUM_DISABLE_CURL)
28+
if(NOT CESIUM_DISABLE_CURL)
2929
list(APPEND cesium_native_targets CesiumCurl)
3030
endif()
3131

@@ -42,7 +42,7 @@ if(CESIUM_TARGET_WASM)
4242
target_link_options(
4343
cesium-native-tests
4444
PRIVATE
45-
"-sEXIT_RUNTIME=1"
45+
"-sEXIT_RUNTIME=1"
4646
)
4747
endif()
4848

@@ -145,6 +145,19 @@ PRIVATE
145145
CESIUM_NATIVE_DATA_DIR=\"${CMAKE_SOURCE_DIR}/data\"
146146
)
147147
148+
if(CESIUM_TARGET_WASM)
149+
set(CESIUM_NATIVE_TEMP_DIR "")
150+
else()
151+
set(CESIUM_NATIVE_TEMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/temp")
152+
endif()
153+
154+
target_compile_definitions(cesium-native-tests
155+
PRIVATE
156+
CESIUM_NATIVE_TEMP_DIR=\"${CESIUM_NATIVE_TEMP_DIR}\"
157+
)
158+
159+
file(MAKE_DIRECTORY "${CESIUM_NATIVE_TEMP_DIR}")
160+
148161
include(CTest)
149162
include(doctest)
150163
if(NOT CESIUM_TARGET_WASM)

CesiumNativeTests/include/CesiumNativeTests/writeTga.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include <CesiumGltf/ImageAsset.h>
44

5-
#include <string>
5+
#include <filesystem>
66

77
namespace CesiumNativeTests {
88
/**
@@ -15,5 +15,5 @@ namespace CesiumNativeTests {
1515
*/
1616
void writeImageToTgaFile(
1717
const CesiumGltf::ImageAsset& image,
18-
const std::string& outputPath);
19-
} // namespace CesiumNativeTests
18+
const std::filesystem::path& outputPath);
19+
} // namespace CesiumNativeTests

CesiumNativeTests/src/writeTga.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <filesystem>
1010
#include <fstream>
1111
#include <iostream>
12-
#include <string>
1312

1413
namespace CesiumNativeTests {
1514
namespace {
@@ -98,7 +97,7 @@ void writeTgaImpl(
9897

9998
void writeImageToTgaFile(
10099
const CesiumGltf::ImageAsset& image,
101-
const std::string& outputPath) {
100+
const std::filesystem::path& outputPath) {
102101
if (image.mipPositions.size() == 0) {
103102
writeTgaImpl(
104103
outputPath,
@@ -107,13 +106,13 @@ void writeImageToTgaFile(
107106
image.width,
108107
image.height);
109108
} else {
110-
std::filesystem::path outputPathParsed(outputPath);
111109
for (size_t i = 0; i < image.mipPositions.size(); i++) {
112-
std::filesystem::path thisPath(fmt::format(
113-
"{}-mip{}{}",
114-
outputPathParsed.stem().string(),
115-
i,
116-
outputPathParsed.extension().string()));
110+
std::filesystem::path thisPath =
111+
outputPath.parent_path() / (fmt::format(
112+
"{}-mip{}{}",
113+
outputPath.stem().string(),
114+
i,
115+
outputPath.extension().string()));
117116
writeTgaImpl(
118117
thisPath,
119118
image.pixelData.data() + image.mipPositions[i].byteOffset,
@@ -123,4 +122,4 @@ void writeImageToTgaFile(
123122
}
124123
}
125124
}
126-
} // namespace CesiumNativeTests
125+
} // namespace CesiumNativeTests

CesiumRasterOverlays/src/GeoJsonDocumentRasterOverlay.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,11 +369,12 @@ struct GeoJsonChildVisitor {
369369
for (const GeoJsonObject& feature : collection.features) {
370370
const GeoJsonFeature* pFeature = feature.getIf<GeoJsonFeature>();
371371
if (pFeature && pFeature->geometry) {
372-
const std::optional<VectorStyle>& geometryStyle = feature.getStyle();
372+
const std::optional<VectorStyle>& geometryStyle =
373+
pFeature->geometry->getStyle();
373374
const std::optional<VectorStyle>& featureStyle =
374375
geometryStyle ? geometryStyle : pFeature->style;
375376
const std::optional<VectorStyle>& collectionStyle =
376-
featureStyle ? featureStyle : pFeature->style;
377+
featureStyle ? featureStyle : collection.style;
377378
addPrimitivesToData(
378379
pFeature->geometry.get(),
379380
data,

0 commit comments

Comments
 (0)