Branch data Line data Source code
1 : : // ----------------- BEGIN LICENSE BLOCK --------------------------------- 2 : : // 3 : : // Copyright (C) 2018-2021 Intel Corporation 4 : : // 5 : : // SPDX-License-Identifier: MIT 6 : : // 7 : : // ----------------- END LICENSE BLOCK ----------------------------------- 8 : : /** 9 : : * @file 10 : : */ 11 : : 12 : : #pragma once 13 : : 14 : : #include "ad/map/point/CoordinateTransform.hpp" 15 : : #include "ad/map/point/ECEFEdge.hpp" 16 : : #include "ad/map/point/ENUEdge.hpp" 17 : : #include "ad/map/point/GeoEdge.hpp" 18 : : #include "ad/map/point/Geometry.hpp" 19 : : #include "ad/physics/ParametricRange.hpp" 20 : : 21 : : /** @brief namespace ad */ 22 : : namespace ad { 23 : : /** @brief namespace map */ 24 : : namespace map { 25 : : /** @brief namespace point */ 26 : : namespace point { 27 : : 28 : : /** 29 : : * @brief validity check 30 : : * 31 : : * @param[in] geometry the geometry to check 32 : : */ 33 : 47010 : inline bool isValid(Geometry const &geometry) 34 : : { 35 : 47010 : return geometry.isValid; 36 : : } 37 : : 38 : : /** 39 : : * @brief create a geometry 40 : : * @param[in] points the points to create the geometry from 41 : : * @param[in] closed should the geometry be closed? 42 : : */ 43 : : Geometry createGeometry(const ECEFEdge &points, bool closed); 44 : : 45 : : /** 46 : : * @brief get the cached ENUEdge for a geometry 47 : : * @param[in] geometry the geometry to work on 48 : : * @returns Polyline that defines this Geometry in the ENU frame. 49 : : * \note Prior to the method call, valid coordinate transformation object must 50 : : * be set using SetCoordinateTransform(). 51 : : * ENU geometry will be calculated on-the-fly if 52 : : * - it was not previously calculated, or 53 : : * - ENU reference point has been changed. 54 : : */ 55 : : ENUEdge getCachedENUEdge(Geometry const &geometry); 56 : : 57 : : /** 58 : : * @brief Checks if Geometry is longitudinally connected with another Geometry at the end. 59 : : * @param[in] other Other object. Must be IsValid()! 60 : : * @returns True if this Geometry longitudinally connected with another Geometry at the end. 61 : : */ 62 : : bool isSuccessor(Geometry const &edge, const Geometry &other); 63 : : 64 : : /** 65 : : * @brief Checks if Geometry is longitudinally connected with another Geometry at the start. 66 : : * @param[in] other Other object. Must be IsValid()! 67 : : * @returns True if this Geometry longitudinally connected with another Geometry at the start. 68 : : */ 69 : : bool isPredecessor(Geometry const &edge, const Geometry &other); 70 : : 71 : : /** 72 : : * @brief Checks if two edges have same start point. 73 : : * @param[in] other Other object. Must be IsValid()! 74 : : * @returns True if this Geometry have same start point as another Geometry. 75 : : */ 76 : : bool haveSameStart(Geometry const &edge, const Geometry &other); 77 : : 78 : : /** 79 : : * @brief Checks if two edges have same end point. 80 : : * @param[in] other Other object. Must be IsValid()! 81 : : * @returns True if this Edge have same end point as another Edge. 82 : : */ 83 : : bool haveSameEnd(Geometry const &edge, const Geometry &other); 84 : : 85 : : /** 86 : : * @brief Calculates parametric point on the geometry. 87 : : * @param[in] t Parameter. 0 will return first point, and 1 last point on the geometry. 88 : : * @return Parameteric point on the geometry. Can be invalid. 89 : : */ 90 : : point::ECEFPoint getParametricPoint(Geometry const &geometry, const physics::ParametricValue &t); 91 : : 92 : : /** 93 : : * @brief Generates sub-geometry for given range. 94 : : * @param[in] geometry source geometry. 95 : : * @param[in] trange Specifies parametric range. 96 : : * @param[out] outputEdge The output edge to be filled with the sub-geometry points 97 : : * @param[in] revertOrder optional parameter: if set \c true the order of the points in the outputEdge is in reverse 98 : : * order of the geometry 99 : : * @return Sub-geometry. 100 : : */ 101 : : void getParametricRange(Geometry const &geometry, 102 : : const physics::ParametricRange &trange, 103 : : ECEFEdge &outputEdge, 104 : : const bool revertOrder = false); 105 : : 106 : : /** 107 : : * @brief Generates sub-geometry for given range. 108 : : * @param[in] geometry source geometry. 109 : : * @param[in] trange Specifies parametric range. 110 : : * @param[out] outputEdge The output edge to be filled with the sub-geometry points 111 : : * @param[in] revertOrder optional parameter: if set \c true the order of the points in the outputEdge is in reverse 112 : : * order of the geometry 113 : : * @return Sub-geometry. 114 : : */ 115 : : void getParametricRange(Geometry const &geometry, 116 : : const physics::ParametricRange &trange, 117 : : GeoEdge &outputEdge, 118 : : const bool revertOrder = false); 119 : : 120 : : /** 121 : : * @brief Generates sub-geometry for given range. 122 : : * This overloaded member internally makes use of the getCachedENUEdge() feature of the geometry. 123 : : * 124 : : * @param[in] geometry source geometry. 125 : : * @param[in] trange Specifies parametric range. 126 : : * @param[out] outputEdge The output edge to be filled with the sub-geometry points 127 : : * @param[in] revertOrder optional parameter: if set \c true the order of the points in the outputEdge is in reverse 128 : : * order of the geometry 129 : : * @return Sub-geometry. 130 : : */ 131 : : void getParametricRange(Geometry const &geometry, 132 : : const physics::ParametricRange &trange, 133 : : ENUEdge &outputEdge, 134 : : const bool revertOrder = false); 135 : : 136 : : /** 137 : : * @brief Finds point on geometry nearest to given point. 138 : : * @param[in] pt Point of interest. 139 : : * @returns Parametric point on geometry nearest to the pt. 140 : : * Can be invalid (if pt is Invalid(), geometry is empty etc.). 141 : : */ 142 : : physics::ParametricValue findNearestPointOnEdge(Geometry const &geometry, const point::ECEFPoint &pt); 143 : : 144 : : /** 145 : : * @brief Calculates middle line between two Geometries. 146 : : * @param[in] geometry A geometry 147 : : * @param[in] other Another geometry. 148 : : * @returns Middle line between two Geometry. Contains same number of points as biggest one. 149 : : */ 150 : : ECEFEdge getMiddleEdge(Geometry const &geometry, Geometry const &other); 151 : : 152 : : } // namespace point 153 : : } // namespace map 154 : : } // namespace ad