Changeset 97 in josm for src/org/openstreetmap
- Timestamp:
- 2006-04-23T23:20:33+02:00 (19 years ago)
- Location:
- src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/data/osm/Segment.java
r94 r97 80 80 81 81 @Override public boolean realEqual(OsmPrimitive osm) { 82 return osm instanceof Segment ? 83 super.realEqual(osm) && 84 from.equals(((Segment)osm).from) && 85 to.equals(((Segment)osm).to) : false; 82 if (!(osm instanceof Segment)) 83 return super.realEqual(osm); 84 if (incomplete) 85 return ((Segment)osm).incomplete; 86 return from.equals(((Segment)osm).from) && to.equals(((Segment)osm).to); 86 87 } 87 88 -
src/org/openstreetmap/josm/data/osm/visitor/MergeVisitor.java
r86 r97 82 82 */ 83 83 public void visit(Segment other) { 84 if (other.incomplete) 85 return; // won't merge in an incomplete line segment! 86 84 87 if (mergeAfterId(mergedSegments, ds.segments, other)) 85 88 return; … … 252 255 } 253 256 257 /** 258 * @return <code>true</code>, if no merge is needed. 259 */ 254 260 private <P extends OsmPrimitive> boolean mergeAfterId(Map<P,P> merged, Collection<P> primitives, P other) { 255 261 for (P my : primitives) { … … 257 263 return true; // no merge needed. 258 264 if (my.id == other.id) { 265 if (my instanceof Segment && ((Segment)my).incomplete) 266 return false; // merge always over an incomplete 259 267 Date d1 = my.timestamp == null ? new Date(0) : my.timestamp; 260 268 Date d2 = other.timestamp == null ? new Date(0) : other.timestamp; -
src/org/openstreetmap/josm/io/OsmServerReader.java
r95 r97 28 28 private final double lat2; 29 29 private final double lon2; 30 30 31 31 /** 32 32 * Construct the reader and store the information for attaching … … 51 51 Collection<Collection<GpsPoint>> data = new LinkedList<Collection<GpsPoint>>(); 52 52 Collection<GpsPoint> list = new LinkedList<GpsPoint>(); 53 53 54 54 for (int i = 0;;++i) { 55 currentAction.setText("Downloading points "+(i*5000)+" to "+((i+1)*5000)+"..."); 55 56 Reader r = getReader(url+i); 56 57 if (r == null) … … 70 71 activeConnection = null; 71 72 } 72 73 73 74 data.add(list); 74 75 return data; -
src/org/openstreetmap/josm/test/MergeVisitorTest.java
r86 r97 16 16 public class MergeVisitorTest extends TestCase { 17 17 18 18 19 19 private DataSet ds; 20 20 private Node dsNode; … … 27 27 v = new MergeVisitor(ds); 28 28 n = DataSetTestCaseHelper.createNode(null); 29 29 } 30 30 31 31 … … 101 101 ds.segments.add(sold); 102 102 // have a conflicting segment point to the new node 103 Segment s = new Segment(n, n);103 Segment s = new Segment(n,DataSetTestCaseHelper.createNode(null)); 104 104 s.id = 23; 105 105 s.modified = true; … … 108 108 assertEquals(n.timestamp, dsNode.timestamp); 109 109 v.visit(s); 110 assertEquals(1, v.conflicts.size()); 110 111 v.fixReferences(); 111 112 assertSame(s.from, dsNode); 112 assertSame(s.to, dsNode);113 113 } 114 114 115 115 public void testNoConflictForSame() { 116 116 dsNode.id = 1; … … 136 136 assertEquals("segment should have been merged.", 1, ds.segments.size()); 137 137 } 138 138 139 /** 140 * Incomplete segments should always loose. 141 */ 142 public void testImportIncomplete() throws Exception { 143 Segment s1 = DataSetTestCaseHelper.createSegment(ds, dsNode, dsNode); 144 s1.id = 1; 145 Segment s2 = new Segment(s1); 146 s1.incomplete = true; 147 v.visit(s2); 148 assertTrue(s1.realEqual(s2)); 149 } 150 151 139 152 /** 140 153 * Nodes beeing merged are equal but should be the same. … … 163 176 assertSame(ls1.from, ls2.from); 164 177 } 165 166 178 179 167 180 /** 168 181 * Create that amount of nodes and add them to the dataset. The id will be 1,2,3,4...
Note:
See TracChangeset
for help on using the changeset viewer.