From 7fde574dfc772f65bc96f28928e355c21192e705 Mon Sep 17 00:00:00 2001 From: Tomas Vajda Date: Sat, 18 Jun 2022 16:46:36 +0200 Subject: [PATCH 1/3] Add support for hiking colours and symbols --- data/functions.sql | 6 +- requirements.txt | 5 +- vectordatasource/transform.py | 143 ++++++++++++++++++++++------------ yaml/roads.yaml | 14 ++-- 4 files changed, 106 insertions(+), 62 deletions(-) diff --git a/data/functions.sql b/data/functions.sql index 21b9439c6..5da08a996 100644 --- a/data/functions.sql +++ b/data/functions.sql @@ -127,7 +127,7 @@ FROM ( unnest(tags) AS unnested FROM ( SELECT - mz_modify_network(hstore(tags))->ARRAY['route','network','ref'] AS tags + mz_modify_network(hstore(tags))->ARRAY['route','network','ref','colour','symbol'] AS tags FROM planet_osm_rels WHERE @@ -135,7 +135,9 @@ FROM ( parts[way_off+1:rel_off] && ARRAY[way_id] AND hstore(tags) ? 'route' AND (hstore(tags) ? 'network' OR - hstore(tags) ? 'ref') + hstore(tags) ? 'ref') AND + hstore(tags) ? 'colour' AND + hstore(tags) ? 'symbol' ) inner1 ) inner2; $$ LANGUAGE sql STABLE; diff --git a/requirements.txt b/requirements.txt index 357c281e5..3f2b96816 100644 --- a/requirements.txt +++ b/requirements.txt @@ -21,9 +21,10 @@ simplejson==3.12.0 six==1.11.0 StreetNames==0.1.5 tqdm==4.31.1 -urllib3==1.24.3 ## REMOVE THIS AS SOON AS botocore ALLOWS >=1.25 +urllib3==1.25.11 +webcolors<=1.11 ## Last version to support py2 Werkzeug==0.12.2 wsgiref==0.1.2 -git+https://github.com/tilezen/tilequeue@master#egg=tilequeue +git+https://github.com/tilezen/tilequeue@v2.4.1-final#egg=tilequeue git+https://github.com/tilezen/tileserver@master#egg=tileserver git+https://github.com/tilezen/raw_tiles@master#egg=raw_tiles diff --git a/vectordatasource/transform.py b/vectordatasource/transform.py index 0622d139b..eeea62711 100644 --- a/vectordatasource/transform.py +++ b/vectordatasource/transform.py @@ -5760,7 +5760,7 @@ def _do_not_backfill(tags): return None -def _sort_network_us(network, ref): +def _sort_network_us(network, ref, colour, symbol): if network is None: network_code = 9999 elif network == 'US:I': @@ -5789,7 +5789,7 @@ def _sort_network_us(network, ref): } -def _sort_network_au(network, ref): +def _sort_network_au(network, ref, colour, symbol): if network is None or \ not network.startswith('AU:'): network_code = 9999 @@ -5801,7 +5801,7 @@ def _sort_network_au(network, ref): return network_code * 10000 + min(ref, 9999) -def _sort_network_br(network, ref): +def _sort_network_br(network, ref, colour, symbol): if network is None: network_code = 9999 elif network == 'BR:Trans-Amazonian': @@ -5814,7 +5814,7 @@ def _sort_network_br(network, ref): return network_code * 10000 + min(ref, 9999) -def _sort_network_ca(network, ref): +def _sort_network_ca(network, ref, colour, symbol): if network is None: network_code = 9999 elif network == 'CA:transcanada': @@ -5829,7 +5829,7 @@ def _sort_network_ca(network, ref): return network_code * 10000 + min(ref, 9999) -def _sort_network_ch(network, ref): +def _sort_network_ch(network, ref, colour, symbol): if network is None: network_code = 9999 elif network == 'CH:national': @@ -5846,7 +5846,7 @@ def _sort_network_ch(network, ref): return network_code * 10000 + min(ref, 9999) -def _sort_network_cn(network, ref): +def _sort_network_cn(network, ref, colour, symbol): if network is None: network_code = 9999 elif network == 'CN:expressway': @@ -5865,7 +5865,7 @@ def _sort_network_cn(network, ref): return network_code * 10000 + min(ref, 9999) -def _sort_network_es(network, ref): +def _sort_network_es(network, ref, colour, symbol): if network is None: network_code = 9999 elif network == 'ES:A-road': @@ -5888,7 +5888,7 @@ def _sort_network_es(network, ref): return network_code * 10000 + min(ref, 9999) -def _sort_network_fr(network, ref): +def _sort_network_fr(network, ref, colour, symbol): if network is None: network_code = 9999 elif network == 'FR:A-road': @@ -5909,7 +5909,7 @@ def _sort_network_fr(network, ref): return network_code * 10000 + min(ref, 9999) -def _sort_network_de(network, ref): +def _sort_network_de(network, ref, colour, symbol): if network is None: network_code = 9999 elif network == 'DE:BAB': @@ -5934,7 +5934,7 @@ def _sort_network_de(network, ref): return network_code * 10000 + min(ref, 9999) -def _sort_network_ga(network, ref): +def _sort_network_ga(network, ref, colour, symbol): if network is None: network_code = 9999 elif network == 'GA:national': @@ -5949,7 +5949,7 @@ def _sort_network_ga(network, ref): return network_code * 10000 + min(ref, 9999) -def _sort_network_gr(network, ref): +def _sort_network_gr(network, ref, colour, symbol): if network is None: network_code = 9999 elif network == 'GR:motorway': @@ -5966,7 +5966,7 @@ def _sort_network_gr(network, ref): return network_code * 10000 + min(ref, 9999) -def _sort_network_in(network, ref): +def _sort_network_in(network, ref, colour, symbol): if network is None: network_code = 9999 elif network == 'IN:NH': @@ -5983,7 +5983,7 @@ def _sort_network_in(network, ref): return network_code * 10000 + min(ref, 9999) -def _sort_network_ir(network, ref): +def _sort_network_ir(network, ref, colour, symbol): if network is None: network_code = 9999 elif network == 'AsianHighway': @@ -5996,7 +5996,7 @@ def _sort_network_ir(network, ref): return network_code * 10000 + min(ref, 9999) -def _sort_network_kz(network, ref): +def _sort_network_kz(network, ref, colour, symbol): if network is None: network_code = 9999 elif network == 'KZ:national': @@ -6015,7 +6015,7 @@ def _sort_network_kz(network, ref): return network_code * 10000 + min(ref, 9999) -def _sort_network_la(network, ref): +def _sort_network_la(network, ref, colour, symbol): if network is None: network_code = 9999 elif network == 'LA:national': @@ -6030,7 +6030,7 @@ def _sort_network_la(network, ref): return network_code * 10000 + min(ref, 9999) -def _sort_network_mx(network, ref): +def _sort_network_mx(network, ref, colour, symbol): if network is None: network_code = 9999 elif network == 'MX:MEX': @@ -6043,7 +6043,7 @@ def _sort_network_mx(network, ref): return network_code * 10000 + min(ref, 9999) -def _sort_network_my(network, ref): +def _sort_network_my(network, ref, colour, symbol): if network is None: network_code = 9999 elif network == 'MY:federal': @@ -6060,7 +6060,7 @@ def _sort_network_my(network, ref): return network_code * 10000 + min(ref, 9999) -def _sort_network_no(network, ref): +def _sort_network_no(network, ref, colour, symbol): if network is None: network_code = 9999 elif network == 'NO:oslo:ring': @@ -6079,7 +6079,7 @@ def _sort_network_no(network, ref): return network_code * 10000 + min(ref, 9999) -def _sort_network_gb(network, ref): +def _sort_network_gb(network, ref, colour, symbol): if network is None: network_code = 9999 elif network == 'GB:M-road': @@ -6100,7 +6100,7 @@ def _sort_network_gb(network, ref): return network_code * 10000 + min(ref, 9999) -def _sort_network_pl(network, ref): +def _sort_network_pl(network, ref, colour, symbol): if network is None: network_code = 9999 elif network == 'PL:motorway': @@ -6119,7 +6119,7 @@ def _sort_network_pl(network, ref): return network_code * 10000 + min(ref, 9999) -def _sort_network_pt(network, ref): +def _sort_network_pt(network, ref, colour, symbol): if network is None: network_code = 9999 elif network == 'PT:motorway': @@ -6148,7 +6148,7 @@ def _sort_network_pt(network, ref): return network_code * 10000 + min(ref, 9999) -def _sort_network_ro(network, ref): +def _sort_network_ro(network, ref, colour, symbol): if network is None: network_code = 9999 elif network == 'RO:motorway': @@ -6169,7 +6169,7 @@ def _sort_network_ro(network, ref): return network_code * 10000 + min(ref, 9999) -def _sort_network_ru(network, ref): +def _sort_network_ru(network, ref, colour, symbol): ref = _make_unicode_or_none(ref) if network is None: @@ -6200,7 +6200,7 @@ def _sort_network_ru(network, ref): return network_code * 10000 + min(ref, 9999) -def _sort_network_tr(network, ref): +def _sort_network_tr(network, ref, colour, symbol): ref = _make_unicode_or_none(ref) if network is None: @@ -6233,7 +6233,7 @@ def _sort_network_tr(network, ref): return network_code * 10000 + min(ref, 9999) -def _sort_network_ua(network, ref): +def _sort_network_ua(network, ref, colour, symbol): ref = _make_unicode_or_none(ref) if network is None: @@ -6259,7 +6259,7 @@ def _sort_network_ua(network, ref): return network_code * 10000 + min(ref, 9999) -def _sort_network_vn(network, ref): +def _sort_network_vn(network, ref, colour, symbol): if network is None: network_code = 9999 elif network == 'VN:expressway': @@ -6283,7 +6283,7 @@ def _sort_network_vn(network, ref): return network_code * 10000 + min(ref, 9999) -def _sort_network_za(network, ref): +def _sort_network_za(network, ref, colour, symbol): if network is None: network_code = 9999 elif network == 'ZA:national': @@ -7649,6 +7649,9 @@ def merge_networks_from_tags(shape, props, fid, zoom): network = props.get('network') ref = props.get('ref') + colour = props.get('colour') + symbol = props.get('symbol') + mz_networks = props.get('mz_networks', []) country_code = props.get('country_code') @@ -7658,8 +7661,10 @@ def merge_networks_from_tags(shape, props, fid, zoom): # * if they begin with two letters and a dash, then make the letters upper # case and replace the dash with a colon. # * expand ;-delimited lists in refs - for i in xrange(0, len(mz_networks), 3): - t, n, r = mz_networks[i:i+3] + for i in xrange(0, len(mz_networks), 5): + #print("props: {}".format(props)) + #print("len: {} {}".format(len(mz_networks), mz_networks)) + t, n, r, c, s = mz_networks[i:i+5] if t == 'road' and n is not None: n = _fixup_network_country_code(n) mz_networks[i+1] = n @@ -7667,7 +7672,7 @@ def merge_networks_from_tags(shape, props, fid, zoom): refs = r.split(';') mz_networks[i+2] = refs.pop() for new_ref in refs: - mz_networks.extend((t, n, new_ref)) + mz_networks.extend((t, n, new_ref, c, s)) # for road networks, if there's no explicit network, but the country code # and ref are both available, then try to use them to back-fill the @@ -7683,8 +7688,8 @@ def merge_networks_from_tags(shape, props, fid, zoom): # then use the network from the relation instead. if network is None: solo_networks_from_relations = [] - for i in xrange(0, len(mz_networks), 3): - t, n, r = mz_networks[i:i+3] + for i in xrange(0, len(mz_networks), 5): + t, n, r, c, s = mz_networks[i:i+5] if t == 'road' and n and (r is None or r == ref): solo_networks_from_relations.append((n, i)) @@ -7697,7 +7702,7 @@ def merge_networks_from_tags(shape, props, fid, zoom): # add network back into properties in case we need to pass it # to the backfill. props['network'] = network - del mz_networks[i:i+3] + del mz_networks[i:i+5] if logic and logic.backfill: networks_and_refs = logic.backfill(props) or [] @@ -7724,8 +7729,8 @@ def merge_networks_from_tags(shape, props, fid, zoom): # an entry in mz_networks with the same ref! if ref: found = False - for i in xrange(0, len(mz_networks), 3): - t, _, r = mz_networks[i:i+3] + for i in xrange(0, len(mz_networks), 5): + t, _, r, _, _ = mz_networks[i:i+5] if t == 'road' and r == ref: found = True break @@ -7744,7 +7749,7 @@ def merge_networks_from_tags(shape, props, fid, zoom): if network and ref: props.pop('network', None) props.pop('ref') - mz_networks.extend([_guess_type_from_network(network), network, ref]) + mz_networks.extend([_guess_type_from_network(network), network, ref, colour, symbol]) if mz_networks: props['mz_networks'] = mz_networks @@ -7757,7 +7762,7 @@ def merge_networks_from_tags(shape, props, fid, zoom): _ANY_NUMBER = re.compile('[^0-9]*([0-9]+)') -def _default_sort_network(network, ref): +def _default_sort_network(network, ref, colour, symbol): """ Returns an integer representing the numeric importance of the network, where lower numbers are more important. @@ -7824,15 +7829,15 @@ def _generic_network_importance(network, ref, codes): return code * 10000 + min(ref, 9999) -def _walking_network_importance(network, ref): +def _walking_network_importance(network, ref, colour, symbol): return _generic_network_importance(network, ref, _WALKING_NETWORK_CODES) -def _bicycle_network_importance(network, ref): +def _bicycle_network_importance(network, ref, colour, symbol): return _generic_network_importance(network, ref, _BICYCLE_NETWORK_CODES) -def _bus_network_importance(network, ref): +def _bus_network_importance(network, ref, colour, symbol): return _generic_network_importance(network, ref, {}) @@ -7964,14 +7969,17 @@ def extract_network_information(shape, properties, fid, zoom): itr = iter(mz_networks) groups = defaultdict(list) - for (type, network, ref) in zip(itr, itr, itr): + for (type, network, ref, colour, symbol) in zip(itr, itr, itr, itr, itr): n = _NETWORKS.get(type) if n: - groups[n].append([network, ref]) + groups[n].append([network, ref, colour, symbol]) for network, vals in groups.items(): + #print("network prefix: {}".format(network.prefix)) all_networks = 'all_' + network.prefix + 'networks' all_shield_texts = 'all_' + network.prefix + 'shield_texts' + all_network_colours = 'all_' + network.prefix + 'network_colours' + all_network_symbols = 'all_' + network.prefix + 'network_symbols' shield_text_fn = network.shield_text_fn if network is _ROAD_NETWORK and country_logic and \ @@ -7980,7 +7988,9 @@ def extract_network_information(shape, properties, fid, zoom): shield_texts = list() network_names = list() - for network_name, ref in vals: + network_colours = list() + network_symbols = list() + for network_name, ref, colour, symbol in vals: network_names.append(network_name) ref = _make_unicode_or_none(ref) @@ -7994,9 +8004,13 @@ def extract_network_information(shape, properties, fid, zoom): ref = ref.encode('utf-8') shield_texts.append(ref) + network_colours.append(colour) + network_symbols.append(symbol) properties[all_networks] = network_names properties[all_shield_texts] = shield_texts + properties[all_network_colours] = network_colours + properties[all_network_symbols] = network_symbols return (shape, properties, fid) @@ -8009,16 +8023,20 @@ def _choose_most_important_network(properties, prefix, importance_fn): all_networks = 'all_' + prefix + 'networks' all_shield_texts = 'all_' + prefix + 'shield_texts' + all_network_colours = 'all_' + prefix + 'network_colours' + all_network_symbols = 'all_' + prefix + 'network_symbols' networks = properties.pop(all_networks, None) shield_texts = properties.pop(all_shield_texts, None) + colours = properties.pop(all_network_colours, None) + symbols = properties.pop(all_network_symbols, None) country_code = properties.get('country_code') - if networks and shield_texts: + if networks and shield_texts and colours and symbols: def network_key(t): return importance_fn(*t) - tuples = sorted(set(zip(networks, shield_texts)), key=network_key) + tuples = sorted(set(zip(networks, shield_texts, colours, symbols)), key=network_key) # i think most route designers would try pretty hard to make sure that # a segment of road isn't on two routes of different networks but with @@ -8028,27 +8046,50 @@ def network_key(t): # with the same ref (and network != none). seen_ref = set() new_tuples = [] - for network, ref in tuples: + for network, ref, colour, symbol in tuples: if network: if ref: seen_ref.add(ref) - new_tuples.append((network, ref)) + new_tuples.append((network, ref, colour, symbol)) elif ref is not None and ref not in seen_ref: # network is None, fall back to the country code - new_tuples.append((country_code, ref)) + new_tuples.append((country_code, ref, colour, symbol)) tuples = new_tuples if tuples: # expose first network as network/shield_text - network, ref = tuples[0] + network, ref, colour, symbol = tuples[0] properties[prefix + 'network'] = network properties[prefix + 'shield_text'] = ref + properties[prefix + 'network_colour'] = colour + properties[prefix + 'network_symbol'] = symbol # replace properties with sorted versions of themselves properties[all_networks] = [n[0] for n in tuples] properties[all_shield_texts] = [n[1] for n in tuples] + properties[all_network_colours] = [n[2] for n in tuples] + properties[all_network_symbols] = [n[3] for n in tuples] + + properties[all_networks + '_str'] = '' + properties[all_shield_texts + '_str'] = '' + properties[all_network_colours + '_str'] = '' + properties[all_network_symbols + '_str'] = '' + + if properties[all_network_colours] is not None: + for x in properties[all_network_colours]: + if x is not None: + properties[all_network_colours + '_str'] += ("," if properties[all_network_colours + '_str'] != '' else '') + x + else: + properties[all_network_colours + '_str'] += ("," if properties[all_network_colours + '_str'] != '' else '') + + if properties[all_network_symbols] is not None: + for x in properties[all_network_symbols]: + if x is not None: + properties[all_network_symbols + '_str'] += ("," if properties[all_network_symbols + '_str'] != '' else '') + x + else: + properties[all_network_symbols + '_str'] += ("," if properties[all_network_symbols + '_str'] != '' else '') return properties @@ -8324,10 +8365,10 @@ def _fixup_country_specific_networks(shape, props, fid, zoom): # mz_networks is a list of repeated [type, network, ref, ...], it isn't # nested! itr = iter(mz_networks) - for (type, network, ref) in zip(itr, itr, itr): + for (type, network, ref, color, symbol) in zip(itr, itr, itr, itr, itr): if type == 'road': network, ref = logic.fix(network, ref) - new_networks.extend([type, network, ref]) + new_networks.extend([type, network, ref, color, symbol]) props['mz_networks'] = new_networks diff --git a/yaml/roads.yaml b/yaml/roads.yaml index 2096a7ef2..7c2388001 100644 --- a/yaml/roads.yaml +++ b/yaml/roads.yaml @@ -177,31 +177,31 @@ global: - when: sov_a3: CAN level: ['Federal', 'Interstate', 'State'] - then: ['road', 'CA:??:primary', { col: name }] + then: ['road', 'CA:??:primary', { col: name }, { col: colour }, { col: symbol }] - when: sov_a3: 'MEX' level: 'Interstate' - then: ['road', 'MX', { col: name }] + then: ['road', 'MX', { col: name }, { col: colour }, { col: symbol }] - when: sov_a3: 'MEX' level: 'Federal' - then: ['road', 'MX:MX', { col: name }] + then: ['road', 'MX:MX', { col: name }, { col: colour }, { col: symbol }] - when: sov_a3: 'USA' level: 'Interstate' - then: ['road', 'US:I', { col: name }] + then: ['road', 'US:I', { col: name }, { col: colour }, { col: symbol }] - when: sov_a3: 'USA' level: 'Federal' - then: ['road', 'US:US', { col: name }] + then: ['road', 'US:US', { col: name }, { col: colour }, { col: symbol }] - when: continent: 'Oceania' level: 'Federal' - then: ['road', 'NZ:SH', { col: label}] + then: ['road', 'NZ:SH', { col: label}, { col: colour }, { col: symbol }] - when: continent: ['Europe', 'Asia'] level: 'E' - then: ['road', 'e-road', { col: name }] + then: ['road', 'e-road', { col: name }, { col: colour }, { col: symbol }] columns: [ sov_a3, continent, label, level ] # tolls toll: From 41ce83fe6878bd73dd590b4f273b2ade5ef97fcd Mon Sep 17 00:00:00 2001 From: Tomas Vajda Date: Wed, 29 Jun 2022 18:11:06 +0200 Subject: [PATCH 2/3] Change to using osmc:symbol for waymarked hiking routes --- data/functions.sql | 5 +- requirements.txt | 12 +-- vectordatasource/transform.py | 152 +++++++++++++++------------------- yaml/roads.yaml | 14 ++-- 4 files changed, 81 insertions(+), 102 deletions(-) diff --git a/data/functions.sql b/data/functions.sql index 5da08a996..4953e82b6 100644 --- a/data/functions.sql +++ b/data/functions.sql @@ -127,7 +127,7 @@ FROM ( unnest(tags) AS unnested FROM ( SELECT - mz_modify_network(hstore(tags))->ARRAY['route','network','ref','colour','symbol'] AS tags + mz_modify_network(hstore(tags))->ARRAY['route','network','ref','osmc:symbol'] AS tags FROM planet_osm_rels WHERE @@ -136,8 +136,7 @@ FROM ( hstore(tags) ? 'route' AND (hstore(tags) ? 'network' OR hstore(tags) ? 'ref') AND - hstore(tags) ? 'colour' AND - hstore(tags) ? 'symbol' + hstore(tags) ? 'osmc:symbol' ) inner1 ) inner2; $$ LANGUAGE sql STABLE; diff --git a/requirements.txt b/requirements.txt index 3f2b96816..bad4044a9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,8 +5,9 @@ boto==2.49.0 edtf==2.6.0 future==0.16.0 gunicorn==19.9.0 +hanzidentifier==1.0.2 hiredis==0.2.0 -lxml==4.1.1 +lxml==4.6.2 mapbox-vector-tile==1.2.0 ModestMaps==1.4.7 protobuf==3.4.0 @@ -15,16 +16,17 @@ pyclipper==1.0.6 pycountry==17.9.23 python-dateutil==2.6.1 PyYAML==4.2b4 +git+https://github.com/tilezen/raw_tiles@master#egg=raw_tiles redis==2.10.6 +setuptools<=44.1.1 ## Last version to support py2 Shapely==1.6.2.post1 simplejson==3.12.0 six==1.11.0 StreetNames==0.1.5 +git+https://github.com/tilezen/tilequeue@v2.4.1-final#egg=tilequeue +git+https://github.com/tilezen/tileserver@master#egg=tileserver tqdm==4.31.1 urllib3==1.25.11 webcolors<=1.11 ## Last version to support py2 -Werkzeug==0.12.2 +Werkzeug<=0.16.1 wsgiref==0.1.2 -git+https://github.com/tilezen/tilequeue@v2.4.1-final#egg=tilequeue -git+https://github.com/tilezen/tileserver@master#egg=tileserver -git+https://github.com/tilezen/raw_tiles@master#egg=raw_tiles diff --git a/vectordatasource/transform.py b/vectordatasource/transform.py index eeea62711..70ba96319 100644 --- a/vectordatasource/transform.py +++ b/vectordatasource/transform.py @@ -5760,7 +5760,7 @@ def _do_not_backfill(tags): return None -def _sort_network_us(network, ref, colour, symbol): +def _sort_network_us(network, ref, osmc_symbol): if network is None: network_code = 9999 elif network == 'US:I': @@ -5789,7 +5789,7 @@ def _sort_network_us(network, ref, colour, symbol): } -def _sort_network_au(network, ref, colour, symbol): +def _sort_network_au(network, ref, osmc_symbol): if network is None or \ not network.startswith('AU:'): network_code = 9999 @@ -5801,7 +5801,7 @@ def _sort_network_au(network, ref, colour, symbol): return network_code * 10000 + min(ref, 9999) -def _sort_network_br(network, ref, colour, symbol): +def _sort_network_br(network, ref, osmc_symbol): if network is None: network_code = 9999 elif network == 'BR:Trans-Amazonian': @@ -5814,7 +5814,7 @@ def _sort_network_br(network, ref, colour, symbol): return network_code * 10000 + min(ref, 9999) -def _sort_network_ca(network, ref, colour, symbol): +def _sort_network_ca(network, ref, osmc_symbol): if network is None: network_code = 9999 elif network == 'CA:transcanada': @@ -5829,7 +5829,7 @@ def _sort_network_ca(network, ref, colour, symbol): return network_code * 10000 + min(ref, 9999) -def _sort_network_ch(network, ref, colour, symbol): +def _sort_network_ch(network, ref, osmc_symbol): if network is None: network_code = 9999 elif network == 'CH:national': @@ -5846,7 +5846,7 @@ def _sort_network_ch(network, ref, colour, symbol): return network_code * 10000 + min(ref, 9999) -def _sort_network_cn(network, ref, colour, symbol): +def _sort_network_cn(network, ref, osmc_symbol): if network is None: network_code = 9999 elif network == 'CN:expressway': @@ -5865,7 +5865,7 @@ def _sort_network_cn(network, ref, colour, symbol): return network_code * 10000 + min(ref, 9999) -def _sort_network_es(network, ref, colour, symbol): +def _sort_network_es(network, ref, osmc_symbol): if network is None: network_code = 9999 elif network == 'ES:A-road': @@ -5888,7 +5888,7 @@ def _sort_network_es(network, ref, colour, symbol): return network_code * 10000 + min(ref, 9999) -def _sort_network_fr(network, ref, colour, symbol): +def _sort_network_fr(network, ref, osmc_symbol): if network is None: network_code = 9999 elif network == 'FR:A-road': @@ -5909,7 +5909,7 @@ def _sort_network_fr(network, ref, colour, symbol): return network_code * 10000 + min(ref, 9999) -def _sort_network_de(network, ref, colour, symbol): +def _sort_network_de(network, ref, osmc_symbol): if network is None: network_code = 9999 elif network == 'DE:BAB': @@ -5934,7 +5934,7 @@ def _sort_network_de(network, ref, colour, symbol): return network_code * 10000 + min(ref, 9999) -def _sort_network_ga(network, ref, colour, symbol): +def _sort_network_ga(network, ref, osmc_symbol): if network is None: network_code = 9999 elif network == 'GA:national': @@ -5949,7 +5949,7 @@ def _sort_network_ga(network, ref, colour, symbol): return network_code * 10000 + min(ref, 9999) -def _sort_network_gr(network, ref, colour, symbol): +def _sort_network_gr(network, ref, osmc_symbol): if network is None: network_code = 9999 elif network == 'GR:motorway': @@ -5966,7 +5966,7 @@ def _sort_network_gr(network, ref, colour, symbol): return network_code * 10000 + min(ref, 9999) -def _sort_network_in(network, ref, colour, symbol): +def _sort_network_in(network, ref, osmc_symbol): if network is None: network_code = 9999 elif network == 'IN:NH': @@ -5983,7 +5983,7 @@ def _sort_network_in(network, ref, colour, symbol): return network_code * 10000 + min(ref, 9999) -def _sort_network_ir(network, ref, colour, symbol): +def _sort_network_ir(network, ref, osmc_symbol): if network is None: network_code = 9999 elif network == 'AsianHighway': @@ -5996,7 +5996,7 @@ def _sort_network_ir(network, ref, colour, symbol): return network_code * 10000 + min(ref, 9999) -def _sort_network_kz(network, ref, colour, symbol): +def _sort_network_kz(network, ref, osmc_symbol): if network is None: network_code = 9999 elif network == 'KZ:national': @@ -6015,7 +6015,7 @@ def _sort_network_kz(network, ref, colour, symbol): return network_code * 10000 + min(ref, 9999) -def _sort_network_la(network, ref, colour, symbol): +def _sort_network_la(network, ref, osmc_symbol): if network is None: network_code = 9999 elif network == 'LA:national': @@ -6030,7 +6030,7 @@ def _sort_network_la(network, ref, colour, symbol): return network_code * 10000 + min(ref, 9999) -def _sort_network_mx(network, ref, colour, symbol): +def _sort_network_mx(network, ref, osmc_symbol): if network is None: network_code = 9999 elif network == 'MX:MEX': @@ -6043,7 +6043,7 @@ def _sort_network_mx(network, ref, colour, symbol): return network_code * 10000 + min(ref, 9999) -def _sort_network_my(network, ref, colour, symbol): +def _sort_network_my(network, ref, osmc_symbol): if network is None: network_code = 9999 elif network == 'MY:federal': @@ -6060,7 +6060,7 @@ def _sort_network_my(network, ref, colour, symbol): return network_code * 10000 + min(ref, 9999) -def _sort_network_no(network, ref, colour, symbol): +def _sort_network_no(network, ref, osmc_symbol): if network is None: network_code = 9999 elif network == 'NO:oslo:ring': @@ -6079,7 +6079,7 @@ def _sort_network_no(network, ref, colour, symbol): return network_code * 10000 + min(ref, 9999) -def _sort_network_gb(network, ref, colour, symbol): +def _sort_network_gb(network, ref, osmc_symbol): if network is None: network_code = 9999 elif network == 'GB:M-road': @@ -6100,7 +6100,7 @@ def _sort_network_gb(network, ref, colour, symbol): return network_code * 10000 + min(ref, 9999) -def _sort_network_pl(network, ref, colour, symbol): +def _sort_network_pl(network, ref, osmc_symbol): if network is None: network_code = 9999 elif network == 'PL:motorway': @@ -6119,7 +6119,7 @@ def _sort_network_pl(network, ref, colour, symbol): return network_code * 10000 + min(ref, 9999) -def _sort_network_pt(network, ref, colour, symbol): +def _sort_network_pt(network, ref, osmc_symbol): if network is None: network_code = 9999 elif network == 'PT:motorway': @@ -6148,7 +6148,7 @@ def _sort_network_pt(network, ref, colour, symbol): return network_code * 10000 + min(ref, 9999) -def _sort_network_ro(network, ref, colour, symbol): +def _sort_network_ro(network, ref, osmc_symbol): if network is None: network_code = 9999 elif network == 'RO:motorway': @@ -6169,7 +6169,7 @@ def _sort_network_ro(network, ref, colour, symbol): return network_code * 10000 + min(ref, 9999) -def _sort_network_ru(network, ref, colour, symbol): +def _sort_network_ru(network, ref, osmc_symbol): ref = _make_unicode_or_none(ref) if network is None: @@ -6200,7 +6200,7 @@ def _sort_network_ru(network, ref, colour, symbol): return network_code * 10000 + min(ref, 9999) -def _sort_network_tr(network, ref, colour, symbol): +def _sort_network_tr(network, ref, osmc_symbol): ref = _make_unicode_or_none(ref) if network is None: @@ -6233,7 +6233,7 @@ def _sort_network_tr(network, ref, colour, symbol): return network_code * 10000 + min(ref, 9999) -def _sort_network_ua(network, ref, colour, symbol): +def _sort_network_ua(network, ref, osmc_symbol): ref = _make_unicode_or_none(ref) if network is None: @@ -6259,7 +6259,7 @@ def _sort_network_ua(network, ref, colour, symbol): return network_code * 10000 + min(ref, 9999) -def _sort_network_vn(network, ref, colour, symbol): +def _sort_network_vn(network, ref, osmc_symbol): if network is None: network_code = 9999 elif network == 'VN:expressway': @@ -6283,7 +6283,7 @@ def _sort_network_vn(network, ref, colour, symbol): return network_code * 10000 + min(ref, 9999) -def _sort_network_za(network, ref, colour, symbol): +def _sort_network_za(network, ref, osmc_symbol): if network is None: network_code = 9999 elif network == 'ZA:national': @@ -7649,8 +7649,7 @@ def merge_networks_from_tags(shape, props, fid, zoom): network = props.get('network') ref = props.get('ref') - colour = props.get('colour') - symbol = props.get('symbol') + osmc_symbol = props.get('osmc:symbol') mz_networks = props.get('mz_networks', []) country_code = props.get('country_code') @@ -7661,10 +7660,8 @@ def merge_networks_from_tags(shape, props, fid, zoom): # * if they begin with two letters and a dash, then make the letters upper # case and replace the dash with a colon. # * expand ;-delimited lists in refs - for i in xrange(0, len(mz_networks), 5): - #print("props: {}".format(props)) - #print("len: {} {}".format(len(mz_networks), mz_networks)) - t, n, r, c, s = mz_networks[i:i+5] + for i in xrange(0, len(mz_networks), 4): + t, n, r, o = mz_networks[i:i+4] if t == 'road' and n is not None: n = _fixup_network_country_code(n) mz_networks[i+1] = n @@ -7672,7 +7669,7 @@ def merge_networks_from_tags(shape, props, fid, zoom): refs = r.split(';') mz_networks[i+2] = refs.pop() for new_ref in refs: - mz_networks.extend((t, n, new_ref, c, s)) + mz_networks.extend((t, n, new_ref, o)) # for road networks, if there's no explicit network, but the country code # and ref are both available, then try to use them to back-fill the @@ -7688,8 +7685,8 @@ def merge_networks_from_tags(shape, props, fid, zoom): # then use the network from the relation instead. if network is None: solo_networks_from_relations = [] - for i in xrange(0, len(mz_networks), 5): - t, n, r, c, s = mz_networks[i:i+5] + for i in xrange(0, len(mz_networks), 4): + t, n, r, o = mz_networks[i:i+4] if t == 'road' and n and (r is None or r == ref): solo_networks_from_relations.append((n, i)) @@ -7702,7 +7699,7 @@ def merge_networks_from_tags(shape, props, fid, zoom): # add network back into properties in case we need to pass it # to the backfill. props['network'] = network - del mz_networks[i:i+5] + del mz_networks[i:i+4] if logic and logic.backfill: networks_and_refs = logic.backfill(props) or [] @@ -7729,8 +7726,8 @@ def merge_networks_from_tags(shape, props, fid, zoom): # an entry in mz_networks with the same ref! if ref: found = False - for i in xrange(0, len(mz_networks), 5): - t, _, r, _, _ = mz_networks[i:i+5] + for i in xrange(0, len(mz_networks), 4): + t, _, r, _ = mz_networks[i:i+4] if t == 'road' and r == ref: found = True break @@ -7749,7 +7746,7 @@ def merge_networks_from_tags(shape, props, fid, zoom): if network and ref: props.pop('network', None) props.pop('ref') - mz_networks.extend([_guess_type_from_network(network), network, ref, colour, symbol]) + mz_networks.extend([_guess_type_from_network(network), network, ref, osmc_symbol]) if mz_networks: props['mz_networks'] = mz_networks @@ -7762,7 +7759,7 @@ def merge_networks_from_tags(shape, props, fid, zoom): _ANY_NUMBER = re.compile('[^0-9]*([0-9]+)') -def _default_sort_network(network, ref, colour, symbol): +def _default_sort_network(network, ref, osmc_symbol): """ Returns an integer representing the numeric importance of the network, where lower numbers are more important. @@ -7829,15 +7826,15 @@ def _generic_network_importance(network, ref, codes): return code * 10000 + min(ref, 9999) -def _walking_network_importance(network, ref, colour, symbol): +def _walking_network_importance(network, ref, osmc_symbol): return _generic_network_importance(network, ref, _WALKING_NETWORK_CODES) -def _bicycle_network_importance(network, ref, colour, symbol): +def _bicycle_network_importance(network, ref, osmc_symbol): return _generic_network_importance(network, ref, _BICYCLE_NETWORK_CODES) -def _bus_network_importance(network, ref, colour, symbol): +def _bus_network_importance(network, ref, osmc_symbol): return _generic_network_importance(network, ref, {}) @@ -7969,17 +7966,15 @@ def extract_network_information(shape, properties, fid, zoom): itr = iter(mz_networks) groups = defaultdict(list) - for (type, network, ref, colour, symbol) in zip(itr, itr, itr, itr, itr): + for (type, network, ref, osmc_symbol) in zip(itr, itr, itr, itr): n = _NETWORKS.get(type) if n: - groups[n].append([network, ref, colour, symbol]) + groups[n].append([network, ref, osmc_symbol]) for network, vals in groups.items(): - #print("network prefix: {}".format(network.prefix)) all_networks = 'all_' + network.prefix + 'networks' all_shield_texts = 'all_' + network.prefix + 'shield_texts' - all_network_colours = 'all_' + network.prefix + 'network_colours' - all_network_symbols = 'all_' + network.prefix + 'network_symbols' + all_osmc_symbols = 'all_' + network.prefix + 'osmc_symbols' shield_text_fn = network.shield_text_fn if network is _ROAD_NETWORK and country_logic and \ @@ -7988,9 +7983,8 @@ def extract_network_information(shape, properties, fid, zoom): shield_texts = list() network_names = list() - network_colours = list() - network_symbols = list() - for network_name, ref, colour, symbol in vals: + osmc_symbols = list() + for network_name, ref, osmc_symbol in vals: network_names.append(network_name) ref = _make_unicode_or_none(ref) @@ -8004,13 +7998,11 @@ def extract_network_information(shape, properties, fid, zoom): ref = ref.encode('utf-8') shield_texts.append(ref) - network_colours.append(colour) - network_symbols.append(symbol) + osmc_symbols.append(osmc_symbol) properties[all_networks] = network_names properties[all_shield_texts] = shield_texts - properties[all_network_colours] = network_colours - properties[all_network_symbols] = network_symbols + properties[all_osmc_symbols] = osmc_symbols return (shape, properties, fid) @@ -8023,20 +8015,18 @@ def _choose_most_important_network(properties, prefix, importance_fn): all_networks = 'all_' + prefix + 'networks' all_shield_texts = 'all_' + prefix + 'shield_texts' - all_network_colours = 'all_' + prefix + 'network_colours' - all_network_symbols = 'all_' + prefix + 'network_symbols' + all_osmc_symbols = 'all_' + prefix + 'osmc_symbols' networks = properties.pop(all_networks, None) shield_texts = properties.pop(all_shield_texts, None) - colours = properties.pop(all_network_colours, None) - symbols = properties.pop(all_network_symbols, None) + osmc_symbols = properties.pop(all_osmc_symbols, None) country_code = properties.get('country_code') - if networks and shield_texts and colours and symbols: + if networks and shield_texts and osmc_symbols: def network_key(t): return importance_fn(*t) - tuples = sorted(set(zip(networks, shield_texts, colours, symbols)), key=network_key) + tuples = sorted(set(zip(networks, shield_texts, osmc_symbols)), key=network_key) # i think most route designers would try pretty hard to make sure that # a segment of road isn't on two routes of different networks but with @@ -8046,50 +8036,38 @@ def network_key(t): # with the same ref (and network != none). seen_ref = set() new_tuples = [] - for network, ref, colour, symbol in tuples: + for network, ref, osmc_symbol in tuples: if network: if ref: seen_ref.add(ref) - new_tuples.append((network, ref, colour, symbol)) + new_tuples.append((network, ref, osmc_symbol)) elif ref is not None and ref not in seen_ref: # network is None, fall back to the country code - new_tuples.append((country_code, ref, colour, symbol)) + new_tuples.append((country_code, ref, osmc_symbol)) tuples = new_tuples if tuples: # expose first network as network/shield_text - network, ref, colour, symbol = tuples[0] + network, ref, osmc_symbol = tuples[0] properties[prefix + 'network'] = network properties[prefix + 'shield_text'] = ref - properties[prefix + 'network_colour'] = colour - properties[prefix + 'network_symbol'] = symbol + properties[prefix + 'osmc_symbol'] = osmc_symbol # replace properties with sorted versions of themselves properties[all_networks] = [n[0] for n in tuples] properties[all_shield_texts] = [n[1] for n in tuples] - properties[all_network_colours] = [n[2] for n in tuples] - properties[all_network_symbols] = [n[3] for n in tuples] + properties[all_osmc_symbols] = [n[2] for n in tuples] - properties[all_networks + '_str'] = '' - properties[all_shield_texts + '_str'] = '' - properties[all_network_colours + '_str'] = '' - properties[all_network_symbols + '_str'] = '' + properties[all_osmc_symbols + '_str'] = '' - if properties[all_network_colours] is not None: - for x in properties[all_network_colours]: + if properties[all_osmc_symbols] is not None: + for x in properties[all_osmc_symbols]: if x is not None: - properties[all_network_colours + '_str'] += ("," if properties[all_network_colours + '_str'] != '' else '') + x + properties[all_osmc_symbols + '_str'] += ("," if properties[all_osmc_symbols + '_str'] != '' else '') + x else: - properties[all_network_colours + '_str'] += ("," if properties[all_network_colours + '_str'] != '' else '') - - if properties[all_network_symbols] is not None: - for x in properties[all_network_symbols]: - if x is not None: - properties[all_network_symbols + '_str'] += ("," if properties[all_network_symbols + '_str'] != '' else '') + x - else: - properties[all_network_symbols + '_str'] += ("," if properties[all_network_symbols + '_str'] != '' else '') + properties[all_osmc_symbols + '_str'] += ("," if properties[all_osmc_symbols + '_str'] != '' else '') return properties @@ -8365,10 +8343,10 @@ def _fixup_country_specific_networks(shape, props, fid, zoom): # mz_networks is a list of repeated [type, network, ref, ...], it isn't # nested! itr = iter(mz_networks) - for (type, network, ref, color, symbol) in zip(itr, itr, itr, itr, itr): + for (type, network, ref, osmc_symbol) in zip(itr, itr, itr, itr): if type == 'road': network, ref = logic.fix(network, ref) - new_networks.extend([type, network, ref, color, symbol]) + new_networks.extend([type, network, ref, osmc_symbol]) props['mz_networks'] = new_networks diff --git a/yaml/roads.yaml b/yaml/roads.yaml index 7c2388001..1701960b2 100644 --- a/yaml/roads.yaml +++ b/yaml/roads.yaml @@ -177,31 +177,31 @@ global: - when: sov_a3: CAN level: ['Federal', 'Interstate', 'State'] - then: ['road', 'CA:??:primary', { col: name }, { col: colour }, { col: symbol }] + then: ['road', 'CA:??:primary', { col: name }, { col: "osmc:symbol" }] - when: sov_a3: 'MEX' level: 'Interstate' - then: ['road', 'MX', { col: name }, { col: colour }, { col: symbol }] + then: ['road', 'MX', { col: name }, { col: "osmc:symbol" }] - when: sov_a3: 'MEX' level: 'Federal' - then: ['road', 'MX:MX', { col: name }, { col: colour }, { col: symbol }] + then: ['road', 'MX:MX', { col: name }, { col: "osmc:symbol" }] - when: sov_a3: 'USA' level: 'Interstate' - then: ['road', 'US:I', { col: name }, { col: colour }, { col: symbol }] + then: ['road', 'US:I', { col: name }, { col: "osmc:symbol" }] - when: sov_a3: 'USA' level: 'Federal' - then: ['road', 'US:US', { col: name }, { col: colour }, { col: symbol }] + then: ['road', 'US:US', { col: name }, { col: "osmc:symbol" }] - when: continent: 'Oceania' level: 'Federal' - then: ['road', 'NZ:SH', { col: label}, { col: colour }, { col: symbol }] + then: ['road', 'NZ:SH', { col: label}, { col: "osmc:symbol" }] - when: continent: ['Europe', 'Asia'] level: 'E' - then: ['road', 'e-road', { col: name }, { col: colour }, { col: symbol }] + then: ['road', 'e-road', { col: name }, { col: "osmc:symbol" }] columns: [ sov_a3, continent, label, level ] # tolls toll: From 0aa8b2495230153cae688a0b860865af73d298c4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 5 Jul 2022 16:13:15 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- vectordatasource/transform.py | 100 +++++++++++++++++----------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/vectordatasource/transform.py b/vectordatasource/transform.py index ee2d7faa0..b15585905 100644 --- a/vectordatasource/transform.py +++ b/vectordatasource/transform.py @@ -710,9 +710,9 @@ def _sorted_attributes(features, attrs, attribute): sort_key = attrs.get('sort_key') reverse = attrs.get('reverse') - assert sort_key is not None, "Configuration " + \ + assert sort_key is not None, 'Configuration ' + \ "parameter 'sort_key' is missing, please " + \ - "check your configuration." + 'check your configuration.' # first, we find the _minimum_ ordering over the # group of key values. this is because we only do @@ -776,8 +776,8 @@ def _sorted_attributes(features, attrs, attribute): # 4: contains a polygon / two-dimensional object def _geom_dimensions(g): dim = _GEOMETRY_DIMENSIONS.get(g.geom_type) - assert dim is not None, "Unknown geometry type " + \ - "%s in transform._geom_dimensions." % \ + assert dim is not None, 'Unknown geometry type ' + \ + '%s in transform._geom_dimensions.' % \ repr(g.geom_type) # recurse for geometry collections to find the true @@ -1865,7 +1865,7 @@ def _make_joined_name(props): >>> _make_joined_name(x) >>> x {'name:right': 'Right', 'name': 'Already Exists', 'name:left': 'Left'} - """ # noqa + """ # don't overwrite an existing name if 'name' in props: @@ -1876,7 +1876,7 @@ def _make_joined_name(props): if lname is not None: if rname is not None: - props['name'] = "%s - %s" % (lname, rname) + props['name'] = '%s - %s' % (lname, rname) else: props['name'] = lname elif rname is not None: @@ -2564,7 +2564,7 @@ def remove_zero_area(shape, properties, fid, zoom): # remove the property if it's present. we _only_ want # to replace it if it matches the positive, float # criteria. - area = properties.pop("area", None) + area = properties.pop('area', None) # try to parse a string if the area has been sent as a # string. it should come through as a float, though, @@ -3533,7 +3533,7 @@ def _intersects_bounds(a, b): # A bucket used to sort shapes into the next level of the quad tree. -Bucket = namedtuple("Bucket", "bounds box shapes") +Bucket = namedtuple('Bucket', 'bounds box shapes') def _mkbucket(*bounds): @@ -3602,8 +3602,8 @@ def _merge_shapes_recursively(shapes, shapes_per_merge, merger, depth=0, break else: raise AssertionError( - "Expected shape %r to intersect at least one quadrant, but " - "intersects none." % (shape.wkt)) + 'Expected shape %r to intersect at least one quadrant, but ' + 'intersects none.' % (shape.wkt)) # recurse if necessary to get below the number of shapes per merge that # we want. @@ -3885,7 +3885,7 @@ def _angle_at(linestring, pt): nx = pt pt = linestring.coords[-2] else: - assert False, "Expected point to be first or last" + assert False, 'Expected point to be first or last' if nx == pt: return None @@ -4039,7 +4039,7 @@ def _loop_merge_junctions(geom, angle_tolerance): break assert len(geom.geoms) < mls_size, \ - "Number of geometries should stay the same or reduce after merge." + 'Number of geometries should stay the same or reduce after merge.' # otherwise, keep looping mls_size = len(geom.geoms) @@ -4404,7 +4404,7 @@ def normalize_tourism_kind(shape, properties, fid, zoom): main kind. See https://github.com/mapzen/vector-datasource/issues/440 for more details. - """ # noqa + """ zoo = properties.pop('zoo', None) if zoo is not None: @@ -4586,7 +4586,7 @@ def match(self, other): return True def __repr__(self): - return "*" + return '*' class _NoneMatcher(object): @@ -4594,7 +4594,7 @@ def match(self, other): return other is None def __repr__(self): - return "-" + return '-' class _SomeMatcher(object): @@ -4602,7 +4602,7 @@ def match(self, other): return other is not None def __repr__(self): - return "+" + return '+' class _TrueMatcher(object): @@ -4610,7 +4610,7 @@ def match(self, other): return other is True def __repr__(self): - return "true" + return 'true' class _ExactMatcher(object): @@ -4697,7 +4697,7 @@ def __repr__(self): def _parse_kt(key_type): - kt = key_type.split("::") + kt = key_type.split('::') type_key = kt[1] if len(kt) > 1 else None fn = _KEY_TYPE_LOOKUP.get(type_key, str) @@ -4994,9 +4994,9 @@ def drop_small_inners(ctx): source_layers = ctx.params.get('source_layers') assert source_layers, \ - "You must provide source_layers (layer names) to drop_small_inners" + 'You must provide source_layers (layer names) to drop_small_inners' assert pixel_area, \ - "You must provide a pixel_area parameter to drop_small_inners" + 'You must provide a pixel_area parameter to drop_small_inners' if zoom < start_zoom: return None @@ -5168,31 +5168,31 @@ def simplify_and_clip(ctx): _lookup_operator_rules = { - 'United States National Park Service': ( - 'National Park Service', - 'US National Park Service', - 'U.S. National Park Service', - 'US National Park service'), - 'United States Forest Service': ( - 'US Forest Service', - 'U.S. Forest Service', - 'USDA Forest Service', - 'United States Department of Agriculture', - 'US National Forest Service', - 'United State Forest Service', - 'U.S. National Forest Service'), - 'National Parks & Wildife Service NSW': ( - 'Department of National Parks NSW', - 'Dept of NSW National Parks', - 'Dept of National Parks NSW', - 'Department of National Parks NSW', - 'NSW National Parks', - 'NSW National Parks & Wildlife Service', - 'NSW National Parks and Wildlife Service', - 'NSW Parks and Wildlife Service', - 'NSW Parks and Wildlife Service (NPWS)', - 'National Parks and Wildlife NSW', - 'National Parks and Wildlife Service NSW')} + 'United States National Park Service': ( + 'National Park Service', + 'US National Park Service', + 'U.S. National Park Service', + 'US National Park service'), + 'United States Forest Service': ( + 'US Forest Service', + 'U.S. Forest Service', + 'USDA Forest Service', + 'United States Department of Agriculture', + 'US National Forest Service', + 'United State Forest Service', + 'U.S. National Forest Service'), + 'National Parks & Wildife Service NSW': ( + 'Department of National Parks NSW', + 'Dept of NSW National Parks', + 'Dept of National Parks NSW', + 'Department of National Parks NSW', + 'NSW National Parks', + 'NSW National Parks & Wildlife Service', + 'NSW National Parks and Wildlife Service', + 'NSW Parks and Wildlife Service', + 'NSW Parks and Wildlife Service (NPWS)', + 'National Parks and Wildlife NSW', + 'National Parks and Wildlife Service NSW')} normalized_operator_lookup = {} for normalized_operator, variants in _lookup_operator_rules.items(): @@ -8178,13 +8178,13 @@ def __init__(self, colours): self.namelookup = dict() for name, colour in colours.items(): assert len(colour) == 3, \ - "Colours must lists of be of length 3 (%r: %r)" % \ + 'Colours must lists of be of length 3 (%r: %r)' % \ (name, colour) for val in colour: assert isinstance(val, int), \ - "Colour values must be integers (%r: %r)" % (name, colour) + 'Colour values must be integers (%r: %r)' % (name, colour) assert val >= 0 and val <= 255, \ - "Colour values must be between 0 and 255 (%r: %r)" % \ + 'Colour values must be between 0 and 255 (%r: %r)' % \ (name, colour) self.namelookup[tuple(colour)] = name self.tree = kdtree.create(colours.values()) @@ -8765,8 +8765,8 @@ def add_vehicle_restrictions(shape, props, fid, zoom): def _one_dp(val, unit): deci = int(floor(10 * val)) if deci % 10 == 0: - return "%d%s" % (deci / 10, unit) - return "%.1f%s" % (0.1 * deci, unit) + return '%d%s' % (deci / 10, unit) + return '%.1f%s' % (0.1 * deci, unit) def _metres(val): # parse metres or feet and inches, return cm