Ignore:
Timestamp:
2017-07-24T21:37:48+02:00 (7 years ago)
Author:
giackserva
Message:

[pt_assistant] SegmentChecker refactoring

Location:
applications/editors/josm/plugins/pt_assistant
Files:
3 edited

Legend:

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

    r33462 r33464  
    2121import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    2222import org.openstreetmap.josm.data.osm.Relation;
     23import org.openstreetmap.josm.data.osm.RelationMember;
    2324import org.openstreetmap.josm.data.osm.Way;
    2425import org.openstreetmap.josm.data.validation.Severity;
     
    332333    private void proceedWithSorting(Relation r) {
    333334
     335        PTRouteDataManager manager = new PTRouteDataManager(r);
     336        StopToWayAssigner assigner = new StopToWayAssigner(manager.getPTWays());
     337
     338        for (RelationMember rm : manager.getFailedMembers()) {
     339            List<Relation> primitives = new ArrayList<>(1);
     340            primitives.add(r);
     341            List<OsmPrimitive> highlighted = new ArrayList<>(1);
     342            highlighted.add(rm.getMember());
     343            Builder builder = TestError.builder(this, Severity.WARNING,
     344                    ERROR_CODE_RELATION_MEMBER_ROLES);
     345            builder.message(tr("PT: Relation member roles do not match tags"));
     346            builder.primitives(primitives);
     347            builder.highlight(highlighted);
     348            TestError e = builder.build();
     349            errors.add(e);
     350        }
     351
    334352        // Check if the relation is correct, or only has a wrong sorting order:
    335353        RouteChecker routeChecker = new RouteChecker(r, this);
     
    338356
    339357        SegmentChecker segmentChecker = new SegmentChecker(r, this);
     358        segmentChecker.setManager(manager);
     359        segmentChecker.setAssigner(assigner);
    340360        segmentChecker.performFirstStopTest();
    341361        segmentChecker.performLastStopTest();
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/SegmentChecker.java

    r33449 r33464  
    6565
    6666        super(relation, test);
    67 
    68         this.setManager(new PTRouteDataManager(relation));
    69 
    70         for (RelationMember rm : getManager().getFailedMembers()) {
    71             List<Relation> primitives = new ArrayList<>(1);
    72             primitives.add(relation);
    73             List<OsmPrimitive> highlighted = new ArrayList<>(1);
    74             highlighted.add(rm.getMember());
    75             Builder builder = TestError.builder(this.test, Severity.WARNING,
    76                     PTAssistantValidatorTest.ERROR_CODE_RELATION_MEMBER_ROLES);
    77             builder.message(tr("PT: Relation member roles do not match tags"));
    78             builder.primitives(primitives);
    79             builder.highlight(highlighted);
    80             TestError e = builder.build();
    81             this.errors.add(e);
    82         }
    83 
    84         this.setAssigner(new StopToWayAssigner(getManager().getPTWays()));
    85 
    8667    }
    8768
  • applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/SegmentCheckerTest.java

    r33429 r33464  
    1111import org.openstreetmap.josm.plugins.pt_assistant.AbstractTest;
    1212import org.openstreetmap.josm.plugins.pt_assistant.ImportUtils;
     13import org.openstreetmap.josm.plugins.pt_assistant.data.PTRouteDataManager;
    1314import org.openstreetmap.josm.plugins.pt_assistant.utils.RouteUtils;
     15import org.openstreetmap.josm.plugins.pt_assistant.utils.StopToWayAssigner;
    1416
    1517public class SegmentCheckerTest extends AbstractTest {
     
    3133
    3234        SegmentChecker segmentChecker = new SegmentChecker(route, test);
     35        PTRouteDataManager manager = new PTRouteDataManager(route);
     36        segmentChecker.setManager(manager);
     37        segmentChecker.setAssigner(new StopToWayAssigner(manager.getPTWays()));
    3338        segmentChecker.performStopByStopTest();
    3439        //since 33425 storing correct segments only of continuous routes
Note: See TracChangeset for help on using the changeset viewer.