Skip to content

Commit

Permalink
Merge pull request #70 from naturalsolutions/fix/get_main_rb_error
Browse files Browse the repository at this point in the history
fix error in get_main_rb
  • Loading branch information
JulienCorny authored Jul 1, 2024
2 parents 3e027e5 + 4a1bb99 commit fd21434
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions backend/gn_module_zh/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from geonature.utils.env import DB
from sqlalchemy import func
from sqlalchemy.sql import select, func
from sqlalchemy.orm import aliased

from werkzeug.exceptions import BadRequest

from .api_error import ZHApiError
Expand Down Expand Up @@ -81,14 +83,16 @@ def get_main_rb(query: list) -> int:
area = 0
for q_ in query:
zh_polygon = DB.session.execute(
select(TZH.geom).where(TZH.id_zh == getattr(q_, "id_zh")).first()
)
select(TZH.geom).where(TZH.id_zh == getattr(q_, "id_zh"))
).scalar_one()

rb_polygon = DB.session.execute(
select(TRiverBasin.geom)
.select_from(CorZhRb)
.join(TRiverBasin, TRiverBasin.id_rb == CorZhRb.id_rb)
.where(TRiverBasin.id_rb == getattr(q_, "id_rb"))
.first()
)
.limit(1)
).scalar_one()

intersection = DB.session.scalar(
select(
Expand Down

0 comments on commit fd21434

Please sign in to comment.