Recreate feature/expose_node_ids
This commit is contained in:
parent
448f8377fb
commit
a4ac07866a
@ -198,6 +198,7 @@ class RouteAPI : public BaseAPI
|
|||||||
{
|
{
|
||||||
util::json::Array durations;
|
util::json::Array durations;
|
||||||
util::json::Array distances;
|
util::json::Array distances;
|
||||||
|
util::json::Array nodes;
|
||||||
auto &leg_geometry = leg_geometries[idx];
|
auto &leg_geometry = leg_geometries[idx];
|
||||||
std::for_each(
|
std::for_each(
|
||||||
leg_geometry.annotations.begin(),
|
leg_geometry.annotations.begin(),
|
||||||
@ -206,9 +207,16 @@ class RouteAPI : public BaseAPI
|
|||||||
durations.values.push_back(step.duration);
|
durations.values.push_back(step.duration);
|
||||||
distances.values.push_back(step.distance);
|
distances.values.push_back(step.distance);
|
||||||
});
|
});
|
||||||
|
std::for_each(
|
||||||
|
leg_geometry.osm_node_ids.begin(),
|
||||||
|
leg_geometry.osm_node_ids.end(),
|
||||||
|
[this, &nodes](const OSMNodeID &node_id) {
|
||||||
|
nodes.values.push_back(static_cast<std::uint64_t>(node_id));
|
||||||
|
});
|
||||||
util::json::Object annotation;
|
util::json::Object annotation;
|
||||||
annotation.values["distance"] = std::move(distances);
|
annotation.values["distance"] = std::move(distances);
|
||||||
annotation.values["duration"] = std::move(durations);
|
annotation.values["duration"] = std::move(durations);
|
||||||
|
annotation.values["nodes"] = std::move(nodes);
|
||||||
annotations.push_back(std::move(annotation));
|
annotations.push_back(std::move(annotation));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,7 @@ class BaseDataFacade
|
|||||||
|
|
||||||
// node and edge information access
|
// node and edge information access
|
||||||
virtual util::Coordinate GetCoordinateOfNode(const unsigned id) const = 0;
|
virtual util::Coordinate GetCoordinateOfNode(const unsigned id) const = 0;
|
||||||
|
virtual OSMNodeID GetOSMNodeIDOfNode(const unsigned id) const = 0;
|
||||||
|
|
||||||
virtual unsigned GetGeometryIndexForEdgeID(const unsigned id) const = 0;
|
virtual unsigned GetGeometryIndexForEdgeID(const unsigned id) const = 0;
|
||||||
|
|
||||||
|
@ -73,6 +73,7 @@ class InternalDataFacade final : public BaseDataFacade
|
|||||||
std::string m_timestamp;
|
std::string m_timestamp;
|
||||||
|
|
||||||
util::ShM<util::Coordinate, false>::vector m_coordinate_list;
|
util::ShM<util::Coordinate, false>::vector m_coordinate_list;
|
||||||
|
util::ShM<OSMNodeID, false>::vector m_osmnodeid_list;
|
||||||
util::ShM<NodeID, false>::vector m_via_node_list;
|
util::ShM<NodeID, false>::vector m_via_node_list;
|
||||||
util::ShM<unsigned, false>::vector m_name_ID_list;
|
util::ShM<unsigned, false>::vector m_name_ID_list;
|
||||||
util::ShM<extractor::guidance::TurnInstruction, false>::vector m_turn_instruction_list;
|
util::ShM<extractor::guidance::TurnInstruction, false>::vector m_turn_instruction_list;
|
||||||
@ -156,10 +157,12 @@ class InternalDataFacade final : public BaseDataFacade
|
|||||||
unsigned number_of_coordinates = 0;
|
unsigned number_of_coordinates = 0;
|
||||||
nodes_input_stream.read((char *)&number_of_coordinates, sizeof(unsigned));
|
nodes_input_stream.read((char *)&number_of_coordinates, sizeof(unsigned));
|
||||||
m_coordinate_list.resize(number_of_coordinates);
|
m_coordinate_list.resize(number_of_coordinates);
|
||||||
|
m_osmnodeid_list.resize(number_of_coordinates);
|
||||||
for (unsigned i = 0; i < number_of_coordinates; ++i)
|
for (unsigned i = 0; i < number_of_coordinates; ++i)
|
||||||
{
|
{
|
||||||
nodes_input_stream.read((char *)¤t_node, sizeof(extractor::QueryNode));
|
nodes_input_stream.read((char *)¤t_node, sizeof(extractor::QueryNode));
|
||||||
m_coordinate_list[i] = util::Coordinate(current_node.lon, current_node.lat);
|
m_coordinate_list[i] = util::Coordinate(current_node.lon, current_node.lat);
|
||||||
|
m_osmnodeid_list[i] = current_node.node_id;
|
||||||
BOOST_ASSERT(m_coordinate_list[i].IsValid());
|
BOOST_ASSERT(m_coordinate_list[i].IsValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,6 +441,11 @@ class InternalDataFacade final : public BaseDataFacade
|
|||||||
return m_coordinate_list[id];
|
return m_coordinate_list[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OSMNodeID GetOSMNodeIDOfNode(const unsigned id) const override final
|
||||||
|
{
|
||||||
|
return m_osmnodeid_list[id];
|
||||||
|
}
|
||||||
|
|
||||||
extractor::guidance::TurnInstruction
|
extractor::guidance::TurnInstruction
|
||||||
GetTurnInstructionForEdgeID(const unsigned id) const override final
|
GetTurnInstructionForEdgeID(const unsigned id) const override final
|
||||||
{
|
{
|
||||||
|
@ -76,6 +76,7 @@ class SharedDataFacade final : public BaseDataFacade
|
|||||||
extractor::ProfileProperties *m_profile_properties;
|
extractor::ProfileProperties *m_profile_properties;
|
||||||
|
|
||||||
util::ShM<util::Coordinate, true>::vector m_coordinate_list;
|
util::ShM<util::Coordinate, true>::vector m_coordinate_list;
|
||||||
|
util::ShM<OSMNodeID, true>::vector m_osmnodeid_list;
|
||||||
util::ShM<NodeID, true>::vector m_via_node_list;
|
util::ShM<NodeID, true>::vector m_via_node_list;
|
||||||
util::ShM<unsigned, true>::vector m_name_ID_list;
|
util::ShM<unsigned, true>::vector m_name_ID_list;
|
||||||
util::ShM<extractor::guidance::TurnInstruction, true>::vector m_turn_instruction_list;
|
util::ShM<extractor::guidance::TurnInstruction, true>::vector m_turn_instruction_list;
|
||||||
@ -170,6 +171,11 @@ class SharedDataFacade final : public BaseDataFacade
|
|||||||
coordinate_list_ptr,
|
coordinate_list_ptr,
|
||||||
data_layout->num_entries[storage::SharedDataLayout::COORDINATE_LIST]);
|
data_layout->num_entries[storage::SharedDataLayout::COORDINATE_LIST]);
|
||||||
|
|
||||||
|
auto osmnodeid_list_ptr = data_layout->GetBlockPtr<OSMNodeID>(
|
||||||
|
shared_memory, storage::SharedDataLayout::OSM_NODE_ID_LIST);
|
||||||
|
m_osmnodeid_list.reset(osmnodeid_list_ptr,
|
||||||
|
data_layout->num_entries[storage::SharedDataLayout::OSM_NODE_ID_LIST]);
|
||||||
|
|
||||||
auto travel_mode_list_ptr = data_layout->GetBlockPtr<extractor::TravelMode>(
|
auto travel_mode_list_ptr = data_layout->GetBlockPtr<extractor::TravelMode>(
|
||||||
shared_memory, storage::SharedDataLayout::TRAVEL_MODE);
|
shared_memory, storage::SharedDataLayout::TRAVEL_MODE);
|
||||||
util::ShM<extractor::TravelMode, true>::vector travel_mode_list(
|
util::ShM<extractor::TravelMode, true>::vector travel_mode_list(
|
||||||
@ -471,6 +477,11 @@ class SharedDataFacade final : public BaseDataFacade
|
|||||||
return m_coordinate_list[id];
|
return m_coordinate_list[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OSMNodeID GetOSMNodeIDOfNode(const unsigned id) const override final
|
||||||
|
{
|
||||||
|
return m_osmnodeid_list[id];
|
||||||
|
}
|
||||||
|
|
||||||
virtual void GetUncompressedGeometry(const EdgeID id,
|
virtual void GetUncompressedGeometry(const EdgeID id,
|
||||||
std::vector<NodeID> &result_nodes) const override final
|
std::vector<NodeID> &result_nodes) const override final
|
||||||
{
|
{
|
||||||
|
@ -43,6 +43,13 @@ LegGeometry assembleGeometry(const DataFacadeT &facade,
|
|||||||
geometry.segment_offsets.push_back(0);
|
geometry.segment_offsets.push_back(0);
|
||||||
geometry.locations.push_back(source_node.location);
|
geometry.locations.push_back(source_node.location);
|
||||||
|
|
||||||
|
// Need to get the node ID preceding the source phantom node
|
||||||
|
// TODO: check if this was traversed in reverse?
|
||||||
|
std::vector<NodeID> reverse_geometry;
|
||||||
|
facade.GetUncompressedGeometry(source_node.reverse_packed_geometry_id, reverse_geometry);
|
||||||
|
geometry.osm_node_ids.push_back(facade.GetOSMNodeIDOfNode(
|
||||||
|
reverse_geometry[reverse_geometry.size() - source_node.fwd_segment_position - 1]));
|
||||||
|
|
||||||
auto cumulative_distance = 0.;
|
auto cumulative_distance = 0.;
|
||||||
auto current_distance = 0.;
|
auto current_distance = 0.;
|
||||||
auto prev_coordinate = geometry.locations.front();
|
auto prev_coordinate = geometry.locations.front();
|
||||||
@ -65,6 +72,7 @@ LegGeometry assembleGeometry(const DataFacadeT &facade,
|
|||||||
geometry.annotations.emplace_back(
|
geometry.annotations.emplace_back(
|
||||||
LegGeometry::Annotation{current_distance, path_point.duration_until_turn / 10.});
|
LegGeometry::Annotation{current_distance, path_point.duration_until_turn / 10.});
|
||||||
geometry.locations.push_back(std::move(coordinate));
|
geometry.locations.push_back(std::move(coordinate));
|
||||||
|
geometry.osm_node_ids.push_back(facade.GetOSMNodeIDOfNode(path_point.turn_via_node));
|
||||||
}
|
}
|
||||||
current_distance =
|
current_distance =
|
||||||
util::coordinate_calculation::haversineDistance(prev_coordinate, target_node.location);
|
util::coordinate_calculation::haversineDistance(prev_coordinate, target_node.location);
|
||||||
@ -76,6 +84,13 @@ LegGeometry assembleGeometry(const DataFacadeT &facade,
|
|||||||
geometry.segment_offsets.push_back(geometry.locations.size());
|
geometry.segment_offsets.push_back(geometry.locations.size());
|
||||||
geometry.locations.push_back(target_node.location);
|
geometry.locations.push_back(target_node.location);
|
||||||
|
|
||||||
|
// Need to get the node ID following the destination phantom node
|
||||||
|
// TODO: check if this was traversed in reverse??
|
||||||
|
std::vector<NodeID> forward_geometry;
|
||||||
|
facade.GetUncompressedGeometry(target_node.forward_packed_geometry_id, forward_geometry);
|
||||||
|
geometry.osm_node_ids.push_back(
|
||||||
|
facade.GetOSMNodeIDOfNode(forward_geometry[target_node.fwd_segment_position]));
|
||||||
|
|
||||||
BOOST_ASSERT(geometry.segment_distances.size() == geometry.segment_offsets.size() - 1);
|
BOOST_ASSERT(geometry.segment_distances.size() == geometry.segment_offsets.size() - 1);
|
||||||
BOOST_ASSERT(geometry.locations.size() > geometry.segment_distances.size());
|
BOOST_ASSERT(geometry.locations.size() > geometry.segment_distances.size());
|
||||||
BOOST_ASSERT(geometry.annotations.size() == geometry.locations.size() - 1);
|
BOOST_ASSERT(geometry.annotations.size() == geometry.locations.size() - 1);
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "util/coordinate.hpp"
|
#include "util/coordinate.hpp"
|
||||||
#include "util/integer_range.hpp"
|
#include "util/integer_range.hpp"
|
||||||
|
#include "util/typedefs.hpp"
|
||||||
|
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
|
|
||||||
@ -30,6 +31,8 @@ struct LegGeometry
|
|||||||
std::vector<std::size_t> segment_offsets;
|
std::vector<std::size_t> segment_offsets;
|
||||||
// length of the segment in meters
|
// length of the segment in meters
|
||||||
std::vector<double> segment_distances;
|
std::vector<double> segment_distances;
|
||||||
|
// original OSM node IDs for each coordinate
|
||||||
|
std::vector<OSMNodeID> osm_node_ids;
|
||||||
|
|
||||||
// Per-coordinate metadata
|
// Per-coordinate metadata
|
||||||
struct Annotation
|
struct Annotation
|
||||||
|
@ -28,6 +28,7 @@ struct SharedDataLayout
|
|||||||
GRAPH_NODE_LIST,
|
GRAPH_NODE_LIST,
|
||||||
GRAPH_EDGE_LIST,
|
GRAPH_EDGE_LIST,
|
||||||
COORDINATE_LIST,
|
COORDINATE_LIST,
|
||||||
|
OSM_NODE_ID_LIST,
|
||||||
TURN_INSTRUCTION,
|
TURN_INSTRUCTION,
|
||||||
ENTRY_CLASSID,
|
ENTRY_CLASSID,
|
||||||
TRAVEL_MODE,
|
TRAVEL_MODE,
|
||||||
|
@ -729,6 +729,7 @@ void trimShortSegments(std::vector<RouteStep> &steps, LegGeometry &geometry)
|
|||||||
// fixup the coordinate
|
// fixup the coordinate
|
||||||
geometry.locations.erase(geometry.locations.begin());
|
geometry.locations.erase(geometry.locations.begin());
|
||||||
geometry.annotations.erase(geometry.annotations.begin());
|
geometry.annotations.erase(geometry.annotations.begin());
|
||||||
|
geometry.osm_node_ids.erase(geometry.osm_node_ids.begin());
|
||||||
|
|
||||||
// remove the initial distance value
|
// remove the initial distance value
|
||||||
geometry.segment_distances.erase(geometry.segment_distances.begin());
|
geometry.segment_distances.erase(geometry.segment_distances.begin());
|
||||||
@ -818,6 +819,7 @@ void trimShortSegments(std::vector<RouteStep> &steps, LegGeometry &geometry)
|
|||||||
{
|
{
|
||||||
geometry.locations.pop_back();
|
geometry.locations.pop_back();
|
||||||
geometry.annotations.pop_back();
|
geometry.annotations.pop_back();
|
||||||
|
geometry.osm_node_ids.pop_back();
|
||||||
geometry.segment_offsets.pop_back();
|
geometry.segment_offsets.pop_back();
|
||||||
BOOST_ASSERT(geometry.segment_distances.back() < 1);
|
BOOST_ASSERT(geometry.segment_distances.back() < 1);
|
||||||
geometry.segment_distances.pop_back();
|
geometry.segment_distances.pop_back();
|
||||||
|
@ -244,6 +244,9 @@ int Storage::Run()
|
|||||||
nodes_input_stream.read((char *)&coordinate_list_size, sizeof(unsigned));
|
nodes_input_stream.read((char *)&coordinate_list_size, sizeof(unsigned));
|
||||||
shared_layout_ptr->SetBlockSize<util::Coordinate>(SharedDataLayout::COORDINATE_LIST,
|
shared_layout_ptr->SetBlockSize<util::Coordinate>(SharedDataLayout::COORDINATE_LIST,
|
||||||
coordinate_list_size);
|
coordinate_list_size);
|
||||||
|
// we'll read a list of OSM node IDs from the same data, so set the same block size:
|
||||||
|
shared_layout_ptr->SetBlockSize<OSMNodeID>(SharedDataLayout::OSM_NODE_ID_LIST,
|
||||||
|
coordinate_list_size);
|
||||||
|
|
||||||
// load geometries sizes
|
// load geometries sizes
|
||||||
boost::filesystem::ifstream geometry_input_stream(config.geometries_path, std::ios::binary);
|
boost::filesystem::ifstream geometry_input_stream(config.geometries_path, std::ios::binary);
|
||||||
@ -535,12 +538,15 @@ int Storage::Run()
|
|||||||
// Loading list of coordinates
|
// Loading list of coordinates
|
||||||
util::Coordinate *coordinates_ptr = shared_layout_ptr->GetBlockPtr<util::Coordinate, true>(
|
util::Coordinate *coordinates_ptr = shared_layout_ptr->GetBlockPtr<util::Coordinate, true>(
|
||||||
shared_memory_ptr, SharedDataLayout::COORDINATE_LIST);
|
shared_memory_ptr, SharedDataLayout::COORDINATE_LIST);
|
||||||
|
OSMNodeID *osmnodeid_ptr = shared_layout_ptr->GetBlockPtr<OSMNodeID, true>(
|
||||||
|
shared_memory_ptr, SharedDataLayout::OSM_NODE_ID_LIST);
|
||||||
|
|
||||||
extractor::QueryNode current_node;
|
extractor::QueryNode current_node;
|
||||||
for (unsigned i = 0; i < coordinate_list_size; ++i)
|
for (unsigned i = 0; i < coordinate_list_size; ++i)
|
||||||
{
|
{
|
||||||
nodes_input_stream.read((char *)¤t_node, sizeof(extractor::QueryNode));
|
nodes_input_stream.read((char *)¤t_node, sizeof(extractor::QueryNode));
|
||||||
coordinates_ptr[i] = util::Coordinate(current_node.lon, current_node.lat);
|
coordinates_ptr[i] = util::Coordinate(current_node.lon, current_node.lat);
|
||||||
|
osmnodeid_ptr[i] = OSMNodeID(current_node.node_id);
|
||||||
}
|
}
|
||||||
nodes_input_stream.close();
|
nodes_input_stream.close();
|
||||||
|
|
||||||
|
@ -50,6 +50,10 @@ class MockDataFacade final : public engine::datafacade::BaseDataFacade
|
|||||||
{
|
{
|
||||||
return {util::FixedLongitude{0}, util::FixedLatitude{0}};
|
return {util::FixedLongitude{0}, util::FixedLatitude{0}};
|
||||||
}
|
}
|
||||||
|
OSMNodeID GetOSMNodeIDOfNode(const unsigned /* id */) const override
|
||||||
|
{
|
||||||
|
return OSMNodeID{0};
|
||||||
|
}
|
||||||
bool EdgeIsCompressed(const unsigned /* id */) const { return false; }
|
bool EdgeIsCompressed(const unsigned /* id */) const { return false; }
|
||||||
unsigned GetGeometryIndexForEdgeID(const unsigned /* id */) const override
|
unsigned GetGeometryIndexForEdgeID(const unsigned /* id */) const override
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user