Understanding OpenStreetMap, auto-fill API and saving cities (locationss)

This topic contains 29 replies, has 4 voices, and was last updated by  directoryfan 5 years, 9 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #418223

    directoryfan
    Expired Member
    Post count: 157

    Hi, I’m using Firefox and I saw this and asked myself if you get another response as the long string in your development environment. After spending some hours reading about Nominatim API and the German state Baden-Württemberg and testing different locations I know now better about the right name resolving.

    OK, so the long string is in the JSON attribute display_name and the others attributes are splitted under the address attribute. And the other attributes are not for each OSM API call consistent. So the attribute city_district is actually never in the JSON response, and you will have its value just in the display_name.

    Here are all locations for Baden-Württemberg, here the params for the Nominatim API search call, here is the proper country address format for Germany (street house_number, postalcode place).

    1. In my opinion you should fill the listing form fields just with values like:
    Listing Address Field: road house_number, city|town|village
    Listing City/Location Field: city|town|village

    and nothing more. Like that you will have the address as the German norm. So please do not fill the fields with suburbs or neighborhoods of little villages and do not use that part of the display_address field like ‘Verwaltungsgemeinschaft X’ or ‘Verwaltungsverband X’. These are 2 administrative levels (maybe as the city_district) just in some German states and they are not consistent, so X can be also a region name instead a city name, see the example 6 below. Do never use them for anything.

    Here are some examples, to better understand the API response in this German state:

    Example 1: village near big city Lahr/Schwarzwald, with its administration in Lahr/Schwarzwald (the data for this village is in OSM not updated, in this case use always the village)

    searching for: ‘Luisenstraße 5, Kippenheimweiler′

    OSM will suggest the address: ’5, Luisenstraße, Kippenheimweiler, Verwaltungsgemeinschaft Lahr/Schwarzwald…’
    and the autofill for address: ’5, Luisenstraße, Kippenheimweiler, Verwaltungsgemeinschaft Lahr/Schwarzwald’
    it should be: ‘Luisenstraße 5, Lahr/Schwarzwald’
    can be: ‘Luisenstraße 5, Kippenweiler’

    and the autofill value for the City field: ‘Kippenweiler′
    it should be: ‘Lahr/Schwrzwald′
    can be: ‘Kippenweiler’

    
    
    {"display_name":"5, Luisenstraße, Kippenheimweiler, Verwaltungsgemeinschaft Lahr\/Schwarzwald, Ortenaukreis, Regierungsbezirk Freiburg, Baden-Württemberg, 77933, Deutschland",
          "class":"highway",
          "type":"residential",
          "importance":0.245,
          "address":{
             "house_number": "5",
             "road":"Luisenstraße",
             "village":"Kippenheimweiler",
             "county":"Ortenaukreis",
             "state_district":"Regierungsbezirk Freiburg",
             "state":"Baden-Württemberg",
             "postcode":"77933",
             "country":"Deutschland",
             "country_code":"de"
          }
       }

    Example 2: another village as in example 1

    searching for: ‘Ruländerstraße 5, Durbach′

    OSM will suggest the address: ‘5, Ruländerstraße, Durbach, St. Anton, Verwaltungsgemeinschaft Offenburg…’
    and the autofill for address: ‘5, Ruländerstraße, Durbach, St. Anton, Verwaltungsgemeinschaft Offenburg’
    it should be:’Ruländerstraße 5, Durbach’

    and the autofill value for the City field: ‘Durbach′
    it should be: ‘Durbach′

    
    
    {"display_name": "5, Ruländerstraße, Durbach, St. Anton, Durbach, Verwaltungsgemeinschaft Offenburg, Ortenaukreis, Regierungsbezirk Freiburg, Baden-Württemberg, 77770, Deutschland",
        "class": "building",
        "type": "yes",
        "importance": 0.331,
        "address": {
          "house_number": "5",
          "road": "Ruländerstraße",
          "residential": "Durbach",
          "suburb": "St. Anton",
          "village": "Durbach",
          "county": "Ortenaukreis",
          "state_district": "Regierungsbezirk Freiburg",
          "state": "Baden-Württemberg",
          "postcode": "77770",
          "country": "Deutschland",
          "country_code": "de"
        }
      }

    Example 3: little village

    searching for: ‘Unditzstraße 6, Schutterzell′

    OSM will suggest the address: ’6, Unditzstraße, Schutterzell, Ottenweier Hof, Neuried…’
    and the autofill for address: ‘6, Unditzstraße, Schutterzell, Ottenweier Hof’
    it should be: ‘Unditzstraße 6, Neuried’
    but can be: ’6, Unditzstraße, Schutterzell, Ottenweier Hof, Neuried’

    and the autofill value for the City field: ‘Neuried′
    it should be: ‘Neuried′
    can be: ‘Schutterzell’

    
    
    "display_name": "6, Unditzstraße, Schutterzell, Ottenweier Hof, Neuried, Ortenaukreis, Regierungsbezirk Freiburg, Baden-Württemberg, 77743, Deutschland",
        "class": "building",
        "type": "yes",
        "importance": 0.331,
        "address": {
          "house_number": "6",
          "road": "Unditzstraße",
          "residential": "Schutterzell",
          "suburb": "Ottenweier Hof",
          "village": "Neuried",
          "county": "Ortenaukreis",
          "state_district": "Regierungsbezirk Freiburg",
          "state": "Baden-Württemberg",
          "postcode": "77743",
          "country": "Deutschland",
          "country_code": "de"
        }

    Example 4: another normal village

    searching for: ‘Belzackerweg 6, Kappelrodeck′

    OSM will suggest the address: ‘6, Belzackerweg, Zuckerberg, Mattenmühle, Verwaltungsverband Kappelrodeck…’
    and the autofill for address: ‘6, Belzackerweg, Zuckerberg, Mattenmühle, Verwaltungsverband Kappelrodeck’
    it should be:’Belzackerweg 6, Kappelrodeck’

    and the autofill value for the City field: ‘Kappelrodeck′
    it should be: ‘Kappelrodeck′

    
    
    {"display_name": "6, Belzackerweg, Zuckerberg, Mattenmühle, Kappelrodeck, Verwaltungsverband Kappelrodeck, Ortenaukreis, Regierungsbezirk Freiburg, Baden-Württemberg, 77876, Deutschland",
        "class": "building",
        "type": "yes",
        "importance": 0.221,
        "address": 
          "house_number": "6",
          "road": "Belzackerweg",
          "neighbourhood": "Zuckerberg",
          "suburb": "Mattenmühle",
          "village": "Kappelrodeck",
          "county": "Ortenaukreis",
          "state_district": "Regierungsbezirk Freiburg",
          "state": "Baden-Württemberg",
          "postcode": "77876",
          "country": "Deutschland",
          "country_code": "de"
        }
      }


    Example 5
    : another little village

    searching for: ‘Messingstraße 10, Legelshurst′

    OSM will suggest the address: ’10, Messingstraße, Legelshurst, Willstätt, Ortenaukreis…’
    and the autofill for address: ’10, Messingstraße, Legelshurst’
    it should be:’Messingstraße 10, Willstätt’
    can be: ‘Messingstraße 10, Legelshurst’

    and the autofill value for the City field: ‘Willstätt′
    it should be: ‘Willstätt′

    
    
    {"display_name": "10, Messingstraße, Legelshurst, Willstätt, Ortenaukreis, Regierungsbezirk Freiburg, Baden-Württemberg, 77731, Deutschland",
        "class": "building",
        "type": "yes",
        "importance": 0.331,
        "address": {
          "house_number": "10",
          "road": "Messingstraße",
          "residential": "Legelshurst",
          "village": "Willstätt",
          "county": "Ortenaukreis",
          "state_district": "Regierungsbezirk Freiburg",
          "state": "Baden-Württemberg",
          "postcode": "77731",
          "country": "Deutschland",
          "country_code": "de"
        }
      }


    Example 6
    : example of town and why you should never use the part ‘Verwaltungsgemeinschaft …’ or ‘Verwaltungsverband …’ of the display_name string

    searching for: ‘Eichbühlstraße 5, Bad-Griesbach′

    OSM will suggest the address: ‘5, Eichbühlstraße, Spinnersberg, Bad Peterstal-Griesbach,Verwaltungsverband Oberes Renchtal…’
    and the autofill for address: ‘5, Eichbühlstraße, Spinnersberg, Verwaltungsverband Oberes Renchtal’
    it should be:’Eichbühlstraße 5, Bad Peterstal-Griesbach’

    and the autofill value for the City field: ‘Bad Peterstal-Griesbach′
    it should be: ‘Bad Peterstal-Griesbach′

    
    
    {"display_name": "5, Eichbühlstraße, Spinnersberg, Bad Peterstal-Griesbach, Verwaltungsverband Oberes Renchtal, Ortenaukreis, Regierungsbezirk Freiburg, Baden-Württemberg, 77740, Deutschland",
        "class": "building",
        "type": "yes",
        "importance": 0.221,
        "address": {
          "house_number": "5",
          "road": "Eichbühlstraße",
          "suburb": "Spinnersberg",
          "town": "Bad Peterstal-Griesbach",
          "county": "Ortenaukreis",
          "state_district": "Regierungsbezirk Freiburg",
          "state": "Baden-Württemberg",
          "postcode": "77740",
          "country": "Deutschland",
          "country_code": "de"
        }
      }

    2. I’ve tried to change your osm js code and add some more params in order to restrict and optimize the search and the country address format (feature request: could be very nice to have this options in the back-end for local directories)

    
    
    accept-language=<browser language string>
    <a href="https://wiki.openstreetmap.org/wiki/Bounding_Box">countrycodes</a>=<countrycode>[,<countrycode>][,<countrycode>]...
    viewbox=<x1>,<y1>,<x2>,<y2>
    bounded=[0|1]

    As my project is restricted to this German state:

    
    
    accept-language='de-DE'
    countrycodes='de'
    viewbox=7.5,47.6,10.5,49.8
    bounded=1

    But this did not work and I could not see the changes applied to the OSM search. Do I have to put it in other functions too as in geocodePositionOSM ?

    #418256

    Alex Rollin
    Moderator
    Post count: 27815

    Hello!

    I will flag this for Stiofan. I just wanted to add, I think I thought I posted it to your other thread.

    https://wiki.openstreetmap.org/wiki/Tag:boundary=administrative#10_admin_level_values_for_specific_countries

    That is the ‘general rules’ for how addresses are written into OSM. Folks in OSM DE are the ones doing it or not doing it. It is fine to reference Wikipedia, just pointing out that OSM has their own book there, too.

    #418297

    Stiofan O’Connor
    Site Admin
    Post count: 22956
    This reply has been marked as private.
    #418393

    directoryfan
    Expired Member
    Post count: 157

    Hi Alex,

    I know that link and have found some more information about the admin levels too. It looks like there is also an admin level 11 for Germany. I still do not understand everything and why they use sometimes suburb or neighborhood or residential for villages. The admin level 10 hierarchy is mentioned in the Nominatim API too. I think, I’ll ask for clarification in the OSM German forum.

    Greetings

    #418396

    directoryfan
    Expired Member
    Post count: 157
    This reply has been marked as private.
    #418426

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    I was not after screen share, just instant text chat.

    Stiofan

    #418441

    directoryfan
    Expired Member
    Post count: 157
    This reply has been marked as private.
    #421422

    directoryfan
    Expired Member
    Post count: 157

    Hello Stiofan,

    sorry for not having the time to work on the project till now. Now I’m focused on it until it will go online.

    Would you like to resolve the problem with OSM in the german State Baden-Württemberg. As I mentioned before, your should fill the listing form fields from the API answer just with values like:

    Listing Address Field: road house_number, city|town|village
    Listing City/Location Field: city|town|village

    Or how can I change the code, to select just the above values for the address and city fields.

    And it is enough to change the function geocodePositionOSM to send more options to the OSM Search API? I want to add also:

    accept-language=’de-DE’
    countrycodes=’de’
    viewbox=7.5,47.6,10.5,49.8
    bounded=1

    
    
    
    function geocodePositionOSM(latLon, address, countrycodes, updateMap, callback) {
        data = {format: 'json', addressdetails: 1, limit: 1, accept-language:'de-DE', countrycodes:'de', viewbox: 7.5,47.6,10.5,49.8, bounded:1};
        
        if (address) {
            type = 'search';
            data.q = address;
            
            if (countrycodes) {
                data.countrycodes = countrycodes.toLowerCase();
            }
        } else if(latLon && typeof latLon === 'object') {
           type = 'reverse';
           data.lat = latLon.lat;
           data.lon = latLon.lng;
        } else {
            return;
        }

    And If you want to test with me the code changes over Skype, just tell me some hours before, to be at place. Now I do have Skype and just invited you.

    Greetings, Marius

    #427066

    directoryfan
    Expired Member
    Post count: 157

    bump

    #427096

    Alex Rollin
    Moderator
    Post count: 27815
    This reply has been marked as private.
    #427148

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Hey,

    I’m going to be working on Locations manager next week so i will take a closer look at this then.

    Thanks,

    Stiofan

    #427370

    directoryfan
    Expired Member
    Post count: 157

    Thank you Stiofan, tell me some hours before to be around and prepared.
    Now I’m on Slack too.

    Greetings, Marius

    #429240

    Thierry BOULOGNE
    Free User
    Post count: 3

    Hello,

    Any fix on this please ?
    (could you share code change please. I face same issue with french address).

    Thanks for help.

    Regards

    Thierry

    #435322

    directoryfan
    Expired Member
    Post count: 157

    Hi Thierry,

    I have not solved the problem. I think in the V2 it will be solved. As a work around I change manually the address field.

    Greetings, Marius

    #439934

    directoryfan
    Expired Member
    Post count: 157

    bump vor v2

Viewing 15 posts - 16 through 30 (of 30 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket