From f0ddbf2738f17e02ac84777248edef91d834094b Mon Sep 17 00:00:00 2001 From: Benjamin Clark Date: Tue, 29 Oct 2024 14:29:16 -0400 Subject: [PATCH 1/8] Re-enable footways layer and add strings. --- data/core.yaml | 3 +++ modules/core/RapidSystem.js | 37 +++++++++++++--------------- modules/pixi/PixiLayerRapid.js | 2 +- modules/services/MapWithAIService.js | 2 +- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/data/core.yaml b/data/core.yaml index c03cc72da..e57bd3e63 100644 --- a/data/core.yaml +++ b/data/core.yaml @@ -1127,6 +1127,9 @@ en: places: label: Overture Places license_markdown: "[license](https://docs.overturemaps.org/attribution/#places)" + omdFootways: + label: Open Data Footways + license_markdown: "[license](https://rapideditor.org/doc/license/MapWithAILicense.pdf)" esri: title: ArcGIS Datasets about: "These datasets have been provided as open data by the ArcGIS user community for the purpose of improving OpenStreetMap.
You can learn more by visiting [the Rapid Guide](https://github.com/facebookmicrosites/Open-Mapping-At-Facebook/wiki/Esri-ArcGIS-FAQ) or [Esri/ArcGIS dataset page on the OSM Wiki](https://wiki.openstreetmap.org/wiki/Esri/ArcGIS_Datasets)." diff --git a/modules/core/RapidSystem.js b/modules/core/RapidSystem.js index ce8be4e56..543813ae4 100644 --- a/modules/core/RapidSystem.js +++ b/modules/core/RapidSystem.js @@ -130,26 +130,23 @@ export class RapidSystem extends AbstractSystem { licenseStringID: 'rapid_feature_toggle.overture.places.license_markdown' }); -// bhousel 8/29/24, not yet -// this._datasets.set('metaFootways', { -// id: 'metaFootways', -// beta: true, -// added: true, // whether it should appear in the list -// enabled: false, // whether the user has checked it on -// conflated: true, -// service: 'mapwithai', -// overlay: { -// url: 'https://external.xx.fbcdn.net/maps/vtp/rapid_overlay_footways/1/{z}/{x}/{y}/', -// minZoom: 1, -// maxZoom: 15, -// }, -// color: RAPID_MAGENTA, -// dataUsed: ['mapwithai', 'Meta Footways'], -// label: l10n.t('rapid_feature_toggle.metaFootways.label'), -// labelStringID: 'rapid_feature_toggle.metaFootways.label', -// license_markdown: l10n.t('rapid_feature_toggle.metaFootways.license_markdown'), -// licenseStringID: 'rapid_feature_toggle.metaFootways.license_markdown' -// }); + this._datasets.set('omdFootways', { + id: 'omdFootways', + beta: true, + added: true, // whether it should appear in the list + enabled: false, // whether the user has checked it on + conflated: true, + service: 'mapwithai', + overlay: { + url: 'https://external.xx.fbcdn.net/maps/vtp/rapid_overlay_footways/1/{z}/{x}/{y}/', + minZoom: 1, + maxZoom: 15, + }, + color: RAPID_MAGENTA, + dataUsed: ['mapwithai', 'Open Footways'], + label: l10n.t('rapid_feature_toggle.omdFootways.label'), + license_markdown: l10n.t('rapid_feature_toggle.omdFootways.license_markdown') + }); }); } diff --git a/modules/pixi/PixiLayerRapid.js b/modules/pixi/PixiLayerRapid.js index 2ad36264d..fe751b506 100644 --- a/modules/pixi/PixiLayerRapid.js +++ b/modules/pixi/PixiLayerRapid.js @@ -216,7 +216,7 @@ export class PixiLayerRapid extends AbstractLayer { // fb_ai service gives us roads and buildings together, // so filter further according to which dataset we're drawing - if (dataset.id === 'fbRoads' || dataset.id === 'metaFootways' || dataset.id === 'rapid_intro_graph') { + if (dataset.id === 'fbRoads' || dataset.id === 'omdFootways' || dataset.id === 'rapid_intro_graph') { data.lines = entities.filter(d => d.geometry(dsGraph) === 'line' && !!d.tags.highway); // Gather endpoint vertices, we will render these also diff --git a/modules/services/MapWithAIService.js b/modules/services/MapWithAIService.js index 4e88aca80..b661f9540 100644 --- a/modules/services/MapWithAIService.js +++ b/modules/services/MapWithAIService.js @@ -255,7 +255,7 @@ export class MapWithAIService extends AbstractSystem { if (datasetID === 'fbRoads') { qs.result_type = 'road_vector_xml'; - } else if (datasetID === 'metaFootways') { + } else if (datasetID === 'omdFootways') { qs.result_type = 'extended_osc'; qs.sources = 'ML2OSM_META_FOOTWAYS'; } else if (datasetID === 'msBuildings') { From dc10608a07e6703228bf62f193cb8768531f6462 Mon Sep 17 00:00:00 2001 From: Benjamin Clark Date: Mon, 11 Nov 2024 16:57:23 -0500 Subject: [PATCH 2/8] Add conflation debug url param. --- modules/pixi/PixiLayerRapid.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/pixi/PixiLayerRapid.js b/modules/pixi/PixiLayerRapid.js index fe751b506..61d8f8964 100644 --- a/modules/pixi/PixiLayerRapid.js +++ b/modules/pixi/PixiLayerRapid.js @@ -1,5 +1,6 @@ import * as PIXI from 'pixi.js'; import geojsonRewind from '@mapbox/geojson-rewind'; +import { utilStringQs } from '@rapid-sdk/util'; import { AbstractLayer } from './AbstractLayer.js'; import { PixiFeatureLine } from './PixiFeatureLine.js'; @@ -192,8 +193,16 @@ export class PixiLayerRapid extends AbstractLayer { const service = context.services[dataset.service]; // 'mapwithai' or 'esri' if (!service?.started) return; + const useConflationStr = utilStringQs(window.location.hash).conflation; + + let useConflation = dataset.conflated; + + if (useConflationStr === 'false' || useConflationStr === 'no') { + useConflation = false; + } + // Adjust the dataset id for whether we want the data conflated or not. - const datasetID = dataset.id + (dataset.conflated ? '-conflated' : ''); + const datasetID = dataset.id + (useConflation ? '-conflated' : ''); const dsGraph = service.graph(datasetID); // Filter out features that have already been accepted or ignored by the user. From 63607b28b952bf18c16bd8628eba48b0e10f066c Mon Sep 17 00:00:00 2001 From: Benjamin Clark Date: Tue, 12 Nov 2024 10:00:57 -0500 Subject: [PATCH 3/8] Fix a bug that was preventing the overlays from rendering. --- modules/pixi/PixiLayerRapidOverlay.js | 28 ++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/modules/pixi/PixiLayerRapidOverlay.js b/modules/pixi/PixiLayerRapidOverlay.js index 0550abd34..7cc85911a 100644 --- a/modules/pixi/PixiLayerRapidOverlay.js +++ b/modules/pixi/PixiLayerRapidOverlay.js @@ -26,14 +26,8 @@ export class PixiLayerRapidOverlay extends AbstractLayer { overlays.sortableChildren = false; overlays.interactiveChildren = true; this.overlaysContainer = overlays; - this._overlaysDefined = false; + this._overlaysDefined = null; - const datasets = this.context.systems.rapid.datasets; - for (const dataset of datasets.values()) { - if (dataset.overlay) { - this._overlaysDefined = true; - } - } const basemapContainer = this.scene.groups.get('basemap'); basemapContainer.addChild(overlays); @@ -93,8 +87,8 @@ export class PixiLayerRapidOverlay extends AbstractLayer { const point = viewport.project(loc); const feature = new PIXI.Graphics() - .fill({color, alpha:0.05}) - .circle(0, 0, 40); + .circle(0, 0, 40) + .fill({color, alpha:0.05}); feature.x = point[0]; feature.y = point[1]; @@ -106,10 +100,22 @@ export class PixiLayerRapidOverlay extends AbstractLayer { /** * hasData - * Return true if there is overlay data to display. + * Return true if there is any overlay endpoint URLs defined in the rapid datasets. * @return {boolean} `true` if there is a vector tile template or geojson to display */ hasData() { + + if (this._overlaysDefined === null) { + const datasets = this.context.systems.rapid.datasets; + this._overlaysDefined = false; + for (const dataset of datasets.values()) { + if (dataset.overlay) { + this._overlaysDefined = true; + } + } + + } + return this._overlaysDefined; } @@ -119,7 +125,7 @@ export class PixiLayerRapidOverlay extends AbstractLayer { * Clear state to prepare for new custom data */ _clear() { - this._overlaysDefined = false; + this._overlaysDefined = null; } } From a98c52ac4a0a38d17faef514b844c4091be738a3 Mon Sep 17 00:00:00 2001 From: Benjamin Clark Date: Mon, 25 Nov 2024 13:52:53 -0500 Subject: [PATCH 4/8] Change footways prevew setting to FALSE. --- modules/core/RapidSystem.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/RapidSystem.js b/modules/core/RapidSystem.js index 543813ae4..90d8c72a3 100644 --- a/modules/core/RapidSystem.js +++ b/modules/core/RapidSystem.js @@ -132,7 +132,7 @@ export class RapidSystem extends AbstractSystem { this._datasets.set('omdFootways', { id: 'omdFootways', - beta: true, + beta: false, added: true, // whether it should appear in the list enabled: false, // whether the user has checked it on conflated: true, From 6329dacbdbfd6890ca9e09896dc25d82ea874470 Mon Sep 17 00:00:00 2001 From: Benjamin Clark Date: Tue, 26 Nov 2024 13:48:21 -0500 Subject: [PATCH 5/8] Add license notice to the feature inspector for footways (with placeholder URL). --- css/80_app_fb.css | 4 ++++ data/core.yaml | 2 ++ modules/core/RapidSystem.js | 6 ++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/css/80_app_fb.css b/css/80_app_fb.css index 9b7b5342a..5ea3a6c22 100644 --- a/css/80_app_fb.css +++ b/css/80_app_fb.css @@ -308,6 +308,10 @@ button.rapid-features.layer-off use { margin: 10px; } +.rapid-inspector-notice { + font-style: italic; +} + .rapid-inspector-choice .choice-wrap { display: flex; flex: 1 0 50px; diff --git a/data/core.yaml b/data/core.yaml index e57bd3e63..4acf45e5f 100644 --- a/data/core.yaml +++ b/data/core.yaml @@ -1098,6 +1098,8 @@ en: rapid_feature_inspector: prompt: How would you like to proceed with this selected feature? + notice: + open_data: This dataset is comprised of open data. See our {license} for more details. tags: Tags option_accept: label: Add This Feature diff --git a/modules/core/RapidSystem.js b/modules/core/RapidSystem.js index 90d8c72a3..1f0b9e013 100644 --- a/modules/core/RapidSystem.js +++ b/modules/core/RapidSystem.js @@ -142,11 +142,13 @@ export class RapidSystem extends AbstractSystem { minZoom: 1, maxZoom: 15, }, + tags: 'opendata', color: RAPID_MAGENTA, dataUsed: ['mapwithai', 'Open Footways'], label: l10n.t('rapid_feature_toggle.omdFootways.label'), - license_markdown: l10n.t('rapid_feature_toggle.omdFootways.license_markdown') - }); + labelStringID: 'rapid_feature_toggle.omdFootways.label', + license_markdown: l10n.t('rapid_feature_toggle.omdFootways.license_markdown'), + licenseStringID: 'rapid_feature_toggle.omdFootways.license_markdown'}); }); } From 7df75c8ba577e9a206b6f95ae021cb0f51176ca3 Mon Sep 17 00:00:00 2001 From: Benjamin Clark Date: Mon, 2 Dec 2024 15:06:59 -0500 Subject: [PATCH 6/8] Add the notice rendering code back for footways (or any other open data). --- modules/ui/UiRapidInspector.js | 42 +++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/modules/ui/UiRapidInspector.js b/modules/ui/UiRapidInspector.js index ad51c3f4e..e334c782f 100644 --- a/modules/ui/UiRapidInspector.js +++ b/modules/ui/UiRapidInspector.js @@ -1,4 +1,5 @@ import { select, selection } from 'd3-selection'; +import { marked } from 'marked'; import { actionNoop, actionRapidAcceptFeature } from '../actions/index.js'; import { uiIcon } from './icon.js'; @@ -49,6 +50,7 @@ export class UiRapidInspector { this.renderTagInfo = this.renderTagInfo.bind(this); this.renderChoices = this.renderChoices.bind(this); this.renderChoice = this.renderChoice.bind(this); + this.renderNotice = this.renderNotice.bind(this); this.acceptFeature = this.acceptFeature.bind(this); this.ignoreFeature = this.ignoreFeature.bind(this); this._setupKeybinding = this._setupKeybinding.bind(this); @@ -117,7 +119,8 @@ export class UiRapidInspector { $inspector.selectAll('.body') .call(this.renderFeatureInfo) .call(this.renderTagInfo) - .call(this.renderChoices); + .call(this.renderChoices) + .call(this.renderNotice); } @@ -396,6 +399,43 @@ export class UiRapidInspector { } + + /** + * renderNotice + * Renders the 'rapid-inspector-notice' section + * This section contains remarks about the data - license, usage, or other hints + * @param {d3-selection} $selection - A d3-selection to a HTMLElement that this content should render itself into + */ + renderNotice($selection) { + const context = this.context; + const l10n = context.systems.l10n; + const rapid = context.systems.rapid; + const datum = this.datum; + if (!datum) return; + + const datasetID = datum.__datasetid__.replace('-conflated', ''); + const dataset = rapid.datasets.get(datasetID); + + // Only display notice data for open data (for now) + if (!dataset.tags.includes('opendata')) return; + + let $notice = $selection.selectAll('.rapid-inspector-notice') + .data([0]); + + // enter + const $$notice = $notice.enter() + .append('div') + .attr('class', 'rapid-inspector-notice'); + + $$notice + .html(marked.parse(l10n.t('rapid_feature_inspector.notice.open_data', {license: dataset.license_markdown}))); + + // update + $notice = $notice.merge($$notice); + } + + + /** * renderChoice * Renders a choice - This should be called within a d3-selection.each From eb209fa3c4aa7c7ac43da1ac91ab6e5ddbe7be20 Mon Sep 17 00:00:00 2001 From: Benjamin Clark Date: Mon, 2 Dec 2024 15:39:07 -0500 Subject: [PATCH 7/8] Fix logic issue that caused the sidebar renderer to go hayire. --- modules/ui/UiRapidInspector.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/modules/ui/UiRapidInspector.js b/modules/ui/UiRapidInspector.js index e334c782f..fd3599377 100644 --- a/modules/ui/UiRapidInspector.js +++ b/modules/ui/UiRapidInspector.js @@ -417,21 +417,23 @@ export class UiRapidInspector { const dataset = rapid.datasets.get(datasetID); // Only display notice data for open data (for now) - if (!dataset.tags.includes('opendata')) return; + if (dataset.tags?.includes('opendata')) { - let $notice = $selection.selectAll('.rapid-inspector-notice') + let $notice = $selection.selectAll('.rapid-inspector-notice') .data([0]); - // enter - const $$notice = $notice.enter() - .append('div') - .attr('class', 'rapid-inspector-notice'); + // enter + const $$notice = $notice.enter() + .append('div') + .attr('class', 'rapid-inspector-notice'); - $$notice - .html(marked.parse(l10n.t('rapid_feature_inspector.notice.open_data', {license: dataset.license_markdown}))); + $$notice + .html(marked.parse(l10n.t('rapid_feature_inspector.notice.open_data', {license: dataset.license_markdown}))); + + // update + $notice = $notice.merge($$notice); + } - // update - $notice = $notice.merge($$notice); } From 883e0d44a10cd097010df5f74d435bec416b5118 Mon Sep 17 00:00:00 2001 From: Benjamin Clark Date: Tue, 3 Dec 2024 09:26:21 -0500 Subject: [PATCH 8/8] Remove the import, orig_id, and debug_way_id from rapid features sent by the conflation service. --- modules/actions/rapid_accept_feature.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/actions/rapid_accept_feature.js b/modules/actions/rapid_accept_feature.js index 6df868889..14693edcd 100644 --- a/modules/actions/rapid_accept_feature.js +++ b/modules/actions/rapid_accept_feature.js @@ -65,6 +65,9 @@ function removeMetadata(entity) { delete entity.__service__; delete entity.__datasetid__; delete entity.tags.conn; + delete entity.tags.orig_id; + delete entity.tags.debug_way_id; + delete entity.tags.import; delete entity.tags.dupe; }