gis-common 1.1.10 → 1.1.11
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/resource.min.js +18 -18
- package/package.json +1 -1
package/dist/resource.min.js
CHANGED
|
@@ -756,38 +756,38 @@ Array.prototype.clear = function () {
|
|
|
756
756
|
/* harmony default export */ var CoordsUtils = ({
|
|
757
757
|
PI: 3.14159265358979324,
|
|
758
758
|
XPI: 3.14159265358979324 * 3000.0 / 180.0,
|
|
759
|
-
delta: function delta(lat,
|
|
759
|
+
delta: function delta(lat, lng) {
|
|
760
760
|
var a = 6378245.0; // a: 卫星椭球坐标投影到平面地图坐标系的投影因子。
|
|
761
761
|
var ee = 0.00669342162296594323; // ee: 椭球的偏心率。
|
|
762
|
-
var dLat = this.transformLat(
|
|
763
|
-
var dLon = this.transformLon(
|
|
762
|
+
var dLat = this.transformLat(lng - 105.0, lat - 35.0);
|
|
763
|
+
var dLon = this.transformLon(lng - 105.0, lat - 35.0);
|
|
764
764
|
var radLat = lat / 180.0 * this.PI;
|
|
765
765
|
var magic = Math.sin(radLat);
|
|
766
766
|
magic = 1 - ee * magic * magic;
|
|
767
767
|
var sqrtMagic = Math.sqrt(magic);
|
|
768
768
|
dLat = dLat * 180.0 / (a * (1 - ee) / (magic * sqrtMagic) * this.PI);
|
|
769
769
|
dLon = dLon * 180.0 / (a / sqrtMagic * Math.cos(radLat) * this.PI);
|
|
770
|
-
return { lat: dLat,
|
|
770
|
+
return { lat: dLat, lng: dLon };
|
|
771
771
|
},
|
|
772
772
|
|
|
773
773
|
// WGS-84 to GCJ-02
|
|
774
774
|
gcjEncrypt: function gcjEncrypt(wgsLat, wgsLon) {
|
|
775
775
|
if (this.outOfChina(wgsLat, wgsLon)) {
|
|
776
|
-
return { lat: wgsLat,
|
|
776
|
+
return { lat: wgsLat, lng: wgsLon };
|
|
777
777
|
}
|
|
778
778
|
|
|
779
779
|
var d = this.delta(wgsLat, wgsLon);
|
|
780
|
-
return { lat: wgsLat + d.lat,
|
|
780
|
+
return { lat: wgsLat + d.lat, lng: wgsLon + d.lng };
|
|
781
781
|
},
|
|
782
782
|
|
|
783
783
|
// GCJ-02 to WGS-84
|
|
784
784
|
gcjDecrypt: function gcjDecrypt(gcjLat, gcjLon) {
|
|
785
785
|
if (this.outOfChina(gcjLat, gcjLon)) {
|
|
786
|
-
return { lat: gcjLat,
|
|
786
|
+
return { lat: gcjLat, lng: gcjLon };
|
|
787
787
|
}
|
|
788
788
|
|
|
789
789
|
var d = this.delta(gcjLat, gcjLon);
|
|
790
|
-
return { lat: gcjLat - d.lat,
|
|
790
|
+
return { lat: gcjLat - d.lat, lng: gcjLon - d.lng };
|
|
791
791
|
},
|
|
792
792
|
|
|
793
793
|
// GCJ-02 to WGS-84 exactly
|
|
@@ -808,7 +808,7 @@ Array.prototype.clear = function () {
|
|
|
808
808
|
wgsLon = (mLon + pLon) / 2;
|
|
809
809
|
var tmp = this.gcj_encrypt(wgsLat, wgsLon);
|
|
810
810
|
dLat = tmp.lat - gcjLat;
|
|
811
|
-
dLon = tmp.
|
|
811
|
+
dLon = tmp.lng - gcjLon;
|
|
812
812
|
if (Math.abs(dLat) < threshold && Math.abs(dLon) < threshold) {
|
|
813
813
|
break;
|
|
814
814
|
}
|
|
@@ -819,7 +819,7 @@ Array.prototype.clear = function () {
|
|
|
819
819
|
if (++i > 10000) break;
|
|
820
820
|
}
|
|
821
821
|
// console.log(i);
|
|
822
|
-
return { lat: wgsLat,
|
|
822
|
+
return { lat: wgsLat, lng: wgsLon };
|
|
823
823
|
},
|
|
824
824
|
|
|
825
825
|
// GCJ-02 to BD-09
|
|
@@ -830,7 +830,7 @@ Array.prototype.clear = function () {
|
|
|
830
830
|
var theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * this.XPI);
|
|
831
831
|
var bdLon = z * Math.cos(theta) + 0.0065;
|
|
832
832
|
var bdLat = z * Math.sin(theta) + 0.006;
|
|
833
|
-
return { lat: bdLat,
|
|
833
|
+
return { lat: bdLat, lng: bdLon };
|
|
834
834
|
},
|
|
835
835
|
|
|
836
836
|
// BD-09 to GCJ-02
|
|
@@ -841,7 +841,7 @@ Array.prototype.clear = function () {
|
|
|
841
841
|
var theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * this.XPI);
|
|
842
842
|
var gcjLon = z * Math.cos(theta);
|
|
843
843
|
var gcjLat = z * Math.sin(theta);
|
|
844
|
-
return { lat: gcjLat,
|
|
844
|
+
return { lat: gcjLat, lng: gcjLon };
|
|
845
845
|
},
|
|
846
846
|
|
|
847
847
|
// WGS-84 to Web mercator
|
|
@@ -850,7 +850,7 @@ Array.prototype.clear = function () {
|
|
|
850
850
|
var x = wgsLon * 20037508.34 / 180.0;
|
|
851
851
|
var y = Math.log(Math.tan((90.0 + wgsLat) * this.PI / 360.0)) / (this.PI / 180.0);
|
|
852
852
|
y = y * 20037508.34 / 180.0;
|
|
853
|
-
return { lat: y,
|
|
853
|
+
return { lat: y, lng: x };
|
|
854
854
|
},
|
|
855
855
|
|
|
856
856
|
// Web mercator to WGS-84
|
|
@@ -859,13 +859,13 @@ Array.prototype.clear = function () {
|
|
|
859
859
|
var x = mercatorLon / 20037508.34 * 180.0;
|
|
860
860
|
var y = mercatorLat / 20037508.34 * 180.0;
|
|
861
861
|
y = 180 / this.PI * (2 * Math.atan(Math.exp(y * this.PI / 180.0)) - this.PI / 2);
|
|
862
|
-
return { lat: y,
|
|
862
|
+
return { lat: y, lng: x };
|
|
863
863
|
},
|
|
864
864
|
|
|
865
865
|
// two point's distance
|
|
866
|
-
distance: function distance(latA,
|
|
866
|
+
distance: function distance(latA, lngA, latB, lngB) {
|
|
867
867
|
var earthR = 6371000.0;
|
|
868
|
-
var x = Math.cos(latA * this.PI / 180.0) * Math.cos(latB * this.PI / 180.0) * Math.cos((
|
|
868
|
+
var x = Math.cos(latA * this.PI / 180.0) * Math.cos(latB * this.PI / 180.0) * Math.cos((lngA - lngB) * this.PI / 180);
|
|
869
869
|
var y = Math.sin(latA * this.PI / 180.0) * Math.sin(latB * this.PI / 180.0);
|
|
870
870
|
var s = x + y;
|
|
871
871
|
if (s > 1) s = 1;
|
|
@@ -874,8 +874,8 @@ Array.prototype.clear = function () {
|
|
|
874
874
|
var distance = alpha * earthR;
|
|
875
875
|
return distance;
|
|
876
876
|
},
|
|
877
|
-
outOfChina: function outOfChina(lat,
|
|
878
|
-
if (
|
|
877
|
+
outOfChina: function outOfChina(lat, lng) {
|
|
878
|
+
if (lng < 72.004 || lng > 137.8347) {
|
|
879
879
|
return true;
|
|
880
880
|
}
|
|
881
881
|
if (lat < 0.8293 || lat > 55.8271) {
|