gis-tools-ts
Version:
A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.
72 lines • 2.39 kB
TypeScript
import type { LonLat } from '../geometry/index.js';
/**
* # Orthodrome
*
* ## Description
* Represents an orthodrome, which is the shortest path between two points on a sphere.
* [Learn more here](http://www.movable-type.co.uk/scripts/latlong.html)
*
* ## Usage
* ```ts
* import { Orthodrome } from 'gis-tools-ts'
*
* // starting at lon-lat (-60, -40) and ending at (20, 10)
* const orthodrome = new Orthodrome(-60, -40, 20, 10);
* // OR create from VectorPoints
* const orthodrome = Orthodrome.fromPoints({ x: -60, y: -40 }, { x: 20, y: 10 });
* // { x: -39.13793657428956, y: -33.72852197561652 }
* const intermediatePoint = orthodrome.intermediatePoint(0.2);
* // Distance in KM: 1.5514126949321814
* const distance = orthodrome.distanceTo();
* // get the bearing of the first point to the second in degrees
* const bearing = orthodrome.bearing();
* ```
*
* ## Links
* - http://www.movable-type.co.uk/scripts/latlong.html
*/
export declare class Orthodrome {
/** start longitude in radians */
readonly lon1: number;
/** start latitude in radians */
readonly lat1: number;
/** end longitude in radians */
readonly lon2: number;
/** end latitude in radians */
readonly lat2: number;
/** distance property */
readonly a: number;
/** distance property */
readonly dist: number;
/**
* @param startLon - start longitude in degrees
* @param startLat - start latitude in degrees
* @param endLon - end longitude in degrees
* @param endLat - end latitude in degrees
*/
constructor(startLon: number, startLat: number, endLon: number, endLat: number);
/**
* Create an orthodrome from two points
* @param p1 - start point
* @param p2 - end point
* @returns - orthodrome
*/
static fromPoints(p1: LonLat, p2: LonLat): Orthodrome;
/**
* input t 0->1. Find a point along the orthodrome.
* @param t - distance along the orthodrome to find
* @returns [lon, lat]
*/
intermediatePoint(t: number): LonLat;
/**
* @returns the bearing in degrees between the two points
*/
bearing(): number;
/**
* Finds the distance between the two points in kilometers
* projected normalized (0->1)
* @returns - total distance between the two points
*/
distanceTo(): number;
}
//# sourceMappingURL=orthodrome.d.ts.map