From d09fd15092c339b819b62261b52951b905caf43f Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Tue, 17 Jan 2017 16:56:23 +0530 Subject: [PATCH] Cleanups and rename service nominatim -> geocoder --- data/presets.yaml | 9 ++------- data/presets/fields.json | 26 ++++++++++++-------------- data/presets/fields/address.json | 26 ++++++++++++-------------- dist/locales/en.json | 26 ++++++++++++-------------- modules/ui/fields/address.js | 26 +++++++++++++------------- 5 files changed, 51 insertions(+), 62 deletions(-) diff --git a/data/presets.yaml b/data/presets.yaml index b92b2ae8f..456ca41a0 100644 --- a/data/presets.yaml +++ b/data/presets.yaml @@ -84,7 +84,7 @@ en: # access=* label: Access address: - # 'addr:block_number=*, addr:city=*, addr:conscriptionnumber=*, addr:county=*, addr:country=*, addr:district=*, addr:floor=*, addr:hamlet=*, addr:housename=*, addr:housenumber=*, addr:neighbourhood=*, addr:place=*, addr:postcode=*, addr:province=*, addr:quarter=*, addr:state=*, addr:street=*, addr:subdistrict=*, addr:suburb=*' + # 'addr:block_number=*, addr:city=*, addr:block_number=*, addr:conscriptionnumber=*, addr:county=*, addr:country=*, addr:county=*, addr:district=*, addr:floor=*, addr:hamlet=*, addr:housename=*, addr:housenumber=*, addr:neighbourhood=*, addr:place=*, addr:postcode=*, addr:province=*, addr:quarter=*, addr:state=*, addr:street=*, addr:subdistrict=*, addr:suburb=*' label: Address placeholders: block_number: Block Number @@ -110,12 +110,7 @@ en: province: Province province!jp: Prefecture quarter: Quarter - quarter!jp: Ōaza/Mach - neighbourhood: Neighbourhood - place: Place - postcode: Postcode - province: Province - quarter: Quarte + quarter!jp: Ōaza/Machi state: State street: Street subdistrict: Subdistrict diff --git a/data/presets/fields.json b/data/presets/fields.json index b58e25361..68ec1dbf4 100644 --- a/data/presets/fields.json +++ b/data/presets/fields.json @@ -109,38 +109,36 @@ "label": "Address", "strings": { "placeholders": { - "block_number": "Block number", - "city": "City", "block_number": "Block Number", + "block_number!jp": "Block No.", + "city": "City", + "city!jp": "City/Town/Village/Tokyo Special Ward", + "city!vn": "City/Town", "conscriptionnumber": "123", - "county": "County", "country": "Country", "county": "County", + "county!jp": "District", "district": "District", + "district!vn": "Arrondissement/Town/District", "floor": "Floor", "hamlet": "Hamlet", "housename": "Housename", "housenumber": "123", + "housenumber!jp": "Building No./Lot No.", "neighbourhood": "Neighbourhood", + "neighbourhood!jp": "Chōme/Aza/Koaza", "place": "Place", "postcode": "Postcode", "province": "Province", + "province!jp": "Prefecture", "quarter": "Quarter", + "quarter!jp": "Ōaza/Machi", "state": "State", "street": "Street", "subdistrict": "Subdistrict", - "suburb": "Suburb", "subdistrict!vn": "Ward/Commune/Townlet", - "district!vn": "Arrondissement/Town/District", - "city!vn": "City/Town", - "province!jp": "Prefecture", - "county!jp": "District", - "city!jp": "City/Town/Village/Tokyo Special Ward", - "suburb!jp": "Ward", - "quarter!jp": "Ōaza/Machi", - "neighbourhood!jp": "Chōme/Aza/Koaza", - "block_number!jp": "Block No.", - "housenumber!jp": "Building No./Lot No." + "suburb": "Suburb", + "suburb!jp": "Ward" } } }, diff --git a/data/presets/fields/address.json b/data/presets/fields/address.json index d8ad9ab39..198967c7d 100644 --- a/data/presets/fields/address.json +++ b/data/presets/fields/address.json @@ -29,38 +29,36 @@ "label": "Address", "strings": { "placeholders": { - "block_number": "Block number", - "city": "City", "block_number": "Block Number", + "block_number!jp": "Block No.", + "city": "City", + "city!jp": "City/Town/Village/Tokyo Special Ward", + "city!vn": "City/Town", "conscriptionnumber": "123", - "county": "County", "country": "Country", "county": "County", + "county!jp": "District", "district": "District", + "district!vn": "Arrondissement/Town/District", "floor": "Floor", "hamlet": "Hamlet", "housename": "Housename", "housenumber": "123", + "housenumber!jp": "Building No./Lot No.", "neighbourhood": "Neighbourhood", + "neighbourhood!jp": "Chōme/Aza/Koaza", "place": "Place", "postcode": "Postcode", "province": "Province", + "province!jp": "Prefecture", "quarter": "Quarter", + "quarter!jp": "Ōaza/Machi", "state": "State", "street": "Street", "subdistrict": "Subdistrict", - "suburb": "Suburb", "subdistrict!vn": "Ward/Commune/Townlet", - "district!vn": "Arrondissement/Town/District", - "city!vn": "City/Town", - "province!jp": "Prefecture", - "county!jp": "District", - "city!jp": "City/Town/Village/Tokyo Special Ward", - "suburb!jp": "Ward", - "quarter!jp": "Ōaza/Machi", - "neighbourhood!jp": "Chōme/Aza/Koaza", - "block_number!jp": "Block No.", - "housenumber!jp": "Building No./Lot No." + "suburb": "Suburb", + "suburb!jp": "Ward" } } } diff --git a/dist/locales/en.json b/dist/locales/en.json index ce48c0b10..9913d9127 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -789,38 +789,36 @@ "address": { "label": "Address", "placeholders": { - "block_number": "Block number", - "city": "City", "block_number": "Block Number", + "block_number!jp": "Block No.", + "city": "City", + "city!jp": "City/Town/Village/Tokyo Special Ward", + "city!vn": "City/Town", "conscriptionnumber": "123", - "county": "County", "country": "Country", "county": "County", + "county!jp": "District", "district": "District", + "district!vn": "Arrondissement/Town/District", "floor": "Floor", "hamlet": "Hamlet", "housename": "Housename", "housenumber": "123", + "housenumber!jp": "Building No./Lot No.", "neighbourhood": "Neighbourhood", + "neighbourhood!jp": "Chōme/Aza/Koaza", "place": "Place", "postcode": "Postcode", "province": "Province", + "province!jp": "Prefecture", "quarter": "Quarter", + "quarter!jp": "Ōaza/Machi", "state": "State", "street": "Street", "subdistrict": "Subdistrict", - "suburb": "Suburb", "subdistrict!vn": "Ward/Commune/Townlet", - "district!vn": "Arrondissement/Town/District", - "city!vn": "City/Town", - "province!jp": "Prefecture", - "county!jp": "District", - "city!jp": "City/Town/Village/Tokyo Special Ward", - "suburb!jp": "Ward", - "quarter!jp": "Ōaza/Machi", - "neighbourhood!jp": "Chōme/Aza/Koaza", - "block_number!jp": "Block No.", - "housenumber!jp": "Building No./Lot No." + "suburb": "Suburb", + "suburb!jp": "Ward" } }, "admin_level": { diff --git a/modules/ui/fields/address.js b/modules/ui/fields/address.js index 4baea3760..4ed7cb1b4 100644 --- a/modules/ui/fields/address.js +++ b/modules/ui/fields/address.js @@ -16,11 +16,9 @@ import { utilGetSetValue } from '../../util/get_set_value'; export function uiFieldAddress(field, context) { var dispatch = d3.dispatch('init', 'change'), - nominatim = services.nominatim, + nominatim = services.geocoder, wrap = d3.select(null), isInitialized = false, - widths, - addrTags, entity; function getNearStreets() { @@ -122,8 +120,10 @@ export function uiFieldAddress(field, context) { return a && a.countryCodes && _.includes(a.countryCodes, countryCode); }) || _.first(dataAddressFormats); - if (typeof addressFormat.widths !== 'undefined') { widths = addressFormat.widths; } - else { widths = {housenumber: 1/3, street: 2/3, city: 2/3, state: 1/4, postcode: 1/3}; } + var widths = addressFormat.widths || { + housenumber: 1/3, street: 2/3, + city: 2/3, state: 1/4, postcode: 1/3 + }; function row(r) { // Normalize widths. @@ -150,23 +150,24 @@ export function uiFieldAddress(field, context) { .append('input') .property('type', 'text') .attr('placeholder', function (d) { - var countryInserter = ''; - if (addressFormat.customPlaceholders.indexOf(d.id) !== -1) { countryInserter = '!' + countryCode; } - return field.t('placeholders.' + d.id + countryInserter); }) + var localkey = d.id + '!' + countryCode, + tkey = field.strings.placeholders[localkey] ? localkey : d.id; + return field.t('placeholders.' + tkey); + }) .attr('class', function (d) { return 'addr-' + d.id; }) .style('width', function (d) { return d.width * 100 + '%'; }); // Update + // setup dropdowns for common address tags - if (typeof addressFormat.dropdowns !== 'undefined') { addrTags = addressFormat.dropdowns; } - else { addrTags = [ + var dropdowns = addressFormat.dropdowns || [ 'city', 'county', 'country', 'district', 'hamlet', 'neighbourhood', 'place', 'postcode', 'province', 'quarter', 'state', 'street', 'subdistrict', 'suburb' - ]; } + ]; // If fields exist for any of these tags, create dropdowns to pick nearby values.. - addrTags.forEach(function(tag) { + dropdowns.forEach(function(tag) { var nearValues = (tag === 'street') ? getNearStreets : (tag === 'city') ? getNearCities : getNearValues; @@ -202,7 +203,6 @@ export function uiFieldAddress(field, context) { .attr('class', 'preset-input-wrap') .merge(wrap); - if (nominatim && entity) { var center = entity.extent(context.graph()).center(); nominatim.countryCode(center, initCallback);