Skip to content

Commit

Permalink
Merge branch 'osmandapp:master' into hardy_Afa
Browse files Browse the repository at this point in the history
  • Loading branch information
sonora authored Sep 23, 2024
2 parents d384dc7 + f01edd8 commit b3a3a5c
Show file tree
Hide file tree
Showing 13 changed files with 252 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ import co.touchlab.stately.collections.ConcurrentMutableList
import co.touchlab.stately.collections.ConcurrentMutableMap
import co.touchlab.stately.concurrency.Synchronizable
import co.touchlab.stately.concurrency.synchronize
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.IO
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.runBlocking
import net.osmand.shared.api.SQLiteAPI.SQLiteConnection
import net.osmand.shared.data.StringIntPair
import net.osmand.shared.extensions.currentTimeMillis
import net.osmand.shared.gpx.GpxReader.GpxDbReaderCallback
import net.osmand.shared.io.KFile
import net.osmand.shared.util.LoggerFactory
import kotlin.random.Random


object GpxDbHelper : GpxDbReaderCallback {
val log = LoggerFactory.getLogger("GpxDbHelper")
Expand Down Expand Up @@ -51,19 +56,34 @@ object GpxDbHelper : GpxDbReaderCallback {
private suspend fun loadGpxItems() {
val start = currentTimeMillis()
val items = getItems()
val fileExistenceMap = items.associate { it.file to it.file.exists() }
val startEx = currentTimeMillis()
val fileExistenceMap = getFileExistenceMap(items)
log.info("Time to getFileExistenceMap ${currentTimeMillis() - startEx} ms, ${items.size} items")

val itemsToCache = mutableMapOf<KFile, GpxDataItem>()
val itemsToRemove = mutableSetOf<KFile>()
items.forEach { item ->
val file = item.file
if (fileExistenceMap[file] == true) {
dataItems[file] = item
itemsToCache[file] = item
} else {
remove(file)
itemsToRemove.add(file)
}
}
putToCacheBulk(itemsToCache);
removeFromCacheBulk(itemsToRemove);
log.info("Time to loadGpxItems ${currentTimeMillis() - start} ms, ${items.size} items")
}

private suspend fun getFileExistenceMap(
items: List<GpxDataItem>,
batchSize: Int = 100
): Map<KFile, Boolean> = coroutineScope {
items.chunked(batchSize).map { batch ->
async(Dispatchers.IO) { batch.associate { it.file to it.file.exists() } }
}.awaitAll().fold(mutableMapOf()) { acc, map -> acc.apply { putAll(map) } }
}

private fun loadGpxDirItems() {
val start = currentTimeMillis()
val items = getDirItems()
Expand Down Expand Up @@ -96,6 +116,14 @@ object GpxDbHelper : GpxDbReaderCallback {
}
}

private fun putToCacheBulk(itemsToCache: Map<KFile, GpxDataItem>) {
dataItems.putAll(itemsToCache)
}

private fun removeFromCacheBulk(filesToRemove: Set<KFile>) {
dataItems.keys.removeAll(filesToRemove)
}

fun rename(currentFile: KFile, newFile: KFile): Boolean {
val success = database.rename(currentFile, newFile)
if (success) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ class TrackFolderLoaderTask(
Companion.cachedRootFolder = TrackFolder(folder)
}

if (progress.isNotEmpty()) {
publishProgress(*progress.toTypedArray())
}

listener.tracksLoaded(folder)
log.info("Finished loading tracks. Took ${currentTimeMillis() - start}ms")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class TrackFolderAnalysis(folder: TracksGroup) {
items.addAll(folder.getTrackItems())
}
var totalDistanceSum = 0.0
for (trackItem in items.sortedBy { it.name }) {
for (trackItem in items) {
val dataItem = trackItem.dataItem
val analysis = dataItem?.getAnalysis()
if (analysis != null) {
Expand Down
1 change: 1 addition & 0 deletions OsmAnd/res/values-b+sr+Latn/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5908,4 +5908,5 @@
<string name="no_photos_available_descr">Još uvek nije dodata nijedna korisnička fotografija na ovu lokaciju</string>
<string name="no_photos_available">Nema dostupnih fotografija</string>
<string name="wikimedia">Vikimedia</string>
<string name="unit_volt">V</string>
</resources>
21 changes: 21 additions & 0 deletions OsmAnd/res/values-da/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5907,4 +5907,25 @@
<string name="no_photos_available_descr">Der er endnu ikke tilføjet nogen brugerbilleder til dette sted</string>
<string name="no_photos_available">Ingen fotos tilgængelige</string>
<string name="wikimedia">Wikimedia</string>
<string name="unit_volt">V</string>
<string name="obd_fuel_type_gasoline">Benzin</string>
<string name="obd_fuel_type_methanol">Metanol</string>
<string name="obd_fuel_type_ethanol">Ethanol</string>
<string name="obd_fuel_type_diesel">Diesel</string>
<string name="obd_fuel_type_lpg">Flaskegas</string>
<string name="obd_fuel_type_propane">Propan</string>
<string name="obd_fuel_type_hybrid_gasoline">Hybrid-benzin</string>
<string name="obd_fuel_type_hybrid_ethanol">Hybrid-ethanol</string>
<string name="obd_fuel_type_hybrid_diesel">Hybrid-diesel</string>
<string name="obd_fuel_type_hybrid_regenerative">Hybrid regenerativ</string>
<string name="obd_fuel_type_hybrid_hydrogen">Hybrid-brint</string>
<string name="obd_fuel_type_hydrogen">Brint</string>
<string name="obd_fuel_type_unknown">Ukendt brændstoftype</string>
<string name="obd_widget_group">Køretøjets parametre</string>
<string name="obd_fuel_type_electric">Elektrisk</string>
<string name="obd_fuel_type_cng">Komprimeret naturgas (CNG)</string>
<string name="obd_fuel_type_not_provided">Ingen brændstoftype angivet</string>
<string name="obd_fuel_type_hybrid_electric_combustion">Hybrid el- og forbrændingsmotor</string>
<string name="percent_unit">%</string>
<string name="obd_fuel_type_hybrid_electric">Hybrid-elektrisk</string>
</resources>
36 changes: 35 additions & 1 deletion OsmAnd/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5903,7 +5903,41 @@
<string name="open_in_browser">Im Browser öffnen</string>
<string name="shared_string_source">Quelle</string>
<string name="shared_string_no_internet_connection">Keine Internetverbindung</string>
<string name="no_internet_descr">Bitte Internetverbindung und erneut versuchen.</string>
<string name="no_internet_descr">Bitte Internetverbindung überprüfen und erneut versuchen.</string>
<string name="no_photos_available_descr">Noch keine Benutzerfotos zu diesem Standort hinzugefügt</string>
<string name="no_photos_available">Keine Fotos verfügbar</string>
<string name="obd_fuel_type_not_provided">Keine Kraftstoffart angegeben</string>
<string name="obd_fuel_type_gasoline">Benzin</string>
<string name="obd_fuel_type_methanol">Methanol</string>
<string name="obd_fuel_type_ethanol">Ethanol</string>
<string name="obd_fuel_type_diesel">Diesel</string>
<string name="obd_fuel_type_lpg">LPG</string>
<string name="obd_fuel_type_cng">CNG</string>
<string name="obd_fuel_type_propane">Propan</string>
<string name="obd_fuel_type_electric">Elektrisch</string>
<string name="obd_fuel_type_bifuel_gasoline">Bifuel mit Benzin</string>
<string name="obd_fuel_type_bifuel_methanol">Bifuel mit Methanol</string>
<string name="obd_fuel_type_bifuel_ethanol">Bifuel mit Ethanol</string>
<string name="obd_fuel_type_bifuel_electric_combustion">Bifuel mit E-Motor und Verbrennungsmotor</string>
<string name="obd_fuel_type_hybrid_electric">Hybrid elektrisch</string>
<string name="obd_fuel_type_hybrid_electric_combustion">Hybrid aus Elektro- und Verbrennungsmotor</string>
<string name="obd_fuel_type_bifuel_hydrogen">Bifuel mit Wasserstoff</string>
<string name="obd_fuel_type_hydrogen">Wasserstoff</string>
<string name="shared_string_obd">OBD</string>
<string name="percent_unit">%</string>
<string name="obd_rpm">Drehzahl</string>
<string name="rpm_unit">U/min</string>
<string name="obd_speed_desc">Geschwindigkeitsanzeige über OBD-Sensor</string>
<string name="unit_volt">V</string>
<string name="obd_fuel_type_bifuel_lpg">Bifuel mit LPG</string>
<string name="obd_fuel_type_bifuel_cng">Bifuel mit CNG</string>
<string name="obd_fuel_type_bifuel_propane">Bifuel mit Propan</string>
<string name="obd_fuel_type_hybrid_ethanol">Hybrid Ethanol</string>
<string name="obd_fuel_type_bifuel_electricity">Bifuel mit E-Motor</string>
<string name="obd_fuel_type_hybrid_gasoline">Hybrid Benzin</string>
<string name="obd_fuel_type_hybrid_diesel">Hybrid Diesel</string>
<string name="obd_fuel_type_hybrid_regenerative">Hybrid Regenerativ</string>
<string name="obd_fuel_type_hybrid_hydrogen">Hybrid Wasserstoff</string>
<string name="obd_fuel_type_unknown">Unbekannter Kraftstoff</string>
<string name="obd_widget_group">Fahrzeugangaben</string>
</resources>
12 changes: 12 additions & 0 deletions OsmAnd/res/values-eo/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5897,4 +5897,16 @@
<string name="no_internet_descr">Kontrolu vian retkonekton kaj reprovu.</string>
<string name="no_photos_available_descr">Neniu foto de uzanto aldonita al tiu ĉi loko</string>
<string name="no_photos_available">Neniu disponebla foto</string>
<string name="obd_fuel_type_gasoline">benzino</string>
<string name="obd_fuel_type_methanol">metanolo</string>
<string name="obd_fuel_type_ethanol">etanolo</string>
<string name="obd_fuel_type_not_provided">neraportata speco de brulaĵo</string>
<string name="obd_fuel_type_diesel">dizeloleo</string>
<string name="obd_fuel_type_lpg">LPG</string>
<string name="obd_fuel_type_cng">CNG</string>
<string name="obd_fuel_type_propane">propano</string>
<string name="obd_fuel_type_electric">elektro</string>
<string name="obd_fuel_type_bifuel_gasoline">plurbrulaĵa, nun benzino</string>
<string name="obd_fuel_type_bifuel_methanol">plurbrulaĵa, nun metanolo</string>
<string name="unit_volt">V</string>
</resources>
8 changes: 6 additions & 2 deletions OsmAnd/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5907,7 +5907,7 @@
<string name="obd_fuel_type_gasoline">Gasolina</string>
<string name="obd_fuel_type_methanol">Metanol</string>
<string name="obd_fuel_type_ethanol">Etanol</string>
<string name="obd_fuel_type_diesel">Diesel</string>
<string name="obd_fuel_type_diesel">Diésel</string>
<string name="obd_fuel_type_lpg">GLP</string>
<string name="obd_fuel_type_cng">GNC</string>
<string name="obd_fuel_type_propane">Propano</string>
Expand All @@ -5921,7 +5921,7 @@
<string name="obd_fuel_type_bifuel_electricity">Combustible dual con electricidad</string>
<string name="obd_fuel_type_hybrid_gasoline">Híbrido gasolina</string>
<string name="obd_fuel_type_hybrid_ethanol">Híbrido etanol</string>
<string name="obd_fuel_type_hybrid_diesel">Híbrido diesel</string>
<string name="obd_fuel_type_hybrid_diesel">Híbrido diésel</string>
<string name="obd_fuel_type_hybrid_electric">Híbrido eléctrico</string>
<string name="obd_fuel_type_hybrid_electric_combustion">Motor híbrido eléctrico y de combustión</string>
<string name="obd_fuel_type_hybrid_regenerative">Híbrido regenerativo</string>
Expand Down Expand Up @@ -5953,4 +5953,8 @@
<string name="obd_fuel_level_desc">Muestra el nivel de combustible del vehículo a través del sensor OBD</string>
<string name="obd_engine_coolant_temp">Temperatura del refrigerante del motor</string>
<string name="obd_fuel_type">Tipo de combustible</string>
<string name="obd_fuel_type_bifuel_electric_combustion">Motor eléctrico y de gasolina o diésel</string>
<string name="obd_fuel_type_hybrid_hydrogen">Híbrido con hidrógeno</string>
<string name="obd_widget_group">Métricas del panel de control</string>
<string name="obd_plugin_name">Métricas del panel de control</string>
</resources>
2 changes: 1 addition & 1 deletion OsmAnd/res/values-fr/phrases.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1533,7 +1533,7 @@
<string name="poi_ramp_luggage_yes">Rampe pour bagages : oui</string>
<string name="poi_ramp_luggage_no">Rampe pour bagages : non</string>
<string name="poi_cairn">Cairn</string>
<string name="poi_defibrillator">Défibrillateur</string>
<string name="poi_defibrillator">Défibrillateur;DAE</string>
<string name="poi_defibrillator_yes">Défibrillateur : oui</string>
<string name="poi_tomb_tumulus">Type : tumulus</string>
<string name="poi_tomb_columbarium">Type : columbarium</string>
Expand Down
1 change: 1 addition & 0 deletions OsmAnd/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5946,4 +5946,5 @@
<string name="obd_fuel_type">Type de carburant</string>
<string name="obd_plugin_description">Accède aux informations de votre véhicule via le protocole OBD</string>
<string name="obd_support">Prise en charge de l\'OBD</string>
<string name="obd_fuel_consumption_rate_desc">Affiche la consommation de carburant du véhicule selon l\'OBD et la localisation</string>
</resources>
54 changes: 54 additions & 0 deletions OsmAnd/res/values-hu/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5900,4 +5900,58 @@
<string name="no_photos_available">Nincs elérhető fénykép</string>
<string name="wikimedia">Wikimedia</string>
<string name="no_photos_available_descr">Ehhez a helyhez még nem adtak hozzá felhasználói fotókat</string>
<string name="obd_fuel_type_gasoline">Benzin</string>
<string name="obd_fuel_type_methanol">Metanol</string>
<string name="obd_fuel_type_ethanol">Etanol</string>
<string name="obd_fuel_type_diesel">Gázolaj</string>
<string name="obd_fuel_type_lpg">LPG</string>
<string name="obd_fuel_type_cng">CNG</string>
<string name="obd_fuel_type_propane">Propán</string>
<string name="unit_volt">V</string>
<string name="obd_fuel_type_not_provided">Nincs megadva üzemanyagtípus</string>
<string name="obd_fuel_type_electric">Elektromos</string>
<string name="obd_fuel_type_bifuel_gasoline">Benzinnel működő Bifuel</string>
<string name="obd_fuel_type_bifuel_methanol">Metanollal működő Bifuel</string>
<string name="obd_fuel_type_bifuel_ethanol">Etanollal működő Bifuel</string>
<string name="obd_fuel_type_bifuel_lpg">LPG-vel működő Bifuel</string>
<string name="obd_fuel_type_bifuel_cng">CNG-vel működő Bifuel</string>
<string name="obd_fuel_type_bifuel_electricity">Elektromos árammal működő Bifuel</string>
<string name="obd_fuel_type_bifuel_electric_combustion">Bifuel elektromos és belső égésű motor</string>
<string name="obd_fuel_type_hybrid_gasoline">Hibrid benzines</string>
<string name="obd_fuel_type_hybrid_ethanol">Hibrid etanollal</string>
<string name="obd_fuel_type_hybrid_diesel">Hibrid dízel</string>
<string name="obd_fuel_type_hybrid_electric">Hibrid elektromos</string>
<string name="obd_fuel_type_hydrogen">Hidrogén</string>
<string name="obd_fuel_type_unknown">Ismeretlen üzemanyagtípus</string>
<string name="shared_string_obd">OBD</string>
<string name="percent_unit">%</string>
<string name="rpm_unit">rpm</string>
<string name="obd_speed_desc">A jármű sebességét mutatja OBD érzékelőn keresztül</string>
<string name="obd_rpm_desc">A fordulatszámot mutatja OBD érzékelőn keresztül</string>
<string name="obd_air_intake_temp_desc">A beszívott levegő hőmérsékletét mutatja OBD érzékelőn keresztül</string>
<string name="obd_ambient_air_temp_desc">A levegő hőmérsékletét mutatja OBD érzékelőn keresztül</string>
<string name="obd_engine_coolant_temp_desc">A hűtőfolyadék hőmérsékletét mutatja OBD érzékelőn keresztül</string>
<string name="obd_battery_voltage_desc">Az akkumulátor feszültséget mutatja OBD érzékelőn keresztül</string>
<string name="obd_fuel_type_hybrid_electric_combustion">Hibrid elektromos és belső égésű motor</string>
<string name="obd_fuel_type_hybrid_regenerative">Hibrid regeneratív</string>
<string name="obd_rpm">RPM</string>
<string name="obd_widget_group">Járműmetrika</string>
<string name="obd_fuel_level_desc">Az üzemanyagszintet mutatja OBD érzékelőn keresztül</string>
<string name="obd_fuel_left_distance_desc">A maradék üzemanyaggal megtehető távolságot mutatja OBD érzékelőn keresztül</string>
<string name="obd_fuel_type_desc">Az üzemanyag típusát mutatja OBD érzékelőn keresztül</string>
<string name="obd_air_intake_temp">Beszívott levegő hőmérséklete</string>
<string name="obd_ambient_air_temp">Környezeti levegő hőmérséklete</string>
<string name="obd_battery_voltage">Akkumulátor feszültség</string>
<string name="obd_engine_coolant_temp">Hűtőfolyadék hőmérséklete</string>
<string name="obd_fuel_level">Üzemanyagszint</string>
<string name="obd_fuel_consumption_rate">Üzemanyag fogyasztás</string>
<string name="obd_fuel_consumption_rate_desc">Az üzemanyag fogyasztást mutatja az OBD adatai alapján</string>
<string name="obd_fuel_left_distance">Megtehető távolság</string>
<string name="obd_fuel_type">Üzemanyag típus</string>
<string name="obd_plugin_description">Hozzáfér a jármű adataihoz OBD protokollon keresztül</string>
<string name="obd_support">OBD támogatás</string>
<string name="obd_plugin_name">Járműmetrika</string>
<string name="obd_fuel_type_bifuel_hydrogen">Hidrogénnel működő Bifuel</string>
<string name="obd_fuel_type_hybrid_hydrogen">Hibrid hidrogén</string>
<string name="obd_fuel_type_bifuel_propane">Propánnal működő Bifuel</string>
</resources>
33 changes: 33 additions & 0 deletions OsmAnd/res/values-pt-rBR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5886,4 +5886,37 @@
<string name="shared_string_increase">Aumentar</string>
<string name="rendering_attr_showDirtbikeTrails_description">Mostrar trilhas de terra para bicicletas</string>
<string name="shared_string_decrease">Diminuir</string>
<string name="unit_volt">V</string>
<string name="wikimedia">Wikimedia</string>
<string name="open_in_browser">Abrir no navegador</string>
<string name="shared_string_source">Fonte</string>
<string name="shared_string_no_internet_connection">Sem conexão com a internet</string>
<string name="no_internet_descr">Verifique sua conexão e tente novamente.</string>
<string name="no_photos_available_descr">Nenhuma foto de usuário foi adicionada a este local ainda</string>
<string name="no_photos_available">Não há fotos disponíveis</string>
<string name="obd_fuel_type_not_provided">Nenhum tipo de combustível fornecido</string>
<string name="obd_fuel_type_gasoline">Gasolina</string>
<string name="obd_fuel_type_methanol">Metanol</string>
<string name="obd_fuel_type_ethanol">Etanol</string>
<string name="obd_fuel_type_diesel">Diesel</string>
<string name="obd_fuel_type_lpg">GLP</string>
<string name="obd_fuel_type_cng">GNV</string>
<string name="obd_fuel_type_propane">Propano</string>
<string name="obd_fuel_type_electric">Elétrico</string>
<string name="obd_fuel_type_hybrid_gasoline">Híbrido a gasolina</string>
<string name="obd_fuel_type_hybrid_diesel">Híbrido a diesel</string>
<string name="obd_fuel_type_hybrid_regenerative">Híbrido regenerativo</string>
<string name="obd_fuel_type_hydrogen">Hidrogênio</string>
<string name="obd_fuel_type_unknown">Tipo de combustível desconhecido</string>
<string name="obd_widget_group">Métricas de veículos</string>
<string name="percent_unit">%</string>
<string name="obd_air_intake_temp">Temperatura do ar de entrada</string>
<string name="obd_ambient_air_temp">Temperatura do ar ambiente</string>
<string name="obd_battery_voltage">Voltagem da bateria</string>
<string name="obd_engine_coolant_temp">Temperatura do líquido de arrefecimento do motor</string>
<string name="obd_fuel_level">Nível de combustível</string>
<string name="obd_fuel_consumption_rate">Taxa de consumo de combustível</string>
<string name="obd_fuel_left_distance">Combustível restante (distância)</string>
<string name="obd_fuel_type">Tipo de combustível</string>
<string name="obd_plugin_name">Métricas de veículos</string>
</resources>
Loading

0 comments on commit b3a3a5c

Please sign in to comment.