views:

29

answers:

2

Hi folks,

I would like to be able to associate various models (Venues, places, landmarks) with a City/Country.

But I am not sure what some good ways of implementing this would be.


I'm following a simple route, I have implemented a Country and City model.

Whenever a new city or country is mentioned it is automatically created.

Unfortunately I have various problems:

  • The database can easily be polluted

  • Django has no real knowledge of what those City/Countries really are


Any tips or ideas? Thanks! :)

+2  A: 

A good starting places would be to get a location dataset from a service like Geonames. There is also GeoDjango which came up in this question. As you encounter new location names, check them against your larger dataset before adding them. For your 2nd point, you'll need to design this into your object model and write your code accordingly.

Here are some other things you may want to consider:

  • Aliases & Abbreviations
    • These come up more than you would think. People often use the names of suburbs or neighbourhoods that aren't official towns. You can also consider ones like LA -> Los Angeles MTL for Montreal, MT Forest -> Mount Forest.
  • Fuzzy Search
    • Looking up city names is much easier when differences in spelling are accounted for. This also helps reduce the number of duplicate names for the same place
  • Location Equivalence
    • Be able to determine that Brooklyn is a borough of New York City.

At the end of the day, this is a tricky problem to solve.

Dana the Sane
A: 

Geocoding datasets from yahoo and google can be a good starting poing, Also take a look at geopy library in django.

bilkulbekar