Skip to content

Commit

Permalink
have to not return vectors on facade.GetUncompressedForwardDurations …
Browse files Browse the repository at this point in the history
…and facade.GetUncompressedReverseDurations
  • Loading branch information
ghoshkaj committed Mar 16, 2018
1 parent 94970d7 commit aa7df0c
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 33 deletions.
19 changes: 19 additions & 0 deletions include/engine/datafacade/contiguous_internalmem_datafacade.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,16 +575,35 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
GetUncompressedForwardDurations(const EdgeID id) const override final
{
auto range = segment_data.GetForwardDurations(id);
// in gdb find the equivalent of `ptype range` or `info types` for all types
// std::cout << "typeid(range).name(): " << typeid(range).name() << std::endl;
return std::vector<EdgeWeight>{range.begin(), range.end()};
}

virtual std::vector<EdgeWeight>
GetUncompressedReverseDurations(const EdgeID id) const override final
{
auto range = segment_data.GetReverseDurations(id);
// std::cout << "typeid(range).name(): " << typeid(range).name() << std::endl;
return std::vector<EdgeWeight>{range.begin(), range.end()};
}

virtual forwardRangeT GetUncompressedForwardDurations1(const EdgeID id) const override final
{
auto range = segment_data.GetForwardDurations(id);
// in gdb find the equivalent of `ptype range` or `info types` for all types
// std::cout << "typeid(range).name(): " << typeid(range).name() << std::endl;
// return std::vector<EdgeWeight>{range.begin(), range.end()};
return range;
}

virtual reverseRangeT GetUncompressedReverseDurations1(const EdgeID id) const override final
{
auto range = segment_data.GetReverseDurations(id);
// return std::vector<EdgeWeight>{range.begin(), range.end()};
return range;
}

virtual std::vector<EdgeWeight>
GetUncompressedForwardWeights(const EdgeID id) const override final
{
Expand Down
26 changes: 23 additions & 3 deletions include/engine/datafacade/datafacade_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@
#include "util/guidance/entry_class.hpp"
#include "util/guidance/turn_lanes.hpp"
#include "util/integer_range.hpp"
#include "util/packed_vector.hpp"
#include "util/string_util.hpp"
#include "util/string_view.hpp"
#include "util/typedefs.hpp"

#include "osrm/coordinate.hpp"
#include "osrm/coordinate.hpp" // also searches in local directory (include directory in this project)

#include <boost/range/adaptor/reversed.hpp> // only in system directories (specified with -I param)
#include <cstddef>

#include <string>
Expand Down Expand Up @@ -77,11 +79,29 @@ class BaseDataFacade
virtual std::vector<EdgeWeight> GetUncompressedForwardWeights(const EdgeID id) const = 0;
virtual std::vector<EdgeWeight> GetUncompressedReverseWeights(const EdgeID id) const = 0;

// Gets the duration values for each segment in an uncompressed geometry.
// Should always be 1 shorter than GetUncompressedGeometry
// // Gets the duration values for each segment in an uncompressed geometry.
// // Should always be 1 shorter than GetUncompressedGeometry
virtual std::vector<EdgeWeight> GetUncompressedForwardDurations(const EdgeID id) const = 0;
virtual std::vector<EdgeWeight> GetUncompressedReverseDurations(const EdgeID id) const = 0;

// Gets the duration values for each segment in an uncompressed geometry.
// Should always be 1 shorter than GetUncompressedGeometry
using forwardRangeT = boost::iterator_range<
osrm::util::detail::PackedVector<unsigned int, 22ul, (osrm::storage::Ownership)1>::
iterator_impl<unsigned int const,
osrm::util::detail::
PackedVector<unsigned int, 22ul, (osrm::storage::Ownership)1> const,
unsigned int>>;
virtual forwardRangeT GetUncompressedForwardDurations1(const EdgeID id) const = 0;

using reverseRangeT = boost::range_detail::reversed_range<const boost::iterator_range<
osrm::util::detail::PackedVector<unsigned int, 22, osrm::storage::Ownership::View>::
iterator_impl<const unsigned int,
const osrm::util::detail::
PackedVector<unsigned int, 22, osrm::storage::Ownership::View>,
unsigned int>>>;
virtual reverseRangeT GetUncompressedReverseDurations1(const EdgeID id) const = 0;

// Returns the data source ids that were used to supply the edge
// weights. Will return an empty array when only the base profile is used.
virtual std::vector<DatasourceID> GetUncompressedForwardDatasources(const EdgeID id) const = 0;
Expand Down
33 changes: 13 additions & 20 deletions include/engine/routing_algorithms/routing_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,28 +403,21 @@ InternalRouteResult extractRoute(const DataFacade<AlgorithmT> &facade,
template <typename FacadeT>
EdgeDuration computeEdgeDuration(const FacadeT &facade, NodeID node_id, NodeID turn_id)
{
// datastructures to hold extracted data from geometry
std::vector<EdgeWeight> duration_vector;
EdgeDuration total_duration = 0;

const auto get_segment_geometry = [&](const auto geometry_index) {
if (geometry_index.forward)
{
duration_vector = facade.GetUncompressedForwardDurations(geometry_index.id);
}
else
{
duration_vector = facade.GetUncompressedReverseDurations(geometry_index.id);
}
};

const auto geometry_index = facade.GetGeometryIndex(node_id);
get_segment_geometry(geometry_index);

for (std::vector<EdgeWeight>::iterator duration = duration_vector.begin();
duration != duration_vector.end();
duration++)
total_duration += *duration;
// datastructures to hold extracted data from geometry
EdgeDuration total_duration;

if (geometry_index.forward)
{
auto durations_range = facade.GetUncompressedForwardDurations1(geometry_index.id);
total_duration = std::accumulate(durations_range.begin(), durations_range.end(), 0);
}
else
{
auto durations_range = facade.GetUncompressedReverseDurations1(geometry_index.id);
total_duration = std::accumulate(durations_range.begin(), durations_range.end(), 0);
}

const auto turn_duration = facade.GetDurationPenaltyForEdgeID(turn_id);
total_duration += turn_duration;
Expand Down
10 changes: 5 additions & 5 deletions scripts/osrm-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ queries = queries.map(q => { return {hostname: options.server.hostname, port: op
http.globalAgent.maxSockets = options['max-sockets'];
queries.map(query => {
run_query(query, options.filter, (query, code, ttfb, total, results) => {
let str = `"${query}",${code}`;
if (ttfb !== undefined) str += `,${ttfb}`;
if (total !== undefined) str += `,${total}`;
if (typeof results === 'object' && results.length > 0)
str += ',' + results.map(x => isNaN(x) ? '"' + JSON.stringify(x).replace(/\n/g, ';').replace(/"/g, "'") + '"' : Number(x)).join(',');
// let str = `"${query}",${code}`;
// if (ttfb !== undefined) str += `,${ttfb}`;
let str = ""; if (total !== undefined) str += `,${total}`;
// if (typeof results === 'object' && results.length > 0)
// str += ',' + results.map(x => isNaN(x) ? '"' + JSON.stringify(x).replace(/\n/g, ';').replace(/"/g, "'") + '"' : Number(x)).join(',');
console.log(str);
});
});
9 changes: 4 additions & 5 deletions src/engine/routing_algorithms/many_to_many_ch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,10 @@ std::vector<EdgeDuration> manyToManySearch(SearchEngineData<ch::Algorithm> &engi
packed_leg.push_back(middle_node_id);

// Step 2: Find path from middle to target node
retrievePackedPathFromSearchSpace(
middle_node_id,
column_idx,
search_space_with_buckets,
packed_leg); // packed_leg_from_middle_to_target
retrievePackedPathFromSearchSpace(middle_node_id,
column_idx,
search_space_with_buckets,
packed_leg); // packed_leg_from_middle_to_target

if (packed_leg.size() == 1 && (needsLoopForward(source_phantom, target_phantom) ||
needsLoopBackwards(source_phantom, target_phantom)))
Expand Down

0 comments on commit aa7df0c

Please sign in to comment.