standardize-geolocation
Version:
takes geolocations of different formats and outputs a standardized version
47 lines (46 loc) • 1.39 kB
TypeScript
export interface StandardizedGeolocation {
elevation?: number;
latitude: number;
longitude: number;
}
export declare type PointInput = string | number;
export interface GeoJSONPoint {
coordinates: PointInput[];
type: string;
}
export declare type WithElevation = {
alt: PointInput;
} | {
altitude: PointInput;
} | {
elev: PointInput;
} | {
elevation: PointInput;
};
export declare type WithLatitude = {
lat: PointInput;
} | {
latitude: PointInput;
};
export declare type WithLongitude = {
lon: PointInput;
} | {
lng: PointInput;
} | {
long: PointInput;
} | {
longitude: PointInput;
};
export declare type GeolocationInput = readonly PointInput[] | (Partial<WithElevation> & WithLatitude & WithLongitude) | {
location: GeolocationInput;
} | {
position: GeolocationInput;
} | GeoJSONPoint | {
geometry: GeoJSONPoint;
};
export declare function createPoint(rawLatitude: PointInput, rawLongitude: PointInput, rawElevation?: PointInput): StandardizedGeolocation;
export declare function getElevation(point: Partial<WithElevation>): PointInput;
export declare function getLatitude(point: WithLatitude): PointInput;
export declare function getLongitude(point: WithLongitude): PointInput;
export declare function standardizeGeolocation(point: GeolocationInput): StandardizedGeolocation;
export default standardizeGeolocation;