我有点困惑,我应该如何将我的SRID值设置到我的GeoDjango PointField中,以便通过Google地图api将地址解析为经由django-postgis查询的坐标和距离的地址环境中保持准确?GeoDjango,用于PointField与Google Maps V3 API接口的SRID是什么?
我正在阅读围绕网络和叠层流程的线程,并且不确定要做什么。正如你可以看到我的应用程序正在使用gemap和谷歌地图API来对地址进行地理编码。现在我的坐标字段没有设置默认为4326的SRID(EPSG:4326)。现在显然这将地球视为一个地球,而不是一个平坦的表面。
根据以下问题的东西,如谷歌地图的答案使用(EPSG 3857),这显然有900913. https://gis.stackexchange.com/questions/48949/epsg-3857-or-4326-for-googlemaps-openstreetmap-and-leaflet
的SRID那么,这是否意味着我要我的SRID设置为900913?我的餐厅模型的所有坐标都使用地理编码器以下面所示的相同方法保存。我会这样认为的。
现在这是我扔掉的地方,以下教程http://invisibleroads.com/tutorials/geodjango-googlemaps-build.html使用SRID设置为4326(默认值)的点场,并且它们的标记点在Google地图上完美显示。
目前我的查询是非常准确的,但仍然感觉似乎有点关闭。
帮助表示赞赏,谢谢!
from geopy.geocoders import GoogleV3
from django.contrib.gis.geos import *
from django.contrib.gis.measure import D
geo = GoogleV3()
def home_page(request):
distance = 3680
address, coordinates = geo.geocode('Swanston Street, Melbourne Australia')
ref_location = Point(coordinates)
query = Restaurant.objects.filter(restaurant_location__distance_lte=(ref_location, D(m=distance))).distance(ref_location).order_by('distance')
return render(request, 'swings/home.html', {'restaurants': query})
餐厅型号
class Restaurant(models.Model):
name = models.CharField(max_length=25, blank=False)
user = models.ForeignKey(User)
address = models.CharField(max_length=50, blank=False)
restaurant_location = models.PointField(null=False, blank=False)
objects = models.GeoManager()
def __str__(self):
return self.name
这是非常有益的。历史课实际上有助于清理事情。谢谢! – user3739703
这是否也意味着我应该使用4326从搜索API返回的点? – bigblind
@bigblind,对不起,哪个搜索API? –