chore: import DH V2 D5.6.4 production baseline
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import {
|
||||
parseBoundingBox,
|
||||
validateGeoJsonGeometry,
|
||||
} from '../../src/asset-master/asset-geometry-validator';
|
||||
import { AssetGeometryType } from '../../src/database/entities';
|
||||
|
||||
test('accepts points and strips unsupported altitude values', () => {
|
||||
assert.deepEqual(validateGeoJsonGeometry({
|
||||
type: AssetGeometryType.POINT,
|
||||
coordinates: [-68.8458, -32.8895, 900],
|
||||
}), {
|
||||
type: AssetGeometryType.POINT,
|
||||
coordinates: [-68.8458, -32.8895],
|
||||
});
|
||||
});
|
||||
|
||||
test('rejects invalid lines and out-of-range coordinates', () => {
|
||||
assert.throws(() => validateGeoJsonGeometry({
|
||||
type: AssetGeometryType.LINESTRING,
|
||||
coordinates: [[-68, -32], [-68, -32]],
|
||||
}));
|
||||
assert.throws(() => validateGeoJsonGeometry({
|
||||
type: AssetGeometryType.POINT,
|
||||
coordinates: [-181, -32],
|
||||
}));
|
||||
});
|
||||
|
||||
test('requires closed, non-degenerate polygon rings', () => {
|
||||
assert.throws(() => validateGeoJsonGeometry({
|
||||
type: AssetGeometryType.POLYGON,
|
||||
coordinates: [[[-68, -32], [-67, -32], [-67, -33]]],
|
||||
}));
|
||||
assert.deepEqual(validateGeoJsonGeometry({
|
||||
type: AssetGeometryType.POLYGON,
|
||||
coordinates: [[
|
||||
[-68, -32], [-67, -32], [-67, -33], [-68, -32],
|
||||
]],
|
||||
}).type, AssetGeometryType.POLYGON);
|
||||
});
|
||||
|
||||
test('parses only ordered WGS84 bounding boxes', () => {
|
||||
assert.deepEqual(parseBoundingBox('-70,-35,-66,-31'), [-70, -35, -66, -31]);
|
||||
assert.throws(() => parseBoundingBox('-66,-31,-70,-35'));
|
||||
assert.throws(() => parseBoundingBox('-200,-35,-66,-31'));
|
||||
});
|
||||
Reference in New Issue
Block a user