0

I am using the freely available geonames data locally to do autocomplete searches during the sign up stage on one of my websites.

I am having trouble working out the best way to make the form more user friendly by auto selecting a geoname based on their IP address and also be able to lookup a geoname based on the postcode data.

The problem is that I can't see a way to easily link an IP range or a postal code to a geoname. So what is the best practice here? Do I just run a separate query to lookup the nearest geoname by long/lat against the postcode or IP address?

Andrew Cetinic
  • 2,805
  • 29
  • 44

1 Answers1

1

You don't mention how you are geolocating the IP address, but the MaxMind GeoIP2 and GeoLite2 databases provide the geoname_id of the location. See, e.g., the CSV docs. The binary databases provide this same information.

Greg Oschwald
  • 1,716
  • 2
  • 11
  • 14
  • Ahh right, I think I was looking at the legacy version which doesn't offer geoname_id. Thanks I will take a look in more detail. – Andrew Cetinic Mar 22 '16 at 14:54