obu-firmware builds against the vanetza-idf C-ITS library, which until now came from the colleague's microbu-esp32c5 tree beside the repository and was not tracked here, so a clone of this repository could not build the firmware it ships. The library alone is now part of obu-firmware, as obu-firmware/external/vanetza-idf: their external/vanetza-idf at commit cf4b99f, unchanged (9775 files; see its PROVENANCE.md). CMake takes it from there by default; -DVANETZA_IDF_DIR still points the build elsewhere. The rest of the colleague's tree (their own VAM firmware, PKI tooling, station-link Python tools, the V2X2MAP bridge) stays out of this repository and gitignored; nothing is pushed to their repository. NOTES.md, docs/06, TODO.md and the pcap verifier's usage line point at the new location.
102 lines
2.6 KiB
C++
102 lines
2.6 KiB
C++
#ifndef AREAS_HPP_CVK1NIAI
|
|
#define AREAS_HPP_CVK1NIAI
|
|
|
|
#include <vanetza/geodesy/geodesy.hpp>
|
|
#include <vanetza/units/area.hpp>
|
|
#include <boost/variant.hpp>
|
|
|
|
namespace vanetza
|
|
{
|
|
namespace geonet
|
|
{
|
|
|
|
using geodesy::CartesianPosition;
|
|
using geodesy::GeodeticPosition;
|
|
using geodesy::distance;
|
|
using geodesy::local_cartesian;
|
|
|
|
struct Circle
|
|
{
|
|
Circle() : r(1.0 * units::si::meters) {}
|
|
units::Length r; // radius
|
|
};
|
|
|
|
struct Rectangle
|
|
{
|
|
Rectangle() : a(1.0 * units::si::meters), b(1.0 * units::si::meters) {}
|
|
units::Length a; // center to long side
|
|
units::Length b; // center to short side
|
|
};
|
|
|
|
struct Ellipse
|
|
{
|
|
Ellipse() : a(1.0 * units::si::meters), b(1.0 * units::si::meters) {}
|
|
units::Length a; // long semi-axis
|
|
units::Length b; // short semi-axis
|
|
};
|
|
|
|
struct Area
|
|
{
|
|
boost::variant<Rectangle, Ellipse, Circle> shape;
|
|
GeodeticPosition position;
|
|
units::Angle angle;
|
|
};
|
|
|
|
double geometric_function(const Circle&, const CartesianPosition&);
|
|
double geometric_function(const Rectangle&, const CartesianPosition&);
|
|
double geometric_function(const Ellipse&, const CartesianPosition&);
|
|
double geometric_function(const decltype(Area::shape)&, const CartesianPosition&);
|
|
|
|
/**
|
|
* Canonicalize a point in a shape's coordinate system w.r.t. its azimuth angle
|
|
* \param point Point to canonicalize
|
|
* \param azimuth Azimuth angle of shape's long side
|
|
* \return canonical position (suitable for geometric_function)
|
|
*/
|
|
CartesianPosition canonicalize(const CartesianPosition& point, units::Angle azimuth);
|
|
|
|
/**
|
|
* Check if positon is within or at border of area
|
|
* \param area with shape, dimensions, azimuth and center point position
|
|
* \param position Geodetic position to check against area
|
|
* \return true if position is inside or at border
|
|
*/
|
|
bool inside_or_at_border(const Area&, const GeodeticPosition&);
|
|
|
|
/**
|
|
* Calculate area size in square km.
|
|
* \param area Area object
|
|
* \return area size
|
|
*/
|
|
units::Area area_size(const Area&);
|
|
|
|
template<class SHAPE>
|
|
bool inside_shape(const SHAPE& shape, const CartesianPosition& p)
|
|
{
|
|
return geometric_function(shape, p) > 0.0;
|
|
}
|
|
|
|
template<class SHAPE>
|
|
bool outside_shape(const SHAPE& shape, const CartesianPosition& p)
|
|
{
|
|
return geometric_function(shape, p) < 0.0;
|
|
}
|
|
|
|
template<class SHAPE>
|
|
bool at_shape_border(const SHAPE& shape, const CartesianPosition& p)
|
|
{
|
|
return geometric_function(shape, p) == 0.0;
|
|
}
|
|
|
|
template<class SHAPE>
|
|
bool at_center_point(const SHAPE& shape, const CartesianPosition& p)
|
|
{
|
|
return geometric_function(shape, p) == 1.0;
|
|
}
|
|
|
|
} // namespace geonet
|
|
} // namespace vanetza
|
|
|
|
#endif /* AREAS_HPP_CVK1NIAI */
|
|
|