[mkgmap] 02/06: Imported Upstream version 0.0.0+svn3436
Sebastiaan Couwenberg
sebastic at moszumanska.debian.org
Fri Feb 6 13:58:00 UTC 2015
This is an automated email from the git hooks/post-receive script.
sebastic pushed a commit to branch master
in repository mkgmap.
commit 0a97c7e08d41aa8700c8711fb6020506437185cf
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date: Fri Feb 6 14:39:48 2015 +0100
Imported Upstream version 0.0.0+svn3436
---
doc/options.txt | 23 +++---
doc/styles/rules-filters.txt | 22 ++++++
doc/tutorial/publish.txt | 23 ++++--
resources/help/en/options | 17 +++--
resources/mkgmap-version.properties | 4 +-
resources/styles/default/relations | 3 +-
src/uk/me/parabola/mkgmap/build/MapBuilder.java | 27 +++----
.../parabola/mkgmap/osmstyle/StyledConverter.java | 6 +-
.../parabola/mkgmap/osmstyle/WrongAngleFixer.java | 11 +++
.../osmstyle/actions/NotContainedFilter.java | 82 +++++++++++++++++++++
.../mkgmap/osmstyle/actions/ValueBuilder.java | 3 +
.../mkgmap/osmstyle/actions/ValueItem.java | 2 +-
src/uk/me/parabola/mkgmap/reader/osm/Element.java | 46 ++++++------
.../mkgmap/reader/osm/OsmMapDataSource.java | 60 +++++++++++-----
.../mkgmap/reader/osm/bin/OsmBinHandler.java | 56 +++++++--------
.../mkgmap/reader/osm/o5m/O5mBinHandler.java | 14 ++--
.../mkgmap/reader/osm/xml/Osm5XmlHandler.java | 42 +++++------
test/func/route/SimpleRouteTest.java | 2 +-
.../osmstyle/actions/NotContainedFilterTest.java | 83 ++++++++++++++++++++++
19 files changed, 388 insertions(+), 138 deletions(-)
diff --git a/doc/options.txt b/doc/options.txt
index 78086de..5e7456b 100644
--- a/doc/options.txt
+++ b/doc/options.txt
@@ -283,15 +283,20 @@ drop-down. The default is "OSM map".
: Area name is displayed on Garmin units (or at least on eTrex) as the second
part of the mapname in the list of the individual maps.
-;--copyright-message=note
-: Specify a copyright message for files that do not contain one.
-
-;--license-file=file
-: Specify a file which content will be added as license.
-All entrys of all maps will be merged in the overview map.
-
-=== Optimization options ===
-
+;--copyright-message=note
+: Specify a copyright message for files that do not contain one.
+
+;--copyright-file=file
+: Specify copyright messages from a file.
+Note that the first copyright message is not displayed on a device, but is
+shown in BaseCamp.
+
+;--license-file=file
+: Specify a file which content will be added as license.
+All entries of all maps will be merged in the overview map.
+
+=== Optimization options ===
+
;--reduce-point-density=NUM
: Simplifies the ways with the Douglas Peucker algorithm.
NUM is the maximal allowed error distance, by which the resulting
diff --git a/doc/styles/rules-filters.txt b/doc/styles/rules-filters.txt
index 6bf7314..97fb833 100644
--- a/doc/styles/rules-filters.txt
+++ b/doc/styles/rules-filters.txt
@@ -129,6 +129,28 @@ are counted starting from zero and the end position is not included.
`${name\|substring:2:5}`
If the "name" was "Dorset Lane", then the result is "rse". If there is just the one number,
then the substring starts from that character until the end of the string.
+
+| not-contained | `separator tag` |
+Used to check for duplicate values. If the value of this tag is contained in the list being
+the value of the tag named as the argument to +not-contained+, then value
+of this tag is set to undefined.
+
+....
+type=route & route=bus & ref=* {
+ apply {
+ set route_ref='$(route_ref),${ref\|not-contained:,:route_ref}' \| '$(route_ref)' \| '${ref}';
+ }
+}
+....
+
+Here, +ref+ value is only added to +route_ref+ when it is not already contained in that list
+(with separator ','). Otherwise, the value of +route_ref+ is unchanged.
+This helps to get correct labeling (no duplicates) for public transport lines where there can be multiple relations
+with the same +ref+ attribute (e.g. one for the forward and one for the backward direction).
+
+For example, if +route_ref+ was already "1,2,150" and +ref+ would again be "150",
+this value would not be added to the list as it is already there.
+In contrast, +ref+ equal to "229" would be added, so after that +route_ref+ would have the value "1,2,150,229"
|=====
=== Symbol codes
diff --git a/doc/tutorial/publish.txt b/doc/tutorial/publish.txt
index 1e5d84b..3476975 100644
--- a/doc/tutorial/publish.txt
+++ b/doc/tutorial/publish.txt
@@ -30,10 +30,19 @@ The default is "OSM map".
--area-name::
Area name is displayed on Garmin units (or at least on eTrex) as the
second part of the mapname in the list of the individual maps.
-
---copyright-message=note::
-Specify a copyright message for files that do not contain one.
-
---license-file=file::
-The contents of the file will be used as licence information to
-be added to the map.
+
+--copyright-message=note::
+Specify a copyright message for files that do not contain one.
+A fixed copyright message that is visible in BaseCamp, but not on a
+device, is also included.
+
+--copyright-file=file::
+Specify copyright messages from a file. Used if you need to display more
+than one copyright message or do not want the fixed copyright message to
+be included. Note that the first copyright message is not displayed on a
+device, but is shown in BaseCamp. You can make the first line of the
+copyright file blank to work around this.
+
+--license-file=file::
+The contents of the file will be used as licence information to
+be added to the map.
diff --git a/resources/help/en/options b/resources/help/en/options
index e8ac20f..f13bef2 100644
--- a/resources/help/en/options
+++ b/resources/help/en/options
@@ -280,12 +280,17 @@ Product description options:
Area name is displayed on Garmin units (or at least on eTrex) as the second
part of the mapname in the list of the individual maps.
---copyright-message=note
- Specify a copyright message for files that do not contain one.
-
---license-file=file
- Specify a file which content will be added as license.
- All entrys of all maps will be merged in the overview map.
+--copyright-message=note
+ Specify a copyright message for files that do not contain one.
+
+--copyright-file=file
+ Specify copyright messages from a file.
+ Note that the first copyright message is not displayed on a device, but is
+ shown in BaseCamp.
+
+--license-file=file
+ Specify a file which content will be added as license.
+ All entrys of all maps will be merged in the overview map.
Optimization options:
diff --git a/resources/mkgmap-version.properties b/resources/mkgmap-version.properties
index 0ad5766..78cc6d5 100644
--- a/resources/mkgmap-version.properties
+++ b/resources/mkgmap-version.properties
@@ -1,2 +1,2 @@
-svn.version: 3419
-build.timestamp: 2015-01-19T20:25:08+0000
+svn.version: 3436
+build.timestamp: 2015-02-02T06:43:48+0000
diff --git a/resources/styles/default/relations b/resources/styles/default/relations
index cbc587c..5747337 100644
--- a/resources/styles/default/relations
+++ b/resources/styles/default/relations
@@ -38,8 +38,7 @@ type=route
# Stops can be grouped within subrelations comprising the vehicle
# stop node and the passenger wait node.
apply { # node role ~ '(start_|end_)stop'
- set route_ref='$(route_ref),${ref}' | '${ref}';
-
+ set route_ref='$(route_ref);${ref|not-contained:;:route_ref}' | '$(route_ref)' | '${ref}';
# In route relations, stops may be defined as relations that group
# the passenger wait area and the vehicle stop area. If such
# subrelations exist, copy the ref to them too.
diff --git a/src/uk/me/parabola/mkgmap/build/MapBuilder.java b/src/uk/me/parabola/mkgmap/build/MapBuilder.java
index cf9d28a..94d4340 100644
--- a/src/uk/me/parabola/mkgmap/build/MapBuilder.java
+++ b/src/uk/me/parabola/mkgmap/build/MapBuilder.java
@@ -859,19 +859,20 @@ public class MapBuilder implements Configurable {
info += s.trim() + "\n";
}
if (!info.isEmpty())
- map.addInfo(info);
- if (copyrights.isEmpty()){
- // There has to be (at least) two copyright messages or else the map
- // does not show up. The second one will be displayed at startup,
- // although the conditions where that happens are not known.
- map.addCopyright("program licenced under GPL v2");
-
- // This one gets shown when you switch on, so put the actual
- // map copyright here.
- for (String cm : src.copyrightMessages())
- map.addCopyright(cm);
- } else {
- for (String cm : copyrights)
+ map.addInfo(info);
+ if (copyrights.isEmpty()){
+ // There has to be (at least) two copyright messages or else the map
+ // does not show up. The second and subsequent ones will be displayed
+ // at startup, although the conditions where that happens are not known.
+ // All copyright messages are displayed in BaseCamp.
+ String[] copyrightMessages = src.copyrightMessages();
+ if (copyrightMessages.length < 2)
+ map.addCopyright("program licenced under GPL v2");
+
+ for (String cm : copyrightMessages)
+ map.addCopyright(cm);
+ } else {
+ for (String cm : copyrights)
map.addCopyright(cm);
}
}
diff --git a/src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java b/src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java
index a11ea4d..d5a98d9 100644
--- a/src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java
+++ b/src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java
@@ -138,7 +138,7 @@ public class StyledConverter implements OsmConverter {
private int reportDeadEnds;
private final boolean linkPOIsToWays;
private final boolean mergeRoads;
- private WrongAngleFixer wrongAngleFixer;
+
private LineAdder lineAdder = new LineAdder() {
public void add(MapLine element) {
@@ -197,7 +197,7 @@ public class StyledConverter implements OsmConverter {
// undocumented option - usually used for debugging only
mergeRoads = props.getProperty("no-mergeroads", false) == false;
- wrongAngleFixer = new WrongAngleFixer(bbox);
+
}
/** One type result for ways to avoid recreating one for each way. */
@@ -540,7 +540,7 @@ public class StyledConverter implements OsmConverter {
findUnconnectedRoads();
rotateClosedWaysToFirstNode();
filterCoordPOI();
-
+ WrongAngleFixer wrongAngleFixer = new WrongAngleFixer(bbox);
wrongAngleFixer.optimizeWays(roads, lines, modifiedRoads, deletedRoads, restrictions);
// make sure that copies of modified roads have equal points
diff --git a/src/uk/me/parabola/mkgmap/osmstyle/WrongAngleFixer.java b/src/uk/me/parabola/mkgmap/osmstyle/WrongAngleFixer.java
index 7e22452..cc164b6 100644
--- a/src/uk/me/parabola/mkgmap/osmstyle/WrongAngleFixer.java
+++ b/src/uk/me/parabola/mkgmap/osmstyle/WrongAngleFixer.java
@@ -63,6 +63,17 @@ public class WrongAngleFixer {
public WrongAngleFixer(Area bbox) {
this.bbox = bbox;
+ if (gpxPath != null && bbox != null){
+ if (bbox.getWidth() * bbox.getHeight() < 100000){
+ List<Coord> grid = new ArrayList<>();
+ for (int lat = bbox.getMinLat(); lat < bbox.getMaxLat(); lat++){
+ for (int lon = bbox.getMinLong(); lon < bbox.getMaxLong(); lon++){
+ grid.add(new Coord(lat,lon));
+ }
+ }
+ GpxCreator.createGpx("e:/ld/grid", bbox.toCoords(), grid);
+ }
+ }
}
/**
diff --git a/src/uk/me/parabola/mkgmap/osmstyle/actions/NotContainedFilter.java b/src/uk/me/parabola/mkgmap/osmstyle/actions/NotContainedFilter.java
new file mode 100644
index 0000000..9ebfa14
--- /dev/null
+++ b/src/uk/me/parabola/mkgmap/osmstyle/actions/NotContainedFilter.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2015.
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License version 3 or version 2 as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ */
+package uk.me.parabola.mkgmap.osmstyle.actions;
+
+import java.util.regex.Pattern;
+
+import uk.me.parabola.mkgmap.reader.osm.Element;
+import uk.me.parabola.mkgmap.reader.osm.TagDict;
+import uk.me.parabola.mkgmap.scan.SyntaxException;
+
+/**
+ * This can be used to filter out redundant values.<br>
+ * <br>
+ * The filter checks whether the value is contained within another tag's value.
+ * If so, a null string is returned.<br>
+ * <br>
+ * Another tag should consist of values separated by a delimiter (semicolon ';'
+ * by default).<br>
+ * <br>
+ * Example:<br>
+ * <code>
+ * type=route & route=bus & ref=* {<br>
+ * apply {<br>
+ * set route_ref='$(route_ref),${ref|not-contained:,:route_ref}' | '$(route_ref)' | '${ref}';<br>
+ * }<br>
+ * }</code><br>
+ * Here, ref value is only added to route_ref when it is not already contained
+ * in that list (with separator ','). Otherwise, the value of route_ref is
+ * unchanged.
+ *
+ * @author Maxim Duester
+ */
+public class NotContainedFilter extends ValueFilter {
+ private String separator;
+ private short tagKey;
+
+ public NotContainedFilter(String arg) {
+ String[] temp = arg.split(":");
+
+ if (temp.length < 2 || temp[1].isEmpty())
+ throw new SyntaxException(
+ "Missing tag to compare in style not-contained command: "
+ + arg);
+
+ // set the separator (default to ;)
+ if (temp[0].length() > 0)
+ separator = temp[0];
+ else
+ separator = ";";
+ // set the tag short value
+ tagKey = TagDict.getInstance().xlate(temp[1]);
+ }
+
+ public String doFilter(String value, Element el) {
+ if (value == null)
+ return null;
+
+ String tagValue = el.getTag(tagKey);
+ // tag not found => value not in tag's value
+ if (tagValue == null)
+ return value;
+
+ // split uses a regex we need to replace special characters
+ String[] temp = tagValue.split(Pattern.quote(separator));
+
+ for (String s : temp)
+ if (s.equals(value))
+ return null;
+
+ // nothing found => value not in tag's value
+ return value;
+ }
+}
diff --git a/src/uk/me/parabola/mkgmap/osmstyle/actions/ValueBuilder.java b/src/uk/me/parabola/mkgmap/osmstyle/actions/ValueBuilder.java
index 36be8cc..37c934c 100644
--- a/src/uk/me/parabola/mkgmap/osmstyle/actions/ValueBuilder.java
+++ b/src/uk/me/parabola/mkgmap/osmstyle/actions/ValueBuilder.java
@@ -236,6 +236,9 @@ public class ValueBuilder {
case "country-ISO":
item.addFilter(new CountryISOFilter());
break;
+ case "not-contained":
+ item.addFilter(new NotContainedFilter(arg));
+ break;
default:
throw new SyntaxException(String.format("Unknown filter '%s'", cmd));
}
diff --git a/src/uk/me/parabola/mkgmap/osmstyle/actions/ValueItem.java b/src/uk/me/parabola/mkgmap/osmstyle/actions/ValueItem.java
index 3299598..1798259 100644
--- a/src/uk/me/parabola/mkgmap/osmstyle/actions/ValueItem.java
+++ b/src/uk/me/parabola/mkgmap/osmstyle/actions/ValueItem.java
@@ -47,7 +47,7 @@ public class ValueItem {
Element e = tagname_is_local ? local_el : el;
String tagval = e.getTag(tagKey);
if (filter != null)
- value = filter.filter(tagval,el);
+ value = filter.filter(tagval, local_el);
else
value = tagval;
}
diff --git a/src/uk/me/parabola/mkgmap/reader/osm/Element.java b/src/uk/me/parabola/mkgmap/reader/osm/Element.java
index 972d4e2..0c36786 100644
--- a/src/uk/me/parabola/mkgmap/reader/osm/Element.java
+++ b/src/uk/me/parabola/mkgmap/reader/osm/Element.java
@@ -22,13 +22,13 @@ import java.util.Map;
/**
* Superclass of the node, segment and way OSM elements.
*/
-public abstract class Element {
- private Tags tags;
- private long id;
- private long OriginalId;
-
- public int getTagCount() {
- return (tags == null ? 0 : tags.size());
+public abstract class Element {
+ private Tags tags;
+ private long id;
+ private long originalId;
+
+ public int getTagCount() {
+ return (tags == null ? 0 : tags.size());
}
/**
@@ -168,19 +168,25 @@ public abstract class Element {
}
public long getId() {
- return id;
- }
-
- public long getOriginalId() {
- return OriginalId;
- }
-
- protected void setId(long id) {
- this.id = id;
- OriginalId = id;
- }
-
- public void setFakeId() {
+ return id;
+ }
+
+ /**
+ * Returns the Id of the original OSM element on which this element was based.
+ * <p>
+ * The Id of the original element will be different from the Id of this
+ * element if this element uses a faked Id.
+ */
+ public long getOriginalId() {
+ return originalId;
+ }
+
+ protected void setId(long id) {
+ this.id = id;
+ originalId = id;
+ }
+
+ public void setFakeId() {
id = FakeIdGenerator.makeFakeId();
}
diff --git a/src/uk/me/parabola/mkgmap/reader/osm/OsmMapDataSource.java b/src/uk/me/parabola/mkgmap/reader/osm/OsmMapDataSource.java
index ad83575..ddc29b7 100644
--- a/src/uk/me/parabola/mkgmap/reader/osm/OsmMapDataSource.java
+++ b/src/uk/me/parabola/mkgmap/reader/osm/OsmMapDataSource.java
@@ -14,23 +14,25 @@
* Author: Steve Ratcliffe
* Create date: 22-Sep-2007
*/
-package uk.me.parabola.mkgmap.reader.osm;
-
-import java.io.BufferedReader;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
+package uk.me.parabola.mkgmap.reader.osm;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import uk.me.parabola.imgfmt.FormatException;
-import uk.me.parabola.imgfmt.Utils;
-import uk.me.parabola.log.Logger;
+import java.util.Map;
+import java.util.Set;
+
+import uk.me.parabola.imgfmt.ExitException;
+import uk.me.parabola.imgfmt.FormatException;
+import uk.me.parabola.imgfmt.Utils;
+import uk.me.parabola.log.Logger;
import uk.me.parabola.mkgmap.general.LevelInfo;
import uk.me.parabola.mkgmap.general.LoadableMapDataSource;
import uk.me.parabola.mkgmap.osmstyle.StyleImpl;
@@ -132,12 +134,34 @@ public abstract class OsmMapDataSource extends MapperBasedMapDataSource
* include a fixed set of strings on the assumption that .osm files
* are probably going to have the OSM copyright statements.
*
- * @return A list of copyright messages as a String array.
- */
- public String[] copyrightMessages() {
- String note = getConfig().getProperty("copyright-message",
- "OpenStreetMap.org contributors. See: http://wiki.openstreetmap.org/index.php/Attribution");
- return new String[] { note };
+ * @return A list of copyright messages as a String array.
+ */
+ public String[] copyrightMessages() {
+ String copyrightFileName = getConfig().getProperty("copyright-file", null);
+ if (copyrightFileName != null)
+ {
+ File file = new File(copyrightFileName);
+ List<String> copyrightArray = new ArrayList<String>();
+ try {
+ BufferedReader reader = new BufferedReader(new FileReader(file));
+ String text;
+ while ((text = reader.readLine()) != null) {
+ copyrightArray.add(text);
+ }
+
+ reader.close();
+ } catch (FileNotFoundException e) {
+ throw new ExitException("Could not open copyright file " + copyrightFileName);
+ } catch (IOException e) {
+ throw new ExitException("Error reading copyright file " + copyrightFileName);
+ }
+ String[] copyright = new String[copyrightArray.size()];
+ copyrightArray.toArray(copyright);
+ return copyright;
+ }
+ String note = getConfig().getProperty("copyright-message",
+ "OpenStreetMap.org contributors. See: http://wiki.openstreetmap.org/index.php/Attribution");
+ return new String[] { note };
}
protected void setStyle(Style style) {
diff --git a/src/uk/me/parabola/mkgmap/reader/osm/bin/OsmBinHandler.java b/src/uk/me/parabola/mkgmap/reader/osm/bin/OsmBinHandler.java
index 4031682..72c43cf 100644
--- a/src/uk/me/parabola/mkgmap/reader/osm/bin/OsmBinHandler.java
+++ b/src/uk/me/parabola/mkgmap/reader/osm/bin/OsmBinHandler.java
@@ -67,13 +67,13 @@ public class OsmBinHandler extends OsmHandler {
int tagCount = binNode.getKeysCount();
if (tagCount > 0) {
- Node node = new Node(id, co);
- for (int tid = 0; tid < tagCount; tid++) {
- String key = getStringById(binNode.getKeys(tid));
- String val = getStringById(binNode.getVals(tid));
- key = keepTag(key, val);
- if (key != null)
- node.addTag(key, val.intern());
+ Node node = new Node(id, co);
+ for (int tid = 0; tid < tagCount; tid++) {
+ String key = getStringById(binNode.getKeys(tid));
+ String val = getStringById(binNode.getVals(tid)).trim();
+ key = keepTag(key, val);
+ if (key != null)
+ node.addTag(key, val.intern());
}
saver.addNode(node);
@@ -102,13 +102,13 @@ public class OsmBinHandler extends OsmHandler {
int ntags = 0;
Node node = null;
while (nodes.getKeysVals(kvid) != 0) {
- int keyid = nodes.getKeysVals(kvid++);
- int valid = nodes.getKeysVals(kvid++);
- String key = getStringById(keyid);
- String val = getStringById(valid);
- key = keepTag(key, val);
- if (key != null) {
- if (node == null)
+ int keyid = nodes.getKeysVals(kvid++);
+ int valid = nodes.getKeysVals(kvid++);
+ String key = getStringById(keyid);
+ String val = getStringById(valid).trim();
+ key = keepTag(key, val);
+ if (key != null) {
+ if (node == null)
node = new Node(id, co);
node.addTag(key, val.intern());
ntags++;
@@ -129,13 +129,13 @@ public class OsmBinHandler extends OsmHandler {
for (Osmformat.Way binWay : ways) {
Way way = startWay(binWay.getId());
- for (int j = 0; j < binWay.getKeysCount(); j++) {
-
- String key = getStringById(binWay.getKeys(j));
- String val = getStringById(binWay.getVals(j));
- key = keepTag(key, val);
- if (key != null)
- way.addTag(key, val.intern());
+ for (int j = 0; j < binWay.getKeysCount(); j++) {
+
+ String key = getStringById(binWay.getKeys(j));
+ String val = getStringById(binWay.getVals(j)).trim();
+ key = keepTag(key, val);
+ if (key != null)
+ way.addTag(key, val.intern());
}
long nid = 0;
@@ -154,13 +154,13 @@ public class OsmBinHandler extends OsmHandler {
long id = binRel.getId();
GeneralRelation rel = new GeneralRelation(id);
- boolean tagsIncomplete = false;
- for (int j = 0; j < binRel.getKeysCount(); j++) {
- String key = getStringById(binRel.getKeys(j));
- String val = getStringById(binRel.getVals(j));
- // type is required for relations - all other tags are filtered
- if ("type".equals(key))
- // intern the string
+ boolean tagsIncomplete = false;
+ for (int j = 0; j < binRel.getKeysCount(); j++) {
+ String key = getStringById(binRel.getKeys(j));
+ String val = getStringById(binRel.getVals(j)).trim();
+ // type is required for relations - all other tags are filtered
+ if ("type".equals(key))
+ // intern the string
key = "type";
else
key = keepTag(key, val);
diff --git a/src/uk/me/parabola/mkgmap/reader/osm/o5m/O5mBinHandler.java b/src/uk/me/parabola/mkgmap/reader/osm/o5m/O5mBinHandler.java
index c5e843e..26d06ed 100644
--- a/src/uk/me/parabola/mkgmap/reader/osm/o5m/O5mBinHandler.java
+++ b/src/uk/me/parabola/mkgmap/reader/osm/o5m/O5mBinHandler.java
@@ -311,13 +311,13 @@ public class O5mBinHandler extends OsmHandler{
private boolean readTags(Element elem) throws IOException{
boolean tagsIncomplete = false;
- while (bytesToRead > 0){
- readStringPair();
- String key = stringPair[0];
- String val = stringPair[1];
- // the type tag is required for relations - all other tags are filtered
- if (elem instanceof Relation && "type".equals(key))
- // intern the string
+ while (bytesToRead > 0){
+ readStringPair();
+ String key = stringPair[0];
+ String val = stringPair[1].trim();
+ // the type tag is required for relations - all other tags are filtered
+ if (elem instanceof Relation && "type".equals(key))
+ // intern the string
key = "type";
else
key = keepTag(key, val);
diff --git a/src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java b/src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java
index c295b20..730a20d 100644
--- a/src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java
+++ b/src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java
@@ -204,13 +204,13 @@ public class Osm5XmlHandler extends OsmHandler {
* @param qName The new tag name.
* @param attributes Its attributes.
*/
- private void startInNode(String qName, Attributes attributes) {
- if (qName.equals("tag")) {
- String key = attributes.getValue("k");
- String val = attributes.getValue("v");
-
- // We only want to create a full node for nodes that are POI's
- // and not just one point of a way. Only create if it has tags that
+ private void startInNode(String qName, Attributes attributes) {
+ if (qName.equals("tag")) {
+ String key = attributes.getValue("k");
+ String val = attributes.getValue("v").trim();
+
+ // We only want to create a full node for nodes that are POI's
+ // and not just one point of a way. Only create if it has tags that
// could be used in a POI.
key = keepTag(key, val);
if (key != null) {
@@ -232,13 +232,13 @@ public class Osm5XmlHandler extends OsmHandler {
private void startInWay(String qName, Attributes attributes) {
if (qName.equals("nd")) {
long id = idVal(attributes.getValue("ref"));
- addCoordToWay(currentWay, id);
- } else if (qName.equals("tag")) {
- String key = attributes.getValue("k");
- String val = attributes.getValue("v");
- key = keepTag(key, val);
- if (key != null)
- currentWay.addTag(key, val.intern());
+ addCoordToWay(currentWay, id);
+ } else if (qName.equals("tag")) {
+ String key = attributes.getValue("k");
+ String val = attributes.getValue("v").trim();
+ key = keepTag(key, val);
+ if (key != null)
+ currentWay.addTag(key, val.intern());
}
}
@@ -273,13 +273,13 @@ public class Osm5XmlHandler extends OsmHandler {
} else
el = null;
if (el != null) // ignore non existing ways caused by splitting files
- currentRelation.addElement(attributes.getValue("role"), el);
- } else if (qName.equals("tag")) {
- String key = attributes.getValue("k");
- String val = attributes.getValue("v");
- // the type tag is required for relations - all other tags are filtered
- if ("type".equals(key))
- // intern the key
+ currentRelation.addElement(attributes.getValue("role"), el);
+ } else if (qName.equals("tag")) {
+ String key = attributes.getValue("k");
+ String val = attributes.getValue("v").trim();
+ // the type tag is required for relations - all other tags are filtered
+ if ("type".equals(key))
+ // intern the key
key = "type";
else
key = keepTag(key, val);
diff --git a/test/func/route/SimpleRouteTest.java b/test/func/route/SimpleRouteTest.java
index 81f3e07..63a9c67 100644
--- a/test/func/route/SimpleRouteTest.java
+++ b/test/func/route/SimpleRouteTest.java
@@ -67,7 +67,7 @@ public class SimpleRouteTest extends Base {
break;
case "LBL":
count++;
- assertEquals("LBL size", 28744, size);
+ assertEquals("LBL size", 28742, size);
break;
case "NET":
count++;
diff --git a/test/uk/me/parabola/mkgmap/osmstyle/actions/NotContainedFilterTest.java b/test/uk/me/parabola/mkgmap/osmstyle/actions/NotContainedFilterTest.java
new file mode 100644
index 0000000..aaf98bd
--- /dev/null
+++ b/test/uk/me/parabola/mkgmap/osmstyle/actions/NotContainedFilterTest.java
@@ -0,0 +1,83 @@
+package uk.me.parabola.mkgmap.osmstyle.actions;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.junit.Test;
+
+import uk.me.parabola.mkgmap.reader.osm.Element;
+import uk.me.parabola.mkgmap.reader.osm.Way;
+import uk.me.parabola.mkgmap.scan.SyntaxException;
+
+/**
+ * @author Maxim Duester
+ *
+ */
+public class NotContainedFilterTest {
+
+ @Test(expected = SyntaxException.class)
+ public void testNoArg() {
+ NotContainedFilter filter = new NotContainedFilter("");
+ filter.doFilter("x", null);
+ }
+
+ @Test(expected = SyntaxException.class)
+ public void testOneArg() {
+ NotContainedFilter filter = new NotContainedFilter(";");
+ filter.doFilter("x", null);
+ }
+
+ @Test(expected = SyntaxException.class)
+ public void test2ndArgMissing() {
+ NotContainedFilter filter = new NotContainedFilter(":");
+ filter.doFilter("x", null);
+ }
+
+ @Test
+ public void test2ndArgNotContained() {
+ NotContainedFilter filter = new NotContainedFilter(";:ref");
+ Element el = stdElement();
+ String s = filter.doFilter("aa", el);
+ assertEquals(s, "aa");
+ }
+
+ @Test
+ public void test2ndArgContained() {
+ NotContainedFilter filter = new NotContainedFilter(":ref");
+ Element el = stdElement();
+ String s = filter.doFilter("x", el);
+ assertNull(s);
+ }
+
+ @Test
+ public void testNonDefaultDelimiterNotContained() {
+ NotContainedFilter filter = new NotContainedFilter("#:ref");
+ Element el = stdElement();
+ String s = filter.doFilter("x", el);
+ assertEquals(s, "x");
+ }
+
+ @Test
+ public void testNonDefaultDelimiterContained() {
+ NotContainedFilter filter = new NotContainedFilter("#:test");
+ Element el = stdElement();
+ el.addTag("test", "Aa#Bb#Cc#Dd");
+ String s = filter.doFilter("Cc", el);
+ assertNull(s);
+ }
+
+ @Test
+ public void testMissingTag(){
+ NotContainedFilter filter=new NotContainedFilter(":sometag");
+ Element el = stdElement();
+ String s=filter.doFilter("x", el);
+ assertEquals(s, "x");
+ }
+
+ private Element stdElement() {
+ Element el1 = new Way(1);
+ el1.addTag("ref", "x;y;z");
+ return el1;
+ }
+
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/mkgmap.git
More information about the Pkg-grass-devel
mailing list