Changeset 32743 in osm for applications/editors/josm


Ignore:
Timestamp:
2016-07-30T00:31:27+02:00 (8 years ago)
Author:
darya
Message:

clarification

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/SegmentChecker.java

    r32741 r32743  
    241241                for (int i = 1; i < manager.getPTStopCount(); i++) {
    242242
    243                         this.firstNodeOfRouteSegmentInDirectionOfTravel = null;
     243//                      this.firstNodeOfRouteSegmentInDirectionOfTravel = null;
    244244
    245245                        PTStop startStop = manager.getPTStops().get(i - 1);
     
    249249                        Way endWay = assigner.get(endStop);
    250250                        if (startWay == null || endWay == null) {
    251                                 this.firstNodeOfRouteSegmentInDirectionOfTravel = null;
    252251                                continue;
    253252                        }
     
    255254                        List<PTWay> segmentWays = manager.getPTWaysBetween(startWay, endWay);
    256255
    257                         if (this.firstNodeOfRouteSegmentInDirectionOfTravel == null) {
    258                                 // if we are at the beginning of the route or after a gap /
    259                                 // error:
    260 
    261                                 this.firstNodeOfRouteSegmentInDirectionOfTravel = findFirstNodeOfRouteSegmentInDirectionOfTravel(
    262                                                 segmentWays.get(0));
    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                                         }
    281                                         continue;
    282                                 }
     256                        Node testNode = findFirstNodeOfRouteSegmentInDirectionOfTravel(
     257                                        segmentWays.get(0));
     258                        if (testNode == null) {
     259                                // check if this error has just been reported:
     260                                if (!this.errors.isEmpty() && this.errors.get(this.errors.size() - 1).getHighlighted().size() == 1
     261                                                && this.errors.get(this.errors.size() - 1).getHighlighted().iterator().next() == startWay) {
     262                                        // do nothing, this error has already been reported in
     263                                        // the previous route segment
     264                                } else {
     265                                        List<Relation> primitives = new ArrayList<>(1);
     266                                        primitives.add(relation);
     267                                        List<OsmPrimitive> highlighted = new ArrayList<>();
     268                                        highlighted.add(startWay);
     269                                        TestError e = new TestError(this.test, Severity.WARNING, tr("PT: Problem in the route segment"),
     270                                                        PTAssistantValidatorTest.ERROR_CODE_STOP_BY_STOP, primitives, highlighted);
     271                                        this.errors.add(e);
     272                                        PTRouteSegment routeSegment = new PTRouteSegment(startStop, endStop, segmentWays);
     273                                        wrongSegments.put(e, routeSegment);
     274                                }
     275                                continue;
    283276                        }
    284277
    285278                        boolean sortingCorrect = existingWaySortingIsCorrect(segmentWays.get(0),
    286                                         this.firstNodeOfRouteSegmentInDirectionOfTravel, segmentWays.get(segmentWays.size() - 1));
     279                                        testNode, segmentWays.get(segmentWays.size() - 1));
    287280                        if (sortingCorrect) {
    288281                                PTRouteSegment routeSegment = new PTRouteSegment(startStop, endStop, segmentWays);
     
    413406                if (start == end) {
    414407                        // if both PTStops are on the same PTWay
    415                         this.firstNodeOfRouteSegmentInDirectionOfTravel = null;
    416408                        return true;
    417409                }
    418410
    419411                PTWay current = start;
     412                Node currentNode = startWayPreviousNodeInDirectionOfTravel;
    420413
    421414                while (!current.equals(end)) {
     
    428421                        // if current contains an unsplit roundabout:
    429422                        if (current.containsUnsplitRoundabout()) {
    430                                 firstNodeOfRouteSegmentInDirectionOfTravel = manager.getCommonNode(current,
    431                                                 nextPTWayAccortingToExistingSorting);
    432                                 if (firstNodeOfRouteSegmentInDirectionOfTravel == null) {
     423                                currentNode = manager.getCommonNode(current, nextPTWayAccortingToExistingSorting);
     424                                if (currentNode == null) {
    433425                                        List<Relation> primitives = new ArrayList<>(1);
    434426                                        primitives.add(relation);
     
    445437                                // find the next node in direction of travel (which is part of
    446438                                // the PTWay start):
    447                                 firstNodeOfRouteSegmentInDirectionOfTravel = getOppositeEndNode(current,
    448                                                 firstNodeOfRouteSegmentInDirectionOfTravel);
     439                                currentNode = getOppositeEndNode(current, currentNode);
    449440
    450441                                List<PTWay> nextWaysInDirectionOfTravel = this.findNextPTWaysInDirectionOfTravel(current,
    451                                                 firstNodeOfRouteSegmentInDirectionOfTravel);
     442                                                currentNode);
    452443
    453444                                if (!nextWaysInDirectionOfTravel.contains(nextPTWayAccortingToExistingSorting)) {
     
    457448
    458449                                        highlighted.addAll(current.getWays());
    459                                         highlighted.add(firstNodeOfRouteSegmentInDirectionOfTravel);
     450                                        highlighted.add(currentNode);
    460451
    461452                                        TestError e = new TestError(this.test, Severity.WARNING, tr("PT: Problem in the route segment"),
    462453                                                        PTAssistantValidatorTest.ERROR_CODE_STOP_BY_STOP, primitives, highlighted);
    463454                                        this.errors.add(e);
    464                                         this.firstNodeOfRouteSegmentInDirectionOfTravel = null;
    465455                                        return false;
    466456
Note: See TracChangeset for help on using the changeset viewer.