Changeset 32741 in osm for applications
- Timestamp:
- 2016-07-29T22:17:04+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/SegmentChecker.java ¶
r32734 r32741 241 241 for (int i = 1; i < manager.getPTStopCount(); i++) { 242 242 243 this.firstNodeOfRouteSegmentInDirectionOfTravel = null; 244 243 245 PTStop startStop = manager.getPTStops().get(i - 1); 244 246 PTStop endStop = manager.getPTStops().get(i); … … 250 252 continue; 251 253 } 252 //253 // System.out.println();254 // System.out.println("start way: " + startWay.getId());255 // System.out.println("end way: " + endWay.getId());256 254 257 255 List<PTWay> segmentWays = manager.getPTWaysBetween(startWay, endWay); … … 264 262 segmentWays.get(0)); 265 263 if (this.firstNodeOfRouteSegmentInDirectionOfTravel == null) { 264 // check if this error has just been reported: 265 TestError previousError = this.errors.get(this.errors.size() - 1); 266 if (previousError.getHighlighted().size() == 1 267 && previousError.getHighlighted().iterator().next() == startWay) { 268 // do nothing, this error has already been reported in 269 // the previous step 270 } else { 271 List<Relation> primitives = new ArrayList<>(1); 272 primitives.add(relation); 273 List<OsmPrimitive> highlighted = new ArrayList<>(); 274 highlighted.add(startWay); 275 TestError e = new TestError(this.test, Severity.WARNING, tr("PT: Problem in the route segment"), 276 PTAssistantValidatorTest.ERROR_CODE_STOP_BY_STOP, primitives, highlighted); 277 this.errors.add(e); 278 PTRouteSegment routeSegment = new PTRouteSegment(startStop, endStop, segmentWays); 279 wrongSegments.put(e, routeSegment); 280 } 266 281 continue; 267 282 } … … 274 289 correctSegments.add(routeSegment); 275 290 } else { 276 // System.out.println("ERROR");277 291 PTRouteSegment routeSegment = new PTRouteSegment(startStop, endStop, segmentWays); 278 292 TestError error = this.errors.get(this.errors.size() - 1); … … 320 334 return null; 321 335 } 336 PTWay wayAfterNext = manager.getNextPTWay(nextWay); 322 337 Node[] nextWayEndnodes = nextWay.getEndNodes(); 338 if ((startWayEndnodes[0] == nextWayEndnodes[0] && startWayEndnodes[1] == nextWayEndnodes[1]) 339 || (startWayEndnodes[0] == nextWayEndnodes[1] && startWayEndnodes[1] == nextWayEndnodes[0])) { 340 // if this is a split roundabout: 341 Node[] wayAfterNextEndnodes = wayAfterNext.getEndNodes(); 342 if (startWayEndnodes[0] == wayAfterNextEndnodes[0] || startWayEndnodes[0] == wayAfterNextEndnodes[1]) { 343 return startWayEndnodes[0]; 344 } 345 if (startWayEndnodes[1] == wayAfterNextEndnodes[0] || startWayEndnodes[1] == wayAfterNextEndnodes[1]) { 346 return startWayEndnodes[1]; 347 } 348 } 349 323 350 if (startWayEndnodes[0] == nextWayEndnodes[0] || startWayEndnodes[0] == nextWayEndnodes[1]) { 324 351 return startWayEndnodes[1]; … … 370 397 } 371 398 399 /** 400 * Checks if the existing sorting of the given route segment is correct 401 * 402 * @param start 403 * PTWay assigned to the first stop of the segment 404 * @param startWayPreviousNodeInDirectionOfTravel 405 * Node if the start way which is furthest away from the rest of 406 * the route 407 * @param end 408 * PTWay assigned to the end stop of the segment 409 * @return true if the sorting is correct, false otherwise. 410 */ 372 411 private boolean existingWaySortingIsCorrect(PTWay start, Node startWayPreviousNodeInDirectionOfTravel, PTWay end) { 373 412 … … 406 445 // find the next node in direction of travel (which is part of 407 446 // the PTWay start): 408 // if (firstNodeOfRouteSegmentInDirectionOfTravel != null) {409 // System.out.println("previous node in direction of travel: "410 // + firstNodeOfRouteSegmentInDirectionOfTravel.getId());411 // } else {412 // System.out.println("previous node in direction of travel: null");413 // }414 447 firstNodeOfRouteSegmentInDirectionOfTravel = getOppositeEndNode(current, 415 448 firstNodeOfRouteSegmentInDirectionOfTravel); 416 // if (firstNodeOfRouteSegmentInDirectionOfTravel != null) {417 // System.out.println(418 // "next node in direction of travel: " + firstNodeOfRouteSegmentInDirectionOfTravel.getId());419 // } else {420 // System.out.println("next node in direction of travel: null");421 // }422 449 423 450 List<PTWay> nextWaysInDirectionOfTravel = this.findNextPTWaysInDirectionOfTravel(current, … … 528 555 protected static boolean isFixable(TestError testError) { 529 556 557 /*- 558 * When is an error fixable? 559 * - if there is a correct segment 560 * - if it can be fixed by sorting 561 * - if the route is compete even without some ways 562 * - if simple routing closes the gap 563 */ 564 530 565 if (testError.getCode() == PTAssistantValidatorTest.ERROR_CODE_STOP_BY_STOP) { 531 532 PTRouteSegment wrongSegment = wrongSegments.get(testError); 533 PTRouteSegment correctSegment = null; 534 // TODO: now just the first correctSegment is taken over. Change 535 // that 536 // the segment is selected. 537 for (PTRouteSegment segment : correctSegments) { 538 if (wrongSegment.getFirstStop().equalsStop(segment.getFirstStop()) 539 && wrongSegment.getLastStop().equalsStop(segment.getLastStop())) { 540 correctSegment = segment; 541 // System.out.println("correct segment found: " + 542 // correctSegment.getFirstStop().getPlatform().getId()); 543 break; 544 } 545 } 546 547 return correctSegment != null; 566 if (isFixableByUsingCorrectSegment(testError)) { 567 return true; 568 } 569 if (isFixableBySegmentSorting(testError)) { 570 return true; 571 } 572 if (isFixableByRemovingWays()) { 573 return true; 574 } 575 if (isFixableBySimpleRouting()) { 576 return true; 577 } 548 578 } 549 579 550 580 return false; 551 581 582 } 583 584 private static boolean isFixableByUsingCorrectSegment(TestError testError) { 585 PTRouteSegment wrongSegment = wrongSegments.get(testError); 586 PTRouteSegment correctSegment = null; 587 // TODO: now just the first correctSegment is taken over. Change 588 // that the segment is selected. 589 for (PTRouteSegment segment : correctSegments) { 590 if (wrongSegment.getFirstStop().equalsStop(segment.getFirstStop()) 591 && wrongSegment.getLastStop().equalsStop(segment.getLastStop())) { 592 correctSegment = segment; 593 break; 594 } 595 } 596 return correctSegment != null; 597 } 598 599 private static boolean isFixableBySegmentSorting(TestError testError) { 600 PTRouteSegment wrongSegment = wrongSegments.get(testError); 601 602 return false; 603 } 604 605 private static boolean isFixableByRemovingWays() { 606 // TODO 607 return false; 608 } 609 610 private static boolean isFixableBySimpleRouting() { 611 // TODO 612 return false; 552 613 } 553 614
Note:
See TracChangeset
for help on using the changeset viewer.