correct partial distances

This commit is contained in:
Dennis Luxen
2014-03-12 17:23:21 +01:00
parent ba37836e24
commit fdebec6448
6 changed files with 100 additions and 35 deletions
+6 -1
View File
@@ -31,7 +31,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <boost/assert.hpp>
#ifndef NDEBUG
#include <bitset>
#endif
#include <iostream>
#include <limits>
@@ -44,6 +46,7 @@ FixedPointCoordinate::FixedPointCoordinate(int lat, int lon)
: lat(lat),
lon(lon)
{
#ifndef NDEBUG
if(0 != (std::abs(lat) >> 30)) {
std::bitset<32> y(lat);
SimpleLogger().Write(logDEBUG) << "broken lat: " << lat << ", bits: " << y;
@@ -52,6 +55,7 @@ FixedPointCoordinate::FixedPointCoordinate(int lat, int lon)
std::bitset<32> x(lon);
SimpleLogger().Write(logDEBUG) << "broken lon: " << lon << ", bits: " << x;
}
#endif
}
void FixedPointCoordinate::Reset() {
@@ -59,7 +63,8 @@ void FixedPointCoordinate::Reset() {
lon = std::numeric_limits<int>::min();
}
bool FixedPointCoordinate::isSet() const {
return (std::numeric_limits<int>::min() != lat) && (std::numeric_limits<int>::min() != lon);
return (std::numeric_limits<int>::min() != lat) &&
(std::numeric_limits<int>::min() != lon);
}
bool FixedPointCoordinate::isValid() const {
if(
+3 -3
View File
@@ -59,11 +59,11 @@ struct PhantomNode {
int GetForwardWeightPlusOffset() const {
return forward_weight - forward_offset;
return forward_weight + forward_offset;
}
int GetReverseWeightPlusOffset() const {
return reverse_weight + reverse_offset;
return reverse_offset + reverse_weight;
}
void Reset() {
@@ -123,7 +123,7 @@ struct PhantomNodes {
//TODO: Rename to: BothPhantomNodesAreInvalid
bool AtLeastOnePhantomNodeIsUINTMAX() const {
return (startPhantom.forward_node_id == SPECIAL_NODEID) && (targetPhantom.forward_node_id == SPECIAL_NODEID);
return (startPhantom.forward_node_id == SPECIAL_NODEID) && (targetPhantom.reverse_node_id == SPECIAL_NODEID);
}
bool PhantomNodesHaveEqualLocation() const {
+13 -3
View File
@@ -758,15 +758,25 @@ public:
ratio = std::min(1., ratio);
}
result_phantom_node.forward_weight *= ratio;
if( INT_MAX != result_phantom_node.reverse_weight ) {
result_phantom_node.reverse_weight *= (1.-ratio);
SimpleLogger().Write(logDEBUG) << "result_phantom_node.forward_offset: " << result_phantom_node.forward_offset;
SimpleLogger().Write(logDEBUG) << "result_phantom_node.reverse_offset: " << result_phantom_node.reverse_offset;
SimpleLogger().Write(logDEBUG) << "result_phantom_node.forward_weight: " << result_phantom_node.forward_weight;
SimpleLogger().Write(logDEBUG) << "result_phantom_node.reverse_weight: " << result_phantom_node.reverse_weight;
if (SPECIAL_NODEID != result_phantom_node.forward_node_id)
{
result_phantom_node.forward_weight *= (1.-ratio);
}
if( SPECIAL_NODEID != result_phantom_node.reverse_node_id )
{
result_phantom_node.reverse_weight *= ratio;
}
result_phantom_node.ratio = ratio;
SimpleLogger().Write(logDEBUG) << "result location: " << result_phantom_node.location << ", start: " << current_start_coordinate << ", end: " << current_end_coordinate;
SimpleLogger().Write(logDEBUG) << "fwd node: " << result_phantom_node.forward_node_id << ", rev node: " << result_phantom_node.reverse_node_id;
SimpleLogger().Write(logDEBUG) << "fwd weight: " << result_phantom_node.forward_weight << ", rev weight: " << result_phantom_node.reverse_weight << ", ratio: " << result_phantom_node.ratio;
SimpleLogger().Write(logDEBUG) << "fwd offset: " << result_phantom_node.forward_offset << ", rev offset: " << result_phantom_node.reverse_offset << ", ratio: " << result_phantom_node.ratio;
SimpleLogger().Write(logDEBUG) << "bidirected: " << (result_phantom_node.isBidirected() ? "y" : "n");
SimpleLogger().Write(logDEBUG) << "name id: " << result_phantom_node.name_id;
SimpleLogger().Write(logDEBUG) << "geom id: " << result_phantom_node.packed_geometry_id;