admin/helpers/mapir.ts
alisaza e1eaf5eff5 feat: initial ghabilee-admin backoffice app
Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js
app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
2026-09-05 13:12:59 +03:30

22 lines
660 B
TypeScript

/** Env + coords only — no mapbox import for lighter non-map pages */
export function getPublicMapApiKey(): string {
return (process.env.NEXT_PUBLIC_MAP_API_KEY || '').trim()
}
/** Mapbox / Map.ir: [lng, lat]; form uses { lat, lng } */
export function toMapirLngLat(lat: number, lng: number): [number, number] {
return [lng, lat]
}
/** Backend geo fields: max 6 decimal places */
export const GEO_COORDINATE_DECIMALS = 6
export function roundGeoCoordinate(value: number, decimals: number = GEO_COORDINATE_DECIMALS): number {
if (!Number.isFinite(value)) return value
const factor = 10 ** decimals
return Math.round(value * factor) / factor
}