mirror of
https://github.com/FoggedLens/iD.git
synced 2026-06-05 14:38:05 +02:00
Migrating to lodash v4
This commit is contained in:
@@ -19,7 +19,7 @@ iD.actions.DeleteRelation = function(relationId) {
|
||||
}
|
||||
});
|
||||
|
||||
_.uniq(_.pluck(relation.members, 'id')).forEach(function(memberId) {
|
||||
_.uniq(_.map(relation.members, 'id')).forEach(function(memberId) {
|
||||
graph = graph.replace(relation.removeMembersWithID(memberId));
|
||||
|
||||
var entity = graph.entity(memberId);
|
||||
|
||||
@@ -9,8 +9,8 @@ iD.actions.DeprecateTags = function(entityId) {
|
||||
for (var i = 0; i < iD.data.deprecated.length; i++) {
|
||||
|
||||
rule = iD.data.deprecated[i];
|
||||
var match = _.pairs(rule.old)[0],
|
||||
replacements = rule.replace ? _.pairs(rule.replace) : null;
|
||||
var match = _.toPairs(rule.old)[0],
|
||||
replacements = rule.replace ? _.toPairs(rule.replace) : null;
|
||||
|
||||
if (entity.tags[match[0]] && match[1] === '*') {
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ iD.actions.Join = function(ids) {
|
||||
|
||||
var joined = iD.geo.joinWays(ways, graph)[0];
|
||||
|
||||
survivor = survivor.update({nodes: _.pluck(joined.nodes, 'id')});
|
||||
survivor = survivor.update({nodes: _.map(joined.nodes, 'id')});
|
||||
graph = graph.replace(survivor);
|
||||
|
||||
joined.forEach(function(way) {
|
||||
@@ -56,7 +56,7 @@ iD.actions.Join = function(ids) {
|
||||
if (joined.length > 1)
|
||||
return 'not_adjacent';
|
||||
|
||||
var nodeIds = _.pluck(joined[0].nodes, 'id').slice(1, -1),
|
||||
var nodeIds = _.map(joined[0].nodes, 'id').slice(1, -1),
|
||||
relation,
|
||||
tags = {},
|
||||
conflicting = false;
|
||||
|
||||
@@ -39,8 +39,8 @@ iD.actions.MergePolygon = function(ids, newRelationId) {
|
||||
return polygons.map(function(d, n) {
|
||||
if (i === n) return null;
|
||||
return iD.geo.polygonContainsPolygon(
|
||||
_.pluck(d.nodes, 'loc'),
|
||||
_.pluck(w.nodes, 'loc'));
|
||||
_.map(d.nodes, 'loc'),
|
||||
_.map(w.nodes, 'loc'));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -55,7 +55,7 @@ iD.actions.MergePolygon = function(ids, newRelationId) {
|
||||
}
|
||||
|
||||
function isContained(d, i) {
|
||||
return _.any(contained[i]);
|
||||
return _.some(contained[i]);
|
||||
}
|
||||
|
||||
function filterContained(d) {
|
||||
|
||||
@@ -65,7 +65,7 @@ iD.actions.MergeRemoteChanges = function(id, localGraph, remoteGraph, formatUser
|
||||
|
||||
function mergeChildren(targetWay, children, updates, graph) {
|
||||
function isUsed(node, targetWay) {
|
||||
var parentWays = _.pluck(graph.parentWays(node), 'id');
|
||||
var parentWays = _.map(graph.parentWays(node), 'id');
|
||||
return node.hasInterestingTags() ||
|
||||
_.without(parentWays, targetWay.id).length > 0 ||
|
||||
graph.parentRelations(node).length > 0;
|
||||
@@ -143,7 +143,7 @@ iD.actions.MergeRemoteChanges = function(id, localGraph, remoteGraph, formatUser
|
||||
|
||||
function mergeTags(base, remote, target) {
|
||||
function ignoreKey(k) {
|
||||
return _.contains(iD.data.discarded, k);
|
||||
return _.includes(iD.data.discarded, k);
|
||||
}
|
||||
|
||||
if (option === 'force_local' || _.isEqual(target.tags, remote.tags)) {
|
||||
|
||||
@@ -8,7 +8,7 @@ iD.actions.Move = function(moveIds, tryDelta, projection, cache) {
|
||||
|
||||
function setupCache(graph) {
|
||||
function canMove(nodeId) {
|
||||
var parents = _.pluck(graph.parentWays(graph.entity(nodeId)), 'id');
|
||||
var parents = _.map(graph.parentWays(graph.entity(nodeId)), 'id');
|
||||
if (parents.length < 3) return true;
|
||||
|
||||
// Don't move a vertex where >2 ways meet, unless all parentWays are moving too..
|
||||
@@ -33,7 +33,7 @@ iD.actions.Move = function(moveIds, tryDelta, projection, cache) {
|
||||
cache.ways.push(id);
|
||||
cacheEntities(entity.nodes);
|
||||
} else {
|
||||
cacheEntities(_.pluck(entity.members, 'id'));
|
||||
cacheEntities(_.map(entity.members, 'id'));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -223,10 +223,10 @@ iD.actions.Move = function(moveIds, tryDelta, projection, cache) {
|
||||
start = projection(node.loc),
|
||||
end = vecAdd(start, delta),
|
||||
movedNodes = graph.childNodes(graph.entity(obj.movedId)),
|
||||
movedPath = _.map(_.pluck(movedNodes, 'loc'),
|
||||
movedPath = _.map(_.map(movedNodes, 'loc'),
|
||||
function(loc) { return vecAdd(projection(loc), delta); }),
|
||||
unmovedNodes = graph.childNodes(graph.entity(obj.unmovedId)),
|
||||
unmovedPath = _.map(_.pluck(unmovedNodes, 'loc'), projection),
|
||||
unmovedPath = _.map(_.map(unmovedNodes, 'loc'), projection),
|
||||
hits = iD.geo.pathIntersections(movedPath, unmovedPath);
|
||||
|
||||
for (var i = 0; i < hits.length; i++) {
|
||||
@@ -267,7 +267,7 @@ iD.actions.Move = function(moveIds, tryDelta, projection, cache) {
|
||||
return entity.type === 'relation' && !entity.isComplete(graph);
|
||||
}
|
||||
|
||||
if (_.any(moveIds, incompleteRelation))
|
||||
if (_.some(moveIds, incompleteRelation))
|
||||
return 'incomplete_relation';
|
||||
};
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ iD.actions.RotateWay = function(wayId, pivot, angle, projection) {
|
||||
return graph.update(function(graph) {
|
||||
var way = graph.entity(wayId);
|
||||
|
||||
_.unique(way.nodes).forEach(function(id) {
|
||||
_.uniq(way.nodes).forEach(function(id) {
|
||||
|
||||
var node = graph.entity(id),
|
||||
point = projection(node.loc),
|
||||
|
||||
@@ -148,7 +148,7 @@ iD.actions.Split = function(nodeId, newWayIds) {
|
||||
action.ways = function(graph) {
|
||||
var node = graph.entity(nodeId),
|
||||
parents = graph.parentWays(node),
|
||||
hasLines = _.any(parents, function(parent) { return parent.geometry(graph) === 'line'; });
|
||||
hasLines = _.some(parents, function(parent) { return parent.geometry(graph) === 'line'; });
|
||||
|
||||
return parents.filter(function(parent) {
|
||||
if (wayIds && wayIds.indexOf(parent.id) === -1)
|
||||
|
||||
@@ -14,7 +14,7 @@ iD.behavior.Copy = function(context) {
|
||||
descendants = descendants || {};
|
||||
|
||||
if (entity.type === 'relation') {
|
||||
children = _.pluck(entity.members, 'id');
|
||||
children = _.map(entity.members, 'id');
|
||||
} else if (entity.type === 'way') {
|
||||
children = entity.nodes;
|
||||
} else {
|
||||
|
||||
@@ -38,7 +38,7 @@ iD.behavior.Lasso = function(context) {
|
||||
bounds = lasso.extent().map(context.projection.invert),
|
||||
extent = iD.geo.Extent(normalize(bounds[0], bounds[1]));
|
||||
|
||||
return _.pluck(context.intersects(extent).filter(function(entity) {
|
||||
return _.map(context.intersects(extent).filter(function(entity) {
|
||||
return entity.type === 'node' &&
|
||||
iD.geo.pointInPolygon(context.projection(entity.loc), lasso.coordinates) &&
|
||||
!context.features().isHidden(entity, graph, entity.geometry(graph));
|
||||
|
||||
@@ -128,11 +128,11 @@ iD.Entity.prototype = {
|
||||
},
|
||||
|
||||
deprecatedTags: function() {
|
||||
var tags = _.pairs(this.tags);
|
||||
var tags = _.toPairs(this.tags);
|
||||
var deprecated = {};
|
||||
|
||||
iD.data.deprecated.forEach(function(d) {
|
||||
var match = _.pairs(d.old)[0];
|
||||
var match = _.toPairs(d.old)[0];
|
||||
tags.forEach(function(t) {
|
||||
if (t[0] === match[0] &&
|
||||
(t[1] === match[1] || match[1] === '*')) {
|
||||
|
||||
+2
-2
@@ -150,7 +150,7 @@ iD.Graph.prototype = {
|
||||
if (base.parentWays[child]) {
|
||||
for (k = 0; k < base.parentWays[child].length; k++) {
|
||||
id = base.parentWays[child][k];
|
||||
if (!this.entities.hasOwnProperty(id) && !_.contains(this._parentWays[child], id)) {
|
||||
if (!this.entities.hasOwnProperty(id) && !_.includes(this._parentWays[child], id)) {
|
||||
this._parentWays[child].push(id);
|
||||
}
|
||||
}
|
||||
@@ -163,7 +163,7 @@ iD.Graph.prototype = {
|
||||
if (base.parentRels[child]) {
|
||||
for (k = 0; k < base.parentRels[child].length; k++) {
|
||||
id = base.parentRels[child][k];
|
||||
if (!this.entities.hasOwnProperty(id) && !_.contains(this._parentRels[child], id)) {
|
||||
if (!this.entities.hasOwnProperty(id) && !_.includes(this._parentRels[child], id)) {
|
||||
this._parentRels[child].push(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ iD.History = function(context) {
|
||||
},
|
||||
|
||||
merge: function(entities, extent) {
|
||||
stack[0].graph.rebase(entities, _.pluck(stack, 'graph'), false);
|
||||
stack[0].graph.rebase(entities, _.map(stack, 'graph'), false);
|
||||
tree.rebase(entities, false);
|
||||
|
||||
dispatch.change(undefined, extent);
|
||||
@@ -181,9 +181,9 @@ iD.History = function(context) {
|
||||
return history;
|
||||
} else {
|
||||
return _(stack.slice(1, index + 1))
|
||||
.pluck('imageryUsed')
|
||||
.map('imageryUsed')
|
||||
.flatten()
|
||||
.unique()
|
||||
.uniq()
|
||||
.without(undefined, 'Custom')
|
||||
.value();
|
||||
}
|
||||
@@ -268,15 +268,15 @@ iD.History = function(context) {
|
||||
// the stack even if the current stack doesn't have them (for
|
||||
// example when iD has been restarted in a different region)
|
||||
var baseEntities = h.baseEntities.map(function(d) { return iD.Entity(d); });
|
||||
stack[0].graph.rebase(baseEntities, _.pluck(stack, 'graph'), true);
|
||||
stack[0].graph.rebase(baseEntities, _.map(stack, 'graph'), true);
|
||||
tree.rebase(baseEntities, true);
|
||||
|
||||
// When we restore a modified way, we also need to fetch any missing
|
||||
// childnodes that would normally have been downloaded with it.. #2142
|
||||
if (loadChildNodes) {
|
||||
var missing = _(baseEntities)
|
||||
.filter('type', 'way')
|
||||
.pluck('nodes')
|
||||
.filter({ type: 'way' })
|
||||
.map('nodes')
|
||||
.flatten()
|
||||
.uniq()
|
||||
.reject(function(n) { return stack[0].graph.hasEntity(n); })
|
||||
@@ -293,8 +293,8 @@ iD.History = function(context) {
|
||||
if (!err) {
|
||||
var visible = _.groupBy(result.data, 'visible');
|
||||
if (!_.isEmpty(visible.true)) {
|
||||
missing = _.difference(missing, _.pluck(visible.true, 'id'));
|
||||
stack[0].graph.rebase(visible.true, _.pluck(stack, 'graph'), true);
|
||||
missing = _.difference(missing, _.map(visible.true, 'id'));
|
||||
stack[0].graph.rebase(visible.true, _.map(stack, 'graph'), true);
|
||||
tree.rebase(visible.true, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -224,8 +224,8 @@ _.extend(iD.Relation.prototype, {
|
||||
outers = iD.geo.joinWays(outers, resolver);
|
||||
inners = iD.geo.joinWays(inners, resolver);
|
||||
|
||||
outers = outers.map(function(outer) { return _.pluck(outer.nodes, 'loc'); });
|
||||
inners = inners.map(function(inner) { return _.pluck(inner.nodes, 'loc'); });
|
||||
outers = outers.map(function(outer) { return _.map(outer.nodes, 'loc'); });
|
||||
inners = inners.map(function(inner) { return _.map(inner.nodes, 'loc'); });
|
||||
|
||||
var result = outers.map(function(o) {
|
||||
// Heuristic for detecting counterclockwise winding order. Assumes
|
||||
|
||||
+3
-3
@@ -102,7 +102,7 @@ _.extend(iD.Way.prototype, {
|
||||
if (!this.isClosed() || this.isDegenerate()) return null;
|
||||
|
||||
var nodes = _.uniq(resolver.childNodes(this)),
|
||||
coords = _.pluck(nodes, 'loc'),
|
||||
coords = _.map(nodes, 'loc'),
|
||||
curr = 0, prev = 0;
|
||||
|
||||
for (var i = 0; i < coords.length; i++) {
|
||||
@@ -215,7 +215,7 @@ _.extend(iD.Way.prototype, {
|
||||
|
||||
asGeoJSON: function(resolver) {
|
||||
return resolver.transient(this, 'GeoJSON', function() {
|
||||
var coordinates = _.pluck(resolver.childNodes(this), 'loc');
|
||||
var coordinates = _.map(resolver.childNodes(this), 'loc');
|
||||
if (this.isArea() && this.isClosed()) {
|
||||
return {
|
||||
type: 'Polygon',
|
||||
@@ -236,7 +236,7 @@ _.extend(iD.Way.prototype, {
|
||||
|
||||
var json = {
|
||||
type: 'Polygon',
|
||||
coordinates: [_.pluck(nodes, 'loc')]
|
||||
coordinates: [_.map(nodes, 'loc')]
|
||||
};
|
||||
|
||||
if (!this.isClosed() && nodes.length) {
|
||||
|
||||
@@ -68,7 +68,7 @@ iD.modes.DragNode = function(context) {
|
||||
iD.actions.Noop());
|
||||
}
|
||||
|
||||
activeIDs = _.pluck(context.graph().parentWays(entity), 'id');
|
||||
activeIDs = _.map(context.graph().parentWays(entity), 'id');
|
||||
activeIDs.push(entity.id);
|
||||
|
||||
context.enter(mode);
|
||||
|
||||
+3
-3
@@ -14,7 +14,7 @@ iD.modes.Save = function(context) {
|
||||
if (e.type === 'way') {
|
||||
try {
|
||||
var cn = graph.childNodes(e);
|
||||
result.push.apply(result, _.pluck(_.filter(cn, 'version'), 'id'));
|
||||
result.push.apply(result, _.map(_.filter(cn, 'version'), 'id'));
|
||||
} catch(err) {
|
||||
/* eslint-disable no-console */
|
||||
if (typeof console !== 'undefined') console.error(err);
|
||||
@@ -31,7 +31,7 @@ iD.modes.Save = function(context) {
|
||||
localGraph = context.graph(),
|
||||
remoteGraph = iD.Graph(history.base(), true),
|
||||
modified = _.filter(history.difference().summary(), {changeType: 'modified'}),
|
||||
toCheck = _.pluck(_.pluck(modified, 'entity'), 'id'),
|
||||
toCheck = _.map(_.map(modified, 'entity'), 'id'),
|
||||
toLoad = withChildNodes(toCheck, localGraph),
|
||||
conflicts = [],
|
||||
errors = [];
|
||||
@@ -71,7 +71,7 @@ iD.modes.Save = function(context) {
|
||||
_.difference(entity.nodes, toCheck, toLoad, loadMore));
|
||||
} else if (entity.type === 'relation' && entity.isMultipolygon()) {
|
||||
loadMore.push.apply(loadMore,
|
||||
_.difference(_.pluck(entity.members, 'id'), toCheck, toLoad, loadMore));
|
||||
_.difference(_.map(entity.members, 'id'), toCheck, toLoad, loadMore));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ iD.modes.Select = function(context, selectedIDs) {
|
||||
mode.enter = function() {
|
||||
function update() {
|
||||
closeMenu();
|
||||
if (_.any(selectedIDs, function(id) { return !context.hasEntity(id); })) {
|
||||
if (_.some(selectedIDs, function(id) { return !context.hasEntity(id); })) {
|
||||
// Exit mode if selected entity gets undone
|
||||
context.enter(iD.modes.Browse(context));
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ iD.operations.Delete = function(selectedIDs, context) {
|
||||
|
||||
operation.disabled = function() {
|
||||
var reason;
|
||||
if (_.any(selectedIDs, context.hasHiddenConnections)) {
|
||||
if (_.some(selectedIDs, context.hasHiddenConnections)) {
|
||||
reason = 'connected_to_hidden';
|
||||
}
|
||||
return action.disabled(context.graph()) || reason;
|
||||
|
||||
@@ -20,7 +20,7 @@ iD.operations.Disconnect = function(selectedIDs, context) {
|
||||
|
||||
operation.disabled = function() {
|
||||
var reason;
|
||||
if (_.any(selectedIDs, context.hasHiddenConnections)) {
|
||||
if (_.some(selectedIDs, context.hasHiddenConnections)) {
|
||||
reason = 'connected_to_hidden';
|
||||
}
|
||||
return action.disabled(context.graph()) || reason;
|
||||
|
||||
@@ -16,7 +16,7 @@ iD.operations.Move = function(selectedIDs, context) {
|
||||
var reason;
|
||||
if (extent.area() && extent.percentContainedIn(context.extent()) < 0.8) {
|
||||
reason = 'too_large';
|
||||
} else if (_.any(selectedIDs, context.hasHiddenConnections)) {
|
||||
} else if (_.some(selectedIDs, context.hasHiddenConnections)) {
|
||||
reason = 'connected_to_hidden';
|
||||
}
|
||||
return iD.actions.Move(selectedIDs).disabled(context.graph()) || reason;
|
||||
|
||||
@@ -30,7 +30,7 @@ iD.operations.Split = function(selectedIDs, context) {
|
||||
|
||||
operation.disabled = function() {
|
||||
var reason;
|
||||
if (_.any(selectedIDs, context.hasHiddenConnections)) {
|
||||
if (_.some(selectedIDs, context.hasHiddenConnections)) {
|
||||
reason = 'connected_to_hidden';
|
||||
}
|
||||
return action.disabled(context.graph()) || reason;
|
||||
|
||||
+2
-2
@@ -142,12 +142,12 @@ iD.presets = function() {
|
||||
all.defaults = function(geometry, n) {
|
||||
var rec = recent.matchGeometry(geometry).collection.slice(0, 4),
|
||||
def = _.uniq(rec.concat(defaults[geometry].collection)).slice(0, n - 1);
|
||||
return iD.presets.Collection(_.unique(rec.concat(def).concat(all.item(geometry))));
|
||||
return iD.presets.Collection(_.uniq(rec.concat(def).concat(all.item(geometry))));
|
||||
};
|
||||
|
||||
all.choose = function(preset) {
|
||||
if (!preset.isFallback()) {
|
||||
recent = iD.presets.Collection(_.unique([preset].concat(recent.collection)));
|
||||
recent = iD.presets.Collection(_.uniq([preset].concat(recent.collection)));
|
||||
}
|
||||
return all;
|
||||
};
|
||||
|
||||
@@ -47,12 +47,12 @@ iD.presets.Collection = function(collection) {
|
||||
|
||||
// matches value to preset.terms values
|
||||
var leading_terms = _.filter(searchable, function(a) {
|
||||
return _.any(a.terms() || [], leading);
|
||||
return _.some(a.terms() || [], leading);
|
||||
});
|
||||
|
||||
// matches value to preset.tags values
|
||||
var leading_tag_values = _.filter(searchable, function(a) {
|
||||
return _.any(_.without(_.values(a.tags || {}), '*'), leading);
|
||||
return _.some(_.without(_.values(a.tags || {}), '*'), leading);
|
||||
});
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ iD.presets.Collection = function(collection) {
|
||||
|
||||
// finds close matches to value in preset.terms
|
||||
var leventstein_terms = _.filter(searchable, function(a) {
|
||||
return _.any(a.terms() || [], function(b) {
|
||||
return _.some(a.terms() || [], function(b) {
|
||||
return iD.util.editDistance(value, b) + Math.min(value.length - b.length, 0) < 3;
|
||||
});
|
||||
});
|
||||
@@ -119,7 +119,7 @@ iD.presets.Collection = function(collection) {
|
||||
leven_suggestions.slice(0, maxSuggestionResults)
|
||||
).slice(0, maxSearchResults-1);
|
||||
|
||||
return iD.presets.Collection(_.unique(
|
||||
return iD.presets.Collection(_.uniq(
|
||||
results.concat(other)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ iD.BackgroundSource.Bing = function(data, dispatch) {
|
||||
bing.copyrightNotices = function(zoom, extent) {
|
||||
zoom = Math.min(zoom, 21);
|
||||
return providers.filter(function(provider) {
|
||||
return _.any(provider.areas, function(area) {
|
||||
return _.some(provider.areas, function(area) {
|
||||
return extent.intersects(area.extent) &&
|
||||
area.zoom[0] <= zoom &&
|
||||
area.zoom[1] >= zoom;
|
||||
|
||||
@@ -390,7 +390,7 @@ iD.Features = function(context) {
|
||||
return resolver.isShared(e) ? _.union(result, resolver.parentWays(e)) : result;
|
||||
}, connections);
|
||||
|
||||
return connections.length ? _.any(connections, function(e) {
|
||||
return connections.length ? _.some(connections, function(e) {
|
||||
return features.isHidden(e, resolver, e.geometry(resolver));
|
||||
}) : false;
|
||||
};
|
||||
|
||||
@@ -131,7 +131,7 @@ iD.Map = function(context) {
|
||||
|
||||
if (extent) {
|
||||
data = context.intersects(map.extent().intersection(extent));
|
||||
var set = d3.set(_.pluck(data, 'id'));
|
||||
var set = d3.set(_.map(data, 'id'));
|
||||
filter = function(d) { return set.has(d.id); };
|
||||
|
||||
} else {
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ iD.svg.Areas = function(projection) {
|
||||
|
||||
areas = d3.values(areas).filter(function hasPath(a) { return path(a.entity); });
|
||||
areas.sort(function areaSort(a, b) { return b.area - a.area; });
|
||||
areas = _.pluck(areas, 'entity');
|
||||
areas = _.map(areas, 'entity');
|
||||
|
||||
var strokes = areas.filter(function(area) {
|
||||
return area.type === 'way';
|
||||
|
||||
+3
-3
@@ -58,7 +58,7 @@ iD.svg.Labels = function(projection, context) {
|
||||
|
||||
var noIcons = ['building', 'landuse', 'natural'];
|
||||
function blacklisted(preset) {
|
||||
return _.any(noIcons, function(s) {
|
||||
return _.some(noIcons, function(s) {
|
||||
return preset.id.indexOf(s) >= 0;
|
||||
});
|
||||
}
|
||||
@@ -237,7 +237,7 @@ iD.svg.Labels = function(projection, context) {
|
||||
var mouse = context.mouse(),
|
||||
pad = 50,
|
||||
rect = [mouse[0] - pad, mouse[1] - pad, mouse[0] + pad, mouse[1] + pad],
|
||||
ids = _.pluck(rtree.search(rect), 'id');
|
||||
ids = _.map(rtree.search(rect), 'id');
|
||||
|
||||
if (!ids.length) return;
|
||||
layers.selectAll('.' + ids.join(', .'))
|
||||
@@ -338,7 +338,7 @@ iD.svg.Labels = function(projection, context) {
|
||||
|
||||
|
||||
function getLineLabel(entity, width, height) {
|
||||
var nodes = _.pluck(graph.childNodes(entity), 'loc').map(projection),
|
||||
var nodes = _.map(graph.childNodes(entity), 'loc').map(projection),
|
||||
length = iD.geo.pathLength(nodes);
|
||||
if (length < width + 20) return;
|
||||
|
||||
|
||||
+3
-3
@@ -37,20 +37,20 @@ iD.svg.Layers = function(projection, context) {
|
||||
};
|
||||
|
||||
drawLayers.layer = function(id) {
|
||||
var obj = _.find(layers, 'id', id);
|
||||
var obj = _.find(layers, function(o) {return o.id === id;});
|
||||
return obj && obj.layer;
|
||||
};
|
||||
|
||||
drawLayers.only = function(what) {
|
||||
var arr = [].concat(what);
|
||||
drawLayers.remove(_.difference(_.pluck(layers, 'id'), arr));
|
||||
drawLayers.remove(_.difference(_.map(layers, 'id'), arr));
|
||||
return this;
|
||||
};
|
||||
|
||||
drawLayers.remove = function(what) {
|
||||
var arr = [].concat(what);
|
||||
arr.forEach(function(id) {
|
||||
layers = _.reject(layers, 'id', id);
|
||||
layers = _.reject(layers, function(o) {return o.id === id;});
|
||||
});
|
||||
dispatch.change();
|
||||
return this;
|
||||
|
||||
@@ -145,11 +145,11 @@ iD.ui.EntityEditor = function(context) {
|
||||
function keepSpaces(k) {
|
||||
var whitelist = ['opening_hours', 'service_times', 'collection_times',
|
||||
'operating_times', 'smoking_hours', 'happy_hours'];
|
||||
return _.any(whitelist, function(s) { return k.indexOf(s) !== -1; });
|
||||
return _.some(whitelist, function(s) { return k.indexOf(s) !== -1; });
|
||||
}
|
||||
|
||||
var blacklist = ['description', 'note', 'fixme'];
|
||||
if (_.any(blacklist, function(s) { return k.indexOf(s) !== -1; })) return v;
|
||||
if (_.some(blacklist, function(s) { return k.indexOf(s) !== -1; })) return v;
|
||||
|
||||
var cleaned = v.split(';')
|
||||
.map(function(s) { return s.trim(); })
|
||||
|
||||
@@ -75,7 +75,7 @@ iD.ui.intro.line = function(context, reveal) {
|
||||
}
|
||||
|
||||
function addIntersection(changes) {
|
||||
if ( _.any(changes.created(), function(d) {
|
||||
if ( _.some(changes.created(), function(d) {
|
||||
return d.type === 'node' && context.graph().parentWays(d).length > 1;
|
||||
})) {
|
||||
context.history().on('change.intro', null);
|
||||
|
||||
+3
-3
@@ -19,12 +19,12 @@ iD.ui.preset = function(context) {
|
||||
field.show = show;
|
||||
|
||||
field.shown = function() {
|
||||
return field.id === 'name' || field.show || _.any(field.keys, function(key) { return !!tags[key]; });
|
||||
return field.id === 'name' || field.show || _.some(field.keys, function(key) { return !!tags[key]; });
|
||||
};
|
||||
|
||||
field.modified = function() {
|
||||
var original = context.graph().base().entities[entity.id];
|
||||
return _.any(field.keys, function(key) {
|
||||
return _.some(field.keys, function(key) {
|
||||
return original ? tags[key] !== original.tags[key] : tags[key];
|
||||
});
|
||||
};
|
||||
@@ -39,7 +39,7 @@ iD.ui.preset = function(context) {
|
||||
};
|
||||
|
||||
field.present = function() {
|
||||
return _.any(field.keys, function(key) {
|
||||
return _.some(field.keys, function(key) {
|
||||
return tags[key];
|
||||
});
|
||||
};
|
||||
|
||||
@@ -111,7 +111,7 @@ iD.ui.preset.address = function(field, context) {
|
||||
|
||||
iD.services.nominatim().countryCode(center, function (err, countryCode) {
|
||||
addressFormat = _.find(iD.data.addressFormats, function (a) {
|
||||
return a && a.countryCodes && _.contains(a.countryCodes, countryCode);
|
||||
return a && a.countryCodes && _.includes(a.countryCodes, countryCode);
|
||||
}) || _.first(iD.data.addressFormats);
|
||||
|
||||
function row(r) {
|
||||
|
||||
@@ -76,7 +76,7 @@ iD.ui.preset.multiCombo = function(field, context) {
|
||||
|
||||
function objectDifference(a, b) {
|
||||
return _.reject(a, function(d1) {
|
||||
return _.any(b, function(d2) { return d1.value === d2.value; });
|
||||
return _.some(b, function(d2) { return d1.value === d2.value; });
|
||||
});
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ iD.ui.preset.multiCombo = function(field, context) {
|
||||
query: (isMulti ? field.key : '') + q
|
||||
}, function(err, data) {
|
||||
if (err) return;
|
||||
comboData = _.pluck(data, 'value').map(function(k) {
|
||||
comboData = _.map(data, 'value').map(function(k) {
|
||||
if (isMulti) k = k.replace(field.key, '');
|
||||
var v = snake_case ? unsnake(k) : k;
|
||||
return {
|
||||
@@ -156,8 +156,8 @@ iD.ui.preset.multiCombo = function(field, context) {
|
||||
if (isMulti) {
|
||||
ph = field.placeholder() || t('inspector.add');
|
||||
} else {
|
||||
var vals = _.pluck(d, 'value').filter(function(s) { return s.length < 20; }),
|
||||
placeholders = vals.length > 1 ? vals : _.pluck(d, 'key');
|
||||
var vals = _.map(d, 'value').filter(function(s) { return s.length < 20; }),
|
||||
placeholders = vals.length > 1 ? vals : _.map(d, 'key');
|
||||
ph = field.placeholder() || placeholders.slice(0, 3).join(', ');
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@ iD.ui.preset.multiCombo = function(field, context) {
|
||||
});
|
||||
|
||||
// Set keys for form-field modified (needed for undo and reset buttons)..
|
||||
field.keys = _.pluck(multiData, 'key');
|
||||
field.keys = _.map(multiData, 'key');
|
||||
|
||||
// Exclude existing multikeys from combo options..
|
||||
var available = objectDifference(comboData, multiData);
|
||||
|
||||
@@ -29,8 +29,8 @@ iD.ui.preset.maxspeed = function(field, context) {
|
||||
var childNodes = context.graph().childNodes(context.entity(entity.id)),
|
||||
loc = childNodes[~~(childNodes.length/2)].loc;
|
||||
|
||||
imperial = _.any(iD.data.imperial.features, function(f) {
|
||||
return _.any(f.geometry.coordinates, function(d) {
|
||||
imperial = _.some(iD.data.imperial.features, function(f) {
|
||||
return _.some(f.geometry.coordinates, function(d) {
|
||||
return iD.geo.pointInPolygon(loc, d[0]);
|
||||
});
|
||||
});
|
||||
|
||||
+1
-1
@@ -108,7 +108,7 @@ iD.util.getStyle = function(selector) {
|
||||
var rules = document.styleSheets[i].rules || document.styleSheets[i].cssRules || [];
|
||||
for (var k = 0; k < rules.length; k++) {
|
||||
var selectorText = rules[k].selectorText && rules[k].selectorText.split(', ');
|
||||
if (_.contains(selectorText, selector)) {
|
||||
if (_.includes(selectorText, selector)) {
|
||||
return rules[k];
|
||||
}
|
||||
}
|
||||
|
||||
+4376
-3068
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user