From 683705f437c943e8cead58ba8f9c2e067d1d61c6 Mon Sep 17 00:00:00 2001 From: ipcjs Date: Tue, 10 Sep 2019 17:02:36 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E6=B7=BB=E5=8A=A0ts=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E5=A3=B0=E6=98=8E,=20=E4=BF=AE=E6=94=B9=E5=9B=BD=E5=86=85?= =?UTF-8?q?=E5=8C=BA=E5=9F=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + index.d.ts | 28 +++++++++ index.js | 163 ++++++++++++++++++++++++++++++--------------------- package.json | 1 + 4 files changed, 127 insertions(+), 66 deletions(-) create mode 100644 index.d.ts diff --git a/.gitignore b/.gitignore index ef772a6..322ed27 100644 --- a/.gitignore +++ b/.gitignore @@ -73,3 +73,4 @@ $RECYCLE.BIN/ # Windows shortcuts *.lnk +/package-lock.json \ No newline at end of file diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..d697ece --- /dev/null +++ b/index.d.ts @@ -0,0 +1,28 @@ +type LngLatTuple = [number, number] +/** @deprecated 换用小驼峰风格命名 */ +export function bd09togcj02(lng: number, lat: number): LngLatTuple +/** @deprecated 换用小驼峰风格命名 */ +export function gcj02tobd09(lng: number, lat: number): LngLatTuple +/** @deprecated 换用小驼峰风格命名 */ +export function wgs84togcj02(lng: number, lat: number): LngLatTuple +/** @deprecated 换用小驼峰风格命名 */ +export function gcj02towgs84(lng: number, lat: number): LngLatTuple + +/** BD09 => GCJ02 */ +export function bd09ToGcj02(lng: number, lat: number): LngLatTuple +/** GCJ02 => BD09 */ +export function gcj02ToBd09(lng: number, lat: number): LngLatTuple +/** WGS84 => GCJ02 */ +export function wgs84ToGcj02(lng: number, lat: number): LngLatTuple +/** GCJ02 => WGS84 */ +export function gcj02ToWgs84(lng: number, lat: number): LngLatTuple +/** + * BD09 => WGS84 + * 是使用其他方法"拼"出来的, 误差较大 + */ +export function bd09ToWgs84(lng: number, lat: number): LngLatTuple +/** + * WGS84 => BD09 + * 是使用其他方法"拼"出来的, 误差较大 + */ +export function wgs84ToBd09(lng: number, lat: number): LngLatTuple \ No newline at end of file diff --git a/index.js b/index.js index be1a7d4..99f6c77 100644 --- a/index.js +++ b/index.js @@ -23,16 +23,63 @@ var PI = 3.1415926535897932384626; var a = 6378245.0; var ee = 0.00669342162296594323; + + function Rectangle(lng1, lat1, lng2, lat2) { + this.west = Math.min(lng1, lng2); + this.north = Math.max(lat1, lat2); + this.east = Math.max(lng1, lng2); + this.south = Math.min(lat1, lat2); + } + /** + * @param {number} lon + * @param {number} lat + */ + Rectangle.prototype.contain = function (lon, lat) { + return this.west <= lon && this.east >= lon && this.north >= lat && this.south <= lat; + } + + //China region - raw data + var region = [ + new Rectangle(79.446200, 49.220400, 96.330000, 42.889900), + new Rectangle(109.687200, 54.141500, 135.000200, 39.374200), + new Rectangle(73.124600, 42.889900, 124.143255, 29.529700), + new Rectangle(82.968400, 29.529700, 97.035200, 26.718600), + new Rectangle(97.025300, 29.529700, 124.367395, 20.414096), + new Rectangle(107.975793, 20.414096, 111.744104, 17.871542) + ]; + //China excluded region - raw data + var exclude = [ + new Rectangle(119.921265, 25.398623, 122.497559, 21.785006), + new Rectangle(101.865200, 22.284000, 106.665000, 20.098800), + new Rectangle(106.452500, 21.542200, 108.051000, 20.487800), + new Rectangle(109.032300, 55.817500, 119.127000, 50.325700), + new Rectangle(127.456800, 55.817500, 137.022700, 49.557400), + new Rectangle(131.266200, 44.892200, 137.022700, 42.569200), + new Rectangle(73.124600, 35.398637, 77.948114, 29.529700) + ]; + + function isInChina(lon, lat) { + for (var i = 0; i < region.length; i++) { + if (region[i].contain(lon, lat)) { + for (var j = 0; j < exclude.length; j++) { + if (exclude[j].contain(lon, lat)) { + return false; + } + } + return true; + } + } + return false; + } + /** * 百度坐标系 (BD-09) 与 火星坐标系 (GCJ-02)的转换 * 即 百度 转 谷歌、高德 - * @param bd_lon - * @param bd_lat + * @param {number} bd_lon + * @param {number} bd_lat * @returns {*[]} */ - var bd09togcj02 = function bd09togcj02(bd_lon, bd_lat) { - var bd_lon = +bd_lon; - var bd_lat = +bd_lat; + function bd09togcj02(bd_lon, bd_lat) { var x = bd_lon - 0.0065; var y = bd_lat - 0.006; var z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_PI); @@ -45,13 +92,11 @@ /** * 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换 * 即谷歌、高德 转 百度 - * @param lng - * @param lat + * @param {number} lng + * @param {number} lat * @returns {*[]} */ - var gcj02tobd09 = function gcj02tobd09(lng, lat) { - var lat = +lat; - var lng = +lng; + function gcj02tobd09(lng, lat) { var z = Math.sqrt(lng * lng + lat * lat) + 0.00002 * Math.sin(lat * x_PI); var theta = Math.atan2(lat, lng) + 0.000003 * Math.cos(lng * x_PI); var bd_lng = z * Math.cos(theta) + 0.0065; @@ -61,59 +106,46 @@ /** * WGS84转GCj02 - * @param lng - * @param lat + * @param {number} lng + * @param {number} lat * @returns {*[]} */ - var wgs84togcj02 = function wgs84togcj02(lng, lat) { - var lat = +lat; - var lng = +lng; - if (out_of_china(lng, lat)) { + function wgs84togcj02(lng, lat) { + if (!isInChina(lng, lat)) { return [lng, lat] - } else { - var dlat = transformlat(lng - 105.0, lat - 35.0); - var dlng = transformlng(lng - 105.0, lat - 35.0); - var radlat = lat / 180.0 * PI; - var magic = Math.sin(radlat); - magic = 1 - ee * magic * magic; - var sqrtmagic = Math.sqrt(magic); - dlat = (dlat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * PI); - dlng = (dlng * 180.0) / (a / sqrtmagic * Math.cos(radlat) * PI); - var mglat = lat + dlat; - var mglng = lng + dlng; - return [mglng, mglat] } + return transform(lng, lat) }; /** * GCJ02 转换为 WGS84 - * @param lng - * @param lat + * @param {number} lng + * @param {number} lat * @returns {*[]} */ - var gcj02towgs84 = function gcj02towgs84(lng, lat) { - var lat = +lat; - var lng = +lng; - if (out_of_china(lng, lat)) { + function gcj02towgs84(lng, lat) { + if (!isInChina(lng, lat)) { return [lng, lat] - } else { - var dlat = transformlat(lng - 105.0, lat - 35.0); - var dlng = transformlng(lng - 105.0, lat - 35.0); - var radlat = lat / 180.0 * PI; - var magic = Math.sin(radlat); - magic = 1 - ee * magic * magic; - var sqrtmagic = Math.sqrt(magic); - dlat = (dlat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * PI); - dlng = (dlng * 180.0) / (a / sqrtmagic * Math.cos(radlat) * PI); - var mglat = lat + dlat; - var mglng = lng + dlng; - return [lng * 2 - mglng, lat * 2 - mglat] } + var out = transform(lng, lat) + return [lng * 2 - out[0], lat * 2 - out[1]] }; - var transformlat = function transformlat(lng, lat) { - var lat = +lat; - var lng = +lng; + function transform(lng, lat) { + var dlat = transformlat(lng - 105.0, lat - 35.0); + var dlng = transformlng(lng - 105.0, lat - 35.0); + var radlat = lat / 180.0 * PI; + var magic = Math.sin(radlat); + magic = 1 - ee * magic * magic; + var sqrtmagic = Math.sqrt(magic); + dlat = (dlat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * PI); + dlng = (dlng * 180.0) / (a / sqrtmagic * Math.cos(radlat) * PI); + var mglat = lat + dlat; + var mglng = lng + dlng; + return [mglng, mglat] + } + + function transformlat(lng, lat) { var ret = -100.0 + 2.0 * lng + 3.0 * lat + 0.2 * lat * lat + 0.1 * lng * lat + 0.2 * Math.sqrt(Math.abs(lng)); ret += (20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0 / 3.0; ret += (20.0 * Math.sin(lat * PI) + 40.0 * Math.sin(lat / 3.0 * PI)) * 2.0 / 3.0; @@ -121,9 +153,7 @@ return ret }; - var transformlng = function transformlng(lng, lat) { - var lat = +lat; - var lng = +lng; + function transformlng(lng, lat) { var ret = 300.0 + lng + 2.0 * lat + 0.1 * lng * lng + 0.1 * lng * lat + 0.1 * Math.sqrt(Math.abs(lng)); ret += (20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0 / 3.0; ret += (20.0 * Math.sin(lng * PI) + 40.0 * Math.sin(lng / 3.0 * PI)) * 2.0 / 3.0; @@ -131,23 +161,24 @@ return ret }; - /** - * 判断是否在国内,不在国内则不做偏移 - * @param lng - * @param lat - * @returns {boolean} - */ - var out_of_china = function out_of_china(lng, lat) { - var lat = +lat; - var lng = +lng; - // 纬度3.86~53.55,经度73.66~135.05 - return !(lng > 73.66 && lng < 135.05 && lat > 3.86 && lat < 53.55); - }; - return { + // 向前兼容 bd09togcj02: bd09togcj02, gcj02tobd09: gcj02tobd09, wgs84togcj02: wgs84togcj02, - gcj02towgs84: gcj02towgs84 + gcj02towgs84: gcj02towgs84, + // 小驼峰命名风格 + bd09ToGcj02: bd09togcj02, + gcj02ToBd09: gcj02tobd09, + wgs84ToGcj02: wgs84togcj02, + gcj02ToWgs84: gcj02towgs84, + bd09ToWgs84: function (lng, lat) { + var gcj02 = bd09togcj02(lng, lat) + return gcj02towgs84(gcj02[0], gcj02[1]) + }, + wgs84ToBd09: function (lng, lat) { + var gcj02 = wgs84togcj02(lng, lat) + return gcj02tobd09(gcj02[0], gcj02[1]) + } } })); diff --git a/package.json b/package.json index 57de812..2dd31ac 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "2.1.2", "description": "A common coordinate systems conversion module!", "main": "index.js", + "types": "index.d.ts", "scripts": { "test": "node test/app.js" }, From 415762022444e6913af620716fd4bb67c6b56f12 Mon Sep 17 00:00:00 2001 From: ipcjs Date: Tue, 10 Sep 2019 21:46:18 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E8=A1=A5=E5=85=85declare=E5=85=B3=E9=94=AE?= =?UTF-8?q?=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.d.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/index.d.ts b/index.d.ts index d697ece..2d3cee5 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,28 +1,28 @@ -type LngLatTuple = [number, number] +export type LngLatTuple = [number, number] /** @deprecated 换用小驼峰风格命名 */ -export function bd09togcj02(lng: number, lat: number): LngLatTuple +export declare function bd09togcj02(lng: number, lat: number): LngLatTuple /** @deprecated 换用小驼峰风格命名 */ -export function gcj02tobd09(lng: number, lat: number): LngLatTuple +export declare function gcj02tobd09(lng: number, lat: number): LngLatTuple /** @deprecated 换用小驼峰风格命名 */ -export function wgs84togcj02(lng: number, lat: number): LngLatTuple +export declare function wgs84togcj02(lng: number, lat: number): LngLatTuple /** @deprecated 换用小驼峰风格命名 */ -export function gcj02towgs84(lng: number, lat: number): LngLatTuple +export declare function gcj02towgs84(lng: number, lat: number): LngLatTuple /** BD09 => GCJ02 */ -export function bd09ToGcj02(lng: number, lat: number): LngLatTuple +export declare function bd09ToGcj02(lng: number, lat: number): LngLatTuple /** GCJ02 => BD09 */ -export function gcj02ToBd09(lng: number, lat: number): LngLatTuple +export declare function gcj02ToBd09(lng: number, lat: number): LngLatTuple /** WGS84 => GCJ02 */ -export function wgs84ToGcj02(lng: number, lat: number): LngLatTuple +export declare function wgs84ToGcj02(lng: number, lat: number): LngLatTuple /** GCJ02 => WGS84 */ -export function gcj02ToWgs84(lng: number, lat: number): LngLatTuple +export declare function gcj02ToWgs84(lng: number, lat: number): LngLatTuple /** * BD09 => WGS84 * 是使用其他方法"拼"出来的, 误差较大 */ -export function bd09ToWgs84(lng: number, lat: number): LngLatTuple +export declare function bd09ToWgs84(lng: number, lat: number): LngLatTuple /** * WGS84 => BD09 * 是使用其他方法"拼"出来的, 误差较大 */ -export function wgs84ToBd09(lng: number, lat: number): LngLatTuple \ No newline at end of file +export declare function wgs84ToBd09(lng: number, lat: number): LngLatTuple \ No newline at end of file From 40a11c3d566fb461cc61eaf08575e023520cf706 Mon Sep 17 00:00:00 2001 From: lzx <1692226948@qq.com> Date: Mon, 17 Feb 2020 11:28:00 +0800 Subject: [PATCH 3/8] =?UTF-8?q?*wgs84=E8=BD=ACbo09=E6=97=B6=E5=A6=82?= =?UTF-8?q?=E6=9E=9C=E5=9D=90=E6=A0=87=E5=9C=A8=E5=9B=BD=E5=A4=96=E5=88=99?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=8E=9F=E5=9D=90=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/index.js b/index.js index 99f6c77..5ae9f27 100644 --- a/index.js +++ b/index.js @@ -177,6 +177,9 @@ return gcj02towgs84(gcj02[0], gcj02[1]) }, wgs84ToBd09: function (lng, lat) { + if (!isInChina(lng, lat)) { + return [lng, lat] + } var gcj02 = wgs84togcj02(lng, lat) return gcj02tobd09(gcj02[0], gcj02[1]) } From 75f539951e6b8e9c80bd156a670e2886f4e1fde6 Mon Sep 17 00:00:00 2001 From: lzx <1692226948@qq.com> Date: Mon, 17 Feb 2020 14:00:56 +0800 Subject: [PATCH 4/8] =?UTF-8?q?*bo09=E8=BD=ACwgs84=E6=97=B6=E5=A6=82?= =?UTF-8?q?=E6=9E=9C=E5=9D=90=E6=A0=87=E5=9C=A8=E5=9B=BD=E5=A4=96=E5=88=99?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=8E=9F=E5=9D=90=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/index.js b/index.js index 5ae9f27..97294ed 100644 --- a/index.js +++ b/index.js @@ -173,6 +173,9 @@ wgs84ToGcj02: wgs84togcj02, gcj02ToWgs84: gcj02towgs84, bd09ToWgs84: function (lng, lat) { + if (!isInChina(lng, lat)) { + return [lng, lat] + } var gcj02 = bd09togcj02(lng, lat) return gcj02towgs84(gcj02[0], gcj02[1]) }, From 703856375ac6688998985ba548d3de0ef34d3082 Mon Sep 17 00:00:00 2001 From: ipcjs Date: Thu, 13 Jun 2024 15:35:25 +0800 Subject: [PATCH 5/8] fix: update china range (#1) --- index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 97294ed..dce7fd4 100644 --- a/index.js +++ b/index.js @@ -55,7 +55,9 @@ new Rectangle(109.032300, 55.817500, 119.127000, 50.325700), new Rectangle(127.456800, 55.817500, 137.022700, 49.557400), new Rectangle(131.266200, 44.892200, 137.022700, 42.569200), - new Rectangle(73.124600, 35.398637, 77.948114, 29.529700) + new Rectangle(73.124600, 35.398637, 77.948114, 29.529700), + new Rectangle(114.505238, 22.138258, 113.845000, 22.428903), + new Rectangle(113.97000, 22.507833, 114.450000, 22.428903), ]; function isInChina(lon, lat) { From c54b1ef043c544f4cf9fb80cb82d16f7555b9529 Mon Sep 17 00:00:00 2001 From: "ipcjs.mac" Date: Thu, 13 Jun 2024 16:49:56 +0800 Subject: [PATCH 6/8] =?UTF-8?q?fix:=20=E5=AF=B9=E4=BA=8Ebd09=E6=9D=A5?= =?UTF-8?q?=E8=AF=B4,=20=E9=A6=99=E6=B8=AF=E5=B1=9E=E4=BA=8E=E4=B8=AD?= =?UTF-8?q?=E5=9B=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 53 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/index.js b/index.js index dce7fd4..1f57014 100644 --- a/index.js +++ b/index.js @@ -38,7 +38,7 @@ return this.west <= lon && this.east >= lon && this.north >= lat && this.south <= lat; } - //China region - raw data + // China region - raw data var region = [ new Rectangle(79.446200, 49.220400, 96.330000, 42.889900), new Rectangle(109.687200, 54.141500, 135.000200, 39.374200), @@ -47,7 +47,7 @@ new Rectangle(97.025300, 29.529700, 124.367395, 20.414096), new Rectangle(107.975793, 20.414096, 111.744104, 17.871542) ]; - //China excluded region - raw data + // China excluded region - raw data var exclude = [ new Rectangle(119.921265, 25.398623, 122.497559, 21.785006), new Rectangle(101.865200, 22.284000, 106.665000, 20.098800), @@ -56,11 +56,14 @@ new Rectangle(127.456800, 55.817500, 137.022700, 49.557400), new Rectangle(131.266200, 44.892200, 137.022700, 42.569200), new Rectangle(73.124600, 35.398637, 77.948114, 29.529700), + ] + // China excluded region 2, Hongkong etc. + var EXCLUDE_REGIN_2 = [ new Rectangle(114.505238, 22.138258, 113.845000, 22.428903), new Rectangle(113.97000, 22.507833, 114.450000, 22.428903), ]; - function isInChina(lon, lat) { + function isInChina(lon, lat, excludeRegin2 = true) { for (var i = 0; i < region.length; i++) { if (region[i].contain(lon, lat)) { for (var j = 0; j < exclude.length; j++) { @@ -68,6 +71,13 @@ return false; } } + if (excludeRegin2) { + for (var j = 0; j < EXCLUDE_REGIN_2.length; j++) { + if (EXCLUDE_REGIN_2[j].contain(lon, lat)) { + return false; + } + } + } return true; } } @@ -113,9 +123,7 @@ * @returns {*[]} */ function wgs84togcj02(lng, lat) { - if (!isInChina(lng, lat)) { - return [lng, lat] - } + return transform(lng, lat) }; @@ -126,9 +134,6 @@ * @returns {*[]} */ function gcj02towgs84(lng, lat) { - if (!isInChina(lng, lat)) { - return [lng, lat] - } var out = transform(lng, lat) return [lng * 2 - out[0], lat * 2 - out[1]] }; @@ -164,25 +169,35 @@ }; return { - // 向前兼容 - bd09togcj02: bd09togcj02, - gcj02tobd09: gcj02tobd09, - wgs84togcj02: wgs84togcj02, - gcj02towgs84: gcj02towgs84, - // 小驼峰命名风格 + // 原始的转换方法 + rawBd09ToGcj02: bd09togcj02, + rawGcj02ToBd09: gcj02tobd09, + rawWgs84ToGcj02: wgs84togcj02, + rawGcj02ToWgs84: gcj02towgs84, + // 判断了中国范围的转换方法 bd09ToGcj02: bd09togcj02, gcj02ToBd09: gcj02tobd09, - wgs84ToGcj02: wgs84togcj02, - gcj02ToWgs84: gcj02towgs84, - bd09ToWgs84: function (lng, lat) { + wgs84ToGcj02: function (lng, lat) { if (!isInChina(lng, lat)) { return [lng, lat] } + return wgs84togcj02(lng, lat) + }, + gcj02ToWgs84: function (lng, lat) { + if (!isInChina(lng, lat)) { + return [lng, lat] + } + return gcj02towgs84(lng, lat) + }, + bd09ToWgs84: function (lng, lat) { + if (!isInChina(lng, lat, false)) { + return [lng, lat] + } var gcj02 = bd09togcj02(lng, lat) return gcj02towgs84(gcj02[0], gcj02[1]) }, wgs84ToBd09: function (lng, lat) { - if (!isInChina(lng, lat)) { + if (!isInChina(lng, lat, false)) { return [lng, lat] } var gcj02 = wgs84togcj02(lng, lat) From fa1d037ed54bac0beddfd62d2c4c00f882b07004 Mon Sep 17 00:00:00 2001 From: "ipcjs.mac" Date: Thu, 13 Jun 2024 16:50:17 +0800 Subject: [PATCH 7/8] =?UTF-8?q?refactor:=20=E6=9A=B4=E9=9C=B2=E5=8E=9F?= =?UTF-8?q?=E5=A7=8B=E7=9A=84=E4=B8=8D=E8=80=83=E8=99=91=E4=B8=AD=E5=9B=BD?= =?UTF-8?q?=E8=8C=83=E5=9B=B4=E7=9A=84=E8=BD=AC=E6=8D=A2=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.d.ts | 24 ++++++++++++------------ package.json | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/index.d.ts b/index.d.ts index 2d3cee5..2db7447 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,28 +1,28 @@ export type LngLatTuple = [number, number] -/** @deprecated 换用小驼峰风格命名 */ -export declare function bd09togcj02(lng: number, lat: number): LngLatTuple -/** @deprecated 换用小驼峰风格命名 */ -export declare function gcj02tobd09(lng: number, lat: number): LngLatTuple -/** @deprecated 换用小驼峰风格命名 */ -export declare function wgs84togcj02(lng: number, lat: number): LngLatTuple -/** @deprecated 换用小驼峰风格命名 */ -export declare function gcj02towgs84(lng: number, lat: number): LngLatTuple +/** 原始的 BD09 => Gcj02 */ +export declare function rawBd09ToGcj02(lng: number, lat: number): LngLatTuple +/** 原始的 Gcj02 => Bd09 */ +export declare function rawGcj02ToBd09(lng: number, lat: number): LngLatTuple +/** 原始的 Wgs84 => Gcj02 */ +export declare function rawWgs84ToGcj02(lng: number, lat: number): LngLatTuple +/** 原始的 Gcj02 => Wgs84 */ +export declare function rawGcj02ToWgs84(lng: number, lat: number): LngLatTuple /** BD09 => GCJ02 */ export declare function bd09ToGcj02(lng: number, lat: number): LngLatTuple /** GCJ02 => BD09 */ export declare function gcj02ToBd09(lng: number, lat: number): LngLatTuple -/** WGS84 => GCJ02 */ +/** WGS84 => GCJ02 (判断了中国范围) */ export declare function wgs84ToGcj02(lng: number, lat: number): LngLatTuple -/** GCJ02 => WGS84 */ +/** GCJ02 => WGS84 (判断了中国范围) */ export declare function gcj02ToWgs84(lng: number, lat: number): LngLatTuple /** - * BD09 => WGS84 + * BD09 => WGS84 (判断了中国范围) * 是使用其他方法"拼"出来的, 误差较大 */ export declare function bd09ToWgs84(lng: number, lat: number): LngLatTuple /** - * WGS84 => BD09 + * WGS84 => BD09 (判断了中国范围) * 是使用其他方法"拼"出来的, 误差较大 */ export declare function wgs84ToBd09(lng: number, lat: number): LngLatTuple \ No newline at end of file diff --git a/package.json b/package.json index 2dd31ac..2f699b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coordtransform", - "version": "2.1.2", + "version": "3.0.0", "description": "A common coordinate systems conversion module!", "main": "index.js", "types": "index.d.ts", From a862314494d4ea9bc30c8b53a5099c4d30d7ad31 Mon Sep 17 00:00:00 2001 From: "ipcjs.mac" Date: Thu, 13 Jun 2024 18:15:48 +0800 Subject: [PATCH 8/8] =?UTF-8?q?chore:=20=E8=B7=9F=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=96=B9=E5=BC=8F=E7=BB=9F=E4=B8=80=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.d.ts | 8 ++++---- index.js | 8 ++++---- package.json | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/index.d.ts b/index.d.ts index 2db7447..e54e0df 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,12 +1,12 @@ export type LngLatTuple = [number, number] /** 原始的 BD09 => Gcj02 */ -export declare function rawBd09ToGcj02(lng: number, lat: number): LngLatTuple +export declare function bd09ToGcj02Raw(lng: number, lat: number): LngLatTuple /** 原始的 Gcj02 => Bd09 */ -export declare function rawGcj02ToBd09(lng: number, lat: number): LngLatTuple +export declare function gcj02ToBd09Raw(lng: number, lat: number): LngLatTuple /** 原始的 Wgs84 => Gcj02 */ -export declare function rawWgs84ToGcj02(lng: number, lat: number): LngLatTuple +export declare function wgs84ToGcj02Raw(lng: number, lat: number): LngLatTuple /** 原始的 Gcj02 => Wgs84 */ -export declare function rawGcj02ToWgs84(lng: number, lat: number): LngLatTuple +export declare function gcj02ToWgs84Raw(lng: number, lat: number): LngLatTuple /** BD09 => GCJ02 */ export declare function bd09ToGcj02(lng: number, lat: number): LngLatTuple diff --git a/index.js b/index.js index 1f57014..b809137 100644 --- a/index.js +++ b/index.js @@ -170,10 +170,10 @@ return { // 原始的转换方法 - rawBd09ToGcj02: bd09togcj02, - rawGcj02ToBd09: gcj02tobd09, - rawWgs84ToGcj02: wgs84togcj02, - rawGcj02ToWgs84: gcj02towgs84, + bd09ToGcj02Raw: bd09togcj02, + gcj02ToBd09Raw: gcj02tobd09, + wgs84ToGcj02Raw: wgs84togcj02, + gcj02ToWgs84Raw: gcj02towgs84, // 判断了中国范围的转换方法 bd09ToGcj02: bd09togcj02, gcj02ToBd09: gcj02tobd09, diff --git a/package.json b/package.json index 2f699b1..80ecb5d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coordtransform", - "version": "3.0.0", + "version": "3.0.1", "description": "A common coordinate systems conversion module!", "main": "index.js", "types": "index.d.ts",