This v2 patch makes "squarer" subdivisions than v1 - otherwise works
the same.
diff --git a/src/uk/me/parabola/imgfmt/app/trergn/RGNFile.java b/src/uk/me/parabola/imgfmt/app/trergn/RGNFile.java
index f0300e8..5c0dc77 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("Too many items in indexed points section");
+				throw new IllegalStateException("IndPoint offset too large");
 
 			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("Too many items in polyline section");
+				throw new IllegalStateException("Polyline offset too large");
 
 			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("Too many items in the polygon section");
+				throw new IllegalStateException("Polygon offset too large");
 
 			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 137de17..3bc60cc 100644
--- a/src/uk/me/parabola/mkgmap/build/MapArea.java
+++ b/src/uk/me/parabola/mkgmap/build/MapArea.java
@@ -359,6 +359,13 @@ public class MapArea implements MapDataSource {
 	}
 
 	/**
+	 * Return number of shapes in this area.
+	 */
+	public int getNumShapes() {
+		return nActiveShapes;
+	}
+
+	/**
 	 * Return number of points in this area.
 	 */
 	public int getNumPoints() {
diff --git a/src/uk/me/parabola/mkgmap/build/MapSplitter.java b/src/uk/me/parabola/mkgmap/build/MapSplitter.java
index ac490df..e714fde 100644
--- a/src/uk/me/parabola/mkgmap/build/MapSplitter.java
+++ b/src/uk/me/parabola/mkgmap/build/MapSplitter.java
@@ -51,6 +51,9 @@ class MapSplitter {
 	// The maximum number of lines. NET points to lines in subdivision
 	// using bytes.
 	// Theoretical maximum about 0x100, which still gives errors.
+	// mb 4/9/2009 - I think this is because the number of lines doesn't take
+	// into account the fact that the lines can be subsequently split
+	// by the line filters which increases the number
 	private static final int MAX_NUM_LINES = 0xf0;
 
 	private static final int MAX_NUM_POINTS = 0xff;
@@ -94,7 +97,7 @@ class MapSplitter {
 		// in them.  For those that do, we further split them.  This is done
 		// recursively until everything fits.
 		List<MapArea> alist = new ArrayList<MapArea>();
-		addAreasToList(areas, alist);
+		addAreasToList(areas, alist, 0);
 
 		MapArea[] results = new MapArea[alist.size()];
 		return alist.toArray(results);
@@ -109,17 +112,32 @@ class MapSplitter {
 	 * @param alist The list that will finally contain the complete list of
 	 * map areas.
 	 */
-	private void addAreasToList(MapArea[] areas, List<MapArea> alist) {
+	private void addAreasToList(MapArea[] areas, List<MapArea> alist, int depth) {
 		int res = zoom.getResolution();
 		for (MapArea area : areas) {
+			Area bounds = area.getBounds();
+			String padding = "                                            ";
+			log.info(padding.substring(0, depth * 2) + 
+					 bounds.getWidth() + "x" + bounds.getHeight() +
+					 ", res = " + res +
+					 ", depth = " + depth +
+					 ", size = " + area.getSizeAtResolution(res) +
+					 ", lines = " + area.getNumLines() +
+					 ", shapes = " + area.getNumShapes() +
+					 ", points = " + area.getNumPoints());
+
 			if (area.getSizeAtResolution(res) > MAX_RGN_SIZE
 			    || area.getNumLines() > MAX_NUM_LINES
 			    || area.getNumPoints() > MAX_NUM_POINTS) {
 				if (area.getBounds().getMaxDimention() > 100) {
 					if (log.isDebugEnabled())
 						log.debug("splitting area", area);
-					MapArea[] sublist = area.split(2, 2, res);
-					addAreasToList(sublist, alist);
+					MapArea[] sublist;
+					if(bounds.getWidth() > bounds.getHeight())
+						sublist = area.split(2, 1, res);
+					else
+						sublist = area.split(1, 2, res);
+					addAreasToList(sublist, alist, depth + 1);
 					continue;
 				} else {
 					log.warn("area too small to split", area);
_______________________________________________
mkgmap-dev mailing list
mkgmap-dev@lists.mkgmap.org.uk
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to