Skip to content

Commit 7f795e9

Browse files
author
Peter
committed
log more information if error in location index
1 parent 3b34c85 commit 7f795e9

File tree

3 files changed

+27
-25
lines changed

3 files changed

+27
-25
lines changed

core/src/main/java/com/graphhopper/storage/GraphHopperStorage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,7 +1495,7 @@ protected int loadNodesHeader()
14951495
{
14961496
bounds.minEle = Helper.intToEle(nodes.getHeader(7 * 4));
14971497
bounds.maxEle = Helper.intToEle(nodes.getHeader(8 * 4));
1498-
}
1498+
}
14991499

15001500
return 7;
15011501
}
@@ -1579,7 +1579,7 @@ public boolean isClosed()
15791579
}
15801580

15811581
@Override
1582-
public GraphExtension getExtension()
1582+
public GraphExtension getExtension()
15831583
{
15841584
return extStorage;
15851585
}

core/src/main/java/com/graphhopper/storage/LevelGraphStorage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public EdgeSkipIterState shortcut( int a, int b )
9595
public EdgeSkipIterState edge( int a, int b )
9696
{
9797
if (lastEdgeIndex + 1 < edgeCount)
98-
throw new IllegalStateException("Cannot create after shortcut was created");
98+
throw new IllegalStateException("Cannot create edge after first shortcut was created");
9999

100100
lastEdgeIndex = edgeCount;
101101
return createEdge(a, b);

core/src/main/java/com/graphhopper/storage/index/LocationIndexTree.java

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -245,27 +245,6 @@ public int findID( double lat, double lon )
245245
return res.getClosestNode();
246246
}
247247

248-
@Override
249-
public boolean loadExisting()
250-
{
251-
if (initialized)
252-
throw new IllegalStateException("Call loadExisting only once");
253-
254-
if (!dataAccess.loadExisting())
255-
return false;
256-
257-
if (dataAccess.getHeader(0) != MAGIC_INT)
258-
throw new IllegalStateException("incorrect location2id index version, expected:" + MAGIC_INT);
259-
260-
if (dataAccess.getHeader(1 * 4) != calcChecksum())
261-
throw new IllegalStateException("location2id index was opened with incorrect graph");
262-
263-
setMinResolutionInMeter(dataAccess.getHeader(2 * 4));
264-
prepareAlgo();
265-
initialized = true;
266-
return true;
267-
}
268-
269248
@Override
270249
public LocationIndex setResolution( int minResolutionInMeter )
271250
{
@@ -292,10 +271,32 @@ public LocationIndexTree create( long size )
292271
throw new UnsupportedOperationException("Not supported. Use prepareIndex instead.");
293272
}
294273

274+
@Override
275+
public boolean loadExisting()
276+
{
277+
if (initialized)
278+
throw new IllegalStateException("Call loadExisting only once");
279+
280+
if (!dataAccess.loadExisting())
281+
return false;
282+
283+
if (dataAccess.getHeader(0) != MAGIC_INT)
284+
throw new IllegalStateException("incorrect location2id index version, expected:" + MAGIC_INT);
285+
286+
if (dataAccess.getHeader(1 * 4) != calcChecksum())
287+
throw new IllegalStateException("location2id index was opened with incorrect graph: "
288+
+ dataAccess.getHeader(1 * 4) + " vs. " + calcChecksum());
289+
290+
setMinResolutionInMeter(dataAccess.getHeader(2 * 4));
291+
prepareAlgo();
292+
initialized = true;
293+
return true;
294+
}
295+
295296
@Override
296297
public void flush()
297298
{
298-
dataAccess.setHeader(0, MAGIC_INT);
299+
dataAccess.setHeader(0, MAGIC_INT);
299300
dataAccess.setHeader(1 * 4, calcChecksum());
300301
dataAccess.setHeader(2 * 4, minResolutionInMeter);
301302

@@ -331,6 +332,7 @@ public LocationIndex prepareIndex()
331332
+ ", leafs:" + Helper.nf(inMem.leafs)
332333
+ ", precision:" + minResolutionInMeter
333334
+ ", depth:" + entries.length
335+
+ ", checksum:" + calcChecksum()
334336
+ ", entries:" + Arrays.toString(entries)
335337
+ ", entriesPerLeaf:" + entriesPerLeaf);
336338

0 commit comments

Comments
 (0)