All good, but needs unpacking of start and end
This commit is contained in:
@@ -26,9 +26,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <osrm/Coordinate.h>
|
||||
#include "../Util/SimpleLogger.h"
|
||||
#include "../Util/StringUtil.h"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <bitset>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
|
||||
FixedPointCoordinate::FixedPointCoordinate()
|
||||
@@ -39,7 +43,16 @@ FixedPointCoordinate::FixedPointCoordinate()
|
||||
FixedPointCoordinate::FixedPointCoordinate(int lat, int lon)
|
||||
: lat(lat),
|
||||
lon(lon)
|
||||
{ }
|
||||
{
|
||||
if(0 != (lat >> 30)) {
|
||||
std::bitset<32> y(lat);
|
||||
SimpleLogger().Write(logDEBUG) << "broken lat: " << lat << ", bits: " << y;
|
||||
}
|
||||
if(0 != (lon >> 30)) {
|
||||
std::bitset<32> x(lon);
|
||||
SimpleLogger().Write(logDEBUG) << "broken lon: " << lon << ", bits: " << x;
|
||||
}
|
||||
}
|
||||
|
||||
void FixedPointCoordinate::Reset() {
|
||||
lat = std::numeric_limits<int>::min();
|
||||
@@ -159,3 +172,7 @@ void FixedPointCoordinate::convertInternalReversedCoordinateToString(
|
||||
convertInternalLatLonToString(coord.lon, tmp);
|
||||
output += tmp;
|
||||
}
|
||||
|
||||
void FixedPointCoordinate::Output(std::ostream & out) const {//, FixedPointCoordinate & c) {
|
||||
out << "(" << lat << "," << lon << ")";
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ struct EdgeBasedNode {
|
||||
name_id(std::numeric_limits<unsigned>::max()),
|
||||
forward_weight(std::numeric_limits<int>::max() >> 1),
|
||||
reverse_weight(std::numeric_limits<int>::max() >> 1),
|
||||
forward_offset_to_edge_based_node(0),
|
||||
reverse_offset_to_edge_based_node(0)
|
||||
forward_offset(0),
|
||||
reverse_offset(0)
|
||||
{ }
|
||||
|
||||
EdgeBasedNode(
|
||||
@@ -38,8 +38,8 @@ struct EdgeBasedNode {
|
||||
NodeID name_id,
|
||||
int forward_weight,
|
||||
int reverse_weight,
|
||||
int forward_offset_to_edge_based_node,
|
||||
int reverse_offset_to_edge_based_node
|
||||
int forward_offset,
|
||||
int reverse_offset
|
||||
) :
|
||||
forward_edge_based_node_id(forward_edge_based_node_id),
|
||||
reverse_edge_based_node_id(reverse_edge_based_node_id),
|
||||
@@ -51,8 +51,8 @@ struct EdgeBasedNode {
|
||||
name_id(name_id),
|
||||
forward_weight(forward_weight),
|
||||
reverse_weight(reverse_weight),
|
||||
forward_offset_to_edge_based_node(forward_offset_to_edge_based_node),
|
||||
reverse_offset_to_edge_based_node(reverse_offset_to_edge_based_node)
|
||||
forward_offset(forward_offset),
|
||||
reverse_offset(reverse_offset)
|
||||
{ }
|
||||
|
||||
// Computes:
|
||||
|
||||
@@ -33,11 +33,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
struct PhantomNode {
|
||||
PhantomNode() :
|
||||
forward_node_id(std::numeric_limits<unsigned>::max()),
|
||||
reverse_node_id(std::numeric_limits<unsigned>::max()),
|
||||
name_id(std::numeric_limits<unsigned>::max()),
|
||||
forward_weight(INT_MAX),
|
||||
reverse_weight(INT_MAX),
|
||||
forward_node_id( SPECIAL_NODEID ),
|
||||
reverse_node_id( SPECIAL_NODEID ),
|
||||
name_id( std::numeric_limits<unsigned>::max() ),
|
||||
forward_weight(INVALID_EDGE_WEIGHT),
|
||||
reverse_weight(INVALID_EDGE_WEIGHT),
|
||||
forward_offset(0),
|
||||
reverse_offset(0),
|
||||
ratio(0.)
|
||||
{ }
|
||||
|
||||
@@ -46,25 +48,44 @@ struct PhantomNode {
|
||||
unsigned name_id;
|
||||
int forward_weight;
|
||||
int reverse_weight;
|
||||
int forward_offset;
|
||||
int reverse_offset;
|
||||
double ratio;
|
||||
FixedPointCoordinate location;
|
||||
|
||||
int GetForwardWeightPlusOffset() const {
|
||||
return forward_weight + forward_offset;
|
||||
}
|
||||
|
||||
int GetReverseWeightPlusOffset() const {
|
||||
return reverse_weight + reverse_offset;
|
||||
}
|
||||
|
||||
void Reset() {
|
||||
forward_node_id = std::numeric_limits<unsigned>::max();
|
||||
name_id = std::numeric_limits<unsigned>::max();
|
||||
forward_weight = INT_MAX;
|
||||
reverse_weight = INT_MAX;
|
||||
forward_node_id = SPECIAL_NODEID;
|
||||
name_id = SPECIAL_NODEID;
|
||||
forward_weight = INVALID_EDGE_WEIGHT;
|
||||
reverse_weight = INVALID_EDGE_WEIGHT;
|
||||
forward_offset = 0;
|
||||
reverse_offset = 0;
|
||||
ratio = 0.;
|
||||
location.Reset();
|
||||
}
|
||||
|
||||
bool isBidirected() const {
|
||||
return forward_node_id != UINT_MAX && reverse_node_id != UINT_MAX;
|
||||
return ( forward_node_id != SPECIAL_NODEID ) &&
|
||||
( reverse_node_id != SPECIAL_NODEID );
|
||||
}
|
||||
|
||||
bool IsCompressed() const {
|
||||
return (forward_offset != 0) || (reverse_offset != 0);
|
||||
}
|
||||
|
||||
bool isValid(const unsigned numberOfNodes) const {
|
||||
return
|
||||
location.isValid() &&
|
||||
( (forward_node_id < numberOfNodes) || (reverse_node_id < numberOfNodes) ) &&
|
||||
( (forward_weight != INT_MAX) || (reverse_weight != INT_MAX) ) &&
|
||||
( (forward_weight != INVALID_EDGE_WEIGHT) || (reverse_weight != INVALID_EDGE_WEIGHT) ) &&
|
||||
(ratio >= 0.) &&
|
||||
(ratio <= 1.) &&
|
||||
(name_id != std::numeric_limits<unsigned>::max());
|
||||
@@ -88,7 +109,7 @@ struct PhantomNodes {
|
||||
}
|
||||
|
||||
bool AtLeastOnePhantomNodeIsUINTMAX() const {
|
||||
return !(startPhantom.forward_node_id == std::numeric_limits<unsigned>::max() || targetPhantom.forward_node_id == std::numeric_limits<unsigned>::max());
|
||||
return !(startPhantom.forward_node_id == SPECIAL_NODEID || targetPhantom.forward_node_id == SPECIAL_NODEID);
|
||||
}
|
||||
|
||||
bool PhantomNodesHaveEqualLocation() const {
|
||||
|
||||
@@ -115,6 +115,8 @@ public:
|
||||
|
||||
std::size_t size() const { return m_size; }
|
||||
|
||||
bool empty() const { return 0 == size(); }
|
||||
|
||||
DataT & operator[](const unsigned index) {
|
||||
BOOST_ASSERT_MSG(index < m_size, "invalid size");
|
||||
return m_ptr[index];
|
||||
|
||||
@@ -115,6 +115,7 @@ public:
|
||||
u << "," << data.id << "," << v << ")";
|
||||
|
||||
data.shortcut = false;
|
||||
BOOST_ASSERT(false);
|
||||
}
|
||||
eid2 = FindEdgeInEitherDirection(data.id, v);
|
||||
if(eid2 == UINT_MAX) {
|
||||
@@ -122,6 +123,7 @@ public:
|
||||
"cannot find second segment of edge (" <<
|
||||
u << "," << data.id << "," << v << ")";
|
||||
data.shortcut = false;
|
||||
BOOST_ASSERT(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -165,7 +167,7 @@ public:
|
||||
//searches for a specific edge
|
||||
EdgeIterator FindEdge( const NodeIterator from, const NodeIterator to ) const {
|
||||
EdgeIterator smallestEdge = SPECIAL_EDGEID;
|
||||
EdgeWeight smallestWeight = UINT_MAX;
|
||||
EdgeWeight smallestWeight = INVALID_EDGE_WEIGHT;
|
||||
for ( EdgeIterator edge = BeginEdges( from ); edge < EndEdges(from); edge++ ) {
|
||||
const NodeID target = GetTarget(edge);
|
||||
const EdgeWeight weight = GetEdgeData(edge).distance;
|
||||
|
||||
@@ -51,6 +51,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <boost/algorithm/minmax_element.hpp>
|
||||
#include <boost/range/algorithm_ext/erase.hpp>
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/type_traits.hpp>
|
||||
|
||||
@@ -68,7 +69,7 @@ const static uint32_t RTREE_LEAF_NODE_SIZE = 1170;
|
||||
|
||||
static boost::thread_specific_ptr<boost::filesystem::ifstream> thread_local_rtree_stream;
|
||||
|
||||
template<class DataT, bool UseSharedMemory = false>
|
||||
template<class DataT, class CoordinateListT = std::vector<FixedPointCoordinate>, bool UseSharedMemory = false>
|
||||
class StaticRTree : boost::noncopyable {
|
||||
public:
|
||||
struct RectangleInt2D {
|
||||
@@ -289,8 +290,9 @@ private:
|
||||
|
||||
typename ShM<TreeNode, UseSharedMemory>::vector m_search_tree;
|
||||
uint64_t m_element_count;
|
||||
|
||||
const std::string m_leaf_node_filename;
|
||||
boost::shared_ptr<CoordinateListT> m_coordinate_list;
|
||||
|
||||
public:
|
||||
//Construct a packed Hilbert-R-Tree with Kamel-Faloutsos algorithm [1]
|
||||
explicit StaticRTree(
|
||||
@@ -426,9 +428,11 @@ public:
|
||||
//Read-only operation for queries
|
||||
explicit StaticRTree(
|
||||
const boost::filesystem::path & node_file,
|
||||
const boost::filesystem::path & leaf_file
|
||||
) : m_leaf_node_filename(leaf_file.string()) {
|
||||
const boost::filesystem::path & leaf_file,
|
||||
const boost::shared_ptr<CoordinateListT> coordinate_list
|
||||
) : m_leaf_node_filename( leaf_file.string() ) {
|
||||
//open tree node file and load into RAM.
|
||||
m_coordinate_list = coordinate_list;
|
||||
|
||||
if ( !boost::filesystem::exists( node_file ) ) {
|
||||
throw OSRMException("ram index file does not exist");
|
||||
@@ -463,9 +467,11 @@ public:
|
||||
explicit StaticRTree(
|
||||
TreeNode * tree_node_ptr,
|
||||
const uint32_t number_of_nodes,
|
||||
const boost::filesystem::path & leaf_file
|
||||
const boost::filesystem::path & leaf_file,
|
||||
boost::shared_ptr<CoordinateListT> coordinate_list
|
||||
) : m_search_tree(tree_node_ptr, number_of_nodes),
|
||||
m_leaf_node_filename(leaf_file.string())
|
||||
m_leaf_node_filename(leaf_file.string()),
|
||||
m_coordinate_list(coordinate_list)
|
||||
{
|
||||
//open leaf node file and store thread specific pointer
|
||||
if ( !boost::filesystem::exists( leaf_file ) ) {
|
||||
@@ -659,6 +665,8 @@ public:
|
||||
result_phantom_node.name_id = current_edge.name_id;
|
||||
result_phantom_node.forward_weight = current_edge.forward_weight;
|
||||
result_phantom_node.reverse_weight = current_edge.reverse_weight;
|
||||
result_phantom_node.forward_offset = current_edge.forward_offset;
|
||||
result_phantom_node.reverse_offset = current_edge.reverse_offset;
|
||||
result_phantom_node.location = nearest;
|
||||
current_start_coordinate.lat = current_edge.lat1;
|
||||
current_start_coordinate.lon = current_edge.lon1;
|
||||
|
||||
Reference in New Issue
Block a user