Ticket #14186: 14186.patch
File 14186.patch, 3.1 KB (added by , 7 years ago) |
---|
-
src/org/openstreetmap/josm/data/osm/DataSet.java
977 977 Set<Way> result = new HashSet<>(); 978 978 beginUpdate(); 979 979 try { 980 for (Way way: ways) { 980 List<Way> refWays = new ArrayList<>(); 981 for (OsmPrimitive ref : node.getReferrers()) { 982 if (ref instanceof Way) { 983 refWays.add((Way) ref); 984 } 985 } 986 for (Way way : refWays) { 981 987 List<Node> wayNodes = way.getNodes(); 982 988 if (wayNodes.remove(node)) { 983 989 if (wayNodes.size() < 2) { -
test/unit/org/openstreetmap/josm/data/osm/DataSetTest.java
1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.data.osm; 3 3 4 import java.util.Arrays; 5 import java.util.List; 6 7 import org.junit.Assert; 4 8 import org.junit.Rule; 5 9 import org.junit.Test; 6 import org. junit.Assert;10 import org.openstreetmap.josm.data.coor.LatLon; 7 11 import org.openstreetmap.josm.testutils.JOSMTestRules; 8 12 9 13 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 10 import java.util.List;11 import org.openstreetmap.josm.data.coor.LatLon;12 14 13 15 /** 14 16 * Unit tests for class {@link DataSet}. … … 33 35 "Empty data set should produce an empty list.", 34 36 ds.searchRelations(null).isEmpty() 35 37 ); 36 38 37 39 // empty data set, any bbox => empty list 38 BBox bbox = new BBox( LatLon.NORTH_POLE, LatLon.SOUTH_POLE);40 BBox bbox = new BBox(new LatLon(-180, -90), new LatLon(180, 90)); 39 41 Assert.assertTrue( 40 42 "Empty data set should produce an empty list.", 41 43 ds.searchRelations(bbox).isEmpty() 42 44 ); 43 45 44 46 // data set with elements in the given bbox => these elements 45 47 Node node = new Node(LatLon.ZERO); 46 48 Relation r = new Relation(1); … … 52 54 List<Relation> result = ds.searchRelations(bbox); 53 55 Assert.assertEquals("We should have found only one item.", 1, result.size()); 54 56 Assert.assertTrue("The item found is relation r.", result.contains(r)); 55 56 57 } 58 59 @Test 60 public void testErr14186() { 61 final DataSet ds = new DataSet(); 62 Node n1 = new Node(1); 63 Node n2 = new Node(2); 64 Node n3 = new Node(3); 65 Way w1 = new Way(1); 66 w1.setNodes(Arrays.asList(n1, n2, n3)); 67 Way w2 = new Way(2); 68 w2.setNodes(Arrays.asList(n1, n2, n3)); 69 ds.addPrimitive(n1); 70 ds.addPrimitive(n2); 71 ds.addPrimitive(n3); 72 ds.addPrimitive(w1); 73 ds.addPrimitive(w2); 74 ds.unlinkNodeFromWays(n2); 75 } 76 57 77 }