Skip to content
Snippets Groups Projects
Commit 1eaa8138 authored by User expired's avatar User expired
Browse files

fixed invalid isochrone calculation

added todo
parent 71dc1560
No related branches found
No related tags found
No related merge requests found
...@@ -26,6 +26,7 @@ import java.util.Set; ...@@ -26,6 +26,7 @@ import java.util.Set;
* algorithms which define the loading of the data from the database. * algorithms which define the loading of the data from the database.
*/ */
public abstract class Isochrone { public abstract class Isochrone {
private static final double COMPARE_PRECISION = 0.0000001d;
private final Query query; private final Query query;
private final PriorityQueue<Node> queue; private final PriorityQueue<Node> queue;
private Set<Integer> codes; private Set<Integer> codes;
...@@ -116,6 +117,7 @@ public abstract class Isochrone { ...@@ -116,6 +117,7 @@ public abstract class Isochrone {
* @param output the output in which the computed nodes and links are stored. * @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) * @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) { public <T extends Output> T compute(final T output) {
output.beforeCalculation(); output.beforeCalculation();
...@@ -134,7 +136,7 @@ public abstract class Isochrone { ...@@ -134,7 +136,7 @@ public abstract class Isochrone {
for (final Link link : adjacents) { for (final Link link : adjacents) {
if (link.isContinuous()) { if (link.isContinuous()) {
updateQueue(expandContinuousLink(node, link)); 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); output.addLink(link);
} }
} else { } else {
......
...@@ -183,7 +183,7 @@ public class MrneX extends Isochrone { ...@@ -183,7 +183,7 @@ public class MrneX extends Isochrone {
// CHECKSTYLE:OFF MagicNumber // CHECKSTYLE:OFF MagicNumber
if (maxMemory * 0.95d < getNodeSize()) { 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) + "%"); throw new RuntimeException("Free memory size is " + NumberFormat.getInstance().format(perc) + "%");
} }
// CHECKSTYLE:ON MagicNumber // CHECKSTYLE:ON MagicNumber
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment