Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenMapData Footways #1608

Merged
merged 8 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions css/80_app_fb.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions data/core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1127,6 +1129,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.<br/>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)."
Expand Down
3 changes: 3 additions & 0 deletions modules/actions/rapid_accept_feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
39 changes: 19 additions & 20 deletions modules/core/RapidSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,26 +130,25 @@ 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: false,
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,
},
tags: 'opendata',
color: RAPID_MAGENTA,
dataUsed: ['mapwithai', 'Open Footways'],
label: l10n.t('rapid_feature_toggle.omdFootways.label'),
labelStringID: 'rapid_feature_toggle.omdFootways.label',
license_markdown: l10n.t('rapid_feature_toggle.omdFootways.license_markdown'),
licenseStringID: 'rapid_feature_toggle.omdFootways.license_markdown'});
});
}

Expand Down
13 changes: 11 additions & 2 deletions modules/pixi/PixiLayerRapid.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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.
Expand All @@ -216,7 +225,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
Expand Down
28 changes: 17 additions & 11 deletions modules/pixi/PixiLayerRapidOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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];
Expand All @@ -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;
}

Expand All @@ -119,7 +125,7 @@ export class PixiLayerRapidOverlay extends AbstractLayer {
* Clear state to prepare for new custom data
*/
_clear() {
this._overlaysDefined = false;
this._overlaysDefined = null;
}

}
2 changes: 1 addition & 1 deletion modules/services/MapWithAIService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
44 changes: 43 additions & 1 deletion modules/ui/UiRapidInspector.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}


Expand Down Expand Up @@ -396,6 +399,45 @@ 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')) {

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
Expand Down
Loading