mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-06 12:34:24 +00:00
Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run: git remote add om-historic [om-historic.git repo url] git fetch --tags om-historic git replace squashed-history historic-commits
This commit is contained in:
68
routing/road_point.hpp
Normal file
68
routing/road_point.hpp
Normal file
@@ -0,0 +1,68 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "std/boost_container_hash.hpp"
|
||||
|
||||
namespace routing
|
||||
{
|
||||
// RoadPoint is a unique identifier for any road point in mwm file.
|
||||
//
|
||||
// Contains feature id and point id.
|
||||
// Point id is the ordinal number of the point in the road.
|
||||
class RoadPoint final
|
||||
{
|
||||
public:
|
||||
RoadPoint() : m_featureId(0), m_pointId(0) {}
|
||||
|
||||
RoadPoint(uint32_t featureId, uint32_t pointId) : m_featureId(featureId), m_pointId(pointId) {}
|
||||
|
||||
uint32_t GetFeatureId() const { return m_featureId; }
|
||||
|
||||
uint32_t GetPointId() const { return m_pointId; }
|
||||
|
||||
bool operator<(RoadPoint const & rp) const
|
||||
{
|
||||
if (m_featureId != rp.m_featureId)
|
||||
return m_featureId < rp.m_featureId;
|
||||
return m_pointId < rp.m_pointId;
|
||||
}
|
||||
|
||||
bool operator==(RoadPoint const & rp) const
|
||||
{
|
||||
return m_featureId == rp.m_featureId && m_pointId == rp.m_pointId;
|
||||
}
|
||||
|
||||
bool operator!=(RoadPoint const & rp) const
|
||||
{
|
||||
return !(*this == rp);
|
||||
}
|
||||
|
||||
struct Hash
|
||||
{
|
||||
size_t operator()(RoadPoint const & roadPoint) const
|
||||
{
|
||||
size_t seed = 0;
|
||||
boost::hash_combine(seed, roadPoint.m_featureId);
|
||||
boost::hash_combine(seed, roadPoint.m_pointId);
|
||||
return seed;
|
||||
}
|
||||
};
|
||||
|
||||
void SetPointId(uint32_t pointId) { m_pointId = pointId; }
|
||||
|
||||
private:
|
||||
uint32_t m_featureId;
|
||||
uint32_t m_pointId;
|
||||
};
|
||||
|
||||
inline std::string DebugPrint(RoadPoint const & rp)
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << "RoadPoint{" << rp.GetFeatureId() << ", " << rp.GetPointId() << "}";
|
||||
return out.str();
|
||||
}
|
||||
} // namespace routing
|
||||
Reference in New Issue
Block a user