From 06e97cd01924c729fe75345ad0d6875218ebf738 Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Wed, 24 Jun 2020 10:40:46 -0400 Subject: [PATCH] Make Maxar imagery strings translatable (close #7724) --- data/manual_imagery.json | 34 ++++++++++++++++++++++++++++++ dist/locales/en.json | 14 +++++++++++++ scripts/build_data.js | 22 +++++++++++++++++++- scripts/update_imagery.js | 44 +++++++-------------------------------- 4 files changed, 76 insertions(+), 38 deletions(-) create mode 100644 data/manual_imagery.json diff --git a/data/manual_imagery.json b/data/manual_imagery.json new file mode 100644 index 000000000..080890dbe --- /dev/null +++ b/data/manual_imagery.json @@ -0,0 +1,34 @@ +[ + { + "id": "Maxar-Premium", + "name": "Maxar Premium Imagery (Beta)", + "type": "tms", + "default": true, + "attribution": { + "required": true, + "text": "Terms & Feedback", + "url": "https://wiki.openstreetmap.org/wiki/DigitalGlobe" + }, + "description": "Maxar Premium is a mosaic composed of Maxar basemap with select regions filled with +Vivid or custom area of interest imagery, 50cm resolution or better, and refreshed more frequently with ongoing updates.", + "icon": "https://osmlab.github.io/editor-layer-index/sources/world/Maxar.png", + "max_zoom": 22, + "url": "7586487389962e3f6e31ab2ed8ca321f2f3fe2cf87f1dedce8fc918b4692efd86fcd816ab8a35303effb1be9abe39b1cce3fe6db2c740044364ae68560822c88373d2c784325baf4e1fa007c6dbedab4cea3fa0dd86ee0ae4feeef032d33dcac28e4b16c90d55a42087c6b66526423ea1b4cc7e63c613940eb1c60f48270060bf41c5fcb6a628985ebe6801e9e71f041cc9f8df06b0345600376663e7dc1cdbc7df16876d8b5d006ed5782e6af4bfe2ff5a292", + "encrypted": true + }, + { + "id": "Maxar-Standard", + "name": "Maxar Standard Imagery (Beta)", + "type": "tms", + "default": true, + "attribution": { + "required": true, + "text": "Terms & Feedback", + "url": "https://wiki.openstreetmap.org/wiki/DigitalGlobe" + }, + "description": "Maxar Standard is a curated set of imagery covering 86% of the earth’s landmass, with 30-60cm resolution where available, backfilled by Landsat. Average age is 2.31 years, with some areas updated 2x per year.", + "icon": "https://osmlab.github.io/editor-layer-index/sources/world/Maxar.png", + "max_zoom": 22, + "url": "7586487389962e3f6e31ab2ed8ca321f2f3fe2cf87f1dedce8fc918b4692efd86fcd816ab8a35303effb1be9abe39b1cce3fe6db2c740044364ae68560822c88373d2c784325baf4e1fa007c6dbedab4cea3fa0dd86ee0ae4feeef032d33dcac28e4b16c90d55a42087c6b66526423ea1b4cc7e63c613940eb1c60f48270060bf41c5fcb6a628985ebe6801e9e71f010c8c9d7fb6b534560012461377dc1cdb672f16827dfe0d005bf5685b7ac4ea97cf5f795", + "encrypted": true + } +] diff --git a/dist/locales/en.json b/dist/locales/en.json index cc75a6b76..a4d4d8a04 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -10892,6 +10892,20 @@ "text": "Urząd Miasta Wrocław" }, "name": "Wrocław: Orthophotomap 2018 (aerial image)" + }, + "Maxar-Premium": { + "name": "Maxar Premium Imagery (Beta)", + "attribution": { + "text": "Terms & Feedback" + }, + "description": "Maxar Premium is a mosaic composed of Maxar basemap with select regions filled with +Vivid or custom area of interest imagery, 50cm resolution or better, and refreshed more frequently with ongoing updates." + }, + "Maxar-Standard": { + "name": "Maxar Standard Imagery (Beta)", + "attribution": { + "text": "Terms & Feedback" + }, + "description": "Maxar Standard is a curated set of imagery covering 86% of the earth’s landmass, with 30-60cm resolution where available, backfilled by Landsat. Average age is 2.31 years, with some areas updated 2x per year." } }, "community": { diff --git a/scripts/build_data.js b/scripts/build_data.js index ffdea8729..a6269687a 100644 --- a/scripts/build_data.js +++ b/scripts/build_data.js @@ -777,12 +777,32 @@ function writeEnJson(tstrings) { const readCoreYaml = fs.readFileSync('data/core.yaml', 'utf8'); const readImagery = fs.readFileSync('node_modules/editor-layer-index/i18n/en.yaml', 'utf8'); const readCommunity = fs.readFileSync('node_modules/osm-community-index/i18n/en.yaml', 'utf8'); + const readManualImagery = fs.readFileSync('data/manual_imagery.json', 'utf8'); - return Promise.all([readCoreYaml, readImagery, readCommunity]) + return Promise.all([readCoreYaml, readImagery, readCommunity, readManualImagery]) .then(data => { let core = YAML.load(data[0]); let imagery = YAML.load(data[1]); let community = YAML.load(data[2]); + let manualImagery = JSON.parse(data[3]); + + for (let i in manualImagery) { + let layer = manualImagery[i]; + let id = layer.id; + for (let key in layer) { + if (key === 'attribution') { + for (let attrKey in layer[key]) { + if (attrKey !== 'text') { + delete layer[key][attrKey]; + } + } + } else if (['name', 'description'].indexOf(key) === -1) { + delete layer[key]; + } + } + // tack on strings for additional imagery not included in the index + imagery.en.imagery[id] = layer; + } let enjson = core; enjson.en.presets = tstrings; diff --git a/scripts/update_imagery.js b/scripts/update_imagery.js index f3f0f1921..f14e62c53 100644 --- a/scripts/update_imagery.js +++ b/scripts/update_imagery.js @@ -1,8 +1,13 @@ /* eslint-disable no-console */ const fs = require('fs'); -const sources = require('editor-layer-index/imagery.json'); +let sources = require('editor-layer-index/imagery.json'); const prettyStringify = require('json-stringify-pretty-compact'); +if (fs.existsSync('./data/manual_imagery.json')) { + // we can include additional imagery sources that aren't in the index + sources = sources.concat(JSON.parse(fs.readFileSync('./data/manual_imagery.json'))); +} + let imagery = []; // ignore imagery more than 20 years old.. @@ -10,41 +15,6 @@ let cutoffDate = new Date(); cutoffDate.setFullYear(cutoffDate.getFullYear() - 20); -const keep = [ - // Add custom sources here if needed. - { - id: 'Maxar-Premium', - name: 'Maxar Premium Imagery (Beta)', - type: 'tms', - default: true, - attribution: { - required: true, - text: 'Terms & Feedback', - url: 'https://wiki.openstreetmap.org/wiki/DigitalGlobe' - }, - description: 'Maxar Premium is a mosaic composed of Maxar basemap with select regions filled with +Vivid or custom area of interest imagery, 50cm resolution or better, and refreshed more frequently with ongoing updates.', - icon: 'https://osmlab.github.io/editor-layer-index/sources/world/Maxar.png', - max_zoom: 22, - url: '7586487389962e3f6e31ab2ed8ca321f2f3fe2cf87f1dedce8fc918b4692efd86fcd816ab8a35303effb1be9abe39b1cce3fe6db2c740044364ae68560822c88373d2c784325baf4e1fa007c6dbedab4cea3fa0dd86ee0ae4feeef032d33dcac28e4b16c90d55a42087c6b66526423ea1b4cc7e63c613940eb1c60f48270060bf41c5fcb6a628985ebe6801e9e71f041cc9f8df06b0345600376663e7dc1cdbc7df16876d8b5d006ed5782e6af4bfe2ff5a292', - encrypted: true - }, { - id: 'Maxar-Standard', - name: 'Maxar Standard Imagery (Beta)', - type: 'tms', - default: true, - attribution: { - required: true, - text: 'Terms & Feedback', - url: 'https://wiki.openstreetmap.org/wiki/DigitalGlobe' - }, - description: 'Maxar Standard is a curated set of imagery covering 86% of the earth’s landmass, with 30-60cm resolution where available, backfilled by Landsat. Average age is 2.31 years, with some areas updated 2x per year.', - icon: 'https://osmlab.github.io/editor-layer-index/sources/world/Maxar.png', - max_zoom: 22, - url: '7586487389962e3f6e31ab2ed8ca321f2f3fe2cf87f1dedce8fc918b4692efd86fcd816ab8a35303effb1be9abe39b1cce3fe6db2c740044364ae68560822c88373d2c784325baf4e1fa007c6dbedab4cea3fa0dd86ee0ae4feeef032d33dcac28e4b16c90d55a42087c6b66526423ea1b4cc7e63c613940eb1c60f48270060bf41c5fcb6a628985ebe6801e9e71f010c8c9d7fb6b534560012461377dc1cdb672f16827dfe0d005bf5685b7ac4ea97cf5f795', - encrypted: true - } -]; - const discard = { 'osmbe': true, // 'OpenStreetMap (Belgian Style)' 'osmfr': true, // 'OpenStreetMap (French Style)' @@ -106,7 +76,7 @@ const supportedWMSProjections = { }; -sources.concat(keep).forEach(source => { +sources.forEach(source => { if (source.type !== 'tms' && source.type !== 'wms' && source.type !== 'bing') return; if (source.id in discard) return;