From 3d16a90579149ee0500afab78dcb7106da40eb7c Mon Sep 17 00:00:00 2001 From: johan12345 Date: Sun, 9 Jul 2023 17:35:57 +0200 Subject: [PATCH] OSM: implement address --- .../evmap/api/openstreetmap/OpenStreetMapModel.kt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/net/vonforst/evmap/api/openstreetmap/OpenStreetMapModel.kt b/app/src/main/java/net/vonforst/evmap/api/openstreetmap/OpenStreetMapModel.kt index 99786c43..c5da1ea8 100644 --- a/app/src/main/java/net/vonforst/evmap/api/openstreetmap/OpenStreetMapModel.kt +++ b/app/src/main/java/net/vonforst/evmap/api/openstreetmap/OpenStreetMapModel.kt @@ -93,7 +93,7 @@ data class OSMChargingStation( "openstreetmap", getName(), Coordinate(lat, lon), - null, // TODO: Can we determine this with overpass? + getAddress(), getChargepoints(), tags["network"], "https://www.openstreetmap.org/node/$id", @@ -117,6 +117,19 @@ data class OSMChargingStation( true, ) + private fun getAddress(): Address? { + val city = tags["addr:city"] + val country = tags["addr:country"] + val postcode = tags["addr:postcode"] + val street = tags["addr:street"] + val housenumber = tags["addr:housenumber"] ?: tags["addr:housename"] + return if (listOf(city, country, postcode, street, housenumber).any { it != null }) { + Address(city, country, postcode, "$street $housenumber") + } else { + null + } + } + /** * Return the name for this charging station. */