From 75a6d564711a7fbadb24a241d17df8acff60c641 Mon Sep 17 00:00:00 2001 From: squallzhjch Date: Fri, 26 May 2023 17:23:47 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=9C=8B=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../library/map/handler/LineHandler.kt | 10 +- .../library/map/layers/MultiLinesLayer.kt | 43 +++++ .../library/map/layers/MultiPathLayer.java | 170 ------------------ 3 files changed, 52 insertions(+), 171 deletions(-) create mode 100644 collect-library/src/main/java/com/navinfo/collect/library/map/layers/MultiLinesLayer.kt delete mode 100644 collect-library/src/main/java/com/navinfo/collect/library/map/layers/MultiPathLayer.java diff --git a/collect-library/src/main/java/com/navinfo/collect/library/map/handler/LineHandler.kt b/collect-library/src/main/java/com/navinfo/collect/library/map/handler/LineHandler.kt index b34a9612..d04ca6c3 100644 --- a/collect-library/src/main/java/com/navinfo/collect/library/map/handler/LineHandler.kt +++ b/collect-library/src/main/java/com/navinfo/collect/library/map/handler/LineHandler.kt @@ -7,6 +7,7 @@ import androidx.annotation.RequiresApi import androidx.appcompat.app.AppCompatActivity import com.navinfo.collect.library.R import com.navinfo.collect.library.map.NIMapView +import com.navinfo.collect.library.map.layers.MultiLinesLayer import com.navinfo.collect.library.map.layers.OmdbTaskLinkLayer import com.navinfo.collect.library.utils.GeometryTools import com.navinfo.collect.library.utils.StringUtil @@ -62,6 +63,12 @@ class LineHandler(context: AppCompatActivity, mapView: NIMapView) : BaseHandler( private val mDefaultPathLayer: PathLayer + val linksLayer by lazy { + val layer = MultiLinesLayer(mapView.vtmMap) + addLayer(layer, NIMapView.LAYER_GROUPS.VECTOR) + layer + } + val omdbTaskLinkLayer by lazy { val omdbTaskLinkLayer = OmdbTaskLinkLayer( mMapView.vtmMap, @@ -375,7 +382,7 @@ class LineHandler(context: AppCompatActivity, mapView: NIMapView) : BaseHandler( } } - fun clean() { + fun clear() { mPathLayer.clearPath() mPathLayer.isEnabled = false mPathLayerTemp.clearPath() @@ -385,5 +392,6 @@ class LineHandler(context: AppCompatActivity, mapView: NIMapView) : BaseHandler( mPathMakers.clear() editIndex = -1 bDrawLine = false + omdbTaskLinkLayer.removeAll() } } \ No newline at end of file diff --git a/collect-library/src/main/java/com/navinfo/collect/library/map/layers/MultiLinesLayer.kt b/collect-library/src/main/java/com/navinfo/collect/library/map/layers/MultiLinesLayer.kt new file mode 100644 index 00000000..30c51446 --- /dev/null +++ b/collect-library/src/main/java/com/navinfo/collect/library/map/layers/MultiLinesLayer.kt @@ -0,0 +1,43 @@ +package com.navinfo.collect.library.map.layers + +import android.graphics.Color +import com.navinfo.collect.library.data.entity.HadLinkDvoBean +import com.navinfo.collect.library.utils.GeometryTools +import org.locationtech.jts.geom.Geometry +import org.locationtech.jts.geom.LineString +import org.oscim.core.GeoPoint +import org.oscim.layers.vector.VectorLayer +import org.oscim.layers.vector.geometries.LineDrawable +import org.oscim.layers.vector.geometries.Style +import org.oscim.map.Map + +/** + * Created by xiaoxiao on 2018/3/26. + */ +class MultiLinesLayer(map: Map) : VectorLayer(map) { + + private val linkList = mutableListOf() + + @Synchronized + fun addLine(geometry: String, color: Int = Color.BLUE) { + try { + val style = + Style.builder().fillColor(color).fillAlpha(0.5f).strokeColor(color) + .strokeWidth(6f).fixed(true).build() + val lineDrawable = + LineDrawable(GeometryTools.createGeometry(geometry), style) + super.add(lineDrawable) + linkList.add(lineDrawable) + } catch (e: Exception) { + + } + } + + @Synchronized + fun clear() { + for (item in linkList) { + super.remove(item) + } + linkList.clear() + } +} \ No newline at end of file diff --git a/collect-library/src/main/java/com/navinfo/collect/library/map/layers/MultiPathLayer.java b/collect-library/src/main/java/com/navinfo/collect/library/map/layers/MultiPathLayer.java deleted file mode 100644 index 8f3efc9b..00000000 --- a/collect-library/src/main/java/com/navinfo/collect/library/map/layers/MultiPathLayer.java +++ /dev/null @@ -1,170 +0,0 @@ -package com.navinfo.collect.library.map.layers; - -import com.navinfo.collect.library.utils.GeometryTools; -import org.locationtech.jts.geom.Geometry; -import org.locationtech.jts.geom.LineString; -import org.oscim.core.GeoPoint; -import org.oscim.layers.vector.PathLayer; -import org.oscim.layers.vector.geometries.LineDrawable; -import org.oscim.layers.vector.geometries.PolygonDrawable; -import org.oscim.layers.vector.geometries.Style; -import org.oscim.map.Map; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** - * Created by xiaoxiao on 2018/3/26. - */ - -public class MultiPathLayer extends PathLayer { - private List pathDrawableList; - - public MultiPathLayer(Map map, Style style) { - super(map, style); - mStyle = style; - pathDrawableList = new ArrayList<>(); - } - - public MultiPathLayer(Map map, Style style, String name) { - this(map, style); - } - - public MultiPathLayer(Map map, int lineColor, float lineWidth, int fillColor, float fillAlpha) { - this(map, Style.builder() - .stippleColor(lineColor) - .stipple(24) - .stippleWidth(lineWidth) - .strokeWidth(lineWidth) - .strokeColor(lineColor).fillColor(fillColor).fillAlpha(fillAlpha) - .fixed(true) - .randomOffset(false) - .build()); - } - - public MultiPathLayer(Map map, int lineColor, int fillColor, float fillAlpha) { - this(map, lineColor, 0.5f, fillColor, fillAlpha); - } - - /** - * 设置polygon的点位 - */ - public void setPathList(List> pointListList) { - if (pointListList == null || pointListList.isEmpty()) { - return; - } - for (List pointList : pointListList) { - if (pointList == null || pointList.size() < 2) { - return; - } - synchronized (this) { - LineDrawable lineDrawable = new LineDrawable(pointList, mStyle); - add(lineDrawable); - pathDrawableList.add(lineDrawable); - } - mWorker.submit(0); - update(); - } - } - - /** - * 移除正在绘制的polygon的图形 - */ - public void removePathDrawable(int i) { - if (pathDrawableList != null && pathDrawableList.size() > i) { - remove(pathDrawableList.get(i)); - update(); - } - } - - public void removePathDrawable(List geoPointList) { - LineString path = GeometryTools.getLineStrinGeo(geoPointList); - removePolygonDrawable(path); - } - - public void removePathDrawable(String pathStr) { - LineString path = (LineString) GeometryTools.createGeometry(pathStr); - removePolygonDrawable(path); - } - - public void removePolygonDrawable(Geometry path) { - if (pathDrawableList != null && !pathDrawableList.isEmpty()) { - Iterator iterator = pathDrawableList.iterator(); - while (iterator.hasNext()) { - LineDrawable lineDrawable = (LineDrawable) iterator.next(); - if (GeometryTools.createGeometry(lineDrawable.getGeometry().toString()).equals(path)) { - remove(lineDrawable); - iterator.remove(); - break; - } - } - mWorker.submit(0); - update(); - } - } - - public void addPathDrawable(List pointList) { - if (pathDrawableList != null) { - if (pointList == null || pointList.size() < 2) { - return; - } - synchronized (this) { - LineDrawable pathDrawable = new LineDrawable(pointList, mStyle); - add(pathDrawable); - pathDrawableList.add(pathDrawable); - } - mWorker.submit(0); - } - update(); - } - - public void addPathDrawable(LineString lineString) { - List geoPointList = GeometryTools.getGeoPoints(lineString.toString()); - addPathDrawable(geoPointList); - } - - public List getAllPathList() { - if (pathDrawableList != null && !pathDrawableList.isEmpty()) { - List pathList = new ArrayList<>(); - for (LineDrawable pathDrawable : pathDrawableList) { - pathList.add((LineString) GeometryTools.createGeometry(pathDrawable.getGeometry().toString())); - } - return pathList; - } - return null; - } - - public List> getAllPathGeoPointList() { - List pathList = getAllPathList(); - if (pathList != null) { - List> geopointList = new ArrayList<>(); - for (LineString path : pathList) { - geopointList.add(GeometryTools.getGeoPoints(path.toString())); - } - return geopointList; - } - return null; - } - - public List getPolygonDrawableList() { - return pathDrawableList; - } - - public void setPolygonDrawableList(List pathDrawableList) { - this.pathDrawableList = pathDrawableList; - } - - public void removeAllPathDrawable(){ - if (pathDrawableList != null && !pathDrawableList.isEmpty()) { - Iterator iterator = pathDrawableList.iterator(); - while (iterator.hasNext()) { - LineDrawable lineDrawable = (LineDrawable) iterator.next(); - remove(lineDrawable); - iterator.remove(); - } - mWorker.submit(0); - update(); - } - } -} From 8d6bb8c6e88a20ff6d734aa1a4c2bc8feacf0d79 Mon Sep 17 00:00:00 2001 From: squallzhjch Date: Fri, 26 May 2023 17:45:36 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=99=AE=E9=80=9A?= =?UTF-8?q?=E4=BA=A4=E9=99=90=E7=9A=84=E9=81=93=E8=B7=AF=E6=B8=B2=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/navinfo/omqs/ui/activity/map/MainViewModel.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/navinfo/omqs/ui/activity/map/MainViewModel.kt b/app/src/main/java/com/navinfo/omqs/ui/activity/map/MainViewModel.kt index 633387f4..593d9b5b 100644 --- a/app/src/main/java/com/navinfo/omqs/ui/activity/map/MainViewModel.kt +++ b/app/src/main/java/com/navinfo/omqs/ui/activity/map/MainViewModel.kt @@ -241,9 +241,17 @@ class MainViewModel @Inject constructor( 2002, 2008, 2010, 2041 -> topSignList.add( signBean ) - 4002, 4003, 4004, 4006, 4022 -> signList.add( + 4002, 4003, 4004, 4022 -> signList.add( signBean ) + 4006 -> { + mapController.lineHandler.linksLayer.clear() + val inLink = element.properties["linkIn"] + val outLink = element.properties["linkOut"] + if (inLink != null){ + + } + } } }