Ignore:
Timestamp:
2017-06-16T19:01:54+02:00 (7 years ago)
Author:
giackserva
Message:

[pt_assistant] unit tests for #josm#14933

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

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/actions/SplitRoundaboutAction.java

    r33403 r33404  
    44
    55import java.awt.event.ActionEvent;
     6import java.util.ArrayList;
    67import java.util.Collection;
    78import java.util.HashMap;
     9import java.util.HashSet;
    810import java.util.List;
    911import java.util.Map;
     12import java.util.Set;
    1013import java.util.concurrent.ExecutionException;
    1114import java.util.concurrent.Future;
     
    3336
    3437        private static final String actionName = "Split Roundabout";
    35 
    3638        private static final long serialVersionUID = 8912249304286025356L;
    3739
     
    4244        @Override
    4345        public void actionPerformed(ActionEvent e) {
     46
    4447                Way roundabout = (Way) getLayerManager().getEditDataSet().getSelected().iterator().next();
    4548
     
    7073        {
    7174                //make the roundabout round, if requested
    72                 int result = JOptionPane.showOptionDialog(Main.parent,
     75                if(Main.pref.getBoolean("pt_assistant.roundabout-splitter.alignalways") ||
     76                                JOptionPane.YES_OPTION == JOptionPane.showOptionDialog(Main.parent,
    7377                                tr("Do you want to make the roundabout round?"), tr("Roundabout round"),
    7478                                JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,
    75                                 null, null, null);
    76 
    77                 if(result == JOptionPane.YES_OPTION) {
     79                                null, null, null)) {
    7880                        new AlignInCircleAction().actionPerformed(null);
    7981                }
     
    8688                getLayerManager().getEditDataSet().setSelected(splitNodes);
    8789                new SplitWayAction().actionPerformed(null);
    88                 Collection<OsmPrimitive> splitWays = getLayerManager().getEditDataSet().getSelected();
     90                Collection<Way> splitWays = getLayerManager().getEditDataSet().getSelectedWays();
    8991
    9092        //update the relations.
     93                updateRelations(savedPositions, splitNodes, splitWays);
     94        }
     95
     96        public void updateRelations(Map<Relation, Integer> savedPositions,
     97                        List<Node> splitNodes, Collection<Way> splitWays) {
    9198                savedPositions.forEach((r, i) -> {
    9299                        Way previous = r.getMember(i-1).getWay();
     
    137144        //split only on the nodes which might be the
    138145        //entry or exit point for some public transport route
    139         private List<Node> getSplitNodes(Way roundabout) {
    140                 List<Node> splitNodes = roundabout.getNodes();
     146        public List<Node> getSplitNodes(Way roundabout) {
     147                Set<Node> noDuplicateSplitNodes = new HashSet<>(roundabout.getNodes());
     148                List<Node> splitNodes = new ArrayList<>(noDuplicateSplitNodes);
     149
    141150                splitNodes.removeIf(n -> {
    142151                        List<Way> parents = n.getParentWays();
     
    159168        //save the position of the roundabout inside each public transport route
    160169        //it is contained in
    161         private Map<Relation, Integer> getSavedPositions(Way roundabout) {
     170        public Map<Relation, Integer> getSavedPositions(Way roundabout) {
    162171
    163172                Map<Relation, Integer> savedPositions = new HashMap<>();
  • applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/AbstractTest.java

    r33055 r33404  
    3737 public static final String PATH_TO_PLATFORM_AS_WAY = "test/data/route-with-platform-as-way.osm";
    3838
     39 public static final String PATH_TO_ROUNDABOUT = "test/data/roundabout.osm";
    3940 public static final String PATH_TO_ROUNDABOUT_ONEWAY = "test/data/duesseldorf_roundabout.osm";
    4041
     
    5556 public static final String PATH_TO_STOP_AREA_MANY_PLATFORMS = "test/data/stop-area-many-platforms.osm";
    5657
    57 
    5858 public static final String PATH_TO_SEGMENT_TEST = "test/data/segment-test.osm";
    5959
Note: See TracChangeset for help on using the changeset viewer.