Merge branch 'master' into validation_and_change_perf

This commit is contained in:
Bryan Housel
2019-04-10 14:22:20 -04:00
209 changed files with 1871 additions and 1169 deletions
+1
View File
@@ -155,6 +155,7 @@
<script src='spec/validations/crossing_ways.js'></script>
<script src='spec/validations/disconnected_way.js'></script>
<script src='spec/validations/generic_name.js'></script>
<script src='spec/validations/incompatible_source.js'></script>
<script src='spec/validations/missing_role.js'></script>
<script src='spec/validations/missing_tag.js'></script>
<script src='spec/validations/old_multipolygon.js'></script>
+29
View File
@@ -180,6 +180,35 @@ describe('iD.actionDisconnect', function () {
expect(graph.entity('|').nodes).to.eql(['d', 'b']);
});
it('preserves the closed way when part of a larger disconnect operation', function () {
// Situation:
// a ---- bb === c
// = ==
// = ==
// d
// Disconnect - at b (whilst == is selected).
//
// Expected result:
// a ---- b ee === c
// = ==
// = ==
// d
//
var graph = iD.coreGraph([
iD.osmNode({id: 'a'}),
iD.osmNode({id: 'b'}),
iD.osmNode({id: 'c'}),
iD.osmNode({id: 'd'}),
iD.osmWay({id: '-', nodes: ['a', 'b']}),
iD.osmWay({id: '=', nodes: ['b', 'c', 'd', 'b']})
]);
graph = iD.actionDisconnect('b', 'e').limitWays(['='])(graph);
expect(graph.entity('-').nodes).to.eql(['a', 'b']);
expect(graph.entity('=').nodes).to.eql(['e', 'c', 'd', 'e']);
});
it('replaces later occurrences in a self-intersecting way', function() {
// Situtation:
// a --- b
@@ -0,0 +1,60 @@
describe('iD.validations.incompatible_source', function () {
var context;
beforeEach(function() {
context = iD.coreContext();
});
function createWay(tags) {
var n1 = iD.osmNode({id: 'n-1', loc: [4,4]});
var n2 = iD.osmNode({id: 'n-2', loc: [4,5]});
var n3 = iD.osmNode({id: 'n-3', loc: [5,5]});
var w = iD.osmWay({id: 'w-1', nodes: ['n-1', 'n-2', 'n-3'], tags: tags});
context.perform(
iD.actionAddEntity(n1),
iD.actionAddEntity(n2),
iD.actionAddEntity(n3),
iD.actionAddEntity(w)
);
}
function validate() {
var validator = iD.validationIncompatibleSource();
var changes = context.history().changes();
var entities = changes.modified.concat(changes.created);
var issues = [];
entities.forEach(function(entity) {
issues = issues.concat(validator(entity, context));
});
return issues;
}
it('has no errors on init', function() {
var issues = validate();
expect(issues).to.have.lengthOf(0);
});
it('ignores way with no source tag', function() {
createWay({ amenity: 'cafe', building: 'yes', name: 'Key Largo Café'});
var issues = validate();
expect(issues).to.have.lengthOf(0);
});
it('ignores way with okay source tag', function() {
createWay({ amenity: 'cafe', building: 'yes', name: 'Key Largo Café', source: 'survey'});
var issues = validate();
expect(issues).to.have.lengthOf(0);
});
it('flags way with incompatible source tag', function() {
createWay({ amenity: 'cafe', building: 'yes', name: 'Key Largo Café', source: 'Google Maps'});
var issues = validate();
expect(issues).to.have.lengthOf(1);
var issue = issues[0];
expect(issue.type).to.eql('incompatible_source');
expect(issue.entities).to.have.lengthOf(1);
expect(issue.entities[0].id).to.eql('w-1');
});
});