fixed java.lang.IndexOutOfBoundsException when first way was without any
nodes.
This commit is contained in:
parent
13fda484e5
commit
41be54750f
2 changed files with 22 additions and 13 deletions
|
@ -168,6 +168,13 @@ public class MultipolygonTest {
|
|||
assertFalse(testee.hasOpenedPolygons());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void test_firstEmptyWayThanOpenedWay()
|
||||
{
|
||||
testee.addOuterWay(new Way(111));
|
||||
testee.addOuterWay(poly1_1_of_2);
|
||||
assertEquals(1, testee.countOuterPolygons());
|
||||
assertTrue(testee.hasOpenedPolygons());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,18 +32,20 @@ public class Multipolygon {
|
|||
protected IdentityHashMap<Way,List<Way>> outerInnerMapping;
|
||||
|
||||
private void addNewPolygonPart(List<Way> polygons, List<Way> closedPolygons, Way newPoly) {
|
||||
if (isClosed(newPoly)) {
|
||||
closedPolygons.add(newPoly); //if closed, put directly to closed polygons
|
||||
} else if (polygons.isEmpty()) {
|
||||
polygons.add(newPoly); //if open, and first, put to polygons..
|
||||
} else {
|
||||
// now we try to merge the ways to form bigger polygons
|
||||
Stack<Way> wayStack = new Stack<Way>();
|
||||
wayStack.push(newPoly);
|
||||
addAndMergePolygon(polygons, closedPolygons, wayStack);
|
||||
}
|
||||
//reset the mapping
|
||||
outerInnerMapping = null;
|
||||
if (!newPoly.getNodes().isEmpty()) {
|
||||
if (isClosed(newPoly)) {
|
||||
closedPolygons.add(newPoly); //if closed, put directly to closed polygons
|
||||
} else if (polygons.isEmpty()) {
|
||||
polygons.add(newPoly); //if open, and first, put to polygons..
|
||||
} else {
|
||||
// now we try to merge the ways to form bigger polygons
|
||||
Stack<Way> wayStack = new Stack<Way>();
|
||||
wayStack.push(newPoly);
|
||||
addAndMergePolygon(polygons, closedPolygons, wayStack);
|
||||
}
|
||||
//reset the mapping
|
||||
outerInnerMapping = null;
|
||||
} //else do nothing
|
||||
}
|
||||
|
||||
private boolean isClosed(Way newPoly) {
|
||||
|
|
Loading…
Reference in a new issue