mirror of https://gitlab.com/pamhyr/pamhyr2
Geometry: Fix width_approximation when rg and rd is missing.
parent
c5df959210
commit
870cba5005
|
|
@ -19,6 +19,7 @@
|
|||
import logging
|
||||
import numpy as np
|
||||
from typing import List
|
||||
from functools import reduce
|
||||
|
||||
from tools import timer
|
||||
|
||||
|
|
@ -324,6 +325,19 @@ class ProfileXYZ(Profile, SQLSubModel):
|
|||
f"for profile ({self.id}) kp = {self.kp}"
|
||||
)
|
||||
|
||||
def has_standard_named_points(self):
|
||||
l, r = reduce(
|
||||
lambda acc, n: (
|
||||
(acc[0] | (n == "rg")),
|
||||
(acc[1] | (n == "rd"))
|
||||
),
|
||||
map(lambda p: p.name.lower().strip(),
|
||||
self.points),
|
||||
(False, False)
|
||||
)
|
||||
|
||||
return l & r
|
||||
|
||||
def add(self):
|
||||
"""Add a new PointXYZ to profile.
|
||||
|
||||
|
|
@ -454,8 +468,12 @@ class ProfileXYZ(Profile, SQLSubModel):
|
|||
return list(map(lambda s: s - constant, station))
|
||||
|
||||
def width_approximation(self):
|
||||
if self.has_standard_named_points():
|
||||
rg = self.get_point_by_name("rg")
|
||||
rd = self.get_point_by_name("rd")
|
||||
else:
|
||||
rg = self.points[0]
|
||||
rd = self.points[-1]
|
||||
|
||||
return abs(rg.dist(rd))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue