Changeset 32650 in osm
- Timestamp:
- 2016-07-13T17:03:16+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/NodeChecker.java
r32647 r32650 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 4 5 import java.lang.reflect.InvocationTargetException; 5 6 import java.util.ArrayList; 6 7 import java.util.List; 7 8 9 import javax.swing.JOptionPane; 10 import javax.swing.SwingUtilities; 11 12 import org.openstreetmap.josm.Main; 13 import org.openstreetmap.josm.command.ChangeCommand; 14 import org.openstreetmap.josm.command.Command; 15 import org.openstreetmap.josm.command.SelectCommand; 8 16 import org.openstreetmap.josm.data.osm.Node; 9 17 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 73 81 } 74 82 } 75 76 public static void fixError() { 77 83 84 /** 85 * Fixes errors: solitary stop position and platform which is part of a way. 86 * Asks the user first. 87 * 88 * @param testError 89 * @return 90 */ 91 protected static Command fixError(TestError testError) { 92 93 if (testError.getCode() != PTAssistantValidatorTest.ERROR_CODE_SOLITARY_STOP_POSITION 94 && testError.getCode() != PTAssistantValidatorTest.ERROR_CODE_PLATFORM_PART_OF_HIGHWAY) { 95 return null; 96 } 97 98 Node problematicNode = (Node) testError.getPrimitives().iterator().next(); 99 ArrayList<OsmPrimitive> primitivesToSelect = new ArrayList<>(1); 100 primitivesToSelect.add(problematicNode); 101 SelectCommand selectCommand = new SelectCommand(primitivesToSelect); 102 selectCommand.executeCommand(); 103 104 final int[] userSelection = { JOptionPane.YES_OPTION }; 105 final TestError errorParameter = testError; 106 if (SwingUtilities.isEventDispatchThread()) { 107 108 userSelection[0] = showFixNodeTagDialog(errorParameter); 109 110 } else { 111 112 try { 113 SwingUtilities.invokeAndWait(new Runnable() { 114 @Override 115 public void run() { 116 userSelection[0] = showFixNodeTagDialog(errorParameter); 117 } 118 }); 119 } catch (InvocationTargetException | InterruptedException e) { 120 e.printStackTrace(); 121 return null; 122 } 123 } 124 125 if (userSelection[0] == JOptionPane.YES_OPTION) { 126 127 Node modifiedNode = new Node(problematicNode); 128 if (testError.getCode() == PTAssistantValidatorTest.ERROR_CODE_SOLITARY_STOP_POSITION) { 129 modifiedNode.put("public_transport", "platform"); 130 ChangeCommand command = new ChangeCommand(problematicNode, modifiedNode); 131 return command; 132 } else { 133 modifiedNode.put("public_transport", "stop_position"); 134 ChangeCommand command = new ChangeCommand(problematicNode, modifiedNode); 135 return command; 136 } 137 } 138 139 return null; 140 141 } 142 143 private static int showFixNodeTagDialog(TestError e) { 144 Node problematicNode = (Node) e.getPrimitives().iterator().next(); 145 Main.map.mapView.zoomTo(problematicNode.getCoor()); 146 147 String[] options = { tr("Yes"), tr("No") }; 148 String message; 149 if (e.getCode() == PTAssistantValidatorTest.ERROR_CODE_SOLITARY_STOP_POSITION) { 150 message = "Do you want to change the tag public_transport=stop_position to public_transport=platform?"; 151 } else { 152 message = "Do you want to change the tag public_transport=platform to public_transport=stop_position?"; 153 } 154 return JOptionPane.showOptionDialog(null, message, tr("PT_Assistant Message"), JOptionPane.YES_NO_OPTION, 155 JOptionPane.QUESTION_MESSAGE, null, options, 0); 78 156 } 79 157 -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/PTAssistantValidatorTest.java
r32647 r32650 39 39 private PTAssistantLayer layer; 40 40 41 42 41 public PTAssistantValidatorTest() { 43 42 super(tr("Public Transport Assistant tests"), … … 67 66 nodeChecker.performPlatformPartOfWayTest(); 68 67 } 69 68 70 69 this.errors.addAll(nodeChecker.getErrors()); 71 70 72 71 } 73 74 72 75 73 @Override … … 83 81 // and do not do any testing. 84 82 if (r.hasIncompleteMembers()) { 85 83 86 84 boolean downloadSuccessful = this.downloadIncompleteMembers(); 87 85 if (!downloadSuccessful) { … … 316 314 public boolean isFixable(TestError testError) { 317 315 if (testError.getCode() == ERROR_CODE_DIRECTION || testError.getCode() == ERROR_CODE_ROAD_TYPE 318 || testError.getCode() == ERROR_CODE_CONSTRUCTION || testError.getCode() == ERROR_CODE_SORTING) { 316 || testError.getCode() == ERROR_CODE_CONSTRUCTION || testError.getCode() == ERROR_CODE_SORTING 317 || testError.getCode() == PTAssistantValidatorTest.ERROR_CODE_SOLITARY_STOP_POSITION 318 || testError.getCode() == PTAssistantValidatorTest.ERROR_CODE_PLATFORM_PART_OF_HIGHWAY) { 319 319 return true; 320 320 } … … 333 333 if (testError.getCode() == ERROR_CODE_DIRECTION) { 334 334 commands.add(WayChecker.fixErrorByZooming(testError)); 335 335 336 336 } 337 337 … … 340 340 } 341 341 342 if (testError.getCode() == ERROR_CODE_SOLITARY_STOP_POSITION) { 343 // TODO342 if (testError.getCode() == ERROR_CODE_SOLITARY_STOP_POSITION || testError.getCode() == ERROR_CODE_PLATFORM_PART_OF_HIGHWAY) { 343 commands.add(NodeChecker.fixError(testError)); 344 344 } 345 345 … … 388 388 new TestError(this, Severity.WARNING, tr("PT: dummy test warning"), ERROR_CODE_DIRECTION, primitives)); 389 389 } 390 390 391 391 } -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/WayChecker.java
r32647 r32650 515 515 // open editor: 516 516 editor.setVisible(true); 517 editor.setFocusable(true);518 editor.requestFocusInWindow();519 517 520 518 // make the current relation purple in the pt_assistant layer:
Note:
See TracChangeset
for help on using the changeset viewer.