Hi Felix,
  
> Ups, sorry, here is the output using logging.properties:
> 
> again broken vs not broken

OK, thanks for those. They are interesting because they differ less
than I expected but in an unexpected way (work that one out!)

I want to double check so please apply v3 of patch (attached) and
recreate the log files for the bad and good styles.

Also, do those styles only differ in the number of polygon styles they
contain or do the number of points and lines change as well?

Thanks,

Mark
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..80db0c9 100644
--- a/src/uk/me/parabola/mkgmap/build/MapArea.java
+++ b/src/uk/me/parabola/mkgmap/build/MapArea.java
@@ -259,6 +259,7 @@ public class MapArea implements MapDataSource {
 			ssize += shapeSize[i];
 		}
 
+		/*
 		// Return the largest one as an overflow of any means that we have to
 		// split the area.
 		int size = psize;
@@ -268,6 +269,8 @@ public class MapArea implements MapDataSource {
 			size = ssize;
 
 		return size;
+		*/
+		return psize + lsize + ssize;
 	}
 
 	/**
@@ -359,6 +362,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..b95b78c 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,34 @@ 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();
+			if(log.isInfoEnabled()) {
+				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
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to