Hi Felix,

> Well one thing that this patch makes, is much much bigger filesize 
> (around 30% increase).

To be expected.

> Furthermore it really crashes Mapsource. Not even possible to move out 
> anymore.

Hmm, not so expected.

> After panning around a bit and choosing a well working zoomscale, 
> Mapsource moves not to the well working one, but out at 1000km
> 
> 
> 
> After panning around at 7km just one step before the "critical" 5km 
> Mapsource crashed completely: Crashlog (mapsourcecrash.txt) is attached.
> If there is no huge error in this patch, it was the worst that ever 
> happened.
> 
> Also now Mapsource 6.15.6 shows no more tile and eventually crashes. 
> mapsource 6.15.6 crashlog is attached too.
> 
> 
> 
> Maybe reversing the patch and increasing subdivision size would help?

That's an interesting idea - the attached patch should reduce the
number of subdivisions - the original code split a subdivision into 4
pieces when it needed splitting. This patch splits it into 2. See what
happens!

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 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..ec605df 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,7 +112,7 @@ 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) {
 			if (area.getSizeAtResolution(res) > MAX_RGN_SIZE
@@ -118,14 +121,27 @@ class MapSplitter {
 				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((depth & 1) != 0)
+						sublist = area.split(1, 2, res);
+					else
+						sublist = area.split(2, 1, res);
+					addAreasToList(sublist, alist, depth + 1);
 					continue;
 				} else {
 					log.warn("area too small to split", area);
 				}
 			}
 
+			//			if(log.isInfoEnabled())
+			log.info("Adding " + area.getBounds().getWidth() +
+					 "x" + area.getBounds().getHeight() +
+					 " area (res = " + res +
+					 ", depth = " + depth +
+					 ", size = " + area.getSizeAtResolution(res) +
+					 ", lines = " + area.getNumLines() +
+					 ", shapes = " + area.getNumShapes() +
+					 ", points = " + area.getNumPoints() + ")");
 			log.debug("adding area unsplit", ",has points" + area.hasPoints());
 
 			MapArea[] sublist = area.split(1, 1, res);
_______________________________________________
mkgmap-dev mailing list
mkgmap-dev@lists.mkgmap.org.uk
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to