geometry/Point.h
Go to the documentation of this file.
1 #pragma once
2 #include <boost/version.hpp>
3 #if BOOST_VERSION < 106300 && BOOST_VERSION >= 106200
4 // Boost 1.62 is missing an iostream include...
5 #include <iostream>
6 #endif
7 #include <boost/geometry/algorithms/distance.hpp>
8 #include <boost/geometry/geometries/geometries.hpp>
9 #include <boost/geometry/geometries/register/point.hpp>
10 #include <boost/geometry/strategies/strategies.hpp>
11 
13 
14 /***********************************************************************
15  * BOOST GEOMETRY REGISTRATIONS *
16  ***********************************************************************/
17 BOOST_GEOMETRY_REGISTER_POINT_3D(lanelet::BasicPoint3d, double, cs::cartesian, x(), y(), z())
18 BOOST_GEOMETRY_REGISTER_POINT_2D(lanelet::BasicPoint2d, double, cs::cartesian, x(), y())
19 BOOST_GEOMETRY_REGISTER_POINT_2D(Eigen::Vector2d, double, cs::cartesian, x(), y())
20 BOOST_GEOMETRY_REGISTER_POINT_2D(lanelet::Point2d, double, cs::cartesian, x(), y())
21 BOOST_GEOMETRY_REGISTER_POINT_2D_CONST(lanelet::ConstPoint2d, double, cs::cartesian, x(), y())
22 BOOST_GEOMETRY_REGISTER_POINT_3D(lanelet::Point3d, double, cs::cartesian, x(), y(), z())
23 BOOST_GEOMETRY_REGISTER_POINT_3D_CONST(lanelet::ConstPoint3d, double, cs::cartesian, x(), y(), z())
24 
25 namespace boost {
26 namespace geometry {
27 // Help boost with type deduction for proxies
28 template <typename Policy>
29 struct robust_point_type<const lanelet::BasicPoint2d, Policy> {
30  using type = lanelet::BasicPoint2d; // NOLINT
31 };
32 
33 template <>
34 struct robust_point_type<const lanelet::BasicPoint2d, detail::no_rescale_policy> {
35  using type = lanelet::BasicPoint2d; // NOLINT
36 };
37 
38 } // namespace geometry
39 } // namespace boost
40 
41 namespace lanelet {
42 namespace geometry {
43 namespace internal {
44 template <typename T, typename Enable = void>
45 struct GetGeometry {
46  static inline auto twoD(const T& geometry) { return geometry; }
47  static inline auto threeD(const T& geometry) { return geometry; }
48 };
49 
50 template <typename T>
51 struct GetGeometry<T, IfPT<T, void>> {
52  static inline auto twoD(const T& geometry) { return traits::to2D(geometry); }
53  static inline auto threeD(const T& geometry) { return traits::to3D(geometry); }
54 };
55 
56 template <typename T1, typename T2>
57 constexpr bool isTrivialDistance() {
58  return traits::noRegelem<T1>() && traits::noRegelem<T2>() &&
59  !(traits::isCategory<T1, traits::LineStringTag>() && traits::isCategory<T2, traits::LineStringTag>() &&
60  traits::is3D<T1>());
61 }
62 } // namespace internal
64 
66 template <typename Geometry1T, typename Geometry2T>
67 auto distance2d(const Geometry1T& p1, const Geometry2T& p2)
68  -> std::enable_if_t<internal::isTrivialDistance<Geometry1T, Geometry2T>(), double> {
69  return distance(internal::GetGeometry<Geometry1T>::twoD(p1), internal::GetGeometry<Geometry2T>::twoD(p2));
70 }
71 
73 template <typename Geometry1T, typename Geometry2T>
74 auto distance3d(const Geometry1T& p1, const Geometry2T& p2)
75  -> std::enable_if_t<internal::isTrivialDistance<Geometry1T, Geometry2T>(), double> {
76  return distance(internal::GetGeometry<Geometry1T>::threeD(p1), internal::GetGeometry<Geometry2T>::threeD(p2));
77 }
78 } // namespace geometry
79 } // namespace lanelet
type
Eigen::Vector3d BasicPoint3d
a simple 3d-point
std::enable_if_t< traits::isPointT< T >(), RetT > IfPT
BasicPoint p2
Optional< double > distance
IfLS2< LineString3d1T, LineString3d2T, double > distance3d(const LineString3d1T &l1, const LineString3d2T &l2)
Eigen::Matrix< double, 2, 1, Eigen::DontAlign > BasicPoint2d
a simple 2d-point
BasicPoint p1
BoundingBox2d to2D(const BoundingBox3d &primitive)
BoundingBox3d to3D(const BoundingBox2d &primitive)
double distance2d(const RegulatoryElement &regElem, const BasicPoint2d &p)


lanelet2_core
Author(s): Fabian Poggenhans
autogenerated on Tue Jun 6 2023 02:23:32