s2-tools
Version:
A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.
151 lines • 5.54 kB
TypeScript
import type { BBox, Point, Point3D } from '../';
/** 900913 (Web Mercator) constant */
export declare const A = 6378137;
/** 900913 (Web Mercator) max extent */
export declare const MAXEXTENT = 20037508.342789244;
/** 900913 (Web Mercator) maximum latitude */
export declare const MAXLAT = 85.0511287798;
/** The source of the coordinate inputs */
export type Sources = 'WGS84' | '900913';
/**
* Convert Longitude and Latitude to a mercator pixel coordinate
* @param ll - the longitude and latitude
* @param zoom - the zoom level
* @param antiMeridian - true if you want to use the antimeridian
* @param tileSize - in pixels
* @returns - the mercator pixel
*/
export declare function llToPX(ll: Point, zoom: number, antiMeridian?: boolean, tileSize?: number): Point;
/**
* Convert mercator pixel coordinates to Longitude and Latitude
* @param px - the mercator pixel
* @param zoom - the zoom level
* @param tileSize - in pixels
* @returns - the longitude and latitude
*/
export declare function pxToLL(px: Point, zoom: number, tileSize?: number): Point;
/**
* Convert Longitude and Latitude to a mercator x-y coordinates
* @param ll - the longitude and latitude
* @returns - the mercator pixel
*/
export declare function llToMerc(ll: Point): Point;
/**
* Convert mercator x-y coordinates to Longitude and Latitude
* @param merc - the mercator pixel
* @returns - the longitude and latitude
*/
export declare function mercToLL(merc: Point): Point;
/**
* Convert a pixel coordinate to a tile x-y coordinate
* @param px - the pixel
* @param tileSize - in pixels
* @returns - the tile x-y
*/
export declare function pxToTile(px: Point, tileSize?: number): Point;
/**
* Convert a tile x-y-z to a bbox of the form `[w, s, e, n]`
* @param tile - the tile
* @param tileSize - in pixels
* @returns - the bbox
*/
export declare function tilePxBounds(tile: Point3D, tileSize?: number): BBox;
/**
* Convert a lat-lon and zoom to the tile's x-y coordinates
* @param ll - the lat-lon
* @param zoom - the zoom
* @param tileSize - in pixels
* @returns - the tile x-y
*/
export declare function llToTile(ll: Point, zoom: number, tileSize?: number): Point;
/**
* given a lon-lat and tile, find the offset in pixels
* @param ll - the lon-lat
* @param tile - the tile
* @param tileSize - in pixels
* @returns - the tile x-y
*/
export declare function llToTilePx(ll: Point, tile: Point3D, tileSize?: number): Point;
/**
* Convert a bbox of the form `[w, s, e, n]` to a bbox of the form `[w, s, e, n]`
* The result can be in lon-lat (WGS84) or WebMercator (900913)
* If the input is in WebMercator (900913), the outSource should be set to 'WGS84'
* @param bbox - the bounding box to convert
* @param outSource - the output source
* @returns - the converted bbox
*/
export declare function convert(bbox: BBox, outSource: Sources): BBox;
/**
* Convert a tile x-y-z to a bbox of the form `[w, s, e, n]`
* The result can be in lon-lat (WGS84) or WebMercator (900913)
* The default result is in WebMercator (900913)
* @param x - the x tile position
* @param y - the y tile position
* @param zoom - the zoom level
* @param tmsStyle - if true, the y is inverted
* @param source - the source
* @param tileSize - in pixels
* @returns - the bounding box in WGS84
*/
export declare function xyzToBBOX(x: number, y: number, zoom: number, tmsStyle?: boolean, source?: Sources, tileSize?: number): BBox;
/**
* Convert a bbox of the form `[w, s, e, n]` to a tile's bounding box
* in the form of [minX, maxX, minY, maxY]
* The bbox can be in lon-lat (WGS84) or WebMercator (900913)
* The default expectation is in WebMercator (900913)
* @param bbox - the bounding box
* @param zoom - the zoom level
* @param tmsStyle - if true, the y is inverted
* @param source - the source
* @param tileSize - in pixels
* @returns - the tile's bounding box [minX, minY, maxX, maxY]
*/
export declare function bboxToXYZBounds(bbox: BBox, zoom: number, tmsStyle?: boolean, source?: Sources, tileSize?: number): BBox;
/**
* Convert longitude to mercator projection X-Value
* @param lng - in degrees
* @returns the X-Value
*/
export declare function mercatorXfromLng(lng: number): number;
/**
* Convert latitude to mercator projection Y-Value
* @param lat - in degrees
* @returns the Y-Value
*/
export declare function mercatorYfromLat(lat: number): number;
/**
* Convert altitude to mercator projection Z-Value
* @param altitude - in meters
* @param lat - in degrees
* @returns the Z-Value
*/
export declare function mercatorZfromAltitude(altitude: number, lat: number): number;
/**
* Convert mercator projection's X-Value to longitude
* @param x - in radians
* @returns the longitude
*/
export declare function lngFromMercatorX(x: number): number;
/**
* Convert mercator projection's Y-Value to latitude
* @param y - in radians
* @returns the latitude
*/
export declare function latFromMercatorY(y: number): number;
/**
* Convert mercator projection's Z-Value to altitude
* @param z - in meters
* @param y - in radians
* @returns the altitude
*/
export declare function altitudeFromMercatorZ(z: number, y: number): number;
/**
* Determine the Mercator scale factor for a given latitude, see
* https://en.wikipedia.org/wiki/Mercator_projection#Scale_factor
*
* At the equator the scale factor will be 1, which increases at higher latitudes.
* @param lat - in degrees
* @returns the scale factor
*/
export declare function mercatorLatScale(lat: number): number;
//# sourceMappingURL=coords.d.ts.map