UNPKG

mars-coord

Version:

[![English README](https://img.shields.io/badge/README-English-green)](./README_EN.md) [![npm version](https://img.shields.io/npm/v/mars-coord.svg?style=flat)](https://www.npmjs.com/package/mars-coord) [![License: MIT](https://img.shields.io/badge/License

86 lines (85 loc) 3.32 kB
/** * Represents a geographic coordinate as a tuple of longitude and latitude. * 用经度和纬度的元组表示地理坐标。 */ export type Coordinate = [longitude: number, latitude: number]; /** * Convert from WGS-84 to GCJ-02. * 将WGS-84转换为GCJ-02。 * WGS-84: standard world geodetic system 标准世界地理系统 * GCJ-02: Chinese national standard used by AMap(高德), Tencent maps(腾讯地图), Google Maps in China etc. 中国国家标准,由高德、腾讯地图、中国谷歌地图等使用。 */ export declare function wgs84_to_gcj02(coord: Coordinate): Coordinate; /** * Convert from GCJ-02 to WGS-84 * 将GCJ-02转换为WGS-84 * GCJ-02: Chinese national standard used by AMap(高德), Tencent maps(腾讯地图), Google Maps in China etc. 中国国家标准,由高德、腾讯地图、中国谷歌地图等使用。 * WGS-84: standard world geodetic system 标准世界地理系统 */ export declare function gcj02_to_wgs84(coord: Coordinate): Coordinate; /** * Convert from GCJ-02 to BD-09 * GCJ-02: Chinese national standard used by AMap(高德), Tencent maps(腾讯地图), Google Maps in China etc. * BD-09: coordinate system used by Baidu Maps(百度地图) */ export declare function gcj02_to_bd09(coord: Coordinate): Coordinate; /** * Convert from BD-09 to GCJ-02 * 将BD-09转换为GCJ-02 * BD-09: coordinate system used by Baidu Maps(百度地图) 百度地图使用的坐标系 * GCJ-02: Chinese national standard used by AMap(高德), Tencent maps(腾讯地图), Google Maps in China etc. 中国国家标准,由高德、腾讯地图、中国谷歌地图等使用。 */ export declare function bd09_to_gcj02(coord: Coordinate): Coordinate; /** * Convert from CGCS2000 to WGS-84 * 将CGCS2000转换为WGS-84 */ export declare const cgcs2000_to_wgs84: (coord: Coordinate) => Coordinate; /** * Convert from WGS-84 to CGCS2000 * 将WGS-84转换为CGCS2000 */ export declare const wgs84_to_cgcs2000: (coord: Coordinate) => Coordinate; /** * Convert from GCJ-02 to CGCS2000 * 将GCJ-02转换为CGCS2000 */ export declare const gcj02_to_cgcs2000: (coord: Coordinate) => Coordinate; /** * Convert from CGCS2000 to GCJ-02 * 将CGCS2000转换为GCJ-02 */ export declare const cgcs2000_to_gcj02: typeof gcj02_to_wgs84; /** * Convert from BD-09 to CGCS2000 * 将BD-09转换为CGCS2000 */ export declare const bd09_to_cgcs2000: (coord: Coordinate) => Coordinate; /** Convert from CGCS2000 to BD-09 */ export declare const cgcs2000_to_bd09: (coord: Coordinate) => Coordinate; /** * All supported coordinate types * 所有支持的坐标类型 */ export type CoordinateType = 'WGS84' | 'GCJ02' | 'AMAP' | 'QQ' | 'BD09' | 'BAIDU' | 'CGCS2000'; /** * All Coordinates * 所有坐标 */ export interface CoordinatesObject { WGS84: Coordinate; GCJ02: Coordinate; AMAP: Coordinate; QQ: Coordinate; BD09: Coordinate; BAIDU: Coordinate; CGCS2000: Coordinate; } /** * Convert coordinates from one type to all * 将坐标从一种类型转换为所有类型 * @param coord Coordinates to convert 需要转换的坐标 * @param coordType Type of coordinates 坐标类型 * @returns All coordinates 所有坐标 */ export declare function convertCoordinate(coord: Coordinate, coordType: CoordinateType): CoordinatesObject;