UNPKG

s2-tools

Version:

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

53 lines 2.03 kB
import type { S1Angle } from '../s1/angle'; import type { Point, Point3D } from '../'; /** Just another way of defining a standard 2D point. */ export type LonLat = Point; /** * 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 toS2Point(ll: LonLat): Point3D; /** * Convert a direction vector (not necessarily unit length) to an LonLat. * @param p - input direction vector * @returns - LonLat */ export declare function fromS2Point(p: Point3D): LonLat; /** * @param ll - input LonLat * @returns a lon-lat in radians */ export declare function toAngles(ll: LonLat): [S1Angle, S1Angle]; /** * @param ll - input lon-lat in degrees * @returns - ensures lon in [-180, 180], lat in [-90, 90] */ export declare function normalize(ll: LonLat): [number, number]; /** * 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 getDistance(a: LonLat, b: LonLat): number; //# sourceMappingURL=index.d.ts.map