Skip to content

Commit

Permalink
OSM: implement address
Browse files Browse the repository at this point in the history
  • Loading branch information
johan12345 committed Jul 9, 2023
1 parent 930a5ef commit f256ddc
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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.
*/
Expand Down

0 comments on commit f256ddc

Please sign in to comment.