Navigation Image

This commit is contained in:
Dimitris
2025-11-25 15:14:34 +01:00
parent b1a9a2c7fe
commit ce382e304c
20 changed files with 437 additions and 244 deletions

View File

@@ -119,7 +119,9 @@ data class ValhallaLocation (
object Constants {
const val STYLE: String = "https://kouros-online.de/liberty.json"
//baseStyle = BaseStyle.Uri("https://tiles.openfreemap.org/styles/liberty"),
//const val STYLE: String = "https://tiles.openfreemap.org/styles/liberty"
//const val STYLE: String = "https://tiles.openfreemap.org/styles/dark"
const val TAG: String = "Navigation"
const val CONTACTS: String = "Contacts"

View File

@@ -0,0 +1,11 @@
package com.kouros.navigation.data.valhalla
import com.google.gson.annotations.SerializedName
data class ExitBranchElements (
@SerializedName("text" ) var text : String? = null,
@SerializedName("consecutive_count" ) var consecutiveCount : Int? = null
)

View File

@@ -0,0 +1,10 @@
package com.kouros.navigation.data.valhalla
import com.google.gson.annotations.SerializedName
data class ExitTowardElements (
@SerializedName("text" ) var text : String? = null
)

View File

@@ -10,8 +10,7 @@ import kotlinx.serialization.json.JsonIgnoreUnknownKeys
@JsonIgnoreUnknownKeys
data class Maneuvers(
@SerializedName("begin_shape_index") var beginShapeIndex: Int,
@SerializedName("end_shape_index") var endShapeIndex: Int,
@SerializedName("type") var type: Int = 0,
@SerializedName("instruction") var instruction: String = "",
@SerializedName("verbal_succinct_transition_instruction") var verbalSuccinctTransitionInstruction: String = "",
@@ -23,6 +22,10 @@ data class Maneuvers(
@SerializedName("length") var length: Double = 0.0,
@SerializedName("cost") var cost: Double = 0.0,
@SerializedName("verbal_multi_cue") var verbalMultiCue: Boolean = false,
@SerializedName("begin_shape_index") var beginShapeIndex: Int,
@SerializedName("end_shape_index") var endShapeIndex: Int,
@SerializedName("highway") var highway: Boolean = false,
@SerializedName("sign") var sign: Sign = Sign(),
@SerializedName("travel_mode") var travelMode: String = "",
@SerializedName("travel_type") var travelType: String = "",

View File

@@ -0,0 +1,11 @@
package com.kouros.navigation.data.valhalla
import com.google.gson.annotations.SerializedName
data class Sign (
@SerializedName("exit_branch_elements" ) var exitBranchElements : ArrayList<ExitBranchElements> = arrayListOf(),
@SerializedName("exit_toward_elements" ) var exitTowardElements : ArrayList<ExitTowardElements> = arrayListOf()
)

View File

@@ -36,7 +36,7 @@ class Contacts(private var context: Context) {
if (name.contains("Jola")
|| name.contains("Dominic")
|| name.contains("Martha")
|| name.contains("Μεντη")
|| name.contains("Rena")
|| name.contains("David")) {
val mimeType: String = getString(getColumnIndex(ContactsContract.Data.MIMETYPE))
if (mimeType == ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE) {

View File

@@ -6,8 +6,11 @@ import com.kouros.navigation.data.Constants.homeLocation
import com.kouros.navigation.data.Place
import com.kouros.navigation.data.Route
import com.kouros.navigation.data.StepData
import com.kouros.navigation.utils.NavigationUtils
import com.kouros.navigation.utils.location
import org.maplibre.geojson.FeatureCollection
import org.maplibre.geojson.Point
import org.maplibre.turf.TurfMeasurement
import kotlin.math.absoluteValue
import kotlin.math.roundToInt
@@ -47,15 +50,12 @@ open class RouteModel() {
private fun createCenterLocation(): Location {
if (route.summary.maxLat == 0.0) {
return location(homeLocation.latitude, homeLocation.longitude)
}
val latitude =
route.summary.maxLat - (route.summary.maxLat - route.summary.minLat)
val longitude =
route.summary.maxLon - (route.summary.maxLon - route.summary.minLon)
return location(latitude, longitude)
val future = TurfMeasurement.center(FeatureCollection.fromJson(route.routeGeoJson))
val point = future.geometry() as Point
return location(point.latitude(), point.longitude())
}
val currentDistance: Double
/** Returns the current [Step] with information such as the cue text and images. */
get() {

View File

@@ -10,10 +10,14 @@ import com.kouros.navigation.data.GeoJsonFeature
import com.kouros.navigation.data.GeoJsonFeatureCollection
import com.kouros.navigation.data.GeoJsonLineString
import kotlinx.serialization.json.Json
import org.maplibre.geojson.Feature
import org.maplibre.geojson.FeatureCollection
import org.maplibre.geojson.LineString
import org.maplibre.geojson.Point
import org.maplibre.turf.TurfClassification
import org.maplibre.turf.TurfConversion
import org.maplibre.turf.TurfJoins
import org.maplibre.turf.TurfMeasurement
import org.maplibre.turf.TurfMeta
import org.maplibre.turf.TurfMisc
import org.maplibre.turf.TurfTransformation
@@ -99,7 +103,8 @@ object NavigationUtils {
return coordinates
}
fun createGeoJson(lineCoordinates: List<List<Double>>): String {
fun createGeoJson(lineCoordinates: List<List<Double>>): String {
val lineString = GeoJsonLineString(type = "LineString", coordinates = lineCoordinates)
val feature = GeoJsonFeature(type = "Feature", geometry = lineString)
val featureCollection =
@@ -163,7 +168,7 @@ fun calculateZoom(speed: Double?): Double {
in 31..40 -> 16.0
in 41..50 -> 15.0
in 51..60 -> 14.0
else -> 11
else -> 14
}
return zoom.toDouble()
}