Skip to content

Commit 34e74ce

Browse files
author
Peter
committed
no need for explicit levelgraph
1 parent 01eaa14 commit 34e74ce

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

config-example.properties

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@ osmreader.dataaccess=inmemory+save
88
#osmreader.dataaccess=mmap
99

1010
# sorts the graph according to location which improves query times by 10-20%
11-
osmreader.sortGraph=true
11+
osmreader.sortGraph=false
1212

13-
14-
# use levelgraph to speed things up (requires more RAM/disc space for holding the graph)
15-
#osmreader.levelgraph=true
16-
# the following options require levelgraph=true
17-
#osmreader.chShortcuts=true
13+
# use contraction hierarchies to speed things up. requires more RAM/disc space for holding the graph
14+
#osmreader.chShortcuts=fastest|shortest
1815

1916
# other options than CAR are currently not supported
2017
osmreader.type=CAR

src/main/java/com/graphhopper/reader/OSMReader.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public static void main(String[] strs) throws Exception {
9595
* reallocation (default is 5mio)
9696
*/
9797
public static OSMReader osm2Graph(final CmdArgs args) throws IOException {
98-
if (!args.get("config", "").isEmpty()) {
98+
if (!args.get("config", "").isEmpty()) {
9999
CmdArgs tmp = CmdArgs.readFromConfig(args.get("config", ""));
100100
// overwrite command line configuration
101101
args.merge(tmp);
@@ -128,10 +128,13 @@ public static OSMReader osm2Graph(final CmdArgs args) throws IOException {
128128
dir = new RAMDirectory(graphLocation, false);
129129
}
130130

131-
if (args.getBool("osmreader.levelgraph", false))
131+
String chShortcuts = args.get("osmreader.chShortcuts", "no");
132+
boolean levelGraph = "true".equals(chShortcuts)
133+
|| "fastest".equals(chShortcuts) || "shortest".equals(chShortcuts);
134+
if (levelGraph)
135+
// necessary for simple or CH shortcuts
132136
storage = new LevelGraphStorage(dir);
133137
else
134-
// necessary for simple or CH shortcuts
135138
storage = new GraphStorage(dir);
136139
return osm2Graph(new OSMReader(storage, size), args);
137140
}
@@ -221,7 +224,7 @@ public void optimize() {
221224
GraphUtility.sortDFS(graphStorage, newGraph);
222225
graphStorage = newGraph;
223226
}
224-
227+
225228
// TODO at the moment a prepared levelgraph cannot be sorted, as otherwise edgeIds won't be copied+recognized
226229
if (prepare == null)
227230
setDefaultAlgoPrepare(Helper.createAlgoPrepare("astar"));

src/main/java/com/graphhopper/routing/util/RoutingAlgorithmSpecialAreaTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ public void start() {
6565

6666
void testAlgos() {
6767
if (unterfrankenGraph instanceof LevelGraph)
68-
throw new IllegalStateException("run testAlgos only with a none-LevelGraph. Use osmreader.levelgraph=false");
68+
throw new IllegalStateException("run testAlgos only with a none-LevelGraph. Use osmreader.chShortcuts=false "
69+
+ "Or use osmreader.chShortcuts=shortest and avoid the preparation");
6970

7071
TestAlgoCollector testCollector = new TestAlgoCollector();
7172
Collection<RoutingAlgorithm> algos = createAlgos(unterfrankenGraph, false);

0 commit comments

Comments
 (0)