Changeset 33509 in osm for applications/editors/josm/plugins/pt_assistant/src/org
- Timestamp:
- 2017-08-21T10:53:02+02:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant
- Files:
-
- 2 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/PTAssistantPlugin.java
r33473 r33509 24 24 import org.openstreetmap.josm.plugins.pt_assistant.actions.EditHighlightedRelationsAction; 25 25 import org.openstreetmap.josm.plugins.pt_assistant.actions.RepeatLastFixAction; 26 import org.openstreetmap.josm.plugins.pt_assistant.actions.SortPT StopsAction;26 import org.openstreetmap.josm.plugins.pt_assistant.actions.SortPTRouteMembersAction; 27 27 import org.openstreetmap.josm.plugins.pt_assistant.actions.SplitRoundaboutAction; 28 28 import org.openstreetmap.josm.plugins.pt_assistant.data.PTRouteSegment; … … 74 74 editHighlightedRelationsMenu = MainMenu.add(Main.main.menu.toolsMenu, editHighlightedRelationsAction); 75 75 MainMenu.add(Main.main.menu.toolsMenu, new SplitRoundaboutAction()); 76 MainMenu.add(Main.main.menu.toolsMenu, new SortPT StopsAction());76 MainMenu.add(Main.main.menu.toolsMenu, new SortPTRouteMembersAction()); 77 77 MainMenu.add(Main.main.menu.toolsMenu, new CreatePlatformNodeAction()); 78 78 } -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/actions/SortPTRouteMembersAction.java
r33506 r33509 36 36 37 37 /** 38 * Sorts the stop positions in a PT route according to the assigned ways 38 * Sorts the members of a PT route. It orders first the ways, then the stops 39 * according to the assigned ways 39 40 * 40 41 * @author giacomo 41 42 * 42 43 */ 43 public class SortPT StopsAction extends JosmAction {44 45 private static final String ACTION_NAME = "Sort PT Stops";44 public class SortPTRouteMembersAction extends JosmAction { 45 46 private static final String ACTION_NAME = "Sort PT Route Members"; 46 47 47 48 /** 48 * Creates a new SortPT StopsAction49 * Creates a new SortPTRouteMembersAction 49 50 */ 50 public SortPT StopsAction() {51 super(ACTION_NAME, "icons/sortpt stops", ACTION_NAME, null, true);51 public SortPTRouteMembersAction() { 52 super(ACTION_NAME, "icons/sortptroutemembers", ACTION_NAME, null, true); 52 53 } 53 54 … … 86 87 private void continueAfterDownload(Relation rel) { 87 88 Relation newRel = new Relation(rel); 88 sortPT Stops(newRel);89 sortPTRouteMembers(newRel); 89 90 Main.main.undoRedo.add(new ChangeCommand(rel, newRel)); 90 91 } 91 92 92 public void sortPTStops(Relation rel) { 93 /*** 94 * Sort the members of the PT route. 95 * 96 * @param rel route to be sorted 97 */ 98 public static void sortPTRouteMembers(Relation rel) { 99 if (!RouteUtils.isVersionTwoPTRoute(rel)) { 100 return; 101 } 102 93 103 List<RelationMember> members = new ArrayList<>(); 94 104 List<RelationMember> oldMembers = rel.getMembers(); … … 184 194 } 185 195 186 private List<PTStop> sortSameWayStops(List<PTStop> stps, Way way, Way prev, Way next) { 196 private static List<PTStop> sortSameWayStops(List<PTStop> stps, Way way, Way prev, Way next) { 187 197 Map<Node, List<PTStop>> closeNodes = new HashMap<>(); 188 198 List<PTStop> noLocationStops = new ArrayList<>(); … … 218 228 } 219 229 220 private List<PTStop> getSortedStops(List<Node> nodes, 230 private static List<PTStop> getSortedStops(List<Node> nodes, 221 231 Map<Node, List<PTStop>> closeNodes) { 222 232 … … 241 251 } 242 252 243 private Node findClosestNode(PTStop stop, List<Node> nodes) { 253 private static Node findClosestNode(PTStop stop, List<Node> nodes) { 244 254 EastNorth stopEN = stopEastNorth(stop); 245 255 if (stopEN == null) … … 257 267 } 258 268 259 private EastNorth stopEastNorth(PTStop stop) { 269 private static EastNorth stopEastNorth(PTStop stop) { 260 270 if (stop.getStopPosition() != null) 261 271 return stop.getStopPosition().getEastNorth(); -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/RouteChecker.java
r33508 r33509 26 26 import org.openstreetmap.josm.gui.dialogs.relation.sort.WayConnectionType.Direction; 27 27 import org.openstreetmap.josm.gui.dialogs.relation.sort.WayConnectionTypeCalculator; 28 import org.openstreetmap.josm.plugins.pt_assistant.actions.SortPTRouteMembersAction; 28 29 import org.openstreetmap.josm.plugins.pt_assistant.data.PTRouteDataManager; 29 30 import org.openstreetmap.josm.plugins.pt_assistant.data.PTStop; … … 328 329 Relation originalRelation = (Relation) primitives.iterator().next(); 329 330 330 // separate ways from stops (because otherwise the order of331 // stops/platforms can be messed up by the sorter:332 List<RelationMember> members = originalRelation.getMembers();333 final List<RelationMember> stops = new ArrayList<>();334 final List<RelationMember> ways = new ArrayList<>();335 for (RelationMember member : members) {336 if (RouteUtils.isPTWay(member)) {337 if ("".equals(member.getRole())) {338 ways.add(member);339 } else {340 RelationMember modifiedMember = new RelationMember("", member.getWay());341 ways.add(modifiedMember);342 }343 } else { // stops:344 if ("stop_positon".equals(member.getRole())) {345 // it is not expected that stop_positions could346 // be relations347 if (member.getType().equals(OsmPrimitiveType.NODE)) {348 RelationMember modifiedMember = new RelationMember("stop", member.getNode());349 stops.add(modifiedMember);350 } else { // if it is a primitive of type way:351 RelationMember modifiedMember = new RelationMember("stop", member.getWay());352 stops.add(modifiedMember);353 }354 } else { // if it is not a stop_position:355 stops.add(member);356 }357 }358 }359 360 // sort the ways:361 RelationSorter sorter = new RelationSorter();362 List<RelationMember> sortedWays = sorter.sortMembers(ways);363 364 331 // create a new relation to pass to the command: 365 332 Relation sortedRelation = new Relation(originalRelation); 366 List<RelationMember> sortedRelationMembers = new ArrayList<>(members.size()); 367 for (RelationMember rm : stops) { 368 sortedRelationMembers.add(rm); 369 } 370 for (RelationMember rm : sortedWays) { 371 sortedRelationMembers.add(rm); 372 } 373 sortedRelation.setMembers(sortedRelationMembers); 374 333 SortPTRouteMembersAction.sortPTRouteMembers(sortedRelation); 375 334 return new ChangeCommand(originalRelation, sortedRelation); 376 335 }
Note:
See TracChangeset
for help on using the changeset viewer.