mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-09-18 15:10:30 +00:00
Added types for geodesy latlon-spherical.js
This commit is contained in:
@@ -4,7 +4,7 @@ import {
|
||||
Dms,
|
||||
Vector3d,
|
||||
OsGridRef,
|
||||
LatLonEllipsoidal as LatLon } from 'geodesy';
|
||||
LatLonEllipsoidal as LatLon, LatLonSpherical } from 'geodesy';
|
||||
|
||||
/**
|
||||
* Mgrs
|
||||
@@ -115,3 +115,53 @@ OsGridRef.latLonToOsGrid(latlon);
|
||||
OsGridRef.osGridToLatLon(gridref);
|
||||
OsGridRef.osGridToLatLon(gridref, LatLon.datum.OSGB36);
|
||||
OsGridRef.parse('TG 51409 13177');
|
||||
|
||||
/**
|
||||
* LatLonSpherical
|
||||
*/
|
||||
const point1 = new LatLonSpherical(52.205, 0.119);
|
||||
const point2 = new LatLonSpherical(48.857, 2.351);
|
||||
|
||||
point1.distanceTo(point2); // 404.3 km
|
||||
point1.distanceTo(point2, 6371e3); // 404.3 km
|
||||
point1.bearingTo(point2); // 156.2°
|
||||
point1.finalBearingTo(point2); // 157.9°
|
||||
point1.midpointTo(point2); // 50.5363°N, 001.2746°E
|
||||
point1.intermediatePointTo(point2, 0.25); // 51.3721°N, 000.7073°E
|
||||
point1.destinationPoint(7794, 300.7); // 51.5135°N, 000.0983°W
|
||||
point1.destinationPoint(7794, 300.7, 6371e3); // 51.5135°N, 000.0983°W
|
||||
|
||||
const ctCurrent = new LatLonSpherical(53.2611, -0.7972);
|
||||
const ct1 = new LatLonSpherical(53.3206, -1.7297);
|
||||
const ct2 = new LatLonSpherical(53.1887, 0.1334);
|
||||
ctCurrent.crossTrackDistanceTo(ct1, ct2); // -307.5 m
|
||||
ctCurrent.crossTrackDistanceTo(ct1, ct2, 6371e3); // -307.5 m
|
||||
|
||||
point1.maxLatitude(156);
|
||||
|
||||
const rhumb1 = new LatLonSpherical(51.127, 1.338);
|
||||
const rhumb2 = new LatLonSpherical(50.964, 1.853);
|
||||
rhumb1.rhumbDistanceTo(rhumb2); // 40.31 km
|
||||
rhumb1.rhumbDistanceTo(rhumb2, 6371e3); // 40.31 km
|
||||
rhumb1.rhumbBearingTo(rhumb2); // 116.7°
|
||||
rhumb1.rhumbDestinationPoint(40300, 116.7); // 50.9642°N, 001.8530°E
|
||||
rhumb1.rhumbDestinationPoint(40300, 116.7, 6371e3); // 50.9642°N, 001.8530°E
|
||||
rhumb1.rhumbMidpointTo(rhumb2); // 51.0455°N, 001.5957°E
|
||||
|
||||
const eq1 = new LatLonSpherical(52.205, 0.119);
|
||||
const eq2 = new LatLonSpherical(52.205, 0.119);
|
||||
eq1.equals(eq2); // true
|
||||
|
||||
eq1.toString();
|
||||
eq1.toString('dm');
|
||||
eq1.toString('d', 0);
|
||||
|
||||
// Static functions
|
||||
const brng1 = 108.547;
|
||||
const brng2 = 32.435;
|
||||
LatLonSpherical.intersection(point1, brng1, point2, brng2); // 50.9078°N, 004.5084°E
|
||||
LatLonSpherical.crossingParallels(point1, point2, 30);
|
||||
|
||||
const polygon = [new LatLonSpherical(0, 0), new LatLonSpherical(1, 0), new LatLonSpherical(0, 1)];
|
||||
LatLonSpherical.areaOf(polygon); // 6.18e9 m²
|
||||
LatLonSpherical.areaOf(polygon, 6371e3); // 6.18e9 m²
|
||||
|
||||
Vendored
+25
@@ -1,6 +1,7 @@
|
||||
// Type definitions for geodesy 1.1
|
||||
// Project: https://github.com/chrisveness/geodesy
|
||||
// Definitions by: Denis Carriere <https://github.com/DenisCarriere>
|
||||
Gilbert Handy <https://github.com/HandyG52>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export type format = 'd' | 'dm' | 'dms';
|
||||
@@ -147,3 +148,27 @@ export class LatLonEllipsoidal {
|
||||
static datum: Datums;
|
||||
static ellipsoid: Ellipsoids;
|
||||
}
|
||||
|
||||
export class LatLonSpherical {
|
||||
lat: number;
|
||||
lon: number;
|
||||
constructor(lat: number, lon: number)
|
||||
distanceTo(point: LatLonSpherical, radius?: number): number;
|
||||
bearingTo(point: LatLonSpherical): number;
|
||||
finalBearingTo(point: LatLonSpherical): number;
|
||||
midpointTo(point: LatLonSpherical): number;
|
||||
intermediatePointTo(point: LatLonSpherical, fraction: number): LatLonSpherical;
|
||||
destinationPoint(distance: number, bearing: number, radius?: number): LatLonSpherical;
|
||||
static intersection(point1: LatLonSpherical, bearing1: number, point2: LatLonSpherical, bearing2: number): LatLonSpherical;
|
||||
crossTrackDistanceTo(pathStart: LatLonSpherical, pathEnd: LatLonSpherical, radius?: number): number;
|
||||
maxLatitude(bearing: number): number;
|
||||
static crossingParallels(point1: LatLonSpherical, point2: LatLonSpherical, latitude: number): any;
|
||||
rhumbDistanceTo(point: LatLonSpherical, radius?: number): number;
|
||||
rhumbBearingTo(point: LatLonSpherical): number;
|
||||
rhumbDestinationPoint(distance: number, bearing: number, radius?: number): LatLonSpherical;
|
||||
rhumbMidpointTo(point: LatLonSpherical): LatLonSpherical;
|
||||
equals(point: LatLonSpherical): boolean;
|
||||
static areaOf(polygon: LatLonSpherical[], radius?: number): number;
|
||||
toString(format?: string, dp?: number): string;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user