Skip to content

Commit

Permalink
Merge pull request #11190 from malaretv/czml-wgs84
Browse files Browse the repository at this point in the history
Be consistent about using Ellipsoid.WGS84 in CzmlDataSource
  • Loading branch information
ggetz committed Jul 31, 2023
2 parents 0ed67aa + be62a8e commit fc42af7
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Fixed issue where terrain with multiple layers was loading higher LOD tiles inconsistently. [#11312](https://github.com/CesiumGS/cesium/issues/11312)
- Fixed `OpenStreetMapImageryProvider` usage in comments, change default url and add `tile.openstreetmap.org` to `RequestScheduler.requestsByServer`. [#11407](https://github.com/CesiumGS/cesium/pull/11407)
- Fixed calculation of GroundPolyline bounding spheres in regions with negative terrain heights. [#11184](https://github.com/CesiumGS/cesium/pull/11184)
- Fixed `CzmlDataSource` in cases of custom `Ellipsoid.WGS84` definitions. [#11190](https://github.com/CesiumGS/cesium/pull/11190)
- Fixed mipmaps for textures using the `KHR_texture_transform` extension. [#11411](https://github.com/CesiumGS/cesium/pull/11411)

#### @cesium/widgets
Expand Down
10 changes: 6 additions & 4 deletions packages/engine/Source/DataSources/CzmlDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -1822,11 +1822,13 @@ function processPositionArrayPacketData(
packetData.array = Cartesian3.unpackArray(packetData.cartesian);
} else if (defined(packetData.cartographicRadians)) {
packetData.array = Cartesian3.fromRadiansArrayHeights(
packetData.cartographicRadians
packetData.cartographicRadians,
Ellipsoid.WGS84
);
} else if (defined(packetData.cartographicDegrees)) {
packetData.array = Cartesian3.fromDegreesArrayHeights(
packetData.cartographicDegrees
packetData.cartographicDegrees,
Ellipsoid.WGS84
);
}

Expand Down Expand Up @@ -1878,11 +1880,11 @@ function unpackCartesianArray(array) {
}

function unpackCartographicRadiansArray(array) {
return Cartesian3.fromRadiansArrayHeights(array);
return Cartesian3.fromRadiansArrayHeights(array, Ellipsoid.WGS84);
}

function unpackCartographicDegreesArray(array) {
return Cartesian3.fromDegreesArrayHeights(array);
return Cartesian3.fromDegreesArrayHeights(array, Ellipsoid.WGS84);
}

function processPositionArrayOfArraysPacketData(
Expand Down
57 changes: 53 additions & 4 deletions packages/engine/Specs/DataSources/CzmlDataSourceSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import {
LabelStyle,
ShadowMode,
VerticalOrigin,
Ellipsoid,
} from "../../index.js";

describe("DataSources/CzmlDataSource", function () {
Expand Down Expand Up @@ -148,17 +149,17 @@ describe("DataSources/CzmlDataSource", function () {
return array.slice(startIndex, startIndex + count);
}

function cartesianFromArrayDegrees(array, startIndex) {
function cartesianFromArrayDegrees(array, startIndex, ellipsoid) {
return Cartesian3.fromDegrees.apply(
null,
arraySubset(array, startIndex, 3)
[].concat(arraySubset(array, startIndex, 3), ellipsoid)
);
}

function cartesianFromArrayRadians(array, startIndex) {
function cartesianFromArrayRadians(array, startIndex, ellipsoid) {
return Cartesian3.fromRadians.apply(
null,
arraySubset(array, startIndex, 3)
[].concat(arraySubset(array, startIndex, 3), ellipsoid)
);
}

Expand Down Expand Up @@ -1317,6 +1318,31 @@ describe("DataSources/CzmlDataSource", function () {
});
});

it("can handle position specified as constant cartographicsDegrees with non-standard ellipsoid", function () {
const WGS84 = Ellipsoid.WGS84.clone();
Ellipsoid.WGS84 = new Ellipsoid(1737400, 1737400, 1737400);
const packet = {
position: {
cartographicDegrees: [34, 117, 10000],
},
};

return CzmlDataSource.load(makeDocument(packet)).then(function (
dataSource
) {
const entity = dataSource.entities.values[0];
const resultCartesian = entity.position.getValue(JulianDate.now());
expect(resultCartesian).toEqual(
cartesianFromArrayDegrees(
packet.position.cartographicDegrees,
0,
Ellipsoid.WGS84
)
);
Ellipsoid.WGS84 = WGS84;
});
});

it("can handle position specified as sampled cartographicsDegrees", function () {
const epoch = JulianDate.now();

Expand Down Expand Up @@ -1397,7 +1423,30 @@ describe("DataSources/CzmlDataSource", function () {
);
});
});
it("can handle position specified as constant cartographicRadians with non-standard ellipsoid", function () {
const WGS84 = Ellipsoid.WGS84.clone();
Ellipsoid.WGS84 = new Ellipsoid(1737400, 1737400, 1737400);
const packet = {
position: {
cartographicRadians: [1, 2, 10000],
},
};

return CzmlDataSource.load(makeDocument(packet)).then(function (
dataSource
) {
const entity = dataSource.entities.values[0];
const resultCartesian = entity.position.getValue(JulianDate.now());
expect(resultCartesian).toEqual(
cartesianFromArrayRadians(
packet.position.cartographicRadians,
0,
Ellipsoid.WGS84
)
);
Ellipsoid.WGS84 = WGS84;
});
});
it("can handle position specified as sampled cartographicRadians", function () {
const epoch = JulianDate.now();

Expand Down

0 comments on commit fc42af7

Please sign in to comment.