mirror of https://gitlab.com/pamhyr/pamhyr2
Point: Delete missing points at 0.1.0 update.
parent
fa9ffccb19
commit
84a5bed66d
|
|
@ -314,7 +314,6 @@ class BoundaryCondition(SQLSubModel):
|
|||
|
||||
ind = 0
|
||||
for d in self._data:
|
||||
print(d)
|
||||
data["ind"] = ind
|
||||
|
||||
d._db_save(execute, data)
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
|
||||
from math import dist
|
||||
import numpy as np
|
||||
|
||||
|
|
@ -23,6 +25,8 @@ from Model.Tools.PamhyrDB import SQLSubModel
|
|||
from Model.Scenario import Scenario
|
||||
from Model.Geometry.Point import Point
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class PointXYZ(Point, SQLSubModel):
|
||||
_sub_classes = []
|
||||
|
|
@ -116,6 +120,12 @@ class PointXYZ(Point, SQLSubModel):
|
|||
pid = next(it)
|
||||
profile_id = next(it)
|
||||
|
||||
if profile_id not in profiles:
|
||||
logger.warning(
|
||||
f"This point as no associated profile ({profile_id})"
|
||||
)
|
||||
continue
|
||||
|
||||
execute(
|
||||
f"UPDATE {table} " +
|
||||
f"SET profile = {profiles[profile_id]} " +
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import numpy as np
|
|||
from typing import List
|
||||
from functools import reduce
|
||||
|
||||
from tools import timer
|
||||
from tools import timer, flatten
|
||||
from shapely import geometry
|
||||
|
||||
from Model.Tools.PamhyrDB import SQLSubModel
|
||||
|
|
@ -129,6 +129,8 @@ class ProfileXYZ(Profile, SQLSubModel):
|
|||
id2pid = data['id2pid']
|
||||
reachs = id2pid['river_reach']
|
||||
|
||||
cls._db_update_cleanup_points(execute)
|
||||
|
||||
cls.update_db_add_pamhyr_id(execute, table, data)
|
||||
Scenario.update_db_add_scenario(execute, table)
|
||||
|
||||
|
|
@ -152,6 +154,24 @@ class ProfileXYZ(Profile, SQLSubModel):
|
|||
sl = id2pid['sedimentary_layer']
|
||||
cls._db_update_to_0_1_0_set_sl_pid(execute, table, sl)
|
||||
|
||||
@classmethod
|
||||
def _db_update_cleanup_points(cls, execute):
|
||||
profiles = set(
|
||||
map(
|
||||
str,
|
||||
flatten(
|
||||
execute(
|
||||
"SELECT id FROM geometry_profileXYZ"
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
execute(
|
||||
"DELETE FROM geometry_pointXYZ " +
|
||||
f"WHERE profile NOT IN ({', '.join(profiles)})"
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def _db_update_to_0_1_0_set_sl_pid(cls, execute, table, sl):
|
||||
els = execute(
|
||||
|
|
|
|||
Loading…
Reference in New Issue