mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-15 05:30:35 +02:00
Remove unnecessary zoom parameter
This commit is contained in:
@@ -183,7 +183,7 @@ export function rendererMap(context) {
|
||||
if (map.editable() && !transformed) {
|
||||
var hover = d3_event.target.__data__;
|
||||
surface.selectAll('.data-layer-osm')
|
||||
.call(drawVertices.drawHover, context.graph(), hover, map.extent(), map.zoom());
|
||||
.call(drawVertices.drawHover, context.graph(), hover, map.extent());
|
||||
dispatch.call('drawn', this, {full: false});
|
||||
}
|
||||
})
|
||||
@@ -191,7 +191,7 @@ export function rendererMap(context) {
|
||||
if (map.editable() && !transformed) {
|
||||
var hover = d3_event.relatedTarget && d3_event.relatedTarget.__data__;
|
||||
surface.selectAll('.data-layer-osm')
|
||||
.call(drawVertices.drawHover, context.graph(), hover, map.extent(), map.zoom());
|
||||
.call(drawVertices.drawHover, context.graph(), hover, map.extent());
|
||||
dispatch.call('drawn', this, {full: false});
|
||||
}
|
||||
});
|
||||
@@ -207,7 +207,7 @@ export function rendererMap(context) {
|
||||
|
||||
all = context.features().filter(all, graph);
|
||||
surface.selectAll('.data-layer-osm')
|
||||
.call(drawVertices, graph, all, filter, map.extent(), map.zoom())
|
||||
.call(drawVertices, graph, all, filter, map.extent())
|
||||
.call(drawMidpoints, graph, all, filter, map.trimmedExtent());
|
||||
dispatch.call('drawn', this, {full: false});
|
||||
}
|
||||
@@ -297,7 +297,7 @@ export function rendererMap(context) {
|
||||
data = features.filter(data, graph);
|
||||
|
||||
surface.selectAll('.data-layer-osm')
|
||||
.call(drawVertices, graph, data, filter, map.extent(), map.zoom())
|
||||
.call(drawVertices, graph, data, filter, map.extent())
|
||||
.call(drawLines, graph, data, filter)
|
||||
.call(drawAreas, graph, data, filter)
|
||||
.call(drawMidpoints, graph, data, filter, map.trimmedExtent())
|
||||
|
||||
+30
-26
@@ -1,10 +1,16 @@
|
||||
import _values from 'lodash-es/values';
|
||||
|
||||
import { select as d3_select } from 'd3-selection';
|
||||
|
||||
import { dataFeatureIcons } from '../../data';
|
||||
import { osmEntity } from '../osm';
|
||||
import { svgPointTransform } from './index';
|
||||
|
||||
|
||||
var TAU = 2 * Math.PI;
|
||||
function ktoz(k) { return Math.log(k * TAU) / Math.LN2 - 8; }
|
||||
|
||||
|
||||
export function svgVertices(projection, context) {
|
||||
var radiuses = {
|
||||
// z16-, z17, z18+, tagged
|
||||
@@ -55,11 +61,12 @@ export function svgVertices(projection, context) {
|
||||
}
|
||||
|
||||
|
||||
function draw(selection, vertices, klass, graph, zoom, siblings) {
|
||||
function draw(selection, vertices, klass, graph, siblings) {
|
||||
siblings = siblings || {};
|
||||
var icons = {};
|
||||
var directions = {};
|
||||
var wireframe = context.surface().classed('fill-wireframe');
|
||||
var zoom = ktoz(projection.scale());
|
||||
var z = (zoom < 17 ? 0 : zoom < 18 ? 1 : 2);
|
||||
|
||||
|
||||
@@ -95,23 +102,20 @@ export function svgVertices(projection, context) {
|
||||
var rads = radiuses[klass];
|
||||
selection.selectAll('.' + klass)
|
||||
.each(function(entity) {
|
||||
var i = z && getIcon(entity),
|
||||
c = i ? 0.5 : 0,
|
||||
r = rads[i ? 3 : z];
|
||||
var i = z && getIcon(entity);
|
||||
var c = i ? 0.5 : 0;
|
||||
var r = rads[i ? 3 : z];
|
||||
|
||||
// slightly increase the size of unconnected endpoints #3775
|
||||
if (entity.isEndpoint(graph) && !entity.isConnected(graph)) {
|
||||
r += 1.5;
|
||||
}
|
||||
|
||||
this.setAttribute('cx', c);
|
||||
this.setAttribute('cy', -c);
|
||||
this.setAttribute('r', r);
|
||||
if (i && klass === 'fill') {
|
||||
this.setAttribute('visibility', 'hidden');
|
||||
} else {
|
||||
this.removeAttribute('visibility');
|
||||
}
|
||||
d3_select(this)
|
||||
.attr('cx', c)
|
||||
.attr('cy', -c)
|
||||
.attr('r', r)
|
||||
.attr('visibility', ((i && klass === 'fill') ? 'hidden' : null));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -148,8 +152,8 @@ export function svgVertices(projection, context) {
|
||||
.append('use')
|
||||
.attr('transform', 'translate(-5, -6)')
|
||||
.attr('xlink:href', function(d) {
|
||||
var picon = getIcon(d),
|
||||
isMaki = dataFeatureIcons.indexOf(picon) !== -1;
|
||||
var picon = getIcon(d);
|
||||
var isMaki = dataFeatureIcons.indexOf(picon) !== -1;
|
||||
return '#' + picon + (isMaki ? '-11' : '');
|
||||
})
|
||||
.attr('width', '11px')
|
||||
@@ -204,14 +208,14 @@ export function svgVertices(projection, context) {
|
||||
}
|
||||
|
||||
|
||||
function drawVertices(selection, graph, entities, filter, extent, zoom) {
|
||||
var siblings = siblingAndChildVertices(context.selectedIDs(), graph, extent),
|
||||
wireframe = context.surface().classed('fill-wireframe'),
|
||||
vertices = [];
|
||||
function drawVertices(selection, graph, entities, filter, extent) {
|
||||
var siblings = siblingAndChildVertices(context.selectedIDs(), graph, extent);
|
||||
var wireframe = context.surface().classed('fill-wireframe');
|
||||
var vertices = [];
|
||||
|
||||
for (var i = 0; i < entities.length; i++) {
|
||||
var entity = entities[i],
|
||||
geometry = entity.geometry(graph);
|
||||
var entity = entities[i];
|
||||
var geometry = entity.geometry(graph);
|
||||
|
||||
if ((geometry === 'point') && (wireframe || entity.directions(graph, projection).length)) {
|
||||
vertices.push(entity);
|
||||
@@ -232,25 +236,25 @@ export function svgVertices(projection, context) {
|
||||
var layer = selection.selectAll('.layer-hit');
|
||||
layer.selectAll('g.vertex.vertex-persistent')
|
||||
.filter(filter)
|
||||
.call(draw, vertices, 'vertex-persistent', graph, zoom, siblings);
|
||||
.call(draw, vertices, 'vertex-persistent', graph, siblings);
|
||||
|
||||
drawHover(selection, graph, extent, zoom);
|
||||
drawHover(selection, graph, extent);
|
||||
}
|
||||
|
||||
|
||||
function drawHover(selection, graph, extent, zoom) {
|
||||
function drawHover(selection, graph, extent) {
|
||||
var hovered = _hover ? siblingAndChildVertices([_hover.id], graph, extent) : {};
|
||||
var layer = selection.selectAll('.layer-hit');
|
||||
|
||||
layer.selectAll('g.vertex.vertex-hover')
|
||||
.call(draw, _values(hovered), 'vertex-hover', graph, zoom);
|
||||
.call(draw, _values(hovered), 'vertex-hover', graph);
|
||||
}
|
||||
|
||||
|
||||
drawVertices.drawHover = function(selection, graph, target, extent, zoom) {
|
||||
drawVertices.drawHover = function(selection, graph, target, extent) {
|
||||
if (target === _hover) return;
|
||||
_hover = target;
|
||||
drawHover(selection, graph, extent, zoom);
|
||||
drawHover(selection, graph, extent);
|
||||
};
|
||||
|
||||
return drawVertices;
|
||||
|
||||
@@ -115,7 +115,7 @@ export function uiFieldRestrictions(field, context) {
|
||||
|
||||
surface
|
||||
.call(utilSetDimensions, d)
|
||||
.call(drawVertices, graph, [vertex], filter, extent, z)
|
||||
.call(drawVertices, graph, [vertex], filter, extent)
|
||||
.call(drawLines, graph, intersection.ways, filter)
|
||||
.call(drawTurns, graph, intersection.turns(fromNodeID));
|
||||
|
||||
|
||||
+15
-12
@@ -1,9 +1,14 @@
|
||||
describe('iD.svgVertices', function () {
|
||||
var context, surface,
|
||||
projection = d3.geoProjection(function(x, y) { return [x, -y]; })
|
||||
.translate([0, 0])
|
||||
.scale(180 / Math.PI)
|
||||
.clipExtent([[0, 0], [Infinity, Infinity]]);
|
||||
var TAU = 2 * Math.PI;
|
||||
function ztok(z) { return 256 * Math.pow(2, z) / TAU; }
|
||||
|
||||
var context;
|
||||
var surface;
|
||||
var projection = d3.geoProjection(function(x, y) { return [x, -y]; })
|
||||
.translate([0, 0])
|
||||
.scale(ztok(17))
|
||||
.clipExtent([[0, 0], [Infinity, Infinity]]);
|
||||
|
||||
|
||||
beforeEach(function () {
|
||||
context = iD.Context();
|
||||
@@ -15,14 +20,12 @@ describe('iD.svgVertices', function () {
|
||||
|
||||
|
||||
it('adds the .shared class to vertices that are members of two or more ways', function () {
|
||||
var zoom = 17,
|
||||
node = iD.Node({loc: [0, 0]}),
|
||||
way1 = iD.Way({nodes: [node.id], tags: {highway: 'residential'}}),
|
||||
way2 = iD.Way({nodes: [node.id], tags: {highway: 'residential'}}),
|
||||
graph = iD.Graph([node, way1, way2]);
|
||||
|
||||
surface.call(iD.svgVertices(projection, context), graph, [node], zoom);
|
||||
var node = iD.Node({loc: [0, 0]});
|
||||
var way1 = iD.Way({nodes: [node.id], tags: {highway: 'residential'}});
|
||||
var way2 = iD.Way({nodes: [node.id], tags: {highway: 'residential'}});
|
||||
var graph = iD.Graph([node, way1, way2]);
|
||||
|
||||
surface.call(iD.svgVertices(projection, context), graph, [node]);
|
||||
expect(surface.select('.vertex').classed('shared')).to.be.true;
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user