简体   繁体   English

如何构造和存储地理点

[英]How to construct and store the geopoint

Am working on GAE with python. 我正在使用python开发GAE。 How to construct and store the latitude and longitude using GeoPoint? 如何使用GeoPoint构造和存储纬度和经度?

This is my DB 这是我的数据库

class Customer(db.Model):
    name = db.StringProperty()
    address= db.PostalAddressProperty()
    geopoint= db.GeoPtProperty()

My code 我的密码

class AddCustomerHandler(BaseHandler):
    input_fullname=self.request.get('fullname')
    input_cusaddress=self.request.get('cusaddress')
    input_latitude=self.request.get('latitude')
    input_longitude=self.request.get('longitude')


    input_geopoint= GeoPoint(input_latitude, input_longitude)
    logging.info('****************** xxxx= %s', input_geopoint)

    newcustomer=Customer(name=input_fullname,address=input_cusaddress,geopoint=input_geopoint)
    newcustomer.put()

Am trying this code. 正在尝试此代码。 But Am getting error. 但是我得到了错误。 How to store this geopoint field? 如何存储这个geopoint字段?

 input_geopoint= GeoPoint(input_latitude, input_longitude) NameError: global name 'GeoPoint' is not defined. 

Am getting this error 正在收到此错误

You're getting that error because you don't have the module imported where GeoPoint is defined. 之所以收到该错误,是因为您没有在定义GeoPoint位置导入模块。

Add this import 添加此导入

from google.appengine.api import search

and then use like this 然后像这样使用

input_geopoint = search.GeoPoint(input_latitude, input_longitude)

Also see the docs 另请参阅文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM