mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-19 23:14:47 +02:00
Fix tests and lint warnings
This commit is contained in:
@@ -191,7 +191,7 @@ export function validationCrossingWays() {
|
||||
|
||||
if (highwaysDisallowingFords.has(entity1.tags.highway) ||
|
||||
highwaysDisallowingFords.has(entity2.tags.highway)) {
|
||||
// do not allow fords on major highways
|
||||
// do not allow fords on major highways
|
||||
return null;
|
||||
}
|
||||
return { ford: 'yes' };
|
||||
@@ -278,96 +278,97 @@ export function validationCrossingWays() {
|
||||
}
|
||||
return [];
|
||||
}));
|
||||
for (var i = 0; i < waysToCheck.length; i++) {
|
||||
var crosses = findCrossingsByWay(waysToCheck[i], graph, tree, edgePairsVisited);
|
||||
for (var j = 0; j < crosses.length; j++) {
|
||||
var crossing = crosses[j];
|
||||
var crossings = waysToCheck.reduce(function(array, way) {
|
||||
return array.concat(findCrossingsByWay(way, graph, tree, edgePairsVisited));
|
||||
}, []);
|
||||
for (var j in crossings) {
|
||||
var crossing = crossings[j];
|
||||
|
||||
// use the entities with the tags that define the feature type
|
||||
var entities = crossing.ways.sort(function(entity1, entity2) {
|
||||
var type1 = getFeatureTypeForCrossingCheck(entity1, graph);
|
||||
var type2 = getFeatureTypeForCrossingCheck(entity2, graph);
|
||||
if (type1 === type2) {
|
||||
return utilDisplayLabel(entity1, context) > utilDisplayLabel(entity2, context);
|
||||
} else if (type1 === 'waterway') {
|
||||
return true;
|
||||
} else if (type2 === 'waterway') {
|
||||
return false;
|
||||
}
|
||||
return type1 < type2;
|
||||
});
|
||||
entities = _map(entities, function(way) {
|
||||
return getFeatureWithFeatureTypeTagsForWay(way, graph);
|
||||
});
|
||||
|
||||
var connectionTags = tagsForConnectionNodeIfAllowed(entities[0], entities[1]);
|
||||
|
||||
var crossingTypeID;
|
||||
if (hasTag(entities[0].tags, 'tunnel') && hasTag(entities[1].tags, 'tunnel')) {
|
||||
crossingTypeID = 'tunnel-tunnel';
|
||||
if (connectionTags) {
|
||||
crossingTypeID += '_connectable';
|
||||
}
|
||||
}
|
||||
else if (hasTag(entities[0].tags, 'bridge') && hasTag(entities[1].tags, 'bridge')) {
|
||||
crossingTypeID = 'bridge-bridge';
|
||||
if (connectionTags) {
|
||||
crossingTypeID += '_connectable';
|
||||
}
|
||||
}
|
||||
else {
|
||||
crossingTypeID = crossing.featureTypes.sort().join('-');
|
||||
// use the entities with the tags that define the feature type
|
||||
var entities = crossing.ways.sort(function(entity1, entity2) {
|
||||
var type1 = getFeatureTypeForCrossingCheck(entity1, graph);
|
||||
var type2 = getFeatureTypeForCrossingCheck(entity2, graph);
|
||||
if (type1 === type2) {
|
||||
return utilDisplayLabel(entity1, context) > utilDisplayLabel(entity2, context);
|
||||
} else if (type1 === 'waterway') {
|
||||
return true;
|
||||
} else if (type2 === 'waterway') {
|
||||
return false;
|
||||
}
|
||||
return type1 < type2;
|
||||
});
|
||||
entities = _map(entities, function(way) {
|
||||
return getFeatureWithFeatureTypeTagsForWay(way, graph);
|
||||
});
|
||||
|
||||
var messageDict = {
|
||||
feature: utilDisplayLabel(entities[0], context),
|
||||
feature2: utilDisplayLabel(entities[1], context)
|
||||
};
|
||||
var connectionTags = tagsForConnectionNodeIfAllowed(entities[0], entities[1]);
|
||||
|
||||
var fixes = [];
|
||||
var crossingTypeID;
|
||||
if (hasTag(entities[0].tags, 'tunnel') && hasTag(entities[1].tags, 'tunnel')) {
|
||||
crossingTypeID = 'tunnel-tunnel';
|
||||
if (connectionTags) {
|
||||
fixes.push(new validationIssueFix({
|
||||
title: t('issues.fix.add_connection_vertex.title'),
|
||||
onClick: function() {
|
||||
var loc = this.issue.coordinates;
|
||||
var ways = this.issue.info.ways;
|
||||
|
||||
context.perform(
|
||||
function actionConnectCrossingWays(graph) {
|
||||
var projection = context.projection;
|
||||
|
||||
var node = osmNode({ loc: loc, tags: connectionTags });
|
||||
graph = graph.replace(node);
|
||||
|
||||
var way0 = graph.entity(ways[0].id);
|
||||
var choice0 = geoChooseEdge(graph.childNodes(way0), projection(loc), projection);
|
||||
var edge0 = [way0.nodes[choice0.index - 1], way0.nodes[choice0.index]];
|
||||
graph = actionAddMidpoint({loc: loc, edge: edge0}, node)(graph);
|
||||
|
||||
var way1 = graph.entity(ways[1].id);
|
||||
var choice1 = geoChooseEdge(graph.childNodes(way1), projection(loc), projection);
|
||||
var edge1 = [way1.nodes[choice1.index - 1], way1.nodes[choice1.index]];
|
||||
graph = actionAddMidpoint({loc: loc, edge: edge1}, node)(graph);
|
||||
|
||||
return graph;
|
||||
},
|
||||
t('issues.fix.add_connection_vertex.undo_redo')
|
||||
);
|
||||
}
|
||||
}));
|
||||
crossingTypeID += '_connectable';
|
||||
}
|
||||
}
|
||||
else if (hasTag(entities[0].tags, 'bridge') && hasTag(entities[1].tags, 'bridge')) {
|
||||
crossingTypeID = 'bridge-bridge';
|
||||
if (connectionTags) {
|
||||
crossingTypeID += '_connectable';
|
||||
}
|
||||
}
|
||||
else {
|
||||
crossingTypeID = crossing.featureTypes.sort().join('-');
|
||||
}
|
||||
|
||||
issues.push(new validationIssue({
|
||||
type: 'crossing_ways',
|
||||
severity: 'warning',
|
||||
message: t('issues.crossing_ways.message', messageDict),
|
||||
tooltip: t('issues.crossing_ways.'+crossingTypeID+'.tip'),
|
||||
entities: entities,
|
||||
info: {'ways': crossing.ways},
|
||||
coordinates: crossing.cross_point,
|
||||
fixes: fixes
|
||||
var messageDict = {
|
||||
feature: utilDisplayLabel(entities[0], context),
|
||||
feature2: utilDisplayLabel(entities[1], context)
|
||||
};
|
||||
|
||||
var fixes = [];
|
||||
if (connectionTags) {
|
||||
fixes.push(new validationIssueFix({
|
||||
title: t('issues.fix.add_connection_vertex.title'),
|
||||
onClick: function() {
|
||||
var loc = this.issue.coordinates;
|
||||
var ways = this.issue.info.ways;
|
||||
var connectionTags = this.issue.info.connectionTags;
|
||||
|
||||
context.perform(
|
||||
function actionConnectCrossingWays(graph) {
|
||||
var projection = context.projection;
|
||||
|
||||
var node = osmNode({ loc: loc, tags: connectionTags });
|
||||
graph = graph.replace(node);
|
||||
|
||||
var way0 = graph.entity(ways[0].id);
|
||||
var choice0 = geoChooseEdge(graph.childNodes(way0), projection(loc), projection);
|
||||
var edge0 = [way0.nodes[choice0.index - 1], way0.nodes[choice0.index]];
|
||||
graph = actionAddMidpoint({loc: loc, edge: edge0}, node)(graph);
|
||||
|
||||
var way1 = graph.entity(ways[1].id);
|
||||
var choice1 = geoChooseEdge(graph.childNodes(way1), projection(loc), projection);
|
||||
var edge1 = [way1.nodes[choice1.index - 1], way1.nodes[choice1.index]];
|
||||
graph = actionAddMidpoint({loc: loc, edge: edge1}, node)(graph);
|
||||
|
||||
return graph;
|
||||
},
|
||||
t('issues.fix.add_connection_vertex.undo_redo')
|
||||
);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
issues.push(new validationIssue({
|
||||
type: 'crossing_ways',
|
||||
severity: 'warning',
|
||||
message: t('issues.crossing_ways.message', messageDict),
|
||||
tooltip: t('issues.crossing_ways.'+crossingTypeID+'.tip'),
|
||||
entities: entities,
|
||||
info: { ways: crossing.ways, connectionTags: connectionTags },
|
||||
coordinates: crossing.cross_point,
|
||||
fixes: fixes
|
||||
}));
|
||||
}
|
||||
|
||||
return issues;
|
||||
|
||||
Reference in New Issue
Block a user