Changeset 1937 in josm
- Timestamp:
- 2009-08-08T20:07:43+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java
r1930 r1937 94 94 } 95 95 for (RelationMember rm : r.getMembers()) { 96 if (rm. member instanceof Way) {96 if (rm.isWay()) { 97 97 for(Way w : selectedWays) { 98 if (rm. member== w) {98 if (rm.getMember() == w) { 99 99 Pair<Relation,String> pair = new Pair<Relation,String>(r, rm.getRole()); 100 100 HashSet<Way> waylinks = new HashSet<Way>(); … … 231 231 // Don't copy the member if it to one of our ways, just keep a 232 232 // note to re-add it later on. 233 if (selectedWays.contains(rm. member)) {233 if (selectedWays.contains(rm.getMember())) { 234 234 rolesToReAdd.add(rm.getRole()); 235 235 } else { -
trunk/src/org/openstreetmap/josm/actions/CopyAction.java
r1925 r1937 97 97 List<RelationMember> members = new ArrayList<RelationMember>(); 98 98 for (RelationMember m : e.getMembers()) { 99 if (! map.containsKey(m. member)) {100 m. member.visit(this);99 if (! map.containsKey(m.getMember())) { 100 m.getMember().visit(this); 101 101 } 102 RelationMember mnew = new RelationMember(m); 103 mnew.member = map.get(m.member); 102 RelationMember mnew = new RelationMember(m.getRole(), map.get(m.getMember())); 104 103 members.add(mnew); 105 104 } -
trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java
r1930 r1937 131 131 } 132 132 for (RelationMember rm : r.getMembers()) { 133 if (rm. member instanceof Node) {133 if (rm.isNode()) { 134 134 for (Node n : allNodes) { 135 if (rm. member== n) {135 if (rm.getMember() == n) { 136 136 Pair<Relation,String> pair = new Pair<Relation,String>(r, rm.getRole()); 137 137 HashSet<Node> nodelinks = new HashSet<Node>(); … … 281 281 // Don't copy the member if it points to one of our nodes, 282 282 // just keep a note to re-add it later on. 283 if (allNodes.contains(rm. member)) {283 if (allNodes.contains(rm.getMember())) { 284 284 rolesToReAdd.add(rm.getRole()); 285 285 } else { -
trunk/src/org/openstreetmap/josm/command/DeleteCommand.java
r1930 r1937 165 165 String role = new String(); 166 166 for (RelationMember m : ref.getMembers()) { 167 if (m. member== osm) {167 if (m.getMember() == osm) { 168 168 role = m.getRole(); 169 169 break; -
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r1925 r1937 404 404 while(it.hasNext()) { 405 405 RelationMember member = it.next(); 406 if (member. member.equals(primitive)) {406 if (member.getMember().equals(primitive)) { 407 407 it.remove(); 408 408 } -
trunk/src/org/openstreetmap/josm/data/osm/RelationMember.java
r1930 r1937 34 34 return role != null && !"".equals(role); 35 35 } 36 37 /** 38 * 39 * @return True if member is relation 40 * @since 1937 41 */ 42 public boolean isRelation() { 43 return member instanceof Relation; 44 } 45 46 /** 47 * 48 * @return True if member is way 49 * @since 1937 50 */ 51 public boolean isWay() { 52 return member instanceof Way; 53 } 54 55 /** 56 * 57 * @return True if member is node 58 * @since 1937 59 */ 60 public boolean isNode() { 61 return member instanceof Node; 62 } 63 64 /** 65 * 66 * @return Member as relation 67 * @since 1937 68 */ 69 public Relation getRelation() { 70 return (Relation)member; 71 } 72 73 /** 74 * 75 * @return Member as way 76 * @since 1937 77 */ 78 public Way getWay() { 79 return (Way)member; 80 } 81 82 /** 83 * 84 * @return Member as node 85 * @since 1937 86 */ 87 public Node getNode() { 88 return (Node)member; 89 } 90 91 /** 92 * 93 * @return Member 94 * @since 1937 95 */ 96 public OsmPrimitive getMember() { 97 return member; 98 } 99 36 100 37 101 /** -
trunk/src/org/openstreetmap/josm/data/osm/visitor/AllNodesVisitor.java
r1925 r1937 44 44 public void visit(Relation e) { 45 45 for (RelationMember m : e.getMembers()) 46 if (m. member instanceof Node) visit((Node)m.member);46 if (m.isNode()) visit(m.getNode()); 47 47 } 48 48 /** -
trunk/src/org/openstreetmap/josm/data/osm/visitor/BoundingXYVisitor.java
r1925 r1937 34 34 // only use direct members 35 35 for (RelationMember m : e.getMembers()) { 36 if (! (m.member instanceof Relation)) {37 m. member.visit(this);36 if (!m.isRelation()) { 37 m.getMember().visit(this); 38 38 } 39 39 } -
trunk/src/org/openstreetmap/josm/data/osm/visitor/CollectBackReferencesVisitor.java
r1925 r1937 74 74 if (r.incomplete || r.deleted) continue; 75 75 for (RelationMember m : r.getMembers()) { 76 if (m. member== p) {76 if (m.getMember() == p) { 77 77 if (!data.contains(r)) { 78 78 data.add(r); -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java
r1930 r1937 487 487 for (RelationMember m : r.getMembers()) 488 488 { 489 if (m.member != null && !m.member.incomplete && !m.member.deleted 490 && m.member instanceof Node) 491 { 492 drawSelectedMember(m.member, styles != null ? getPrimitiveStyle(m.member) : null, true, true); 489 if (m.isNode() && !m.getMember().incomplete && !m.getMember().deleted) 490 { 491 drawSelectedMember(m.getMember(), styles != null ? getPrimitiveStyle(m.getMember()) : null, true, true); 493 492 } 494 493 } … … 509 508 for (RelationMember m : r.getMembers()) 510 509 { 511 if (m.member != null && !m.member.incomplete && !m.member.deleted 512 && m.member instanceof Way) /* nodes drawn on second call */ 513 { 514 drawSelectedMember(m.member, styles != null ? getPrimitiveStyle(m.member) 510 if (m.isWay() && !m.getMember().incomplete && !m.getMember().deleted) /* nodes drawn on second call */ 511 { 512 drawSelectedMember(m.getMember(), styles != null ? getPrimitiveStyle(m.getMember()) 515 513 : null, true, true); 516 514 } … … 537 535 // System.out.println("member " + m.member + " selected " + r.selected); 538 536 539 if(m.member == null) 537 if(m.getMember() == null) 538 // TODO Nullable member will not be allowed after RelationMember.member is encalupsed 540 539 r.putError(tr("Empty member in relation."), true); 541 else if(m. member.deleted)540 else if(m.getMember().deleted) 542 541 r.putError(tr("Deleted member ''{0}'' in relation.", 543 m. member.getName()), true);544 else if(m. member.incomplete)542 m.getMember().getName()), true); 543 else if(m.getMember().incomplete) 545 544 { 546 545 return; … … 548 547 else 549 548 { 550 if(m. member instanceof Way)551 { 552 Way w = (Way) m.member;549 if(m.isWay()) 550 { 551 Way w = m.getWay(); 553 552 if(w.getNodesCount() < 2) 554 553 { … … 577 576 r.putError(tr("Unknown role ''{0}''.", m.getRole()), true); 578 577 } 579 else if(m. member instanceof Node)580 { 581 Node n = (Node) m.member;578 else if(m.isNode()) 579 { 580 Node n = m.getNode(); 582 581 if("via".equals(m.getRole())) 583 582 { … … 591 590 } 592 591 else 593 r.putError(tr("Unknown member type for ''{0}''.", m. member.getName()), true);592 r.putError(tr("Unknown member type for ''{0}''.", m.getMember().getName()), true); 594 593 } 595 594 } … … 784 783 for (RelationMember m : r.getMembers()) 785 784 { 786 if(m.member == null) 785 if(m.getMember() == null) 786 //TODO Remove useless nullcheck when RelationMember.member is encalupsed 787 787 r.putError(tr("Empty member in relation."), true); 788 else if(m. member.deleted)788 else if(m.getMember().deleted) 789 789 r.putError(tr("Deleted member ''{0}'' in relation.", 790 m. member.getName()), true);791 else if(m. member.incomplete)790 m.getMember().getName()), true); 791 else if(m.getMember().incomplete) 792 792 incomplete = true; 793 793 else 794 794 { 795 if(m. member instanceof Way)796 { 797 Way w = (Way) m.member;795 if(m.isWay()) 796 { 797 Way w = m.getWay(); 798 798 if(w.getNodesCount() < 2) 799 799 { … … 812 812 outer.add(w); 813 813 else if(r.isSelected()) 814 drawSelectedMember(m. member, styles != null815 ? getPrimitiveStyle(m. member) : null, true, true);814 drawSelectedMember(m.getMember(), styles != null 815 ? getPrimitiveStyle(m.getMember()) : null, true, true); 816 816 } 817 817 } … … 819 819 { 820 820 r.putError(tr("Non-Way ''{0}'' in multipolygon.", 821 m. member.getName()), true);821 m.getMember().getName()), true); 822 822 } 823 823 } -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MergeSourceBuildingVisitor.java
r1925 r1937 92 92 clone.members.clear(); 93 93 for (RelationMember member: r.getMembers()) { 94 RelationMember cloneMember = new RelationMember(member); 95 cloneMember.member = mappedPrimitives.get(member.member); 94 RelationMember cloneMember = new RelationMember(member.getRole(), mappedPrimitives.get(member.getMember())); 96 95 clone.members.add(cloneMember); 97 96 } … … 190 189 rememberRelationPartial(r); 191 190 for (RelationMember member: r.getMembers()) { 192 if (isAlreadyRemembered(member. member)) {191 if (isAlreadyRemembered(member.getMember())) { 193 192 // referred primitive already remembered 194 193 // 195 194 continue; 196 195 } 197 if (member. member instanceof Node) {198 Node node = (Node)member.member;196 if (member.isNode()) { 197 Node node = member.getNode(); 199 198 if (isInSelectionBase(node)) { 200 199 rememberNode(node); … … 204 203 rememberNodeIncomplete(node); 205 204 } 206 } else if (member. member instanceof Way) {207 Way way = (Way)member.member;205 } else if (member.isWay()) { 206 Way way = member.getWay(); 208 207 if (isInSelectionBase(way)) { 209 208 way.visit(this); … … 213 212 rememberWayIncomplete(way); 214 213 } 215 } else if (member. member instanceof Relation) {216 Relation relation = (Relation)member.member;217 if (isInSelectionBase(member. member)) {214 } else if (member.isRelation()) { 215 Relation relation = member.getRelation(); 216 if (isInSelectionBase(member.getMember())) { 218 217 relation.visit(this); 219 218 } else if (isNew(relation)) { -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MergeVisitor.java
r1926 r1937 193 193 LinkedList<RelationMember> newMembers = new LinkedList<RelationMember>(); 194 194 for (RelationMember myMember : r.getMembers()) { 195 OsmPrimitive mergedMember = merged.get(myMember. member);195 OsmPrimitive mergedMember = merged.get(myMember.getMember()); 196 196 if (mergedMember == null) { 197 197 newMembers.add(myMember); 198 198 } else { 199 199 if (! mergedMember.deleted) { 200 RelationMember newMember = new RelationMember(myMember); 201 newMember.member = mergedMember; 200 RelationMember newMember = new RelationMember(myMember.getRole(), mergedMember); 202 201 newMembers.add(newMember); 203 202 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java
r1925 r1937 191 191 public void visit(Relation e) { 192 192 for (RelationMember em : e.getMembers()) { 193 em. member.visit(this);193 em.getMember().visit(this); 194 194 } 195 195 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ChildRelationBrowser.java
r1925 r1937 366 366 downloadedRelationIds.add(parent.id); 367 367 for (RelationMember member: parent.getMembers()) { 368 if (member. member instanceof Relation) {369 Relation child = (Relation)member.member;368 if (member.isRelation()) { 369 Relation child = member.getRelation(); 370 370 if (!downloadedRelationIds.contains(child)) { 371 371 relationsToDownload.push(child); -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r1927 r1937 55 55 import org.openstreetmap.josm.command.ChangeCommand; 56 56 import org.openstreetmap.josm.command.ConflictAddCommand; 57 import org.openstreetmap.josm.data.SelectionChangedListener;58 57 import org.openstreetmap.josm.data.conflict.Conflict; 59 58 import org.openstreetmap.josm.data.osm.DataSet; … … 933 932 * Selects members in the relation editor which refer to primitives in the current 934 933 * selection of the context layer. 935 * 934 * 936 935 */ 937 936 class SelectedMembersForSelectionAction extends AbstractAction implements TableModelListener { … … 967 966 * Selects primitives in the layer this editor belongs to. The selected primitives are 968 967 * equal to the set of primitives the currently selected relation members refer to. 969 * 968 * 970 969 */ 971 970 class SelectPrimitivesForSelectedMembersAction extends AbstractAction implements ListSelectionListener { … … 1480 1479 Collection<OsmPrimitive> selection = getLayer().data.getSelected(); 1481 1480 for (RelationMember member: r.getMembers()) { 1482 if (selection.contains(member. member)) {1481 if (selection.contains(member.getMember())) { 1483 1482 members.add(member); 1484 1483 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java
r1930 r1937 89 89 return members.get(rowIndex).getRole(); 90 90 case 1: 91 return members.get(rowIndex). member;91 return members.get(rowIndex).getMember(); 92 92 case 2: 93 93 return linked(rowIndex); … … 109 109 110 110 public OsmPrimitive getReferredPrimitive(int idx) { 111 return members.get(idx). member;111 return members.get(idx).getMember(); 112 112 } 113 113 … … 198 198 public void updateMemberReferences(DataSet ds) { 199 199 for (RelationMember member : members) { 200 if (member. member.id == 0) {200 if (member.getMember().id == 0) { 201 201 continue; 202 202 } 203 OsmPrimitive primitive = ds.getPrimitiveById(member. member.id);203 OsmPrimitive primitive = ds.getPrimitiveById(member.getMember().id); 204 204 if (primitive != null) { 205 205 member.member = primitive; … … 215 215 while (it.hasNext()) { 216 216 RelationMember member = it.next(); 217 if (primitives.contains(member. member)) {217 if (primitives.contains(member.getMember())) { 218 218 it.remove(); 219 219 } … … 240 240 public boolean hasIncompleteMembers() { 241 241 for (RelationMember member : members) { 242 if (member. member.incomplete)242 if (member.getMember().incomplete) 243 243 return true; 244 244 } … … 333 333 int count = 0; 334 334 for (RelationMember member : members) { 335 if (member. member.equals(primitive)) {335 if (member.getMember().equals(primitive)) { 336 336 count++; 337 337 } … … 379 379 HashSet<OsmPrimitive> ret = new HashSet<OsmPrimitive>(); 380 380 for (RelationMember m: getSelectedMembers()) { 381 ret.add(m. member);381 ret.add(m.getMember()); 382 382 } 383 383 return ret; … … 393 393 if (referenceSet == null) return null; 394 394 for (RelationMember m: members) { 395 if (referenceSet.contains(m. member)) {396 ret.add(m. member);395 if (referenceSet.contains(m.getMember())) { 396 ret.add(m.getMember()); 397 397 } 398 398 } … … 466 466 return false; 467 467 RelationMember member = members.get(index); 468 if (! (member.member instanceof Relation))468 if (!member.isRelation()) 469 469 return false; 470 Relation r = (Relation) member.member;470 Relation r = member.getRelation(); 471 471 return !r.incomplete; 472 472 } … … 486 486 HashSet<OsmPrimitive> referrers = new HashSet<OsmPrimitive>(); 487 487 for(RelationMember member : members) { 488 referrers.add(member. member);488 referrers.add(member.getMember()); 489 489 } 490 490 Iterator<OsmPrimitive> it = primitives.iterator(); … … 509 509 for (int i=0; i< members.size();i++) { 510 510 RelationMember m = members.get(i); 511 if (primitives.contains(m. member)) {511 if (primitives.contains(m.getMember())) { 512 512 this.getSelectionModel().addSelectionInterval(i,i); 513 513 } … … 541 541 Node result = null; 542 542 543 if (element. member instanceof Way) {544 Way w = (Way) element.member;545 if (linked_element. member instanceof Way) {546 Way x = (Way) linked_element.member;543 if (element.isWay()) { 544 Way w = element.getWay(); 545 if (linked_element.isWay()) { 546 Way x = linked_element.getWay(); 547 547 if ((w.firstNode() == x.firstNode()) || (w.firstNode() == x.lastNode())) { 548 548 result = w.lastNode(); … … 550 550 result = w.firstNode(); 551 551 } 552 } else if (linked_element. member instanceof Node) {553 Node m = (Node) linked_element.member;552 } else if (linked_element.isNode()) { 553 Node m = linked_element.getNode(); 554 554 if (w.firstNode() == m) { 555 555 result = w.lastNode(); … … 558 558 } 559 559 } 560 } else if (element. member instanceof Node) {561 Node n = (Node) element.member;560 } else if (element.isNode()) { 561 Node n = element.getNode(); 562 562 result = n; 563 563 } … … 609 609 // only one element in segment, so try to link against each linkable node of element 610 610 RelationMember m = members.get(segment.getFirst()); 611 if (m. member instanceof Way) {612 Way w = (Way) m.member;611 if (m.isWay()) { 612 Way w = m.getWay(); 613 613 endSearchNode = w.lastNode(); 614 614 if (w.lastNode() != w.firstNode()) … … 616 616 startSearchNode = w.firstNode(); 617 617 } 618 } else if (m. member instanceof Node) {619 Node n = (Node) m.member;618 } else if (m.isNode()) { 619 Node n = m.getNode(); 620 620 endSearchNode = n; 621 621 } … … 687 687 Way way2 = null; 688 688 689 if (m1. member instanceof Way) {690 way1 = (Way) m1.member;691 } 692 if (m2. member instanceof Way) {693 way2 = (Way) m2.member;689 if (m1.isWay()) { 690 way1 = m1.getWay(); 691 } 692 if (m2.isWay()) { 693 way2 = m2.getWay(); 694 694 } 695 695 if ((way1 != null) && (way2 != null)) {
Note:
See TracChangeset
for help on using the changeset viewer.