def _make_4326_polygon_from_bbox(bbox: list, srid: int) -> Polygon:
""" make a shapely Polygon in SRID 4326 from bbox and srid"""
try:
polygon = box(bbox[0], bbox[1], bbox[2], bbox[3])
if not srid == 4326:
geometry = shape.from_shape(polygon, srid)
geom_4326 = db.engine.execute(ST_Transform(geometry, 4326)).scalar()
polygon = shape.to_shape(geom_4326)
except Exception as e:
raise ProjectSearchServiceError(f'error making polygon: {e}')
return polygon
评论列表
文章目录