UNPKG

gis-tools-ts

Version:

A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.

62 lines 2.61 kB
import type { S1Angle } from '../s1/angle.js'; import type { MValue, Properties, VectorPoint } from '../index.js'; /** Just another way of defining a standard 2D point. */ export type LonLat<M extends MValue = Properties> = VectorPoint<M>; /** * Converts an LonLat to the equivalent unit-length vector. Unnormalized * values (see Normalize()) are wrapped around the sphere as would be expected * based on their definition as spherical angles. So for example the * following pairs yield equivalent points (modulo numerical error): * (90.5, 10) =~ (89.5, -170) * (a, b) =~ (a + 360 * n, b) * The maximum error in the result is 1.5 * DBL_EPSILON. (This does not * include the error of converting degrees, E5, E6, or E7 to radians.) * * Can be used just like an S2Point constructor. For example: * S2Cap cap; * cap.AddPoint(S2Point(latlon)); * @param ll - input LonLat * @returns - equivalent unit-length vector 3D point */ export declare function llToS2Point<M extends MValue = Properties>(ll: LonLat<M>): VectorPoint<M>; /** * Convert a direction vector (not necessarily unit length) to an LonLat. * @param p - input direction vector * @returns - LonLat */ export declare function llFromS2Point<M extends MValue = Properties>(p: VectorPoint<M>): LonLat<M>; /** * Converts an LonLat to the equivalent spherical angles. * @param ll - input LonLat * @returns a lon-lat in radians */ export declare function llToAngles(ll: LonLat): [S1Angle, S1Angle]; /** * Ensures that lon is in [-180, 180] and lat is in [-90, 90]. Updates the input in place * @param ll - input lon-lat in degrees * @returns - the input lon-lat but normalized */ export declare function llNormalize<M extends MValue = Properties>(ll: LonLat<M>): LonLat<M>; /** * Returns the distance (measured along the surface of the sphere) to the * given LonLat, implemented using the Haversine formula. This is * equivalent to * * S1Angle(ToPoint(), o.ToPoint()) * * except that this function is slightly faster, and is also somewhat less * accurate for distances approaching 180 degrees (see s1angle.h for * details). Both LngLats must be normalized. * @param a - input LonLat * @param b - input LonLat * @returns - distance in radians */ export declare function llGetDistance(a: LonLat, b: LonLat): number; /** * Returns the bearing from the first point to the second point. * @param a - first LonLat * @param b - second LonLat to find the bearing to * @returns - bearing in degrees */ export declare function llGetBearing(a: LonLat, b: LonLat): number; //# sourceMappingURL=index.d.ts.map