tomayac / local-reverse-geocoder

Local reverse geocoder for Node.js based on GeoNames data

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Geocoder going to infinte loop for some latitude and longitute.

edwinbbu opened this issue · comments

Coding goining in infinite loop on provide
latitude: 28.7041
longitude: 77.1025

Geocoder initialised with dump file in the provided location.

geocoder.init({
  dumpDirectory: '/tmp/geonames',
  load: {
    admin1: true, admin2: true, admin3And4: false, alternateNames: false
  }
}, function () {
  console.log('Initialized geocoder');
});

Lookup code

geocoder.lookUp({ latitude, longitude }, function(err, res) {
          if (err) {
            console.log(err);
          } else {
            console.log(res);
          }
        });

Not reaching either error or response.

I just tried your example on a local server: http://localhost:3000/geocode?latitude=28.7041&longitude=77.1025. This returns the following JSON, which looks correct to me:

[
  [{
    "geoNameId": "7290413",
    "name": "Pitampura",
    "asciiName": "Pitampura",
    "alternateNames": "Pitam Pura,Pitampura,Pītāmpura",
    "latitude": "28.68964",
    "longitude": "77.13126",
    "featureClass": "P",
    "featureCode": "PPL",
    "countryCode": "IN",
    "cc2": null,
    "admin1Code": {
      "name": "Delhi",
      "asciiName": "Delhi",
      "geoNameId": "1273293"
    },
    "admin2Code": {
      "name": "North West Delhi",
      "asciiName": "North West Delhi",
      "geoNameId": "8335427"
    },
    "admin3Code": null,
    "admin4Code": null,
    "population": "2000",
    "elevation": null,
    "dem": "217",
    "timezone": "Asia/Kolkata",
    "modificationDate": "2014-10-13",
    "alternateName": {
      "en": {
        "altName": "Pitam Pura",
        "isPreferredName": false,
        "isShortName": false,
        "isColloquial": false,
        "isHistoric": false
      },
      "link": {
        "altName": "https://en.wikipedia.org/wiki/Pitam_Pura",
        "isPreferredName": false,
        "isShortName": false,
        "isColloquial": false,
        "isHistoric": false
      }
    },
    "distance": 3.2333015244920125
  }]
]

Try not setting any initialization values, this will pull all the data from the network and try again:

geocoder.init({
  /*
  dumpDirectory: '/tmp/geonames',
  load: {
    admin1: true, admin2: true, admin3And4: false, alternateNames: false
  }
  */
}, function () {
  console.log('Initialized geocoder');
});

Most probably your dump data is invalid somehow… I'm closing the Issue for now, but of course please feel free to comment again.