tomayac / local-reverse-geocoder

Local reverse geocoder for Node.js based on GeoNames data
Apache License 2.0
190 stars 60 forks source link

No geonames_dump folder #54

Closed Garamani closed 2 years ago

Garamani commented 2 years ago

Hello Thomas, Thank you for providing this great package(It's the main part of my project).

  1. Today I noticed local-reverse-geocoder doesn't return the City of Toronto and instead it's returning small areas of Toronto which are not useful for so many case scenarios.
  2. I checked the old dump folder I had and when I compared it with the new cities1000 from GeoNames, it seems the problem is the updated version of cities1000.
  3. I wanted to replace it in my Heroku server and I noticed there is NO geonames_dump FOLDER!

My question is: If there is no geonames_dump FOLDER, how the local-reverse-geocoder is returning the results?

I also built a folder "geonames_dump" but the local-reverse-geocoder is returning the same result.

What can be the possible issue in this case?

tomayac commented 2 years ago

You really should have that folder, it's created here: https://github.com/tomayac/local-reverse-geocoder/blob/0e3e04ecf380134ede0bb80368d1ab32995d3ef0/index.js#L659

Try starting your server with DEBUG=local-reverse-geocoder npm start and see what comes out in the debug messages.

Garamani commented 2 years ago

Thanks, DEBUG=local-reverse-geocoder npm start was a big help.

I kept an old version of cities1000 without the timestamp at the end in the geonames_dump folder, as you suggested in the readme file: data gets refreshed each day. You can override this behavior by removing the timestamp from the files in the ./geonames_dump download folder.

But It seems Heroku downloads "cities1000" from https://download.geonames.org/export/dump/cities1000.zip when the server starts.

DEBUG info: Getting GeoNames cities data from https://download.geonames.org/export/dump/cities1000.zip (this may take a while)

I had to replace the area names with the city name "Toronto" when the local-reverse-geocoder returns the result and then sends them to the client.

I think it can be a good idea to have an option to set the local-reverse-geocoder to use a local file. The updated version of data from GeoNames can make the output result inconsistent in many projects.

tomayac commented 2 years ago

Can you share the latitude/longitude pair? Not sure if this is a data issue.

Garamani commented 2 years ago
name: 'Moss Park',
latitude: '43.65498',
longitude: '-79.37153',
name: 'Bay Street Corridor',
latitude: '43.65751',
longitude: '-79.38572',
tomayac commented 2 years ago

This is what I get for http://localhost:3000/geocode?latitude=43.65498&longitude=-79.37153:

[
    [{
        "geoNameId": "7870782",
        "name": "Moss Park",
        "asciiName": "Moss Park",
        "alternateNames": null,
        "latitude": "43.65498",
        "longitude": "-79.37153",
        "featureClass": "P",
        "featureCode": "PPLX",
        "countryCode": "CA",
        "cc2": null,
        "admin1Code": {
            "name": "Ontario",
            "asciiName": "Ontario",
            "geoNameId": "6093943"
        },
        "admin2Code": {
            "name": "Toronto county",
            "asciiName": "Toronto county",
            "geoNameId": "8133394"
        },
        "admin3Code": null,
        "admin4Code": null,
        "population": "20506",
        "elevation": null,
        "dem": "87",
        "timezone": "America/Toronto",
        "modificationDate": "2020-05-02",
        "alternateName": {
            "link": {
                "altName": "https://en.wikipedia.org/wiki/Moss_Park",
                "isPreferredName": false,
                "isShortName": false,
                "isColloquial": false,
                "isHistoric": false
            },
            "wkdt": {
                "altName": "Q14875318",
                "isPreferredName": false,
                "isShortName": false,
                "isColloquial": false,
                "isHistoric": false
            }
        },
        "distance": 0
    }]
]

It's like that in the data I guess. The park is the same you get when you throw the coordinates into Google Maps. I'm closing this Issue, since there's nothing I could do about the data format.