#5325 Make osm_ids optional after the revew
This commit is contained in:
parent
848e96238e
commit
129d9549d3
@ -242,7 +242,7 @@ endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -ggdb")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og -ggdb")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb")
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
@ -504,7 +504,8 @@ class RouteAPI : public BaseAPI
|
||||
}
|
||||
}
|
||||
std::vector<int64_t> ways;
|
||||
if (requested_annotations & RouteParameters::AnnotationsType::Ways)
|
||||
if (requested_annotations & RouteParameters::AnnotationsType::Ways &&
|
||||
leg_geometry.osm_way_ids.size())
|
||||
{
|
||||
ways.reserve(leg_geometry.osm_way_ids.size());
|
||||
for (const auto way_id : leg_geometry.osm_way_ids)
|
||||
@ -843,7 +844,8 @@ class RouteAPI : public BaseAPI
|
||||
}
|
||||
annotation.values["nodes"] = std::move(nodes);
|
||||
}
|
||||
if (requested_annotations & RouteParameters::AnnotationsType::Ways)
|
||||
if (requested_annotations & RouteParameters::AnnotationsType::Ways &&
|
||||
leg_geometry.osm_way_ids.size())
|
||||
{
|
||||
util::json::Array ways;
|
||||
ways.values.reserve(leg_geometry.osm_way_ids.size());
|
||||
|
||||
@ -259,6 +259,10 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
{
|
||||
return segment_data.GetReverseOSMWayIDs(id);
|
||||
}
|
||||
bool GetUncompressedWayIDsSkipped() const override final
|
||||
{
|
||||
return segment_data.GetOSMWaysSkipped();
|
||||
}
|
||||
|
||||
DurationForwardRange GetUncompressedForwardDurations(const EdgeID id) const override final
|
||||
{
|
||||
|
||||
@ -93,6 +93,7 @@ class BaseDataFacade
|
||||
|
||||
virtual OSMWayForwardRange GetUncompressedForwardWayIDs(const EdgeID id) const = 0;
|
||||
virtual OSMWayReverseRange GetUncompressedReverseWayIDs(const EdgeID id) const = 0;
|
||||
virtual bool GetUncompressedWayIDsSkipped() const = 0;
|
||||
|
||||
virtual NodeForwardRange GetUncompressedForwardGeometry(const EdgeID id) const = 0;
|
||||
virtual NodeReverseRange GetUncompressedReverseGeometry(const EdgeID id) const = 0;
|
||||
|
||||
@ -100,6 +100,7 @@ inline LegGeometry assembleGeometry(const datafacade::BaseDataFacade &facade,
|
||||
path_point.datasource_id});
|
||||
geometry.locations.push_back(std::move(coordinate));
|
||||
geometry.osm_node_ids.push_back(osm_node_id);
|
||||
if (!facade.GetUncompressedWayIDsSkipped())
|
||||
geometry.osm_way_ids.push_back(path_point.osm_way_id);
|
||||
}
|
||||
}
|
||||
@ -161,18 +162,20 @@ inline LegGeometry assembleGeometry(const datafacade::BaseDataFacade &facade,
|
||||
const auto target_geometry = facade.GetUncompressedForwardGeometry(target_geometry_id);
|
||||
geometry.osm_node_ids.push_back(
|
||||
facade.GetOSMNodeIDOfNode(target_geometry(target_segment_end_coordinate)));
|
||||
if (!facade.GetUncompressedWayIDsSkipped())
|
||||
{
|
||||
if (reversed_target)
|
||||
{
|
||||
const auto target_osm_way_ids = facade.GetUncompressedReverseWayIDs(target_geometry_id);
|
||||
geometry.osm_way_ids.push_back(
|
||||
target_osm_way_ids(target_osm_way_ids.size() - target_node.fwd_segment_position - 1));
|
||||
geometry.osm_way_ids.push_back(target_osm_way_ids(
|
||||
target_osm_way_ids.size() - target_node.fwd_segment_position - 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto target_osm_way_ids = facade.GetUncompressedForwardWayIDs(target_geometry_id);
|
||||
geometry.osm_way_ids.push_back(target_osm_way_ids(target_node.fwd_segment_position));
|
||||
}
|
||||
|
||||
}
|
||||
BOOST_ASSERT(geometry.segment_distances.size() == geometry.segment_offsets.size() - 1);
|
||||
BOOST_ASSERT(geometry.locations.size() > geometry.segment_distances.size());
|
||||
BOOST_ASSERT(geometry.annotations.size() == geometry.locations.size() - 1);
|
||||
|
||||
@ -194,7 +194,7 @@ void annotatePath(const FacadeT &facade,
|
||||
BOOST_ASSERT(datasource_vector.size() > 0);
|
||||
BOOST_ASSERT(weight_vector.size() + 1 == id_vector.size());
|
||||
BOOST_ASSERT(duration_vector.size() + 1 == id_vector.size());
|
||||
BOOST_ASSERT(osm_way_id_vector.size() + 1 == id_vector.size());
|
||||
BOOST_ASSERT(!osm_way_id_vector.size() || osm_way_id_vector.size() + 1 == id_vector.size());
|
||||
|
||||
const bool is_first_segment = unpacked_path.empty();
|
||||
|
||||
@ -219,7 +219,7 @@ void annotatePath(const FacadeT &facade,
|
||||
{
|
||||
unpacked_path.push_back(
|
||||
PathData{*node_from,
|
||||
osm_way_id_vector[segment_idx],
|
||||
osm_way_id_vector.size() ? osm_way_id_vector[segment_idx] : 0,
|
||||
id_vector[segment_idx + 1],
|
||||
name_index,
|
||||
is_segregated,
|
||||
@ -295,7 +295,7 @@ void annotatePath(const FacadeT &facade,
|
||||
BOOST_ASSERT(facade.GetTravelMode(target_node_id) > 0);
|
||||
unpacked_path.push_back(
|
||||
PathData{target_node_id,
|
||||
osm_way_id_vector[segment_idx],
|
||||
osm_way_id_vector.size() ? osm_way_id_vector[segment_idx] : 0,
|
||||
id_vector[start_index < end_index ? segment_idx + 1 : segment_idx - 1],
|
||||
facade.GetNameIndex(target_node_id),
|
||||
facade.IsSegregated(target_node_id),
|
||||
|
||||
@ -70,7 +70,8 @@ struct ExtractorConfig final : storage::IOConfig
|
||||
".osrm.cnbg",
|
||||
".osrm.cnbg_to_ebg",
|
||||
".osrm.maneuver_overrides"}),
|
||||
requested_num_threads(0), parse_conditionals(false), use_locations_cache(true)
|
||||
requested_num_threads(0), parse_conditionals(false), use_locations_cache(true),
|
||||
skip_osm_ways(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -92,6 +93,7 @@ struct ExtractorConfig final : storage::IOConfig
|
||||
bool use_metadata;
|
||||
bool parse_conditionals;
|
||||
bool use_locations_cache;
|
||||
bool skip_osm_ways;
|
||||
};
|
||||
} // namespace extractor
|
||||
} // namespace osrm
|
||||
|
||||
@ -206,7 +206,9 @@ inline void readSegmentData(const boost::filesystem::path &path, SegmentDataT &s
|
||||
|
||||
// writes .osrm.geometry
|
||||
template <typename SegmentDataT>
|
||||
inline void writeSegmentData(const boost::filesystem::path &path, const SegmentDataT &segment_data)
|
||||
inline void writeSegmentData(const boost::filesystem::path &path,
|
||||
bool skip_osm_ways,
|
||||
const SegmentDataT &segment_data)
|
||||
{
|
||||
static_assert(std::is_same<SegmentDataContainer, SegmentDataT>::value ||
|
||||
std::is_same<SegmentDataView, SegmentDataT>::value,
|
||||
@ -214,7 +216,7 @@ inline void writeSegmentData(const boost::filesystem::path &path, const SegmentD
|
||||
const auto fingerprint = storage::tar::FileWriter::GenerateFingerprint;
|
||||
storage::tar::FileWriter writer{path, fingerprint};
|
||||
|
||||
serialization::write(writer, "/common/segment_data", segment_data);
|
||||
serialization::write(writer, "/common/segment_data", skip_osm_ways, segment_data);
|
||||
}
|
||||
|
||||
// reads .osrm.ebg_nodes
|
||||
|
||||
@ -40,6 +40,7 @@ inline void read(storage::tar::FileReader &reader,
|
||||
template <storage::Ownership Ownership>
|
||||
inline void write(storage::tar::FileWriter &writer,
|
||||
const std::string &name,
|
||||
const bool skip_osm_ways,
|
||||
const detail::SegmentDataContainerImpl<Ownership> &segment_data);
|
||||
} // namespace serialization
|
||||
|
||||
@ -171,6 +172,8 @@ template <storage::Ownership Ownership> class SegmentDataContainerImpl
|
||||
|
||||
auto GetForwardOSMWayIDs(const DirectionalGeometryID id) const
|
||||
{
|
||||
if (GetOSMWaysSkipped())
|
||||
return boost::make_iterator_range(osm_ways.cend(), osm_ways.cend());
|
||||
const auto begin = osm_ways.cbegin() + index[id];
|
||||
const auto end = osm_ways.cbegin() + index[id + 1] - 1;
|
||||
|
||||
@ -233,6 +236,7 @@ template <storage::Ownership Ownership> class SegmentDataContainerImpl
|
||||
|
||||
auto GetNumberOfGeometries() const { return index.size() - 1; }
|
||||
auto GetNumberOfSegments() const { return fwd_weights.size(); }
|
||||
auto GetOSMWaysSkipped() const { return osm_ways.size() == 0; }
|
||||
|
||||
friend void
|
||||
serialization::read<Ownership>(storage::tar::FileReader &reader,
|
||||
@ -241,6 +245,7 @@ template <storage::Ownership Ownership> class SegmentDataContainerImpl
|
||||
friend void serialization::write<Ownership>(
|
||||
storage::tar::FileWriter &writer,
|
||||
const std::string &name,
|
||||
const bool skip_osm_ways,
|
||||
const detail::SegmentDataContainerImpl<Ownership> &segment_data);
|
||||
|
||||
private:
|
||||
|
||||
@ -98,11 +98,18 @@ inline void read(storage::tar::FileReader &reader,
|
||||
template <storage::Ownership Ownership>
|
||||
inline void write(storage::tar::FileWriter &writer,
|
||||
const std::string &name,
|
||||
const bool skip_osm_ways,
|
||||
const detail::SegmentDataContainerImpl<Ownership> &segment_data)
|
||||
{
|
||||
storage::serialization::write(writer, name + "/index", segment_data.index);
|
||||
storage::serialization::write(writer, name + "/nodes", segment_data.nodes);
|
||||
if (!skip_osm_ways)
|
||||
storage::serialization::write(writer, name + "/osm_ways", segment_data.osm_ways);
|
||||
else
|
||||
storage::serialization::write(
|
||||
writer,
|
||||
name + "/osm_ways",
|
||||
osrm::util::ViewOrVector<OSMWayIDDir, osrm::storage::Ownership::Container>());
|
||||
util::serialization::write(writer, name + "/forward_weights", segment_data.fwd_weights);
|
||||
util::serialization::write(writer, name + "/reverse_weights", segment_data.rev_weights);
|
||||
util::serialization::write(writer, name + "/forward_durations", segment_data.fwd_durations);
|
||||
|
||||
@ -321,6 +321,7 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
|
||||
// output the geometry of the node-based graph, needs to be done after the last usage, since it
|
||||
// destroys internal containers
|
||||
files::writeSegmentData(config.GetPath(".osrm.geometry"),
|
||||
config.skip_osm_ways,
|
||||
*node_based_graph_factory.GetCompressedEdges().ToSegmentData());
|
||||
|
||||
util::Log() << "Saving edge-based node weights to file.";
|
||||
|
||||
@ -74,7 +74,12 @@ return_code parseArguments(int argc,
|
||||
boost::program_options::bool_switch(&extractor_config.use_locations_cache)
|
||||
->implicit_value(false)
|
||||
->default_value(true),
|
||||
"Use internal nodes locations cache for location-dependent data lookups");
|
||||
"Use internal nodes locations cache for location-dependent data lookups")(
|
||||
"skip-osm-ways",
|
||||
boost::program_options::bool_switch(&extractor_config.skip_osm_ways)
|
||||
->implicit_value(true)
|
||||
->default_value(false),
|
||||
"Skip OSM Way IDs in annotations");
|
||||
|
||||
bool dummy;
|
||||
// hidden options, will be allowed on command line, but will not be
|
||||
|
||||
@ -623,7 +623,8 @@ Updater::LoadAndUpdateEdgeExpandedGraph(std::vector<extractor::EdgeBasedEdge> &e
|
||||
coordinates,
|
||||
osm_node_ids);
|
||||
// Now save out the updated compressed geometries
|
||||
extractor::files::writeSegmentData(config.GetPath(".osrm.geometry"), segment_data);
|
||||
extractor::files::writeSegmentData(
|
||||
config.GetPath(".osrm.geometry"), segment_data.GetOSMWaysSkipped(), segment_data);
|
||||
TIMER_STOP(segment);
|
||||
util::Log() << "Updating segment data took " << TIMER_MSEC(segment) << "ms.";
|
||||
}
|
||||
|
||||
@ -170,6 +170,7 @@ class ContiguousInternalMemoryDataFacade<routing_algorithms::offline::Algorithm>
|
||||
{
|
||||
return {};
|
||||
}
|
||||
bool GetUncompressedWayIDsSkipped() const override { return true; }
|
||||
|
||||
OSMWayReverseRange GetUncompressedReverseWayIDs(const EdgeID id) const override
|
||||
{
|
||||
|
||||
@ -70,6 +70,7 @@ class MockBaseDataFacade : public engine::datafacade::BaseDataFacade
|
||||
static extractor::SegmentDataView::SegmentOSMWayVector ways(data, 4);
|
||||
return boost::make_iterator_range(ways.cbegin(), ways.cend());
|
||||
}
|
||||
bool GetUncompressedWayIDsSkipped() const override { return false; }
|
||||
OSMWayReverseRange GetUncompressedReverseWayIDs(const EdgeID id) const override
|
||||
{
|
||||
return boost::adaptors::reverse(boost::adaptors::transform(GetUncompressedForwardWayIDs(id),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user