raintee-maputils 1.0.48 → 1.0.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -19854,7 +19854,7 @@ class MapJumpControl {
19854
19854
  }
19855
19855
 
19856
19856
  _convertCoordinates(lng, lat, fromSystem, toSystem) {
19857
- console.log(`转换坐标: ${fromSystem} -> ${toSystem}, 坐标: (${lng}, ${lat})`);
19857
+ // console.log(`转换坐标: ${fromSystem} -> ${toSystem}, 坐标: (${lng}, ${lat})`);
19858
19858
 
19859
19859
  if (fromSystem === toSystem) {
19860
19860
  return { lng, lat };
@@ -21899,124 +21899,5 @@ const useDrawCache = () => {
21899
21899
  }
21900
21900
  };
21901
21901
 
21902
- /**
21903
- * 经纬度坐标系转换
21904
- * @param {number} lng - 经度
21905
- * @param {number} lat - 纬度
21906
- * @param {string} fromType - 起始坐标系: 'wgs84' | 'gcj02' | 'bd09'
21907
- * @param {string} toType - 目标坐标系: 'wgs84' | 'gcj02' | 'bd09'
21908
- * @returns {Object} 转换后的坐标 {lng, lat}
21909
- */
21910
- function convertCoordinate(lng, lat, fromType, toType) {
21911
- // 如果起始坐标系和目标坐标系相同,直接返回
21912
- if (fromType === toType) {
21913
- return { lng, lat };
21914
- }
21915
-
21916
- // 转换链:确保通过中间坐标系正确转换
21917
- if (fromType === 'wgs84' && toType === 'gcj02') {
21918
- return wgs84ToGcj02(lng, lat);
21919
- } else if (fromType === 'wgs84' && toType === 'bd09') {
21920
- const gcj = wgs84ToGcj02(lng, lat);
21921
- return gcj02ToBd09(gcj.lng, gcj.lat);
21922
- } else if (fromType === 'gcj02' && toType === 'wgs84') {
21923
- return gcj02ToWgs84(lng, lat);
21924
- } else if (fromType === 'gcj02' && toType === 'bd09') {
21925
- return gcj02ToBd09(lng, lat);
21926
- } else if (fromType === 'bd09' && toType === 'wgs84') {
21927
- const gcj = bd09ToGcj02(lng, lat);
21928
- return gcj02ToWgs84(gcj.lng, gcj.lat);
21929
- } else if (fromType === 'bd09' && toType === 'gcj02') {
21930
- return bd09ToGcj02(lng, lat);
21931
- }
21932
-
21933
- return { lng, lat };
21934
- }
21935
-
21936
- // ---------- 核心转换算法 ----------
21937
-
21938
- // WGS84转GCJ-02
21939
- function wgs84ToGcj02(lng, lat) {
21940
- const PI = 3.1415926535897932384626;
21941
- const a = 6378245.0; // 长半轴
21942
- const ee = 0.00669342162296594323; // 扁率
21943
-
21944
- if (outOfChina(lng, lat)) {
21945
- return { lng, lat };
21946
- }
21947
-
21948
- let dlat = transformLat(lng - 105.0, lat - 35.0);
21949
- let dlng = transformLng(lng - 105.0, lat - 35.0);
21950
-
21951
- const radlat = lat / 180.0 * PI;
21952
- let magic = Math.sin(radlat);
21953
- magic = 1 - ee * magic * magic;
21954
- const sqrtmagic = Math.sqrt(magic);
21955
-
21956
- dlat = (dlat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * PI);
21957
- dlng = (dlng * 180.0) / (a / sqrtmagic * Math.cos(radlat) * PI);
21958
-
21959
- const mglat = lat + dlat;
21960
- const mglng = lng + dlng;
21961
-
21962
- return { lng: mglng, lat: mglat };
21963
- }
21964
-
21965
- // GCJ-02转WGS84
21966
- function gcj02ToWgs84(lng, lat) {
21967
- const gps = wgs84ToGcj02(lng, lat);
21968
- const dlng = lng - gps.lng;
21969
- const dlat = lat - gps.lat;
21970
- return { lng: lng - dlng, lat: lat - dlat };
21971
- }
21972
-
21973
- // GCJ-02转BD-09
21974
- function gcj02ToBd09(lng, lat) {
21975
- const z = Math.sqrt(lng * lng + lat * lat) + 0.00002 * Math.sin(lat * Math.PI * 3000.0 / 180.0);
21976
- const theta = Math.atan2(lat, lng) + 0.000003 * Math.cos(lng * Math.PI * 3000.0 / 180.0);
21977
- const bd_lng = z * Math.cos(theta) + 0.0065;
21978
- const bd_lat = z * Math.sin(theta) + 0.006;
21979
- return { lng: bd_lng, lat: bd_lat };
21980
- }
21981
-
21982
- // BD-09转GCJ-02
21983
- function bd09ToGcj02(lng, lat) {
21984
- const x = lng - 0.0065;
21985
- const y = lat - 0.006;
21986
- const z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * Math.PI * 3000.0 / 180.0);
21987
- const theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * Math.PI * 3000.0 / 180.0);
21988
- const gcj_lng = z * Math.cos(theta);
21989
- const gcj_lat = z * Math.sin(theta);
21990
- return { lng: gcj_lng, lat: gcj_lat };
21991
- }
21992
-
21993
- // 判断是否在中国境外
21994
- function outOfChina(lng, lat) {
21995
- return lng < 72.004 || lng > 137.8347 || lat < 0.8293 || lat > 55.8271;
21996
- }
21997
-
21998
- // 纬度转换
21999
- function transformLat(lng, lat) {
22000
- let ret = -100 + 2.0 * lng + 3.0 * lat + 0.2 * lat * lat + 0.1 * lng * lat + 0.2 * Math.sqrt(Math.abs(lng));
22001
- ret += (20.0 * Math.sin(6.0 * lng * Math.PI) + 20.0 * Math.sin(2.0 * lng * Math.PI)) * 2.0 / 3.0;
22002
- ret += (20.0 * Math.sin(lat * Math.PI) + 40.0 * Math.sin(lat / 3.0 * Math.PI)) * 2.0 / 3.0;
22003
- ret += (160.0 * Math.sin(lat / 12.0 * Math.PI) + 320 * Math.sin(lat * Math.PI / 30.0)) * 2.0 / 3.0;
22004
- return ret;
22005
- }
22006
-
22007
- // 经度转换
22008
- function transformLng(lng, lat) {
22009
- let ret = 300.0 + lng + 2.0 * lat + 0.1 * lng * lng + 0.1 * lng * lat + 0.1 * Math.sqrt(Math.abs(lng));
22010
- ret += (20.0 * Math.sin(6.0 * lng * Math.PI) + 20.0 * Math.sin(2.0 * lng * Math.PI)) * 2.0 / 3.0;
22011
- ret += (20.0 * Math.sin(lng * Math.PI) + 40.0 * Math.sin(lng / 3.0 * Math.PI)) * 2.0 / 3.0;
22012
- ret += (150.0 * Math.sin(lng / 12.0 * Math.PI) + 300.0 * Math.sin(lng / 30.0 * Math.PI)) * 2.0 / 3.0;
22013
- return ret;
22014
- }
22015
-
22016
- var CoordinateConverter = /*#__PURE__*/Object.freeze({
22017
- __proto__: null,
22018
- convertCoordinate: convertCoordinate
22019
- });
22020
-
22021
- export { CoordinateConverter, CustomOptionsControl, CustomSearchSelectControl, CustomToggleControl, DrawCacheFeatureManager, MapJumpControl, RainteeConstants, RainteeGISUtil, RainteeSourceMapTool, RasterLayerControl, RulerControl, TerrainToggleControl, useDrawCache };
21902
+ export { CustomOptionsControl, CustomSearchSelectControl, CustomToggleControl, DrawCacheFeatureManager, MapJumpControl, RainteeConstants, RainteeGISUtil, RainteeSourceMapTool, RasterLayerControl, RulerControl, TerrainToggleControl, useDrawCache };
22022
21903
  //# sourceMappingURL=index.js.map