Files
Ashin Walpola d107534eb2 Keep vanetza-idf in obu-firmware, so a plain clone builds the firmware
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.
2026-09-24 10:56:05 +02:00

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