JeroenDeDauw / SimpleGeocoder

Simple and minimalistic Geocoder interface with some basic implementations
Other
2 stars 0 forks source link

Lookup address details via Nominatim #18

Open gesinn-it-gea opened 2 years ago

gesinn-it-gea commented 2 years ago

I'd like to lookup address details via Nominatim to further process these details, e.g. store them in SMW properties (via Maps #geocode?).

https://nominatim.openstreetmap.org/search.php?q=Tieckstra%C3%9Fe%2024-25,%20Berlin&format=jsonv2&addressdetails=1

Is this something that could/should be added to SimpleGeocoder? Is this functionality available already and I missed it?

JeroenDeDauw commented 2 years ago

As per the README, this library provides a NomatimGeocoder class

gesinn-it-gea commented 2 years ago

I know, but I'd like to process details that are provided by Nominatim API with "addressdetails=1" (like "city" or "postcode") That's a feature that's currently not available, isn't it?

JeroenDeDauw commented 2 years ago
interface Geocoder {
    /**
     * Returns null when no result is found or when an error occurs.
     * @return LatLongValue|null
     */
    public function geocode( string $address );
}

Sounds like you need another interface

gesinn-it-gea commented 2 years ago

... depends. I't like to enter an "unsharp" address like in my example "Tiekstrasse 24-25, Berlin" and like to get what Nominatim can find out. So it's an alternative output to return new LatLongValue( (float)$location->lat, (float)$location->lon );

gesinn-it-gea commented 2 years ago
  {
    "place_id": 192025117,
    "licence": "Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright",
    "osm_type": "way",
    "osm_id": 369726993,
    "boundingbox": [
      "52.5293547",
      "52.5297502",
      "13.3879833",
      "13.3895535"
    ],
    "lat": "52.5294022",
    "lon": "13.3881056",
    "display_name": "Tieckstraße, Spandauer Vorstadt, Mitte, Berlin, 10115, Deutschland",
    "place_rank": 26,
    "category": "highway",
    "type": "residential",
    "importance": 0.32,
    "address": {
      "road": "Tieckstraße",
      "neighbourhood": "Spandauer Vorstadt",
      "suburb": "Mitte",
      "borough": "Mitte",
      "city": "Berlin",
      "ISO3166-2-lvl4": "DE-BE",
      "postcode": "10115",
      "country": "Deutschland",
      "country_code": "de"
    }