Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be consistent about using Ellipsoid.WGS84 in CzmlDataSource #11190

Merged
merged 7 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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