The patch removes the two tags "type" and "maxspeed" from the
builtin-tag-list.
This reduces memory requirements (a few) if these tags are not required.
Tag "type":
The tag is mandatory for relations. So I think it's ok to implement a
rule in the relation loader that keeps the "type" tag. For nodes and
ways the type tag is used only if it is referenced in the style file.
Tag "maxspeed":
In case the ignore-maxspeeds option is set the maxspeed tag is loaded
anyhow. The new MaxspeedHook adds the maxspeed tag to the used tags only
if the ignore-maxspeeds option is not set.
Any objections or comments?
WanMil
Index: resources/styles/builtin-tag-list
===================================================================
--- resources/styles/builtin-tag-list (revision 2052)
+++ resources/styles/builtin-tag-list (working copy)
@@ -14,11 +14,9 @@
exit:to
int_ref
junction
-maxspeed
mkgmap:gtype
name
nat_ref
oneway
ref
reg_ref
-type
Index: src/uk/me/parabola/mkgmap/reader/osm/MaxspeedHook.java
===================================================================
--- src/uk/me/parabola/mkgmap/reader/osm/MaxspeedHook.java (revision 0)
+++ src/uk/me/parabola/mkgmap/reader/osm/MaxspeedHook.java (revision 0)
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2011.
+ *
+ * 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.reader.osm;
+
+import java.util.Collections;
+import java.util.Set;
+
+import uk.me.parabola.util.EnhancedProperties;
+
+
+/**
+ * This hook is used to decide if the maxspeed tag is used by the StyledConverter.
+ * Maybe in future it can also be used to perform the special maxspeed processing.
+ * @author WanMil
+ */
+public class MaxspeedHook extends OsmReadingHooksAdaptor {
+
+ private final Set<String> usedTags = Collections.singleton("maxspeed");
+
+ public boolean init(ElementSaver saver, EnhancedProperties props) {
+ // return true if the ignore-maxspeeds is not set
+ // in this case the maxspeed tag is used by the StyledConverter
+ return props.getProperty("ignore-maxspeeds") == null;
+ }
+
+ public Set<String> getUsedTags() {
+ return usedTags;
+ }
+}
Index: src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java
===================================================================
--- src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java (revision 2052)
+++ src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java (working copy)
@@ -283,7 +283,12 @@
} else if (qName.equals("tag")) {
String key = attributes.getValue("k");
String val = attributes.getValue("v");
- key = keepTag(key, val);
+
+ // the tag type is a mandatory tag for relations
+ // for all other tags check if they are really used and should be kept
+ if ("type".equals(key) == false) {
+ key = keepTag(key, val);
+ }
if (key != null)
currentRelation.addTag(key, val);
}
Index: src/uk/me/parabola/mkgmap/reader/osm/OsmMapDataSource.java
===================================================================
--- src/uk/me/parabola/mkgmap/reader/osm/OsmMapDataSource.java (revision 2052)
+++ src/uk/me/parabola/mkgmap/reader/osm/OsmMapDataSource.java (working copy)
@@ -54,6 +54,7 @@
new SeaGenerator(),
new MultiPolygonFinishHook(),
new RoutingHook(),
+ new MaxspeedHook(),
new HighwayHooks(),
new LocationHook(),
new Areas2POIHook(),
Index: src/uk/me/parabola/mkgmap/reader/osm/bin/OsmBinHandler.java
===================================================================
--- src/uk/me/parabola/mkgmap/reader/osm/bin/OsmBinHandler.java (revision 2052)
+++ src/uk/me/parabola/mkgmap/reader/osm/bin/OsmBinHandler.java (working copy)
@@ -170,7 +170,11 @@
for (int j = 0; j < binRel.getKeysCount(); j++) {
String key = getStringById(binRel.getKeys(j));
String val = getStringById(binRel.getVals(j));
- key = keepTag(key, val);
+ // the tag type is a mandatory tag for relations
+ // for all other tags check if they are really used and should be kept
+ if ("type".equals(key) == false) {
+ key = keepTag(key, val);
+ }
if (key != null)
rel.addTag(key, val);
}
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev