mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
Geometry: Fix width_approximation when rg and rd is missing.
This commit is contained in:
1 parent
c5df959210
commit
870cba5005
1 file changed
+20
-2
@@ -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):
|
||||
rg = self.get_point_by_name("rg")
|
||||
rd = self.get_point_by_name("rd")
|
||||
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))
|
||||
|
||||
|
||||
Reference in new issue
Block a user