logo separator

[mkgmap-dev] [PATCH] make gps report correct exit when routing through roundabouts

From Robert Vollmert rvollmert-lists at gmx.net on Wed Feb 11 16:19:03 GMT 2009

On Feb 11, 2009, at 16:51, Robert Vollmert wrote:

> On Feb 11, 2009, at 16:17, Mark Burton wrote:
>> Robert (or anyone else that knows), is this exception caused by  
>> points being
>> too close together? The code in BitWriter.java that's barfing is:
>>
>> 	public void putn(int bval, int nb) {
>> 		int val = bval & ((1<<nb) - 1);
>> 		int n = nb;
>>
>> 		// We need to be able to deal with more than 24 bits, but now we  
>> can't yet
>> 		if (n >= 24)
>> 			throw new IllegalArgumentException();
>>
>>
>> If so, what's the minimum distance between points?
>>
>> If not, can you say why it needs 24 bits or more?
>
> I don't know the BitWriter code, or why the limit of 24 bits.
>
> These bit streams come from LinePreparer, and each putn should  
> correspond to one latitude or longitude delta between adjacent  
> coordinates in a polyline. 24 bits seems quite large for a delta.
>
> A large delta should correspond to a large distance between  
> coordinates, but since 2**24 map units is 360 degrees, this limit  
> shouldn't really be reached.
>
> Perhaps it's some bug close to longitude 0?

Something along these lines might help (doesn't as is, but no time):

Index: src/uk/me/parabola/imgfmt/app/trergn/LinePreparer.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/trergn/LinePreparer.java	(revision  
833)
+++ src/uk/me/parabola/imgfmt/app/trergn/LinePreparer.java	(working  
copy)
@@ -200,8 +200,11 @@
  				continue;
  			}

-			int dx = lon - lastLong;
-			int dy = lat - lastLat;
+			// calculate normalized differences
+			int dx = (lon - lastLong) % (1 << (24-shift))
+					- (1 << (23-shift));
+			int dy = (lat - lastLat) % (1 << (24-shift))
+					- (1 << (23-shift));

  			lastLong = lon;
  			lastLat = lat;

Cheers
Robert




More information about the mkgmap-dev mailing list