My problem is this. I'm creating a model for some data.
class Cables(Base):
__tablename__ = 'cables'
id = Column(Integer, nullable=False)
route = Column(Geometry(geometry_type='LINESTRING', srid=4326), nullable=False)
Now, I want to transform such a route to GeoJSON.
Things I've tried
@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))
returns ST_AsGeoJSON(ST_GeomFromEWKB(:ST_GeomFromEWKB_1))
If I change the return:
return geoalchemy2.functions.ST_AsGeoJSON(cable.route)
returns TypeError: 'ST_AsGeoJSON' object is not callable
return str(cable.route)
returns 0102000020e610000002000000b34fd4d9bca351c032e14d5134c240c0d24f8055e0a351c0dedea9f4dcbf40c0
This would signal that I do have a geometry object.
return cable.route
returns TypeError: 'WKBElement' object is not callable
If I print the route type,
print(type(cable.route))
returns
<class 'geoalchemy2.elements.WKBElement'>
I thought it should have returned an object of such class, and not the class itself. I'm baffled at this point and I don't know what I should do now.
Any suggestions?