Skip to content

Commit

Permalink
Fix issue #84: Change feature count tracking to operate across AI so…
Browse files Browse the repository at this point in the history
…urce types (#85)

Fix AI Feature maximum-count-per-changeset logic to include all AI features, not just roads.
  • Loading branch information
Bonkles committed Dec 10, 2019
1 parent 129a61c commit 379784b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
4 changes: 2 additions & 2 deletions data/core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,8 @@ en:
description: Does this look like an accurate feature? Select this to start editing it so that you can connect, tag, and save it to OpenStreetMap. 👍
annotation: Added a Map With AI feature.
tooltip: Add this feature to the map to begin editing.
disabled: To help improve OSM data quality, we only allow {n} ML roads to be added in each mapping session. Please try to fix issues on your edits so far. You will be able to add more roads after saving.
disabled_flash: To help improve OSM data quality, we only allow {n} ML roads to be added in each mapping session.
disabled: To help improve OSM data quality, we only allow {n} AI features to be added in each mapping session. Please try to fix issues on your edits so far. You will be able to add more AI features after saving.
disabled_flash: To help improve OSM data quality, we only allow {n} AI Features to be added in each mapping session.
key: A
option_reject:
label: Remove This Feature
Expand Down
26 changes: 10 additions & 16 deletions modules/ui/fb_feature_picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,30 @@ import { uiRapidFirstEdit } from './rapid_first_edit_dialog';

export function uiFbFeaturePicker(context, keybinding) {
var _datum;
var ML_ROADS_LIMIT_NON_TM_MODE = 50;
var AI_FEATURES_LIMIT_NON_TM_MODE = 50;


function isAddRoadDisabled() {
function isAddFeatureDisabled() {
// when task GPX is set in URL (TM mode), "add roads" is always enabled
var gpxInUrl = utilStringQs(window.location.hash).gpx;
if (gpxInUrl) return false;

var mlRoadsCount = 0;
var entities = context.graph().entities;
for (var eid in entities) {
var e = entities[eid];
if (eid.startsWith('w-') && e && (e.tags.source === 'digitalglobe' || e.tags.source === 'maxar')) {
mlRoadsCount += 1;
}
}
return mlRoadsCount >= ML_ROADS_LIMIT_NON_TM_MODE;
var annotations = context.history().peekAllAnnotations();
var aiFeatureAccepts = annotations.filter(function (a) { return a.type === 'fb_accept_feature'; });
return aiFeatureAccepts.length >= AI_FEATURES_LIMIT_NON_TM_MODE;
}


function onAcceptRoad() {
if (_datum) {
if (isAddRoadDisabled()) {
if (isAddFeatureDisabled()) {
var flash = uiFlash()
.duration(4000)
.iconName('#iD-icon-rapid-plus-circle')
.iconClass('operation disabled')
.text(t(
'fb_feature_picker.option_accept.disabled_flash',
{n: ML_ROADS_LIMIT_NON_TM_MODE}
{n: AI_FEATURES_LIMIT_NON_TM_MODE}
));
flash();
return;
Expand Down Expand Up @@ -204,18 +198,18 @@ export function uiFbFeaturePicker(context, keybinding) {
.placement('bottom')
.html(true)
.title(function() {
return isAddRoadDisabled()
return isAddFeatureDisabled()
? uiTooltipHtml(t(
'fb_feature_picker.option_accept.disabled',
{n: ML_ROADS_LIMIT_NON_TM_MODE}
{n: AI_FEATURES_LIMIT_NON_TM_MODE}
))
: uiTooltipHtml(
t('fb_feature_picker.option_accept.tooltip'),
t('fb_feature_picker.option_accept.key')
);
}),
onClick: onAcceptRoad,
disabledFunction: isAddRoadDisabled
disabledFunction: isAddFeatureDisabled
}, 'ai-features-accept');

presetItem(bodyEnter, {
Expand Down
2 changes: 1 addition & 1 deletion modules/ui/rapid_feature_toggle_dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export function uiRapidFeatureToggleDialog(context, AIFeatureToggleKey, featureT
toggleOptionText
.append('div')
.attr('class', 'rapid-feature-license')
.html(options.license)
.html(options.license);

toggleOptionText.select('p a')
.attr('target','_blank');
Expand Down

0 comments on commit 379784b

Please sign in to comment.