Fix vertices areas midlines

This commit is contained in:
Tom MacWright
2016-09-06 10:58:07 -04:00
parent 4fcbcddc5b
commit 20962074ba
9 changed files with 57 additions and 31 deletions
+4 -1
View File
@@ -17,6 +17,10 @@ import * as services from '../services/index';
export var areaKeys = {};
export function setAreaKeys(value) {
areaKeys = value;
}
export function Context(root) {
if (!root.locale) {
root.locale = {
@@ -403,4 +407,3 @@ export function Context(root) {
return rebind(context, dispatch, 'on');
}
+1 -1
View File
@@ -16,7 +16,7 @@ export { Detect } from './util/detect';
// core
export { Connection } from './core/connection';
export { Context } from './core/context';
export { Context, setAreaKeys } from './core/context';
export { Difference } from './core/difference';
export { Entity } from './core/entity';
export { Graph } from './core/graph';
-1
View File
@@ -92,7 +92,6 @@ export function Areas(projection) {
var areagroup = surface
.selectAll('.layer-areas')
.selectAll('g.areagroup')
.data(['fill', 'shadow', 'stroke']);
+17 -11
View File
@@ -56,8 +56,15 @@ export function Lines(projection) {
.valueOf();
});
var layergroup = surface
var layer = surface
.selectAll('.layer-lines')
.data([0])
layer = layer.enter()
.append('g').attr('class', 'layer-lines')
.merge(layer);
var layergroup = layer
.selectAll('g.layergroup')
.data(d3.range(-10, 11));
@@ -106,9 +113,10 @@ export function Lines(projection) {
.selectAll('g.onewaygroup')
.data(['oneway']);
onewaygroup.enter()
onewaygroup = onewaygroup.enter()
.append('g')
.attr('class', 'layer onewaygroup');
.attr('class', 'layer onewaygroup')
.merge(onewaygroup);
var oneways = onewaygroup
@@ -119,20 +127,18 @@ export function Lines(projection) {
function(d) { return [d.id, d.index]; }
);
oneways.enter()
oneways.exit()
.remove();
oneways = oneways.enter()
.append('path')
.attr('class', 'oneway')
.attr('marker-mid', 'url(#oneway-marker)');
oneways
.attr('marker-mid', 'url(#oneway-marker)')
.merge(oneways)
.attr('d', function(d) { return d.d; });
if (Detect().ie) {
oneways.each(function() { this.parentNode.insertBefore(this, this); });
}
oneways.exit()
.remove();
};
}
+8 -1
View File
@@ -71,7 +71,14 @@ export function Midpoints(projection, context) {
return false;
}
var groups = surface.selectAll('.layer-hit').selectAll('g.midpoint')
var layer = surface.selectAll('.layer-hit')
.data([0]);
layer = layer.enter().append('g').attr('class', 'layer-hit')
.merge(layer);
var groups = layer
.selectAll('g.midpoint')
.filter(midpointFilter)
.data(_.values(midpoints), function(d) { return d.id; });
+7 -1
View File
@@ -125,6 +125,7 @@ export function Vertices(projection, context) {
.each(setClass('fill'));
groups
.merge(enter)
.attr('transform', PointTransform(projection))
.classed('shared', function(entity) { return graph.isShared(entity); })
.call(setAttributes);
@@ -157,7 +158,12 @@ export function Vertices(projection, context) {
}
}
surface.selectAll('.layer-hit').selectAll('g.vertex.vertex-persistent')
var layer = surface.selectAll('.layer-hit')
.data([0]);
layer = layer.enter().append('g').attr('class', 'layer-hit')
.merge(layer);
layer.selectAll('g.vertex.vertex-persistent')
.filter(filter)
.call(draw, vertices, 'vertex-persistent', graph, zoom);
+9 -4
View File
@@ -8,6 +8,11 @@ describe('iD.svg.Areas', function () {
beforeEach(function () {
surface = d3.select(document.createElementNS('http://www.w3.org/2000/svg', 'svg'))
.call(iD.svg.Layers(projection, iD.Context(window)));
iD.setAreaKeys({
building: {},
landuse: {},
natural: {}
});
});
it('adds way and area classes', function () {
@@ -127,7 +132,7 @@ describe('iD.svg.Areas', function () {
surface.call(iD.svg.Areas(projection), graph, areas, none);
expect(surface.selectAll('.stroke')[0].length).to.equal(0);
expect(surface.selectAll('.stroke').size()).to.equal(0);
});
it('renders fill for a multipolygon with tags on the outer way', function() {
@@ -140,8 +145,8 @@ describe('iD.svg.Areas', function () {
surface.call(iD.svg.Areas(projection), graph, [w, r], none);
expect(surface.selectAll('.way.fill')[0].length).to.equal(0);
expect(surface.selectAll('.relation.fill')[0].length).to.equal(1);
expect(surface.selectAll('.way.fill').size()).to.equal(0);
expect(surface.selectAll('.relation.fill').size()).to.equal(1);
expect(surface.select('.relation.fill')).to.be.classed('tag-natural-wood');
});
@@ -155,6 +160,6 @@ describe('iD.svg.Areas', function () {
surface.call(iD.svg.Areas(projection), graph, [w, r], none);
expect(surface.selectAll('.stroke')[0].length).to.equal(0);
expect(surface.selectAll('.stroke').size()).to.equal(0);
});
});
+8 -8
View File
@@ -87,16 +87,16 @@ describe('iD.svg.Lines', function () {
surface.call(iD.svg.Lines(projection), graph, [graph.entity('lo'), graph.entity('hi')], none);
var selection = surface.selectAll('g.line-stroke > path.line');
expect(selection[0][0].__data__.id).to.eql('lo');
expect(selection[0][1].__data__.id).to.eql('hi');
expect(selection.nodes()[0].__data__.id).to.eql('lo');
expect(selection.nodes()[1].__data__.id).to.eql('hi');
});
it('stacks higher lines above lower ones in a single render (reverse)', function () {
surface.call(iD.svg.Lines(projection), graph, [graph.entity('hi'), graph.entity('lo')], none);
var selection = surface.selectAll('g.line-stroke > path.line');
expect(selection[0][0].__data__.id).to.eql('lo');
expect(selection[0][1].__data__.id).to.eql('hi');
expect(selection.nodes()[0].__data__.id).to.eql('lo');
expect(selection.nodes()[1].__data__.id).to.eql('hi');
});
it('stacks higher lines above lower ones in separate renders', function () {
@@ -104,8 +104,8 @@ describe('iD.svg.Lines', function () {
surface.call(iD.svg.Lines(projection), graph, [graph.entity('hi')], none);
var selection = surface.selectAll('g.line-stroke > path.line');
expect(selection[0][0].__data__.id).to.eql('lo');
expect(selection[0][1].__data__.id).to.eql('hi');
expect(selection.nodes()[0].__data__.id).to.eql('lo');
expect(selection.nodes()[1].__data__.id).to.eql('hi');
});
it('stacks higher lines above lower in separate renders (reverse)', function () {
@@ -113,8 +113,8 @@ describe('iD.svg.Lines', function () {
surface.call(iD.svg.Lines(projection), graph, [graph.entity('lo')], none);
var selection = surface.selectAll('g.line-stroke > path.line');
expect(selection[0][0].__data__.id).to.eql('lo');
expect(selection[0][1].__data__.id).to.eql('hi');
expect(selection.nodes()[0].__data__.id).to.eql('lo');
expect(selection.nodes()[1].__data__.id).to.eql('hi');
});
});
+3 -3
View File
@@ -34,7 +34,7 @@ describe('iD.svg.Midpoints', function () {
context.selectedIDs = function() { return [line.id]; };
surface.call(iD.svg.Midpoints(projection, context), graph, [line], filter, extent);
expect(surface.selectAll('.midpoint')[0]).to.have.length(0);
expect(surface.selectAll('.midpoint').nodes()).to.have.length(0);
});
it('doesn\'t create midpoint on segment completely outside of the extent', function () {
@@ -47,7 +47,7 @@ describe('iD.svg.Midpoints', function () {
context.selectedIDs = function() { return [line.id]; };
surface.call(iD.svg.Midpoints(projection, context), graph, [line], filter, extent);
expect(surface.selectAll('.midpoint')[0]).to.have.length(0);
expect(surface.selectAll('.midpoint').nodes()).to.have.length(0);
});
it('creates midpoint on extent edge for segment partially outside of the extent', function () {
@@ -74,7 +74,7 @@ describe('iD.svg.Midpoints', function () {
context.selectedIDs = function() { return [line.id]; };
surface.call(iD.svg.Midpoints(projection, context), graph, [line], filter, extent);
expect(surface.selectAll('.midpoint')[0]).to.have.length(0);
expect(surface.selectAll('.midpoint').nodes()).to.have.length(0);
});
});