Files
MapLibreParticleLab/include/mln/style/variable_anchor_offset_collection.hpp
Bart Louwers 2a8ebc4906 core: rename mbgl directories to mln (#4511)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-08-22 20:50:14 +02:00

62 lines
1.8 KiB
C++

#pragma once
#include <mln/style/types.hpp>
#include <mln/util/feature.hpp>
#include <mln/util/geometry.hpp>
#include <array>
#include <string>
#include <vector>
namespace mln {
struct AnchorOffsetPair {
style::SymbolAnchorType anchorType;
std::array<float, 2> offset;
AnchorOffsetPair(style::SymbolAnchorType anchorType_, std::array<float, 2> offset_)
: anchorType(anchorType_),
offset(offset_) {}
bool operator==(const AnchorOffsetPair& other) const = default;
};
class VariableAnchorOffsetCollection {
private:
using CollectionType = std::vector<AnchorOffsetPair>;
CollectionType anchorOffsets;
public:
VariableAnchorOffsetCollection() = default;
VariableAnchorOffsetCollection(const VariableAnchorOffsetCollection& other) = default;
VariableAnchorOffsetCollection(VariableAnchorOffsetCollection&& other) noexcept = default;
VariableAnchorOffsetCollection(std::vector<AnchorOffsetPair>&& values) { anchorOffsets = std::move(values); }
std::array<float, 2> getOffsetByAnchor(const style::SymbolAnchorType& anchorType) const;
std::string toString() const;
mln::Value serialize() const;
bool empty() const { return anchorOffsets.size() == 0; }
CollectionType::size_type size() const { return anchorOffsets.size(); }
CollectionType::const_iterator begin() const { return anchorOffsets.begin(); }
CollectionType::const_iterator end() const { return anchorOffsets.end(); }
const AnchorOffsetPair& operator[](size_t index) const { return anchorOffsets[index]; }
VariableAnchorOffsetCollection& operator=(const VariableAnchorOffsetCollection& other) = default;
VariableAnchorOffsetCollection& operator=(VariableAnchorOffsetCollection&& other) noexcept = default;
bool operator==(const VariableAnchorOffsetCollection& other) const = default;
};
} // namespace mln