[Git][debian-gis-team/mkgmap][master] 4 commits: New upstream version 0.0.0+svn4839

Bas Couwenberg (@sebastic) gitlab at salsa.debian.org
Sat Jan 1 07:46:27 GMT 2022



Bas Couwenberg pushed to branch master at Debian GIS Project / mkgmap


Commits:
a64e1e8a by Bas Couwenberg at 2022-01-01T08:39:26+01:00
New upstream version 0.0.0+svn4839
- - - - -
e976e37a by Bas Couwenberg at 2022-01-01T08:39:41+01:00
Update upstream source from tag 'upstream/0.0.0+svn4839'

Update to upstream version '0.0.0+svn4839'
with Debian dir 8c48898703198ac0d254abc3f7361cb79556eb3f
- - - - -
7f801be6 by Bas Couwenberg at 2022-01-01T08:39:55+01:00
New upstream SVN snapshot.

- - - - -
758556a2 by Bas Couwenberg at 2022-01-01T08:40:42+01:00
Set distribution to unstable.

- - - - -


18 changed files:

- debian/changelog
- doc/options.txt
- resources/help/en/options
- resources/mkgmap-version.properties
- src/uk/me/parabola/imgfmt/app/CommonHeader.java
- src/uk/me/parabola/imgfmt/app/labelenc/AnyCharsetEncoder.java
- src/uk/me/parabola/imgfmt/app/labelenc/Format6Decoder.java
- src/uk/me/parabola/imgfmt/app/lbl/LBLFile.java
- src/uk/me/parabola/imgfmt/app/lbl/LBLHeader.java
- src/uk/me/parabola/imgfmt/app/map/Map.java
- src/uk/me/parabola/imgfmt/app/mdr/MDRFile.java
- src/uk/me/parabola/imgfmt/app/net/NETFile.java
- src/uk/me/parabola/imgfmt/app/trergn/ExtTypeAttributes.java
- src/uk/me/parabola/imgfmt/mdxfmt/MdxFile.java
- src/uk/me/parabola/imgfmt/sys/ImgFS.java
- src/uk/me/parabola/mkgmap/CommandArgs.java
- src/uk/me/parabola/mkgmap/osmstyle/actions/HighwaySymbolFilter.java
- src/uk/me/parabola/mkgmap/osmstyle/actions/SubstringFilter.java


Changes:

=====================================
debian/changelog
=====================================
@@ -1,3 +1,9 @@
+mkgmap (0.0.0+svn4839-1) unstable; urgency=medium
+
+  * New upstream SVN snapshot.
+
+ -- Bas Couwenberg <sebastic at debian.org>  Sat, 01 Jan 2022 08:40:33 +0100
+
 mkgmap (0.0.0+svn4821-1) unstable; urgency=medium
 
   * New upstream SVN snapshot.


=====================================
doc/options.txt
=====================================
@@ -218,8 +218,9 @@ It may list 'Rueben Brookins Road' if that is in the map.
 :	See comments in the example roadNameConfig.txt for further details.
 
 ;--mdr7-excl=name[,name...]
-:	Specify words which should be omitted from the road index.
+:	Specify words which should be omitted from the road index. 
 It was developed before option --road-name-config and is probably no longer needed.
+Matching is done case insensitive.
 :	Example usage: --mdr7-excl="Road, Street, Weg"
 
 ;--mdr7-del=name[,name...]
@@ -229,6 +230,7 @@ of a road name / address search. The list is used like this:
 For each road label, mkgmap searches for the last blank. If one is found, it checks
 whether the word after it appears in the given list. If so, the word is removed
 and the search is repeated. The remaining string is used to create the index.
+The search is done case insensitive.
 :	Example: Assume your style adds surface attributes like 'pav.' or 'unp.' to a road
 label. You can use --mdr7-del="pav.,unp." to remove these suffixes from the index.
 


=====================================
resources/help/en/options
=====================================
@@ -218,7 +218,8 @@ filename
 
 --mdr7-excl=name[,name...]
     Specify words which should be omitted from the road index. It was developed
-    before option --road-name-config and is probably no longer needed.
+    before option --road-name-config and is probably no longer needed. Matching
+    is done case insensitive.
     Example usage: --mdr7-excl="Road, Street, Weg"
 
 --mdr7-del=name[,name...]
@@ -228,7 +229,7 @@ filename
     label, mkgmap searches for the last blank. If one is found, it checks
     whether the word after it appears in the given list. If so, the word is
     removed and the search is repeated. The remaining string is used to create
-    the index.
+    the index. The search is done case insensitive.
     Example: Assume your style adds surface attributes like 'pav.' or 'unp.' to
     a road label. You can use --mdr7-del="pav.,unp." to remove these suffixes
     from the index.


=====================================
resources/mkgmap-version.properties
=====================================
@@ -1,2 +1,2 @@
-svn.version: 4821
-build.timestamp: 2021-11-30T13:17:18+0000
+svn.version: 4839
+build.timestamp: 2021-12-30T15:30:14+0000


=====================================
src/uk/me/parabola/imgfmt/app/CommonHeader.java
=====================================
@@ -16,7 +16,7 @@
  */
 package uk.me.parabola.imgfmt.app;
 
-import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
 import java.util.Date;
 
 import uk.me.parabola.imgfmt.ReadFailedException;
@@ -81,11 +81,7 @@ public abstract class CommonHeader {
 		reader.position(0);
 		headerLength = reader.get2u();
 		byte[] bytes = reader.get(TYPE_LEN);
-		try {
-			type = new String(bytes, "ascii");
-		} catch (UnsupportedEncodingException e) {
-			// ascii is supported always, so this can't happen
-		}
+		type = new String(bytes, StandardCharsets.US_ASCII);
 		reader.get(); // ignore
 		reader.get(); // ignore
 


=====================================
src/uk/me/parabola/imgfmt/app/labelenc/AnyCharsetEncoder.java
=====================================
@@ -107,6 +107,8 @@ public class AnyCharsetEncoder extends BaseEncoder implements CharacterEncoder {
 			} else if (result == CoderResult.OVERFLOW) {
 				// Ran out of space in the output
 				outBuf = reallocBuf(outBuf);
+			} else if (result.isMalformed()) {
+				break;
 			}
 		} while (result != CoderResult.UNDERFLOW);
 


=====================================
src/uk/me/parabola/imgfmt/app/labelenc/Format6Decoder.java
=====================================
@@ -1,7 +1,7 @@
 package uk.me.parabola.imgfmt.app.labelenc;
 
 import java.io.ByteArrayOutputStream;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 
 /**
  * Convert the 6-bit label format back to a java string.
@@ -16,8 +16,6 @@ public class Format6Decoder implements CharacterDecoder {
 	private int store;
 	private int nbits;
 
-	private final Charset charset = Charset.forName("ascii");
-
 	public boolean addByte(int in) {
 		int b = 0xff & in; //wipe out high bits (in case of negative byte)
 
@@ -51,7 +49,7 @@ public class Format6Decoder implements CharacterDecoder {
 
 	public DecodedText getText() {
 		byte[] ba = out.toByteArray();
-		DecodedText text = new DecodedText(ba, charset);
+		DecodedText text = new DecodedText(ba, StandardCharsets.US_ASCII);
 
 		assert nbits == 0 || nbits == 8;
 		// If there is a byte left inside the decoder then we have to let our


=====================================
src/uk/me/parabola/imgfmt/app/lbl/LBLFile.java
=====================================
@@ -57,9 +57,12 @@ public class LBLFile extends ImgFile {
 	private final PlacesFile places = new PlacesFile();
 	private Sort sort;
 
-	// Shift value for the label offset, we always use 1 here.
+	/** Shift value for the label offset, we always use 1 here. */
 	private static final int OFFSET_MULTIPLIER = 1;
 
+	/** Garmin software doesn't display longer labels */
+	private static final int MAX_LABEL_LEN = 170;
+
 	public LBLFile(ImgChannel chan, Sort sort) {
 		this.sort = sort;
 		lblHeader.setSort(sort);
@@ -125,10 +128,38 @@ public class LBLFile extends ImgFile {
 	 * Add a new label with the given text.  Labels are shared, so that identical
 	 * text is always represented by the same label.
 	 *
-	 * @param text The text of the label, it will be in uppercase.
-	 * @return A reference to the created label.
+	 * @param text The text of the label
+	 * @return A reference to the created label
 	 */
 	public Label newLabel(String text) {
+		return newLabel(text, true);
+	}
+	
+	/**
+	 * Add a new label with the given text.  Labels are shared, so that identical
+	 * text is always represented by the same label.
+	 *
+	 * @param text The text of the label
+	 * @param cutToMaxLen if true, cut labels to max length
+	 * @return A reference to the created label
+	 */
+	public Label newLabel(String text, boolean cutToMaxLen) {
+		if (text != null && cutToMaxLen && text.length() > MAX_LABEL_LEN) {
+			int trimmedLen;
+			try {
+				trimmedLen = text.offsetByCodePoints(0, MAX_LABEL_LEN);
+			} catch (IndexOutOfBoundsException e) {
+				trimmedLen = 0; // short enough
+			}
+			if (trimmedLen > 0) {
+				do { // logic elsewhere removes leading, trailing and multiple spaces, but now might have trailing; remove multiple anyway
+					--trimmedLen;
+					if (text.charAt(trimmedLen) != ' ')
+						break;
+				} while (trimmedLen > 0);
+				text = text.substring(0, trimmedLen + 1);
+			}
+		}
 		EncodedText encodedText = textEncoder.encodeText(text);
 
 		Label l = labelCache.get(encodedText);


=====================================
src/uk/me/parabola/imgfmt/app/lbl/LBLHeader.java
=====================================
@@ -16,7 +16,7 @@
  */
 package uk.me.parabola.imgfmt.app.lbl;
 
-import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
 
 import uk.me.parabola.imgfmt.app.CommonHeader;
 import uk.me.parabola.imgfmt.app.ImgFileReader;
@@ -85,11 +85,7 @@ public class LBLHeader extends CommonHeader {
 		reader.position(descOff);
 		byte[] bytes = reader.get(descLen);
 		String description;
-		try {
-			description = new String(bytes, "ascii");
-		} catch (UnsupportedEncodingException e) {
-			description = "Unknown";
-		}
+		description = new String(bytes, StandardCharsets.US_ASCII);
 
 		sort = new Sort();
 		sort.setCodepage(codepage);


=====================================
src/uk/me/parabola/imgfmt/app/map/Map.java
=====================================
@@ -176,7 +176,7 @@ public class Map implements InternalFiles, Configurable {
 	 * gets shown when the device starts (sometimes?).
 	 */
 	public void addCopyright(String str) {
-		Label cpy = lblFile.newLabel(str);
+		Label cpy = lblFile.newLabel(str, false);
 		treFile.addCopyright(cpy);
 	}
 


=====================================
src/uk/me/parabola/imgfmt/app/mdr/MDRFile.java
=====================================
@@ -15,6 +15,7 @@ package uk.me.parabola.imgfmt.app.mdr;
 import java.util.Arrays;
 import java.util.Set;
 
+import uk.me.parabola.imgfmt.MapFailedException;
 import uk.me.parabola.imgfmt.app.BufferedImgFileReader;
 import uk.me.parabola.imgfmt.app.FileBackedImgFileWriter;
 import uk.me.parabola.imgfmt.app.ImgFile;
@@ -395,6 +396,10 @@ public class MDRFile extends ImgFile {
 		mdrHeader.setItemSize(1, mdr1.getItemSize());
 		mdrHeader.setEnd(1, writer.position());
 		mdrHeader.setExtraValue(1, mdr1.getExtraValue());
+		if (writer.position() < 0) {
+			// integer overflow can cause this
+			throw new MapFailedException("MDR sub file is too large");
+		}
 	}
 
 	/**


=====================================
src/uk/me/parabola/imgfmt/app/net/NETFile.java
=====================================
@@ -114,7 +114,7 @@ public class NETFile extends ImgFile {
 	 * @return A list of road labels that identify all the different roads
 	 */
 	private List<LabeledRoadDef> deDupRoads() {
-		List<SortKey<LabeledRoadDef>> sortKeys = createSortKeysyNameAndCity();
+		List<SortKey<LabeledRoadDef>> sortKeys = createSortKeysByNameAndCity();
 		sortKeys.sort(null);
 
 		List<LabeledRoadDef> out = new ArrayList<>(sortKeys.size());
@@ -137,7 +137,7 @@ public class NETFile extends ImgFile {
 		return out;
 	}
 
-	private List<SortKey<LabeledRoadDef>> createSortKeysyNameAndCity() {
+	private List<SortKey<LabeledRoadDef>> createSortKeysByNameAndCity() {
 		List<SortKey<LabeledRoadDef>> sortKeys = new ArrayList<>(roads.size());
 
 		for (RoadDef rd : roads) {


=====================================
src/uk/me/parabola/imgfmt/app/trergn/ExtTypeAttributes.java
=====================================
@@ -204,17 +204,17 @@ public class ExtTypeAttributes {
 		if(note == null) {
 			String ns = attributes.get("note");
 			if(ns != null)
-				note = lbl.newLabel(ns);
+				note = lbl.newLabel(ns, false);
 		}
 		if(intDesig == null) {
 			String ids = attributes.get("int-desig");
 			if(ids != null)
-				intDesig = lbl.newLabel(ids);
+				intDesig = lbl.newLabel(ids, false);
 		}
 		if(localDesig == null) {
 			String lds = attributes.get("local-desig");
 			if(lds != null)
-				localDesig = lbl.newLabel(lds);
+				localDesig = lbl.newLabel(lds, false);
 		}
 	}
 


=====================================
src/uk/me/parabola/imgfmt/mdxfmt/MdxFile.java
=====================================
@@ -20,6 +20,7 @@ import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 import java.nio.channels.FileChannel;
 import java.nio.channels.WritableByteChannel;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -84,11 +85,7 @@ public class MdxFile {
 	}
 
 	private void writeHeader(WritableByteChannel chan, ByteBuffer buf) throws IOException {
-		try {
-			buf.put("Midx".getBytes("ascii"));
-		} catch (UnsupportedEncodingException e) {
-			throw new IOException("Could not write header");
-		}
+		buf.put("Midx".getBytes(StandardCharsets.US_ASCII));
 		buf.putChar((char) 100);
 		buf.putInt(12);
 		buf.putInt(maps.size());


=====================================
src/uk/me/parabola/imgfmt/sys/ImgFS.java
=====================================
@@ -246,7 +246,7 @@ public class ImgFS implements FileSystem {
 
 		fileBlockManager.setBlockSize(param.getBlockSize());
 		headerBlockManager.setBlockSize(param.getBlockSize());
-		file.position(param.getReservedDirectoryBlocks() * param.getBlockSize());
+		file.position((long)param.getReservedDirectoryBlocks() * param.getBlockSize());
 
 		fileBlockManager.setCurrentBlock(param.getReservedDirectoryBlocks());
 		for (FileNode n : openNodes) {
@@ -291,7 +291,7 @@ public class ImgFS implements FileSystem {
 			int headerBlocks = (requiredSlots * ENTRY_SIZE + blockSize - 1) / blockSize;
 			int totalBlocks = headerBlocks + fileBlocks;
 			int size = totalBlocks * blockSize;
-			log.infof("bs=%d, whole size=%d, hb=%d, fb=%d, blocks=%d\n", blockSize, size,
+			log.infof("bs=%d, whole size=%d, hb=%d, fb=%d, blocks=%d", blockSize, size,
 					headerBlocks, fileBlocks, totalBlocks);
 
 			if (headerBlocks > SLOTS_PER_ENTRY)
@@ -308,7 +308,7 @@ public class ImgFS implements FileSystem {
 			sizeInBlocks = fileBlocks + headerBlocks;
 			bestSize = size;
 		}
-		log.infof("Best block size: %d sizeInBlocks=%d, reserved=%d\n", bestBlockSize, sizeInBlocks, reserved);
+		log.infof("Best block size: %d sizeInBlocks=%d, reserved=%d", bestBlockSize, sizeInBlocks, reserved);
 
 		param.setBlockSize(bestBlockSize);
 		param.setReservedDirectoryBlocks(reserved);


=====================================
src/uk/me/parabola/mkgmap/CommandArgs.java
=====================================
@@ -80,15 +80,16 @@ public class CommandArgs {
 	}
 
 	public int getCodePage() {
-		int cp;
+		int cp = 0;
 
 		String s = currentOptions.getProperty("code-page");
-		try {
-			cp = Integer.parseInt(s);
-		} catch (NumberFormatException e) {
-			cp = 0;
+		if (s != null) {
+			try {
+				cp = Integer.parseInt(s);
+			} catch (NumberFormatException e) {
+				throw new ExitException("The --code-page parameter must be a number.");
+			}
 		}
-
 		return cp;
 	}
 


=====================================
src/uk/me/parabola/mkgmap/osmstyle/actions/HighwaySymbolFilter.java
=====================================
@@ -85,11 +85,14 @@ public class HighwaySymbolFilter extends ValueFilter {
 		for (char c : shieldText.toCharArray()) {
 		  	if (Character.isDigit(c)) {
 				isAlphaNum = true; // Consider alphanumeric if we find one or more digits
+				break;
 			}
 		}
 
 		// Check if shield exceeds maximum length:
-		if ( (isAlphaNum && shieldText.length() > maxAlphaNum) || (! isAlphaNum) && shieldText.length() > maxAlpha ) {
+		int codePointLength = shieldText.codePointCount(0, shieldText.length());
+		if (isAlphaNum && codePointLength > maxAlphaNum || !isAlphaNum && codePointLength > maxAlpha) {
+			// ??? this doesn't do as described in the documentation
 			return value; // If so, return original value
 		} else {
 			return prefix + shieldText; // If not, return condensed value with magic code


=====================================
src/uk/me/parabola/mkgmap/osmstyle/actions/SubstringFilter.java
=====================================
@@ -56,14 +56,28 @@ public class SubstringFilter extends ValueFilter {
 	}
 
 	protected String doFilter(String value, Element el) {
-		if (value == null) return null;
+		if (value == null)
+			return null;
 		if (start > value.length())
 			return null;
+		int codePointStart = 0;
+		if (start > 0)
+			try {
+				codePointStart = value.offsetByCodePoints(0, start);
+			} catch (IndexOutOfBoundsException e) {
+				return null;
+			}
 		if (args == 1 || end > value.length()) {
-			return value.substring(start);
+			return value.substring(codePointStart);
 		}
 		if (args == 2) {
-			return value.substring(start, end);
+			int codePointEnd = 0;
+			try {
+				codePointEnd = value.offsetByCodePoints(start, end-start);
+			} catch (IndexOutOfBoundsException e) {
+				return value.substring(codePointStart);
+			}
+			return value.substring(codePointStart, codePointEnd);
 		}
 		return value;
 	}



View it on GitLab: https://salsa.debian.org/debian-gis-team/mkgmap/-/compare/bd81b50903254e54f686a5717b2a81614fbd31c3...758556a26fb7e657d81778e628e367afd4066c28

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/mkgmap/-/compare/bd81b50903254e54f686a5717b2a81614fbd31c3...758556a26fb7e657d81778e628e367afd4066c28
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20220101/dddc2a70/attachment-0001.htm>


More information about the Pkg-grass-devel mailing list