mirror of
https://github.com/Dasemu/NavFrame.git
synced 2026-11-26 15:26:05 +00:00
Merge pull request #15 from Dasemu/feat/gpx-route-road-calculation
Feat/gpx route road calculation
This commit is contained in:
5 files changed
+54
-5
No files matched your search
@@ -6,7 +6,7 @@ NavFrame is an experimental Android navigation app that renders its own 480×240
|
|||||||
|
|
||||||
The owner has confirmed static and synthetic NavFrame frames on a Xiaomi 11 Lite 5G NE running Android 14 and a 2026 Yamaha MT-07, and the bundled Asturias map working offline on the phone. On 2026-10-12, the owner reported that the latest version displayed the map on the TFT for about 20 minutes, then showed `Mapa no disponible` in La Corredoria (Oviedo) for the rest of the trip while the phone map continued working. An offline map was installed. The exact installed build, diagnostic code and background state were not recorded; the cause is under investigation. This establishes a successful map display followed by a persistent failure, not sustained TFT reliability.
|
The owner has confirmed static and synthetic NavFrame frames on a Xiaomi 11 Lite 5G NE running Android 14 and a 2026 Yamaha MT-07, and the bundled Asturias map working offline on the phone. On 2026-10-12, the owner reported that the latest version displayed the map on the TFT for about 20 minutes, then showed `Mapa no disponible` in La Corredoria (Oviedo) for the rest of the trip while the phone map continued working. An offline map was installed. The exact installed build, diagnostic code and background state were not recorded; the cause is under investigation. This establishes a successful map display followed by a persistent failure, not sustained TFT reliability.
|
||||||
|
|
||||||
The current checkout is version 0.14.6. The 0.13 series adds voice/routing language selection for Spanish, English, German, French, and Italian, plus a system-language option; unsupported system locales resolve to English. Speech still depends on the Android TextToSpeech engine and its installed voice data. The app includes offline map and place data for Asturias, plus installable regional packages. Worldwide regions can be discovered and built on demand through the [regional package workflow](docs/GLOBAL_OFFLINE.md); this is not complete worldwide coverage. Installed packages currently provide map and local place/camera data. Offline route calculation, global camera completeness, and complete worldwide font coverage are not provided.
|
The current checkout is version 0.14.7. The 0.13 series adds voice/routing language selection for Spanish, English, German, French, and Italian, plus a system-language option; unsupported system locales resolve to English. Speech still depends on the Android TextToSpeech engine and its installed voice data. The app includes offline map and place data for Asturias, plus installable regional packages. Worldwide regions can be discovered and built on demand through the [regional package workflow](docs/GLOBAL_OFFLINE.md); this is not complete worldwide coverage. Installed packages currently provide map and local place/camera data. Offline route calculation, global camera completeness, and complete worldwide font coverage are not provided.
|
||||||
|
|
||||||
Route calculation and address search use configurable online services. Spoken output uses the selected language when Android provides voice data; voice availability and offline behavior depend on the device's TextToSpeech engine. Physical validation of route guidance, voice playback, camera alerts, sustained TFT map rendering, and a 30-minute screen-off session remains pending unless a newer test report says otherwise.
|
Route calculation and address search use configurable online services. Spoken output uses the selected language when Android provides voice data; voice availability and offline behavior depend on the device's TextToSpeech engine. Physical validation of route guidance, voice playback, camera alerts, sustained TFT map rendering, and a 30-minute screen-off session remains pending unless a newer test report says otherwise.
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ android {
|
|||||||
applicationId = "dev.navframe.app"
|
applicationId = "dev.navframe.app"
|
||||||
minSdk = 26
|
minSdk = 26
|
||||||
targetSdk = 35
|
targetSdk = 35
|
||||||
versionName = "0.14.6"
|
versionName = "0.14.7"
|
||||||
versionCode = 23
|
versionCode = 24
|
||||||
}
|
}
|
||||||
if (hasReleaseSigning) {
|
if (hasReleaseSigning) {
|
||||||
signingConfigs.create("production") {
|
signingConfigs.create("production") {
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ open class MainActivity : Activity() {
|
|||||||
private var searchJob: Job? = null
|
private var searchJob: Job? = null
|
||||||
private var positionWait: Job? = null
|
private var positionWait: Job? = null
|
||||||
private var importJob: Job? = null
|
private var importJob: Job? = null
|
||||||
|
private var lastImportedRoute: ImportedRoute? = null
|
||||||
private var pendingImportUri: Uri? = null
|
private var pendingImportUri: Uri? = null
|
||||||
private var searchGeneration = 0L
|
private var searchGeneration = 0L
|
||||||
private var updatingDestination = false
|
private var updatingDestination = false
|
||||||
@@ -356,6 +357,7 @@ open class MainActivity : Activity() {
|
|||||||
val current = service ?: run { hint.text = "Servicio no disponible · vuelve a cargar el GPX"; return@launch }
|
val current = service ?: run { hint.text = "Servicio no disponible · vuelve a cargar el GPX"; return@launch }
|
||||||
cancelSearch(); routeDialog?.dismiss()
|
cancelSearch(); routeDialog?.dismiss()
|
||||||
current.prepareImportedRoute(imported)
|
current.prepareImportedRoute(imported)
|
||||||
|
lastImportedRoute = imported
|
||||||
destination = null; destinationName = ""
|
destination = null; destinationName = ""
|
||||||
hint.text = "Ruta GPX cargada"
|
hint.text = "Ruta GPX cargada"
|
||||||
showImportedRouteSheet(imported.name)
|
showImportedRouteSheet(imported.name)
|
||||||
@@ -373,6 +375,11 @@ open class MainActivity : Activity() {
|
|||||||
val box = column().apply { setPadding(dp(20), dp(16), dp(20), dp(16)) }
|
val box = column().apply { setPadding(dp(20), dp(16), dp(20), dp(16)) }
|
||||||
box.addView(label(name ?: "Ruta GPX", 20f))
|
box.addView(label(name ?: "Ruta GPX", 20f))
|
||||||
box.addView(routeInfo)
|
box.addView(routeInfo)
|
||||||
|
lastImportedRoute?.takeIf { !it.isTrack && it.route.geometry.size in 2..50 }?.let { imported ->
|
||||||
|
box.addView(button("Calcular por carreteras · evitar autopistas") {
|
||||||
|
service?.calculateImportedStops(imported)
|
||||||
|
})
|
||||||
|
}
|
||||||
routeLoading = ProgressBar(this).apply { visibility = View.GONE }
|
routeLoading = ProgressBar(this).apply { visibility = View.GONE }
|
||||||
box.addView(routeLoading)
|
box.addView(routeLoading)
|
||||||
retryRouteButton = null
|
retryRouteButton = null
|
||||||
|
|||||||
@@ -586,6 +586,47 @@ class TftService : Service() {
|
|||||||
mutableRouteInfo.value = "GPX · %.1f km · %d puntos\nSigue el trazado: sin instrucciones de giro, ETA ni recálculo automático. Revisa el recorrido antes de iniciar.".format(java.util.Locale.ROOT, imported.route.distanceMeters / 1000.0, imported.route.geometry.size)
|
mutableRouteInfo.value = "GPX · %.1f km · %d puntos\nSigue el trazado: sin instrucciones de giro, ETA ni recálculo automático. Revisa el recorrido antes de iniciar.".format(java.util.Locale.ROOT, imported.route.distanceMeters / 1000.0, imported.route.geometry.size)
|
||||||
if (!hasActiveGuidance()) showPreparedPreview()
|
if (!hasActiveGuidance()) showPreparedPreview()
|
||||||
}
|
}
|
||||||
|
/** Resolve GPX route stops against Valhalla; never alter a detailed imported track. */
|
||||||
|
fun calculateImportedStops(imported: ImportedRoute) {
|
||||||
|
if (imported.isTrack || imported.route.geometry.size !in 2..50) {
|
||||||
|
mutableRouteInfo.value = "Solo se pueden calcular rutas GPX con entre 2 y 50 puntos de paso."
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val stops = imported.route.geometry
|
||||||
|
val generation = preparedGeneration
|
||||||
|
val options = RouteOptions(profile = RouteProfile.AVOID_MOTORWAYS, avoidMotorways = true, avoidUnpaved = true)
|
||||||
|
mutableRouteInfo.value = "Calculando sobre carreteras · evitando autopistas y pistas sin asfaltar…"
|
||||||
|
routeJob?.cancel()
|
||||||
|
routeJob = scope.launch {
|
||||||
|
try {
|
||||||
|
val engine = routingEngineFactory(routingEndpoint())
|
||||||
|
val geometry = mutableListOf<GeoPoint>()
|
||||||
|
var metres = 0L
|
||||||
|
for (i in 0 until stops.lastIndex) {
|
||||||
|
val part = engine.calculateRoute(stops[i], stops[i + 1], options)
|
||||||
|
ensureActive()
|
||||||
|
if (part.geometry.size < 2) throw java.io.IOException("Segmento sin geometría")
|
||||||
|
geometry.addAll(if (i == 0) part.geometry else part.geometry.drop(1))
|
||||||
|
metres += part.distanceMeters
|
||||||
|
if (geometry.size > 10_000) throw IllegalArgumentException("La ruta supera 10000 puntos")
|
||||||
|
if (generation != preparedGeneration) return@launch
|
||||||
|
mutableRouteInfo.value = "Calculando carreteras · tramo ${i + 1}/${stops.lastIndex}"
|
||||||
|
}
|
||||||
|
ensureActive()
|
||||||
|
if (generation != preparedGeneration) return@launch
|
||||||
|
val result = RouteResult(geometry = geometry, maneuvers = emptyList(),
|
||||||
|
distanceMeters = metres.coerceAtMost(Int.MAX_VALUE.toLong()).toInt(),
|
||||||
|
durationSeconds = 0, destination = geometry.last(), imported = true)
|
||||||
|
prepareImportedRoute(ImportedRoute(imported.name, result, isTrack = true))
|
||||||
|
mutableRouteInfo.value = "GPX ajustado a carreteras · %.1f km · %d puntos\nComprueba que no haya autovías ni tramos inadecuados antes de salir. No hay avisos de giro ni recálculo.".format(java.util.Locale.ROOT, metres / 1000.0, geometry.size)
|
||||||
|
} catch (cancelled: CancellationException) {
|
||||||
|
throw cancelled
|
||||||
|
} catch (error: Exception) {
|
||||||
|
if (generation == preparedGeneration)
|
||||||
|
mutableRouteInfo.value = "No se pudo calcular sobre carreteras. Se conserva el GPX original; comprueba conexión y endpoint Valhalla."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
fun preparedRouteIsImported() = hasPreparedRoute() && routePlan?.route?.imported == true
|
fun preparedRouteIsImported() = hasPreparedRoute() && routePlan?.route?.imported == true
|
||||||
fun hasPreparedRoute() = !preparedDestinationDirty && routePlan != null
|
fun hasPreparedRoute() = !preparedDestinationDirty && routePlan != null
|
||||||
fun routeUsesGps() = !preparedDestinationDirty && routePlan?.demo == false
|
fun routeUsesGps() = !preparedDestinationDirty && routePlan?.demo == false
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import org.xml.sax.SAXException
|
|||||||
import org.xml.sax.ext.DefaultHandler2
|
import org.xml.sax.ext.DefaultHandler2
|
||||||
import kotlin.math.*
|
import kotlin.math.*
|
||||||
|
|
||||||
data class ImportedRoute(val name: String?, val route: RouteResult)
|
data class ImportedRoute(val name: String?, val route: RouteResult, val isTrack: Boolean = false)
|
||||||
|
|
||||||
/** Imports geometry only: GPX points do not establish road turns, speeds or travel time. */
|
/** Imports geometry only: GPX points do not establish road turns, speeds or travel time. */
|
||||||
object GpxRouteImporter {
|
object GpxRouteImporter {
|
||||||
@@ -52,7 +52,7 @@ object GpxRouteImporter {
|
|||||||
return ImportedRoute(handler.name?.trim()?.takeIf { it.isNotEmpty() }, RouteResult(
|
return ImportedRoute(handler.name?.trim()?.takeIf { it.isNotEmpty() }, RouteResult(
|
||||||
geometry = points.toList(), maneuvers = emptyList(), distanceMeters = distance.roundToInt().coerceAtLeast(1),
|
geometry = points.toList(), maneuvers = emptyList(), distanceMeters = distance.roundToInt().coerceAtLeast(1),
|
||||||
durationSeconds = 0, destination = points.last(), imported = true,
|
durationSeconds = 0, destination = points.last(), imported = true,
|
||||||
))
|
), handler.isTrack)
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Handler : DefaultHandler2() {
|
private class Handler : DefaultHandler2() {
|
||||||
@@ -61,6 +61,7 @@ object GpxRouteImporter {
|
|||||||
private var routeName: String? = null
|
private var routeName: String? = null
|
||||||
private var trackName: String? = null
|
private var trackName: String? = null
|
||||||
val points: List<GeoPoint> get() = if (tracks > 0) trackPoints else routePoints
|
val points: List<GeoPoint> get() = if (tracks > 0) trackPoints else routePoints
|
||||||
|
val isTrack: Boolean get() = tracks > 0
|
||||||
val name: String? get() = if (tracks > 0) trackName else routeName
|
val name: String? get() = if (tracks > 0) trackName else routeName
|
||||||
private val path = mutableListOf<String>()
|
private val path = mutableListOf<String>()
|
||||||
private var rootNamespace = ""
|
private var rootNamespace = ""
|
||||||
|
|||||||
Reference in new issue
Block a user