Changeset 10777 in josm for trunk/src/org
- Timestamp:
- 2016-08-10T23:36:13+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/dialogs/relation
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java
r10700 r10777 46 46 import org.openstreetmap.josm.gui.util.GuiHelper; 47 47 import org.openstreetmap.josm.gui.widgets.OsmPrimitivesTableModel; 48 import org.openstreetmap.josm.tools.bugreport.BugReport; 48 49 49 50 public class MemberTableModel extends AbstractTableModel … … 807 808 808 809 WayConnectionType getWayConnection(int i) { 809 if (connectionType == null) { 810 connectionType = wayConnectionTypeCalculator.updateLinks(members); 811 } 812 return connectionType.get(i); 810 try { 811 if (connectionType == null) { 812 connectionType = wayConnectionTypeCalculator.updateLinks(members); 813 } 814 return connectionType.get(i); 815 } catch (RuntimeException e) { 816 throw BugReport.intercept(e).put("i", i).put("members", members).put("relation", relation); 817 } 813 818 } 814 819 -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculator.java
r10308 r10777 13 13 import org.openstreetmap.josm.data.osm.Way; 14 14 import org.openstreetmap.josm.gui.dialogs.relation.sort.WayConnectionType.Direction; 15 import org.openstreetmap.josm.tools.bugreport.BugReport; 15 16 16 17 public class WayConnectionTypeCalculator { … … 41 42 42 43 for (int i = 0; i < members.size(); ++i) { 43 final RelationMember m = members.get(i); 44 if (!m.isWay() || m.getWay() == null || m.getWay().isIncomplete()) { 45 if (i > 0) { 46 makeLoopIfNeeded(con, i-1); 47 } 48 con.set(i, new WayConnectionType()); 49 firstGroupIdx = i; 50 continue; 51 } 52 53 WayConnectionType wct = new WayConnectionType(false); 54 wct.linkPrev = i > 0 && con.get(i-1) != null && con.get(i-1).isValid(); 55 wct.direction = NONE; 56 57 if (RelationSortUtils.isOneway(m)) { 58 if (lastWct != null && lastWct.isOnewayTail) { 59 wct.isOnewayHead = true; 60 } 61 if (lastBackwardWay == UNCONNECTED && lastForwardWay == UNCONNECTED) { //Beginning of new oneway 62 wct.isOnewayHead = true; 63 lastForwardWay = i-1; 64 lastBackwardWay = i-1; 65 onewayBeginning = true; 66 } 67 } 68 69 if (wct.linkPrev) { 70 if (lastBackwardWay != UNCONNECTED && lastForwardWay != UNCONNECTED) { 71 determineOnewayConnectionType(con, m, i, wct); 72 if (!wct.linkPrev) { 73 firstGroupIdx = i; 74 } 75 } 76 77 if (!RelationSortUtils.isOneway(m) && lastWct != null) { 78 wct.direction = determineDirection(i-1, lastWct.direction, i); 79 wct.linkPrev = wct.direction != NONE; 80 } 81 } 82 83 if (!wct.linkPrev) { 84 wct.direction = determineDirectionOfFirst(i, m); 85 if (RelationSortUtils.isOneway(m)) { 86 wct.isOnewayLoopForwardPart = true; 87 lastForwardWay = i; 88 } 89 } 90 91 wct.linkNext = false; 92 if (lastWct != null) { 93 lastWct.linkNext = wct.linkPrev; 94 } 95 con.set(i, wct); 96 lastWct = wct; 44 try { 45 lastWct = updateLinksFor(con, lastWct, i); 46 } catch (RuntimeException e) { 47 int index = i; 48 throw BugReport.intercept(e).put("i", i).put("member", () -> members.get(index)).put("con", con); 49 } 50 } 51 makeLoopIfNeeded(con, members.size()-1); 52 53 return con; 54 } 55 56 private WayConnectionType updateLinksFor(final List<WayConnectionType> con, WayConnectionType lastWct, int i) { 57 final RelationMember m = members.get(i); 58 if (isNoHandleableWay(m)) { 59 if (i > 0) { 60 makeLoopIfNeeded(con, i-1); 61 } 62 con.set(i, new WayConnectionType()); 63 firstGroupIdx = i; 64 } else { 65 WayConnectionType wct = computeNextWayConnection(con, lastWct, i, m); 97 66 98 67 if (!wct.linkPrev) { … … 102 71 firstGroupIdx = i; 103 72 } 104 } 105 makeLoopIfNeeded(con, members.size()-1); 106 107 return con; 73 lastWct = wct; 74 } 75 return lastWct; 76 } 77 78 private static boolean isNoHandleableWay(final RelationMember m) { 79 return !m.isWay() || m.getWay() == null || m.getWay().isIncomplete(); 80 } 81 82 private WayConnectionType computeNextWayConnection(final List<WayConnectionType> con, WayConnectionType lastWct, int i, 83 final RelationMember m) { 84 WayConnectionType wct = new WayConnectionType(false); 85 wct.linkPrev = i > 0 && con.get(i-1) != null && con.get(i-1).isValid(); 86 wct.direction = NONE; 87 88 if (RelationSortUtils.isOneway(m)) { 89 handleOneway(lastWct, i, wct); 90 } 91 92 if (wct.linkPrev) { 93 if (lastBackwardWay != UNCONNECTED && lastForwardWay != UNCONNECTED) { 94 determineOnewayConnectionType(con, m, i, wct); 95 if (!wct.linkPrev) { 96 firstGroupIdx = i; 97 } 98 } 99 100 if (!RelationSortUtils.isOneway(m) && lastWct != null) { 101 wct.direction = determineDirection(i-1, lastWct.direction, i); 102 wct.linkPrev = wct.direction != NONE; 103 } 104 } 105 106 if (!wct.linkPrev) { 107 wct.direction = determineDirectionOfFirst(i, m); 108 if (RelationSortUtils.isOneway(m)) { 109 wct.isOnewayLoopForwardPart = true; 110 lastForwardWay = i; 111 } 112 } 113 114 wct.linkNext = false; 115 if (lastWct != null) { 116 lastWct.linkNext = wct.linkPrev; 117 } 118 con.set(i, wct); 119 return wct; 120 } 121 122 private void handleOneway(WayConnectionType lastWct, int i, WayConnectionType wct) { 123 if (lastWct != null && lastWct.isOnewayTail) { 124 wct.isOnewayHead = true; 125 } 126 if (lastBackwardWay == UNCONNECTED && lastForwardWay == UNCONNECTED) { //Beginning of new oneway 127 wct.isOnewayHead = true; 128 lastForwardWay = i-1; 129 lastBackwardWay = i-1; 130 onewayBeginning = true; 131 } 108 132 } 109 133
Note:
See TracChangeset
for help on using the changeset viewer.