Re: [mkgmap-dev] Possible fix for "evil forest" crash

2009-09-06 Thread Mark Burton

Felix,
  
> I was all the time using it without problems. I don't know whether there 
> have been improvements, but nothing became worse in any case. I 
> subjectively think map panning got a tiny bit quicker, but might be 
> mistaken.

Ok, good.

If the patch is working right, it should be reducing the number of
subdivisions being created so it may well make map display a little
quicker.

Cheers,

Mark
___
mkgmap-dev mailing list
mkgmap-dev@lists.mkgmap.org.uk
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev


Re: [mkgmap-dev] Possible fix for "evil forest" crash

2009-09-06 Thread Felix Hartmann



Mark Burton wrote:

Yeah great, Finally fixed.
I could not find any errors in the map.



That's good.

The problem was that a polygon was being generated that only
contained 2 points. The more recent mapsource versions must
ignore degenerate polygons (and lines as well, presumably) but the
older mapsource and at least some gps units barfed.

I have committed the fix.

I am still looking to get some feedback on the subdiv fixes patch I
posted yesterday, please try it out if possible as I believe that they
are an improvement.
  
I was all the time using it without problems. I don't know whether there 
have been improvements, but nothing became worse in any case. I 
subjectively think map panning got a tiny bit quicker, but might be 
mistaken.

Cheers,

Mark
___
mkgmap-dev mailing list
mkgmap-dev@lists.mkgmap.org.uk
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
  
___
mkgmap-dev mailing list
mkgmap-dev@lists.mkgmap.org.uk
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Re: [mkgmap-dev] Possible fix for "evil forest" crash

2009-09-06 Thread Mark Burton

> Yeah great, Finally fixed.
> I could not find any errors in the map.

That's good.

The problem was that a polygon was being generated that only
contained 2 points. The more recent mapsource versions must
ignore degenerate polygons (and lines as well, presumably) but the
older mapsource and at least some gps units barfed.

I have committed the fix.

I am still looking to get some feedback on the subdiv fixes patch I
posted yesterday, please try it out if possible as I believe that they
are an improvement.

Cheers,

Mark
___
mkgmap-dev mailing list
mkgmap-dev@lists.mkgmap.org.uk
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev


Re: [mkgmap-dev] Possible fix for "evil forest" crash

2009-09-06 Thread Felix Hartmann



Mark Burton wrote:

Hi Felix,

Please try the attached patch on the original tile and see if it fixes
the problem.

Cheers,

Mark
  



___
mkgmap-dev mailing list
mkgmap-dev@lists.mkgmap.org.uk
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Yeah great, Finally fixed.
I could not find any errors in the map.

I think you should submit that patch, maybe there exist other evil 
places


I had just prepared a supersmall tile for you to work with but 
ironically on that supersmall (max-nodes 2) tile installed alone 
(200kb .img size, 2MB osm unpacked) mapsource would not have problems.
___
mkgmap-dev mailing list
mkgmap-dev@lists.mkgmap.org.uk
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

[mkgmap-dev] Possible fix for "evil forest" crash

2009-09-06 Thread Mark Burton

Hi Felix,

Please try the attached patch on the original tile and see if it fixes
the problem.

Cheers,

Mark
diff --git a/src/uk/me/parabola/imgfmt/app/trergn/LinePreparer.java b/src/uk/me/parabola/imgfmt/app/trergn/LinePreparer.java
index 122d811..9fb07a2 100644
--- a/src/uk/me/parabola/imgfmt/app/trergn/LinePreparer.java
+++ b/src/uk/me/parabola/imgfmt/app/trergn/LinePreparer.java
@@ -68,7 +68,7 @@ class LinePreparer {
 	 *
 	 * @return A class containing the writen byte stream.
 	 */
-	public BitWriter makeBitStream() {
+	public BitWriter makeBitStream(int minPointsRequired) {
 
 		assert xBase >= 0 && yBase >= 0;
 
@@ -117,12 +117,15 @@ class LinePreparer {
 		if (extraBit)
 			bw.put1(false);
 
+		int numPointsEncoded = 1;
 		for (int i = 0; i < deltas.length; i+=2) {
 			int dx = deltas[i];
 			int dy = deltas[i + 1];
 			if (dx == 0 && dy == 0)
 continue;
 			
+			++numPointsEncoded;
+
 			if (log.isDebugEnabled())
 log.debug("x delta", dx, "~", xbits);
 			assert dx >> xbits == 0 || dx >> xbits == -1;
@@ -154,6 +157,10 @@ class LinePreparer {
 
 		if (log.isDebugEnabled())
 			log.debug(bw);
+
+		if(numPointsEncoded < minPointsRequired)
+			return null;
+
 		return bw;
 	}
 
diff --git a/src/uk/me/parabola/imgfmt/app/trergn/Polyline.java b/src/uk/me/parabola/imgfmt/app/trergn/Polyline.java
index b52774c..66a913c 100644
--- a/src/uk/me/parabola/imgfmt/app/trergn/Polyline.java
+++ b/src/uk/me/parabola/imgfmt/app/trergn/Polyline.java
@@ -78,17 +78,17 @@ public class Polyline extends MapObject {
 	 * @param file A reference to the file that should be written to.
 	 */
 	public void write(ImgFileWriter file) {
-		// If there is nothing to do, then do nothing.
-		if (points.size() < 2) {
-			log.debug("less than two points, not writing");
-			return;
-		}
 
 		// Prepare for writing by doing all the required calculations.
 
 		// Prepare the information that we need.
 		LinePreparer w = new LinePreparer(this);
-		BitWriter bw = w.makeBitStream();
+		int minPointsRequired = (this instanceof Polygon)? 3 : 2;
+		BitWriter bw = w.makeBitStream(minPointsRequired);
+		if(bw == null) {
+			log.warn("Encoded " + ((this instanceof Polygon)? "polygon" : "polyline") + " has less than " + minPointsRequired + " points, discarding");
+			return;
+		}
 
 		// The type of feature, also contains a couple of flags hidden inside.
 		byte b1 = (byte) getType();
@@ -149,6 +149,18 @@ public class Polyline extends MapObject {
 		int labelOff = getLabel().getOffset();
 		byte[] extraBytes = getExtTypeExtraBytes();
 
+		// need to prepare line info before outputing lat/lon
+		LinePreparer w = new LinePreparer(this);
+		int minPointsRequired = (this instanceof Polygon)? 3 : 2;
+		BitWriter bw = w.makeBitStream(minPointsRequired);
+		if(bw == null) {
+			log.warn("Encoded " + ((this instanceof Polygon)? "polygon" : "polyline") + " has less than " + minPointsRequired + " points, discarding");
+			return;
+		}
+		int blen = bw.getLength();
+		assert blen > 1 : "zero length bitstream";
+		assert blen < 0x1 : "bitstream too long " + blen;
+
 		if(labelOff != 0)
 			type |= 0x20;		// has label
 		if(extraBytes != null)
@@ -156,13 +168,6 @@ public class Polyline extends MapObject {
 		stream.write(type >> 8);
 		stream.write(type);
 
-		// need to prepare line info before outputing lat/lon
-		LinePreparer w = new LinePreparer(this);
-		BitWriter bw = w.makeBitStream();
-		int blen = bw.getLength();
-		assert blen > 1 : "zero length bitstream";
-		assert blen < 0x1 : "bitstream too long " + blen;
-
 		int deltaLong = getDeltaLong();
 		int deltaLat = getDeltaLat();
 		stream.write(deltaLong);
___
mkgmap-dev mailing list
mkgmap-dev@lists.mkgmap.org.uk
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev