Fixed null pointer exception

This commit is contained in:
Pavol Zibrita 2012-09-26 18:27:51 +02:00
parent 80ad668b99
commit 5bbd882e47

View file

@ -111,39 +111,22 @@ public class Ring implements Comparable<Ring> {
if ((w.getNodes() == null || w.getNodes().size() == 0) && if ((w.getNodes() == null || w.getNodes().size() == 0) &&
!unInitializedNodes) continue; !unInitializedNodes) continue;
Way newWay = null; // merge the Way w with the first borderway suitable, repeat until nothing can be merged
Way addedTo = null; Way wayToMerge = w;
// merge the Way w with the first borderway suitable; Way newWay;
for (Way borderWay : borderWays) { do {
newWay = combineTwoWaysIfHasPoints(w, borderWay); newWay = null;
if(newWay != null) {
addedTo = borderWay;
}
}
if (newWay == null) {
// no suitable borderWay has been found, add this way as one of the boundaries
borderWays.add(w);
} else {
// ways are combined, remove the original borderway
borderWays.remove(addedTo);
addedTo = null;
// search if it can be combined with something else
for (Way borderWay : borderWays) { for (Way borderWay : borderWays) {
newWay = combineTwoWaysIfHasPoints(newWay, borderWay); newWay = combineTwoWaysIfHasPoints(wayToMerge, borderWay);
if(newWay != null) { if(newWay != null) {
addedTo = borderWay; wayToMerge = newWay;
borderWays.remove(borderWay);
break;
} }
} }
} while (newWay != null);
if (addedTo != null) { //no suitable borderWay has been found, add this way as one of the boundaries
// newWay has enlarged a second time borderWays.add(wayToMerge);
borderWays.remove(addedTo);
}
// newWay is now a concatenation of 2 or 3 ways, needs to be added to the borderWays
borderWays.add(newWay);
}
} }
if (borderWays.size() != 1) { if (borderWays.size() != 1) {