제 문제는 이것입니다. 일부 데이터에 대한 모델을 만들고 있습니다.geometry를 geojson으로 변환 할 수 없습니다.
class Cables(Base):
__tablename__ = 'cables'
id = Column(Integer, nullable=False)
route = Column(Geometry(geometry_type='LINESTRING', srid=4326), nullable=False)
이제 이러한 경로를 GeoJSON으로 변환하고 싶습니다. 내가 반환 변경하는 경우
것들 내가
@app.route("/api/cable/<int:id>", methods=['GET'])
def get_cable(id):
cable = session.query(Cables).filter(Cables.id == id).first()
return str(geoalchemy2.functions.ST_AsGeoJSON(cable.route))
반환 ST_AsGeoJSON(ST_GeomFromEWKB(:ST_GeomFromEWKB_1))
을 시도했다 :
return geoalchemy2.functions.ST_AsGeoJSON(cable.route)
수익을 TypeError: 'ST_AsGeoJSON' object is not callable
return str(cable.route)
반환 0102000020e610000002000000b34fd4d9bca351c032e14d5134c240c0d24f8055e0a351c0dedea9f4dcbf40c0
이것은 내가 기하학 객체를 가지고 있다는 신호 것입니다.
return cable.route
반환 TypeError: 'WKBElement' object is not callable
내가 경로 유형을 인쇄 할 경우
,
print(type(cable.route))
반환
<class 'geoalchemy2.elements.WKBElement'>
나는이 같은 클래스의 객체를 반환하고,하지 않은한다고 생각 클래스 그 자체. 나는이 시점에서 당혹스럽고 지금 무엇을해야하는지 모른다.
제안 사항?