From 1eaa81387da46b4a78e1492ca1e9ec2d1a7df120 Mon Sep 17 00:00:00 2001 From: Nikolaus Krismer <nikolaus.krismer@uibk.ac.at> Date: Tue, 1 Jul 2014 22:35:58 +0200 Subject: [PATCH] fixed invalid isochrone calculation added todo --- src/main/java/it/unibz/inf/isochrone/algorithm/Isochrone.java | 4 +++- src/main/java/it/unibz/inf/isochrone/algorithm/MrneX.java | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/it/unibz/inf/isochrone/algorithm/Isochrone.java b/src/main/java/it/unibz/inf/isochrone/algorithm/Isochrone.java index d66d30b7..c9c3623f 100644 --- a/src/main/java/it/unibz/inf/isochrone/algorithm/Isochrone.java +++ b/src/main/java/it/unibz/inf/isochrone/algorithm/Isochrone.java @@ -26,6 +26,7 @@ import java.util.Set; * algorithms which define the loading of the data from the database. */ public abstract class Isochrone { + private static final double COMPARE_PRECISION = 0.0000001d; private final Query query; private final PriorityQueue<Node> queue; private Set<Integer> codes; @@ -116,6 +117,7 @@ public abstract class Isochrone { * @param output the output in which the computed nodes and links are stored. * @return the computed output (stored in the output given by the parameter) */ + // TODO: Add some more tests for this method. If isochrone gets too small (2points for 15min isochrone from FUB) nothing fails ;-( public <T extends Output> T compute(final T output) { output.beforeCalculation(); @@ -134,7 +136,7 @@ public abstract class Isochrone { for (final Link link : adjacents) { if (link.isContinuous()) { updateQueue(expandContinuousLink(node, link)); - if (Double.valueOf(Double.MIN_VALUE).equals(link.getStartOffset())) { + if (Math.abs(link.getStartOffset() - Double.MIN_VALUE) < COMPARE_PRECISION) { output.addLink(link); } } else { diff --git a/src/main/java/it/unibz/inf/isochrone/algorithm/MrneX.java b/src/main/java/it/unibz/inf/isochrone/algorithm/MrneX.java index 02e6102d..80796b24 100644 --- a/src/main/java/it/unibz/inf/isochrone/algorithm/MrneX.java +++ b/src/main/java/it/unibz/inf/isochrone/algorithm/MrneX.java @@ -183,7 +183,7 @@ public class MrneX extends Isochrone { // CHECKSTYLE:OFF MagicNumber if (maxMemory * 0.95d < getNodeSize()) { - final double perc = 100.0d - (double) getNodeSize() / maxMemory * 100.0d; + final double perc = 100.0d - ((double) getNodeSize() / maxMemory) * 100.0d; throw new RuntimeException("Free memory size is " + NumberFormat.getInstance().format(perc) + "%"); } // CHECKSTYLE:ON MagicNumber -- GitLab