Merge branch 'master' of gitlab.navinfo.com:CollectVehicle/OneMapQS

This commit is contained in:
squallzhjch
2023-04-28 16:03:52 +08:00
8 changed files with 263 additions and 8 deletions

View File

@@ -0,0 +1,19 @@
package com.navinfo.collect.library.data.entity
import io.realm.RealmObject
open class HadLinkDvoBean @JvmOverloads constructor(
/**
* 图幅号
*/
var mesh: String = "",
/**
* linkPid
*/
var linkPid: String = "",
/**
* (几何)加偏后
*/
var geometry: String = ""
) : RealmObject()

View File

@@ -108,6 +108,12 @@ class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView,tracePa
}
}
/**
* 初始化任务Link高亮的图层
* */
private fun initOMDBTaskVectorLayer() {
}
/**
* 切换基础底图样式
*/

View File

@@ -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.OmdbTaskLinkLayer
import com.navinfo.collect.library.utils.GeometryTools
import com.navinfo.collect.library.utils.StringUtil
import org.locationtech.jts.geom.LineString
@@ -21,10 +22,11 @@ import org.oscim.layers.marker.MarkerInterface
import org.oscim.layers.marker.MarkerItem
import org.oscim.layers.marker.MarkerSymbol
import org.oscim.layers.vector.PathLayer
import org.oscim.layers.vector.VectorLayer
import org.oscim.layers.vector.geometries.Style
import org.oscim.map.Map
@RequiresApi(Build.VERSION_CODES.M)
@RequiresApi(Build.VERSION_CODES.N)
class LineHandler(context: AppCompatActivity, mapView: NIMapView) : BaseHandler(context, mapView),
Map.UpdateListener {
@@ -57,6 +59,19 @@ class LineHandler(context: AppCompatActivity, mapView: NIMapView) : BaseHandler(
private val mDefaultPathLayer: PathLayer
val omdbTaskLinkLayer by lazy {
val omdbTaskLinkLayer = OmdbTaskLinkLayer(mMapView.vtmMap,
Style.builder()
// .stippleColor(context.resources.getColor(R.color.draw_line_red_color, null))
.fillColor(context.resources.getColor(R.color.draw_line_red_color, null))
.fillAlpha(0.5f)
.strokeColor(context.resources.getColor(R.color.draw_line_red_color, null))
.strokeWidth(4f)
.fixed(true).build())
addLayer(omdbTaskLinkLayer, NIMapView.LAYER_GROUPS.VECTOR)
omdbTaskLinkLayer
}
init {
mMapView.vtmMap.events.bind(this)

View File

@@ -0,0 +1,170 @@
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<LineDrawable> 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<List<GeoPoint>> pointListList) {
if (pointListList == null || pointListList.isEmpty()) {
return;
}
for (List<GeoPoint> 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<GeoPoint> 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<GeoPoint> 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<GeoPoint> geoPointList = GeometryTools.getGeoPoints(lineString.toString());
addPathDrawable(geoPointList);
}
public List<LineString> getAllPathList() {
if (pathDrawableList != null && !pathDrawableList.isEmpty()) {
List<LineString> pathList = new ArrayList<>();
for (LineDrawable pathDrawable : pathDrawableList) {
pathList.add((LineString) GeometryTools.createGeometry(pathDrawable.getGeometry().toString()));
}
return pathList;
}
return null;
}
public List<List<GeoPoint>> getAllPathGeoPointList() {
List<LineString> pathList = getAllPathList();
if (pathList != null) {
List<List<GeoPoint>> geopointList = new ArrayList<>();
for (LineString path : pathList) {
geopointList.add(GeometryTools.getGeoPoints(path.toString()));
}
return geopointList;
}
return null;
}
public List<LineDrawable> getPolygonDrawableList() {
return pathDrawableList;
}
public void setPolygonDrawableList(List<LineDrawable> 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();
}
}
}

View File

@@ -0,0 +1,54 @@
package com.navinfo.collect.library.map.layers
import android.graphics.Color
import com.navinfo.collect.library.R
import com.navinfo.collect.library.data.entity.HadLinkDvoBean
import com.navinfo.collect.library.utils.GeometryTools
import org.locationtech.jts.geom.Geometry
import org.oscim.layers.vector.VectorLayer
import org.oscim.layers.vector.geometries.Drawable
import org.oscim.layers.vector.geometries.LineDrawable
import org.oscim.layers.vector.geometries.Style
import org.oscim.map.Map
class OmdbTaskLinkLayer(map: Map, private var style: Style) : VectorLayer(map) {
private val lineMap = HashMap<String, Drawable>()
fun addLine(hadLinkDvoBean: HadLinkDvoBean, style: Style = this.style) {
hadLinkDvoBean.let {
if (!lineMap.containsKey(it.linkPid)) {
// 添加geometry到图层上
val lineDrawable = LineDrawable(GeometryTools.createGeometry(it.geometry), style)
super.add(lineDrawable)
lineMap[it.linkPid] = lineDrawable
}
}
}
fun addLineList(hadLinkDvoBeanList: List<HadLinkDvoBean>, style: Style = this.style) {
hadLinkDvoBeanList.forEach {
addLine(it, style)
}
}
fun removeLine(linkPid: String):Boolean {
if (lineMap.containsKey(linkPid)) {
super.remove(lineMap[linkPid])
lineMap.remove(linkPid)
}
return false
}
fun removeLine(geometry: Geometry) {
super.remove(geometry)
}
fun setLineColor(color: Color) {
this.style = Style.builder()
.fillColor(color.toArgb())
.fillAlpha(0.5f)
.strokeColor(color.toArgb())
.strokeWidth(4f)
.fixed(true).build()
}
}