Attached patch realizes the proposals.
Please test it and if possible give a note if there is a speed improvement for specialized styles.

WanMil


Hi,

I want to remove a long list of tags from the builtin-tag-list by
different actions. The advantage is that specialised styles that do not
need these tags are faster and do consume less memory.

== Tags that are no longer used ==

Tag: osm:id
There are only two references in mkgmap source code: HighwayHook sets
this tag and StyleConverter that reads this tag. I think this is not an
OSM tag but a tag set internally by mkgmap.
If so we should rename it to mkgmap:osmid. Any objections?

Tag: openGeoDB:postal_codes
I haven't found any references in the source code. openGeoDB workout
have been removed with locator branch merge.

== Tags that can be moved to style handling ==

I am thinking about moving some static coded rules (e.g. name of a POI
street is taken from tag "addr:street") to the style system as it has
been done with other location items:
mkgmap:street!=*&  addr:street=* { set mkgmap:street='${addr:street}' }

This has two advantages:
1. Speed improvement for styles that don't use this information. (Marko:
this should help you with your need for speed improvements for special
styles)

2. More flexiblity: If someone likes to use different tags for a POI
street name it is easy to configure that.

Possible downside:
* Little more memory requirement for styles that use address information

The tags to be changed are:
addr:street
addr:housename
addr:housenumber
addr:phone (is currently not used in mkgmap)
phone
is_in


== Tags that are used only if --route is set ==

I am not sure if that's correct. Can someone please confirm that?

access
bicycle
carpool
delivery
emergency
except
exception
foot
goods
hgv
motorcar
motorcycle
psv
restriction
route
taxi
toll


I would certainly agree with you on the addr: tags; the way it is
currently done internal to the mkgmap code is a little confusing and
it would be much more flexible if the address treatment was moved to
the points style file.

Not sure about addr:phone though - isn't this deprecated and instead
phone=* is used to fill the telephone field in the address form?

Just my two fils,


Charlie

_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev


Index: resources/styles/default/lines
===================================================================
--- resources/styles/default/lines	(revision 2018)
+++ resources/styles/default/lines	(working copy)
@@ -69,6 +69,15 @@
 mkgmap:postal_code!=* & mkgmap:postcode=* { set mkgmap:postal_code='${mkgmap:postcode}' } 
 mkgmap:postal_code!=* & addr:postcode=* { set mkgmap:postal_code='${addr:postcode}' } 
 
+mkgmap:street!=* & addr:street=* { set mkgmap:street='${addr:street}' }
+mkgmap:street!=* & addr:housename=* { set mkgmap:street='${addr:housename}' }
+
+mkgmap:housenumber!=* & addr:housenumber=* { set mkgmap:housenumber='${addr:housenumber}' }
+
+mkgmap:phone!=* & phone=* { set mkgmap:phone='${phone}' }
+
+mkgmap:is_in!=* & is_in=* { set mkgmap:is_in='${is_in}' }
+
 
 aeroway=runway [0x27 resolution 20]
 aeroway=taxiway [0x27 resolution 24]
Index: resources/styles/default/polygons
===================================================================
--- resources/styles/default/polygons	(revision 2018)
+++ resources/styles/default/polygons	(working copy)
@@ -69,6 +69,18 @@
 mkgmap:postal_code!=* & mkgmap:postcode=* { set mkgmap:postal_code='${mkgmap:postcode}' } 
 mkgmap:postal_code!=* & addr:postcode=* { set mkgmap:postal_code='${addr:postcode}' } 
 
+mkgmap:postal_code!=* & mkgmap:postcode=* { set mkgmap:postal_code='${mkgmap:postcode}' } 
+mkgmap:postal_code!=* & addr:postcode=* { set mkgmap:postal_code='${addr:postcode}' } 
+
+mkgmap:street!=* & addr:street=* { set mkgmap:street='${addr:street}' }
+mkgmap:street!=* & addr:housename=* { set mkgmap:street='${addr:housename}' }
+
+mkgmap:housenumber!=* & addr:housenumber=* { set mkgmap:housenumber='${addr:housenumber}' }
+
+mkgmap:phone!=* & phone=* { set mkgmap:phone='${phone}' }
+
+mkgmap:is_in!=* & is_in=* { set mkgmap:is_in='${is_in}' }
+
 
 aeroway=airport [0x07 resolution 20]
 aeroway=aerodrome [0x07 resolution 20]
Index: resources/styles/default/points
===================================================================
--- resources/styles/default/points	(revision 2018)
+++ resources/styles/default/points	(working copy)
@@ -69,6 +69,18 @@
 mkgmap:postal_code!=* & mkgmap:postcode=* { set mkgmap:postal_code='${mkgmap:postcode}' } 
 mkgmap:postal_code!=* & addr:postcode=* { set mkgmap:postal_code='${addr:postcode}' } 
 
+mkgmap:postal_code!=* & mkgmap:postcode=* { set mkgmap:postal_code='${mkgmap:postcode}' } 
+mkgmap:postal_code!=* & addr:postcode=* { set mkgmap:postal_code='${addr:postcode}' } 
+
+mkgmap:street!=* & addr:street=* { set mkgmap:street='${addr:street}' }
+mkgmap:street!=* & addr:housename=* { set mkgmap:street='${addr:housename}' }
+
+mkgmap:housenumber!=* & addr:housenumber=* { set mkgmap:housenumber='${addr:housenumber}' }
+
+mkgmap:phone!=* & phone=* { set mkgmap:phone='${phone}' }
+
+mkgmap:is_in!=* & is_in=* { set mkgmap:is_in='${is_in}' }
+
 internet_access=yes { name 'Internet ${name}' | 'Internet' } [0x2f12 resolution 24 continue]
 internet_access=* & internet_access!=no & internet_access!=yes { name 'Internet(${internet_access}) ${name|def:}' } [0x2f12 resolution 24 continue]
 
Index: resources/styles/builtin-tag-list
===================================================================
--- resources/styles/builtin-tag-list	(revision 2018)
+++ resources/styles/builtin-tag-list	(working copy)
@@ -8,42 +8,17 @@
 # later recognised by mkgmap. In general these begin with the
 # string 'mkgmap:'
 #
-access
-addr:housename
-addr:housenumber
-addr:phone
-addr:street
-bicycle
-carpool
-delivery
 display_name
-emergency
-except
-exception
 exit:facility
 exit:road_ref
 exit:to
-foot
-goods
-hgv
 int_ref
-is_in
 junction
 maxspeed
 mkgmap:gtype
-motorcar
-motorcycle
 name
 nat_ref
 oneway
-openGeoDB:postal_codes
-osm:id
-phone
-psv
 ref
 reg_ref
-restriction
-route
-taxi
-toll
 type
Index: src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java	(revision 2018)
+++ src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java	(working copy)
@@ -560,7 +560,7 @@
 		int type = gt.getType();
 		if(type >= 0x2000 && type < 0x2800) {
 			String ref = node.getTag(Exit.TAG_ROAD_REF);
-			String id = node.getTag("osm:id");
+			String id = node.getTag("mkgmap:osmid");
 			if(ref != null) {
 				String to = node.getTag(Exit.TAG_TO);
 				MapExitPoint mep = new MapExitPoint(ref, to);
@@ -667,11 +667,10 @@
 		String region       = element.getTag("mkgmap:region");
 		String city         = element.getTag("mkgmap:city");
 		String zip          = element.getTag("mkgmap:postal_code");
-		String street 	    = element.getTag("addr:street");
-		String housename    = element.getTag("addr:housename");
-		String houseNumber  = element.getTag("addr:housenumber");
-		String phone        = element.getTag("phone");
-		String isIn         = element.getTag("is_in");
+		String street 	    = element.getTag("mkgmap:street");
+		String houseNumber  = element.getTag("mkgmap:housenumber");
+		String phone        = element.getTag("mkgmap:phone");
+		String isIn         = element.getTag("mkgmap:is_in");
 
 		if(country != null)
 			ms.setCountry(country);
@@ -687,8 +686,6 @@
 		  
 		if(street != null)
 			ms.setStreet(street);
-		else if (housename != null)
-			ms.setStreet(housename);
 
 		if(houseNumber != null)
 			ms.setHouseNumber(houseNumber);
Index: src/uk/me/parabola/mkgmap/reader/osm/RoutingHook.java
===================================================================
--- src/uk/me/parabola/mkgmap/reader/osm/RoutingHook.java	(revision 0)
+++ src/uk/me/parabola/mkgmap/reader/osm/RoutingHook.java	(revision 0)
@@ -0,0 +1,65 @@
+/*
+ * 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.HashSet;
+import java.util.Set;
+
+import uk.me.parabola.mkgmap.osmstyle.StyledConverter;
+import uk.me.parabola.util.EnhancedProperties;
+
+/**
+ * This hook performs some steps required for routing. <br/>
+ * At the moment the only function is to add tags used for routing to the
+ * overall tag list. The rest of the routing work is done in the 
+ * {@link StyledConverter} class.
+ * @author WanMil
+ *
+ */
+public class RoutingHook extends OsmReadingHooksAdaptor {
+
+	private final Set<String> usedTags;
+	
+	public RoutingHook() {
+		usedTags = new HashSet<String>();
+		usedTags.add("access");
+		usedTags.add("bicycle");
+		usedTags.add("carpool");
+		usedTags.add("delivery");
+		usedTags.add("emergency");
+		usedTags.add("except");
+		usedTags.add("exception");
+		usedTags.add("foot");
+		usedTags.add("goods");
+		usedTags.add("hgv");
+		usedTags.add("motorcar");
+		usedTags.add("motorcycle");
+		usedTags.add("psv");
+		usedTags.add("restriction");
+		usedTags.add("route");
+		usedTags.add("taxi");
+		usedTags.add("toll");
+	}
+
+	public boolean init(ElementSaver saver, EnhancedProperties props) {
+		return props.containsKey("route");
+	}
+
+
+	public Set<String> getUsedTags() {
+		return usedTags;
+	}
+	
+
+}
Index: src/uk/me/parabola/mkgmap/reader/osm/OsmMapDataSource.java
===================================================================
--- src/uk/me/parabola/mkgmap/reader/osm/OsmMapDataSource.java	(revision 2018)
+++ src/uk/me/parabola/mkgmap/reader/osm/OsmMapDataSource.java	(working copy)
@@ -53,6 +53,7 @@
 	private final OsmReadingHooks[] POSSIBLE_HOOKS = {
 			new SeaGenerator(),
 			new MultiPolygonFinishHook(),
+			new RoutingHook(),
 			new HighwayHooks(),
 			new LocationHook(),
 	};
Index: src/uk/me/parabola/mkgmap/reader/osm/HighwayHooks.java
===================================================================
--- src/uk/me/parabola/mkgmap/reader/osm/HighwayHooks.java	(revision 2018)
+++ src/uk/me/parabola/mkgmap/reader/osm/HighwayHooks.java	(working copy)
@@ -96,7 +96,7 @@
 		String val = node.getTag("highway");
 		if (val != null && (val.equals("motorway_junction") || val.equals("services"))) {
 			exits.add(node);
-			node.addTag("osm:id", String.valueOf(node.getId()));
+			node.addTag("mkgmap:osmid", String.valueOf(node.getId()));
 		}
 	}
 
Index: src/uk/me/parabola/mkgmap/reader/osm/MultiPolygonFinishHook.java
===================================================================
--- src/uk/me/parabola/mkgmap/reader/osm/MultiPolygonFinishHook.java	(revision 2018)
+++ src/uk/me/parabola/mkgmap/reader/osm/MultiPolygonFinishHook.java	(working copy)
@@ -1,3 +1,15 @@
+/*
+ * 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.Arrays;
@@ -13,13 +25,11 @@
 	public MultiPolygonFinishHook() {
 	}
 
-	@Override
 	public boolean init(ElementSaver saver, EnhancedProperties props) {
 		this.saver = saver;
 		return true;
 	}
 
-	@Override
 	public void end() {
 		long t1 = System.currentTimeMillis();
 		log.info("Finishing multipolygons");
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to