wd vor 7 Jahren
Ursprung
Commit
4ba1ee4ae3
1 geänderte Dateien mit 9 neuen und 7 gelöschten Zeilen
  1. 9 7
      index.js

+ 9 - 7
index.js

@@ -326,6 +326,13 @@ function getBearingPoint(point, lastBearing, bearing, airlineWidth) {
     return [leftPoint, rightPoint]
 }
 
+function myRound(num, digits) {
+    if(digits == null)
+        digits = 6 // 比较的精度,经纬度会被经过度分秒方式到浮点方式的转化
+
+    return Math.round(num * Math.pow(10, digits)) / Math.pow(10, digits)
+}
+
 function isLineConnect(line1, line2) {
     // 判断 line1 的终点和 line2 的起点是否相同
     let line1LastPoint = line1.coordinates[line1.coordinates.length -1]
@@ -334,19 +341,14 @@ function isLineConnect(line1, line2) {
     let [line1lat, line1lng] = getFixedLatLng(line1LastPoint)
     let [line2lat, line2lng] = getFixedLatLng(line2FirstPoint)
 
-    let precision = 9 // 比较的精度,经纬度会被经过度分秒方式到浮点方式的转化
-
-    if(line1lat.toFixed(precision) == line2lat.toFixed(precision)
-       && line1lng.toFixed(precision) == line2lng.toFixed(precision)) {
+    if(myRound(line1lat) == myRound(line2lat)
+       && myRound(line1lng) == myRound(line2lng)) {
         return true
     } else {
         return false
     }
 }
 
-function getPolygonFromLine(line, airlineWidth) {
-}
-
 function getLinesPolygonsAndMarkers(airspaceInfos, setStyle, currentAirspaceIndex) {
     let retLines = [];
     let retMarkers = [];