mirror of
https://github.com/FoggedLens/iD.git
synced 2026-04-21 11:16:36 +02:00
Migrating to lodash v4
This commit is contained in:
@@ -317,4 +317,4 @@ d3:
|
||||
@echo 'd3 rebuilt. Please reapply 7e2485d, 4da529f, and 223974d'
|
||||
|
||||
lodash:
|
||||
node_modules/.bin/lodash --development --output js/lib/lodash.js include="any,assign,bind,chunk,clone,compact,contains,debounce,difference,each,every,extend,filter,find,first,forEach,forOwn,groupBy,indexOf,intersection,isEmpty,isEqual,isFunction,keys,last,map,omit,pairs,pluck,reject,some,throttle,union,uniq,unique,values,without,flatten,value,chain,cloneDeep,merge,pick,reduce" exports="global,node"
|
||||
node_modules/.bin/lodash --development --output js/lib/lodash.js include="includes,toPairs,assign,bind,chunk,clone,compact,debounce,difference,each,every,extend,filter,find,first,forEach,forOwn,groupBy,indexOf,intersection,isEmpty,isEqual,isFunction,keys,last,map,omit,reject,some,throttle,union,uniq,values,without,flatten,value,chain,cloneDeep,merge,pick,reduce" exports="global,node"
|
||||
|
||||
@@ -183,7 +183,7 @@ function generateTranslate(fields, presets) {
|
||||
_.forEach(translate.presets, function(preset, id) {
|
||||
var p = presets[id];
|
||||
if (!_.isEmpty(p.tags))
|
||||
preset['name#'] = _.pairs(p.tags).map(function(pair) { return pair[0] + '=' + pair[1]; }).join(', ');
|
||||
preset['name#'] = _.toPairs(p.tags).map(function(pair) { return pair[0] + '=' + pair[1]; }).join(', ');
|
||||
if (p.terms && p.terms.length)
|
||||
preset['terms#'] = 'terms: ' + p.terms.join();
|
||||
preset.terms = "<translate with synonyms or related terms for '" + preset.name + "', separated by commas>";
|
||||
|
||||
@@ -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
+1
-1
@@ -28,7 +28,7 @@
|
||||
"happen": "0.1.2",
|
||||
"js-yaml": "~3.3.1",
|
||||
"jsonschema": "~0.3.2",
|
||||
"lodash-cli": "3.9.3",
|
||||
"lodash-cli": "4.12.0",
|
||||
"maki": "0.5.0",
|
||||
"minimist": "~1.2.0",
|
||||
"mocha": "~2.3.4",
|
||||
|
||||
@@ -7,7 +7,7 @@ describe("iD.actions.AddMember", function() {
|
||||
|
||||
describe("inserts way members at a sensible index", function() {
|
||||
function members(graph) {
|
||||
return _.pluck(graph.entity('r').members, 'id');
|
||||
return _.map(graph.entity('r').members, 'id');
|
||||
}
|
||||
|
||||
specify("no members", function() {
|
||||
|
||||
@@ -2,7 +2,7 @@ describe("iD.actions.Circularize", function () {
|
||||
var projection = d3.geo.mercator();
|
||||
|
||||
function isCircular(id, graph) {
|
||||
var points = _.pluck(graph.childNodes(graph.entity(id)), 'loc').map(projection),
|
||||
var points = _.map(graph.childNodes(graph.entity(id)), 'loc').map(projection),
|
||||
centroid = d3.geom.polygon(points).centroid(),
|
||||
radius = iD.geo.euclideanDistance(centroid, points[0]),
|
||||
estArea = Math.PI * radius * radius,
|
||||
@@ -105,7 +105,7 @@ describe("iD.actions.Circularize", function () {
|
||||
graph = iD.actions.Circularize('-', projection, 20)(graph);
|
||||
|
||||
expect(isCircular('-', graph)).to.be.ok;
|
||||
points = _.pluck(graph.childNodes(graph.entity('-')), 'loc').map(projection);
|
||||
points = _.map(graph.childNodes(graph.entity('-')), 'loc').map(projection);
|
||||
centroid = d3.geom.polygon(points).centroid();
|
||||
|
||||
for (var i = 0; i < points.length - 1; i++) {
|
||||
@@ -116,7 +116,7 @@ describe("iD.actions.Circularize", function () {
|
||||
});
|
||||
|
||||
function area(id, graph) {
|
||||
return d3.geom.polygon(_.pluck(graph.childNodes(graph.entity(id)), 'loc')).area();
|
||||
return d3.geom.polygon(_.map(graph.childNodes(graph.entity(id)), 'loc')).area();
|
||||
}
|
||||
|
||||
it("leaves clockwise ways clockwise", function () {
|
||||
|
||||
@@ -11,7 +11,7 @@ describe("iD.actions.DeleteWay", function() {
|
||||
relation = iD.Relation({members: [{ id: way.id }, { id: 'w-2' }]}),
|
||||
action = iD.actions.DeleteWay(way.id),
|
||||
graph = iD.Graph([way, relation]).update(action);
|
||||
expect(_.pluck(graph.entity(relation.id).members, 'id')).not.to.contain(way.id);
|
||||
expect(_.map(graph.entity(relation.id).members, 'id')).not.to.contain(way.id);
|
||||
});
|
||||
|
||||
it("deletes member nodes not referenced by another parent", function() {
|
||||
|
||||
@@ -93,14 +93,15 @@ describe("iD.actions.MergeRemoteChanges", function () {
|
||||
describe("non-destuctive merging", function () {
|
||||
describe("tags", function() {
|
||||
it("doesn't merge tags if conflict (local change, remote change)", function () {
|
||||
|
||||
var localTags = {foo: 'foo_local'}, // changed foo
|
||||
remoteTags = {foo: 'foo_remote'}, // changed foo
|
||||
local = base.entity('a').update({tags: localTags}),
|
||||
remote = base.entity('a').update({tags: remoteTags, version: '2'}),
|
||||
localGraph = makeGraph([local]),
|
||||
remoteGraph = makeGraph([remote]),
|
||||
action = iD.actions.MergeRemoteChanges('a', localGraph, remoteGraph),
|
||||
result = action(localGraph);
|
||||
action = iD.actions.MergeRemoteChanges('a', localGraph, remoteGraph);
|
||||
var result = action(localGraph);
|
||||
|
||||
expect(result).to.eql(localGraph);
|
||||
});
|
||||
|
||||
@@ -377,7 +377,7 @@ describe("iD.actions.Split", function () {
|
||||
|
||||
graph = iD.actions.Split('b', ['='])(graph);
|
||||
|
||||
expect(_.pluck(graph.entity('r').members, 'id')).to.eql(['-', '=', '~']);
|
||||
expect(_.map(graph.entity('r').members, 'id')).to.eql(['-', '=', '~']);
|
||||
});
|
||||
|
||||
it("adds the new way to parent relations (reverse order)", function () {
|
||||
@@ -403,7 +403,7 @@ describe("iD.actions.Split", function () {
|
||||
|
||||
graph = iD.actions.Split('b', ['='])(graph);
|
||||
|
||||
expect(_.pluck(graph.entity('r').members, 'id')).to.eql(['~', '=', '-']);
|
||||
expect(_.map(graph.entity('r').members, 'id')).to.eql(['~', '=', '-']);
|
||||
});
|
||||
|
||||
it("handles incomplete relations", function () {
|
||||
@@ -417,7 +417,7 @@ describe("iD.actions.Split", function () {
|
||||
|
||||
graph = iD.actions.Split('b', ['='])(graph);
|
||||
|
||||
expect(_.pluck(graph.entity('r').members, 'id')).to.eql(['~', '-', '=']);
|
||||
expect(_.map(graph.entity('r').members, 'id')).to.eql(['~', '-', '=']);
|
||||
});
|
||||
|
||||
it("converts simple multipolygon to a proper multipolygon", function () {
|
||||
@@ -433,7 +433,7 @@ describe("iD.actions.Split", function () {
|
||||
|
||||
expect(graph.entity('-').tags).to.eql({});
|
||||
expect(graph.entity('r').tags).to.eql({type: 'multipolygon', natural: 'water'});
|
||||
expect(_.pluck(graph.entity('r').members, 'id')).to.eql(['-', '=']);
|
||||
expect(_.map(graph.entity('r').members, 'id')).to.eql(['-', '=']);
|
||||
});
|
||||
|
||||
['restriction', 'restriction:bus'].forEach(function (type) {
|
||||
|
||||
@@ -190,9 +190,9 @@ describe("iD.Tree", function() {
|
||||
|
||||
graph = graph.replace(n1.move([1.1,1.1])).replace(n2.move([2.1,2.1]));
|
||||
expect(
|
||||
_.pluck(tree.intersects(extent, graph),'id').sort()
|
||||
_.map(tree.intersects(extent, graph),'id').sort()
|
||||
).to.eql(
|
||||
_.pluck([n1, n2, way],'id').sort()
|
||||
_.map([n1, n2, way],'id').sort()
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ describe("iD.geo.Intersection", function() {
|
||||
iD.Way({id: '=', nodes: ['u', '*'], tags: {highway: 'residential'}}),
|
||||
iD.Way({id: '-', nodes: ['*'], tags: {highway: 'residential'}})
|
||||
]);
|
||||
expect(_.pluck(iD.geo.Intersection(graph, '*').ways, 'id')).to.eql(['=']);
|
||||
expect(_.map(iD.geo.Intersection(graph, '*').ways, 'id')).to.eql(['=']);
|
||||
});
|
||||
|
||||
it("excludes coincident highways", function() {
|
||||
@@ -39,7 +39,7 @@ describe("iD.geo.Intersection", function() {
|
||||
iD.Way({id: '=', nodes: ['u', '*'], tags: {highway: 'residential'}}),
|
||||
iD.Way({id: '-', nodes: ['*', 'w']})
|
||||
]);
|
||||
expect(_.pluck(iD.geo.Intersection(graph, '*').ways, 'id')).to.eql(['=']);
|
||||
expect(_.map(iD.geo.Intersection(graph, '*').ways, 'id')).to.eql(['=']);
|
||||
});
|
||||
|
||||
it('excludes area highways', function() {
|
||||
@@ -59,7 +59,7 @@ describe("iD.geo.Intersection", function() {
|
||||
iD.Node({id: 'w'}),
|
||||
iD.Way({id: '=', nodes: ['u', '*', 'w'], tags: {highway: 'residential'}})
|
||||
]);
|
||||
expect(_.pluck(iD.geo.Intersection(graph, '*').ways, 'id')).to.eql(['=-a', '=-b']);
|
||||
expect(_.map(iD.geo.Intersection(graph, '*').ways, 'id')).to.eql(['=-a', '=-b']);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ describe("iD.geo.joinWays", function() {
|
||||
]);
|
||||
|
||||
var result = iD.geo.joinWays(graph.entity('r').members, graph);
|
||||
expect(_.pluck(result[0], 'id')).to.eql(['=', '-', '~']);
|
||||
expect(_.map(result[0], 'id')).to.eql(['=', '-', '~']);
|
||||
});
|
||||
|
||||
it("reverses member tags of reversed segements", function() {
|
||||
|
||||
@@ -18,15 +18,15 @@ describe('iD.ui.preset.access', function() {
|
||||
|
||||
it('does not include "yes", "designated", "dismount" options for general access (#934), (#2213)', function() {
|
||||
var access = iD.ui.preset.access(field);
|
||||
expect(_.pluck(access.options('access'), 'value')).not.to.include('yes');
|
||||
expect(_.pluck(access.options('access'), 'value')).not.to.include('designated');
|
||||
expect(_.pluck(access.options('access'), 'value')).not.to.include('dismount');
|
||||
expect(_.map(access.options('access'), 'value')).not.to.include('yes');
|
||||
expect(_.map(access.options('access'), 'value')).not.to.include('designated');
|
||||
expect(_.map(access.options('access'), 'value')).not.to.include('dismount');
|
||||
});
|
||||
|
||||
it('does include a "dismount" option for bicycles (#2726)', function() {
|
||||
var access = iD.ui.preset.access(field);
|
||||
expect(_.pluck(access.options('bicycle'), 'value')).to.include('dismount');
|
||||
expect(_.pluck(access.options('foot'), 'value')).not.to.include('dismount');
|
||||
expect(_.map(access.options('bicycle'), 'value')).to.include('dismount');
|
||||
expect(_.map(access.options('foot'), 'value')).not.to.include('dismount');
|
||||
});
|
||||
|
||||
it('sets foot placeholder to "yes" for steps and pedestrian', function() {
|
||||
|
||||
Reference in New Issue
Block a user