Compare commits

..

4 Commits
1.6.3 ... 1.6.4

Author SHA1 Message Date
johan12345
06801c1898 Release 1.6.4 2023-06-17 17:59:30 +02:00
johan12345
c946b0fcd3 TeslaAvailabilityDetector: fix cases when number of chargepoints does not match 2023-06-17 17:38:33 +02:00
johan12345
dd4fcc7550 Run clustering on Dispatchers.Default, not Dispatchers.IO 2023-06-16 23:08:01 +02:00
johan12345
2ce82b961b Introduce clustering up to zoom level 15 in very crowded places (>500 chargers within view)
refs #285
2023-06-16 22:50:14 +02:00
7 changed files with 40 additions and 10 deletions

View File

@@ -21,8 +21,8 @@ android {
minSdkVersion 21
targetSdkVersion 33
// NOTE: always increase versionCode by 2 since automotive flavor uses versionCode + 1
versionCode 186
versionName "1.6.3"
versionCode 188
versionName "1.6.4"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
resConfigs supportedLocales.split(',')

View File

@@ -540,6 +540,9 @@ class TeslaAvailabilityDetector(
Chargepoint.CCS_UNKNOWN
) && it.power != null && it.power <= 150
}
if (scV2CCSConnectors.sumOf { it.count } != 0 && scV2CCSConnectors.sumOf { it.count } != scV2Connectors.sumOf { it.count }) {
throw AvailabilityDetectorException("number of V2 connectors does not match number of V2 CCS connectors")
}
val scV3Connectors = location.chargepoints.filter {
it.type in listOf(
Chargepoint.CCS_TYPE_2,
@@ -550,27 +553,39 @@ class TeslaAvailabilityDetector(
"charger has unknown connectors"
)
val statusSorted = details.siteDynamic.chargerDetails.sortedBy { it.charger.labelLetter }
.sortedBy { it.charger.labelNumber }
var statusSorted = details.siteDynamic.chargerDetails.sortedBy { it.charger.labelLetter }
.sortedBy { it.charger.labelNumber }.map { it.availability }
if (statusSorted.size != scV2Connectors.sumOf { it.count } + scV3Connectors.sumOf { it.count }) {
// apparently some connectors are missing in Tesla data
// If we have just one type of charger, we can still match
val numMissing =
scV2Connectors.sumOf { it.count } + scV3Connectors.sumOf { it.count } - statusSorted.size
if (scV2Connectors.isEmpty() || scV3Connectors.isEmpty() && numMissing > 0) {
statusSorted =
statusSorted + List(numMissing) { TeslaGraphQlApi.ChargerAvailability.UNKNOWN }
} else {
throw AvailabilityDetectorException("Tesla API chargepoints do not match data source")
}
}
val statusMap = emptyMap<Chargepoint, List<ChargepointStatus>>().toMutableMap()
var i = 0
for (connector in scV2Connectors) {
statusMap[connector] =
statusSorted.subList(i, i + connector.count).map { it.availability.toStatus() }
statusSorted.subList(i, i + connector.count).map { it.toStatus() }
i += connector.count
}
if (scV2CCSConnectors.isNotEmpty()) {
i = 0
for (connector in scV2CCSConnectors) {
statusMap[connector] =
statusSorted.subList(i, i + connector.count).map { it.availability.toStatus() }
statusSorted.subList(i, i + connector.count).map { it.toStatus() }
i += connector.count
}
}
for (connector in scV3Connectors) {
statusMap[connector] =
statusSorted.subList(i, i + connector.count).map { it.availability.toStatus() }
statusSorted.subList(i, i + connector.count).map { it.toStatus() }
i += connector.count
}

View File

@@ -867,7 +867,7 @@ class MapFragment : Fragment(), OnMapReadyCallback, MapsActivity.FragmentCallbac
if (BuildConfig.FLAVOR.contains("google") && mapFragment!!.priority[0] == MapFragment.GOOGLE) {
// Google Maps: icons can be generated in background thread
lifecycleScope.launch {
withContext(Dispatchers.IO) {
withContext(Dispatchers.Default) {
chargerIconGenerator.preloadCache()
}
}

View File

@@ -290,10 +290,14 @@ class ChargeLocationsRepository(
chargers: List<ChargeLocation>,
zoom: Float
): List<ChargepointListItem> {
/* in very crowded places (good example: central London on OpenChargeMap without filters)
we have to cluster even at pretty high zoom levels to make sure the map does not get
laggy. Otherwise, only cluster at zoom levels <= 11. */
val useClustering = chargers.size > 500 || zoom <= 11f
val clusterDistance = getClusterDistance(zoom)
val chargersClustered = if (clusterDistance != null) {
Dispatchers.IO.run {
val chargersClustered = if (useClustering && clusterDistance != null) {
Dispatchers.Default.run {
cluster(chargers, zoom, clusterDistance)
}
} else chargers

View File

@@ -53,6 +53,7 @@ internal fun getClusterDistance(zoom: Float): Int? {
return when (zoom) {
in 0.0..7.0 -> 100
in 7.0..11.0 -> 75
in 11.0..15.0 -> 75
else -> null
}
}

View File

@@ -0,0 +1,5 @@
Verbesserungen:
- Clustering an Orten mit extrem hoher Ladestationsdichte verstärkt
Fehler behoben:
- Abstürze behoben

View File

@@ -0,0 +1,5 @@
Improvements:
- Increased clustering in places with extremely high charger density
Bugfixes:
- Fixed crashes