调整看板
This commit is contained in:
parent
d5d251c85e
commit
75a6d56471
@ -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()
|
||||
}
|
||||
}
|
@ -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<LineDrawable>()
|
||||
|
||||
@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()
|
||||
}
|
||||
}
|
@ -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<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();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user