CheckRoute, Simulation, Closed Streets
This commit is contained in:
@@ -3,7 +3,7 @@ package com.kouros.navigation.data
|
||||
import androidx.compose.ui.graphics.Color
|
||||
|
||||
val NavigationColorLight = Color(0xFF17A119)
|
||||
val NavigationColorDark = Color(0xFF1055DE)
|
||||
val NavigationColorDark = Color(0xFF2B007A)
|
||||
|
||||
val RouteColor = Color(0xFF5201B4)
|
||||
|
||||
@@ -18,7 +18,6 @@ val SlowColor = Color(0xFFC43E3E)
|
||||
val StationaryColor = Color(0xFF910A0A)
|
||||
val HeavyColor = Color(0xFF6B0404)
|
||||
val RoadworksColor = Color(0xFFDAA707)
|
||||
val ClosedColor = Color(0xFF280C10)
|
||||
val LaneColor = Color(0xFFEFBAC1)
|
||||
|
||||
val PharmacyColor = Color(0xFF054603)
|
||||
@@ -166,6 +166,8 @@ object Constants {
|
||||
const val TILT = 60.0
|
||||
|
||||
const val TANKER_KOENIG_DELAY = 300000
|
||||
|
||||
const val LAST_CHECK_ROUTE_DISTANCE = 5000
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,7 +21,7 @@ const val tomtomTrafficUrl = "https://api.tomtom.com/traffic/services/5/incident
|
||||
private const val tomtomFields =
|
||||
"{incidents{type,geometry{type,coordinates},properties{iconCategory,events{description}}}}"
|
||||
|
||||
val useLocal = BuildConfig.DEBUG
|
||||
val useLocal = BuildConfig.DEBUG
|
||||
|
||||
val useLocalTraffic = BuildConfig.DEBUG
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.kouros.navigation.model
|
||||
|
||||
import android.content.Context
|
||||
import android.location.Location
|
||||
import android.util.Log
|
||||
import androidx.compose.runtime.snapshots.SnapshotStateList
|
||||
import androidx.compose.runtime.toMutableStateList
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
@@ -14,7 +13,6 @@ import com.kouros.navigation.data.Constants
|
||||
import com.kouros.navigation.data.Constants.FAVORITES
|
||||
import com.kouros.navigation.data.Constants.SPEED_BEARING_DEVIATION
|
||||
import com.kouros.navigation.data.Constants.SPEED_UPDATE_DISTANCE
|
||||
import com.kouros.navigation.data.Constants.TAG
|
||||
import com.kouros.navigation.data.Constants.TANKER_KOENIG_DELAY
|
||||
import com.kouros.navigation.data.NavigationRepository
|
||||
import com.kouros.navigation.data.Place
|
||||
@@ -30,7 +28,8 @@ import com.kouros.navigation.data.overpass.Elements
|
||||
import com.kouros.navigation.data.overpass.Overpass
|
||||
import com.kouros.navigation.repository.SettingsRepository
|
||||
import com.kouros.navigation.utils.GeoUtils.snapLocation
|
||||
import com.kouros.navigation.utils.GeoUtils.transferCoordinates
|
||||
import com.kouros.navigation.utils.GeoUtils.buildLineStrings
|
||||
import com.kouros.navigation.utils.GeoUtils.buildPointCollection
|
||||
import com.kouros.navigation.utils.bearingPositive
|
||||
import com.kouros.navigation.utils.countryCodeSpeedLimit
|
||||
import com.kouros.navigation.utils.getSettingsRepository
|
||||
@@ -290,25 +289,25 @@ class NavigationViewModel(private val repository: NavigationRepository) : ViewMo
|
||||
val incidents = mutableMapOf<String, String>()
|
||||
val queuing = featureCollection.features()!!
|
||||
.filter { it.properties()!!.get("events").toString().contains("Queuing traffic") }
|
||||
incidents["queuing"] = transferCoordinates(queuing)
|
||||
incidents["queuing"] = buildLineStrings(queuing)
|
||||
val stationary = featureCollection.features()!!
|
||||
.filter { it.properties()!!.get("events").toString().contains("Stationary traffic") }
|
||||
incidents["stationary"] = transferCoordinates(stationary)
|
||||
incidents["stationary"] = buildLineStrings(stationary)
|
||||
val slow = featureCollection.features()!!
|
||||
.filter { it.properties()!!.get("events").toString().contains("Slow traffic") }
|
||||
incidents["slow"] = transferCoordinates(slow)
|
||||
incidents["slow"] = buildLineStrings(slow)
|
||||
val heavy = featureCollection.features()!!
|
||||
.filter { it.properties()!!.get("events").toString().contains("Heavy traffic") }
|
||||
incidents["heavy"] = transferCoordinates(heavy)
|
||||
incidents["heavy"] = buildLineStrings(heavy)
|
||||
val roadworks = featureCollection.features()!!
|
||||
.filter { it.properties()!!.get("events").toString().contains("Roadworks") }
|
||||
incidents["roadworks"] = transferCoordinates(roadworks)
|
||||
incidents["roadworks"] = buildLineStrings(roadworks)
|
||||
val laneClosed = featureCollection.features()!!
|
||||
.filter { it.properties()!!.get("events").toString().contains("Lane closed") }
|
||||
incidents["lane"] = transferCoordinates(laneClosed)
|
||||
incidents["lane"] = buildLineStrings(laneClosed)
|
||||
val closed = featureCollection.features()!!
|
||||
.filter { it.properties()!!.get("events").toString().contains("Closed") }
|
||||
incidents["closed"] = transferCoordinates(closed)
|
||||
incidents["closed"] = buildPointCollection(closed)
|
||||
|
||||
return incidents
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.maplibre.spatialk.geojson.Feature
|
||||
import org.maplibre.spatialk.geojson.dsl.addFeature
|
||||
import org.maplibre.spatialk.geojson.dsl.buildFeatureCollection
|
||||
import org.maplibre.spatialk.geojson.dsl.buildLineString
|
||||
import org.maplibre.spatialk.geojson.dsl.buildMultiPoint
|
||||
import org.maplibre.spatialk.geojson.toJson
|
||||
import org.maplibre.turf.TurfMeasurement
|
||||
import org.maplibre.turf.TurfMisc
|
||||
@@ -136,7 +137,7 @@ object GeoUtils {
|
||||
return points
|
||||
}
|
||||
|
||||
fun createEndCollection(geoJson: String): String {
|
||||
fun createPointCollection(geoJson: String): String {
|
||||
val featureCollection = FeatureCollection.fromJson(geoJson)
|
||||
val geometry = featureCollection.features()!!.first().geometry()
|
||||
val coordinates = (geometry as LineString)
|
||||
@@ -187,41 +188,66 @@ object GeoUtils {
|
||||
return isInside
|
||||
}
|
||||
|
||||
fun transferCoordinates(features: List<org.maplibre.geojson.Feature>): String {
|
||||
fun buildLineStrings(features: List<org.maplibre.geojson.Feature>): String {
|
||||
return buildFeatureCollection {
|
||||
features.forEach {
|
||||
val movedCoordinates = arrayListOf<org.maplibre.spatialk.geojson.Point>()
|
||||
val coordinates = it.geometry() as LineString
|
||||
val geo = coordinates.coordinates()
|
||||
var bearing = 0.0F
|
||||
for (index in 0..<geo.size) {
|
||||
val current = location(geo[index].longitude(), geo[index].latitude())
|
||||
bearing = if (index < geo.size - 1) {
|
||||
val next =
|
||||
location(geo[index + 1].longitude(), geo[index + 1].latitude())
|
||||
current.bearingPositive(next)
|
||||
} else {
|
||||
bearing
|
||||
}
|
||||
val point = movePoint(
|
||||
current.latitude,
|
||||
current.longitude,
|
||||
bearingDegrees = bearing + 90.0
|
||||
val coordinates = it.geometry() as LineString
|
||||
val geo = coordinates.coordinates()
|
||||
var bearing = 0.0F
|
||||
for (index in 0..<geo.size) {
|
||||
val current = location(geo[index].longitude(), geo[index].latitude())
|
||||
bearing = if (index < geo.size - 1) {
|
||||
val next =
|
||||
location(geo[index + 1].longitude(), geo[index + 1].latitude())
|
||||
current.bearingPositive(next)
|
||||
} else {
|
||||
bearing
|
||||
}
|
||||
val point = movePoint(
|
||||
current.latitude,
|
||||
current.longitude,
|
||||
bearingDegrees = bearing + 90.0
|
||||
)
|
||||
movedCoordinates.add(point)
|
||||
}
|
||||
val lineString = buildLineString {
|
||||
movedCoordinates.forEach { ft ->
|
||||
add(
|
||||
ft
|
||||
)
|
||||
movedCoordinates.add(point)
|
||||
}
|
||||
val lineString = buildLineString {
|
||||
movedCoordinates.forEach { ft ->
|
||||
add(
|
||||
ft
|
||||
)
|
||||
}
|
||||
}
|
||||
addFeature {
|
||||
geometry = lineString
|
||||
properties = buildJsonObject { null }
|
||||
}
|
||||
}
|
||||
addFeature {
|
||||
geometry = lineString
|
||||
properties = buildJsonObject { null }
|
||||
}
|
||||
}
|
||||
}.toJson()
|
||||
}
|
||||
|
||||
fun buildPointCollection(features: List<org.maplibre.geojson.Feature>): String {
|
||||
return buildFeatureCollection {
|
||||
features.forEach {
|
||||
val movedCoordinates = arrayListOf<org.maplibre.spatialk.geojson.Point>()
|
||||
val coordinates = it.geometry() as LineString
|
||||
val geo = coordinates.coordinates()
|
||||
var point = org.maplibre.spatialk.geojson.Point(geo.first().longitude(), geo.first().latitude())
|
||||
movedCoordinates.add(point)
|
||||
point = org.maplibre.spatialk.geojson.Point(geo.last().longitude(), geo.last().latitude())
|
||||
movedCoordinates.add(point)
|
||||
val multiPoint = buildMultiPoint {
|
||||
movedCoordinates.forEach { ft ->
|
||||
add(
|
||||
ft
|
||||
)
|
||||
}
|
||||
}
|
||||
addFeature {
|
||||
geometry = multiPoint
|
||||
properties = buildJsonObject { null }
|
||||
}
|
||||
}
|
||||
}.toJson()
|
||||
}
|
||||
|
||||
|
||||
@@ -49,18 +49,20 @@ object NavigationUtils {
|
||||
}
|
||||
|
||||
fun calculateZoom(speed: Double?): Double {
|
||||
val zoom = 16.5
|
||||
if (speed == null) {
|
||||
return 17.0
|
||||
return zoom
|
||||
}
|
||||
val speedKmh = (speed * 3.6).toInt()
|
||||
val zoom = when (speedKmh) {
|
||||
in 0..10 -> 17.0
|
||||
in 11..30 -> 17.5
|
||||
in 31..65 -> 17.0
|
||||
in 66..70 -> 16.5
|
||||
else -> 16.0
|
||||
return when (speedKmh) {
|
||||
in 0..10 -> zoom + 1.0
|
||||
in 11..30 -> zoom + 0.5
|
||||
in 31..65 -> zoom
|
||||
in 66..70 -> zoom - 0.5
|
||||
in 71..90 -> zoom - 1.0
|
||||
in 91..100 -> zoom - 2.0
|
||||
else -> zoom - 3.0
|
||||
}
|
||||
return zoom
|
||||
}
|
||||
|
||||
fun previewZoom(centerLocation: Location, previewDistance: Double): Double {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M280,520L680,520L680,440L280,440L280,520ZM480,880Q397,880 324,848.5Q251,817 197,763Q143,709 111.5,636Q80,563 80,480Q80,397 111.5,324Q143,251 197,197Q251,143 324,111.5Q397,80 480,80Q563,80 636,111.5Q709,143 763,197Q817,251 848.5,324Q880,397 880,480Q880,563 848.5,636Q817,709 763,763Q709,817 636,848.5Q563,880 480,880Z"/>
|
||||
</vector>
|
||||
Reference in New Issue
Block a user