arjunmehta / node-geo-proximity

Super fast proximity searches of geo coordinates.
MIT License
132 stars 18 forks source link

proximity.location function gives values even after the location is removed. #15

Closed nexhop closed 9 years ago

nexhop commented 9 years ago

I have created empty data set and used proximity.location without even adding any location and I am getting the values for any location i enter: "latitude":-89.99999865889549,"longitude":-179.99999731779099

arjunmehta commented 9 years ago

@nexhop Thank you for bringing this to my attention. You should be getting a null value for those (since the location is undefined) instead of those values. I'll fix this!

Thank you.

To be sure, when creating an empty data set and finding locations (after you add locations of course!) make sure you run the .location method on the subset (instead of the main proximity instance):

var new_dataset = proximity.addSet('dataSetName');
new_dataset.location(function(err, reply){
  if(!err) console.log(reply)
})
arjunmehta commented 9 years ago

@nexhop Fixed in version 2.2.2 Now calling .location or .locations for non-existent locations will return an object of the form:

{
  name: "Location Name",
  latitude: null,
  longitude: null
}

If I were to rewrite the API, I would have .locations()/.location() actually return a set of objects, with key names as the location name. But kind of late for that :D. Thanks again!