让 Django 感知地理定位的好方法? - Django/地理定位
我希望能够将各种模型(场地、地点、地标)与城市/国家相关联。
但我不确定实现这一点的一些好方法是什么。
我遵循一条简单的路线,我已经实现了国家和城市模型。
每当提到新的城市或国家时,都会自动创建它。
不幸的是,我有各种问题:
数据库很容易被污染
Django 不知道这些城市/国家到底是什么
什么建议或想法吗?谢谢! :)
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! :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一个好的起点是从 Geonames 等服务获取位置数据集。还有 GeoDjango 出现在 这个问题。
当您遇到新的位置名称时,请在添加之前对照较大的数据集进行检查。对于第二点,您需要将其设计到对象模型中并相应地编写代码。
以下是您可能需要考虑的其他一些事项:
归根结底,这是一个难题,但应用这些建议应该会大大减少数据损坏的数量和您必须处理的其他令人头疼的问题。
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:
At the end of the day, this is a hard problem, but applying these suggestions should greatly reduce the amount of data corruption and other headaches you have to deal with.
来自 yahoo 和 google 的地理编码数据集可能是一个很好的起点,也可以看看 django 中的 geopy 库。
Geocoding datasets from yahoo and google can be a good starting poing, Also take a look at geopy library in django.