Ignore:
Timestamp:
2017-07-25T16:44:13+02:00 (7 years ago)
Author:
giackserva
Message:

[pt_assistant] #josm15068

Location:
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/PTAssistantLayerManager.java

    r33462 r33470  
    4242        for (OsmPrimitive primitive : newSelection) {
    4343            if (primitive.getType().equals(OsmPrimitiveType.RELATION)
    44                     && RouteUtils.isVersionTwoPTRoute((Relation) primitive)) {
     44                    && (RouteUtils.isVersionTwoPTRoute((Relation) primitive)
     45                        || RouteUtils.isBicycleRoute((Relation) primitive)
     46                        || RouteUtils.isFootRoute((Relation) primitive)
     47                        || RouteUtils.isHorseRoute((Relation) primitive))) {
    4548                routes.add(primitive);
    4649            }
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/PTAssistantPaintVisitor.java

    r33454 r33470  
    2424import org.openstreetmap.josm.data.validation.PaintVisitor;
    2525import org.openstreetmap.josm.gui.MapView;
     26import org.openstreetmap.josm.gui.dialogs.relation.sort.WayConnectionType;
     27import org.openstreetmap.josm.gui.dialogs.relation.sort.WayConnectionTypeCalculator;
    2628import org.openstreetmap.josm.plugins.pt_assistant.data.PTStop;
    2729import org.openstreetmap.josm.plugins.pt_assistant.data.PTWay;
     
    5658    @Override
    5759    public void visit(Relation r) {
     60
     61        if (RouteUtils.isBicycleRoute(r)
     62                || RouteUtils.isFootRoute(r)
     63                || RouteUtils.isHorseRoute(r)) {
     64            drawCycleRoute(r);
     65            return;
     66        }
    5867
    5968        // first, draw primitives:
     
    116125    }
    117126
     127    private void drawCycleRoute(Relation r) {
     128
     129        List<RelationMember> members = new ArrayList<>(r.getMembers());
     130        members.removeIf(m -> !m.isWay());
     131        WayConnectionTypeCalculator connectionTypeCalculator = new WayConnectionTypeCalculator();
     132        List<WayConnectionType> links = connectionTypeCalculator.updateLinks(members);
     133
     134        for (int i = 0; i < links.size(); i++) {
     135            WayConnectionType link = links.get(i);
     136            Way way = members.get(i).getWay();
     137            if (!link.isOnewayLoopForwardPart && !link.isOnewayLoopBackwardPart) {
     138                drawWay(way, new Color(0, 255, 255, 100));
     139            } else if (link.isOnewayLoopForwardPart) {
     140                drawWay(way, new Color(255, 0, 0, 100));
     141            } else {
     142                drawWay(way, new Color(0, 0, 255, 100));
     143            }
     144        }
     145    }
     146
     147    private void drawWay(Way way, Color color) {
     148        List<Node> nodes = way.getNodes();
     149        for (int i = 0; i < nodes.size()-1; i++) {
     150            drawSegment(nodes.get(i), nodes.get(i + 1), color, 1);
     151        }
     152    }
     153
    118154    @Override
    119155    public void visit(Way w) {
Note: See TracChangeset for help on using the changeset viewer.