reduce size of InternalExtractorEdge by using single-precision values
This commit is contained in:
committed by
Patrick Niklaus
parent
5f1c7efd41
commit
c48fc58eb2
@@ -427,10 +427,8 @@ void ExtractionContainers::PrepareEdges(ScriptingEnvironment &scripting_environm
|
||||
const double distance = util::coordinate_calculation::greatCircleDistance(
|
||||
edge_iterator->source_coordinate, target_coord);
|
||||
|
||||
double weight = static_cast<double>(mapbox::util::apply_visitor(
|
||||
detail::ToValueByEdge(distance), edge_iterator->weight_data));
|
||||
double duration = static_cast<double>(mapbox::util::apply_visitor(
|
||||
detail::ToValueByEdge(distance), edge_iterator->duration_data));
|
||||
auto weight = edge_iterator->weight_data(distance);
|
||||
auto duration = edge_iterator->duration_data(distance);
|
||||
|
||||
ExtractionSegment extracted_segment(
|
||||
edge_iterator->source_coordinate, target_coord, distance, weight, duration);
|
||||
|
||||
@@ -119,20 +119,20 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
|
||||
InternalExtractorEdge::WeightData forward_weight_data;
|
||||
InternalExtractorEdge::WeightData backward_weight_data;
|
||||
|
||||
const auto toValueByEdgeOrByMeter =
|
||||
[&nodes](const double by_way, const double by_meter) -> detail::ByEdgeOrByMeterValue {
|
||||
if (by_way > 0)
|
||||
const auto toValueByEdgeOrByMeter = [&nodes](const double by_way, const double by_meter) {
|
||||
using Value = detail::ByEdgeOrByMeterValue;
|
||||
if (by_way >= 0)
|
||||
{
|
||||
// FIXME We divide by the number of edges here, but should rather consider
|
||||
// the length of each segment. We would either have to compute the length
|
||||
// of the whole way here (we can't: no node coordinates) or push that back
|
||||
// to the container and keep a reference to the way.
|
||||
const unsigned num_edges = (nodes.size() - 1);
|
||||
return detail::ValueByEdge{by_way / num_edges};
|
||||
const std::size_t num_edges = (nodes.size() - 1);
|
||||
return Value(Value::by_edge, by_way / num_edges);
|
||||
}
|
||||
else
|
||||
{
|
||||
return detail::ValueByMeter{by_meter};
|
||||
return Value(Value::by_meter, by_meter);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user