useless rules in default style inc/address

Hi all, the default style file inc/address starts with these three rules: # first set the country code mkgmap:country!=* & mkgmap:admin_level2=* { set mkgmap:country='${mkgmap:admin_level2}' } mkgmap:country!=* & addr:country=* { set mkgmap:country='${addr:country}' } mkgmap:country!=* & is_in:country=* { set mkgmap:country='${is_in:country}' } I found no code in the mkgmap java sources that sets mkgmap:country, so the first rule will always set mkgmap:country unless one manipulates the OSM data. The following rules evaluate mkgmap:country and expect the ISO 1366 code with 3 characters, e.g. DEU for Germany. The wiki for tag addr:country says that it should contain the 2 character ISO code, e.g. DE for Germany. The is_in:country tag contains the country name, not the iso code. I think we should remove the two useless rules unless someone finds a working alternative. Gerd

El 27/11/14 a las 15:36, Gerd Petermann escribió:
Hi all,
the default style file inc/address starts with these three rules: # first set the country code mkgmap:country!=* & mkgmap:admin_level2=* { set mkgmap:country='${mkgmap:admin_level2}' } mkgmap:country!=* & addr:country=* { set mkgmap:country='${addr:country}' } mkgmap:country!=* & is_in:country=* { set mkgmap:country='${is_in:country}' }
I found no code in the mkgmap java sources that sets mkgmap:country, so the first rule will always set mkgmap:country unless one manipulates the OSM data.
The following rules evaluate mkgmap:country and expect the ISO 1366 code with 3 characters, e.g. DEU for Germany. The wiki for tag addr:country says that it should contain the 2 character ISO code, e.g. DE for Germany. The is_in:country tag contains the country name, not the iso code.
I think we should remove the two useless rules unless someone finds a working alternative.
Gerd
LocatorConfig.xml contains 2 and 3 character ISO codes for each country. Could it be that mkgmap assigns the 3 char ISO code to mkgmap:country using it when addr:country or is_in:country are evaluated?

Hi Carlos, I am not sure what you mean, but mkgmap doesn't contain java code to set or evaluate the tags addr:country or is_in:country. Gerd Carlos Dávila-2 wrote
El 27/11/14 a las 15:36, Gerd Petermann escribió:
Hi all,
the default style file inc/address starts with these three rules: # first set the country code mkgmap:country!=* & mkgmap:admin_level2=* { set mkgmap:country='${mkgmap:admin_level2}' } mkgmap:country!=* & addr:country=* { set mkgmap:country='${addr:country}' } mkgmap:country!=* & is_in:country=* { set mkgmap:country='${is_in:country}' }
I found no code in the mkgmap java sources that sets mkgmap:country, so the first rule will always set mkgmap:country unless one manipulates the OSM data.
The following rules evaluate mkgmap:country and expect the ISO 1366 code with 3 characters, e.g. DEU for Germany. The wiki for tag addr:country says that it should contain the 2 character ISO code, e.g. DE for Germany. The is_in:country tag contains the country name, not the iso code.
I think we should remove the two useless rules unless someone finds a working alternative.
Gerd
LocatorConfig.xml contains 2 and 3 character ISO codes for each country. Could it be that mkgmap assigns the 3 char ISO code to mkgmap:country using it when addr:country or is_in:country are evaluated? _______________________________________________ mkgmap-dev mailing list
mkgmap-dev@.org
-- View this message in context: http://gis.19327.n5.nabble.com/useless-rules-in-default-style-inc-address-tp... Sent from the Mkgmap Development mailing list archive at Nabble.com.

El 27/11/14 a las 16:22, GerdP escribió:
Hi Carlos,
I am not sure what you mean, but mkgmap doesn't contain java code to set or evaluate the tags addr:country or is_in:country.
Gerd
Carlos Dávila-2 wrote
El 27/11/14 a las 15:36, Gerd Petermann escribió:
Hi all,
the default style file inc/address starts with these three rules: # first set the country code mkgmap:country!=* & mkgmap:admin_level2=* { set mkgmap:country='${mkgmap:admin_level2}' } mkgmap:country!=* & addr:country=* { set mkgmap:country='${addr:country}' } mkgmap:country!=* & is_in:country=* { set mkgmap:country='${is_in:country}' }
I found no code in the mkgmap java sources that sets mkgmap:country, so the first rule will always set mkgmap:country unless one manipulates the OSM data.
The following rules evaluate mkgmap:country and expect the ISO 1366 code with 3 characters, e.g. DEU for Germany. The wiki for tag addr:country says that it should contain the 2 character ISO code, e.g. DE for Germany. The is_in:country tag contains the country name, not the iso code.
I think we should remove the two useless rules unless someone finds a working alternative.
Gerd
LocatorConfig.xml contains 2 and 3 character ISO codes for each country. Could it be that mkgmap assigns the 3 char ISO code to mkgmap:country using it when addr:country or is_in:country are evaluated?
I meant that perhaps if mkgmap finds addr:country=DE it reads in LocatorConfig that DE ISO 2 corresponds to DEU ISO 3 and assings DEU to mkgmap:country, but if it has no code to evaluate addr:country it's not possible.

Hi Carlos, okay, got it. Maybe we can add a style function to convert from/to ISO codes. Gerd Carlos Dávila-2 wrote
El 27/11/14 a las 16:22, GerdP escribió:
Hi Carlos,
I am not sure what you mean, but mkgmap doesn't contain java code to set or evaluate the tags addr:country or is_in:country.
Gerd
Carlos Dávila-2 wrote
El 27/11/14 a las 15:36, Gerd Petermann escribió:
Hi all,
the default style file inc/address starts with these three rules: # first set the country code mkgmap:country!=* & mkgmap:admin_level2=* { set mkgmap:country='${mkgmap:admin_level2}' } mkgmap:country!=* & addr:country=* { set mkgmap:country='${addr:country}' } mkgmap:country!=* & is_in:country=* { set mkgmap:country='${is_in:country}' }
I found no code in the mkgmap java sources that sets mkgmap:country, so the first rule will always set mkgmap:country unless one manipulates the OSM data.
The following rules evaluate mkgmap:country and expect the ISO 1366 code with 3 characters, e.g. DEU for Germany. The wiki for tag addr:country says that it should contain the 2 character ISO code, e.g. DE for Germany. The is_in:country tag contains the country name, not the iso code.
I think we should remove the two useless rules unless someone finds a working alternative.
Gerd
LocatorConfig.xml contains 2 and 3 character ISO codes for each country. Could it be that mkgmap assigns the 3 char ISO code to mkgmap:country using it when addr:country or is_in:country are evaluated?
I meant that perhaps if mkgmap finds addr:country=DE it reads in LocatorConfig that DE ISO 2 corresponds to DEU ISO 3 and assings DEU to mkgmap:country, but if it has no code to evaluate addr:country it's not possible.
mkgmap-dev mailing list
mkgmap-dev@.org
-- View this message in context: http://gis.19327.n5.nabble.com/useless-rules-in-default-style-inc-address-tp... Sent from the Mkgmap Development mailing list archive at Nabble.com.

Hi Gerd, the address file is an include and you don't know what happens before. Maybe it is not set in the mkgmap style. But the address file is quite general and so it is probably used by other styles which might have some special rules before "include address" that set mkgmap:country. So I would recommend to leave it as it is (I think the style optimizer will reduce the performance drawbacks of the one additional mkgmap:country!=* ). I would like to use mkgmap:country!=* { set mkgmap:country='${mkgmap:admin_level2}'|'${addr:country}'|'${is_in:country}' } But that doesn't work because it is not allowed to use a != rule only. Maybe you have a good idea to tweak it so that it works in such a way. You are right that this assignment does not normalize the country codes within the styles. It would be good to add that. A function need to call Locator.getCountryISOCode(String). This returns the three letter ISO code. All values listed in the Locator.xml are accepted (name, ISO code, variants). Additionally it learns automatically all localization variants from the loaded bounds files. Just start at BoundaryLocationPreparer.parseTags(String). For all other values that are still not mapped the uppercase string is returned. At the moment mkgmap:country is normalized after the style file processing in the MapBuilder class. Just search for locator.getCountryISOCode(String). Ulrich
Hi all,
the default style file inc/address starts with these three rules: # first set the country code mkgmap:country!=* & mkgmap:admin_level2=* { set mkgmap:country='${mkgmap:admin_level2}' } mkgmap:country!=* & addr:country=* { set mkgmap:country='${addr:country}' } mkgmap:country!=* & is_in:country=* { set mkgmap:country='${is_in:country}' }
I found no code in the mkgmap java sources that sets mkgmap:country, so the first rule will always set mkgmap:country unless one manipulates the OSM data.
The following rules evaluate mkgmap:country and expect the ISO 1366 code with 3 characters, e.g. DEU for Germany. The wiki for tag addr:country says that it should contain the 2 character ISO code, e.g. DE for Germany. The is_in:country tag contains the country name, not the iso code.
I think we should remove the two useless rules unless someone finds a working alternative.
Gerd
_______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Hi WanMil,
the address file is an include and you don't know what happens before. Maybe it is not set in the mkgmap style. But the address file is quite general and so it is probably used by other styles which might have some special rules before "include address" that set mkgmap:country.
So I would recommend to leave it as it is (I think the style optimizer will reduce the performance drawbacks of the one additional mkgmap:country!=* ).
OK. I don't mind to have a few more simple rules, I just wanted to point out that they will probably not produce the wanted result.
I would like to use mkgmap:country!=* { set mkgmap:country='${mkgmap:admin_level2}'|'${addr:country}'|'${is_in:country}' } But that doesn't work because it is not allowed to use a != rule only. Maybe you have a good idea to tweak it so that it works in such a way.
OK, I'll have a look. Up to now I don't even know why it is not allowed.
You are right that this assignment does not normalize the country codes within the styles. It would be good to add that.
OK. I'll try to code the style function. Sounds easy enough. Gerd
A function need to call Locator.getCountryISOCode(String). This returns the three letter ISO code. All values listed in the Locator.xml are accepted (name, ISO code, variants). Additionally it learns automatically all localization variants from the loaded bounds files. Just start at BoundaryLocationPreparer.parseTags(String). For all other values that are still not mapped the uppercase string is returned.
At the moment mkgmap:country is normalized after the style file processing in the MapBuilder class. Just search for locator.getCountryISOCode(String).
Ulrich
Hi all,
the default style file inc/address starts with these three rules: # first set the country code mkgmap:country!=* & mkgmap:admin_level2=* { set mkgmap:country='${mkgmap:admin_level2}' } mkgmap:country!=* & addr:country=* { set mkgmap:country='${addr:country}' } mkgmap:country!=* & is_in:country=* { set mkgmap:country='${is_in:country}' }
I found no code in the mkgmap java sources that sets mkgmap:country, so the first rule will always set mkgmap:country unless one manipulates the OSM data.
The following rules evaluate mkgmap:country and expect the ISO 1366 code with 3 characters, e.g. DEU for Germany. The wiki for tag addr:country says that it should contain the 2 character ISO code, e.g. DE for Germany. The is_in:country tag contains the country name, not the iso code.
I think we should remove the two useless rules unless someone finds a working alternative.
Gerd
_______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
_______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev
participants (4)
-
Carlos Dávila
-
Gerd Petermann
-
GerdP
-
WanMil