[Git][debian-gis-team/mkgmap][upstream] New upstream version 0.0.0+svn4260

Bas Couwenberg gitlab at salsa.debian.org
Tue Jan 1 09:57:39 GMT 2019


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


Commits:
9a1b9333 by Bas Couwenberg at 2019-01-01T09:49:52Z
New upstream version 0.0.0+svn4260
- - - - -


7 changed files:

- doc/styles/rules.txt
- resources/mkgmap-version.properties
- src/uk/me/parabola/imgfmt/app/net/RoadDef.java
- src/uk/me/parabola/mkgmap/general/MapRoad.java
- src/uk/me/parabola/mkgmap/osmstyle/actions/ActionReader.java
- src/uk/me/parabola/mkgmap/osmstyle/actions/SubAction.java
- src/uk/me/parabola/mkgmap/osmstyle/housenumber/ExtNumbers.java


Changes:

=====================================
doc/styles/rules.txt
=====================================
@@ -487,6 +487,13 @@ per relation member. A round-trip route relation may include the same
 ways multiple times, unless all member ways have been defined as parallel
 one way streets.
 
+=== apply_first ===
+The apply_first action is like +apply+, but it will apply the action only to the 
+first relation member as appearing in the input file. In combination with the 
+--add-pois-to-lines option this might be used with route relations to mark the 
+beginning of a route, presuming that the relation is complete and ordered so
+that the first member is the start of the route. 
+                                                
 === echo ===
 The echo action prints the element id plus a text to standard error. This can be
 used for quality checks and debugging purposes.


=====================================
resources/mkgmap-version.properties
=====================================
@@ -1,2 +1,2 @@
-svn.version: 4257
-build.timestamp: 2018-11-26T14:51:21+0000
+svn.version: 4260
+build.timestamp: 2018-12-28T10:15:41+0000


=====================================
src/uk/me/parabola/imgfmt/app/net/RoadDef.java
=====================================
@@ -29,6 +29,7 @@ import java.util.TreeMap;
 import uk.me.parabola.imgfmt.MapFailedException;
 import uk.me.parabola.imgfmt.Utils;
 import uk.me.parabola.imgfmt.app.BitWriter;
+import uk.me.parabola.imgfmt.app.Coord;
 import uk.me.parabola.imgfmt.app.ImgFileWriter;
 import uk.me.parabola.imgfmt.app.Label;
 import uk.me.parabola.imgfmt.app.lbl.City;
@@ -61,6 +62,7 @@ import uk.me.parabola.mkgmap.general.ZipCodeInfo;
 
 public class RoadDef {
 	private static final Logger log = Logger.getLogger(RoadDef.class);
+	public static final int MAX_NUMBER_NODES = 0x3ff; 
 
 	public static final int NET_FLAG_NODINFO  = 0x40;
 	public static final int NET_FLAG_ADDRINFO = 0x10;
@@ -140,7 +142,7 @@ public class RoadDef {
 	// the first point in the road is a node (the above routing node)
 	private boolean startsWithNode = true;
 	// number of nodes in the road
-	private int nnodes;
+	private int nnodes = -1;
 
 	// always appears to be set
 	private int nod2Flags = NOD2_FLAG_UNK;
@@ -524,6 +526,9 @@ public class RoadDef {
 	}
 
 	public void setNumNodes(int n) {
+		if (n-2 > MAX_NUMBER_NODES) {
+			throw new MapFailedException("Too many special nodes: " + n + " is > " + MAX_NUMBER_NODES + " " + this);
+		}
 		nnodes = n;
 	}
 


=====================================
src/uk/me/parabola/mkgmap/general/MapRoad.java
=====================================
@@ -18,6 +18,7 @@ package uk.me.parabola.mkgmap.general;
 
 import java.util.List;
 
+import uk.me.parabola.imgfmt.app.Coord;
 import uk.me.parabola.imgfmt.app.lbl.City;
 import uk.me.parabola.imgfmt.app.lbl.Zip;
 import uk.me.parabola.imgfmt.app.net.Numbers;
@@ -209,4 +210,15 @@ public class MapRoad extends MapLine {
 		roadDef.resetImgData();
 		
 	}
+	
+	public int countNodes() {
+		int n = 0;
+		for (Coord p : getPoints()) {
+			if (p.isNumberNode()) 
+				n++;
+		}
+		return n;
+	}
+
+	
 }


=====================================
src/uk/me/parabola/mkgmap/osmstyle/actions/ActionReader.java
=====================================
@@ -71,9 +71,11 @@ public class ActionReader {
 			} else if ("addaccess".equals(cmd)) { 
 				actions.add(readAccessValue(false, changeableTags));
 			} else if ("apply".equals(cmd)) {
-				actions.add(readAllCmd(false));
+				actions.add(readAllCmd(null));
 			} else if ("apply_once".equals(cmd)) {
-				actions.add(readAllCmd(true));
+				actions.add(readAllCmd("once"));
+			} else if ("apply_first".equals(cmd)) {
+				actions.add(readAllCmd("first"));
 			} else if ("name".equals(cmd)) {
 				actions.add(readValueBuilder(new NameAction()));
 				changeableTags.add("mkgmap:label:1");
@@ -115,7 +117,7 @@ public class ActionReader {
 		return new ActionList(actions, changeableTags);
 	}
 
-	private Action readAllCmd(boolean once) {
+	private Action readAllCmd(String selector) {
 		String role = null;
 		if (scanner.checkToken("role")) {
 			scanner.nextToken();
@@ -124,7 +126,7 @@ public class ActionReader {
 				throw new SyntaxException(scanner, "Expecting '=' after role keyword");
 			role = scanner.nextWord();
 		}
-		SubAction subAction = new SubAction(role, once);
+		SubAction subAction = new SubAction(role, selector);
 
 		List<Action> actionList = readActions().getList();
 		for (Action a : actionList)


=====================================
src/uk/me/parabola/mkgmap/osmstyle/actions/SubAction.java
=====================================
@@ -36,11 +36,11 @@ import uk.me.parabola.mkgmap.reader.osm.Relation;
 public class SubAction implements Action {
 	private final List<Action> actionList = new ArrayList<Action>();
 	private final String role;
-	private final boolean once;
+	private final String selector;
 
-	public SubAction(String role, boolean once) {
+	public SubAction(String role, String selector) {
 		this.role = role;
-		this.once = once;
+		this.selector = selector;
 	}
 
 	public boolean perform(Element el) {
@@ -58,6 +58,8 @@ public class SubAction implements Action {
 			else if (a instanceof AddAccessAction)
 				((AddAccessAction) a).setValueTags(rel);
 
+		boolean once = "once".equals(selector);
+		boolean first_only = "first".equals(selector);
 		HashSet<Element> elems = once ? new HashSet<Element>() : null;
 
 		for (Map.Entry<String,Element> r_el : elements) {
@@ -67,6 +69,8 @@ public class SubAction implements Action {
 				for (Action a : actionList)
 					a.perform(r_el.getValue());
 			}
+			if (first_only)
+				break;
 		}
 	}
 
@@ -76,7 +80,10 @@ public class SubAction implements Action {
 
 	public String toString() {
 		Formatter fmt = new Formatter();
-		fmt.format(once ? "apply_once" : "apply");
+		fmt.format("apply");
+		if (selector != null) {
+			fmt.format("_%s",selector);
+		}
 		if (role != null)
 			fmt.format(" role=%s ", role);
 		


=====================================
src/uk/me/parabola/mkgmap/osmstyle/housenumber/ExtNumbers.java
=====================================
@@ -26,12 +26,13 @@ import java.util.Set;
 import java.util.TreeMap;
 
 import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
+import uk.me.parabola.imgfmt.MapFailedException;
 import uk.me.parabola.imgfmt.Utils;
 import uk.me.parabola.imgfmt.app.Coord;
 import uk.me.parabola.imgfmt.app.net.NumberStyle;
 import uk.me.parabola.imgfmt.app.net.Numbers;
+import uk.me.parabola.imgfmt.app.net.RoadDef;
 import uk.me.parabola.log.Logger;
-import uk.me.parabola.mkgmap.filters.LineSplitterFilter;
 import uk.me.parabola.mkgmap.general.CityInfo;
 import uk.me.parabola.mkgmap.general.MapRoad;
 import uk.me.parabola.mkgmap.general.ZipCodeInfo;
@@ -507,6 +508,11 @@ public class ExtNumbers {
 	private ExtNumbers splitInterval(){
 		if (log.isDebugEnabled())
 			log.debug("trying to split",this,"so that",badNum,"is not contained");
+		if (getRoad().countNodes() + 1 > 0x3ff) {
+			log.warn("cannot increase number of number nodes", getRoad());
+			return this;
+		}
+		
 		boolean doSplit = false;
 		Numbers origNumbers = getNumbers();
 		if (origNumbers.countMatches(badNum) == 0){
@@ -678,14 +684,15 @@ public class ExtNumbers {
 	 * @return
 	 */
 	private ExtNumbers tryAddNumberNode(int reason) {
+		int numNumNodes = getRoad().countNodes();
+		if (numNumNodes + 1 > RoadDef.MAX_NUMBER_NODES){
+			log.warn("can't change intervals, road has already", numNumNodes, "number nodes");
+			return this; // can't add a node
+		}
 		String action;
 		if (endInRoad - startInRoad > 1)
 			action = "change";
 		else {
-			if (getRoad().getPoints().size() + 1 > LineSplitterFilter.MAX_POINTS_IN_LINE){
-				log.warn("can't change intervals, road has already",LineSplitterFilter.MAX_POINTS_IN_LINE,"points");
-				return this; // can't add a node
-			}
 			Coord c1 = getRoad().getPoints().get(startInRoad);
 			Coord c2 = getRoad().getPoints().get(startInRoad+1);
 			if (c1.equals(c2)){
@@ -1085,6 +1092,9 @@ public class ExtNumbers {
 	 * @return new start of next interval
 	 */
 	private int addAsNumberNode(int pos, Coord toAdd){
+		if (getRoad().countNodes()  + 1 > RoadDef.MAX_NUMBER_NODES) {
+			throw new MapFailedException("too many number nodes in " + getRoad());
+		}
 		toAdd.setNumberNode(true);
 		toAdd.setAddedNumberNode(true);
 		getRoad().getPoints().add(pos, toAdd);
@@ -1132,16 +1142,18 @@ public class ExtNumbers {
 				continue;
 			if (multipleZipOrCity(left))
 				multipleZipOrCity = true;
-			for (HousenumberMatch house: houses){
-				int hn = house.getHousenumber();
-				if (countOccurence(houses, hn) > 1)
-					continue;
-				ExtNumbers modIvl = simulateRemovalOfHouseNumber(hn, left);
-				if (modIvl.isPlausible()){
-					badNum = hn;
-					if (log.isDebugEnabled())
-						log.debug("splitpos details: single remove of",badNum,"results in plausible interval");
-					return;
+			if (houses.size() < 50) {
+				for (HousenumberMatch house: houses){
+					int hn = house.getHousenumber();
+					if (countOccurence(houses, hn) > 1)
+						continue;
+					ExtNumbers modIvl = simulateRemovalOfHouseNumber(hn, left);
+					if (modIvl.isPlausible()){
+						badNum = hn;
+						if (log.isDebugEnabled())
+							log.debug("splitpos details: single remove of",badNum,"results in plausible interval");
+						return;
+					}
 				}
 			}
 		}



View it on GitLab: https://salsa.debian.org/debian-gis-team/mkgmap/commit/9a1b933368b66dbd748ca45888b0a0199d815fa9

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/mkgmap/commit/9a1b933368b66dbd748ca45888b0a0199d815fa9
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/20190101/d1616474/attachment-0001.html>


More information about the Pkg-grass-devel mailing list