[2.13.2]fix bug of wgs84 to gaode
This commit is contained in:
@@ -9,7 +9,6 @@ import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity
|
||||
import com.mogo.eagle.core.function.v2x.events.bridge.BridgeApi.context
|
||||
import com.mogo.eagle.core.function.v2x.events.bridge.BridgeApi.v2xMarker
|
||||
import com.mogo.map.*
|
||||
import com.mogo.map.R.raw
|
||||
import com.mogo.map.marker.*
|
||||
import com.mogo.map.overlay.*
|
||||
import java.util.*
|
||||
@@ -33,7 +32,7 @@ object V2XAiRoadEventMarker {
|
||||
|
||||
private val overlayManager by lazy { MogoOverlayManager.getInstance() }
|
||||
|
||||
fun drawMarkers(entity: V2XRoadEventEntity): Pair<IMogoPolyline?, List<IMogoMarker>?>? {
|
||||
fun drawMarkers(entity: V2XRoadEventEntity) {
|
||||
removeMarkers(current.get())
|
||||
timerTask.get()?.cancel()
|
||||
val extra = entity.noveltyInfo.extras["polygon"]
|
||||
@@ -50,58 +49,42 @@ object V2XAiRoadEventMarker {
|
||||
if (first !is Double || second !is Double) {
|
||||
continue
|
||||
}
|
||||
val xx = CoordinateUtils.transformWgsToGcj(second, first)
|
||||
polygons.add(androidx.core.util.Pair.create(xx[0], xx[1]))
|
||||
polygons.add(androidx.core.util.Pair.create(second, first))
|
||||
}
|
||||
if (polygons.size > 0) {
|
||||
val markers = ArrayList<IMogoMarker>(polygons.size)
|
||||
for (i in polygons.indices) {
|
||||
val p = polygons[i]
|
||||
val options = MogoMarkerOptions().data(entity).latitude(p.second).longitude(p.first)
|
||||
options.anchor(0.5f, 0.5f)
|
||||
options.icon3DRes(raw.sanjiaozhui)
|
||||
try {
|
||||
val marker = MogoMarkerManager.getInstance(context()).addMarker("road_pyramid_" + entity.poiType, options)
|
||||
markers += marker
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
v2xMarker()?.drawableAlarmPOI(context(), entity, null)
|
||||
val l2 = entity.noveltyInfo?.location ?: return
|
||||
v2xLocation.set(MogoLocation().also {
|
||||
it.longitude = l2.lon; it.latitude = l2.lat; it.bearing = l2.angle.toFloat()
|
||||
})
|
||||
|
||||
val options = MogoPolylineOptions()
|
||||
val colors = ArrayList<Int>()
|
||||
colors.add(Color.argb(204, 237, 172, 21))
|
||||
colors.add(Color.argb(0, 255, 255, 255))
|
||||
options.colorValues(colors)
|
||||
val points = ArrayList<MogoLatLng>()
|
||||
|
||||
for (p in polygons) {
|
||||
points.add(MogoLatLng(p.first, p.second))
|
||||
}
|
||||
if (markers.size > 0) {
|
||||
v2xMarker()?.drawableAlarmPOI(context(), entity, null)
|
||||
val l2 = entity.noveltyInfo?.location ?: return null
|
||||
v2xLocation.set(MogoLocation().also { it.longitude = l2.lon; it.latitude = l2.lat; it.bearing = l2.angle.toFloat() })
|
||||
|
||||
val options = MogoPolylineOptions()
|
||||
val colors = ArrayList<Int>()
|
||||
colors.add(Color.argb(204, 237, 172, 21))
|
||||
colors.add(Color.argb(0, 255, 255, 255))
|
||||
options.colorValues(colors)
|
||||
val points = ArrayList<MogoLatLng>()
|
||||
|
||||
for (p in polygons) {
|
||||
points.add(MogoLatLng(p.second, p.first))
|
||||
}
|
||||
if (points.size > 2) {
|
||||
points.add(points[0])
|
||||
}
|
||||
options.points(points)
|
||||
options.useGradient(true)
|
||||
options.useFacade(true)
|
||||
options.setGps(false)
|
||||
options.width(5f)
|
||||
options.zIndex(75000f)
|
||||
options.maxIndex(800000f)
|
||||
val line = overlayManager.addPolyline(options)
|
||||
current.set(Pair(line, markers))
|
||||
if (line != null) {
|
||||
line.isVisible = true
|
||||
}
|
||||
if (points.size > 2) {
|
||||
points.add(points[0])
|
||||
}
|
||||
options.points(points)
|
||||
options.useGradient(true)
|
||||
options.useFacade(true)
|
||||
options.setGps(true)
|
||||
options.width(5f)
|
||||
options.zIndex(75000f)
|
||||
options.maxIndex(800000f)
|
||||
val line = overlayManager.addPolyline(options)
|
||||
if (line != null) {
|
||||
line.isVisible = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return current.get()
|
||||
}
|
||||
|
||||
fun removeMarkers(pair: Pair<IMogoPolyline?, List<IMogoMarker>?>?) {
|
||||
@@ -136,19 +119,34 @@ object V2XAiRoadEventMarker {
|
||||
val markerLocation = v2xLocation.get()
|
||||
carLocation.set(location)
|
||||
if (markerLocation != null) {
|
||||
if (isOutOfRange(markerLocation.longitude, markerLocation.latitude, location.longitude, location.latitude, location.bearing.toDouble())) {
|
||||
if (isOutOfRange(
|
||||
markerLocation.longitude,
|
||||
markerLocation.latitude,
|
||||
location.longitude,
|
||||
location.latitude,
|
||||
location.bearing.toDouble()
|
||||
)
|
||||
) {
|
||||
v2xLocation.set(null)
|
||||
this.distance.set(0)
|
||||
timer.schedule(object : TimerTask() {
|
||||
override fun run() {
|
||||
val carLocation = this@V2XAiRoadEventMarker.carLocation.get()
|
||||
Log.d("XXXXX", "timer do action ---: marker_lon: ${markerLocation.longitude}, marker_lat: ${markerLocation.latitude}, car_lon:${carLocation.longitude}, car_lat: ${carLocation.latitude}")
|
||||
checkDistanceIsValid(markerLocation.longitude, markerLocation.latitude, carLocation)
|
||||
Log.d(
|
||||
"XXXXX",
|
||||
"timer do action ---: marker_lon: ${markerLocation.longitude}, marker_lat: ${markerLocation.latitude}, car_lon:${carLocation.longitude}, car_lat: ${carLocation.latitude}"
|
||||
)
|
||||
checkDistanceIsValid(
|
||||
markerLocation.longitude,
|
||||
markerLocation.latitude,
|
||||
carLocation
|
||||
)
|
||||
}
|
||||
}.also { this.timerTask.set(it) }, 1000, 1000)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkDistanceIsValid(x1: Double, y1: Double, location: MogoLocation) {
|
||||
val distance = DrivingDirectionUtils.distance(x1, y1, location.longitude, location.latitude)
|
||||
Log.d("XXXXX", "distance: $distance")
|
||||
@@ -159,12 +157,30 @@ object V2XAiRoadEventMarker {
|
||||
}
|
||||
}
|
||||
|
||||
private fun isOutOfRange(markerLon: Double, markerLat: Double, carLon: Double, carLat: Double, carAngle: Double): Boolean {
|
||||
private fun isOutOfRange(
|
||||
markerLon: Double,
|
||||
markerLat: Double,
|
||||
carLon: Double,
|
||||
carLat: Double,
|
||||
carAngle: Double
|
||||
): Boolean {
|
||||
return !isFrontOfCar(markerLon, markerLat, carLon, carLat, carAngle)
|
||||
}
|
||||
|
||||
private fun isFrontOfCar(markerLon: Double, markerLat: Double, carLon: Double, carLat: Double, carAngle: Double): Boolean {
|
||||
val degree = DrivingDirectionUtils.getDegreeOfCar2Poi2(carLon, carLat, markerLon, markerLat, carAngle)
|
||||
private fun isFrontOfCar(
|
||||
markerLon: Double,
|
||||
markerLat: Double,
|
||||
carLon: Double,
|
||||
carLat: Double,
|
||||
carAngle: Double
|
||||
): Boolean {
|
||||
val degree = DrivingDirectionUtils.getDegreeOfCar2Poi2(
|
||||
carLon,
|
||||
carLat,
|
||||
markerLon,
|
||||
markerLat,
|
||||
carAngle
|
||||
)
|
||||
return degree < 90
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.utils
|
||||
|
||||
import android.util.Log
|
||||
import androidx.core.util.Pair
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnum.Companion.isRoadEvent
|
||||
@@ -12,7 +11,6 @@ import com.mogo.eagle.core.function.v2x.events.scenario.scene.airoad.AiRoadMarke
|
||||
import com.mogo.v2x.data.*
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import roadwork.Road
|
||||
import kotlin.math.abs
|
||||
|
||||
|
||||
fun V2XMarkerLocation?.toMarkerLocation(): MarkerLocation? =
|
||||
@@ -110,15 +108,9 @@ fun Road.RW_PB.toRoadMarker(): V2XMarkerCardResult =
|
||||
|
||||
fun MessagePad.TrackedObject.toRoadMarker(poiType: String): V2XMarkerCardResult =
|
||||
V2XMarkerCardResult().also { l1 ->
|
||||
Log.i("emArrow", "polygonList size : " + polygonList.size + " , step : ${abs(polygonList.size / 5)}")
|
||||
this.polygonList?.takeIf { it.isNotEmpty() }?.also { old ->
|
||||
val list = mutableListOf<MessagePad.Location>()
|
||||
for (i in 0 until old.size - 1 step abs(old.size / 5)) {
|
||||
list.add(old[i])
|
||||
}
|
||||
Log.i("emArrow", "road marker list filter size : " + list.size)
|
||||
l1.extras = HashMap<String, List<Pair<Double, Double>>>().also { extra ->
|
||||
extra["polygon"] = list.map { d -> Pair(d.longitude, d.latitude) }
|
||||
extra["polygon"] = old.map { d -> Pair(d.longitude, d.latitude) }
|
||||
extra["gps_location"] = listOf(Pair(this.longitude, this.latitude))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user