FEAT - FOUNDRY: activate sector workspace
This commit is contained in:
@@ -4,15 +4,19 @@ import {
|
||||
ArcType,
|
||||
ApproximateTerrainHeights,
|
||||
Cartesian3,
|
||||
Ellipsoid,
|
||||
GroundPolylineGeometry,
|
||||
Matrix4,
|
||||
Math as CesiumMath,
|
||||
PolylineGeometry,
|
||||
Transforms,
|
||||
} from "cesium";
|
||||
import {
|
||||
alignedGridValues,
|
||||
boundedAngularParts,
|
||||
fixedGridOrigin,
|
||||
geodeticRectangleAreaSquareMeters,
|
||||
geodeticToLocalGridPlane,
|
||||
graticuleGranularity,
|
||||
graticuleLinePlan,
|
||||
graticuleMajorTileAt,
|
||||
@@ -42,6 +46,7 @@ import {
|
||||
localParentSector,
|
||||
localSectorAreaSquareMeters,
|
||||
localSectorAt,
|
||||
localSectorAtGeodetic,
|
||||
localSectorBounds,
|
||||
localSectorNeighbors,
|
||||
localSectorSummary,
|
||||
@@ -108,6 +113,30 @@ test("local sectors use half-open floor boundaries on both sides of the ENU orig
|
||||
);
|
||||
});
|
||||
|
||||
test("WGS84 positions use the same tangent-plane address as Cesium sector picking", () => {
|
||||
const origin = Cartesian3.fromDegrees(localDefinition.originLongitude, localDefinition.originLatitude, 0);
|
||||
const inverseEnu = Matrix4.inverse(Transforms.eastNorthUpToFixedFrame(origin), new Matrix4());
|
||||
const point = { longitude: 37.645, latitude: 55.773 };
|
||||
const worldPosition = Cartesian3.fromDegrees(point.longitude, point.latitude, 0);
|
||||
const surface = Ellipsoid.WGS84.scaleToGeodeticSurface(worldPosition, new Cartesian3());
|
||||
const normal = Ellipsoid.WGS84.geodeticSurfaceNormal(surface, new Cartesian3());
|
||||
const localSurface = Matrix4.multiplyByPoint(inverseEnu, surface, new Cartesian3());
|
||||
const localNormal = Matrix4.multiplyByPointAsVector(inverseEnu, normal, new Cartesian3());
|
||||
const normalScale = -localSurface.z / localNormal.z;
|
||||
const expected = {
|
||||
eastMeters: localSurface.x + localNormal.x * normalScale,
|
||||
northMeters: localSurface.y + localNormal.y * normalScale,
|
||||
};
|
||||
const actual = geodeticToLocalGridPlane(point, localDefinition);
|
||||
|
||||
assert.ok(Math.abs(actual.eastMeters - expected.eastMeters) < 1e-6);
|
||||
assert.ok(Math.abs(actual.northMeters - expected.northMeters) < 1e-6);
|
||||
assert.equal(
|
||||
localSectorAtGeodetic(point, localDefinition).id,
|
||||
localSectorAt(expected, localDefinition).id,
|
||||
);
|
||||
});
|
||||
|
||||
test("local sector IDs and bounds stay stable across calls and normalized equivalent origins", () => {
|
||||
const first = localSectorAt({ eastMeters: -1, northMeters: 2_500 }, localDefinition);
|
||||
const second = localSectorAt({ eastMeters: -1, northMeters: 2_500 }, {
|
||||
|
||||
Reference in New Issue
Block a user