Skip to content

Commit

Permalink
Transform geom in 4326 #1104
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrien-Pajot authored and TheoLechemia committed Aug 2, 2021
1 parent e0072b2 commit ec216ee
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions backend/geonature/core/gn_profiles/routes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from flask import Blueprint
import json

from flask import Blueprint
from geojson import Feature
from sqlalchemy.sql import func
from utils_flask_sqla.response import json_resp

from geonature.core.gn_profiles.models import VmCorTaxonPhenology
Expand All @@ -23,9 +26,16 @@ def get_phenology(cd_ref):
@routes.route("/valid_profile/<cd_ref>", methods=["GET"])
@json_resp
def get_profile(cd_ref):
data = DB.session.query(VmValidProfiles).get(cd_ref)
data = (
DB.session.query(
func.st_asgeojson(func.st_transform(VmValidProfiles.valid_distribution, 4326)),
VmValidProfiles,
)
.filter(VmValidProfiles.cd_ref == cd_ref)
.one_or_none()
)
if data:
return data.as_geofeature("valid_distribution", "cd_ref", False)
return Feature(geometry=json.loads(data[0]), properties=data[1].as_dict())
return None

# récupérer la query string
Expand Down

0 comments on commit ec216ee

Please sign in to comment.