mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00:00
Treat entities on addr:interpolation lines as points, not vertices
(closes #3241)
This commit is contained in:
@@ -51,6 +51,15 @@ _.extend(Node.prototype, {
|
||||
});
|
||||
},
|
||||
|
||||
isOnAddressLine: function(resolver) {
|
||||
return resolver.transient(this, 'isOnAddressLine', function() {
|
||||
return resolver.parentWays(this).filter(function(parent) {
|
||||
return parent.tags.hasOwnProperty('addr:interpolation') &&
|
||||
parent.geometry(resolver) === 'line';
|
||||
}).length > 0;
|
||||
});
|
||||
},
|
||||
|
||||
asJXON: function(changeset_id) {
|
||||
var r = {
|
||||
node: {
|
||||
|
||||
@@ -23,8 +23,14 @@ export function presets() {
|
||||
};
|
||||
|
||||
all.match = function(entity, resolver) {
|
||||
var geometry = entity.geometry(resolver),
|
||||
geometryMatches = index[geometry],
|
||||
var geometry = entity.geometry(resolver);
|
||||
|
||||
// Treat entities on addr:interpolation lines as points, not vertices (#3241)
|
||||
if (geometry === 'vertex' && entity.isOnAddressLine(resolver)) {
|
||||
geometry = 'point';
|
||||
}
|
||||
|
||||
var geometryMatches = index[geometry],
|
||||
best = -1,
|
||||
match;
|
||||
|
||||
|
||||
@@ -6,14 +6,21 @@ import { PresetIcon } from './preset_icon';
|
||||
import { TagReference } from './tag_reference';
|
||||
|
||||
export function PresetList(context) {
|
||||
var event = d3.dispatch('choose'),
|
||||
var dispatch = d3.dispatch('choose'),
|
||||
id,
|
||||
currentPreset,
|
||||
autofocus = false;
|
||||
|
||||
function presetList(selection) {
|
||||
var geometry = context.geometry(id),
|
||||
presets = context.presets().matchGeometry(geometry);
|
||||
var entity = context.entity(id),
|
||||
geometry = context.geometry(id);
|
||||
|
||||
// Treat entities on addr:interpolation lines as points, not vertices (#3241)
|
||||
if (geometry === 'vertex' && entity.isOnAddressLine(context.graph())) {
|
||||
geometry = 'point';
|
||||
}
|
||||
|
||||
var presets = context.presets().matchGeometry(geometry);
|
||||
|
||||
selection.html('');
|
||||
|
||||
@@ -26,7 +33,7 @@ export function PresetList(context) {
|
||||
if (context.entity(id).isUsed(context.graph())) {
|
||||
messagewrap.append('button')
|
||||
.attr('class', 'preset-choose')
|
||||
.on('click', function() { event.choose(currentPreset); })
|
||||
.on('click', function() { dispatch.choose(currentPreset); })
|
||||
.append('span')
|
||||
.html('►');
|
||||
} else {
|
||||
@@ -221,7 +228,7 @@ export function PresetList(context) {
|
||||
ChangePreset(id, currentPreset, preset),
|
||||
t('operations.change_tags.annotation'));
|
||||
|
||||
event.choose(preset);
|
||||
dispatch.choose(preset);
|
||||
};
|
||||
|
||||
item.help = function() {
|
||||
@@ -254,5 +261,5 @@ export function PresetList(context) {
|
||||
return presetList;
|
||||
};
|
||||
|
||||
return d3.rebind(presetList, event, 'on');
|
||||
return d3.rebind(presetList, dispatch, 'on');
|
||||
}
|
||||
|
||||
@@ -8,16 +8,16 @@ describe('iD.presets.presets', function() {
|
||||
tags: {},
|
||||
geometry: ['line']
|
||||
},
|
||||
vertex: {
|
||||
tags: {},
|
||||
geometry: ['vertex']
|
||||
},
|
||||
residential: {
|
||||
tags: {
|
||||
highway: 'residential'
|
||||
},
|
||||
tags: { highway: 'residential' },
|
||||
geometry: ['line']
|
||||
},
|
||||
park: {
|
||||
tags: {
|
||||
leisure: 'park'
|
||||
},
|
||||
tags: { leisure: 'park' },
|
||||
geometry: ['point', 'area']
|
||||
}
|
||||
};
|
||||
@@ -26,18 +26,36 @@ describe('iD.presets.presets', function() {
|
||||
|
||||
describe('#match', function() {
|
||||
it('returns a collection containing presets matching a geometry and tags', function() {
|
||||
var way = iD.Way({tags: { highway: 'residential'}}),
|
||||
var way = iD.Way({ tags: { highway: 'residential' } }),
|
||||
graph = iD.Graph([way]);
|
||||
expect(c.match(way, graph).id).to.eql('residential');
|
||||
});
|
||||
|
||||
it('returns the appropriate fallback preset when no tags match', function() {
|
||||
var point = iD.Node(),
|
||||
line = iD.Way({tags: {foo: 'bar'}}),
|
||||
line = iD.Way({ tags: { foo: 'bar' } }),
|
||||
graph = iD.Graph([point, line]);
|
||||
|
||||
expect(c.match(point, graph).id).to.eql('point');
|
||||
expect(c.match(line, graph).id).to.eql('line');
|
||||
});
|
||||
|
||||
it('matches vertices on a line as vertices', function() {
|
||||
var point = iD.Node({ tags: { leisure: 'park' } }),
|
||||
line = iD.Way({ nodes: [point.id], tags: { 'highway': 'residential' } }),
|
||||
graph = iD.Graph([point, line]);
|
||||
|
||||
expect(c.match(point, graph).id).to.eql('vertex');
|
||||
});
|
||||
|
||||
it('matches vertices on an addr:interpolation line as points', function() {
|
||||
var point = iD.Node({ tags: { leisure: 'park' } }),
|
||||
line = iD.Way({ nodes: [point.id], tags: { 'addr:interpolation': 'even' } }),
|
||||
graph = iD.Graph([point, line]);
|
||||
|
||||
expect(c.match(point, graph).id).to.eql('park');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#areaKeys', function() {
|
||||
|
||||
Reference in New Issue
Block a user