Hi Gerd

Changes:

- Added comment in style-manual.txt about tools needed and how to
generate the pdf. These are asciidoc, fop, python-pygments and mkgmap
-pygments.

- Adjusted the layout of "Table 4.2. Style functions" so that
is_in(...) doesn't run into the flags and and slightly changed the
highlighting again.

- Changed log.info to log.debug.

- Added default: throw...  to a couple of switch statements. I disagree
with SonarLint that this is always good practice; here it is just
pointless clutter.

I'm not sure what the problem is with commented code blocks. I left
@override value() {...} in as commented because it clarifies what needs
to change between a CachedFunction and a StyleFunction.

doc/styles/main.txt should be deleted from svn; it has been superseded 
by style-manual.txt.

Reg. b14. It might be slight rounding errors, but the hole generated from the 
merge of the 2 halves of the outer retains the 2 cut-points and this does match 
the inner polygon, whereas, for the inner polygon, isLineInShape gives 
IN/ON/OUT against one of the halves of the outer. I'd have expected the 
problems to be the other way around.

Ticker 

On Wed, 2020-02-26 at 08:46 +0000, Gerd Petermann wrote:
> Hi Ticker,
> 
> no idea how the tool chain for the pdf works.
> 
> There are some commented code blocks and Eclipse and SonarLint warn
> about several missing default statements, e.g.
> Complete cases by adding the missing enum constants or add a default
> case to this switch.       IsInFunction.java      
>  mkgmap/src/uk/me/parabola/mkgmap/osmstyle/function      line 164    
>     SonarLint On-The-Fly Issue
> 
> Reg. the TODO comment
> // problem with test b14 on the cut polygons and isLineInShape that
> goes away when merged. TODO: investigate sometime
> Maybe the reason is that we create a Coord instance at the place
> where the polygon is split. Due to the rounding errors this point can
> be a 1-2 mm inside or outside the original inner polygon. Merging
> should not change the result unless the added point is removed by the
> merge. In that case I would assume that there were no rounding
> errors.
> 
> Some log statements might be removed or changed to debug level?
> log.info("done", System.identityHashCode(this), hasIn, hasOn,
> hasOut);
> 
> Gerd
> 
> ________________________________________
> Von: mkgmap-dev <mkgmap-dev-boun...@lists.mkgmap.org.uk> im Auftrag
> von Ticker Berkin <rwb-mkg...@jagit.co.uk>
> Gesendet: Dienstag, 25. Februar 2020 10:27
> An: Development list for mkgmap
> Betreff: Re: [mkgmap-dev] Work on is_in branch
> 
> Hi Gerd
> 
> I think this is about ready for release.
> 
> There is a slight problem with the layout in the Style Manual in that
> the width of "is_in(tag,value,method)" causes it to run into the
> Node/Way/Relation flags. If there was a way to put the function args
> down the first column it would fix it, but I have no idea of the
> rules
> of the formatting language. What are the tools used to transform
> doc/styles/*.txt to the style-manual.pdf?
> 
> I'm not going to be able to do any complex line->polygon in/on/out
> debugging in the next few days and it seems to work well for most
> cases.
> 
> Ticker
> 
> On Mon, 2020-02-24 at 12:50 +0000, Ticker Berkin wrote:
> > Hi Gerd
> > 
> > Patch attached that:
> > 
> > - rewords the sentence is the Style Manual and changes the
> > highlighting; I need to check the next build/download to see if
> > this
> > is clearer.
> > 
> > - fixes polygon 'any' method to also return true if exactly ON.
> > 
> > - merge polygons for 'any' so that line on shared boundary is "in"
> > rather than "on".
> > 
> > - change the test driver to try all methods relevant to the
> > element,
> > checking they return true/false as appropriate. I decided that,
> > rather than introducing a new tag saying which methods should
> > match,
> > it was clearer to use the 'expected' tag value as a description of
> > how the element interacted with the polygons and generate the
> > methods
> > that should match from this and the non-matching from a list if all
> > methods.
> > 
> > Ticker
> 
> _______________________________________________
> mkgmap-dev mailing list
> mkgmap-dev@lists.mkgmap.org.uk
> http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
Index: doc/styles/about.txt
===================================================================
--- doc/styles/about.txt	(revision 4458)
+++ doc/styles/about.txt	(working copy)
@@ -14,9 +14,9 @@
 People who have contributed suggestions and corrections to this document
 are:
 Carlos Dávila,
-Geoff Sherlock
+Geoff Sherlock,
+Ticker Berkin
 
-
 The list of nicknames of everyone that had modified the wiki pages at the time that
 this manual was created is as follows:
 Brogo,
Index: doc/styles/rules.txt
===================================================================
--- doc/styles/rules.txt	(revision 4458)
+++ doc/styles/rules.txt	(working copy)
@@ -244,9 +244,9 @@
 Functions calculate a specific property of an OSM element.
 
 .Style functions
-[width="100%",cols="2,1,1,1,5",options="header"]
+[width="100%",cols="5,1,1,1,11",options="header"]
 |=====
-|Function |Node |Way |Relation |Description
+|Function |Node |Way |Rel. |Description
 |length()      |  | x  | x  |
 Calculates the length in m. For relations its the sum of all member length (including sub relations).
 
@@ -282,8 +282,8 @@
 Retrieves the id of the OSM element. This can be useful for style debugging purposes. Note that due to internal changes like merging, cutting etc. 
 some element ids are changed and some have a faked id > 4611686018427387904.  
 
-|is_in(tag,value,method)   | x | x  |  |
-+true+ if the element is in polygon(s) having the specified *tag=value* according to the *method*, +false+ otherwise.
+|is_in(*tag*,*value*,*method*)   | x | x  |  |
++true+ if the element is in polygon(s) having the specified *tag*=*value* according to the *method*, +false+ otherwise.
 The methods available depend on the Style section:
 
 polygons:
Index: doc/styles/style-manual.txt
===================================================================
--- doc/styles/style-manual.txt	(revision 4458)
+++ doc/styles/style-manual.txt	(working copy)
@@ -1,6 +1,6 @@
 = Conversion Style manual
 The mkgmap team
-:pubdate: January 2013
+:pubdate: set to date of pdf generation
 :toc:
 :numbered:
 :doctype: book
@@ -9,6 +9,18 @@
 :description: Describes the style language that converts from OSM tags to Garmin types.
 :max-width: 58em
 
+////
+To generate style-manual.pdf you will need asciidoc, fop, python-pygments, mkgmap-pygments.
+eg. for a Fedora system, as superuser:
+# dnf install asciidoc.noarch
+# dnf install fop.noarch
+# dnf install python-pygments.noarch
+# pip install mkgmap-pygments
+
+Then, as normal user, cd to this directory (doc/styles) and
+$ make pdf
+////
+
 :frame: topbot
 :grid: rows
 
Index: src/uk/me/parabola/mkgmap/osmstyle/function/IsInFunction.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/function/IsInFunction.java	(revision 4458)
+++ src/uk/me/parabola/mkgmap/osmstyle/function/IsInFunction.java	(working copy)
@@ -20,6 +20,7 @@
 import java.util.Set;
 import java.util.stream.Collectors;
 
+import uk.me.parabola.imgfmt.ExitException;
 import uk.me.parabola.imgfmt.app.Area;
 import uk.me.parabola.imgfmt.app.Coord;
 import uk.me.parabola.log.Logger;
@@ -144,7 +145,7 @@
 		// 1: polygon tagName
 		// 2: value for above tag
 		// 3: method keyword, see above
-		log.info("isInFunction", System.identityHashCode(this));
+		log.debug("isInFunction", System.identityHashCode(this));
 	}
 
 	private void resetHasFlags() {
@@ -155,7 +156,7 @@
 	}
 
 	public String calcImpl(Element el) {
-		log.info("calcImpl", System.identityHashCode(this), kind, params, el);
+		log.debug("calcImpl", System.identityHashCode(this), kind, params, el);
 		assert qt != null : "invoked the non-augmented instance";
 		if (qt.isEmpty())
 			return String.valueOf(false);
@@ -171,9 +172,11 @@
 			case POLYGON:
 				doPolygonTest((Way) el);
 				break;
+			default:
+				throw new ExitException("Bad FeatureKind: " + kind);
 			}
 		} catch (CanStopProcessing e) {}
-		log.info("done", System.identityHashCode(this), hasIn, hasOn, hasOut);
+		log.debug("done", System.identityHashCode(this), hasIn, hasOn, hasOut);
 		if (!hasIn && !hasOn)
 			hasOut = true;
 		return String.valueOf(method.mapFlags(hasIn, hasOn, hasOut));
@@ -189,7 +192,7 @@
 	@Override
 	public void setParams(List<String> params, FeatureKind kind) {
 		super.setParams(params, kind);
-		log.info("setParams", System.identityHashCode(this), kind, params);
+		log.debug("setParams", System.identityHashCode(this), kind, params);
 		String methodStr = params.get(2);
 		boolean knownMethod = false;
 		List<String> methodsForKind = new ArrayList<>();
@@ -209,7 +212,7 @@
 	}
 
 	private void setIn() {
-		log.info("setIn", hasIn, hasOn, hasOut);
+		log.debug("setIn", hasIn, hasOn, hasOut);
 		hasIn = true;
 		if (method.canStopIn() || hasOut)
 			throw new CanStopProcessing();
@@ -216,13 +219,13 @@
 	}
 
 	private void setOn() {
-		log.info("setOn", hasIn, hasOn, hasOut);
+		log.debug("setOn", hasIn, hasOn, hasOut);
 		hasOn = true;
 		if (method.canStopOn() || (hasIn && hasOut))
 			throw new CanStopProcessing();
 	}
 	private void setOut() {
-		log.info("setOut", hasIn, hasOn, hasOut);
+		log.debug("setOut", hasIn, hasOn, hasOut);
 		hasOut = true;
 		if (method.canStopOut() || hasIn)
 			throw new CanStopProcessing();
@@ -229,7 +232,7 @@
 	}
 
 	private void setHasFromFlags(int flags) {
-		log.info("setFlags", flags);
+		log.debug("setFlags", flags);
 		if ((flags & IsInUtil.ON) != 0)
 			setOn();
 		if ((flags & IsInUtil.IN) != 0)
@@ -272,6 +275,8 @@
 				// hole checking is a separate pass
 				setOn(); // don't care about setIn()
 			break;
+		default:
+			throw new ExitException("Bbad point method: " + method);
 		}
 	}
 
@@ -285,7 +290,7 @@
 			List<List<Coord>> outers = new ArrayList<>();
 			List<List<Coord>> holes = new ArrayList<>();
 			IsInUtil.mergePolygons(polygons, outers, holes);
-			log.info("pointMerge", polygons.size(), outers.size(), holes.size());
+			log.debug("pointMerge", polygons.size(), outers.size(), holes.size());
 			for (List<Coord> shape : outers)
 				checkPointInShape(c, shape, holes);
 			if (method == MethodArg.POINT_ON && !holes.isEmpty())
@@ -293,7 +298,7 @@
 				for (List<Coord> hole : holes)
 					checkPointInShape(c, hole, null);
 		} else { // just one polygon or IN_OR_ON, which can do one-by-one
-			log.info("point1by1", polygons.size());
+			log.debug("point1by1", polygons.size());
 			for (Way polygon : polygons)
 				checkPointInShape(c, polygon.getPoints(), null);
 		}
@@ -311,7 +316,7 @@
 		boolean foundSomething = false;
 		for (List<Coord> hole : holes) {
 			int flags = IsInUtil.isLineInShape(polyLine, hole, elementBbox);
-			log.info("checkhole", flags);
+			log.debug("checkhole", flags);
 			if ((flags & IsInUtil.IN) != 0) {
 				setOut();
 				if ((flags & IsInUtil.ON) != 0)
@@ -332,7 +337,7 @@
 	private void checkHoleInThis(List<Coord> polyLine, List<List<Coord>> holes, Area elementBbox) {
 		for (List<Coord> hole : holes) {
 			int flags = IsInUtil.isLineInShape(hole, polyLine, elementBbox);
-			log.info("holeInThis", flags);
+			log.debug("holeInThis", flags);
 			if ((flags & IsInUtil.IN) != 0 ||
 			    (flags == IsInUtil.ON)) { // exactly on hole
 				setOut();
@@ -346,26 +351,26 @@
 		Area elementBbox = Area.getBBox(polyLine);
 		Set<Way> polygons = qt.get(elementBbox).stream().map(e -> (Way) e)
 				.collect(Collectors.toCollection(LinkedHashSet::new));
-		if (log.isInfoEnabled()) {
-			log.info("line", polyLine);
-			log.info(polygons.size(), "polygons");
+		if (log.isDebugEnabled()) {
+			log.debug("line", polyLine);
+			log.debug(polygons.size(), "polygons");
 			for (Way polygon : polygons)
-				log.info("polygon", polygon.getPoints());
+				log.debug("polygon", polygon.getPoints());
 		}
 		if (method.needMerge() && polygons.size() > 1) { // ALL-like methods need to merge shapes
 			List<List<Coord>> outers = new ArrayList<>();
 			List<List<Coord>> holes = new ArrayList<>();
 			IsInUtil.mergePolygons(polygons, outers, holes);
-			if (log.isInfoEnabled()) {
-				log.info(outers.size(), "outers", holes.size(), "holes");
+			if (log.isDebugEnabled()) {
+				log.debug(outers.size(), "outers", holes.size(), "holes");
 				for (List<Coord> shape : outers)
-					log.info("outer", shape);
+					log.debug("outer", shape);
 				for (List<Coord> hole : holes)
-					log.info("hole", hole);
+					log.debug("hole", hole);
 			}
 			for (List<Coord> shape : outers) {
 				int flags = IsInUtil.isLineInShape(polyLine, shape, elementBbox);
-				log.info("checkShape", flags);
+				log.debug("checkShape", flags);
 				if ((flags & IsInUtil.IN) != 0) { // this shape is the one to consider
 					if ((flags & IsInUtil.ON) != 0)
 						setOn();
@@ -426,7 +431,7 @@
 
 	@Override
 	public void augmentWith(ElementSaver elementSaver) {
-		log.info("augmentWith", System.identityHashCode(this), kind, params);
+		log.debug("augmentWith", System.identityHashCode(this), kind, params);
 		// the cached function mechanism creates an instance for each occurance in the rule file
 		// but then just uses one of them for augmentWith() and calcImpl().
 		if (qt != null)
_______________________________________________
mkgmap-dev mailing list
mkgmap-dev@lists.mkgmap.org.uk
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to