Make StaticRTree and facades const

This commit is contained in:
Patrick Niklaus
2016-05-07 02:56:08 +02:00
parent ddd128ce0e
commit 7174c5d036
6 changed files with 62 additions and 62 deletions
+11 -11
View File
@@ -90,47 +90,47 @@ class BaseDataFacade
virtual extractor::TravelMode GetTravelModeForEdgeID(const unsigned id) const = 0;
virtual std::vector<RTreeLeaf> GetEdgesInBox(const util::Coordinate south_west,
const util::Coordinate north_east) = 0;
const util::Coordinate north_east) const = 0;
virtual std::vector<PhantomNodeWithDistance>
NearestPhantomNodesInRange(const util::Coordinate input_coordinate,
const float max_distance,
const int bearing,
const int bearing_range) = 0;
const int bearing_range) const = 0;
virtual std::vector<PhantomNodeWithDistance>
NearestPhantomNodesInRange(const util::Coordinate input_coordinate,
const float max_distance) = 0;
const float max_distance) const = 0;
virtual std::vector<PhantomNodeWithDistance>
NearestPhantomNodes(const util::Coordinate input_coordinate,
const unsigned max_results,
const double max_distance,
const int bearing,
const int bearing_range) = 0;
const int bearing_range) const = 0;
virtual std::vector<PhantomNodeWithDistance>
NearestPhantomNodes(const util::Coordinate input_coordinate,
const unsigned max_results,
const int bearing,
const int bearing_range) = 0;
const int bearing_range) const = 0;
virtual std::vector<PhantomNodeWithDistance>
NearestPhantomNodes(const util::Coordinate input_coordinate, const unsigned max_results) = 0;
NearestPhantomNodes(const util::Coordinate input_coordinate, const unsigned max_results) const = 0;
virtual std::vector<PhantomNodeWithDistance>
NearestPhantomNodes(const util::Coordinate input_coordinate,
const unsigned max_results,
const double max_distance) = 0;
const double max_distance) const = 0;
virtual std::pair<PhantomNode, PhantomNode>
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate) = 0;
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate) const = 0;
virtual std::pair<PhantomNode, PhantomNode>
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
const double max_distance) = 0;
const double max_distance) const = 0;
virtual std::pair<PhantomNode, PhantomNode>
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
const double max_distance,
const int bearing,
const int bearing_range) = 0;
const int bearing_range) const = 0;
virtual std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
const util::Coordinate input_coordinate, const int bearing, const int bearing_range) = 0;
const util::Coordinate input_coordinate, const int bearing, const int bearing_range) const = 0;
virtual unsigned GetCheckSum() const = 0;
@@ -379,7 +379,7 @@ class InternalDataFacade final : public BaseDataFacade
}
std::vector<RTreeLeaf> GetEdgesInBox(const util::Coordinate south_west,
const util::Coordinate north_east) override final
const util::Coordinate north_east) const override final
{
BOOST_ASSERT(m_geospatial_query.get());
const util::RectangleInt2D bbox{south_west.lon, north_east.lon, south_west.lat,
@@ -389,7 +389,7 @@ class InternalDataFacade final : public BaseDataFacade
std::vector<PhantomNodeWithDistance>
NearestPhantomNodesInRange(const util::Coordinate input_coordinate,
const float max_distance) override final
const float max_distance) const override final
{
BOOST_ASSERT(m_geospatial_query.get());
@@ -400,7 +400,7 @@ class InternalDataFacade final : public BaseDataFacade
NearestPhantomNodesInRange(const util::Coordinate input_coordinate,
const float max_distance,
const int bearing,
const int bearing_range) override final
const int bearing_range) const override final
{
BOOST_ASSERT(m_geospatial_query.get());
@@ -410,7 +410,7 @@ class InternalDataFacade final : public BaseDataFacade
std::vector<PhantomNodeWithDistance>
NearestPhantomNodes(const util::Coordinate input_coordinate,
const unsigned max_results) override final
const unsigned max_results) const override final
{
BOOST_ASSERT(m_geospatial_query.get());
@@ -420,7 +420,7 @@ class InternalDataFacade final : public BaseDataFacade
std::vector<PhantomNodeWithDistance>
NearestPhantomNodes(const util::Coordinate input_coordinate,
const unsigned max_results,
const double max_distance) override final
const double max_distance) const override final
{
BOOST_ASSERT(m_geospatial_query.get());
@@ -431,7 +431,7 @@ class InternalDataFacade final : public BaseDataFacade
NearestPhantomNodes(const util::Coordinate input_coordinate,
const unsigned max_results,
const int bearing,
const int bearing_range) override final
const int bearing_range) const override final
{
BOOST_ASSERT(m_geospatial_query.get());
@@ -444,7 +444,7 @@ class InternalDataFacade final : public BaseDataFacade
const unsigned max_results,
const double max_distance,
const int bearing,
const int bearing_range) override final
const int bearing_range) const override final
{
BOOST_ASSERT(m_geospatial_query.get());
@@ -454,7 +454,7 @@ class InternalDataFacade final : public BaseDataFacade
std::pair<PhantomNode, PhantomNode>
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
const double max_distance) override final
const double max_distance) const override final
{
BOOST_ASSERT(m_geospatial_query.get());
@@ -463,7 +463,7 @@ class InternalDataFacade final : public BaseDataFacade
}
std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
const util::Coordinate input_coordinate) override final
const util::Coordinate input_coordinate) const override final
{
BOOST_ASSERT(m_geospatial_query.get());
@@ -475,7 +475,7 @@ class InternalDataFacade final : public BaseDataFacade
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
const double max_distance,
const int bearing,
const int bearing_range) override final
const int bearing_range) const override final
{
BOOST_ASSERT(m_geospatial_query.get());
@@ -486,7 +486,7 @@ class InternalDataFacade final : public BaseDataFacade
std::pair<PhantomNode, PhantomNode>
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
const int bearing,
const int bearing_range) override final
const int bearing_range) const override final
{
BOOST_ASSERT(m_geospatial_query.get());
+11 -11
View File
@@ -459,7 +459,7 @@ class SharedDataFacade final : public BaseDataFacade
}
std::vector<RTreeLeaf> GetEdgesInBox(const util::Coordinate south_west,
const util::Coordinate north_east) override final
const util::Coordinate north_east) const override final
{
BOOST_ASSERT(m_geospatial_query.get());
const util::RectangleInt2D bbox{south_west.lon, north_east.lon, south_west.lat,
@@ -469,7 +469,7 @@ class SharedDataFacade final : public BaseDataFacade
std::vector<PhantomNodeWithDistance>
NearestPhantomNodesInRange(const util::Coordinate input_coordinate,
const float max_distance) override final
const float max_distance) const override final
{
BOOST_ASSERT(m_geospatial_query.get());
@@ -480,7 +480,7 @@ class SharedDataFacade final : public BaseDataFacade
NearestPhantomNodesInRange(const util::Coordinate input_coordinate,
const float max_distance,
const int bearing,
const int bearing_range) override final
const int bearing_range) const override final
{
BOOST_ASSERT(m_geospatial_query.get());
@@ -490,7 +490,7 @@ class SharedDataFacade final : public BaseDataFacade
std::vector<PhantomNodeWithDistance>
NearestPhantomNodes(const util::Coordinate input_coordinate,
const unsigned max_results) override final
const unsigned max_results) const override final
{
BOOST_ASSERT(m_geospatial_query.get());
@@ -500,7 +500,7 @@ class SharedDataFacade final : public BaseDataFacade
std::vector<PhantomNodeWithDistance>
NearestPhantomNodes(const util::Coordinate input_coordinate,
const unsigned max_results,
const double max_distance) override final
const double max_distance) const override final
{
BOOST_ASSERT(m_geospatial_query.get());
@@ -511,7 +511,7 @@ class SharedDataFacade final : public BaseDataFacade
NearestPhantomNodes(const util::Coordinate input_coordinate,
const unsigned max_results,
const int bearing,
const int bearing_range) override final
const int bearing_range) const override final
{
BOOST_ASSERT(m_geospatial_query.get());
@@ -524,7 +524,7 @@ class SharedDataFacade final : public BaseDataFacade
const unsigned max_results,
const double max_distance,
const int bearing,
const int bearing_range) override final
const int bearing_range) const override final
{
BOOST_ASSERT(m_geospatial_query.get());
@@ -533,7 +533,7 @@ class SharedDataFacade final : public BaseDataFacade
}
std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
const util::Coordinate input_coordinate) override final
const util::Coordinate input_coordinate) const override final
{
BOOST_ASSERT(m_geospatial_query.get());
@@ -543,7 +543,7 @@ class SharedDataFacade final : public BaseDataFacade
std::pair<PhantomNode, PhantomNode>
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
const double max_distance) override final
const double max_distance) const override final
{
BOOST_ASSERT(m_geospatial_query.get());
@@ -555,7 +555,7 @@ class SharedDataFacade final : public BaseDataFacade
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
const double max_distance,
const int bearing,
const int bearing_range) override final
const int bearing_range) const override final
{
BOOST_ASSERT(m_geospatial_query.get());
@@ -566,7 +566,7 @@ class SharedDataFacade final : public BaseDataFacade
std::pair<PhantomNode, PhantomNode>
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
const int bearing,
const int bearing_range) override final
const int bearing_range) const override final
{
BOOST_ASSERT(m_geospatial_query.get());
+13 -13
View File
@@ -45,7 +45,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
// Returns nearest PhantomNodes in the given bearing range within max_distance.
// Does not filter by small/big component!
std::vector<PhantomNodeWithDistance>
NearestPhantomNodesInRange(const util::Coordinate input_coordinate, const double max_distance)
NearestPhantomNodesInRange(const util::Coordinate input_coordinate, const double max_distance) const
{
auto results =
rtree.Nearest(input_coordinate,
@@ -68,7 +68,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
NearestPhantomNodesInRange(const util::Coordinate input_coordinate,
const double max_distance,
const int bearing,
const int bearing_range)
const int bearing_range) const
{
auto results = rtree.Nearest(
input_coordinate,
@@ -91,7 +91,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
NearestPhantomNodes(const util::Coordinate input_coordinate,
const unsigned max_results,
const int bearing,
const int bearing_range)
const int bearing_range) const
{
auto results =
rtree.Nearest(input_coordinate,
@@ -115,7 +115,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
const unsigned max_results,
const double max_distance,
const int bearing,
const int bearing_range)
const int bearing_range) const
{
auto results =
rtree.Nearest(input_coordinate,
@@ -136,7 +136,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
// Returns max_results nearest PhantomNodes.
// Does not filter by small/big component!
std::vector<PhantomNodeWithDistance>
NearestPhantomNodes(const util::Coordinate input_coordinate, const unsigned max_results)
NearestPhantomNodes(const util::Coordinate input_coordinate, const unsigned max_results) const
{
auto results =
rtree.Nearest(input_coordinate,
@@ -157,7 +157,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
std::vector<PhantomNodeWithDistance>
NearestPhantomNodes(const util::Coordinate input_coordinate,
const unsigned max_results,
const double max_distance)
const double max_distance) const
{
auto results =
rtree.Nearest(input_coordinate,
@@ -179,7 +179,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
// a second phantom node is return that is the nearest coordinate in a big component.
std::pair<PhantomNode, PhantomNode>
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
const double max_distance)
const double max_distance) const
{
bool has_small_component = false;
bool has_big_component = false;
@@ -216,7 +216,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
// Returns the nearest phantom node. If this phantom node is not from a big component
// a second phantom node is return that is the nearest coordinate in a big component.
std::pair<PhantomNode, PhantomNode>
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate)
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate) const
{
bool has_small_component = false;
bool has_big_component = false;
@@ -251,7 +251,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
// Returns the nearest phantom node. If this phantom node is not from a big component
// a second phantom node is return that is the nearest coordinate in a big component.
std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
const util::Coordinate input_coordinate, const int bearing, const int bearing_range)
const util::Coordinate input_coordinate, const int bearing, const int bearing_range) const
{
bool has_small_component = false;
bool has_big_component = false;
@@ -297,7 +297,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
const double max_distance,
const int bearing,
const int bearing_range)
const int bearing_range) const
{
bool has_small_component = false;
bool has_big_component = false;
@@ -418,7 +418,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
bool CheckSegmentDistance(const Coordinate input_coordinate,
const CandidateSegment &segment,
const double max_distance)
const double max_distance) const
{
BOOST_ASSERT(segment.data.forward_segment_id.id != SPECIAL_SEGMENTID ||
!segment.data.forward_segment_id.enabled);
@@ -434,7 +434,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
std::pair<bool, bool> CheckSegmentBearing(const CandidateSegment &segment,
const int filter_bearing,
const int filter_bearing_range)
const int filter_bearing_range) const
{
BOOST_ASSERT(segment.data.forward_segment_id.id != SPECIAL_SEGMENTID ||
!segment.data.forward_segment_id.enabled);
@@ -459,7 +459,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
return std::make_pair(forward_bearing_valid, backward_bearing_valid);
}
RTreeT &rtree;
const RTreeT &rtree;
const CoordinateList &coordinates;
DataFacadeT &datafacade;
};
+5 -5
View File
@@ -326,7 +326,7 @@ class StaticRTree
/* Returns all features inside the bounding box.
Rectangle needs to be projected!*/
std::vector<EdgeDataT> SearchInBox(const Rectangle &search_rectangle)
std::vector<EdgeDataT> SearchInBox(const Rectangle &search_rectangle) const
{
const Rectangle projected_rectangle{
search_rectangle.min_lon, search_rectangle.max_lon,
@@ -392,7 +392,7 @@ class StaticRTree
}
// Override filter and terminator for the desired behaviour.
std::vector<EdgeDataT> Nearest(const Coordinate input_coordinate, const std::size_t max_results)
std::vector<EdgeDataT> Nearest(const Coordinate input_coordinate, const std::size_t max_results) const
{
return Nearest(input_coordinate,
[](const CandidateSegment &)
@@ -408,7 +408,7 @@ class StaticRTree
// Override filter and terminator for the desired behaviour.
template <typename FilterT, typename TerminationT>
std::vector<EdgeDataT>
Nearest(const Coordinate input_coordinate, const FilterT filter, const TerminationT terminate)
Nearest(const Coordinate input_coordinate, const FilterT filter, const TerminationT terminate) const
{
std::vector<EdgeDataT> results;
auto projected_coordinate = web_mercator::fromWGS84(input_coordinate);
@@ -473,7 +473,7 @@ class StaticRTree
void ExploreLeafNode(const std::uint32_t leaf_id,
const Coordinate projected_input_coordinate_fixed,
const FloatCoordinate &projected_input_coordinate,
QueueT &traversal_queue)
QueueT &traversal_queue) const
{
const LeafNode& current_leaf_node = m_leaves[leaf_id];
@@ -500,7 +500,7 @@ class StaticRTree
template <class QueueT>
void ExploreTreeNode(const TreeNode &parent,
const Coordinate fixed_projected_input_coordinate,
QueueT &traversal_queue)
QueueT &traversal_queue) const
{
for (std::uint32_t i = 0; i < parent.child_count; ++i)
{