如何在python中将firebase firestore geopoint转换为latlng

2024-06-09 18:11:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我在firestore中有地质点域。 我希望能够将地质点转换回latlng。 在firestore文档中,.getLatitude()getLatitude()应该可以实现这一功能。 但这似乎不适用于Python。我不断得到错误:

print(geopoint.getLatitude())

AttributeError: 'GeoPoint' object has no attribute 'getLatitude'

如何在Python中获取地质点值

geopoint = field['location']

print(geopoint.getLatitude()) 
print(geopoint.getLongitude()) 

Tags: no文档功能object错误attributeerrorhasprint
2条回答

正如@spmaddox提到的,对于Python,get方法不是必需的。 因此,以下工作:

print(geopoint.latitude)
print(geopoint.longitude)

GeoPoint具有经度和纬度属性,请参考这些属性,而不是您正在使用的方法

相关问题 更多 >