Skip to content

Commit

Permalink
Improve graph preparation time in case of not activating the noisy_ro…
Browse files Browse the repository at this point in the history
…ad_nearby EV
  • Loading branch information
ratrun committed Aug 12, 2024
1 parent 7e5e020 commit 9abe564
Showing 1 changed file with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@ public class WaySegmentParser {
private static final Set<String> INCLUDE_IF_NODE_TAGS = new HashSet<>(Arrays.asList("barrier", "highway", "railway", "crossing", "ford"));

private ToDoubleFunction<ReaderNode> elevationProvider = node -> 0d;
private static boolean customPass0WayPreHook = false;
private Consumer<ReaderWay> pass0WayPreHook = way -> {
};
private static boolean customPass1NodePreHook = false;
private Consumer<ReaderNode> pass1NodePreHook = node -> {
};
private Consumer<ReaderWay> pass1WayPreHook = way -> {
};
private Runnable pass1FinishHook = () -> {
};
private Predicate<ReaderWay> wayFilter = way -> true;
private Consumer<ReaderNode> pass2NodePreHook = node -> {
};
private Runnable pass2AfterNodesHook = () -> {
};
private Predicate<ReaderNode> splitNodeFilter = node -> false;
Expand Down Expand Up @@ -104,13 +104,14 @@ public void readOSM(File osmFile) {
LOGGER.info("Start reading OSM file: '" + osmFile + "'");
LOGGER.info("pass0 - start");
StopWatch sw0 = StopWatch.started();
// todonow: skip options
readOSM(osmFile, new Pass0Handler(), new SkipOptions(true, false, true));
if (customPass0WayPreHook) {
readOSM(osmFile, new Pass0Handler(), new SkipOptions(true, false, true));
}
LOGGER.info("pass0 - finished, took: {}", sw0.stop().getTimeString());

LOGGER.info("pass1 - start");
StopWatch sw1 = StopWatch.started();
readOSM(osmFile, new Pass1Handler(), new SkipOptions(false, false, false));
readOSM(osmFile, new Pass1Handler(), new SkipOptions(!customPass1NodePreHook, false, false));
LOGGER.info("pass1 - finished, took: {}", sw1.stop().getTimeString());

long nodes = nodeData.getNodeCount();
Expand Down Expand Up @@ -237,8 +238,6 @@ public void handleNode(ReaderNode node) {
LOGGER.info("pass2 - processed nodes: " + nf(nodeCounter) + ", accepted nodes: " + nf(acceptedNodes) +
", " + Helper.getMemInfo());

pass2NodePreHook.accept(node);

long nodeType = nodeData.addCoordinatesIfMapped(node.getId(), node.getLat(), node.getLon(), () -> elevationProvider.applyAsDouble(node));
if (nodeType == EMPTY_NODE)
return;
Expand Down Expand Up @@ -465,11 +464,13 @@ public Builder setElevationProvider(ToDoubleFunction<ReaderNode> elevationProvid
}

public Builder setPass0WayPreHook(Consumer<ReaderWay> pass0WayPreHook) {
customPass0WayPreHook = true;
waySegmentParser.pass0WayPreHook = pass0WayPreHook;
return this;
}

public Builder setPass1NodePreHook(Consumer<ReaderNode> pass1NodePreHook) {
customPass1NodePreHook = true;
waySegmentParser.pass1NodePreHook = pass1NodePreHook;
return this;
}
Expand All @@ -492,11 +493,6 @@ public Builder setWayFilter(Predicate<ReaderWay> wayFilter) {
return this;
}

public Builder setPass2NodePreHook(Consumer<ReaderNode> pass2NodePreHook) {
waySegmentParser.pass2NodePreHook = pass2NodePreHook;
return this;
}

public Builder setPass2AfterNodesHook(Runnable pass2AfterNodesHook) {
waySegmentParser.pass2AfterNodesHook = pass2AfterNodesHook;
return this;
Expand Down

0 comments on commit 9abe564

Please sign in to comment.