Repository navigation
Expand file tree
/
Copy pathgridBounds.ts
More file actions
72 lines (64 loc) · 2.2 KB
/
Copy pathgridBounds.ts
File metadata and controls
72 lines (64 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
* Official Romania TransDatRO SPG Grid Envelope Constants
* Derived from the union of:
* 1. Planimetric 2D Grid (etrs89_krasovschi42 in Stereo 70)
* 2. Vertical 1D Quasigeoid Grid (romhybqgeoid_cs1 in ETRS89)
* Extracted via tools/extract_spg_metadata.py from pytransdatro/grids/rom_grid3d_25.09.spg
*/
export const STEREO70_GRID_BOUNDS = {
minN: 213600.0,
maxN: 785640.0,
minE: 101260.0,
maxE: 890790.0,
};
export const ETRS89_GRID_BOUNDS = {
minLat: 43.30,
maxLat: 48.58,
minLon: 19.70,
maxLon: 30.30,
};
/** Canonical warning string constants matching backend API */
export const WARNING_OUT_OF_GRID = 'Out of grid';
export const WARNING_NO_DATA = 'No data on grid';
/**
* Coarse pre-flight envelope check for Stereo 70 coordinates (meters).
*/
export function isWithinStereo70Grid(northing: number, easting: number): boolean {
if (isNaN(northing) || isNaN(easting)) return false;
return (
northing >= STEREO70_GRID_BOUNDS.minN &&
northing <= STEREO70_GRID_BOUNDS.maxN &&
easting >= STEREO70_GRID_BOUNDS.minE &&
easting <= STEREO70_GRID_BOUNDS.maxE
);
}
/**
* Coarse pre-flight envelope check for ETRS89 coordinates (decimal degrees).
*/
export function isWithinETRS89Grid(lat: number, lon: number): boolean {
if (isNaN(lat) || isNaN(lon)) return false;
return (
lat >= ETRS89_GRID_BOUNDS.minLat &&
lat <= ETRS89_GRID_BOUNDS.maxLat &&
lon >= ETRS89_GRID_BOUNDS.minLon &&
lon <= ETRS89_GRID_BOUNDS.maxLon
);
}
/** Backward-compatible alias for MapView / PointConverter */
export const isInsideRomaniaGrid = isWithinETRS89Grid;
export const ROMANIA_GRID_BOUNDS = ETRS89_GRID_BOUNDS;
/**
* Returns true if the warning indicates that the coordinate cannot be transformed
* by the official SPG grid (either out-of-grid or no-data on grid cell).
*/
export function isUntransformableWarning(warning: string | null | undefined): boolean {
if (!warning) return false;
return warning === WARNING_OUT_OF_GRID || warning === WARNING_NO_DATA;
}
/**
* Returns true if the warning indicates out-of-grid condition.
*/
export function isOutOfGridWarning(warning: string | null | undefined): boolean {
if (!warning) return false;
return warning === WARNING_OUT_OF_GRID;
}