Skip to content

Commit 086c634

Browse files
committed
Location index will not wrap around anymore; fixes graphhopper#2556
1 parent 548f446 commit 086c634

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,11 @@ public void findEdgeIdsInNeighborhood(double queryLat, double queryLon, int iter
237237
int subqueryY = y + yreg;
238238
int subqueryXA = x - iteration;
239239
int subqueryXB = x + iteration;
240-
if (subqueryXA >= 0 && subqueryY >= 0) { // TODO: Also don't walk off the _other_ side of the grid.
240+
if (subqueryXA >= 0 && subqueryY >= 0 && subqueryXA < indexStructureInfo.getParts() && subqueryY < indexStructureInfo.getParts()) {
241241
long keyPart = keyAlgo.encode(subqueryXA, subqueryY) << (64 - keyAlgo.getBits());
242242
fillIDs(keyPart, foundEntries);
243243
}
244-
if (iteration > 0 && subqueryXB >= 0 && subqueryY >= 0) {
244+
if (iteration > 0 && subqueryXB >= 0 && subqueryY >= 0 && subqueryXB < indexStructureInfo.getParts() && subqueryY < indexStructureInfo.getParts()) {
245245
long keyPart = keyAlgo.encode(subqueryXB, subqueryY) << (64 - keyAlgo.getBits());
246246
fillIDs(keyPart, foundEntries);
247247
}
@@ -251,11 +251,11 @@ public void findEdgeIdsInNeighborhood(double queryLat, double queryLon, int iter
251251
int subqueryX = x + xreg;
252252
int subqueryYA = y - iteration;
253253
int subqueryYB = y + iteration;
254-
if (subqueryX >= 0 && subqueryYA >= 0) {
254+
if (subqueryX >= 0 && subqueryYA >= 0 && subqueryX < indexStructureInfo.getParts() && subqueryYA < indexStructureInfo.getParts()) {
255255
long keyPart = keyAlgo.encode(subqueryX, subqueryYA) << (64 - keyAlgo.getBits());
256256
fillIDs(keyPart, foundEntries);
257257
}
258-
if (subqueryX >= 0 && subqueryYB >= 0) {
258+
if (subqueryX >= 0 && subqueryYB >= 0 && subqueryX < indexStructureInfo.getParts() && subqueryYB < indexStructureInfo.getParts()) {
259259
long keyPart = keyAlgo.encode(subqueryX, subqueryYB) << (64 - keyAlgo.getBits());
260260
fillIDs(keyPart, foundEntries);
261261
}

0 commit comments

Comments
 (0)