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
|
ind = 0
|
||||||
for d in self._data:
|
for d in self._data:
|
||||||
print(d)
|
|
||||||
data["ind"] = ind
|
data["ind"] = ind
|
||||||
|
|
||||||
d._db_save(execute, data)
|
d._db_save(execute, data)
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from math import dist
|
from math import dist
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
|
@ -23,6 +25,8 @@ from Model.Tools.PamhyrDB import SQLSubModel
|
||||||
from Model.Scenario import Scenario
|
from Model.Scenario import Scenario
|
||||||
from Model.Geometry.Point import Point
|
from Model.Geometry.Point import Point
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
class PointXYZ(Point, SQLSubModel):
|
class PointXYZ(Point, SQLSubModel):
|
||||||
_sub_classes = []
|
_sub_classes = []
|
||||||
|
|
@ -116,6 +120,12 @@ class PointXYZ(Point, SQLSubModel):
|
||||||
pid = next(it)
|
pid = next(it)
|
||||||
profile_id = 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(
|
execute(
|
||||||
f"UPDATE {table} " +
|
f"UPDATE {table} " +
|
||||||
f"SET profile = {profiles[profile_id]} " +
|
f"SET profile = {profiles[profile_id]} " +
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ import numpy as np
|
||||||
from typing import List
|
from typing import List
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
|
|
||||||
from tools import timer
|
from tools import timer, flatten
|
||||||
from shapely import geometry
|
from shapely import geometry
|
||||||
|
|
||||||
from Model.Tools.PamhyrDB import SQLSubModel
|
from Model.Tools.PamhyrDB import SQLSubModel
|
||||||
|
|
@ -129,6 +129,8 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||||
id2pid = data['id2pid']
|
id2pid = data['id2pid']
|
||||||
reachs = id2pid['river_reach']
|
reachs = id2pid['river_reach']
|
||||||
|
|
||||||
|
cls._db_update_cleanup_points(execute)
|
||||||
|
|
||||||
cls.update_db_add_pamhyr_id(execute, table, data)
|
cls.update_db_add_pamhyr_id(execute, table, data)
|
||||||
Scenario.update_db_add_scenario(execute, table)
|
Scenario.update_db_add_scenario(execute, table)
|
||||||
|
|
||||||
|
|
@ -152,6 +154,24 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||||
sl = id2pid['sedimentary_layer']
|
sl = id2pid['sedimentary_layer']
|
||||||
cls._db_update_to_0_1_0_set_sl_pid(execute, table, sl)
|
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
|
@classmethod
|
||||||
def _db_update_to_0_1_0_set_sl_pid(cls, execute, table, sl):
|
def _db_update_to_0_1_0_set_sl_pid(cls, execute, table, sl):
|
||||||
els = execute(
|
els = execute(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue