obu-firmware builds against vanetza-idf from microbu-esp32c5/external, but that tree was gitignored, so a clone of this repository could not build the firmware it ships. It is now committed here as ordinary files in its own folder, microbu-esp32c5/: the colleague's commit cf4b99f plus the V2X2MAP bridge's signature verification (--trust) used on the bench. Nothing is fetched from or pushed to the colleague's repository; this repository and its remotes carry everything. The folder's own .gitignore keeps build output, downloaded components and private key material out, as it did there; the committed file set is identical to that repository's tracked files. The ESP32-C5 is still flashed from obu-firmware/, which only takes vanetza-idf from microbu-esp32c5/, so the two stay separate folders. FLASHING.md says how to take a newer version of the colleague's tree (copy it over the folder, rebuild, test, commit).
95 lines
2.5 KiB
C++
95 lines
2.5 KiB
C++
#pragma once
|
|
#include <vanetza/security/v3/asn1_types.hpp>
|
|
#include <boost/geometry/core/closure.hpp>
|
|
#include <boost/geometry/core/cs.hpp>
|
|
#include <boost/geometry/geometries/point.hpp>
|
|
#include <boost/iterator/iterator_facade.hpp>
|
|
|
|
namespace vanetza
|
|
{
|
|
|
|
// forward declaration
|
|
struct PositionFix;
|
|
|
|
namespace security
|
|
{
|
|
namespace v3
|
|
{
|
|
|
|
/**
|
|
* TwoDLocationModel is a Boost.Geometry point model representing a 2D geographic location.
|
|
*/
|
|
using TwoDLocationModel = boost::geometry::model::point<double, 2, boost::geometry::cs::geographic<boost::geometry::degree>>;
|
|
|
|
/**
|
|
* \brief Create a TwoDLocationModel from an ASN.1 TwoDLocation.
|
|
*
|
|
* \param location The ASN.1 TwoDLocation_t structure to convert.
|
|
* \return A TwoDLocationModel representing the geographic location.
|
|
*/
|
|
TwoDLocationModel make_model(const asn1::TwoDLocation& location);
|
|
TwoDLocationModel make_model(const PositionFix&);
|
|
|
|
/**
|
|
* TwoDLocationIterator allows traversal of ASN.1 PolygonalRegion providing TwoDLocationModel objects.
|
|
*/
|
|
class TwoDLocationIterator :
|
|
public boost::iterator_facade<TwoDLocationIterator,
|
|
TwoDLocationModel,
|
|
boost::random_access_traversal_tag,
|
|
TwoDLocationModel>
|
|
{
|
|
public:
|
|
TwoDLocationIterator() = default;
|
|
explicit TwoDLocationIterator(const asn1::PolygonalRegion& region, std::size_t index);
|
|
|
|
private:
|
|
friend class boost::iterator_core_access;
|
|
|
|
void increment();
|
|
void decrement();
|
|
void advance(std::size_t n);
|
|
std::ptrdiff_t distance_to(const TwoDLocationIterator& other) const;
|
|
bool equal(const TwoDLocationIterator& other) const;
|
|
TwoDLocationModel dereference() const;
|
|
|
|
const asn1::PolygonalRegion* m_region = nullptr;
|
|
std::size_t m_index = 0;
|
|
};
|
|
|
|
/**
|
|
* \brief Adapt ASN.1 PolygonalRegion to a Boost.Geometry ring.
|
|
*/
|
|
class PolygonalRegionRingAdapter
|
|
{
|
|
public:
|
|
using iterator = TwoDLocationIterator;
|
|
using const_iterator = TwoDLocationIterator;
|
|
|
|
PolygonalRegionRingAdapter(const asn1::PolygonalRegion& region);
|
|
iterator begin() const;
|
|
iterator end() const;
|
|
std::size_t size() const;
|
|
|
|
private:
|
|
const asn1::PolygonalRegion& m_region;
|
|
};
|
|
|
|
} // namespace v3
|
|
} // namespace security
|
|
} // namespace vanetza
|
|
|
|
namespace boost
|
|
{
|
|
namespace geometry
|
|
{
|
|
namespace traits
|
|
{
|
|
|
|
template<> struct tag<vanetza::security::v3::PolygonalRegionRingAdapter> { using type = ring_tag; };
|
|
template<> struct closure<vanetza::security::v3::PolygonalRegionRingAdapter> { static const closure_selector value = open; };
|
|
|
|
} // namespace traits
|
|
} // namespace gemoetry
|
|
} // namespace boost
|