From b985be527729c9a2f5e105846b4127d16804514e Mon Sep 17 00:00:00 2001
From: Nikolaus Krismer <nikolaus.krismer@uibk.ac.at>
Date: Mon, 25 Aug 2014 14:26:23 +0200
Subject: [PATCH] fixed a problem in isochrone calculation with link length

---
 .../inf/isochrone/algorithm/Isochrone.java    |  4 +--
 .../isochrone/network/ReachabilityTest.java   | 25 +++++++++++++++++--
 2 files changed, 25 insertions(+), 4 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 cf96a1f4..dc4e4760 100644
--- a/src/main/java/it/unibz/inf/isochrone/algorithm/Isochrone.java
+++ b/src/main/java/it/unibz/inf/isochrone/algorithm/Isochrone.java
@@ -32,7 +32,6 @@ 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 Collection<Integer> dateCodes;
 	private final AbstractQueue<Node> nodeQueue;
 	private final long qDuration;
@@ -431,8 +430,9 @@ public abstract class Isochrone {
 	// Private static methods
 
 	private static <T extends IOutput> void addLinks(final T output, final Collection<Link> links) {
+		final Double min = Double.MIN_VALUE;
 		for (final Link link : links) {
-			if (link.isContinuous() && Math.abs(link.getStartOffset() - Double.MIN_VALUE) < COMPARE_PRECISION) {
+			if (link.isContinuous() && !min.equals(link.getStartOffset())) {
 				output.addLink(link);
 			}
 		}
diff --git a/src/test/java/it/unibz/inf/isochrone/network/ReachabilityTest.java b/src/test/java/it/unibz/inf/isochrone/network/ReachabilityTest.java
index c9ffeb70..245facdf 100644
--- a/src/test/java/it/unibz/inf/isochrone/network/ReachabilityTest.java
+++ b/src/test/java/it/unibz/inf/isochrone/network/ReachabilityTest.java
@@ -42,12 +42,13 @@ public class ReachabilityTest {
 	}
 
 	@Test
-	public void testBzBusStation15() {
+	public void testBzBusStationNode15() {
 		final int nodeIdToCheck = 5117; // bus station id = 5117; Defregger Str./Fagenstraße (reachable by bus route 1)
 
 		LOGGER.info("Checking nodes from FUB (15min isncoming isochrone)");
 		final AlgorithmResult result = AlgorithmHelper.run(MineX.class, PARAM_LOCAL, true);
 		final Collection<Node> resultNodes = result.getOutput().getNodes();
+		LOGGER.info(" - found " + resultNodes.size() + " reachable nodes");
 
 		boolean foundNode = false;
 		for (final Node node : resultNodes) {
@@ -57,7 +58,27 @@ public class ReachabilityTest {
 			}
 		}
 
-		Assert.assertTrue(foundNode, "Expected node not found in 15min incoming isochrone to FUB");
+		Assert.assertTrue(foundNode, "Expected node \"" + nodeIdToCheck + "\" not in 15min incoming isochrone to FUB");
+	}
+
+	@Test
+	public void testBzBusStationLink15() {
+		final int nodeIdToCheck = 5117; // bus station id = 5117; Defregger Str./Fagenstraße (reachable by bus route 1)
+
+		LOGGER.info("Checking nodes from FUB (15min isncoming isochrone)");
+		final AlgorithmResult result = AlgorithmHelper.run(MineX.class, PARAM_LOCAL, true);
+		final Collection<Link> resultLinks = result.getOutput().getLinks().values();
+		LOGGER.info(" - found " + resultLinks.size() + " links");
+
+		boolean foundLink = false;
+		for (final Link link : resultLinks) {
+			if (link.getEndNode() == nodeIdToCheck) {
+				foundLink = true;
+				break;
+			}
+		}
+
+		Assert.assertTrue(foundLink, "Expected link to node \"" + nodeIdToCheck + "\" not in 15min incoming isochrone to FUB");
 	}
 
 }
-- 
GitLab