full frontend refactor
This commit is contained in:
42
ui/src/utils/coordinates.js
Normal file
42
ui/src/utils/coordinates.js
Normal file
@@ -0,0 +1,42 @@
|
||||
// ============================================================================
|
||||
// COORDINATE & DISTANCE FORMATTING UTILITIES
|
||||
// ============================================================================
|
||||
|
||||
/**
|
||||
* Format coordinate to 6 decimal places (±11cm precision)
|
||||
*/
|
||||
export function formatCoordinate(value, type) {
|
||||
const dir = type === 'lat'
|
||||
? (value >= 0 ? 'N' : 'S')
|
||||
: (value >= 0 ? 'E' : 'W');
|
||||
return `${Math.abs(value).toFixed(6)}°${dir}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format distance in meters or feet based on unit preference
|
||||
*/
|
||||
export function formatDistance(meters, useImperial = false) {
|
||||
if (useImperial) {
|
||||
const feet = meters * 3.28084;
|
||||
if (feet < 5280) {
|
||||
return `${feet.toFixed(1)} ft`;
|
||||
} else {
|
||||
const miles = feet / 5280;
|
||||
return `${miles.toFixed(2)} mi`;
|
||||
}
|
||||
} else {
|
||||
if (meters < 1000) {
|
||||
return `${meters.toFixed(1)} m`;
|
||||
} else {
|
||||
const km = meters / 1000;
|
||||
return `${km.toFixed(2)} km`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Format bearing angle
|
||||
*/
|
||||
export function formatBearing(degrees) {
|
||||
return `${degrees.toFixed(1)}°`;
|
||||
}
|
||||
Reference in New Issue
Block a user