Changeset 2077 in josm
- Timestamp:
- 2009-09-07T23:06:19+02:00 (15 years ago)
- Location:
- trunk
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/UpdateSelectionAction.java
r2025 r2077 16 16 import org.openstreetmap.josm.data.osm.Node; 17 17 import org.openstreetmap.josm.data.osm.OsmPrimitive; 18 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 18 19 import org.openstreetmap.josm.data.osm.Relation; 19 20 import org.openstreetmap.josm.data.osm.Way; … … 39 40 * @param id the primitive id 40 41 */ 41 protected void handlePrimitiveGoneException(long id ) {42 protected void handlePrimitiveGoneException(long id, OsmPrimitiveType type) { 42 43 MultiFetchServerObjectReader reader = new MultiFetchServerObjectReader(); 43 reader.append(getCurrentDataSet(),id );44 reader.append(getCurrentDataSet(),id, type); 44 45 DataSet ds = null; 45 46 try { … … 73 74 * 74 75 */ 75 public void updatePrimitive( long id) throws IllegalStateException{76 public void updatePrimitive(OsmPrimitiveType type, long id) throws IllegalStateException{ 76 77 if (getEditLayer() == null) 77 78 throw new IllegalStateException(tr("No current dataset found")); 78 OsmPrimitive primitive = getEditLayer().data.getPrimitiveById(id );79 OsmPrimitive primitive = getEditLayer().data.getPrimitiveById(id, type); 79 80 if (primitive == null) 80 81 throw new IllegalStateException(tr("Didn't find a primitive with id {0} in the current dataset", id)); -
trunk/src/org/openstreetmap/josm/actions/UploadAction.java
r2074 r2077 41 41 import org.openstreetmap.josm.data.osm.DataSet; 42 42 import org.openstreetmap.josm.data.osm.OsmPrimitive; 43 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 43 44 import org.openstreetmap.josm.gui.ExceptionDialogUtil; 44 45 import org.openstreetmap.josm.gui.ExtendedDialog; … … 191 192 * @param id the primitive ID 192 193 */ 193 protected void synchronizePrimitive(final String id) {194 Main.worker.execute(new UpdatePrimitiveTask( Long.parseLong(id)));194 protected void synchronizePrimitive(final OsmPrimitiveType type, final long id) { 195 Main.worker.execute(new UpdatePrimitiveTask(type, id)); 195 196 } 196 197 … … 217 218 * @param myVersion the version of the primitive in the local dataset 218 219 */ 219 protected void handleUploadConflictForKnownConflict( String primitiveType, String id, String serverVersion, String myVersion) {220 protected void handleUploadConflictForKnownConflict(OsmPrimitiveType primitiveType, long id, String serverVersion, String myVersion) { 220 221 Object[] options = new Object[] { 221 tr("Synchronize {0} {1} only", tr(primitiveType ), id),222 tr("Synchronize {0} {1} only", tr(primitiveType.getAPIName()), id), 222 223 tr("Synchronize entire dataset"), 223 224 tr("Cancel") … … 232 233 + "Click <strong>{5}</strong> to synchronize the entire local dataset with the server.<br>" 233 234 + "Click <strong>{6}</strong> to abort and continue editing.<br></html>", 234 tr(primitiveType ), id, serverVersion, myVersion,235 tr(primitiveType.getAPIName()), id, serverVersion, myVersion, 235 236 options[0], options[1], options[2] 236 237 ); … … 247 248 ); 248 249 switch(ret) { 249 250 251 case 0: synchronizePrimitive(id); break;252 253 254 255 250 case JOptionPane.CLOSED_OPTION: return; 251 case JOptionPane.CANCEL_OPTION: return; 252 case 0: synchronizePrimitive(primitiveType, id); break; 253 case 1: synchronizeDataSet(); break; 254 default: 255 // should not happen 256 throw new IllegalStateException(tr("unexpected return value. Got {0}", ret)); 256 257 } 257 258 } … … 287 288 ); 288 289 switch(ret) { 289 290 291 292 293 294 290 case JOptionPane.CLOSED_OPTION: return; 291 case 1: return; 292 case 0: synchronizeDataSet(); break; 293 default: 294 // should not happen 295 throw new IllegalStateException(tr("unexpected return value. Got {0}", ret)); 295 296 } 296 297 } … … 306 307 Matcher m = p.matcher(e.getErrorHeader()); 307 308 if (m.matches()) { 308 handleUploadConflictForKnownConflict( m.group(3), m.group(4), m.group(2),m.group(1));309 handleUploadConflictForKnownConflict(OsmPrimitiveType.from(m.group(3)), Long.parseLong(m.group(4)), m.group(2),m.group(1)); 309 310 } else { 310 311 logger.warning(tr("Warning: error header \"{0}\" did not match expected pattern \"{1}\"", e.getErrorHeader(),pattern)); … … 326 327 * @see UpdateSelectionAction#handlePrimitiveGoneException(long) 327 328 */ 328 protected void handleGoneForKnownPrimitive( StringprimitiveType, String id) {329 protected void handleGoneForKnownPrimitive(OsmPrimitiveType primitiveType, String id) { 329 330 UpdateSelectionAction act = new UpdateSelectionAction(); 330 act.handlePrimitiveGoneException(Long.parseLong(id) );331 act.handlePrimitiveGoneException(Long.parseLong(id),primitiveType); 331 332 } 332 333 … … 344 345 Matcher m = p.matcher(e.getErrorHeader()); 345 346 if (m.matches()) { 346 handleGoneForKnownPrimitive( m.group(1), m.group(2));347 handleGoneForKnownPrimitive(OsmPrimitiveType.from(m.group(1)), m.group(2)); 347 348 } else { 348 349 logger.warning(tr("Error header \"{0}\" does not match expected pattern \"{1}\"",e.getErrorHeader(), pattern)); … … 424 425 private Exception lastException = null; 425 426 private long id; 426 427 public UpdatePrimitiveTask(long id) { 427 private OsmPrimitiveType type; 428 429 public UpdatePrimitiveTask(OsmPrimitiveType type, long id) { 428 430 super(tr("Updating primitive"),false /* don't ignore exceptions */); 429 431 this.id = id; 432 this.type = type; 430 433 } 431 434 … … 433 436 try { 434 437 UpdateSelectionAction act = new UpdateSelectionAction(); 435 act.updatePrimitive( id);438 act.updatePrimitive(type, id); 436 439 } catch (Exception sxe) { 437 440 if (uploadCancelled) { -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTaskList.java
r2017 r2077 125 125 final OsmDataLayer editLayer = Main.map.mapView.getEditLayer(); 126 126 if (editLayer != null) { 127 Set<Long> myPrimitiveIds = editLayer.data.getCompletePrimitiveIds(); 128 Set<Long> downloadedIds = getDownloadedIds(); 129 myPrimitiveIds.removeAll(downloadedIds); 130 myPrimitiveIds.remove(new Long(0)); // ignore new primitives 131 if (! myPrimitiveIds.isEmpty()) { 132 handlePotentiallyDeletedPrimitives(myPrimitiveIds); 133 } 134 } 127 Set<OsmPrimitive> myPrimitives = getCompletePrimitives(editLayer.data); 128 for (DownloadTask task : osmTasks) { 129 if(task instanceof DownloadOsmTask) { 130 DataSet ds = ((DownloadOsmTask)task).getDownloadedData(); 131 if (ds != null) { 132 myPrimitives.removeAll(ds.nodes); 133 myPrimitives.removeAll(ds.ways); 134 myPrimitives.removeAll(ds.relations); 135 } 136 } 137 } 138 if (! myPrimitives.isEmpty()) { 139 handlePotentiallyDeletedPrimitives(myPrimitives); 140 } 141 } 142 } 143 144 145 /** 146 * Replies the set of ids of all complete primitives (i.e. those with 147 * ! primitive.incomplete) 148 * 149 * @return the set of ids of all complete primitives 150 */ 151 protected Set<OsmPrimitive> getCompletePrimitives(DataSet ds) { 152 HashSet<OsmPrimitive> ret = new HashSet<OsmPrimitive>(); 153 for (OsmPrimitive primitive : ds.nodes) { 154 if (!primitive.incomplete && primitive.getId() == 0) { 155 ret.add(primitive); 156 } 157 } 158 for (OsmPrimitive primitive : ds.ways) { 159 if (! primitive.incomplete && primitive.getId() == 0) { 160 ret.add(primitive); 161 } 162 } 163 for (OsmPrimitive primitive : ds.relations) { 164 if (! primitive.incomplete && primitive.getId() == 0) { 165 ret.add(primitive);; 166 } 167 } 168 return ret; 135 169 } 136 170 … … 141 175 * @param potentiallyDeleted a set of ids to check update from the server 142 176 */ 143 protected void updatePotentiallyDeletedPrimitives(Set<Long> potentiallyDeleted) { 144 DataSet ds = Main.map.mapView.getEditLayer().data; 177 protected void updatePotentiallyDeletedPrimitives(Set<OsmPrimitive> potentiallyDeleted) { 145 178 final ArrayList<OsmPrimitive> toSelect = new ArrayList<OsmPrimitive>(); 146 for (Long id : potentiallyDeleted) { 147 OsmPrimitive primitive = ds.getPrimitiveById(id); 179 for (OsmPrimitive primitive : potentiallyDeleted) { 148 180 if (primitive != null) { 149 181 toSelect.add(primitive); … … 167 199 * @param potentiallyDeleted a set of primitives (given by their ids) 168 200 */ 169 protected void handlePotentiallyDeletedPrimitives(Set< Long> potentiallyDeleted) {201 protected void handlePotentiallyDeletedPrimitives(Set<OsmPrimitive> potentiallyDeleted) { 170 202 String [] options = { 171 203 "Check on the server", … … 197 229 ); 198 230 switch(ret) { 199 case JOptionPane.CLOSED_OPTION: return; 200 case JOptionPane.NO_OPTION: return; 201 case JOptionPane.YES_OPTION: updatePotentiallyDeletedPrimitives(potentiallyDeleted); break; 202 } 203 } 204 205 /** 206 * replies true, if the primitive with id <code>id</code> was downloaded into the 207 * dataset <code>ds</code> 208 * 209 * @param id the id 210 * @param ds the dataset 211 * @return true, if the primitive with id <code>id</code> was downloaded into the 212 * dataset <code>ds</code>; false otherwise 213 */ 214 protected boolean wasDownloaded(long id, DataSet ds) { 215 OsmPrimitive primitive = ds.getPrimitiveById(id); 216 return primitive != null; 217 } 218 219 /** 220 * replies true, if the primitive with id <code>id</code> was downloaded into the 221 * dataset of one of the download tasks 222 * 223 * @param id the id 224 * @return true, if the primitive with id <code>id</code> was downloaded into the 225 * dataset of one of the download tasks 226 * 227 */ 228 public boolean wasDownloaded(long id) { 229 for (DownloadTask task : osmTasks) { 230 if(task instanceof DownloadOsmTask) { 231 DataSet ds = ((DownloadOsmTask)task).getDownloadedData(); 232 if(wasDownloaded(id,ds)) return true; 233 } 234 } 235 return false; 231 case JOptionPane.CLOSED_OPTION: return; 232 case JOptionPane.NO_OPTION: return; 233 case JOptionPane.YES_OPTION: updatePotentiallyDeletedPrimitives(potentiallyDeleted); break; 234 } 236 235 } 237 236 … … 241 240 * @return the set of primitive ids which have been downloaded by this task list 242 241 */ 243 public Set< Long> getDownloadedIds() {244 HashSet< Long> ret = new HashSet<Long>();242 public Set<OsmPrimitive> getDownloadedPrimitives() { 243 HashSet<OsmPrimitive> ret = new HashSet<OsmPrimitive>(); 245 244 for (DownloadTask task : osmTasks) { 246 245 if(task instanceof DownloadOsmTask) { 247 246 DataSet ds = ((DownloadOsmTask)task).getDownloadedData(); 248 247 if (ds != null) { 249 ret.addAll(ds.getPrimitiveIds()); 248 ret.addAll(ds.nodes); 249 ret.addAll(ds.ways); 250 ret.addAll(ds.relations); 250 251 } 251 252 } -
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r2070 r2077 313 313 * 314 314 * @param id the id, > 0 required 315 * @param type the type of the primitive. Must not be null. 315 316 * @return the primitive 316 317 * @exception IllegalArgumentException thrown, if id <= 0 317 */ 318 public OsmPrimitive getPrimitiveById(long id) { 318 * @exception IllegalArgumentException thrown, if type is null 319 * @exception IllegalArgumentException thrown, if type is neither NODE, or WAY or RELATION 320 */ 321 public OsmPrimitive getPrimitiveById(long id, OsmPrimitiveType type) { 319 322 if (id <= 0) 320 323 throw new IllegalArgumentException(tr("parameter {0} > 0 required. Got {1}.", "id", id)); 321 for (OsmPrimitive primitive : nodes) { 322 if (primitive.getId() == id) return primitive; 323 } 324 for (OsmPrimitive primitive : ways) { 325 if (primitive.getId() == id) return primitive; 326 } 327 for (OsmPrimitive primitive : relations) { 324 if (id <= 0) 325 throw new IllegalArgumentException(tr("paramete''{0}'' must not be null", "type")); 326 Collection<? extends OsmPrimitive> primitives = null; 327 switch(type) { 328 case NODE: primitives = nodes; break; 329 case WAY: primitives = ways; break; 330 case RELATION: primitives = relations; break; 331 case CHANGESET: throw new IllegalArgumentException(tr("unsupported value ''{0}'' or parameter ''{1}''", type, "type")); 332 } 333 for (OsmPrimitive primitive : primitives) { 328 334 if (primitive.getId() == id) return primitive; 329 335 } … … 341 347 for (OsmPrimitive primitive : relations) { 342 348 ret.add(primitive.getId()); 343 }344 return ret;345 }346 347 /**348 * Replies the set of ids of all complete primitives (i.e. those with349 * ! primitive.incomplete)350 *351 * @return the set of ids of all complete primitives352 */353 public Set<Long> getCompletePrimitiveIds() {354 HashSet<Long> ret = new HashSet<Long>();355 for (OsmPrimitive primitive : nodes) {356 if (!primitive.incomplete) {357 ret.add(primitive.getId());358 }359 }360 for (OsmPrimitive primitive : ways) {361 if (! primitive.incomplete) {362 ret.add(primitive.getId());363 }364 }365 for (OsmPrimitive primitive : relations) {366 if (! primitive.incomplete) {367 ret.add(primitive.getId());368 }369 349 } 370 350 return ret; -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitiveType.java
r1989 r2077 39 39 } 40 40 41 public static OsmPrimitiveType from(String value) { 42 if (value == null) return null; 43 for (OsmPrimitiveType type: values()){ 44 if (type.getAPIName().equalsIgnoreCase(value)) 45 return type; 46 } 47 return null; 48 } 49 41 50 } -
trunk/src/org/openstreetmap/josm/data/osm/Relation.java
r2070 r2077 112 112 */ 113 113 public Relation() { 114 114 super(0); 115 115 } 116 116 -
trunk/src/org/openstreetmap/josm/data/osm/Way.java
r2070 r2077 3 3 4 4 import java.util.ArrayList; 5 5 6 import java.util.Arrays; 6 7 import java.util.Collection; … … 10 11 import org.openstreetmap.josm.tools.CopyList; 11 12 import org.openstreetmap.josm.tools.Pair; 13 import static org.openstreetmap.josm.tools.I18n.tr; 12 14 13 15 /** … … 123 125 */ 124 126 public Way(){ 127 super(0); 125 128 } 126 129 … … 197 200 } 198 201 199 public void addNode(Node n) { 202 /** 203 * Adds a node to the end of the list of nodes. Ignored, if n is null. 204 * 205 * @param n the node. Ignored, if null. 206 * @throws IllegalStateException thrown, if this way is marked as incomplete. We can't add a node 207 * to an incomplete way 208 */ 209 public void addNode(Node n) throws IllegalStateException { 210 if (n==null) return; 211 if (incomplete) 212 throw new IllegalStateException(tr("can't add node {0} to incomplete way {1}", n.getId(), getId())); 200 213 if (incomplete) return; 201 214 clearCached(); … … 203 216 } 204 217 205 public void addNode(int offs, Node n) { 206 if (incomplete) return; 218 /** 219 * Adds a node at position offs. 220 * 221 * @param int offs the offset 222 * @param n the node. Ignored, if null. 223 * @throws IllegalStateException thrown, if this way is marked as incomplete. We can't add a node 224 * to an incomplete way 225 * @throws IndexOutOfBoundsException thrown if offs is out of bounds 226 */ 227 public void addNode(int offs, Node n) throws IllegalStateException, IndexOutOfBoundsException { 228 if (n==null) return; 229 if (incomplete) 230 throw new IllegalStateException(tr("can't add node {0} to incomplete way {1}", n.getId(), getId())); 207 231 clearCached(); 208 232 nodes.add(offs, n); -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java
r2070 r2077 21 21 import org.openstreetmap.josm.data.osm.Node; 22 22 import org.openstreetmap.josm.data.osm.OsmPrimitive; 23 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 23 24 import org.openstreetmap.josm.data.osm.Relation; 24 25 import org.openstreetmap.josm.data.osm.RelationMember; … … 86 87 public Object getValueAt(int rowIndex, int columnIndex) { 87 88 switch (columnIndex) { 88 89 90 91 92 93 89 case 0: 90 return members.get(rowIndex).getRole(); 91 case 1: 92 return members.get(rowIndex).getMember(); 93 case 2: 94 return linked(rowIndex); 94 95 } 95 96 // should not happen … … 201 202 continue; 202 203 } 203 OsmPrimitive primitive = ds.getPrimitiveById(member.getMember().getId() );204 OsmPrimitive primitive = ds.getPrimitiveById(member.getMember().getId(), OsmPrimitiveType.from(member.getMember())); 204 205 if (primitive != null) { 205 206 member.member = primitive; -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ParentRelationLoadingTask.java
r2070 r2077 14 14 import org.openstreetmap.josm.data.osm.DataSet; 15 15 import org.openstreetmap.josm.data.osm.DataSource; 16 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 16 17 import org.openstreetmap.josm.data.osm.Relation; 17 18 import org.openstreetmap.josm.data.osm.visitor.MergeVisitor; … … 150 151 parents.clear(); 151 152 for (Relation parent : referrers.relations) { 152 parents.add((Relation)getLayer().data.getPrimitiveById(parent.getId() ));153 parents.add((Relation)getLayer().data.getPrimitiveById(parent.getId(),OsmPrimitiveType.RELATION)); 153 154 } 154 155 if (continuation != null) { -
trunk/src/org/openstreetmap/josm/io/MultiFetchServerObjectReader.java
r2070 r2077 110 110 * id=<code>id</code> 111 111 */ 112 protected void remember(DataSet ds, long id ) throws IllegalArgumentException, NoSuchElementException{112 protected void remember(DataSet ds, long id, OsmPrimitiveType type) throws IllegalArgumentException, NoSuchElementException{ 113 113 if (ds == null) 114 114 throw new IllegalArgumentException(tr("parameter ''{0}'' must not be null", "ds")); 115 115 if (id <= 0) return; 116 OsmPrimitive primitive = ds.getPrimitiveById(id );116 OsmPrimitive primitive = ds.getPrimitiveById(id, type); 117 117 if (primitive == null) 118 118 throw new NoSuchElementException(tr("no primitive with id {0} in local dataset. Can't infer primitive type", id)); … … 122 122 123 123 /** 124 * appends a list of ids to the list of ids which will be fetched from the server. ds must 125 * include an {@see OsmPrimitive} for each id in ids. 126 * 127 * id is ignored if id <= 0. 128 * 129 * @param ds the dataset 130 * @param ids the list of ids 124 * appends a {@see Node}s id to the list of ids which will be fetched from the server. 125 * 126 * @param node the node (ignored, if null) 131 127 * @return this 132 128 * 133 129 */ 134 public MultiFetchServerObjectReader append(DataSet ds, long ... ids) { 135 if (ids == null) return this; 136 for (int i=0; i < ids.length; i++) { 137 remember(ds, ids[i]); 138 } 139 return this; 140 } 141 142 /** 143 * appends a collection of ids to the list of ids which will be fetched from the server. ds must 144 * include an {@see OsmPrimitive} for each id in ids. 145 * 146 * id is ignored if id <= 0. 147 * 148 * @param ds the dataset 149 * @param ids the collection of ids 150 * @return this 151 * 152 */ 153 public MultiFetchServerObjectReader append(DataSet ds, Collection<Long> ids) { 154 if (ids == null) return null; 155 for (long id: ids) { 156 append(ds,id); 130 public MultiFetchServerObjectReader append(DataSet ds, long id, OsmPrimitiveType type) { 131 switch(type) { 132 case NODE: 133 Node n = (Node)ds.getPrimitiveById(id,type); 134 append(n); 135 break; 136 case WAY: 137 Way w= (Way)ds.getPrimitiveById(id,type); 138 append(w); 139 break; 140 case RELATION: 141 Relation r = (Relation)ds.getPrimitiveById(id,type); 142 append(r); 143 break; 157 144 } 158 145 return this; … … 376 363 String msg = ""; 377 364 switch(type) { 378 379 380 365 case NODE: msg = tr("Fetching node with id {0} from ''{1}''", id, OsmApi.getOsmApi().getBaseUrl()); break; 366 case WAY: msg = tr("Fetching way with id {0} from ''{1}''", id, OsmApi.getOsmApi().getBaseUrl()); break; 367 case RELATION: msg = tr("Fetching relation with id {0} from ''{1}''", id, OsmApi.getOsmApi().getBaseUrl()); break; 381 368 } 382 369 progressMonitor.setCustomText(msg); … … 414 401 String msg = ""; 415 402 switch(type) { 416 417 418 403 case NODE: msg = tr("Fetching a package of nodes from ''{0}''", OsmApi.getOsmApi().getBaseUrl()); break; 404 case WAY: msg = tr("Fetching a package of ways from ''{0}''", OsmApi.getOsmApi().getBaseUrl()); break; 405 case RELATION: msg = tr("Fetching a package of relations from ''{0}''", OsmApi.getOsmApi().getBaseUrl()); break; 419 406 } 420 407 progressMonitor.setCustomText(msg); -
trunk/test/functional/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMergerTest.java
r2041 r2077 26 26 Node my = new Node(1); 27 27 my.setCoor(new LatLon(1,1)); 28 my. deleted = true;28 my.setDeleted(true); 29 29 30 30 Node their = new Node(2); -
trunk/test/functional/org/openstreetmap/josm/io/MultiFetchServerObjectReaderTest.java
r2072 r2077 28 28 import org.openstreetmap.josm.data.osm.Node; 29 29 import org.openstreetmap.josm.data.osm.OsmPrimitive; 30 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 30 31 import org.openstreetmap.josm.data.osm.Relation; 31 32 import org.openstreetmap.josm.data.osm.RelationMember; … … 247 248 while(it.hasNext()) { 248 249 Node n1 = it.next(); 249 Node n2 = (Node)ds.getPrimitiveById(n1. id);250 Node n2 = (Node)ds.getPrimitiveById(n1.getId(), OsmPrimitiveType.NODE); 250 251 assertNotNull(n2); 251 252 assertEquals(n2.get("name"),n2.get("name")); … … 266 267 while(it.hasNext()) { 267 268 Way w1 = it.next(); 268 Way w2 = (Way)ds.getPrimitiveById(w1. id);269 Way w2 = (Way)ds.getPrimitiveById(w1.getId(), OsmPrimitiveType.WAY); 269 270 assertNotNull(w2); 270 271 assertEquals(w2.getNodesCount(), w1.getNodesCount()); … … 286 287 while(it.hasNext()) { 287 288 Relation r1 = it.next(); 288 Relation r2 = (Relation)ds.getPrimitiveById(r1. id);289 Relation r2 = (Relation)ds.getPrimitiveById(r1.getId(), OsmPrimitiveType.RELATION); 289 290 assertNotNull(r2); 290 291 assertEquals(r2.getMembersCount(), r1.getMembersCount()); … … 306 307 while(it.hasNext()) { 307 308 Node n1 = it.next(); 308 Node n2 = (Node)ds.getPrimitiveById(n1. id);309 Node n2 = (Node)ds.getPrimitiveById(n1.getId(), OsmPrimitiveType.NODE); 309 310 assertNotNull(n2); 310 311 assertEquals(n2.get("name"),n2.get("name")); … … 327 328 while(it.hasNext()) { 328 329 Node n1 = it.next(); 329 Node n2 = (Node)ds.getPrimitiveById(n1. id);330 Node n2 = (Node)ds.getPrimitiveById(n1.getId(), OsmPrimitiveType.NODE); 330 331 assertNotNull(n2); 331 332 assertEquals(n2.get("name"),n2.get("name")); -
trunk/test/functional/org/openstreetmap/josm/io/OsmServerBackreferenceReaderTest.java
r2072 r2077 27 27 import org.openstreetmap.josm.data.osm.Node; 28 28 import org.openstreetmap.josm.data.osm.OsmPrimitive; 29 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 29 30 import org.openstreetmap.josm.data.osm.Relation; 30 31 import org.openstreetmap.josm.data.osm.RelationMember; … … 253 254 assertEquals(0, referers.relations.size()); 254 255 for (Way way: referers.ways) { 255 assertEquals(w. id, way.id);256 assertEquals(w.getId(), way.getId()); 256 257 assertEquals(false, way.incomplete); 257 258 } … … 272 273 assertEquals(0, referers.relations.size()); 273 274 for (Way way: referers.ways) { 274 assertEquals(w. id, way.id);275 assertEquals(w.getId(), way.getId()); 275 276 assertEquals(false, way.incomplete); 276 277 assertEquals(10, w.getNodesCount()); … … 319 320 Set<Long> expectedNodeIds = new HashSet<Long>(); 320 321 for (Way way: referers.ways) { 321 Way orig = (Way)ds.getPrimitiveById(way. id);322 Way orig = (Way)ds.getPrimitiveById(way.getId(), OsmPrimitiveType.WAY); 322 323 for(Node n: orig.getNodes()) { 323 expectedNodeIds.add(n. id);324 expectedNodeIds.add(n.getId()); 324 325 } 325 326 } 326 327 assertEquals(expectedNodeIds.size(), referers.nodes.size()); 327 328 for (Node n : referers.nodes) { 328 assertEquals(true, expectedNodeIds.contains(n. id));329 assertEquals(true, expectedNodeIds.contains(n.getId())); 329 330 } 330 331 … … 352 353 assertNotNull(r); 353 354 assertEquals(false, r.incomplete); 354 referringRelationsIds.add(r. id);355 referringRelationsIds.add(r.getId()); 355 356 r = lookupRelation(referers, 7); 356 357 assertNotNull(r); 357 358 assertEquals(false, r.incomplete); 358 referringRelationsIds.add(r. id);359 referringRelationsIds.add(r.getId()); 359 360 r = lookupRelation(referers, 8); 360 361 assertNotNull(r); 361 362 assertEquals(false, r.incomplete); 362 referringRelationsIds.add(r. id);363 referringRelationsIds.add(r.getId()); 363 364 r = lookupRelation(referers, 9); 364 365 assertNotNull(r); 365 366 assertEquals(false, r.incomplete); 366 referringRelationsIds.add(r. id);367 referringRelationsIds.add(r.getId()); 367 368 368 369 for (Relation r1: referers.relations) { 369 if (! referringRelationsIds.contains(r1. id)) {370 if (! referringRelationsIds.contains(r1.getId())) { 370 371 assertEquals(true, r1.incomplete); 371 372 } … … 378 379 for (RelationMember m : lookupRelation(ds, 6).getMembers()) { 379 380 if (m.isWay()) { 380 expectedWayIds.add(m.getMember(). id);381 expectedWayIds.add(m.getMember().getId()); 381 382 } 382 383 } 383 384 for (RelationMember m : lookupRelation(ds, 7).getMembers()) { 384 385 if (m.isWay()) { 385 expectedWayIds.add(m.getMember(). id);386 expectedWayIds.add(m.getMember().getId()); 386 387 } 387 388 } 388 389 for (RelationMember m : lookupRelation(ds, 8).getMembers()) { 389 390 if (m.isWay()) { 390 expectedWayIds.add(m.getMember(). id);391 expectedWayIds.add(m.getMember().getId()); 391 392 } 392 393 } 393 394 for (RelationMember m : lookupRelation(ds, 9).getMembers()) { 394 395 if (m.isWay()) { 395 expectedWayIds.add(m.getMember(). id);396 expectedWayIds.add(m.getMember().getId()); 396 397 } 397 398 } … … 399 400 assertEquals(expectedWayIds.size(), referers.ways.size()); 400 401 for (Way w1 : referers.ways) { 401 assertEquals(true, expectedWayIds.contains(w1. id));402 assertEquals(true, expectedWayIds.contains(w1.getId())); 402 403 assertEquals(true, w1.incomplete); 403 404 } … … 412 413 if (way == null)return ret; 413 414 for (Node n: way.getNodes()) { 414 ret.add(n. id);415 ret.add(n.getId()); 415 416 } 416 417 return ret; … … 422 423 for (RelationMember m: r.getMembers()) { 423 424 if (m.isNode()) { 424 ret.add(m.getMember(). id);425 ret.add(m.getMember().getId()); 425 426 } else if (m.isWay()) { 426 427 ret.addAll(getNodeIdsInWay(m.getWay())); … … 448 449 assertNotNull(r); 449 450 assertEquals(false, r.incomplete); 450 referringRelationsIds.add(r. id);451 referringRelationsIds.add(r.getId()); 451 452 r = lookupRelation(referers, 7); 452 453 assertNotNull(r); 453 454 assertEquals(false, r.incomplete); 454 referringRelationsIds.add(r. id);455 referringRelationsIds.add(r.getId()); 455 456 r = lookupRelation(referers, 8); 456 457 assertNotNull(r); 457 458 assertEquals(false, r.incomplete); 458 referringRelationsIds.add(r. id);459 referringRelationsIds.add(r.getId()); 459 460 r = lookupRelation(referers, 9); 460 461 assertNotNull(r); 461 462 assertEquals(false, r.incomplete); 462 referringRelationsIds.add(r. id);463 referringRelationsIds.add(r.getId()); 463 464 464 465 // all relations are fully loaded … … 474 475 for (RelationMember m : lookupRelation(ds, 6).getMembers()) { 475 476 if (m.isWay()) { 476 expectedWayIds.add(m.getMember(). id);477 expectedWayIds.add(m.getMember().getId()); 477 478 } 478 479 } 479 480 for (RelationMember m : lookupRelation(ds, 7).getMembers()) { 480 481 if (m.isWay()) { 481 expectedWayIds.add(m.getMember(). id);482 expectedWayIds.add(m.getMember().getId()); 482 483 } 483 484 } 484 485 for (RelationMember m : lookupRelation(ds, 8).getMembers()) { 485 486 if (m.isWay()) { 486 expectedWayIds.add(m.getMember(). id);487 expectedWayIds.add(m.getMember().getId()); 487 488 } 488 489 } 489 490 for (RelationMember m : lookupRelation(ds, 9).getMembers()) { 490 491 if (m.isWay()) { 491 expectedWayIds.add(m.getMember(). id);492 expectedWayIds.add(m.getMember().getId()); 492 493 } 493 494 } 494 495 for (long id : expectedWayIds) { 495 Way w = (Way)referers.getPrimitiveById(id );496 Way w = (Way)referers.getPrimitiveById(id, OsmPrimitiveType.WAY); 496 497 assertNotNull(w); 497 498 assertEquals(false, w.incomplete); … … 506 507 assertEquals(expectedNodeIds.size(), referers.nodes.size()); 507 508 for(Node n : referers.nodes) { 508 assertEquals(true, expectedNodeIds.contains(n. id));509 assertEquals(true, expectedNodeIds.contains(n.getId())); 509 510 } 510 511 } -
trunk/test/unit/org/openstreetmap/josm/data/osm/visitor/MergeSourceBuildingVisitorTest.java
r1951 r2077 14 14 import org.openstreetmap.josm.data.osm.Node; 15 15 import org.openstreetmap.josm.data.osm.OsmPrimitive; 16 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 16 17 import org.openstreetmap.josm.data.osm.Relation; 17 18 import org.openstreetmap.josm.data.osm.RelationMember; … … 50 51 assertEquals(2, hull.nodes.size()); 51 52 52 OsmPrimitive p = hull.getPrimitiveById(1 );53 OsmPrimitive p = hull.getPrimitiveById(1,OsmPrimitiveType.NODE); 53 54 assertNotNull(p); 54 55 assertEquals(p.getClass(), Node.class); 55 56 56 p = hull.getPrimitiveById(3 );57 p = hull.getPrimitiveById(3,OsmPrimitiveType.NODE); 57 58 assertNull(p); 58 59 … … 71 72 Node n2 = new Node(2); 72 73 Way w1 = new Way(3); 74 w1.incomplete = false; 73 75 w1.addNode(n1); 74 76 w1.addNode(n2); … … 84 86 assertEquals(2, hull.nodes.size()); 85 87 86 OsmPrimitive p = hull.getPrimitiveById(1 );88 OsmPrimitive p = hull.getPrimitiveById(1,OsmPrimitiveType.NODE); 87 89 assertNotNull(p); 88 90 assertEquals(p.getClass(), Node.class); 89 91 90 p = hull.getPrimitiveById(2 );92 p = hull.getPrimitiveById(2,OsmPrimitiveType.NODE); 91 93 assertNotNull(p); 92 94 assertEquals(p.getClass(), Node.class); 93 95 94 p = hull.getPrimitiveById(3 );96 p = hull.getPrimitiveById(3, OsmPrimitiveType.WAY); 95 97 assertNotNull(p); 96 98 assertEquals(p.getClass(), Way.class); … … 103 105 Node n2 = new Node(2); 104 106 Way w1 = new Way(3); 107 w1.incomplete = false; 105 108 w1.addNode(n1); 106 109 w1.addNode(n2); … … 116 119 assertEquals(2, hull.nodes.size()); 117 120 118 OsmPrimitive p = hull.getPrimitiveById(1 );121 OsmPrimitive p = hull.getPrimitiveById(1,OsmPrimitiveType.NODE); 119 122 assertNotNull(p); 120 123 assertEquals(p.getClass(), Node.class); 121 124 122 p = hull.getPrimitiveById(2 );125 p = hull.getPrimitiveById(2, OsmPrimitiveType.NODE); 123 126 assertNotNull(p); 124 127 assertEquals(p.getClass(), Node.class); 125 128 126 p = hull.getPrimitiveById(3 );129 p = hull.getPrimitiveById(3,OsmPrimitiveType.WAY); 127 130 assertNotNull(p); 128 131 assertEquals(p.getClass(), Way.class); … … 142 145 assertEquals(1, hull.ways.size()); 143 146 144 OsmPrimitive p = hull.getPrimitiveById(3 );147 OsmPrimitive p = hull.getPrimitiveById(3, OsmPrimitiveType.WAY); 145 148 assertNotNull(p); 146 149 assertEquals(p.getClass(), Way.class); … … 154 157 Node n20 = new Node(20); 155 158 r1.addMember(new RelationMember("node-20",n20)); 159 r1.incomplete = false; 156 160 Way w30 = new Way(30); 161 w30.incomplete = false; 157 162 Node n21; 158 163 w30.addNode(n21 = new Node(21)); … … 177 182 assertEquals(2, hull.relations.size()); 178 183 179 OsmPrimitive p = hull.getPrimitiveById(1 );184 OsmPrimitive p = hull.getPrimitiveById(1, OsmPrimitiveType.RELATION); 180 185 assertNotNull(p); 181 186 assertEquals(p.getClass(), Relation.class); 182 187 183 Way w = (Way)hull.getPrimitiveById(30 );188 Way w = (Way)hull.getPrimitiveById(30,OsmPrimitiveType.WAY); 184 189 assertNotNull(w); 185 190 assertEquals(2, w.getNodesCount()); 186 Node n = (Node)hull.getPrimitiveById(21 );191 Node n = (Node)hull.getPrimitiveById(21, OsmPrimitiveType.NODE); 187 192 assertNotNull(n); 188 193 assertTrue(w.containsNode(n)); 189 194 190 n = (Node)hull.getPrimitiveById(22 );195 n = (Node)hull.getPrimitiveById(22,OsmPrimitiveType.NODE); 191 196 assertNotNull(n); 192 197 assertTrue(w.containsNode(n)); 193 198 194 Relation r = (Relation)hull.getPrimitiveById(40 );195 assertNotNull(r); 196 197 r = (Relation)hull.getPrimitiveById(1 );199 Relation r = (Relation)hull.getPrimitiveById(40,OsmPrimitiveType.RELATION); 200 assertNotNull(r); 201 202 r = (Relation)hull.getPrimitiveById(1, OsmPrimitiveType.RELATION); 198 203 assertNotNull(r); 199 204 assertEquals(3, r.getMembersCount()); 200 RelationMember m = new RelationMember("node-20", hull.getPrimitiveById(20 ));201 assertTrue(r.getMembers().contains(m)); 202 m = new RelationMember("way-30", hull.getPrimitiveById(30 ));203 assertTrue(r.getMembers().contains(m)); 204 m = new RelationMember("relation-40", hull.getPrimitiveById(40 ));205 RelationMember m = new RelationMember("node-20", hull.getPrimitiveById(20,OsmPrimitiveType.NODE)); 206 assertTrue(r.getMembers().contains(m)); 207 m = new RelationMember("way-30", hull.getPrimitiveById(30, OsmPrimitiveType.WAY)); 208 assertTrue(r.getMembers().contains(m)); 209 m = new RelationMember("relation-40", hull.getPrimitiveById(40, OsmPrimitiveType.RELATION)); 205 210 assertTrue(r.getMembers().contains(m)); 206 211 } … … 213 218 r1.addMember(new RelationMember("node-20",n20)); 214 219 Way w30 = new Way(30); 220 w30.incomplete = false; 215 221 Node n21; 216 222 w30.addNode(n21 = new Node(21)); … … 235 241 assertEquals(2, hull.relations.size()); 236 242 237 OsmPrimitive p = hull.getPrimitiveById(1 );243 OsmPrimitive p = hull.getPrimitiveById(1, OsmPrimitiveType.RELATION); 238 244 assertNotNull(p); 239 245 assertEquals(p.getClass(), Relation.class); 240 246 241 Way w = (Way)hull.getPrimitiveById(30 );247 Way w = (Way)hull.getPrimitiveById(30, OsmPrimitiveType.WAY); 242 248 assertNotNull(w); 243 249 assertTrue(w.incomplete); 244 250 245 251 246 Node n = (Node)hull.getPrimitiveById(21 );252 Node n = (Node)hull.getPrimitiveById(21,OsmPrimitiveType.NODE); 247 253 assertNull(n); 248 254 249 n = (Node)hull.getPrimitiveById(22 );255 n = (Node)hull.getPrimitiveById(22, OsmPrimitiveType.NODE); 250 256 assertNull(n); 251 257 252 Relation r = (Relation)hull.getPrimitiveById(40 );258 Relation r = (Relation)hull.getPrimitiveById(40, OsmPrimitiveType.RELATION); 253 259 assertNotNull(r); 254 260 assertTrue(r.incomplete); 255 261 256 r = (Relation)hull.getPrimitiveById(1 );262 r = (Relation)hull.getPrimitiveById(1, OsmPrimitiveType.RELATION); 257 263 assertNotNull(r); 258 264 assertEquals(3, r.getMembersCount()); 259 RelationMember m = new RelationMember("node-20", hull.getPrimitiveById(20 ));260 assertTrue(r.getMembers().contains(m)); 261 m = new RelationMember("way-30", hull.getPrimitiveById(30 ));262 assertTrue(r.getMembers().contains(m)); 263 m = new RelationMember("relation-40", hull.getPrimitiveById(40 ));265 RelationMember m = new RelationMember("node-20", hull.getPrimitiveById(20, OsmPrimitiveType.NODE)); 266 assertTrue(r.getMembers().contains(m)); 267 m = new RelationMember("way-30", hull.getPrimitiveById(30, OsmPrimitiveType.WAY)); 268 assertTrue(r.getMembers().contains(m)); 269 m = new RelationMember("relation-40", hull.getPrimitiveById(40, OsmPrimitiveType.RELATION)); 264 270 assertTrue(r.getMembers().contains(m)); 265 271 } … … 272 278 Node n20 = new Node(new LatLon(20.0,20.0)); 273 279 n20.put("name", "n20"); 274 r1.getMembers().add(new RelationMember("node-20",n20)); 280 r1.addMember(new RelationMember("node-20",n20)); 281 275 282 Way w30 = new Way(); 276 283 w30.put("name", "w30"); … … 285 292 r40.put("name", "r40"); 286 293 r1.addMember(new RelationMember("relation-40", r40)); 294 287 295 source.nodes.add(n20); 288 296 source.nodes.add(n21); … … 343 351 assertEquals(1, hull.relations.size()); 344 352 345 Relation r = (Relation)hull.getPrimitiveById(1 );353 Relation r = (Relation)hull.getPrimitiveById(1, OsmPrimitiveType.RELATION); 346 354 assertNotNull(r); 347 355 assertEquals(1, r.getMembersCount()); … … 385 393 assertEquals(2, hull.relations.size()); 386 394 387 r1 = (Relation)hull.getPrimitiveById(1 );395 r1 = (Relation)hull.getPrimitiveById(1, OsmPrimitiveType.RELATION); 388 396 assertNotNull(r1); 389 r2 = (Relation)hull.getPrimitiveById(2 );397 r2 = (Relation)hull.getPrimitiveById(2, OsmPrimitiveType.RELATION); 390 398 assertNotNull(r2); 391 399 assertEquals(1, r1.getMembersCount()); -
trunk/test/unit/org/openstreetmap/josm/data/osm/visitor/MergeVisitorTest.java
r2071 r2077 24 24 import org.openstreetmap.josm.data.osm.Node; 25 25 import org.openstreetmap.josm.data.osm.OsmPrimitive; 26 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 26 27 import org.openstreetmap.josm.data.osm.Relation; 27 28 import org.openstreetmap.josm.data.osm.RelationMember; … … 97 98 visitor.merge(); 98 99 99 Node n2 = (Node)my.getPrimitiveById(1 );100 Node n2 = (Node)my.getPrimitiveById(1, OsmPrimitiveType.NODE); 100 101 assertTrue(visitor.getConflicts().isEmpty()); 101 102 assertEquals(1, n2.getId()); … … 133 134 visitor.merge(); 134 135 135 Node n2 = (Node)my.getPrimitiveById(1 );136 Node n2 = (Node)my.getPrimitiveById(1, OsmPrimitiveType.NODE); 136 137 assertTrue(visitor.getConflicts().isEmpty()); 137 138 assertEquals(1, n2.getId()); … … 173 174 visitor.merge(); 174 175 175 Node n2 = (Node)my.getPrimitiveById(1 );176 Node n2 = (Node)my.getPrimitiveById(1, OsmPrimitiveType.NODE); 176 177 assertEquals(1,visitor.getConflicts().size()); 177 178 assertEquals(n, n2); … … 209 210 visitor.merge(); 210 211 211 Node n2 = (Node)my.getPrimitiveById(1 );212 Node n2 = (Node)my.getPrimitiveById(1, OsmPrimitiveType.NODE); 212 213 assertEquals(1,visitor.getConflicts().size()); 213 214 assertEquals(n, n2); … … 242 243 visitor.merge(); 243 244 244 Node n2 = (Node)my.getPrimitiveById(1 );245 Node n2 = (Node)my.getPrimitiveById(1,OsmPrimitiveType.NODE); 245 246 assertEquals(1,visitor.getConflicts().size()); 246 247 assertEquals(true, n2.isVisible()); … … 271 272 visitor.merge(); 272 273 273 Node n2 = (Node)my.getPrimitiveById(1 );274 Node n2 = (Node)my.getPrimitiveById(1, OsmPrimitiveType.NODE); 274 275 assertEquals(0,visitor.getConflicts().size()); 275 276 assertEquals(true, n2.isVisible()); … … 354 355 visitor.merge(); 355 356 356 Node n2 = (Node)my.getPrimitiveById(1 );357 Node n2 = (Node)my.getPrimitiveById(1,OsmPrimitiveType.NODE); 357 358 assertEquals(0,visitor.getConflicts().size()); 358 359 assertEquals(2,my.nodes.size()); … … 501 502 visitor.merge(); 502 503 503 Way merged = (Way)my.getPrimitiveById(3 );504 Way merged = (Way)my.getPrimitiveById(3, OsmPrimitiveType.WAY); 504 505 assertEquals(0,visitor.getConflicts().size()); 505 506 assertEquals("value1",merged.get("key1")); … … 571 572 visitor.merge(); 572 573 573 Way merged = (Way)my.getPrimitiveById(3 );574 Way merged = (Way)my.getPrimitiveById(3, OsmPrimitiveType.WAY); 574 575 assertEquals(0,visitor.getConflicts().size()); 575 576 assertEquals(3,merged.getId()); … … 642 643 visitor.merge(); 643 644 644 Way merged = (Way)my.getPrimitiveById(3 );645 Way merged = (Way)my.getPrimitiveById(3, OsmPrimitiveType.WAY); 645 646 assertEquals(1,visitor.getConflicts().size()); 646 647 assertEquals(3,merged.getId()); … … 690 691 visitor.merge(); 691 692 692 Way merged = (Way)my.getPrimitiveById(3 );693 Way merged = (Way)my.getPrimitiveById(3, OsmPrimitiveType.WAY); 693 694 assertEquals(1,visitor.getConflicts().size()); 694 695 assertEquals(true, visitor.getConflicts().hasConflictForMy(myWay)); … … 851 852 assertEquals(0,visitor.getConflicts().size()); 852 853 853 Way myWay = (Way)my.getPrimitiveById(4 );854 Way myWay = (Way)my.getPrimitiveById(4,OsmPrimitiveType.WAY); 854 855 assertEquals(2, myWay.getNodesCount()); 855 856 856 Node n = (Node)my.getPrimitiveById(1 );857 Node n = (Node)my.getPrimitiveById(1,OsmPrimitiveType.NODE); 857 858 assertTrue(n != null); 858 859 } … … 906 907 assertEquals(0,visitor.getConflicts().size()); 907 908 908 Relation r = (Relation)my.getPrimitiveById(4 );909 Relation r = (Relation)my.getPrimitiveById(4,OsmPrimitiveType.RELATION); 909 910 assertEquals(2, r.getMembersCount()); 910 911 911 Node n = (Node)my.getPrimitiveById(1 );912 Node n = (Node)my.getPrimitiveById(1,OsmPrimitiveType.NODE); 912 913 assertTrue(n != null); 913 914 } … … 942 943 assertEquals(0,visitor.getConflicts().size()); 943 944 944 OsmPrimitive p= my.getPrimitiveById(1 );945 OsmPrimitive p= my.getPrimitiveById(1, OsmPrimitiveType.NODE); 945 946 assertNotNull(p); 946 947 assertTrue(p.incomplete); 947 p= my.getPrimitiveById(2 );948 p= my.getPrimitiveById(2, OsmPrimitiveType.NODE); 948 949 assertNotNull(p); 949 950 assertTrue(p.incomplete); 950 p= my.getPrimitiveById(3 );951 p= my.getPrimitiveById(3, OsmPrimitiveType.WAY); 951 952 assertNotNull(p); 952 953 assertTrue(p.incomplete); 953 954 954 Way w = (Way)my.getPrimitiveById(3 );955 Way w = (Way)my.getPrimitiveById(3, OsmPrimitiveType.WAY); 955 956 assertNotNull(w); 956 957 assertTrue(p.incomplete); … … 1005 1006 assertEquals(0,visitor.getConflicts().size()); 1006 1007 1007 OsmPrimitive p= my.getPrimitiveById(1 );1008 OsmPrimitive p= my.getPrimitiveById(1, OsmPrimitiveType.NODE); 1008 1009 assertNotNull(p); 1009 1010 assertTrue(!p.incomplete); 1010 p= my.getPrimitiveById(2 );1011 p= my.getPrimitiveById(2, OsmPrimitiveType.NODE); 1011 1012 assertNotNull(p); 1012 1013 assertTrue(!p.incomplete); 1013 p= my.getPrimitiveById(3 );1014 p= my.getPrimitiveById(3,OsmPrimitiveType.WAY); 1014 1015 assertNotNull(p); 1015 1016 assertTrue(!p.incomplete); 1016 1017 1017 Way w = (Way)my.getPrimitiveById(3 );1018 Way w = (Way)my.getPrimitiveById(3,OsmPrimitiveType.WAY); 1018 1019 assertNotNull(w); 1019 1020 assertTrue(!p.incomplete); -
trunk/test/unit/org/openstreetmap/josm/gui/conflict/nodes/NodeListMergeModelTest.java
r1954 r2077 65 65 66 66 Way myWay = new Way(1); 67 myWay.incomplete = false; 67 68 myWay.addNode(new Node(2)); 68 69 myWay.addNode(new Node(3)); … … 75 76 76 77 assertEquals(1, mergedNodes.size()); 77 assertEquals(2, mergedNodes.get(0). id);78 assertEquals(2, mergedNodes.get(0).getId()); 78 79 79 80 DefaultListSelectionModel mergedSelection = inspectListSelectionModel(model, "mergedEntriesSelectionModel"); … … 89 90 90 91 Way myWay = new Way(1); 92 myWay.incomplete = false; 91 93 myWay.addNode(new Node(2)); 92 94 myWay.addNode(new Node(3)); … … 102 104 mergedNodes = inspectNodeList(model, "Merged"); 103 105 assertEquals(2, mergedNodes.size()); 104 assertEquals(2, mergedNodes.get(0). id);105 assertEquals(1, mergedNodes.get(1). id);106 assertEquals(2, mergedNodes.get(0).getId()); 107 assertEquals(1, mergedNodes.get(1).getId()); 106 108 107 109 DefaultListSelectionModel mergedSelection = inspectListSelectionModel(model, "mergedEntriesSelectionModel"); … … 120 122 121 123 Way myWay = new Way(1); 122 myWay.addNode(new Node(2)); 123 myWay.addNode(new Node(3)); 124 Way theirWay = new Way(1); 124 myWay.incomplete = false; 125 myWay.addNode(new Node(2)); 126 myWay.addNode(new Node(3)); 127 Way theirWay = new Way(1); 128 125 129 126 130 model.populate(myWay, theirWay); … … 133 137 mergedNodes = inspectNodeList(model, "Merged"); 134 138 assertEquals(2, mergedNodes.size()); 135 assertEquals(3, mergedNodes.get(0). id); // my node 3 at position 0136 assertEquals(1, mergedNodes.get(1). id); // already merged node 1 at position 1139 assertEquals(3, mergedNodes.get(0).getId()); // my node 3 at position 0 140 assertEquals(1, mergedNodes.get(1).getId()); // already merged node 1 at position 1 137 141 138 142 DefaultListSelectionModel mergedSelection = inspectListSelectionModel(model, "mergedEntriesSelectionModel"); … … 146 150 147 151 Way myWay = new Way(1); 152 myWay.incomplete = false; 148 153 myWay.addNode(new Node(2)); 149 154 myWay.addNode(new Node(3)); … … 160 165 mergedNodes = inspectNodeList(model, "Merged"); 161 166 assertEquals(3, mergedNodes.size()); 162 assertEquals(3, mergedNodes.get(0). id); // my node 3 at position 0163 assertEquals(4, mergedNodes.get(1). id); // my node 4 at position 1164 assertEquals(1, mergedNodes.get(2). id); // already merged node 1 at position 2167 assertEquals(3, mergedNodes.get(0).getId()); // my node 3 at position 0 168 assertEquals(4, mergedNodes.get(1).getId()); // my node 4 at position 1 169 assertEquals(1, mergedNodes.get(2).getId()); // already merged node 1 at position 2 165 170 166 171 DefaultListSelectionModel mergedSelection = inspectListSelectionModel(model, "mergedEntriesSelectionModel"); … … 174 179 175 180 Way myWay = new Way(1); 181 myWay.incomplete = false; 176 182 myWay.addNode(new Node(2)); 177 183 myWay.addNode(new Node(3)); … … 184 190 185 191 assertEquals(1, mergedNodes.size()); 186 assertEquals(2, mergedNodes.get(0). id);192 assertEquals(2, mergedNodes.get(0).getId()); 187 193 188 194 DefaultListSelectionModel mergedSelection = inspectListSelectionModel(model, "mergedEntriesSelectionModel"); … … 195 201 196 202 Way myWay = new Way(1); 203 myWay.incomplete = false; 197 204 myWay.addNode(new Node(2)); 198 205 myWay.addNode(new Node(3)); … … 208 215 mergedNodes = inspectNodeList(model, "Merged"); 209 216 assertEquals(2, mergedNodes.size()); 210 assertEquals(1, mergedNodes.get(0). id); // already merged node 1 at position 0211 assertEquals(2, mergedNodes.get(1). id); // copied node 2 at position 1217 assertEquals(1, mergedNodes.get(0).getId()); // already merged node 1 at position 0 218 assertEquals(2, mergedNodes.get(1).getId()); // copied node 2 at position 1 212 219 213 220 DefaultListSelectionModel mergedSelection = inspectListSelectionModel(model, "mergedEntriesSelectionModel"); … … 221 228 222 229 Way myWay = new Way(1); 230 myWay.incomplete = false; 223 231 myWay.addNode(new Node(2)); 224 232 myWay.addNode(new Node(3)); … … 234 242 mergedNodes = inspectNodeList(model, "Merged"); 235 243 assertEquals(2, mergedNodes.size()); 236 assertEquals(1, mergedNodes.get(0). id); // already merged node 1 at position 0237 assertEquals(3, mergedNodes.get(1). id); // my node 3 at position 1244 assertEquals(1, mergedNodes.get(0).getId()); // already merged node 1 at position 0 245 assertEquals(3, mergedNodes.get(1).getId()); // my node 3 at position 1 238 246 239 247 … … 248 256 249 257 Way myWay = new Way(1); 258 myWay.incomplete = false; 250 259 myWay.addNode(new Node(2)); 251 260 myWay.addNode(new Node(3)); … … 262 271 mergedNodes = inspectNodeList(model, "Merged"); 263 272 assertEquals(3, mergedNodes.size()); 264 assertEquals(1, mergedNodes.get(0). id); // already merged node 1 at position 0265 assertEquals(3, mergedNodes.get(1). id); // my node 3 at position 1266 assertEquals(4, mergedNodes.get(2). id); // my node 4 at position 2273 assertEquals(1, mergedNodes.get(0).getId()); // already merged node 1 at position 0 274 assertEquals(3, mergedNodes.get(1).getId()); // my node 3 at position 1 275 assertEquals(4, mergedNodes.get(2).getId()); // my node 4 at position 2 267 276 268 277 … … 280 289 281 290 Way myWay = new Way(1); 291 myWay.incomplete = false; 282 292 myWay.addNode(new Node(1)); 283 293 myWay.addNode(new Node(2)); … … 293 303 294 304 assertEquals(4, mergedNodes.size()); 295 assertEquals(10, mergedNodes.get(0). id); // already merged node296 assertEquals(1, mergedNodes.get(1). id); // copied node 1 at position 1297 assertEquals(11, mergedNodes.get(2). id); // already merged node298 assertEquals(12, mergedNodes.get(3). id); // already merged node305 assertEquals(10, mergedNodes.get(0).getId()); // already merged node 306 assertEquals(1, mergedNodes.get(1).getId()); // copied node 1 at position 1 307 assertEquals(11, mergedNodes.get(2).getId()); // already merged node 308 assertEquals(12, mergedNodes.get(3).getId()); // already merged node 299 309 300 310 DefaultListSelectionModel mergedSelection = inspectListSelectionModel(model, "mergedEntriesSelectionModel"); … … 308 318 309 319 Way myWay = new Way(1); 320 myWay.incomplete = false; 310 321 myWay.addNode(new Node(1)); 311 322 myWay.addNode(new Node(2)); … … 321 332 322 333 assertEquals(5, mergedNodes.size()); 323 assertEquals(1, mergedNodes.get(0). id); // copied node 1 at position 0324 assertEquals(2, mergedNodes.get(1). id); // copied node 2 at position 1325 assertEquals(10, mergedNodes.get(2). id); // already merged node326 assertEquals(11, mergedNodes.get(3). id); // already merged node327 assertEquals(12, mergedNodes.get(4). id); // already merged node334 assertEquals(1, mergedNodes.get(0).getId()); // copied node 1 at position 0 335 assertEquals(2, mergedNodes.get(1).getId()); // copied node 2 at position 1 336 assertEquals(10, mergedNodes.get(2).getId()); // already merged node 337 assertEquals(11, mergedNodes.get(3).getId()); // already merged node 338 assertEquals(12, mergedNodes.get(4).getId()); // already merged node 328 339 329 340 DefaultListSelectionModel mergedSelection = inspectListSelectionModel(model, "mergedEntriesSelectionModel"); … … 336 347 337 348 Way myWay = new Way(1); 349 myWay.incomplete = false; 338 350 myWay.addNode(new Node(1)); 339 351 myWay.addNode(new Node(2)); … … 369 381 370 382 Way myWay = new Way(1); 383 myWay.incomplete = false; 371 384 myWay.addNode(new Node(1)); 372 385 myWay.addNode(new Node(2)); … … 382 395 383 396 assertEquals(4, mergedNodes.size()); 384 assertEquals(10, mergedNodes.get(0). id); // already merged node385 assertEquals(11, mergedNodes.get(1). id); // already merged node386 assertEquals(1, mergedNodes.get(2). id); // copied node 1 at position 2387 assertEquals(12, mergedNodes.get(3). id); // already merged node397 assertEquals(10, mergedNodes.get(0).getId()); // already merged node 398 assertEquals(11, mergedNodes.get(1).getId()); // already merged node 399 assertEquals(1, mergedNodes.get(2).getId()); // copied node 1 at position 2 400 assertEquals(12, mergedNodes.get(3).getId()); // already merged node 388 401 389 402 DefaultListSelectionModel mergedSelection = inspectListSelectionModel(model, "mergedEntriesSelectionModel"); … … 397 410 398 411 Way myWay = new Way(1); 412 myWay.incomplete = false; 399 413 myWay.addNode(new Node(1)); 400 414 myWay.addNode(new Node(2)); … … 411 425 412 426 assertEquals(5, mergedNodes.size()); 413 assertEquals(10, mergedNodes.get(0). id); // already merged node414 assertEquals(11, mergedNodes.get(1). id); // already merged node415 assertEquals(12, mergedNodes.get(2). id); // already merged node416 assertEquals(1, mergedNodes.get(3). id); // copied node 1 at position 3417 assertEquals(2, mergedNodes.get(4). id); // copied node 2 at position 4427 assertEquals(10, mergedNodes.get(0).getId()); // already merged node 428 assertEquals(11, mergedNodes.get(1).getId()); // already merged node 429 assertEquals(12, mergedNodes.get(2).getId()); // already merged node 430 assertEquals(1, mergedNodes.get(3).getId()); // copied node 1 at position 3 431 assertEquals(2, mergedNodes.get(4).getId()); // copied node 2 at position 4 418 432 419 433 … … 427 441 428 442 Way myWay = new Way(1); 443 myWay.incomplete = false; 429 444 myWay.addNode(new Node(1)); 430 445 myWay.addNode(new Node(2)); … … 441 456 442 457 assertEquals(5, mergedNodes.size()); 443 assertEquals(10, mergedNodes.get(0). id); // already merged node444 assertEquals(1, mergedNodes.get(1). id); // copied node 1 at position 1445 assertEquals(3, mergedNodes.get(2). id); // copied node 3 at position 2446 assertEquals(11, mergedNodes.get(3). id); // already merged node447 assertEquals(12, mergedNodes.get(4). id); // already merged node458 assertEquals(10, mergedNodes.get(0).getId()); // already merged node 459 assertEquals(1, mergedNodes.get(1).getId()); // copied node 1 at position 1 460 assertEquals(3, mergedNodes.get(2).getId()); // copied node 3 at position 2 461 assertEquals(11, mergedNodes.get(3).getId()); // already merged node 462 assertEquals(12, mergedNodes.get(4).getId()); // already merged node 448 463 449 464 DefaultListSelectionModel mergedSelection = inspectListSelectionModel(model, "mergedEntriesSelectionModel"); … … 456 471 457 472 Way myWay = new Way(1); 473 myWay.incomplete = false; 458 474 myWay.addNode(new Node(1)); 459 475 myWay.addNode(new Node(2)); … … 489 505 490 506 Way myWay = new Way(1); 507 myWay.incomplete = false; 491 508 myWay.addNode(new Node(1)); 492 509 myWay.addNode(new Node(2)); … … 502 519 503 520 assertEquals(3, mergedNodes.size()); 504 assertEquals(11, mergedNodes.get(0). id);505 assertEquals(10, mergedNodes.get(1). id);506 assertEquals(12, mergedNodes.get(2). id);521 assertEquals(11, mergedNodes.get(0).getId()); 522 assertEquals(10, mergedNodes.get(1).getId()); 523 assertEquals(12, mergedNodes.get(2).getId()); 507 524 508 525 DefaultListSelectionModel mergedSelection = inspectListSelectionModel(model, "mergedEntriesSelectionModel"); … … 515 532 516 533 Way myWay = new Way(1); 534 myWay.incomplete = false; 517 535 myWay.addNode(new Node(1)); 518 536 myWay.addNode(new Node(2)); … … 530 548 531 549 assertEquals(5, mergedNodes.size()); 532 assertEquals(11, mergedNodes.get(0). id);533 assertEquals(10, mergedNodes.get(1). id);534 assertEquals(12, mergedNodes.get(2). id);535 assertEquals(14, mergedNodes.get(3). id);536 assertEquals(13, mergedNodes.get(4). id);550 assertEquals(11, mergedNodes.get(0).getId()); 551 assertEquals(10, mergedNodes.get(1).getId()); 552 assertEquals(12, mergedNodes.get(2).getId()); 553 assertEquals(14, mergedNodes.get(3).getId()); 554 assertEquals(13, mergedNodes.get(4).getId()); 537 555 538 556 DefaultListSelectionModel mergedSelection = inspectListSelectionModel(model, "mergedEntriesSelectionModel"); … … 545 563 546 564 Way myWay = new Way(1); 565 myWay.incomplete = false; 547 566 myWay.addNode(new Node(1)); 548 567 myWay.addNode(new Node(2)); … … 560 579 561 580 assertEquals(5, mergedNodes.size()); 562 assertEquals(11, mergedNodes.get(0). id);563 assertEquals(12, mergedNodes.get(1). id);564 assertEquals(13, mergedNodes.get(2). id);565 assertEquals(14, mergedNodes.get(3). id);566 assertEquals(10, mergedNodes.get(4). id);581 assertEquals(11, mergedNodes.get(0).getId()); 582 assertEquals(12, mergedNodes.get(1).getId()); 583 assertEquals(13, mergedNodes.get(2).getId()); 584 assertEquals(14, mergedNodes.get(3).getId()); 585 assertEquals(10, mergedNodes.get(4).getId()); 567 586 568 587 DefaultListSelectionModel mergedSelection = inspectListSelectionModel(model, "mergedEntriesSelectionModel"); … … 578 597 579 598 Way myWay = new Way(1); 599 myWay.incomplete = false; 580 600 myWay.addNode(new Node(1)); 581 601 myWay.addNode(new Node(2)); … … 591 611 592 612 assertEquals(3, mergedNodes.size()); 593 assertEquals(10, mergedNodes.get(0). id);594 assertEquals(12, mergedNodes.get(1). id);595 assertEquals(11, mergedNodes.get(2). id);613 assertEquals(10, mergedNodes.get(0).getId()); 614 assertEquals(12, mergedNodes.get(1).getId()); 615 assertEquals(11, mergedNodes.get(2).getId()); 596 616 597 617 DefaultListSelectionModel mergedSelection = inspectListSelectionModel(model, "mergedEntriesSelectionModel"); … … 604 624 605 625 Way myWay = new Way(1); 626 myWay.incomplete = false; 606 627 myWay.addNode(new Node(1)); 607 628 myWay.addNode(new Node(2)); … … 619 640 620 641 assertEquals(5, mergedNodes.size()); 621 assertEquals(10, mergedNodes.get(0). id);622 assertEquals(12, mergedNodes.get(1). id);623 assertEquals(11, mergedNodes.get(2). id);624 assertEquals(14, mergedNodes.get(3). id);625 assertEquals(13, mergedNodes.get(4). id);642 assertEquals(10, mergedNodes.get(0).getId()); 643 assertEquals(12, mergedNodes.get(1).getId()); 644 assertEquals(11, mergedNodes.get(2).getId()); 645 assertEquals(14, mergedNodes.get(3).getId()); 646 assertEquals(13, mergedNodes.get(4).getId()); 626 647 627 648 DefaultListSelectionModel mergedSelection = inspectListSelectionModel(model, "mergedEntriesSelectionModel"); … … 634 655 635 656 Way myWay = new Way(1); 657 myWay.incomplete = false; 636 658 myWay.addNode(new Node(1)); 637 659 myWay.addNode(new Node(2)); … … 649 671 650 672 assertEquals(5, mergedNodes.size()); 651 assertEquals(10, mergedNodes.get(0). id);652 assertEquals(14, mergedNodes.get(1). id);653 assertEquals(11, mergedNodes.get(2). id);654 assertEquals(12, mergedNodes.get(3). id);655 assertEquals(13, mergedNodes.get(4). id);673 assertEquals(10, mergedNodes.get(0).getId()); 674 assertEquals(14, mergedNodes.get(1).getId()); 675 assertEquals(11, mergedNodes.get(2).getId()); 676 assertEquals(12, mergedNodes.get(3).getId()); 677 assertEquals(13, mergedNodes.get(4).getId()); 656 678 657 679 DefaultListSelectionModel mergedSelection = inspectListSelectionModel(model, "mergedEntriesSelectionModel");
Note:
See TracChangeset
for help on using the changeset viewer.