Changeset 32557 in osm
- Timestamp:
- 2016-07-04T18:48:41+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/PTAssistantPaintVisitor.java
r32540 r32557 291 291 if (parent.getType().equals(OsmPrimitiveType.RELATION)) { 292 292 Relation relation = (Relation) parent; 293 if (RouteUtils.isTwoDirectionRoute(relation) && relation.get("ref") != null && !relation.get("ref").equals("")) { 293 if (RouteUtils.isTwoDirectionRoute(relation) && relation.get("ref") != null 294 && !relation.get("ref").equals("")) { 294 295 295 296 boolean stringFound = false; … … 331 332 public int compare(String s1, String s2) { 332 333 333 if (s1 == null || s1.equals("")) { 334 if (s2 == null || s2.equals("")) { 335 return 0; 336 } else { 337 return 1; 338 } 339 } 340 341 String firstNumberString1 = s1.split("\\D+")[0]; 342 String firstNumberString2 = s2.split("\\D+")[0]; 343 334 if (s1 == null || s1.equals("") || s2 == null || s2.equals("")) { 335 // if at least one of the strings is null or empty, there is no 336 // point in comparing: 337 return 0; 338 } 339 340 String[] splitString1 = s1.split("\\D"); 341 String[] splitString2 = s2.split("\\D"); 342 343 if (splitString1.length == 0 && splitString2.length != 0) { 344 // if the first ref does not start a digit and the second ref 345 // starts with a digit: 346 return 1; 347 } 348 349 if (splitString1.length != 0 && splitString2.length == 0) { 350 // if the first ref starts a digit and the second ref does not 351 // start with a digit: 352 return -1; 353 } 354 355 if (splitString1.length == 0 && splitString2.length == 0) { 356 // if both ref values do not start with a digit: 357 return s1.compareTo(s2); 358 } 359 360 String firstNumberString1 = splitString1[0]; 361 String firstNumberString2 = splitString2[0]; 362 344 363 try { 345 364 int firstNumber1 = Integer.valueOf(firstNumberString1); -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/PTAssitantValidatorTest.java
r32554 r32557 98 98 if (SwingUtilities.isEventDispatchThread()) { 99 99 100 userSelection[0] = realDownloadIncompleteMembers();100 userSelection[0] = showIncompleteMembersDownloadDialog(); 101 101 102 102 } else { … … 106 106 public void run() { 107 107 try { 108 userSelection[0] = realDownloadIncompleteMembers();108 userSelection[0] = showIncompleteMembersDownloadDialog(); 109 109 } catch (InterruptedException e) { 110 110 e.printStackTrace(); … … 144 144 * @throws InterruptedException 145 145 */ 146 private int realDownloadIncompleteMembers() throws InterruptedException {146 private int showIncompleteMembersDownloadDialog() throws InterruptedException { 147 147 148 148 IncompleteMembersDownloadDialog incompleteMembersDownloadDialog = new IncompleteMembersDownloadDialog(); … … 169 169 } 170 170 171 ProceedDialog proceedDialog = new ProceedDialog(r.getId(), numberOfDirectionErrors, numberOfRoadTypeErrors); 172 int userInput = proceedDialog.getUserSelection(); 173 174 if (userInput == 0) { 171 final int[] userInput = { 0 }; 172 final long idParameter = r.getId(); 173 final int directionErrorParameter = numberOfDirectionErrors; 174 final int roadTypeErrorParameter = numberOfRoadTypeErrors; 175 176 if (SwingUtilities.isEventDispatchThread()) { 177 178 userInput[0] = showProceedDialog(idParameter, directionErrorParameter, roadTypeErrorParameter); 179 180 } else { 181 182 try { 183 SwingUtilities.invokeAndWait(new Runnable() { 184 @Override 185 public void run() { 186 userInput[0] = showProceedDialog(idParameter, roadTypeErrorParameter, roadTypeErrorParameter); 187 188 } 189 }); 190 } catch (InvocationTargetException | InterruptedException e1) { 191 // TODO Auto-generated catch block 192 e1.printStackTrace(); 193 } 194 195 } 196 197 if (userInput[0] == 0) { 175 198 this.fixErrorFromPlugin(this.errors); 176 199 proceedWithSorting(r); … … 178 201 } 179 202 180 if (userInput == 1) { 203 if (userInput[0] == 1) { 181 204 // TODO 182 205 JOptionPane.showMessageDialog(null, "This is not implemented yet!"); … … 184 207 } 185 208 186 if (userInput == 2) { 209 if (userInput[0] == 2) { 187 210 // TODO: should the errors be removed from the error list? 188 211 proceedWithSorting(r); … … 191 214 // if userInput==-1 (i.e. no input), do nothing and stop testing of the 192 215 // route. 216 217 } 218 219 private int showProceedDialog(long id, int numberOfDirectionErrors, int numberOfRoadTypeErrors) { 220 221 ProceedDialog proceedDialog = new ProceedDialog(id, numberOfDirectionErrors, numberOfRoadTypeErrors); 222 return proceedDialog.getUserSelection(); 193 223 194 224 } -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/WayChecker.java
r32554 r32557 6 6 import java.util.Collection; 7 7 import java.util.List; 8 9 import javax.swing.SwingUtilities; 8 10 9 11 import org.openstreetmap.josm.Main; … … 12 14 import org.openstreetmap.josm.command.Command; 13 15 import org.openstreetmap.josm.command.SelectCommand; 16 import org.openstreetmap.josm.command.SequenceCommand; 14 17 import org.openstreetmap.josm.data.osm.OsmPrimitive; 15 18 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; … … 29 32 30 33 /** 31 * Performs tests of a route at the level of single ways: DirectionTest and RoadTypeTest 34 * Performs tests of a route at the level of single ways: DirectionTest and 35 * RoadTypeTest 32 36 * 33 37 * @author darya … … 35 39 */ 36 40 public class WayChecker extends Checker { 37 41 38 42 public WayChecker(Relation relation, Test test) { 39 43 … … 43 47 44 48 protected void performRoadTypeTest() { 45 49 46 50 if (!relation.hasTag("route", "bus") && !relation.hasTag("route", "trolleybus") 47 51 && !relation.hasTag("route", "share_taxi")) { … … 121 125 122 126 } 123 127 124 128 if (isUnderConstruction) { 125 129 List<Relation> primitives = new ArrayList<>(1); … … 127 131 List<Way> highlighted = new ArrayList<>(1); 128 132 highlighted.add(way); 129 TestError e = new TestError(this.test, Severity.WARNING, 130 tr("PT: Road is under construction"), 133 TestError e = new TestError(this.test, Severity.WARNING, tr("PT: Road is under construction"), 131 134 PTAssitantValidatorTest.ERROR_CODE_CONSTRUCTION, primitives, highlighted); 132 135 errors.add(e); … … 215 218 return false; 216 219 } 217 220 218 221 protected static Command fixErrorByRemovingWay(TestError testError) { 219 222 220 if (testError.getCode() != PTAssitantValidatorTest.ERROR_CODE_ROAD_TYPE && testError.getCode() != PTAssitantValidatorTest.ERROR_CODE_DIRECTION) { 223 if (testError.getCode() != PTAssitantValidatorTest.ERROR_CODE_ROAD_TYPE 224 && testError.getCode() != PTAssitantValidatorTest.ERROR_CODE_DIRECTION) { 221 225 return null; 222 226 } … … 272 276 return changeCommand; 273 277 } 274 275 278 276 279 protected static Command fixErrorByZooming(TestError testError) { 277 280 278 281 if (testError.getCode() != PTAssitantValidatorTest.ERROR_CODE_DIRECTION) { 279 282 return null; 280 283 } 281 284 282 long startTime = System.currentTimeMillis();283 285 ArrayList<Command> commands = new ArrayList<>(); 286 284 287 Collection<? extends OsmPrimitive> primitives = testError.getPrimitives(); 285 288 Relation originalRelation = (Relation) primitives.iterator().next(); 289 ArrayList<OsmPrimitive> primitivesToSelect = new ArrayList<>(1); 290 primitivesToSelect.add(originalRelation); 286 291 Collection<?> highlighted = testError.getHighlighted(); 287 292 Way wayToHighlight = (Way) highlighted.iterator().next(); 288 ArrayList<OsmPrimitive> primitivesToHighlight = new ArrayList<>(1); 289 primitivesToHighlight.add(wayToHighlight); 293 ArrayList<OsmPrimitive> primitivesToZoom = new ArrayList<>(1); 294 primitivesToZoom.add(wayToHighlight); 295 296 SelectCommand command1 = new SelectCommand(primitivesToSelect); 297 commands.add(command1); 298 SelectCommand command2 = new SelectCommand(primitivesToZoom); 299 commands.add(command2); 300 301 List<OsmDataLayer> listOfLayers = Main.getLayerManager().getLayersOfType(OsmDataLayer.class); 302 for (OsmDataLayer osmDataLayer : listOfLayers) { 303 if (osmDataLayer.data == originalRelation.getDataSet()) { 304 305 final OsmDataLayer layerParameter = osmDataLayer; 306 final Relation relationParameter = originalRelation; 307 final Collection<OsmPrimitive> zoomParameter = primitivesToZoom; 308 309 if (SwingUtilities.isEventDispatchThread()) { 310 311 showRelationEditorAndZoom(layerParameter, relationParameter, zoomParameter); 312 313 } else { 314 315 SwingUtilities.invokeLater(new Runnable() { 316 @Override 317 public void run() { 318 319 showRelationEditorAndZoom(layerParameter, relationParameter, zoomParameter); 320 321 } 322 }); 323 324 } 325 326 return new SequenceCommand(null, commands); 327 } 328 } 329 330 return null; 331 332 } 333 334 private static void showRelationEditorAndZoom(OsmDataLayer layer, Relation r, Collection<OsmPrimitive> primitives) { 335 336 AutoScaleAction.zoomTo(primitives); 337 GenericRelationEditor editor = new GenericRelationEditor(layer, r, r.getMembersFor(primitives)); 338 RelationDialogManager.getRelationDialogManager().register(layer, r, editor); 290 339 291 long endTime = System.currentTimeMillis();292 System.out.println("obtaining primitives: " + (endTime - startTime));293 startTime = endTime;294 340 295 SelectCommand command = new SelectCommand(primitivesToHighlight); 341 editor.setVisible(true); 342 // editor.requestFocus(); 343 // editor.requestFocusInWindow(); 296 344 297 endTime = System.currentTimeMillis(); 298 System.out.println("constructing command: " + (endTime - startTime)); 299 startTime = endTime; 300 301 AutoScaleAction.zoomTo(primitivesToHighlight); 302 303 endTime = System.currentTimeMillis(); 304 System.out.println("AutoScaleAction done: " + (endTime - startTime)); 305 startTime = endTime; 306 307 List<OsmDataLayer> listOfLayers = Main.getLayerManager().getLayersOfType(OsmDataLayer.class); 308 for (OsmDataLayer osmDataLayer: listOfLayers) { 309 if (osmDataLayer.data == originalRelation.getDataSet()) { 310 endTime = System.currentTimeMillis(); 311 System.out.println("getting to the necessary layer: " + (endTime - startTime)); 312 startTime = endTime; 313 314 GenericRelationEditor editor = new GenericRelationEditor(osmDataLayer, originalRelation, originalRelation.getMembersFor(primitivesToHighlight)); 315 endTime = System.currentTimeMillis(); 316 System.out.println("creating relation editor: " + (endTime - startTime)); 317 startTime = endTime; 318 319 RelationDialogManager.getRelationDialogManager().register(osmDataLayer, originalRelation, editor); 320 321 endTime = System.currentTimeMillis(); 322 System.out.println("registering relation editor: " + (endTime - startTime)); 323 startTime = endTime; 324 325 editor.setVisible(true); 326 327 endTime = System.currentTimeMillis(); 328 System.out.println("setting editor visible: " + (endTime - startTime)); 329 startTime = endTime; 330 331 break; 332 } 333 } 334 335 endTime = System.currentTimeMillis(); 336 System.out.println("whatever else: " + (endTime - startTime)); 337 startTime = endTime; 338 339 return command; 340 341 } 342 345 // editor.firePropertyChange("focusedWindow", editor, editor); 346 // editor.setRelation(r); 347 348 } 349 343 350 }
Note:
See TracChangeset
for help on using the changeset viewer.