Conflicts:
	app/src/main/java/com/navinfo/omqs/ui/fragment/tasklist/TaskListFragment.kt
This commit is contained in:
qiji4215
2023-07-13 14:16:51 +08:00
29 changed files with 1346 additions and 361 deletions

View File

@@ -1 +1,45 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="136" height="136" viewBox="0 0 136 136"><defs><style>.a,.f{fill:#fff;}.a{opacity:0;}.b{fill:#ff5f4c;opacity:0.304;}.c{fill:#a74d4b;opacity:0.708;}.d{fill:url(#a);}.e{fill:url(#b);}.g{fill:#2a23f5;stroke:#db4646;stroke-linecap:square;stroke-width:3px;stroke-dasharray:9 10;}.h{stroke:none;}.i{fill:none;}</style><radialGradient id="a" cx="0.21" cy="0.134" r="1.274" gradientTransform="matrix(0.849, 0.529, -0.307, 0.493, 0.073, -0.043)" gradientUnits="objectBoundingBox"><stop offset="0" stop-color="#ff9287"/><stop offset="0.786" stop-color="#ff5f4c"/><stop offset="1" stop-color="#ff5f4c"/></radialGradient><radialGradient id="b" cx="0.5" cy="0.5" r="0.5" gradientUnits="objectBoundingBox"><stop offset="0" stop-color="#e75545"/><stop offset="0.793" stop-color="#c4483b"/><stop offset="1" stop-color="#983b31"/></radialGradient></defs><g transform="translate(-956 -396)"><rect class="a" width="136" height="136" transform="translate(956 396)"/><g transform="translate(989.164 429.346)"><g transform="translate(10.653 81.66)"><ellipse class="b" cx="24.183" cy="8.497" rx="24.183" ry="8.497"/><ellipse class="c" cx="8.497" cy="3.268" rx="8.497" ry="3.268" transform="translate(15.687 5.229)"/></g><g transform="translate(0 0)"><path class="d" d="M22.956,71.538q-.792-.8-1.543-1.533A36.466,36.466,0,0,1,0,36.4C0,16.3,15.6,0,34.837,0S69.673,16.3,69.673,36.4c0,15.235-8.954,28.283-21.664,33.711q-.588.673-1.219,1.424A73.582,73.582,0,0,0,35.337,90.157S30.335,78.981,22.956,71.538Z" transform="translate(0 0)"/><circle class="e" cx="27.451" cy="27.451" r="27.451" transform="translate(7.029 7.568)"/></g></g><g transform="translate(10096 7643)"><circle class="f" cx="28" cy="28" r="28" transform="translate(-9100 -7207)"/><g class="g" transform="translate(-9096 -7203)"><circle class="h" cx="24" cy="24" r="24"/><circle class="i" cx="24" cy="24" r="25.5"/></g></g></g></svg>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="136"
height="136" viewBox="0 0 136 136">
<defs>
<style>
.a,.f{fill:#fff;}.a{opacity:0;}.b{fill:#ff5f4c;opacity:0.304;}.c{fill:#a74d4b;opacity:0.708;}.d{fill:url(#a);}.e{fill:url(#b);}.g{fill:#2a23f5;stroke:#db4646;stroke-linecap:square;stroke-width:3px;stroke-dasharray:9
10;}.h{stroke:none;}.i{fill:none;}
</style>
<radialGradient id="a" cx="0.21" cy="0.134" r="1.274"
gradientTransform="matrix(0.849, 0.529, -0.307, 0.493, 0.073, -0.043)"
gradientUnits="objectBoundingBox">
<stop offset="0" stop-color="#ff9287" />
<stop offset="0.786" stop-color="#ff5f4c" />
<stop offset="1" stop-color="#ff5f4c" />
</radialGradient>
<radialGradient id="b" cx="0.5" cy="0.5" r="0.5" gradientUnits="objectBoundingBox">
<stop offset="0" stop-color="#e75545" />
<stop offset="0.793" stop-color="#c4483b" />
<stop offset="1" stop-color="#983b31" />
</radialGradient>
</defs>
<g transform="translate(-956 -396)">
<rect class="a" width="136" height="136" transform="translate(956 396)" />
<g transform="translate(989.164 429.346)">
<g transform="translate(10.653 81.66)">
<ellipse class="b" cx="24.183" cy="8.497" rx="24.183" ry="8.497" />
<ellipse class="c" cx="8.497" cy="3.268" rx="8.497" ry="3.268"
transform="translate(15.687 5.229)" />
</g>
<g transform="translate(0 0)">
<path class="d"
d="M22.956,71.538q-.792-.8-1.543-1.533A36.466,36.466,0,0,1,0,36.4C0,16.3,15.6,0,34.837,0S69.673,16.3,69.673,36.4c0,15.235-8.954,28.283-21.664,33.711q-.588.673-1.219,1.424A73.582,73.582,0,0,0,35.337,90.157S30.335,78.981,22.956,71.538Z"
transform="translate(0 0)" />
<circle class="e" cx="27.451" cy="27.451" r="27.451"
transform="translate(7.029 7.568)" />
</g>
</g>
<g transform="translate(10096 7643)">
<circle class="f" cx="28" cy="28" r="28" transform="translate(-9100 -7207)" />
<g class="g" transform="translate(-9096 -7203)">
<circle class="h" cx="24" cy="24" r="24" />
<circle class="i" cx="24" cy="24" r="25.5" />
</g>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@@ -1 +1,24 @@
<svg xmlns="http://www.w3.org/2000/svg" width="56" height="74.999" viewBox="0 0 56 74.999"><defs><style>.a{fill:#fff;opacity:0;}.b{fill:#fad950;}.c,.d{fill:#0b1923;}.c{stroke:#0b1923;stroke-width:0.5px;}.e,.f{stroke:none;}.f{fill:#0b1923;}</style></defs><g transform="translate(1401 -1261.001) rotate(90)"><rect class="a" width="56" height="56" transform="translate(1280 1345)"/><g transform="translate(0 -2)"><g class="b" transform="translate(1280 1349)"><path class="e" d="M 52.55363845825195 47.5 L 3.446360111236572 47.5 C 3.195830106735229 47.5 3.067879915237427 47.34397125244141 3.0139000415802 47.25096893310547 C 2.959929943084717 47.157958984375 2.887939929962158 46.96945190429688 3.012239933013916 46.75191879272461 L 27.56587028503418 3.783060550689697 C 27.69112968444824 3.563860416412354 27.89163017272949 3.53113055229187 28 3.53113055229187 C 28.10836029052734 3.53113055229187 28.30886077880859 3.563860416412354 28.43411064147949 3.783050537109375 L 52.98777008056641 46.75193023681641 C 53.112060546875 46.96945190429688 53.04006958007812 47.157958984375 52.98609924316406 47.25096893310547 C 52.93212127685547 47.34397125244141 52.80416870117188 47.5 52.55363845825195 47.5 Z"/><path class="f" d="M 27.99999618530273 6.046699523925781 L 5.169540405273438 46 L 50.83046340942383 46 L 27.99999618530273 6.046699523925781 M 27.99999809265137 2.0311279296875 C 28.67629432678223 2.0311279296875 29.35259056091309 2.367034912109375 29.73648071289062 3.038848876953125 L 54.29013061523438 46.00772094726562 C 55.05202102661133 47.34104156494141 54.08929061889648 49 52.55363845825195 49 L 3.446361541748047 49 C 1.910709381103516 49 0.9479789733886719 47.34104156494141 1.709869384765625 46.00772094726562 L 26.26350975036621 3.038848876953125 C 26.64740562438965 2.367034912109375 27.32370185852051 2.0311279296875 27.99999809265137 2.0311279296875 Z"/></g><path class="c" d="M44.849,49.162a.812.812,0,0,0,.794-.794V46.779H48.2a4.526,4.526,0,0,0,3.462-1.419,5.191,5.191,0,0,0,1.248-3.178,2.467,2.467,0,0,0,2.213-2.667c-.113-3.235-3.235-4.483-5.221-4.483H40.309a5.77,5.77,0,0,0-5.278,5.618v1.475a1.138,1.138,0,0,0,1.135,1.135h.34c.113,2.043,1.305,3.518,2.951,3.518h1.873v1.589a.812.812,0,0,0,.794.794h.908v.624a2.519,2.519,0,0,0,2.5,2.5h.738v1.362a1.5,1.5,0,0,0,1.475,1.475H50.41a1.5,1.5,0,0,0,1.475-1.475V50.127a1.5,1.5,0,0,0-1.475-1.475H47.743a1.5,1.5,0,0,0-1.475,1.475v1.362H45.53a1.707,1.707,0,0,1-1.7-1.7v-.624Zm2.213,4.483V52.283c1.873,0,1.873-.794,0-.794ZM37.3,43.2h6.242a2.894,2.894,0,0,0,1.759-.624,2.984,2.984,0,0,0,1.021,1.589,3.224,3.224,0,0,0,2.1.794h.4c1.532-.284,2.44-1.589,2.44-3.575a4,4,0,0,0-1.816-3.745,6.605,6.605,0,0,1,.851-.34.413.413,0,1,0-.227-.794,3.922,3.922,0,0,0-1.532.794l-.057.057a6.481,6.481,0,0,0-1.532,2.1c-.738,1.419-2.1,2.951-3.4,2.951H36.167a.366.366,0,0,1-.34-.34V40.593a4.919,4.919,0,0,1,4.483-4.824H49.9c1.135,0,4.313.681,4.426,3.689a1.7,1.7,0,0,1-1.419,1.873,6.868,6.868,0,0,0-.057-1.078.4.4,0,1,0-.794.113,5.661,5.661,0,0,1-1.021,4.426,3.6,3.6,0,0,1-2.894,1.192H39.458C38.266,45.984,37.415,44.849,37.3,43.2Zm4.824,3.575h2.667v1.589H42.125Z" transform="translate(1262.925 1337.469)"/></g><path class="d" d="M69.876,257.508H31.287a2.233,2.233,0,1,1,0-4.466H69.876a2.233,2.233,0,1,1,0,4.466Zm1.217-.951-9.7-8.471a2.2,2.2,0,0,1,0-3.157,2.328,2.328,0,0,1,3.234,0l9.705,8.471a2.2,2.2,0,0,1,0,3.157A2.325,2.325,0,0,1,71.093,256.557Zm-9.7,5.908,9.7-8.471a2.328,2.328,0,0,1,3.234,0,2.2,2.2,0,0,1,0,3.157l-9.7,8.471a2.328,2.328,0,0,1-3.234,0A2.2,2.2,0,0,1,61.392,262.465Z" transform="translate(1016.726 1425) rotate(-90)"/></g></svg>
<svg xmlns="http://www.w3.org/2000/svg" width="56" height="74.999" viewBox="0 0 56 74.999">
<defs>
<style>
.a{fill:#fff;opacity:0;}.b{fill:#fad950;}.c,.d{fill:#0b1923;}.c{stroke:#0b1923;stroke-width:0.5px;}.e,.f{stroke:none;}.f{fill:#0b1923;}
</style>
</defs>
<g transform="translate(1401 -1261.001) rotate(90)">
<rect class="a" width="56" height="56" transform="translate(1280 1345)" />
<g transform="translate(0 -2)">
<g class="b" transform="translate(1280 1349)">
<path class="e"
d="M 52.55363845825195 47.5 L 3.446360111236572 47.5 C 3.195830106735229 47.5 3.067879915237427 47.34397125244141 3.0139000415802 47.25096893310547 C 2.959929943084717 47.157958984375 2.887939929962158 46.96945190429688 3.012239933013916 46.75191879272461 L 27.56587028503418 3.783060550689697 C 27.69112968444824 3.563860416412354 27.89163017272949 3.53113055229187 28 3.53113055229187 C 28.10836029052734 3.53113055229187 28.30886077880859 3.563860416412354 28.43411064147949 3.783050537109375 L 52.98777008056641 46.75193023681641 C 53.112060546875 46.96945190429688 53.04006958007812 47.157958984375 52.98609924316406 47.25096893310547 C 52.93212127685547 47.34397125244141 52.80416870117188 47.5 52.55363845825195 47.5 Z" />
<path class="f"
d="M 27.99999618530273 6.046699523925781 L 5.169540405273438 46 L 50.83046340942383 46 L 27.99999618530273 6.046699523925781 M 27.99999809265137 2.0311279296875 C 28.67629432678223 2.0311279296875 29.35259056091309 2.367034912109375 29.73648071289062 3.038848876953125 L 54.29013061523438 46.00772094726562 C 55.05202102661133 47.34104156494141 54.08929061889648 49 52.55363845825195 49 L 3.446361541748047 49 C 1.910709381103516 49 0.9479789733886719 47.34104156494141 1.709869384765625 46.00772094726562 L 26.26350975036621 3.038848876953125 C 26.64740562438965 2.367034912109375 27.32370185852051 2.0311279296875 27.99999809265137 2.0311279296875 Z" />
</g>
<path class="c"
d="M44.849,49.162a.812.812,0,0,0,.794-.794V46.779H48.2a4.526,4.526,0,0,0,3.462-1.419,5.191,5.191,0,0,0,1.248-3.178,2.467,2.467,0,0,0,2.213-2.667c-.113-3.235-3.235-4.483-5.221-4.483H40.309a5.77,5.77,0,0,0-5.278,5.618v1.475a1.138,1.138,0,0,0,1.135,1.135h.34c.113,2.043,1.305,3.518,2.951,3.518h1.873v1.589a.812.812,0,0,0,.794.794h.908v.624a2.519,2.519,0,0,0,2.5,2.5h.738v1.362a1.5,1.5,0,0,0,1.475,1.475H50.41a1.5,1.5,0,0,0,1.475-1.475V50.127a1.5,1.5,0,0,0-1.475-1.475H47.743a1.5,1.5,0,0,0-1.475,1.475v1.362H45.53a1.707,1.707,0,0,1-1.7-1.7v-.624Zm2.213,4.483V52.283c1.873,0,1.873-.794,0-.794ZM37.3,43.2h6.242a2.894,2.894,0,0,0,1.759-.624,2.984,2.984,0,0,0,1.021,1.589,3.224,3.224,0,0,0,2.1.794h.4c1.532-.284,2.44-1.589,2.44-3.575a4,4,0,0,0-1.816-3.745,6.605,6.605,0,0,1,.851-.34.413.413,0,1,0-.227-.794,3.922,3.922,0,0,0-1.532.794l-.057.057a6.481,6.481,0,0,0-1.532,2.1c-.738,1.419-2.1,2.951-3.4,2.951H36.167a.366.366,0,0,1-.34-.34V40.593a4.919,4.919,0,0,1,4.483-4.824H49.9c1.135,0,4.313.681,4.426,3.689a1.7,1.7,0,0,1-1.419,1.873,6.868,6.868,0,0,0-.057-1.078.4.4,0,1,0-.794.113,5.661,5.661,0,0,1-1.021,4.426,3.6,3.6,0,0,1-2.894,1.192H39.458C38.266,45.984,37.415,44.849,37.3,43.2Zm4.824,3.575h2.667v1.589H42.125Z"
transform="translate(1262.925 1337.469)" />
</g>
<path class="d"
d="M69.876,257.508H31.287a2.233,2.233,0,1,1,0-4.466H69.876a2.233,2.233,0,1,1,0,4.466Zm1.217-.951-9.7-8.471a2.2,2.2,0,0,1,0-3.157,2.328,2.328,0,0,1,3.234,0l9.705,8.471a2.2,2.2,0,0,1,0,3.157A2.325,2.325,0,0,1,71.093,256.557Zm-9.7,5.908,9.7-8.471a2.328,2.328,0,0,1,3.234,0,2.2,2.2,0,0,1,0,3.157l-9.7,8.471a2.328,2.328,0,0,1-3.234,0A2.2,2.2,0,0,1,61.392,262.465Z"
transform="translate(1016.726 1425) rotate(-90)" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@@ -19,6 +19,15 @@ open class HadLinkDvoBean @JvmOverloads constructor(
/**
* 不作业原因
*/
var reason: String = ""
var reason: String = "",
/**
* 1:源库link 3现象新增
*/
var linkStatus: Int = 1,
/**
* link 长度
*/
var linkLength: Double = 0.000
) : RealmObject()

View File

@@ -1,18 +1,11 @@
package com.navinfo.collect.library.map
import android.os.Build
import androidx.annotation.RequiresApi
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import com.navinfo.collect.library.data.entity.NiLocation
import com.navinfo.collect.library.data.handler.DataNiLocationHandler
import com.navinfo.collect.library.map.NIMapView.OnMapClickListener
import com.navinfo.collect.library.map.handler.*
import com.navinfo.collect.library.map.handler.MeasureLayerHandler
import com.navinfo.collect.library.map.handler.ViewportHandler
import com.navinfo.collect.library.system.Constant
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.launch
import org.oscim.core.GeoPoint

View File

@@ -5,13 +5,17 @@ import android.graphics.Canvas
import android.graphics.Color
import android.os.Build
import android.text.TextPaint
import android.util.Log
import android.widget.Toast
import androidx.annotation.RequiresApi
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.MutableLiveData
import com.navinfo.collect.library.R
import com.navinfo.collect.library.map.NIMapView
import com.navinfo.collect.library.map.layers.NIPolygonLayer
import com.navinfo.collect.library.utils.DistanceUtil
import com.navinfo.collect.library.utils.GeometryTools
import com.navinfo.collect.library.utils.StringUtil.Companion.createUUID
import org.oscim.android.canvas.AndroidBitmap
import org.oscim.backend.CanvasAdapter
import org.oscim.backend.canvas.Bitmap
@@ -27,6 +31,8 @@ import org.oscim.layers.vector.PathLayer
import org.oscim.layers.vector.geometries.Style
import org.oscim.map.Map
import java.math.BigDecimal
import kotlin.math.abs
import kotlin.math.ceil
@RequiresApi(Build.VERSION_CODES.M)
open class MeasureLayerHandler(context: AppCompatActivity, mapView: NIMapView) :
@@ -37,230 +43,195 @@ open class MeasureLayerHandler(context: AppCompatActivity, mapView: NIMapView) :
private var bDrawLine = false
private val bDrawPoint = false
private var mAreaLayer: ItemizedLayer
/**
* 加上虚线的总长度
*/
val tempLineDistanceLiveData = MutableLiveData("")
/**
* 实际绘制的总长度
*/
val lineLenghtLiveData = MutableLiveData<Double>(0.000)
private val markerLayer: ItemizedLayer by lazy {
val markerSymbol = MarkerSymbol(
mPathMarkerBitmap, MarkerSymbol.HotspotPlace.CENTER
)
//新增marker图层
val layer = ItemizedLayer(
mapView.vtmMap, mutableListOf<MarkerInterface>(), markerSymbol, itemGestureListener
)
addLayer(layer, NIMapView.LAYER_GROUPS.OPERATE_MARKER)
layer
}
private val mAreaLayer: ItemizedLayer by lazy {
val markerSymbol = MarkerSymbol(mPathMarkerBitmap, MarkerSymbol.HotspotPlace.CENTER)
ItemizedLayer(mMapView.vtmMap, ArrayList(), markerSymbol, null)
}
//绘制线 样式
private val lineStyle: Style
private val newTempStyle: Style
//线型编辑时的样式
private val editTempStyle: Style
//新增线数据引线
private var mPathLayerTemp: PathLayer
//新增线数据
private var mPathLayer: PathLayer
//线路端点图标
private var mPathMarkerBitmap: Bitmap
private var bDrawPolygon = false
private var mPolygonLayer: NIPolygonLayer
init {
private val lineStyle: Style by lazy {
//新增线数据图层和线样式
lineStyle = Style.builder().scaleZoomLevel(20).buffer(1.0)
Style.builder().scaleZoomLevel(20).buffer(1.0)
.stippleColor(context.resources.getColor(R.color.draw_line_blue1_color, null))
.strokeWidth(4f)
.fillColor(context.resources.getColor(R.color.draw_line_blue2_color, null))
.fillAlpha(0.5f)
.strokeColor(context.resources.getColor(R.color.draw_line_blue2_color, null))
.fillColor(context.resources.getColor(R.color.draw_line_red_color, null))
.stippleWidth(4f)
.fixed(true)
.build()
.stippleWidth(4f).fixed(true).build()
}
newTempStyle = Style.builder()
.stippleColor(context.resources.getColor(R.color.transparent, null))
.stipple(30)
.stippleWidth(30f)
.strokeWidth(4f)
private val newTempStyle: Style by lazy {
Style.builder().stippleColor(context.resources.getColor(R.color.transparent, null))
.stipple(30).stippleWidth(30f).strokeWidth(4f)
.strokeColor(context.resources.getColor(R.color.draw_line_blue2_color, null))
.fixed(true)
.randomOffset(false)
.build()
.fixed(true).randomOffset(false).build()
}
editTempStyle = Style.builder()
.stippleColor(context.resources.getColor(R.color.transparent, null))
.stipple(30)
.stippleWidth(30f)
.strokeWidth(8f)
.strokeColor(context.resources.getColor(R.color.draw_line_red_color, null))
.fixed(true)
.randomOffset(false)
.build()
mPolygonLayer = NIPolygonLayer(
mMapView.vtmMap,
lineStyle
)
// addLayer(mPolygonLayer, NIMapView.LAYER_GROUPS.OPERATE)
mPathLayerTemp = PathLayer(mMapView.vtmMap, newTempStyle)
// addLayer(mPathLayerTemp, NIMapView.LAYER_GROUPS.OPERATE)
mPathMarkerBitmap = AndroidBitmap(
BitmapFactory.decodeResource(
context.resources,
R.mipmap.icon_path_maker
)
)
val markerSymbol = MarkerSymbol(mPathMarkerBitmap, MarkerSymbol.HotspotPlace.CENTER)
mAreaLayer = ItemizedLayer(mMapView.vtmMap, ArrayList(), markerSymbol, null)
mPathLayer = PathLayer(mMapView.vtmMap, lineStyle)
addLayer(mPathLayer, NIMapView.LAYER_GROUPS.OPERATE_LINE)
//线型编辑时的样式
private val editTempStyle: Style by lazy {
Style.builder().stippleColor(context.resources.getColor(R.color.transparent, null))
.stipple(30).stippleWidth(30f).strokeWidth(8f)
.strokeColor(context.resources.getColor(R.color.draw_line_red_color, null)).fixed(true)
.randomOffset(false).build()
}
open fun drawLineOrPolygon(type: Int) {
//新增线数据引线
private val mPathLayerTemp: PathLayer by lazy {
val layer = PathLayer(mMapView.vtmMap, newTempStyle)
addLayer(layer, NIMapView.LAYER_GROUPS.OPERATE_LINE)
layer
}
//新增线数据
val mPathLayer: PathLayer by lazy {
val layer = PathLayer(mMapView.vtmMap, lineStyle)
addLayer(layer, NIMapView.LAYER_GROUPS.OPERATE_LINE)
layer
}
//线路端点图标
private val mPathMarkerBitmap: Bitmap by lazy {
AndroidBitmap(
BitmapFactory.decodeResource(
context.resources, R.mipmap.icon_path_maker
)
)
}
private var bDrawPolygon = false
val mPolygonLayer: NIPolygonLayer by lazy {
val layer = NIPolygonLayer(mMapView.vtmMap, lineStyle)
addLayer(layer, NIMapView.LAYER_GROUPS.OPERATE_LINE)
layer
}
init {
mMapView.vtmMap.events.bind(this)
}
open fun drawLineOrPolygon(isPolygon: Boolean) {
bDrawLine = true
// //画面
// if (type == 3) {
// if (mPolygonLayer == null) {
// mPolygonLayer = NIPolygonLayer(mMapView.vtmMap, lineStyle)
// addLayer(mPolygonLayer, NIMapView.LAYER_GROUPS.OPERATE)
// } else if (!mPolygonLayer.isEnabled) {
// mPolygonLayer.isEnabled = true
// }
// } else {
// if (mPathLayer == null) {
// mPathLayer = PathLayer(mMapView.vtmMap, lineStyle)
// addLayer(mPathLayer, NIMapView.LAYER_GROUPS.OPERATE)
// } else if (!mPathLayer.isEnabled()) {
// mPathLayer.setEnabled(true)
// }
// }
// //上一个点的引线
// if (mPathLayerTemp == null) {
// mPathLayerTemp = PathLayer(mMapView.vtmMap, newTempStyle)
// addLayer(mPathLayerTemp, NIMapView.LAYER_GROUPS.OPERATE)
// } else if (!mPathLayerTemp.isEnabled) {
// mPathLayerTemp.isEnabled = true
// }
// val geoPoint: GeoPoint =
// GeoPoint(
// mMapView.vtmMap.getMapPosition().getLatitude(),
// mMapView.vtmMap.getMapPosition().getLongitude()
// )
//
// //编辑点
// if (editIndex > -1) {
// if (mPathMakers.size > editIndex) {
// mMapView.layerManager.removeMarker(
// mPathMakers[editIndex],
// NILayerManager.MARQUEE_MARKER_LAYER
// )
// mPathMakers.removeAt(editIndex)
// if (mPathMarkerBitmap == null) {
// mPathMarkerBitmap = AndroidBitmap(
// BitmapFactory.decodeResource(
// mContext.getResources(),
// R.mipmap.icon_path_maker
// )
// )
// }
// val markerItem = MarkerItem(createUUID(), "", "", geoPoint)
// val markerSymbol = MarkerSymbol(mPathMarkerBitmap, MarkerSymbol.HotspotPlace.CENTER)
// markerItem.marker = markerSymbol
// mMapView.layerManager.addMarker2MarkerLayer(
// markerItem,
// mPathMarkerBitmap,
// NILayerManager.MARQUEE_MARKER_LAYER,
// NIMapView.LAYER_GROUPS.OTHER.ordinal,
// itemGestureListener
// )
// mPathMakers.add(editIndex, markerItem)
// if (mPathLayer != null && mPathLayer.getPoints().size > 0) {
// val list: MutableList<GeoPoint> = mPathLayer.getPoints()
// if (editIndex < list.size) {
// list.removeAt(editIndex)
// val list2: MutableList<GeoPoint> = java.util.ArrayList(list)
// list2.add(editIndex, geoPoint)
// mPathLayer.setPoints(list2)
// }
// } else if (mPolygonLayer != null && mPolygonLayer.points.size > 0) {
// val list = mPolygonLayer.points
// if (editIndex < list.size) {
// list.removeAt(editIndex)
// val list2: MutableList<GeoPoint> = java.util.ArrayList(list)
// list2.add(editIndex, geoPoint)
// mPolygonLayer.setPoints(list2)
// }
// }
// if (mPathLayerTemp != null) {
// mPathLayerTemp.setStyle(newTempStyle)
// val list: MutableList<GeoPoint> = java.util.ArrayList<GeoPoint>()
// if (type == 3 && mPathMakers.size > 1) {
// list.add(mPathMakers[0].geoPoint)
// list.add(geoPoint)
// list.add(mPathMakers[mPathMakers.size - 1].geoPoint)
// } else {
// list.add(mPathMakers[mPathMakers.size - 1].geoPoint)
// list.add(geoPoint)
// }
// mPathLayerTemp.setPoints(list)
// }
// }
// editIndex = -1
// } else { //新增点
// if (type == 3) {
// val points: MutableList<GeoPoint> = java.util.ArrayList(mPolygonLayer.points)
// if (points.size > 2) {
// val list: MutableList<GeoPoint> = java.util.ArrayList()
// points.add(points[0])
// list.add(points[0])
// list.add(geoPoint)
// list.add(mPolygonLayer.points[mPolygonLayer.points.size - 1])
// val bCross = GeometryTools.isPolygonCrosses(points, list)
// if (bCross == true) {
// Toast.makeText(mContext, "不能交叉", Toast.LENGTH_SHORT).show()
// return
// }
// }
// mPolygonLayer.addPoint(geoPoint)
// } else {
// val points: List<GeoPoint> = mPathLayer.getPoints()
// if (points.size > 2) {
// val list: MutableList<GeoPoint> = java.util.ArrayList()
// list.add(geoPoint)
// list.add(points[points.size - 1])
// val bCross = GeometryTools.isLineStringCrosses(points, list)
// if (bCross == true) {
// Toast.makeText(mContext, "不能交叉", Toast.LENGTH_SHORT).show()
// return
// }
// }
// mPathLayer.addPoint(geoPoint)
// }
// if (mPathMarkerBitmap == null) {
// mPathMarkerBitmap = AndroidBitmap(
// BitmapFactory.decodeResource(
// mContext.getResources(),
// R.mipmap.icon_path_maker
// )
// )
// }
// val markerItem = MarkerItem(createUUID(), "", "", geoPoint)
// val markerSymbol = MarkerSymbol(mPathMarkerBitmap, MarkerSymbol.HotspotPlace.CENTER)
// markerItem.marker = markerSymbol
// mMapView.layerManager.addMarker2MarkerLayer(
// markerItem,
// mPathMarkerBitmap,
// NILayerManager.MARQUEE_MARKER_LAYER,
// NIMapView.LAYER_GROUPS.OTHER.ordinal,
// itemGestureListener
// )
// mPathMakers.add(markerItem)
// }
//画面
if (isPolygon && !mPolygonLayer.isEnabled) {
mPolygonLayer.isEnabled = true
} else if (!mPathLayer.isEnabled) {
mPathLayer.isEnabled = true
}
//上一个点的引线
if (!mPathLayerTemp.isEnabled) {
mPathLayerTemp.isEnabled = true
}
val geoPoint = GeoPoint(
mMapView.vtmMap.mapPosition.latitude, mMapView.vtmMap.mapPosition.longitude
)
//编辑点
if (editIndex > -1) {
if (mPathMakers.size > editIndex) {
markerLayer.removeItem(editIndex)
mPathMakers.removeAt(editIndex)
val markerItem = MarkerItem(createUUID(), "", "", geoPoint)
markerLayer.addItem(markerItem)
mPathMakers.add(editIndex, markerItem)
if (mPathLayer.points.size > 0) {
val list: MutableList<GeoPoint> = mPathLayer.points
if (editIndex < list.size) {
list.removeAt(editIndex)
val list2: MutableList<GeoPoint> = java.util.ArrayList(list)
list2.add(editIndex, geoPoint)
mPathLayer.setPoints(list2)
}
} else if (mPolygonLayer.points.size > 0) {
val list = mPolygonLayer.points
if (editIndex < list.size) {
list.removeAt(editIndex)
val list2: MutableList<GeoPoint> = java.util.ArrayList(list)
list2.add(editIndex, geoPoint)
mPolygonLayer.setPoints(list2)
}
}
mPathLayerTemp.setStyle(newTempStyle)
val list: MutableList<GeoPoint> = java.util.ArrayList<GeoPoint>()
if (isPolygon && mPathMakers.size > 1) {
list.add(mPathMakers[0].geoPoint)
list.add(geoPoint)
list.add(mPathMakers[mPathMakers.size - 1].geoPoint)
} else {
list.add(mPathMakers[mPathMakers.size - 1].geoPoint)
list.add(geoPoint)
}
mPathLayerTemp.setPoints(list)
}
editIndex = -1
} else { //新增点
if (isPolygon) {
val points: MutableList<GeoPoint> = java.util.ArrayList(mPolygonLayer.points)
if (points.size > 2) {
val list: MutableList<GeoPoint> = java.util.ArrayList()
points.add(points[0])
list.add(points[0])
list.add(geoPoint)
list.add(mPolygonLayer.points[mPolygonLayer.points.size - 1])
val bCross = GeometryTools.isPolygonCrosses(points, list)
if (bCross) {
Toast.makeText(mContext, "不能交叉", Toast.LENGTH_SHORT).show()
return
}
}
mPolygonLayer.addPoint(geoPoint)
} else {
val points: List<GeoPoint> = mPathLayer.points
if (points.size > 2) {
val list: MutableList<GeoPoint> = java.util.ArrayList()
list.add(geoPoint)
list.add(points[points.size - 1])
val bCross = GeometryTools.isLineStringCrosses(points, list)
if (bCross) {
Toast.makeText(mContext, "不能交叉", Toast.LENGTH_SHORT).show()
return
}
}
mPathLayer.addPoint(geoPoint)
if (mPathLayer.points.size > 1) {
val distance: Double = GeometryTools.getDistance(mPathLayer.points)
val bg = BigDecimal(distance)
val f1 = bg.setScale(3, BigDecimal.ROUND_HALF_UP).toDouble()
lineLenghtLiveData.value = f1
}
}
val markerItem = MarkerItem(createUUID(), "", "", geoPoint)
markerLayer.addItem(markerItem)
mPathMakers.add(markerItem)
}
showAreaLayer()
}
@@ -298,10 +269,8 @@ open class MeasureLayerHandler(context: AppCompatActivity, mapView: NIMapView) :
* 隐藏面积计算
*/
open fun hideAreaLayer() {
if (mAreaLayer != null) {
mAreaLayer.removeAllItems()
mMapView.vtmMap.layers().remove(mAreaLayer)
}
mAreaLayer.removeAllItems()
mMapView.vtmMap.layers().remove(mAreaLayer)
}
@@ -309,46 +278,39 @@ open class MeasureLayerHandler(context: AppCompatActivity, mapView: NIMapView) :
* 显示面积计算
*/
open fun showAreaLayer() {
if (mAreaLayer != null) {
mAreaLayer.removeAllItems()
mMapView.vtmMap.layers().remove(mAreaLayer)
}
if (mPolygonLayer != null && mPolygonLayer.points.size > 2) {
mAreaLayer.removeAllItems()
mMapView.vtmMap.layers().remove(mAreaLayer)
if (mPolygonLayer.points.size > 2) {
val list: MutableList<GeoPoint> = ArrayList(mPolygonLayer.points)
val area = DistanceUtil.planarPolygonAreaMeters2(list)
var areaString: String
if (area < 1000000) {
areaString = area.toString() + "平方米"
val areaString = if (area < 1000000) {
area.toString() + "平方米"
} else if (area < 10000000000.0) {
val d = area / 1000000.0
val bg = BigDecimal(d)
val f1 = bg.setScale(1, BigDecimal.ROUND_HALF_UP).toDouble()
areaString = f1.toString() + "平方公里"
f1.toString() + "平方公里"
} else {
val d = area / 10000000000.0
val bg = BigDecimal(d)
val f1 = bg.setScale(1, BigDecimal.ROUND_HALF_UP).toDouble()
areaString = f1.toString() + "万平方公里"
f1.toString() + "万平方公里"
}
val textPaint = TextPaint()
textPaint.textSize = 13 * CanvasAdapter.getScale()
textPaint.color = Color.BLUE
val width = Math.ceil(textPaint.measureText(areaString).toDouble()).toInt()
val width = ceil(textPaint.measureText(areaString).toDouble()).toInt()
val fontMetrics = textPaint.fontMetrics
val height =
Math.ceil((Math.abs(fontMetrics.bottom) + Math.abs(fontMetrics.top)).toDouble())
.toInt()
val height = ceil((abs(fontMetrics.bottom) + abs(fontMetrics.top)).toDouble()).toInt()
val bitmap = android.graphics.Bitmap.createBitmap(
width,
height,
android.graphics.Bitmap.Config.ARGB_8888
width, height, android.graphics.Bitmap.Config.ARGB_8888
)
val canvas = Canvas(bitmap)
canvas.drawText(areaString, 0f, Math.abs(fontMetrics.ascent), textPaint)
val bitmap2: Bitmap = AndroidBitmap(bitmap)
val markerSymbol = MarkerSymbol(bitmap2, MarkerSymbol.HotspotPlace.CENTER)
mAreaLayer = ItemizedLayer(mMapView.vtmMap, ArrayList(), markerSymbol, null)
mMapView.vtmMap.layers().add(mAreaLayer)
canvas.drawText(areaString, 0f, abs(fontMetrics.ascent), textPaint)
// val bitmap2: Bitmap = AndroidBitmap(bitmap)
// val markerSymbol = MarkerSymbol(bitmap2, MarkerSymbol.HotspotPlace.CENTER)
// mAreaLayer = ItemizedLayer(mMapView.vtmMap, ArrayList(), markerSymbol, null)
// mMapView.vtmMap.layers().add(mAreaLayer)
list.add(list[0])
val polygon = GeometryTools.createPolygon(list)
val point = polygon.centroid
@@ -360,66 +322,119 @@ open class MeasureLayerHandler(context: AppCompatActivity, mapView: NIMapView) :
}
open fun removeLine() {
// bDrawLine = false
// editIndex = -1
// for (item in mPathMakers) {
// mMapView.layerManager.removeMarker(item, NILayerManager.MARQUEE_MARKER_LAYER)
// }
// mPathMakers.clear()
// if (mPathLayer != null) {
// mPathLayer.clearPath()
// mPathLayer.isEnabled = false
// }
// if (mPolygonLayer != null) {
// mPolygonLayer.clearPath()
// mPolygonLayer.isEnabled = false
// }
// if (mPathLayerTemp != null) {
// mPathLayerTemp.clearPath()
// mPathLayerTemp.isEnabled = false
// mPathLayerTemp.setStyle(newTempStyle)
// }
bDrawLine = false
editIndex = -1
markerLayer.removeAllItems()
mPathMakers.clear()
mPathLayer.clearPath()
mPathLayer.isEnabled = false
mPolygonLayer.clearPath()
mPolygonLayer.isEnabled = false
mPathLayerTemp.clearPath()
mPathLayerTemp.isEnabled = false
mPathLayerTemp.setStyle(newTempStyle)
hideAreaLayer()
}
fun clean() {
fun clear() {
removeLine()
mMapView.vtmMap.updateMap(true)
}
override fun onMapEvent(e: Event?, mapPosition: MapPosition?) {
override fun onMapEvent(e: Event, mapPosition: MapPosition) {
if (!bDrawLine) return
// if (mMapView.centerPixel[1] > mMapView.vtmMap.height / 2) {
// val geoPoint =
// mMapView.vtmMap.viewport()
// .fromScreenPoint(
// mMapView.centerPixel[0],
// mMapView.vtmMap.height - mMapView.centerPixel[1]
// )
// mapPosition.setPosition(geoPoint)
// }
if (e === Map.POSITION_EVENT) {
if (mPathLayer.points.size > 0) {
if (editIndex > -1) {
val list: MutableList<GeoPoint> = mutableListOf()
if (editIndex == 0 || editIndex == mPathMakers.size - 1) {
list.add(mPathMakers[editIndex].geoPoint)
list.add(
GeoPoint(
mapPosition.latitude, mapPosition.longitude
)
)
} else {
list.add(mPathMakers[editIndex - 1].geoPoint)
list.add(
GeoPoint(
mapPosition.latitude, mapPosition.longitude
)
)
list.add(mPathMakers[editIndex + 1].geoPoint)
}
mPathLayerTemp.setPoints(list)
// crossText.setText("")
} else {
val list: MutableList<GeoPoint> = mutableListOf()
list.add(mPathLayer.points[mPathLayer.points.size - 1])
val nowPoint = GeoPoint(
mapPosition.latitude, mapPosition.longitude
)
list.add(
nowPoint
)
mPathLayerTemp.setPoints(list)
if (mPathLayer.points.size > 0) {
val dList = mPathLayer.points.toMutableList()
dList.add(nowPoint)
val distance: Double =
GeometryTools.getDistance(dList)
if (distance < 1000) {
tempLineDistanceLiveData.value = "${distance.toInt()}"
} else {
try {
val d = distance / 1000.0
val bg = BigDecimal(d)
val f1 =
bg.setScale(1, BigDecimal.ROUND_HALF_UP).toDouble()
tempLineDistanceLiveData.value = "${f1}公里"
} catch (e: Exception) {
Log.e("jingo",e.toString() + "$distance")
}
}
}
}
}
}
}
private val itemGestureListener: OnItemGestureListener<*> =
private val itemGestureListener: OnItemGestureListener<MarkerInterface> =
object : OnItemGestureListener<MarkerInterface> {
override fun onItemSingleTapUp(index: Int, item: MarkerInterface): Boolean {
if (bDrawLine) {
// for (i in mPathMakers.indices) {
// val item1 = mPathMakers[i]
// if (item === item1) {
// mMapView.layerManager.jumpToPosition(
// item.getPoint().longitude,
// item.getPoint().latitude,
// 0
// )
// editIndex = i
// if (mPathLayerTemp != null) {
// mPathLayerTemp.setStyle(editTempStyle)
// val list: MutableList<GeoPoint> = java.util.ArrayList<GeoPoint>()
// if (editIndex == 0 || editIndex == mPathMakers.size - 1) {
// list.add(item.geoPoint as Nothing)
// list.add(item.geoPoint as Nothing)
// } else {
// list.add(mPathMakers[editIndex - 1].geoPoint as Nothing)
// list.add(item.geoPoint as Nothing)
// list.add(mPathMakers[editIndex + 1].geoPoint as Nothing)
// }
// mPathLayerTemp.setPoints(list)
// }
// return true
// }
// }
for (i in mPathMakers.indices) {
val item1 = mPathMakers[i]
if (item === item1) {
mMapView.vtmMap.animator().animateTo(
GeoPoint(
item.getPoint().latitude, item.getPoint().longitude
)
)
editIndex = i
mPathLayerTemp.setStyle(editTempStyle)
val list: MutableList<GeoPoint> = mutableListOf()
if (editIndex == 0 || editIndex == mPathMakers.size - 1) {
list.add(item.getPoint())
list.add(item.getPoint())
} else {
list.add(mPathMakers[editIndex - 1].geoPoint)
list.add(item.getPoint())
list.add(mPathMakers[editIndex + 1].geoPoint)
}
mPathLayerTemp.setPoints(list)
return true
}
}
}
return false
}

View File

@@ -1,6 +1,5 @@
package com.navinfo.collect.library.utils
import java.text.ParsePosition
import java.text.SimpleDateFormat
import java.util.*