Hi

A bug was reported which I can reproduce with the following stack trace:

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
        at java.util.ArrayList.rangeCheck(ArrayList.java:635)
        at java.util.ArrayList.get(ArrayList.java:411)
at uk.me.parabola.mkgmap.osmstyle.WrongAngleFixer.fixAnglesInShape(WrongAngleFixer.java:1401) at uk.me.parabola.mkgmap.filters.ShapeMergeFilter.merge(ShapeMergeFilter.java:123) at uk.me.parabola.mkgmap.build.MapBuilder.processShapes(MapBuilder.java:1075) at uk.me.parabola.mkgmap.build.MapBuilder.makeSubdivision(MapBuilder.java:740)

This is caused by a shape that consists of many points very close
together eg:

 [2405169/355005, 2405169/355004, 2405169/355004, 2405169/355001,
 2405169/355001, 2405169/355001, 2405164/355001, 2405164/355001,
 2405164/355001, 2405164/355005, 2405164/355009, 2405164/355009,
 2405164/355009, 2405169/355009, 2405169/355009, 2405169/355009,
 2405169/355007, 2405169/355007, 2405169/355005]

This results in the modifiedPoints list inside fixAnglesInShape() to
be empty.  The caller expects an empty list, but the last line that
closes the polygon fails if the list is empty.

The attached patch fixes the crash, but perhaps the situation should
be dealt with differently. Any comments?

..Steve
Index: src/uk/me/parabola/mkgmap/osmstyle/WrongAngleFixer.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/WrongAngleFixer.java	(revision 3334)
+++ src/uk/me/parabola/mkgmap/osmstyle/WrongAngleFixer.java	(revision )
@@ -1396,7 +1396,7 @@
 			}
 			modifiedPoints.add(cm);
 		}
-		if (modifiedPoints.get(0) != modifiedPoints.get(modifiedPoints.size()-1))
+		if (modifiedPoints.size() > 1 && modifiedPoints.get(0) != modifiedPoints.get(modifiedPoints.size()-1))
 			modifiedPoints.add(modifiedPoints.get(0));
 		return modifiedPoints;
 	}
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to