Fix rounding error in calcDistance
This commit is contained in:
parent
2387513a1f
commit
4495952625
3 changed files with 3 additions and 3 deletions
|
@ -75,7 +75,7 @@ public class OsmPathElement implements OsmPos {
|
|||
}
|
||||
|
||||
public final int calcDistance(OsmPos p) {
|
||||
return (int) (CheapRuler.distance(ilon, ilat, p.getILon(), p.getILat()) + 1.0);
|
||||
return (int) Math.max(1.0, Math.round(CheapRuler.distance(ilon, ilat, p.getILon(), p.getILat())));
|
||||
}
|
||||
|
||||
public OsmPathElement origin;
|
||||
|
|
|
@ -462,7 +462,7 @@ public final class RoutingContext {
|
|||
}
|
||||
}
|
||||
}
|
||||
return (int) (d + 0.5);
|
||||
return (int) Math.max(1.0, Math.round(d));
|
||||
}
|
||||
|
||||
public OsmPathModel pm;
|
||||
|
|
|
@ -100,7 +100,7 @@ public class OsmNode extends OsmLink implements OsmPos {
|
|||
}
|
||||
|
||||
public final int calcDistance(OsmPos p) {
|
||||
return (int) (CheapRuler.distance(ilon, ilat, p.getILon(), p.getILat()) + 1.0);
|
||||
return (int) Math.max(1.0, Math.round(CheapRuler.distance(ilon, ilat, p.getILon(), p.getILat())));
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
|
Loading…
Reference in a new issue