【发布时间】:2020-02-07 07:22:53
【问题描述】:
请帮我解决这个问题。
class RecievingImages(models.Model):
"""Original and Masked Images"""
name = models.CharField(max_length = 100, unique = True, primary_key=True)
cordinate_X = models.FloatField()
cordinate_Y = models.FloatField()
point = models.PointField(srid=4326, geography=True, default='POINT(0.0 0.0)')
def __str__(self):
return self.name
class Meta:
verbose_name_plural = 'Image Mapping'
我有从谷歌地图 API 获得的坐标 此处示例
cordinate_X : 21.2166277
cordinate_Y : 72.7763859
从技术上讲,这些坐标位于印度古吉拉特邦 actual link of the coordinates
现在要在传单上绘图,我参考此链接将其转换为点字段 https://stackoverflow.com/a/48293443/7999665
from django.contrib.gis.geos import Point
for l in RecievingImages.objects.all():
... l.point = Point(x=l.cordinate_X, y=l.cordinate_Y, srid=4326)
... l.save()
现在,当我返回 Django 管理页面时,它在 Sea 的某处错误地标记了坐标
感谢您的宝贵时间。
问候
更新
经过大量谷歌搜索,我发现可能存在 srid 使用的问题,即谷歌地图可能使用“3587”而我使用了“4326” 我尝试更改此设置,但出现错误。
raise NotSupportedError('PostGIS only supports geography columns with an SRID of 4326.')
django.db.utils.NotSupportedError: PostGIS only supports geography columns with an SRID of 4326.
我使用的数据库是PostGIS。
【问题讨论】:
标签: django google-maps django-admin postgis geodjango