fixed java.lang.IndexOutOfBoundsException when first way was without any

nodes.
This commit is contained in:
Pavol Zibrita 2012-07-17 02:00:44 +02:00
parent 13fda484e5
commit 41be54750f
2 changed files with 22 additions and 13 deletions

View file

@ -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());
}
}

View file

@ -32,6 +32,7 @@ public class Multipolygon {
protected IdentityHashMap<Way,List<Way>> outerInnerMapping;
private void addNewPolygonPart(List<Way> polygons, List<Way> closedPolygons, Way newPoly) {
if (!newPoly.getNodes().isEmpty()) {
if (isClosed(newPoly)) {
closedPolygons.add(newPoly); //if closed, put directly to closed polygons
} else if (polygons.isEmpty()) {
@ -44,6 +45,7 @@ public class Multipolygon {
}
//reset the mapping
outerInnerMapping = null;
} //else do nothing
}
private boolean isClosed(Way newPoly) {