Changeset 33500 in osm
- Timestamp:
- 2017-08-15T23:51:45+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/actions/SortPTStopsAction.java
r33492 r33500 142 142 }); 143 143 144 Way prev = null; 145 for (RelationMember wm : wayMembers) { 144 for (int i = 0; i < wayMembers.size(); i++) { 145 RelationMember wm = wayMembers.get(i); 146 Way prev = null; 147 Way next = null; 148 if (i > 0) { 149 RelationMember wmp = wayMembers.get(i-1); 150 if (wmp.getType() == OsmPrimitiveType.WAY) 151 prev = wmp.getWay(); 152 } 153 if (i < wayMembers.size() - 1) { 154 RelationMember wmn = wayMembers.get(i+1); 155 if (wmn.getType() == OsmPrimitiveType.WAY) 156 next = wmn.getWay(); 157 } 158 146 159 if (wm.getType() == OsmPrimitiveType.WAY) { 147 160 Way curr = wm.getWay(); … … 149 162 if (stps != null) { 150 163 if (stps.size() > 1) 151 stps = sortSameWayStops(stps, curr, prev );164 stps = sortSameWayStops(stps, curr, prev, next); 152 165 stps.forEach(stop -> { 153 166 if (stop != null) { … … 159 172 }); 160 173 } 161 prev = curr;162 174 } 163 175 } … … 166 178 } 167 179 168 private List<PTStop> sortSameWayStops(List<PTStop> stps, Way way, Way prev ) {180 private List<PTStop> sortSameWayStops(List<PTStop> stps, Way way, Way prev, Way next) { 169 181 Map<Node, List<PTStop>> closeNodes = new HashMap<>(); 170 182 List<PTStop> noLocationStops = new ArrayList<>(); … … 182 194 } 183 195 184 boolean reverse = prev != null && 185 (prev.firstNode().equals(way.lastNode()) 186 || prev.lastNode().equals(way.lastNode())); 196 boolean reverse = false; 197 198 if (prev != null) { 199 reverse = prev.firstNode().equals(way.lastNode()) 200 || prev.lastNode().equals(way.lastNode()); 201 } else if (next != null) { 202 reverse = next.firstNode().equals(way.firstNode()) 203 || next.lastNode().equals(way.firstNode()); 204 } 187 205 188 206 if (reverse)
Note:
See TracChangeset
for help on using the changeset viewer.