refactor get_altitudes()
This commit is contained in:
parent
9b66a2b4e5
commit
7575605aae
1 changed files with 2 additions and 11 deletions
|
@ -149,17 +149,8 @@ class AltitudeArea(LevelGeometryMixin, models.Model):
|
|||
if self.altitude2 is None:
|
||||
return np.full((points.shape[0], ), fill_value=float(self.altitude))
|
||||
|
||||
a_to_p = points - np.array(self.point1)
|
||||
a_to_b = np.array(self.point2) - np.array(self.point1)
|
||||
|
||||
atb2 = (a_to_b**2).sum()
|
||||
|
||||
atp_dot_atb = a_to_p[:, 0] * a_to_b[0] + a_to_p[:, 1] * a_to_b[1]
|
||||
|
||||
distances = atp_dot_atb / atb2
|
||||
|
||||
distances = distances.clip(0, 1)
|
||||
|
||||
slope = np.array(self.point2) - np.array(self.point1)
|
||||
distances = np.sum(((points - np.array(self.point1)) * slope), axis=1) / (slope ** 2).sum().clip(0, 1)
|
||||
return self.altitude + distances*(self.altitude2-self.altitude)
|
||||
|
||||
@classmethod
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue