Hi

Thanks for your work on this.

I now believe that the shield code should not strongly affect the sort
order, whereas before I thought they did.

Could you try the attached patch please.

..Steve

Index: src/uk/me/parabola/imgfmt/app/Label.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/Label.java	(revision 1650)
+++ src/uk/me/parabola/imgfmt/app/Label.java	(revision )
@@ -56,10 +56,6 @@
 		return text;
 	}
 
-	public String getTextSansGarminCodes() {
-		return stripGarminCodes(text);
-	}
-
 	// highway shields and "thin" separators
 	private final static Pattern SHIELDS = Pattern.compile("[\u0001-\u0006\u001b-\u001c]");
 
Index: src/uk/me/parabola/imgfmt/app/srt/Sort.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/srt/Sort.java	(revision 1873)
+++ src/uk/me/parabola/imgfmt/app/srt/Sort.java	(revision )
@@ -94,21 +94,29 @@
 			byte[] bval = out.array();
 			byte[] key = new byte[bval.length * 3 + 3];
 			int length = bval.length;
-			for (int i = 0; i < length; i++) {
-				int b = bval[i] & 0xff;
-				key[i] = primary[b];
-				key[length + 1 + i] = secondary[b];
-				key[2*length + 2 + i] = tertiary[b];
-			}
-			key[length] = 0;
-			key[2 * length + 1] = 0;
-			key[3 * length + 2] = 0;
+
+			int start = fillKey(primary, bval, key, 0);
+			start = fillKey(secondary, bval, key, start);
+			fillKey(tertiary, bval, key, start);
+
 			return new SrtSortKey<T>(object, key, second);
 		} catch (CharacterCodingException e) {
 			return new SrtSortKey<T>(object, ZERO_KEY);
 		}
 	}
 
+	private int fillKey(byte[] sortMap, byte[] input, byte[] outKey, int start) {
+		int index = start;
+		for (byte inb : input) {
+			int b = inb & 0xff;
+			if (sortMap[b] != 0)
+				outKey[index++] = sortMap[b];
+		}
+
+		outKey[index++] = '\0';
+		return index;
+	}
+
 	public <T> SortKey<T> createSortKey(T object, String s) {
 		return createSortKey(object, s, 0);
 	}
Index: src/uk/me/parabola/imgfmt/app/net/NETFile.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/net/NETFile.java	(revision 1870)
+++ src/uk/me/parabola/imgfmt/app/net/NETFile.java	(revision )
@@ -71,8 +71,7 @@
 				Label[] l = rd.getLabels();
 				for(int i = 0; i < l.length && l[i] != null; ++i) {
 					if(l[i].getLength() != 0) {
-						String cleanName = l[i].getTextSansGarminCodes();
-						SortKey<LabeledRoadDef> sortKey = sort.createSortKey(new LabeledRoadDef(l[i], rd), cleanName);
+						SortKey<LabeledRoadDef> sortKey = sort.createSortKey(new LabeledRoadDef(l[i], rd), l[i].getText());
 						sortKeys.add(sortKey);
 					}
 				}
@@ -107,7 +106,7 @@
 		List<LabeledRoadDef> out = new ArrayList<LabeledRoadDef>(in.size());
 		while(!in.isEmpty()) {
 			LabeledRoadDef firstLabeledRoadDef = in.get(0).getObject();
-			String name0 = firstLabeledRoadDef.label.getTextSansGarminCodes();
+			String name0 = firstLabeledRoadDef.label.getText();
 			RoadDef road0 = firstLabeledRoadDef.roadDef;
 
 			City city0 = road0.getCity();
@@ -119,7 +118,7 @@
 			// firstly determine the entries whose name and city match
 			// name0 and city0
 			for(n = 0; (n < in.size() &&
-						name0.equalsIgnoreCase(in.get(n).getObject().label.getTextSansGarminCodes()) &&
+						name0.equalsIgnoreCase(in.get(n).getObject().label.getText()) &&
 						city0 == in.get(n).getObject().roadDef.getCity()); ++n) {
 				// relax
 			}
Index: src/uk/me/parabola/imgfmt/app/mdr/MDRFile.java
===================================================================
--- src/uk/me/parabola/imgfmt/app/mdr/MDRFile.java	(revision 1870)
+++ src/uk/me/parabola/imgfmt/app/mdr/MDRFile.java	(revision )
@@ -203,7 +203,8 @@
 			String cleanName = cleanUpName(name);
 			int strOff = createString(cleanName);
 
-			// XXX not sure: we sort on the dirty name (ie with the Garmin shield codes).
+			// We sort on the dirty name (ie with the Garmin shield codes) although those codes do not
+			// affect the sort order. The string for mdr15 does not include the shield codes.
 			mdr7.addStreet(currentMap, name, lab.getOffset(), strOff, mdrCity);
 		}
 	}
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to