Index: src/uk/me/parabola/imgfmt/app/net/RoadDef.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/net/RoadDef.java	(revision 4566)
+++ src/uk/me/parabola/imgfmt/app/net/RoadDef.java	(working copy)
@@ -62,6 +62,7 @@
 public class RoadDef {
 	private static final Logger log = Logger.getLogger(RoadDef.class);
 	public static final int MAX_NUMBER_NODES = 0x3ff; 
+	public static final int MAX_NUMBER_POLYLINES = 0x7f; 
 
 	public static final int NET_FLAG_NODINFO  = 0x40;
 	public static final int NET_FLAG_ADDRINFO = 0x10;
@@ -335,7 +336,8 @@
 		for (int i = 0; i <= maxlevel; i++) {
 			List<RoadIndex> l = roadIndexes.get(i);
 			int b = (l == null) ? 0 : l.size();
-			assert b < 0x80 : "too many polylines at level " + i;
+			if (b > MAX_NUMBER_POLYLINES)
+				throw new MapFailedException("Too many polylines for road " + this + " at level " + i);
 			if (i == maxlevel)
 				b |= 0x80;
 			writer.put1u(b);
Index: src/uk/me/parabola/mkgmap/build/MapSplitter.java
===================================================================
--- src/uk/me/parabola/mkgmap/build/MapSplitter.java	(revision 4566)
+++ src/uk/me/parabola/mkgmap/build/MapSplitter.java	(working copy)
@@ -140,9 +140,9 @@
 				String padding = depth + "                                                                      ";
 				log.info(padding.substring(0, (depth + 1) * 2) + 
 						 bounds.getWidth() + "x" + bounds.getHeight() +
-						 ", points = " + area.getNumPoints() + "/" + sizes[MapArea.POINT_KIND] +
-						 ", lines = " + area.getNumLines() + "/" + sizes[MapArea.LINE_KIND] +
-						 ", shapes = " + area.getNumShapes() + "/" + sizes[MapArea.SHAPE_KIND]);
+						 ", points = " + area.getNumPoints() + "/" + sizes[MapArea.POINT_KIND] + "/" + sizes[MapArea.XT_POINT_KIND] +
+						 ", lines = " + area.getNumLines() + "/" + sizes[MapArea.LINE_KIND] + "/" + sizes[MapArea.XT_LINE_KIND] +
+						 ", shapes = " + area.getNumShapes() + "/" + sizes[MapArea.SHAPE_KIND] + "/" + sizes[MapArea.XT_SHAPE_KIND]);
 			}
 
 			boolean wantSplit = false;
Index: src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java	(revision 4566)
+++ src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java	(working copy)
@@ -42,11 +42,13 @@
 import uk.me.parabola.imgfmt.app.Label;
 import uk.me.parabola.imgfmt.app.net.AccessTagsAndBits;
 import uk.me.parabola.imgfmt.app.net.GeneralRouteRestriction;
+import uk.me.parabola.imgfmt.app.net.RoadDef;
 import uk.me.parabola.imgfmt.app.trergn.ExtTypeAttributes;
 import uk.me.parabola.imgfmt.app.trergn.MapObject;
 import uk.me.parabola.log.Logger;
 import uk.me.parabola.mkgmap.build.LocatorConfig;
 import uk.me.parabola.mkgmap.filters.LineSizeSplitterFilter;
+import uk.me.parabola.mkgmap.filters.LineSplitterFilter;
 import uk.me.parabola.mkgmap.general.AreaClipper;
 import uk.me.parabola.mkgmap.general.Clipper;
 import uk.me.parabola.mkgmap.general.LineAdder;
@@ -108,6 +110,10 @@
 
 	// limit arc lengths to what can be handled by RouteArc
 	private static final int MAX_ARC_LENGTH = 20450000; // (1 << 22) * 16 / 3.2808 ~ 20455030*/
+	
+	// limit number of points so that a single road doesn't have too many polylines 
+	private static final int MAX_ROAD_POINTS = (RoadDef.MAX_NUMBER_POLYLINES - 2) * LineSplitterFilter.MAX_POINTS_IN_LINE; 
+	
 
 	/** Number of routing nodes in way, possibly could be increased, not a hard limit in IMG format.
 	 * See also RoadDef.MAX_NUMBER_NODES. 
@@ -1723,7 +1729,13 @@
 				
 				wayBBox.addPoint(nextP);
 
-				if ((arcLength + d) > MAX_ARC_LENGTH) {
+				if (i >= MAX_ROAD_POINTS) {
+					trailingWay = splitWayAt(way, i);
+					// this will have truncated the current Way's
+					// points so the loop will now terminate
+					if (log.isInfoEnabled())
+						log.info("Splitting way", debugWayName, "at", points.get(i).toOSMURL(), "to limit the total number of points");
+				} else if ((arcLength + d) > MAX_ARC_LENGTH) {
 					if (i <= 0)
 						log.error("internal error: long arc segment was not split", debugWayName);
 					assert i > 0 : "long arc segment was not split";
