我可以轻松地从谷歌地图API中获得一对长长的对:
from googlemaps import GoogleMaps
gmaps = GoogleMaps(GOOGLEMAPS_API_KEY)
gmaps.address_to_latlng('Jose Javier Diaz 440 Cordoba Argentina')
>>>> (-31.4464489, -64.191219899999993)
我有一个这样的模型:
from django import models
class MaapPoint(models.Model):
geom = models.PointField(srid=DEFAULT_SRID)
但我找不到从wkt
返回的latlng
获取gmaps
的方法。
任何指针?
答案 0 :(得分:3)
Shapely为此提供了一个很好的API:
>>> import shapely
>>> from shapely.wkt import dumps, loads
>>> pt1 = loads('POINT (0.0000000000000000 0.0000000000000000)')
>>> pt1
<shapely.geometry.point.Point object at 0x1011436d0>
>>> dumps(pt1)
'POINT (0.0000000000000000 0.0000000000000000)'
>>> pt3 = shapely.geometry.point.Point(2, 3)
>>> dumps(pt3)
'POINT (2.0000000000000000 3.0000000000000000)'
答案 1 :(得分:3)
在django,contrib.gis
有帮手。
>>> from django.contrib.gis.geos import Point
>>> Point(0,1).wkt
'POINT (0.0000000000000000 1.0000000000000000)'