Am 22.02.2012 05:10, schrieb Thorsten Kukuk:

Hi,

On Tue, Feb 21, Ronny Klier wrote:

I had a look for the occurences of sequence format like 1+(1),1+(3) in
OSM and found it used at least in GB, france and spain. Given this wide
usage, this patch allows "," as seperator. Additional (), which mark
phases of eclipse, are handled explicit and not as seperator.

Looks like the patch itself is missing.

Thorsten


Sorry, here it is.
Index: src/uk/me/parabola/imgfmt/app/trergn/ExtTypeAttributes.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/trergn/ExtTypeAttributes.java	(Revision 2221)
+++ src/uk/me/parabola/imgfmt/app/trergn/ExtTypeAttributes.java	(Arbeitskopie)
@@ -439,21 +439,32 @@ 
 
 		if(sequence != null) {
 			StringBuffer periods = new StringBuffer();
-			for(String p : sequence.split("[+()]")) {
-				if (p.isEmpty())
-					continue;
-				if(periods.length() > 0)
-					periods.append(",");
-				periods.append(Double.parseDouble(p));
+			StringBuffer eclipse = new StringBuffer();
+			for(String p : sequence.split("[+,]")) {
+				if (p.startsWith("(") && p.endsWith(")")) {
+					// phases of eclipse are enclosed in (), remove them
+					p = p.substring(1, p.length()-1);
+					if(eclipse.length() > 0)
+						eclipse.append(",");
+					eclipse.append(Double.parseDouble(p));
+				} else {
+					if(periods.length() > 0)
+						periods.append(",");
+					periods.append(Double.parseDouble(p));
+				}
 			}
 			attributes.put("period", periods.toString());
+			attributes.put("eclipse", eclipse.toString());
 		}
 
 		if(mapObject instanceof Point) {
 
 			Light[] lights = parseLights(attributes.get("light"));
 			int[] periods = parsePeriods(attributes.get("period"));
-
+			int[] eclipse = parsePeriods(attributes.get("eclipse"));
+			if (1 != periods.length && periods.length != eclipse.length)
+				log.error("number of light and eclipse phases has to be equal");
+			
 			if(type8to15 == 0x0100) { // lights
 				byte flags0 = 0;
 				int lightType = lightType("");
@@ -486,6 +497,13 @@ 
 						}
 						++nob;
 					}
+					for(int p : eclipse) {
+						while(p > 0x3f) {
+							++nob;
+							p -= 0x3f;
+						}
+						++nob;
+					}
 					flags1 |= 0x01; // further record present?
 				}
 				else if(morseLetter != null)
@@ -531,6 +549,8 @@ 
 				int period = 0;
 				for(int p : periods)
 					period += p;
+				for(int p : eclipse)
+					period += p;
 				if(period > 255)
 					lightType |= 0x40; // 9th bit of period
 				else if(period > 511) {
@@ -599,22 +619,22 @@ 
 					extraBytes[i++] = (byte)((lc << 5) | lr);
 				}
 				if(periods.length > 1) {
-					extraBytes[i++] = (byte)(0x80 + periods.length / 2);
+					extraBytes[i++] = (byte)(0x80 + periods.length);
 					// first all lights
-					for (int pi = 0; pi < periods.length; pi+=2) {
-						while(periods[pi] > 0x3f) {
+					for (int p : periods) {
+						while(p > 0x3f) {
 							extraBytes[i++] = (byte)0x3f;
-							periods[pi] -= 0x3f;
+							p -= 0x3f;
 						}
-						extraBytes[i++] = (byte)periods[pi];
+						extraBytes[i++] = (byte)p;
 					}
 					// second all pause
-					for (int pi = 1; pi < periods.length; pi+=2) {
-						while(periods[pi] > 0x3f) {
+					for (int p : eclipse) {
+						while(p > 0x3f) {
 							extraBytes[i++] = (byte)0x3f;
-							periods[pi] -= 0x3f;
+							p -= 0x3f;
 						}
-						extraBytes[i++] = (byte)periods[pi];
+						extraBytes[i++] = (byte)p;
 					}
 				}
 				else if(morseLetter != null)
_______________________________________________
mkgmap-dev mailing list
mkgmap-dev@lists.mkgmap.org.uk
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to