leaflet.geodesic
Version:
Add-on to draw geodesic lines with leaflet
82 lines (81 loc) • 3.4 kB
TypeScript
import L from "leaflet";
export interface GeodesicOptions extends L.PolylineOptions {
wrap?: boolean;
steps?: number;
radius?: number;
}
export interface WGS84Vector extends L.LatLngLiteral {
bearing: number;
}
export interface GeoDistance {
distance: number;
initialBearing: number;
finalBearing: number;
}
export declare class GeodesicCore {
readonly options: GeodesicOptions;
readonly ellipsoid: {
a: number;
b: number;
f: number;
};
constructor(options?: GeodesicOptions);
toRadians(degree: number): number;
toDegrees(radians: number): number;
/**
* implements scientific modulus
* source: http://www.codeavenger.com/2017/05/19/JavaScript-Modulo-operation-and-the-Caesar-Cipher.html
* @param n
* @param p
* @return
*/
mod(n: number, p: number): number;
/**
* source: https://github.com/chrisveness/geodesy/blob/master/dms.js
* @param degrees arbitrary value
* @return degrees between 0..360
*/
wrap360(degrees: number): number;
/**
* general wrap function with arbitrary max value
* @param degrees arbitrary value
* @param max
* @return degrees between `-max`..`+max`
*/
wrap(degrees: number, max?: number): number;
/**
* Vincenty direct calculation.
* based on the work of Chris Veness (https://github.com/chrisveness/geodesy)
* source: https://github.com/chrisveness/geodesy/blob/master/latlon-ellipsoidal-vincenty.js
*
* @param start starting point
* @param bearing initial bearing (in degrees)
* @param distance distance from starting point to calculate along given bearing in meters.
* @param maxInterations How many iterations can be made to reach the allowed deviation (`ε`), before an error will be thrown.
* @return Final point (destination point) and bearing (in degrees)
*/
direct(start: L.LatLng, bearing: number, distance: number, maxInterations?: number): WGS84Vector;
/**
* Vincenty inverse calculation.
* based on the work of Chris Veness (https://github.com/chrisveness/geodesy)
* source: https://github.com/chrisveness/geodesy/blob/master/latlon-ellipsoidal-vincenty.js
*
* @param start Latitude/longitude of starting point.
* @param dest Latitude/longitude of destination point.
* @return Object including distance, initialBearing, finalBearing.
*/
inverse(start: L.LatLng, dest: L.LatLng, maxInterations?: number, mitigateConvergenceError?: boolean): GeoDistance;
/**
* Returns the point of intersection of two paths defined by position and bearing.
* This calculation uses a spherical model of the earth. This will lead to small errors compared to an ellipsiod model.
* based on the work of Chris Veness (https://github.com/chrisveness/geodesy)
* source: https://github.com/chrisveness/geodesy/blob/master/latlon-spherical.js
*
* @param firstPos 1st path: position and bearing
* @param firstBearing
* @param secondPos 2nd path: position and bearing
* @param secondBearing
*/
intersection(firstPos: L.LatLng, firstBearing: number, secondPos: L.LatLng, secondBearing: number): L.LatLng | null;
midpoint(start: L.LatLng, dest: L.LatLng): L.LatLng;
}