我有一个这种格式的json:
{
"type":"Feature",
"properties":{},
"geometry":{
"type":"Point",
"coordinates":[6.74285888671875,-3.6778915094650726]
}
}
还有一个flask-geoalchemy2定义的字段是这样的:-
from app import db
from app.mixins import TimestampMixin
from geoalchemy2 import Geometry
class Event(db.Model, TimestampMixin):
__tablename__ = 'events'
id = db.Column(db.BigInteger, primary_key=True)
title = db.Column(db.Unicode(255))
start = db.Column(db.DateTime(timezone=True))
location = db.Column(Geometry(geometry_type='POINT', srid=4326))
is_active = db.Column(db.Boolean(), default=False)
def __repr__(self):
return '<Event %r %r>' % (self.id, self.title)
尝试保存分配有上述 json 值的event
对象失败并出现此错误event.location
DataError: (DataError) Geometry SRID (0) does not match column SRID (4326)
什么是正确的格式event.location
必须是为了
db.session.add(event)
db.session.commit()
正常工作?