tomayac / local-reverse-geocoder

Local reverse geocoder for Node.js based on GeoNames data

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Returning wrong country?

alexcroox opened this issue · comments

commented

I'm passing { latitude: 51.5305516, longitude: 0.0051629 } into geocoder.lookUp, it takes about 10 seconds to return any data (this is even after the first run when the cache has finished), and the result is:

{
        "geoNameId": "6640087",
        "name": "Frasnes-lez-Anvaing",
        "asciiName": "Frasnes-lez-Anvaing",
        "alternateNames": "Fraine-dile-Anvegn,Fraine-dilé-Anvegn,Fran lez Anven,Fran-lez-Anven,frazn-lh-anwn,Фран лез Анвен,Фран-лез-Анвен,فرازن-له-آنون",
        "latitude": "50.69211",
        "longitude": "3.63562",
        "featureClass": "P",
        "featureCode": "PPLA4",
        "countryCode": "BE",
}

When this is a location in london

commented

structure

I deleted this directory after you asked for the structure and re-ran just to make sure, the lookups are now immediate (after the first one of course), but they are still in the wrong country.

Alright, the directory structure is correct and all required data has been
loaded. The problem is the dataset itself. I checked on GeoNames directly
with your coordinates (
http://api.geonames.org/findNearestAddressJSON?lat=51.5305516&lng=0.0051629&username=demo
[replace "demo" with your username, instructions here:
http://www.geonames.org/login]) and the result is an empty object {}.
This means GeoNames doesn't cover this area. My library returns the closest
spot it finds, I think you did remove the distance field from the JSON
output, but it should be a long distance. Maybe worth adding a pull request
for a maxDistance configuration object…

This seems to be working now, for http://localhost:3000/geocode?latitude=51.5305516&longitude=0.0051629, I get:

[
  [{
    "geoNameId": "2640091",
    "name": "Poplar",
    "asciiName": "Poplar",
    "alternateNames": "poplara,pwplr  lndn,پوپلر، لندن,पॉप्लर",
    "latitude": "51.51113",
    "longitude": "-0.01565",
    "featureClass": "P",
    "featureCode": "PPLA3",
    "countryCode": "GB",
    "cc2": null,
    "admin1Code": {
      "name": "England",
      "asciiName": "England",
      "geoNameId": "6269131"
    },
    "admin2Code": {
      "name": "Greater London",
      "asciiName": "Greater London",
      "geoNameId": "2648110"
    },
    "admin3Code": {
      "name": "Tower Hamlets",
      "asciiName": "Tower Hamlets",
      "geoNameId": "2635594"
    },
    "admin4Code": null,
    "population": "0",
    "elevation": null,
    "dem": "7",
    "timezone": "Europe/London",
    "modificationDate": "2011-03-03",
    "distance": 2.595661252043696
  }]
]