mirror of
https://github.com/ev-map/EVMap.git
synced 2026-04-19 05:38:07 -04:00
add filter by categories (fixes #64)
This commit is contained in:
@@ -27,6 +27,7 @@ interface GoingElectricApi {
|
||||
@Query("plugs") plugs: String? = null,
|
||||
@Query("chargecards") chargecards: String? = null,
|
||||
@Query("networks") networks: String? = null,
|
||||
@Query("categories") categories: String? = null,
|
||||
@Query("startkey") startkey: Int? = null,
|
||||
@Query("open_twentyfourseven") open247: Boolean = false,
|
||||
@Query("barrierfree") barrierfree: Boolean = false,
|
||||
@@ -46,7 +47,7 @@ interface GoingElectricApi {
|
||||
suspend fun getChargeCards(): Response<ChargeCardList>
|
||||
|
||||
companion object {
|
||||
private val cacheSize = 10L * 1024 * 1024; // 10MB
|
||||
private val cacheSize = 10L * 1024 * 1024 // 10MB
|
||||
|
||||
fun create(
|
||||
apikey: String,
|
||||
|
||||
@@ -63,6 +63,34 @@ private fun MediatorLiveData<List<Filter<FilterValue>>>.buildFilters(
|
||||
}?.toMap() ?: return
|
||||
val networkMap = networks.value?.map { it.name to it.name }?.toMap() ?: return
|
||||
val chargecardMap = chargeCards.value?.map { it.id.toString() to it.name }?.toMap() ?: return
|
||||
val categoryMap = mapOf(
|
||||
"Autohaus" to application.getString(R.string.category_car_dealership),
|
||||
"Autobahnraststätte" to application.getString(R.string.category_service_on_motorway),
|
||||
"Autohof" to application.getString(R.string.category_service_off_motorway),
|
||||
"Bahnhof" to application.getString(R.string.category_railway_station),
|
||||
"Behörde" to application.getString(R.string.category_public_authorities),
|
||||
"Campingplatz" to application.getString(R.string.category_camping),
|
||||
"Einkaufszentrum" to application.getString(R.string.category_shopping_mall),
|
||||
"Ferienwohnung" to application.getString(R.string.category_holiday_home),
|
||||
"Flughafen" to application.getString(R.string.category_airport),
|
||||
"Freizeitpark" to application.getString(R.string.category_amusement_park),
|
||||
"Hotel" to application.getString(R.string.category_hotel),
|
||||
"Kino" to application.getString(R.string.category_cinema),
|
||||
"Kirche" to application.getString(R.string.category_church),
|
||||
"Krankenhaus" to application.getString(R.string.category_hospital),
|
||||
"Museum" to application.getString(R.string.category_museum),
|
||||
"Parkhaus" to application.getString(R.string.category_parking_multi),
|
||||
"Parkplatz" to application.getString(R.string.category_parking),
|
||||
"Privater Ladepunkt" to application.getString(R.string.category_private_charger),
|
||||
"Rastplatz" to application.getString(R.string.category_rest_area),
|
||||
"Restaurant" to application.getString(R.string.category_restaurant),
|
||||
"Schwimmbad" to application.getString(R.string.category_swimming_pool),
|
||||
"Supermarkt" to application.getString(R.string.category_supermarket),
|
||||
"Tankstelle" to application.getString(R.string.category_petrol_station),
|
||||
"Tiefgarage" to application.getString(R.string.category_parking_underground),
|
||||
"Tierpark" to application.getString(R.string.category_zoo),
|
||||
"Wohnmobilstellplatz" to application.getString(R.string.category_caravan_site)
|
||||
)
|
||||
value = listOf(
|
||||
BooleanFilter(application.getString(R.string.filter_free), "freecharging"),
|
||||
BooleanFilter(application.getString(R.string.filter_free_parking), "freeparking"),
|
||||
@@ -90,6 +118,11 @@ private fun MediatorLiveData<List<Filter<FilterValue>>>.buildFilters(
|
||||
application.getString(R.string.filter_networks), "networks",
|
||||
networkMap, manyChoices = true
|
||||
),
|
||||
MultipleChoiceFilter(
|
||||
application.getString(R.string.categories), "categories",
|
||||
categoryMap,
|
||||
manyChoices = true
|
||||
),
|
||||
BooleanFilter(application.getString(R.string.filter_barrierfree), "barrierfree"),
|
||||
MultipleChoiceFilter(
|
||||
application.getString(R.string.filter_chargecards), "chargecards",
|
||||
|
||||
@@ -280,6 +280,13 @@ class MapViewModel(application: Application, geApiKey: String) : AndroidViewMode
|
||||
}
|
||||
val networks = formatMultipleChoice(networksVal)
|
||||
|
||||
val categoriesVal = getMultipleChoiceValue(filters, "categories")
|
||||
if (categoriesVal.values.isEmpty() && !categoriesVal.all) {
|
||||
// no categories chosen
|
||||
return Triple(Resource.success(emptyList()), filteredConnectors, filteredChargeCards)
|
||||
}
|
||||
val categories = formatMultipleChoice(categoriesVal)
|
||||
|
||||
// do not use clustering if filters need to be applied locally.
|
||||
val useClustering = zoom < 13
|
||||
val geClusteringAvailable = minConnectors <= 1
|
||||
@@ -308,6 +315,7 @@ class MapViewModel(application: Application, geApiKey: String) : AndroidViewMode
|
||||
plugs = connectors,
|
||||
chargecards = chargeCards,
|
||||
networks = networks,
|
||||
categories = categories,
|
||||
startkey = startkey
|
||||
)
|
||||
if (!response.isSuccessful || response.body()!!.status != "ok") {
|
||||
|
||||
@@ -109,6 +109,33 @@
|
||||
<string name="contact">Kontakt</string>
|
||||
<string name="menu_report_new_charger">Ladesäule melden</string>
|
||||
<string name="edit_on_goingelectric">bei GoingElectric.de bearbeiten</string>
|
||||
<string name="categories">Kategorien</string>
|
||||
<string name="category_car_dealership">Autohaus</string>
|
||||
<string name="category_service_on_motorway">Autobahnraststätte</string>
|
||||
<string name="category_service_off_motorway">Autohof</string>
|
||||
<string name="category_railway_station">Bahnhof</string>
|
||||
<string name="category_public_authorities">Behörde</string>
|
||||
<string name="category_camping">Campingplatz</string>
|
||||
<string name="category_shopping_mall">Einkaufszentrum</string>
|
||||
<string name="category_holiday_home">Ferienwohnung</string>
|
||||
<string name="category_airport">Flughafen</string>
|
||||
<string name="category_amusement_park">Freizeitpark</string>
|
||||
<string name="category_hotel">Hotel</string>
|
||||
<string name="category_cinema">Kino</string>
|
||||
<string name="category_church">Kirche</string>
|
||||
<string name="category_hospital">Krankenhaus</string>
|
||||
<string name="category_museum">Museum</string>
|
||||
<string name="category_parking_multi">Parkhaus</string>
|
||||
<string name="category_parking">Parkplatz</string>
|
||||
<string name="category_private_charger">Privater Ladepunkt</string>
|
||||
<string name="category_rest_area">Rastplatz</string>
|
||||
<string name="category_restaurant">Restaurant</string>
|
||||
<string name="category_swimming_pool">Schwimmbad</string>
|
||||
<string name="category_supermarket">Supermarkt</string>
|
||||
<string name="category_petrol_station">Tankstelle</string>
|
||||
<string name="category_parking_underground">Tiefgarage</string>
|
||||
<string name="category_zoo">Tierpark</string>
|
||||
<string name="category_caravan_site">Wohnmobilstellplatz</string>
|
||||
<plurals name="charge_cards_compatible_num">
|
||||
<item quantity="one">%d kompatibler Ladetarif</item>
|
||||
<item quantity="other">%d kompatible Ladetarife</item>
|
||||
|
||||
@@ -108,6 +108,33 @@
|
||||
<string name="contact">Contact</string>
|
||||
<string name="menu_report_new_charger">Report new charger</string>
|
||||
<string name="edit_on_goingelectric">edit on GoingElectric.de</string>
|
||||
<string name="categories">Categories</string>
|
||||
<string name="category_car_dealership">Car Dealership</string>
|
||||
<string name="category_service_on_motorway">Service area (on motorway)</string>
|
||||
<string name="category_service_off_motorway">Service area (off motorway)</string>
|
||||
<string name="category_railway_station">Railway station</string>
|
||||
<string name="category_public_authorities">Public authorities</string>
|
||||
<string name="category_camping">Camping site</string>
|
||||
<string name="category_shopping_mall">Shopping mall</string>
|
||||
<string name="category_holiday_home">Holiday home</string>
|
||||
<string name="category_airport">Airport</string>
|
||||
<string name="category_amusement_park">Amusement park</string>
|
||||
<string name="category_hotel">Hotel</string>
|
||||
<string name="category_cinema">Cinema</string>
|
||||
<string name="category_church">Church</string>
|
||||
<string name="category_hospital">Hospital</string>
|
||||
<string name="category_museum">Museum</string>
|
||||
<string name="category_parking_multi">Multi-storey car park</string>
|
||||
<string name="category_parking">Car park</string>
|
||||
<string name="category_private_charger">Private charger</string>
|
||||
<string name="category_rest_area">Rest area</string>
|
||||
<string name="category_restaurant">Restaurant</string>
|
||||
<string name="category_swimming_pool">Swimming pool</string>
|
||||
<string name="category_supermarket">Supermarket</string>
|
||||
<string name="category_petrol_station">Petrol station</string>
|
||||
<string name="category_parking_underground">Underground car park</string>
|
||||
<string name="category_zoo">Zoo</string>
|
||||
<string name="category_caravan_site">Caravan site</string>
|
||||
<plurals name="charge_cards_compatible_num">
|
||||
<item quantity="one">%d compatible payment method</item>
|
||||
<item quantity="other">%d compatible payment methods</item>
|
||||
|
||||
Reference in New Issue
Block a user