From 4d265afb3419bd5cedc6f31ab78d570f6917b520 Mon Sep 17 00:00:00 2001
From: seatonwan9 <seatonwan9@163.com>
Date: 星期五, 21 五月 2021 14:30:44 +0800
Subject: [PATCH] Merge branch 'develop' of http://xearth.cn:6600/r/wuyushui/SewerAndRainNetwork into develop

---
 src/utils/utils.js |  135 ++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 132 insertions(+), 3 deletions(-)

diff --git a/src/utils/utils.js b/src/utils/utils.js
index def6f2a..c187b1c 100644
--- a/src/utils/utils.js
+++ b/src/utils/utils.js
@@ -4,7 +4,6 @@
 * arg_val 鏇挎崲鍚庣殑鍙傛暟鐨勫��
 * return url 鍙傛暟鏇挎崲鍚庣殑url
 */
-import MapConfig from '../conf/MapConfig'
 export function changeURLArg (url, arg, argValue) {
   var pattern = arg + '=([^&]*)'
   var replaceText = arg + '=' + argValue
@@ -23,6 +22,136 @@
   // eslint-disable-next-line no-unreachable
   return url + '\n' + arg + '\n' + argValue
 }
-export function getRandomTDTToken () {
-  return MapConfig.mapTokenArray[Math.floor(Math.random() * MapConfig.mapTokenArray.length)]
+
+/**
+ * 鑴夊啿鏁堟灉
+ */
+export function pulseEffect (xy) {
+  let times = 1000
+  const colors = ['#00f100', '#ff0000']
+  // 鎻掍欢 鏁堟灉瀹炵幇
+  var pulsingIcon = window.L.icon.pulse({
+    iconSize: [30, 30],
+    color: colors[0],
+    fillColor: ''
+  })
+  var picGroupMarker = window.L.marker(xy, { icon: pulsingIcon }).addTo(window.mapManager.hightlightLayer)
+  // 瀹氭椂
+  var timeInterval = setInterval(() => {
+    if (times > 0) {
+      times--
+    } else {
+      clearInterval(timeInterval)
+      picGroupMarker.remove()
+    }
+  }, 1000)
 }
+
+export function reversePolyLine (feature) {
+  const coordinates = clone(feature.geometry.coordinates)
+  var latlng = []
+  for (var j = 0; j < coordinates.length; j++) {
+    let coordinate = coordinates[j]
+    coordinate = [coordinate[1], coordinate[0]]
+    latlng.push(coordinate)
+  }
+  return latlng
+}
+
+export function reverseMultiLine (feature) {
+  const coordinates = clone(feature.geometry.coordinates)
+  var latlng = []
+  for (var j = 0; j < coordinates.length; j++) {
+    const coordinate = coordinates[j]
+    var xy = []
+    for (var k = 0; k < coordinate.length; k++) {
+      let coor = coordinate[k]
+      if (coor.length > 2) {
+        coor = coor.splice(2, 1)
+      }
+      xy.push(coor.reverse())
+    }
+    latlng.push(xy)
+  }
+  return latlng
+}
+
+/**
+ * 璁剧疆寮圭獥骞崇Щ浣嶇疆
+ * @param pos
+ * @param value
+ */
+export function setPanTo (pos, value) {
+  var position = pos
+  position = window.map.latLngToLayerPoint(position)
+  position.y += value
+  position = window.map.layerPointToLatLng(position)
+  window.map.flyTo(position)
+}
+
+/**
+ * 澶嶅埗瀵硅薄
+ * @param obj
+ * @returns {{}}
+ */
+export function clone (obj) {
+  var o
+  // 濡傛灉  浠栨槸瀵硅薄object鐨勮瘽  , 鍥犱负null,object,array  涔熸槸'object';
+  if (typeof obj === 'object') {
+    // 濡傛灉  浠栨槸绌虹殑璇�
+    if (obj === null) {
+      o = null
+    } else {
+      // 濡傛灉  浠栨槸鏁扮粍arr鐨勮瘽
+      if (obj instanceof Array) {
+        o = []
+        for (var i = 0, len = obj.length; i < len; i++) {
+          o.push(clone(obj[i]))
+        }
+      } else {
+        // 濡傛灉  浠栨槸瀵硅薄object鐨勮瘽
+        o = {}
+        for (var j in obj) {
+          o[j] = clone(obj[j])
+        }
+      }
+    }
+  } else {
+    o = obj
+  }
+  return o
+}
+
+/**
+ *
+ * 璁剧疆index,绾垮湪鏈�涓嬮潰锛岀偣鍦ㄤ笂闈�
+ * @param layerGroup 鍥惧眰缁�
+ */
+export function setZIndex (layer) {
+  if (Array.isArray(layer)) {
+    for (var i = 0; i < layer.length; i++) {
+      setZIndex(layer[i])
+    }
+  } else {
+    if (layer.getLayers) {
+      setZIndex(layer.getLayers())
+    } else {
+      if (layer.feature && (layer.feature.geometry.type === 'LineString' || layer.feature.geometry.type === 'MultiLineString')) {
+        layer.bringToBack && layer.bringToBack()
+      } else {
+        layer.bringToFront && layer.bringToFront()
+      }
+    }
+  }
+}
+
+/**
+ * 鍘绘帀涓ゅご绌烘牸
+ * @param str
+ * @returns {*}
+ */
+export function lrtrim (str) {
+  return str.replace(/^\s+|\s+$/g, '')
+}
+
+export default clone

--
Gitblit v1.8.0