【问题标题】:How to convert firebase firestore geopoint to a latlng in python如何将firebase firestore geopoint转换为python中的latlng
【发布时间】:2020-01-20 01:40:44
【问题描述】:

我在 Firestore 中有地理点字段。 我希望能够将地理点转换回 latlng。 从 firestore 文档来看,.getLatitude()getLongitude() 应该可以解决问题。 但这似乎不适用于 Python。我不断收到错误:

打印(geopoint.getLatitude())

AttributeError: 'GeoPoint' 对象没有属性 'getLatitude'

如何在 Python 中获取地理点值?

geopoint = field['location']

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

【问题讨论】:

标签: python firebase google-cloud-firestore


【解决方案1】:

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

【讨论】:

    【解决方案2】:

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

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

    【讨论】:

      猜你喜欢
      • 2019-05-16
      • 2017-10-11
      • 1970-01-01
      • 2010-09-25
      • 2011-03-29
      • 1970-01-01
      • 2021-11-10
      • 1970-01-01
      • 2019-03-01
      相关资源
      最近更新 更多