Skip to content

Commit

Permalink
tile.ts: fix lat lng display
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Geihs committed Mar 30, 2024
1 parent 72f7a40 commit 7d71655
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/ui/tile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,23 @@ export function initTileModal(viewer: Viewer, tiles: TileEntity[], earth: EARTH)

function formatLatLng(lat: number, lng: number): string {
const precision = 3;
return `${Math.toDegrees(lat).toFixed(precision)}°N ${Math.toDegrees(lng).toFixed(precision)}°E`;
const latDeg = (() => {
const latDeg = Math.toDegrees(lat);
if (latDeg >= 0) {
return `${latDeg.toFixed(precision)}°N`
} else {
return `${(latDeg * -1).toFixed(precision)}°S`
}
})();
const lngDeg = (() => {
const lngDeg = Math.toDegrees(lng);
if (lngDeg >= 0) {
return `${lngDeg.toFixed(precision)}°E`
} else {
return `${(lngDeg * -1).toFixed(precision)}°W`
}
})();
return `${latDeg} ${lngDeg}`;
}

function formatCoordinates(coords: number[]): string {
Expand Down

0 comments on commit 7d71655

Please sign in to comment.