diff --git a/data/core.yaml b/data/core.yaml index 722410a62..b049cff91 100644 --- a/data/core.yaml +++ b/data/core.yaml @@ -23,6 +23,8 @@ en: title: Point description: "Add restaurants, monuments, postal boxes or other points to the map." tail: Click on the map to add a point. + add_vertex: + title: Vertex add_note: title: Note description: "Spotted an issue? Let other mappers know." @@ -35,6 +37,8 @@ en: title: "Add {feature} as a line" area: title: "Add {feature} as an area" + vertex: + title: "Add {feature} as a vertex" browse: title: Browse description: Pan and zoom the map. diff --git a/data/presets.yaml b/data/presets.yaml index 28b08d5ff..4754acec9 100644 --- a/data/presets.yaml +++ b/data/presets.yaml @@ -6944,8 +6944,9 @@ en: name: Waterway terms: '' vertex: - name: Other - terms: '' + name: Vertex + # 'terms: other' + terms: '' waterway: # waterway=* name: Waterway diff --git a/data/presets/presets.json b/data/presets/presets.json index 1f1e58ea6..6667af5eb 100644 --- a/data/presets/presets.json +++ b/data/presets/presets.json @@ -1060,7 +1060,7 @@ "type/route/tram": {"icon": "iD-route-tram", "fields": ["name", "ref_route", "operator", "network", "to", "from"], "geometry": ["relation"], "tags": {"type": "route", "route": "tram"}, "name": "Tram Route"}, "type/site": {"icon": "iD-relation", "fields": ["name", "site"], "geometry": ["relation"], "tags": {"type": "site"}, "name": "Site"}, "type/waterway": {"icon": "iD-route-water", "fields": ["name", "waterway", "ref"], "geometry": ["relation"], "tags": {"type": "waterway"}, "name": "Waterway"}, - "vertex": {"moreFields": ["name"], "geometry": ["vertex"], "tags": {}, "name": "Other", "matchScore": 0.1}, + "vertex": {"moreFields": ["name"], "geometry": ["vertex"], "terms": ["other"], "tags": {}, "name": "Vertex", "matchScore": 0.1}, "waterway/riverbank": {"icon": "maki-water", "geometry": ["area"], "tags": {"waterway": "riverbank"}, "name": "Riverbank", "searchable": false}, "waterway/boatyard": {"icon": "maki-harbor", "fields": ["name", "operator"], "moreFields": ["address", "website", "phone", "email", "fax", "wheelchair"], "geometry": ["area", "vertex", "point"], "tags": {"waterway": "boatyard"}, "name": "Boatyard"}, "waterway/canal": {"icon": "iD-waterway-canal", "fields": ["name", "width", "intermittent"], "moreFields": ["salt"], "geometry": ["line"], "tags": {"waterway": "canal"}, "name": "Canal"}, diff --git a/data/presets/presets/vertex.json b/data/presets/presets/vertex.json index 85c3ddbc6..228e00fd3 100644 --- a/data/presets/presets/vertex.json +++ b/data/presets/presets/vertex.json @@ -5,7 +5,10 @@ "geometry": [ "vertex" ], + "terms": [ + "other" + ], "tags": {}, - "name": "Other", + "name": "Vertex", "matchScore": 0.1 } diff --git a/dist/locales/en.json b/dist/locales/en.json index 58f9d3a84..19736eda0 100644 --- a/dist/locales/en.json +++ b/dist/locales/en.json @@ -29,6 +29,9 @@ "description": "Add restaurants, monuments, postal boxes or other points to the map.", "tail": "Click on the map to add a point." }, + "add_vertex": { + "title": "Vertex" + }, "add_note": { "title": "Note", "description": "Spotted an issue? Let other mappers know.", @@ -44,6 +47,9 @@ }, "area": { "title": "Add {feature} as an area" + }, + "vertex": { + "title": "Add {feature} as a vertex" } }, "browse": { @@ -8127,8 +8133,8 @@ "terms": "" }, "vertex": { - "name": "Other", - "terms": "" + "name": "Vertex", + "terms": "other" }, "waterway/riverbank": { "name": "Riverbank", diff --git a/modules/behavior/draw.js b/modules/behavior/draw.js index 49a243905..8959569f4 100644 --- a/modules/behavior/draw.js +++ b/modules/behavior/draw.js @@ -129,13 +129,11 @@ export function behaviorDraw(context) { var mode = context.mode(); - var allowsSnappingToWay = (mode.id !== 'add-point' || mode.preset.matchGeometry('vertex')); - if (target && target.type === 'node' && allowsVertex(target)) { // Snap to a node dispatch.call('clickNode', this, target, d); return; - } else if (target && target.type === 'way' && allowsSnappingToWay) { // Snap to a way + } else if (target && target.type === 'way' && (mode.id !== 'add-point' || mode.preset.matchGeometry('vertex'))) { // Snap to a way var choice = geoChooseEdge( context.childNodes(target), context.mouse(), context.projection, context.activeID() ); @@ -144,8 +142,10 @@ export function behaviorDraw(context) { dispatch.call('clickWay', this, choice.loc, edge, d); return; } + } else if (mode.id !== 'add-point' || mode.preset.matchGeometry('point')) { + dispatch.call('click', this, context.map().mouseCoordinates(), d); } - dispatch.call('click', this, context.map().mouseCoordinates(), d); + } diff --git a/modules/ui/modes.js b/modules/ui/modes.js index 15956cd44..75d304100 100644 --- a/modules/ui/modes.js +++ b/modules/ui/modes.js @@ -82,7 +82,7 @@ export function uiModes(context) { } var presetName = t('presets.presets.' + preset.id + '.name'); var relevantMatchingGeometry = preset.geometry.filter(function(geometry) { - return ['point', 'line', 'area'].indexOf(geometry) !== -1; + return ['vertex', 'point', 'line', 'area'].indexOf(geometry) !== -1; }); var tooltipTitleID = 'modes.add_preset.title'; if (relevantMatchingGeometry.length !== 1) { diff --git a/modules/ui/preset_favorite.js b/modules/ui/preset_favorite.js index d100b6e18..00440cefc 100644 --- a/modules/ui/preset_favorite.js +++ b/modules/ui/preset_favorite.js @@ -15,7 +15,7 @@ export function uiPresetFavorite(preset, geom, context, klass) { presetFavorite.button = function(selection) { - var canFavorite = geom !== 'vertex' && geom !== 'relation'; + var canFavorite = geom !== 'relation'; _button = selection.selectAll('.preset-favorite-button') .data(canFavorite ? [0] : []); diff --git a/modules/ui/search_add.js b/modules/ui/search_add.js index a44ad7ced..b9a307cb1 100644 --- a/modules/ui/search_add.js +++ b/modules/ui/search_add.js @@ -25,7 +25,7 @@ export function uiSearchAdd(context) { var presets; var search = d3_select(null), popover = d3_select(null), list = d3_select(null); - var shownGeometry = ['point', 'line', 'area']; + var shownGeometry = ['vertex', 'point', 'line', 'area']; function searchAdd(selection) { @@ -192,20 +192,28 @@ export function uiSearchAdd(context) { } } + function itemForPreset(preset) { + var supportedGeometry = preset.geometry.filter(function(geometry) { + return shownGeometry.indexOf(geometry) !== -1; + }).sort(); + var vertexIndex = supportedGeometry.indexOf('vertex'); + if (vertexIndex !== -1 && supportedGeometry.indexOf('point') !== -1) { + // both point and vertex allowed, just show point + supportedGeometry.splice(vertexIndex, 1); + } + if (supportedGeometry.length === 1) { + return AddablePresetItem(preset, supportedGeometry[0]); + } + return MultiGeometryPresetItem(preset, supportedGeometry); + } + function drawList(list, presets) { var collection = presets.collection.map(function(preset) { if (preset.members) { return CategoryItem(preset); - } else if (preset.visible()) { - var supportedGeometry = preset.geometry.filter(function(geometry) { - return shownGeometry.indexOf(geometry) !== -1; - }).sort(); - if (supportedGeometry.length === 1) { - return AddablePresetItem(preset, supportedGeometry[0]); - } - return MultiGeometryPresetItem(preset, supportedGeometry); } + return itemForPreset(preset); }); var items = list.selectAll('.list-item') @@ -279,7 +287,7 @@ export function uiSearchAdd(context) { row.each(function(d) { if (d.geometry) { - var presetFavorite = uiPresetFavorite(d.preset,d.geometry, context, 'accessory'); + var presetFavorite = uiPresetFavorite(d.preset, d.geometry, context, 'accessory'); d3_select(this).call(presetFavorite.button); } }); @@ -354,13 +362,7 @@ export function uiSearchAdd(context) { }; item.subitems = function() { return preset.members.matchAnyGeometry(shownGeometry).collection.map(function(preset) { - var supportedGeometry = preset.geometry.filter(function(geometry) { - return shownGeometry.indexOf(geometry) !== -1; - }).sort(); - if (supportedGeometry.length === 1) { - return AddablePresetItem(preset, supportedGeometry[0]); - } - return MultiGeometryPresetItem(preset, supportedGeometry); + return itemForPreset(preset); }); }; return item;