s2-tools
Version:
A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.
227 lines • 8.67 kB
TypeScript
import type { S1Angle } from '../s1/angle';
import type { Face, Point3D, S2CellId } from '../';
/**
* Convert a lon-lat coord to an XYZ Point using the left-hand-rule
* @param lon The longitude in degrees
* @param lat The latitude in degrees
* @returns The XYZ Point
*/
export declare function fromLonLat(lon: number, lat: number): Point3D;
/**
* Convert a lon-lat coord to an XYZ Point using the right-hand-rule.
* This function takes longitude and latitude as input and returns the corresponding XYZ coordinates.
* @param lon The longitude in degrees.
* @param lat The latitude in degrees.
* @returns The XYZ Point representing the provided longitude and latitude.
*/
export declare function fromLonLatGL(lon: number, lat: number): Point3D;
/**
* Convert a u-v coordinate to an XYZ Point.
* @param face - The face of the S2 cell.
* @param u - The u-coordinate on the face.
* @param v - The v-coordinate on the face.
* @returns The XYZ Point representing the given u-v coordinates.
*/
export declare function fromUV(face: Face, u: number, v: number): Point3D;
/**
* Convert an s-t coordinate to an XYZ Point.
* @param face - The face of the S2 cell.
* @param s - The s-coordinate on the face.
* @param t - The t-coordinate on the face.
* @returns The XYZ Point representing the given s-t coordinates.
*/
export declare function fromST(face: Face, s: number, t: number): Point3D;
/**
* Convert an i-j coordinate to an XYZ Point.
* @param face - The face of the S2 cell.
* @param i - The i-coordinate on the face.
* @param j - The j-coordinate on the face.
* @returns The XYZ Point representing the given i-j coordinates.
*/
export declare function fromIJ(face: Face, i: number, j: number): Point3D;
/**
* Convert an S2CellID to an XYZ Point.
* @param id - The S2CellID to convert.
* @returns The XYZ Point representing the given S2CellID.
*/
export declare function fromS2CellID(id: S2CellId): Point3D;
/**
* Convert an Face-U-V coord to an XYZ Point using the right-hand-rule
* @param face - The face of the S2 cell.
* @param u - The u-coordinate on the face.
* @param v - The v-coordinate on the face.
* @returns The XYZ Point representing the given Face-U-V coordinates.
*/
export declare function fromUVGL(face: Face, u: number, v: number): Point3D;
/**
* Convert an Face-S-T coord to an XYZ Point using the right-hand-rule
* @param face - The face of the S2 cell.
* @param s - The s-coordinate on the face.
* @param t - The t-coordinate on the face.
* @returns The XYZ Point representing the given Face-S-T coordinates.
*/
export declare function fromSTGL(face: Face, s: number, t: number): Point3D;
/**
* Convert an XYZ Point to a Face-U-V coord
* @param xyz - The XYZ Point to convert.
* @returns - The Face-U-V coordinates representing the given XYZ Point.
*/
export declare function toUV(xyz: Point3D): [face: Face, u: number, v: number];
/**
* Convert an XYZ Point to a Face-S-T coord
* @param xyz - The XYZ Point to convert.
* @returns - The Face-S-T coordinates representing the given XYZ Point.
*/
export declare function toST(xyz: Point3D): [face: Face, s: number, t: number];
/**
* Convert an XYZ Point to a Face-I-J coord
* @param xyz - The XYZ Point to convert.
* @param level - The zoom level of the result. If not provided, the result will have 30 bits of precision.
* @returns The Face-I-J coordinates representing the given XYZ Point.
*/
export declare function toIJ(xyz: Point3D, level?: number): [face: Face, i: number, j: number];
/**
* Convert an XYZ Point to a lon-lat coord
* @param xyz - The XYZ Point to convert.
* @returns The lon-lat coordinates representing the given XYZ Point.
*/
export declare function toLonLat(xyz: Point3D): [lon: number, lat: number];
/**
* Convert an XYZ Point to an S2CellID
* @param xyz - The XYZ Point to convert.
* @returns The S2CellID representing the given XYZ Point.
*/
export declare function toS2CellID(xyz: Point3D): S2CellId;
/**
* Take an XYZ Point and add another XYZ Point to it
* @param a - The XYZ Point to add to.
* @param b - The XYZ Point to add.
* @returns - The XYZ Point with the added XYZ Point.
*/
export declare function add(a: Point3D, b: Point3D): Point3D;
/**
* Take an XYZ Point and add another XYZ Point to it
* @param a - The XYZ Point to add to.
* @param b - The XYZ Point to add.
*/
export declare function addMut(a: Point3D, b: Point3D): void;
/**
* Take an XYZ Point and add an n to each component
* @param xyz - The XYZ Point to add to.
* @param n - The amount to add.
* @returns - The XYZ Point with the added amount.
*/
export declare function addScalar(xyz: Point3D, n: number): Point3D;
/**
* Take an XYZ Point and subtract another XYZ Point from it
* @param a - The XYZ Point to subtract from.
* @param b - The XYZ Point to subtract.
* @returns - The XYZ Point with the subtracted XYZ Point.
*/
export declare function sub(a: Point3D, b: Point3D): Point3D;
/**
* Take an XYZ Point and subtract an n from each component
* @param xyz - The XYZ Point to subtract from.
* @param n - The amount to subtract.
* @returns - The XYZ Point with the subtracted amount.
*/
export declare function subScalar(xyz: Point3D, n: number): Point3D;
/**
* Take an XYZ Point and multiply it by another XYZ Point
* @param a - The XYZ Point to multiply.
* @param b - The XYZ Point to multiply.
* @returns - The XYZ Point with the multiplied XYZ Point.
*/
export declare function mul(a: Point3D, b: Point3D): Point3D;
/**
* Take an XYZ Point and multiply each component by n
* @param xyz - The XYZ Point to multiply.
* @param n - The amount to multiply.
* @returns - The XYZ Point with the multiplied amount.
*/
export declare function mulScalar(xyz: Point3D, n: number): Point3D;
/**
* Take an XYZ Point and divide it by another XYZ Point
* @param a - The XYZ Point to divide.
* @param b - The XYZ Point to divide by.
* @returns - The XYZ Point with the multiplied XYZ Point.
*/
export declare function div(a: Point3D, b: Point3D): Point3D;
/**
* Take an XYZ Point and divide each component by n
* @param xyz - The XYZ Point to divide.
* @param n - The amount to divide by.
* @returns - The XYZ Point with the multiplied amount.
*/
export declare function divScalar(xyz: Point3D, n: number): Point3D;
/**
* Take an XYZ Point and divide each component by n
* @param xyz - The XYZ Point to divide.
* @param n - The amount to divide by.
*/
export declare function divMutScalar(xyz: Point3D, n: number): void;
/**
* Take an XYZ Point and divide each component by its length
* @param xyz - The XYZ Point to divide.
* @returns - The XYZ Point with the divided amount.
*/
export declare function normalize(xyz: Point3D): Point3D;
/**
* Get the length of the XYZ Point
* @param xyz - The XYZ Point
* @returns - The length of the XYZ Point
*/
export declare function length(xyz: Point3D): number;
/**
* Get the squared length of the XYZ Point with itself
* @param xyz - The XYZ Point
* @returns - The squared length of the XYZ Point
*/
export declare function norm2(xyz: Point3D): number;
/**
* Invert the XYZ Point
* @param xyz - The XYZ Point
* @returns - The inverted XYZ Point
*/
export declare function invert(xyz: Point3D): Point3D;
/**
* dot returns the standard dot product of a and b.
* @param a - The first XYZ Point
* @param b - The second XYZ Point
* @returns - The dot product of the two XYZ Points
*/
export declare function dot(a: Point3D, b: Point3D): number;
/**
* Get the corss product of two XYZ Points
* @param a - The first XYZ Point
* @param b - The second XYZ Point
* @returns - The cross product of the two XYZ Points
*/
export declare function cross(a: Point3D, b: Point3D): Point3D;
/**
* Get the distance between two XYZ Points using Earth's size
* @param a - The first XYZ Point
* @param b - The second XYZ Point
* @returns - The distance between the two XYZ Points
*/
export declare function distanceEarth(a: Point3D, b: Point3D): number;
/**
* Get the distance between two XYZ Points
* @param a - The first XYZ Point
* @param b - The second XYZ Point
* @returns - The raw distance between the two XYZ Points. Highly inaccurate for large distances
*/
export declare function distance(a: Point3D, b: Point3D): number;
/**
* @param a - The first XYZ Point
* @param b - The second XYZ Point
* @returns - The angle between the two XYZ Points
*/
export declare function angle(a: Point3D, b: Point3D): S1Angle;
/**
* Find the S2 Hilbert Face of the XYZ Point [0, 6)
* @param xyz - The XYZ Point
* @returns - The S2 Hilbert Face
*/
export declare function getFace(xyz: Point3D): number;
//# sourceMappingURL=point.d.ts.map