diff --git a/DataStructures/RestrictionMap.cpp b/DataStructures/RestrictionMap.cpp index d825759ac..3bbc5f380 100644 --- a/DataStructures/RestrictionMap.cpp +++ b/DataStructures/RestrictionMap.cpp @@ -30,7 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../Util/SimpleLogger.h" -bool RestrictionMap::IsNodeAViaNode(const NodeID node) const +bool RestrictionMap::IsViaNode(const NodeID node) const { return m_no_turn_via_node_set.find(node) != m_no_turn_via_node_set.end(); } @@ -86,7 +86,7 @@ void RestrictionMap::FixupArrivingTurnRestriction(const NodeID node_u, BOOST_ASSERT(node_v != SPECIAL_NODEID); BOOST_ASSERT(node_w != SPECIAL_NODEID); - if (!RestrictionStartsAtNode(node_u)) + if (!IsViaNode(node_u)) { return; } @@ -106,7 +106,7 @@ void RestrictionMap::FixupArrivingTurnRestriction(const NodeID node_u, for (const NodeID node_x : predecessors) { - auto restriction_iterator = m_restriction_map.find({node_x, node_u}); + const auto restriction_iterator = m_restriction_map.find({node_x, node_u}); if (restriction_iterator == m_restriction_map.end()) { continue; @@ -133,7 +133,7 @@ void RestrictionMap::FixupStartingTurnRestriction(const NodeID node_u, BOOST_ASSERT(node_v != SPECIAL_NODEID); BOOST_ASSERT(node_w != SPECIAL_NODEID); - if (!RestrictionStartsAtNode(node_u)) + if (!IsSourceNode(node_v)) { return; } @@ -144,8 +144,8 @@ void RestrictionMap::FixupStartingTurnRestriction(const NodeID node_u, const unsigned index = restriction_iterator->second; // remove old restriction start (v,w) m_restriction_map.erase(restriction_iterator); - - // insert new restriction start (u,w) (point to index) + m_restriction_start_nodes.emplace(node_u); + // insert new restriction start (u,w) (pointing to index) RestrictionSource new_source = {node_u, node_w}; m_restriction_map.emplace(new_source, index); } @@ -159,7 +159,7 @@ NodeID RestrictionMap::CheckForEmanatingIsOnlyTurn(const NodeID node_u, BOOST_ASSERT(node_u != SPECIAL_NODEID); BOOST_ASSERT(node_v != SPECIAL_NODEID); - if (!RestrictionStartsAtNode(node_u)) + if (!IsSourceNode(node_u)) { return SPECIAL_NODEID; } @@ -185,11 +185,13 @@ bool RestrictionMap::CheckIfTurnIsRestricted(const NodeID node_u, const NodeID node_v, const NodeID node_w) const { + // return false; + BOOST_ASSERT(node_u != SPECIAL_NODEID); BOOST_ASSERT(node_v != SPECIAL_NODEID); BOOST_ASSERT(node_w != SPECIAL_NODEID); - if (!RestrictionStartsAtNode(node_u)) + if (!IsSourceNode(node_u)) { return false; } @@ -212,7 +214,7 @@ bool RestrictionMap::CheckIfTurnIsRestricted(const NodeID node_u, } // check of node is the start of any restriction -bool RestrictionMap::RestrictionStartsAtNode(const NodeID node) const +bool RestrictionMap::IsSourceNode(const NodeID node) const { if (m_restriction_start_nodes.find(node) == m_restriction_start_nodes.end()) { diff --git a/DataStructures/RestrictionMap.h b/DataStructures/RestrictionMap.h index 7406daef2..a962a0702 100644 --- a/DataStructures/RestrictionMap.h +++ b/DataStructures/RestrictionMap.h @@ -51,11 +51,11 @@ class RestrictionMap void FixupStartingTurnRestriction(const NodeID u, const NodeID v, const NodeID w); NodeID CheckForEmanatingIsOnlyTurn(const NodeID u, const NodeID v) const; bool CheckIfTurnIsRestricted(const NodeID u, const NodeID v, const NodeID w) const; - bool IsNodeAViaNode(const NodeID node) const; + bool IsViaNode(const NodeID node) const; unsigned size() { return m_count; } private: - bool RestrictionStartsAtNode(const NodeID node) const; + bool IsSourceNode(const NodeID node) const; typedef std::pair RestrictionSource; typedef std::pair RestrictionTarget; typedef std::vector EmanatingRestrictionsVector; diff --git a/DataStructures/StaticRTree.h b/DataStructures/StaticRTree.h index 33e4c09a7..c1cad7fdb 100644 --- a/DataStructures/StaticRTree.h +++ b/DataStructures/StaticRTree.h @@ -46,8 +46,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include - #include +#include #include #include @@ -257,6 +257,27 @@ class StaticRTree } }; + template + struct IncrementalQueryCandidate + { + explicit IncrementalQueryCandidate(const float dist, const uint32_t n_id) + : min_dist(dist), node_id(n_id) + { + } + IncrementalQueryCandidate() : min_dist(std::numeric_limits::max()), node_id(UINT_MAX) {} + float min_dist; + uint32_t node_id; + inline bool operator<(const IncrementalQueryCandidate &other) const + { + // Attn: this is reversed order. std::pq is a max pq! + return other.min_dist < min_dist; + } + + boost::variant NodeWrapper; + }; + + + typename ShM::vector m_search_tree; uint64_t m_element_count; const std::string m_leaf_node_filename; @@ -580,6 +601,18 @@ class StaticRTree return result_coordinate.isValid(); } + // implementation of the Hjaltason/Samet query [3] + bool IncrementalFindPhantomNodeForCoordinate(const FixedPointCoordinate &input_coordinate, + PhantomNode &result_phantom_node, + const unsigned zoom_level) + { + bool found_result = false; + + + // BOOST_ASSERT(found_result); + return found_result; + } + bool FindPhantomNodeForCoordinate(const FixedPointCoordinate &input_coordinate, PhantomNode &result_phantom_node, const unsigned zoom_level) @@ -753,5 +786,5 @@ class StaticRTree //[1] "On Packing R-Trees"; I. Kamel, C. Faloutsos; 1993; DOI: 10.1145/170088.170403 //[2] "Nearest Neighbor Queries", N. Roussopulos et al; 1995; DOI: 10.1145/223784.223794 - +//[3] "Distance Browsing in Spatial Databases"; G. Hjaltason, H. Samet; 1999; ACM Trans. DB Sys Vol.24 No.2, pp.265-318 #endif // STATICRTREE_H