Hi Paul,

> I've just updated to the latest mkgmap from trunk and am now having
> problems processing tiles that I have previously successfully processed.
> The error I am receiving is
> 
> java.lang.IllegalStateException: Polygon offset too large

Please try attached patch.

Cheers,

Mark

diff --git a/src/uk/me/parabola/imgfmt/app/trergn/RGNFile.java b/src/uk/me/parabola/imgfmt/app/trergn/RGNFile.java
index 5c0dc77..3138302 100644
--- a/src/uk/me/parabola/imgfmt/app/trergn/RGNFile.java
+++ b/src/uk/me/parabola/imgfmt/app/trergn/RGNFile.java
@@ -147,7 +147,7 @@ public class RGNFile extends ImgFile {
 			position(indPointPtrOff);
 			long off = currPos - currentDivision.getRgnPointer() - HEADER_LEN;
 			if (off > 0xffff)
-				throw new IllegalStateException("IndPoint offset too large");
+				throw new IllegalStateException("IndPoint offset too large: " + off);
 
 			getWriter().putChar((char) off);
 			position(currPos);
@@ -160,7 +160,7 @@ public class RGNFile extends ImgFile {
 			position(polylinePtrOff);
 			long off = currPos - currentDivision.getRgnPointer() - HEADER_LEN;
 			if (off > 0xffff)
-				throw new IllegalStateException("Polyline offset too large");
+				throw new IllegalStateException("Polyline offset too large: " + off);
 
 			if (log.isDebugEnabled())
 				log.debug("setting polyline offset to", off);
@@ -176,7 +176,7 @@ public class RGNFile extends ImgFile {
 			long off = currPos - currentDivision.getRgnPointer() - HEADER_LEN;
 			log.debug("currpos=", currPos, ", off=", off);
 			if (off > 0xffff)
-				throw new IllegalStateException("Polygon offset too large");
+				throw new IllegalStateException("Polygon offset too large: " + off);
 
 			if (log.isDebugEnabled())
 				log.debug("setting polygon offset to ", off, " @", polygonPtrOff);
diff --git a/src/uk/me/parabola/mkgmap/build/MapArea.java b/src/uk/me/parabola/mkgmap/build/MapArea.java
index 7fd0da0..e772dbe 100644
--- a/src/uk/me/parabola/mkgmap/build/MapArea.java
+++ b/src/uk/me/parabola/mkgmap/build/MapArea.java
@@ -398,7 +398,8 @@ public class MapArea implements MapDataSource {
 			return;
 
 		int s;
-		int n;
+		int numPoints;
+		int numElements;
 
 		switch (kind) {
 		case POINT_KIND:
@@ -416,18 +417,20 @@ public class MapArea implements MapDataSource {
 		case LINE_KIND:
 			// Estimate the size taken by lines and shapes as a constant plus
 			// a factor based on the number of points.
-			n = ((MapLine) p).getPoints().size();
-			s = 11 + n * 2;
+			numPoints = ((MapLine) p).getPoints().size();
+			numElements = 1 + ((numPoints - 1) / LineSplitterFilter.MAX_POINTS_IN_LINE);
+			s = numElements * 11 + numPoints * 2;
 			if (res <= areaResolution)
-				nActiveLines += 1 + ((n - 1) / LineSplitterFilter.MAX_POINTS_IN_LINE);
+				nActiveLines += numElements;
 			break;
 		case SHAPE_KIND:
 			// Estimate the size taken by lines and shapes as a constant plus
 			// a factor based on the number of points.
-			n = ((MapLine) p).getPoints().size();
-			s = 11 + n * 2;
+			numPoints = ((MapLine) p).getPoints().size();
+			numElements = 1 + ((numPoints - 1) / PolygonSplitterFilter.MAX_POINT_IN_ELEMENT);
+			s = numElements * 11 + numPoints * 2;
 			if (res <= areaResolution)
-				nActiveShapes += 1 + ((n - 1) / PolygonSplitterFilter.MAX_POINT_IN_ELEMENT);
+				nActiveShapes += numElements;
 			break;
 
 		default:
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to