terriajs
Version:
Geospatial data visualization platform.
60 lines (47 loc) • 1.8 kB
JavaScript
;
import Cartographic from "terriajs-cesium/Source/Core/Cartographic";
import EarthGravityModel1996 from "../../lib/Map/Vector/EarthGravityModel1996";
import gravityModel from "../../wwwroot/data/WW15MGH.DAC";
var describeIfSupported = EarthGravityModel1996.isSupported()
? describe
: xdescribe;
describeIfSupported("EarthGravityModel1996", function () {
var egm96;
beforeAll(function () {
egm96 = new EarthGravityModel1996(gravityModel);
});
// NGA calculator is here: http://earth-info.nga.mil/GandG/wgs84/gravitymod/egm96/intpt.html
it("produces a single result consistent with NGA calculator", async function () {
const height = await egm96.getHeight(0.0, 0.0);
expect(height).toBe(17.16);
});
it("produces multiple results consistent with NGA calculator", async function () {
var testData = [
// longitude, latitude, expected height
0.0, 89.74, 13.92, 180.0, 89.74, 13.49, -180.0, 89.74, 13.49, 0.0, -89.74,
-29.55, 180.0, -89.74, -30.11, -180.0, -89.74, -30.11, 0.15, 0.0, 17.12,
-0.15, 0.0, 17.17
];
var cartographics = [];
var i;
for (i = 0; i < testData.length; i += 3) {
cartographics.push(
Cartographic.fromDegrees(testData[i], testData[i + 1], 0.0)
);
}
await egm96.getHeights(cartographics);
for (let i = 0; i < cartographics.length; ++i) {
expect(
Math.abs(cartographics[i].height - testData[i * 3 + 2])
).toBeLessThan(0.01);
}
});
it("works at the north pole", async function () {
const height = await egm96.getHeight(0.0, Math.PI);
expect(height).toBe(13.61);
});
it("works at the south pole", async function () {
const height = await egm96.getHeight(0.0, -Math.PI);
expect(height).toBe(-29.53);
});
});