Module losanalyst.classes.los_without_target

Expand source code
from osgeo import ogr
from losanalyst.classes.los import LoS
from gdalhelpers.helpers import math_helpers


class LoSWithoutTarget(LoS):

    def __init__(self,
                 points: list,
                 observer_offset: float = 0,
                 sampling_distance: float = None,
                 use_curvature_corrections: bool = True,
                 refraction_coefficient: float = 0.13):

        super().__init__(points=points,
                         is_without_target=True,
                         observer_offset=observer_offset,
                         sampling_distance=sampling_distance,
                         use_curvature_corrections=use_curvature_corrections,
                         refraction_coefficient=refraction_coefficient)

    def get_horizontal_angle(self) -> float:
        return math_helpers.horizontal_angle(self.points[0][0], self.points[0][1],
                                             self.points[-1][0], self.points[-1][1])

    def get_maximal_vertical_angle(self) -> float:
        angles = [row[4] for row in self.points]
        return max(angles)

    def __get_max_local_horizon_index(self) -> int:

        index_visible = None
        index_horizon = None

        for i in range(len(self.points) - 1, -1, -1):
            if self.visible[i]:
                index_visible = i
                break

        if 0 < index_visible:
            for i in range(index_visible - 1, -1, -1):
                if self.horizon[i]:
                    index_horizon = i
                    break

        return index_horizon

    def get_max_local_horizon_angle(self) -> float:

        index_horizon = self.__get_max_local_horizon_index()

        if index_horizon is not None:
            return self.points[index_horizon][4]
        else:
            return -180

    def get_local_horizon_distance(self) -> float:

        index_horizon = self.__get_max_local_horizon_index()

        if index_horizon is not None:
            return self.points[index_horizon][2]
        else:
            return 0

    def get_max_local_horizon(self) -> ogr.Geometry:

        index = self.__get_max_local_horizon_index()

        if index is None:
            index = 0

        return self._get_geom_at_index(index)

    def __get_global_horizon_index(self) -> int:

        index = None

        for i in range(len(self.points)-1, -1, -1):
            if self.horizon[i]:
                index = i
                break

        return index

    def get_global_horizon_distance(self) -> float:

        index = self.__get_global_horizon_index()

        if index is not None:
            return self.points[index][2]
        else:
            return 0

    def get_global_horizon(self) -> ogr.Geometry:

        index = self.__get_global_horizon_index()

        if index is None:
            index = -1

        return self._get_geom_at_index(index)

Classes

class LoSWithoutTarget (points, observer_offset=0, sampling_distance=None, use_curvature_corrections=True, refraction_coefficient=0.13)

Basic class representing LoS. From this class the specific types of LoS (local, global, without target) are derived.

Attributes

points : list of list of float
List of points that represents LoS. The structure is [[X1, Y1, Z1], [X2, Y2, Z2] … [Xn, Yn, Zn]].
is_global : bool
Is the LoS global?
is_without_target : bool
Is the LoS without target?
observer_offset, target_offset : float
Values representing offset of observer and target.
target_x, target_y : float
Coordinates of the target point. Necessary for global LoS.
use_curvature_corrections : bool, optional
Calculate Earth curvature corrections while analyzing LoS. Default value is True.
refraction_coefficient : float, optional
Refraction coefficient. Default value is 0.13.
target_index : int
Index of target point in points. Important for global LoS, for local LoS the value is len(points)-1.
previous_max_angle : list of floats
Maximal view angle before the given point (in points).
visible : list of bool
Is the given point (from points) visible?
horizon : list of bool
Is the given point (from points) horizon?

Constructor of Los.

Parameters

points : list of list of float
List of points that represents LoS. The structure is [[X1, Y1, Z1], [X2, Y2, Z2] … [Xn, Yn, Zn]].
is_global : bool
Is the LoS global?
is_without_target : bool
Is the LoS without target?
observer_offset, target_offset : float
Values representing offset of observer and target.
target_x, target_y : float
Coordinates of the target point. Necessary for global LoS.
sampling_distance : float, optional
Sampling distance on Los if it known. Otherwise it is estimated from points.
use_curvature_corrections : bool, optional
Calculate Earth curvature corrections while analyzing LoS. Default value is True.
refraction_coefficient : float, optional
Refraction coefficient. Default value is 0.13.
Expand source code
class LoSWithoutTarget(LoS):

    def __init__(self,
                 points: list,
                 observer_offset: float = 0,
                 sampling_distance: float = None,
                 use_curvature_corrections: bool = True,
                 refraction_coefficient: float = 0.13):

        super().__init__(points=points,
                         is_without_target=True,
                         observer_offset=observer_offset,
                         sampling_distance=sampling_distance,
                         use_curvature_corrections=use_curvature_corrections,
                         refraction_coefficient=refraction_coefficient)

    def get_horizontal_angle(self) -> float:
        return math_helpers.horizontal_angle(self.points[0][0], self.points[0][1],
                                             self.points[-1][0], self.points[-1][1])

    def get_maximal_vertical_angle(self) -> float:
        angles = [row[4] for row in self.points]
        return max(angles)

    def __get_max_local_horizon_index(self) -> int:

        index_visible = None
        index_horizon = None

        for i in range(len(self.points) - 1, -1, -1):
            if self.visible[i]:
                index_visible = i
                break

        if 0 < index_visible:
            for i in range(index_visible - 1, -1, -1):
                if self.horizon[i]:
                    index_horizon = i
                    break

        return index_horizon

    def get_max_local_horizon_angle(self) -> float:

        index_horizon = self.__get_max_local_horizon_index()

        if index_horizon is not None:
            return self.points[index_horizon][4]
        else:
            return -180

    def get_local_horizon_distance(self) -> float:

        index_horizon = self.__get_max_local_horizon_index()

        if index_horizon is not None:
            return self.points[index_horizon][2]
        else:
            return 0

    def get_max_local_horizon(self) -> ogr.Geometry:

        index = self.__get_max_local_horizon_index()

        if index is None:
            index = 0

        return self._get_geom_at_index(index)

    def __get_global_horizon_index(self) -> int:

        index = None

        for i in range(len(self.points)-1, -1, -1):
            if self.horizon[i]:
                index = i
                break

        return index

    def get_global_horizon_distance(self) -> float:

        index = self.__get_global_horizon_index()

        if index is not None:
            return self.points[index][2]
        else:
            return 0

    def get_global_horizon(self) -> ogr.Geometry:

        index = self.__get_global_horizon_index()

        if index is None:
            index = -1

        return self._get_geom_at_index(index)

Ancestors

Methods

def get_global_horizon(self)
Expand source code
def get_global_horizon(self) -> ogr.Geometry:

    index = self.__get_global_horizon_index()

    if index is None:
        index = -1

    return self._get_geom_at_index(index)
def get_global_horizon_distance(self)
Expand source code
def get_global_horizon_distance(self) -> float:

    index = self.__get_global_horizon_index()

    if index is not None:
        return self.points[index][2]
    else:
        return 0
def get_horizontal_angle(self)
Expand source code
def get_horizontal_angle(self) -> float:
    return math_helpers.horizontal_angle(self.points[0][0], self.points[0][1],
                                         self.points[-1][0], self.points[-1][1])
def get_local_horizon_distance(self)
Expand source code
def get_local_horizon_distance(self) -> float:

    index_horizon = self.__get_max_local_horizon_index()

    if index_horizon is not None:
        return self.points[index_horizon][2]
    else:
        return 0
def get_max_local_horizon(self)
Expand source code
def get_max_local_horizon(self) -> ogr.Geometry:

    index = self.__get_max_local_horizon_index()

    if index is None:
        index = 0

    return self._get_geom_at_index(index)
def get_max_local_horizon_angle(self)
Expand source code
def get_max_local_horizon_angle(self) -> float:

    index_horizon = self.__get_max_local_horizon_index()

    if index_horizon is not None:
        return self.points[index_horizon][4]
    else:
        return -180
def get_maximal_vertical_angle(self)
Expand source code
def get_maximal_vertical_angle(self) -> float:
    angles = [row[4] for row in self.points]
    return max(angles)

Inherited members