Changeset 32874 in osm for applications/editors/josm/plugins
- Timestamp:
- 2016-08-23T05:53:57+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/pt_assistant
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/PTAssistantPlugin.java
r32871 r32874 32 32 private static PTRouteSegment lastFix; 33 33 34 /* item of the Tools menu for adding stop_positions */ 34 35 private JMenuItem addStopPositionMenu; 36 37 /* item of the Tools menu for repeating the last fix */ 35 38 private static JMenuItem repeatLastFixMenu; 36 39 -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/actions/AddStopPositionAction.java
r32855 r32874 39 39 } 40 40 41 /** 42 * Actions that add the new node, set tags and update the map frame. 43 */ 41 44 @Override 42 45 public void actionPerformed(ActionEvent e) { -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/actions/IncompleteMembersDownloadThread.java
r32871 r32874 14 14 import org.openstreetmap.josm.plugins.pt_assistant.utils.RouteUtils; 15 15 16 /** 17 * Thread that downloads incomplete relation members while pausing the rest of testing 18 * @author darya 19 * 20 */ 16 21 public class IncompleteMembersDownloadThread extends Thread { 17 22 23 /** 24 * Default constructor 25 */ 18 26 public IncompleteMembersDownloadThread() { 19 27 super(); -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/actions/RepeatLastFixAction.java
r32871 r32874 13 13 import org.openstreetmap.josm.tools.Shortcut; 14 14 15 /** 16 * Carries out the changes after the Repeat last fix button has been pressed 17 * 18 * @author darya 19 * 20 */ 15 21 public class RepeatLastFixAction extends JosmAction { 16 22 17 23 private static final long serialVersionUID = 2681464946469047054L; 18 24 25 /** 26 * Default constructor 27 */ 19 28 public RepeatLastFixAction() { 20 29 super(tr("Repeat last fix"), new ImageProvider("presets/transport", "bus.svg"), tr("Repeat last fix"), … … 24 33 } 25 34 35 /** 36 * Applies the fixes, resets the last fix attribute 37 */ 26 38 @Override 27 39 public void actionPerformed(ActionEvent e) { -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/data/PTRouteSegment.java
r32855 r32874 19 19 public class PTRouteSegment { 20 20 21 /* first stop of the route segment */ 21 22 private PTStop firstStop; 23 24 /* last stop of the route segment */ 22 25 private PTStop lastStop; 26 27 /* ptways that belong to this route segment */ 23 28 private List<PTWay> ptways; 29 30 /* fix variants available for this route segment */ 24 31 private List<List<PTWay>> fixVariants; 32 33 /* route relation for which this route segment was created */ 25 34 private Relation relation; 26 35 36 /** 37 * Constructor 38 * @param firstStop first stop of the route segment 39 * @param lastStop last stop of the route segment 40 * @param ways ways PTWays that belong to this route segment 41 * @param relation the route relation for which this route segment is created 42 */ 27 43 public PTRouteSegment(PTStop firstStop, PTStop lastStop, List<PTWay> ways, Relation relation) { 28 44 this.firstStop = firstStop; … … 34 50 } 35 51 52 /** 53 * Returns the PTWays of this route segment 54 * @return 55 */ 36 56 public List<PTWay> getPTWays() { 37 57 return this.ptways; 38 58 } 39 59 60 /** 61 * Sets the PTWays of this route segment to the given list 62 * @param ptwayList 63 */ 40 64 public void setPTWays(List<PTWay> ptwayList) { 41 65 this.ptways = ptwayList; … … 43 67 } 44 68 69 /** 70 * Returns the first stop of this route segment 71 * @return 72 */ 45 73 public PTStop getFirstStop() { 46 74 return this.firstStop; 47 75 } 48 76 77 /** 78 * Returns the last stop of this route segment 79 * @return 80 */ 49 81 public PTStop getLastStop() { 50 82 return this.lastStop; 51 83 } 52 84 85 /** 86 * Returns the first PTWay of this route segment 87 * @return 88 */ 53 89 public PTWay getFirstPTWay() { 54 90 if (ptways.isEmpty()) { … … 58 94 } 59 95 96 /** 97 * Returns the last PTWay of this route segment 98 * @return 99 */ 60 100 public PTWay getLastPTWay() { 61 101 if (ptways.isEmpty()) { … … 65 105 } 66 106 107 /** 108 * Returns the first way of this route segment 109 * @return 110 */ 67 111 public Way getFirstWay() { 68 112 if (ptways.isEmpty()) { … … 72 116 } 73 117 118 /** 119 * Returns the last way of this route segment 120 * @return 121 */ 74 122 public Way getLastWay() { 75 123 if (ptways.isEmpty()) { … … 114 162 } 115 163 164 /** 165 * Returns the fix variants stored for this route segment 166 * @return 167 */ 116 168 public List<List<PTWay>> getFixVariants() { 117 169 return this.fixVariants; 118 170 } 119 171 172 /** 173 * Returns the route relation for which this route segment was created 174 * @return 175 */ 120 176 public Relation getRelation() { 121 177 return this.relation; -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/data/PTStop.java
r32734 r32874 12 12 import org.openstreetmap.josm.data.osm.RelationMember; 13 13 14 /** 15 * Model a stop with one or two elements (platform and/or stop_position) 16 * 17 * @author darya 18 * 19 */ 14 20 public class PTStop extends RelationMember { 15 21 22 /* stop_position element of this stop */ 16 23 private Node stopPosition = null; 24 25 /* platform element of this stop */ 17 26 private OsmPrimitive platform = null; 18 27 28 /* the name of this stop */ 19 29 private String name = ""; 20 30 31 /** 32 * Constructor 33 * 34 * @param other 35 * @throws IllegalArgumentException 36 * if the given relation member does not fit to the data model 37 * used in the plugin 38 */ 21 39 public PTStop(RelationMember other) throws IllegalArgumentException { 22 40 … … 111 129 } 112 130 131 /** 132 * Returns the name of this stop 133 * @return 134 */ 113 135 protected String getName() { 114 136 return this.name; 115 137 } 116 138 139 /** 140 * Sets the stop_position for this stop to the given node 141 * @param newStopPosition 142 */ 117 143 public void setStopPosition(Node newStopPosition) { 118 144 -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/data/PTWay.java
r32747 r32874 118 118 return endNodes; 119 119 } 120 120 121 /** 122 * Checks if this PTWay contains an unsplit roundabout (i.e. a way that 123 * touches itself) among its ways 124 * 125 * @return 126 */ 121 127 public boolean containsUnsplitRoundabout() { 122 128 123 129 List<Way> ways = this.getWays(); 124 for (Way way: ways) { 130 for (Way way : ways) { 125 131 if (way.firstNode() == way.lastNode()) { 126 132 return true; … … 129 135 return false; 130 136 } 131 137 138 /** 139 * Checks if the first Way of this PTWay is an unsplit roundabout (i.e. a 140 * way that touches itself) 141 * 142 * @return 143 */ 132 144 public boolean startsWithUnsplitRoundabout() { 133 145 if (this.ways.get(0).firstNode() == this.ways.get(0).lastNode()) { … … 136 148 return false; 137 149 } 138 150 151 /** 152 * Checks if the last Way of this PTWay is an unsplit roundabout (i.e. a way 153 * that touches itself) 154 * 155 * @return 156 */ 139 157 public boolean endsWithUnsplitRoundabout() { 140 if (this.ways.get(this.ways.size() - 1).firstNode() == this.ways.get(this.ways.size() -1).lastNode()) {158 if (this.ways.get(this.ways.size() - 1).firstNode() == this.ways.get(this.ways.size() - 1).lastNode()) { 141 159 return true; 142 160 } -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/DownloadReferrersDialog.java
r32621 r32874 7 7 import javax.swing.JPanel; 8 8 9 /** 10 * Dialog that asks the user whether referrers should be downloaded 11 * @author darya 12 * 13 */ 9 14 public class DownloadReferrersDialog extends JPanel { 10 15 -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/IncompleteMembersDownloadDialog.java
r32871 r32874 7 7 import javax.swing.JPanel; 8 8 9 /** 10 * Dialog that asks the user whether the incomplete relation members should be 11 * downloaded. 12 * 13 * @author darya 14 * 15 */ 9 16 public class IncompleteMembersDownloadDialog extends JPanel { 10 17 … … 26 33 27 34 public IncompleteMembersDownloadDialog() { 28 35 29 36 selectedOption = Integer.MIN_VALUE; 30 message = tr("Route relations have incomplete members.\nThey need to be downloaded to proceed with validation.\nDo you want to download them?"); 37 message = tr( 38 "Route relations have incomplete members.\nThey need to be downloaded to proceed with validation.\nDo you want to download them?"); 31 39 checkbox = new JCheckBox(tr("Remember my choice and do not ask me again in this session")); 32 40 options = new String[2]; … … 53 61 } 54 62 55 56 Object[] params = {message, checkbox}; 57 selectedOption = JOptionPane.showOptionDialog(this, params, tr("PT_Assistant Fetch Request"), JOptionPane.YES_NO_OPTION, 58 JOptionPane.QUESTION_MESSAGE, null, options, 0); 59 63 Object[] params = { message, checkbox }; 64 selectedOption = JOptionPane.showOptionDialog(this, params, tr("PT_Assistant Fetch Request"), 65 JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, 0); 66 60 67 if (checkbox.isSelected()) { 61 68 if (selectedOption == JOptionPane.YES_OPTION) { -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/PTAssistantLayer.java
r32801 r32874 38 38 import org.openstreetmap.josm.tools.ImageProvider; 39 39 40 /** 41 * Layer that visualizes the routes in a more convenient way 42 * 43 * @author darya 44 * 45 */ 40 46 public class PTAssistantLayer extends Layer 41 47 implements SelectionChangedListener, PropertyChangeListener, LayerChangeListener { … … 61 67 } 62 68 69 /** 70 * Adds a primitive (route) to be displayed in this layer 71 * 72 * @param primitive 73 */ 63 74 public void addPrimitive(OsmPrimitive primitive) { 64 75 this.primitives.add(primitive); 65 76 } 66 77 78 /** 79 * Clears all primitives (routes) from being displayed. 80 */ 67 81 public void clear() { 68 82 this.primitives.clear(); … … 82 96 public void addFixVariants(List<List<PTWay>> fixVariants) { 83 97 HashMap<List<PTWay>, Character> fixVariantLetterMap = new HashMap<>(); 84 98 85 99 char alphabet = 'A'; 86 100 for (int i = 0; i < 5 && i < fixVariants.size(); i++) { … … 91 105 } 92 106 93 for (Character currentFixVariantLetter: this.fixVariants.keySet()) { 107 for (Character currentFixVariantLetter : this.fixVariants.keySet()) { 94 108 List<PTWay> fixVariant = this.fixVariants.get(currentFixVariantLetter); 95 109 for (PTWay ptway : fixVariant) { -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/PTAssistantPaintVisitor.java
r32801 r32874 25 25 import org.openstreetmap.josm.tools.Pair; 26 26 27 /** 28 * Visits the primitives to be visualized in the pt_assistant layer 29 * 30 * @author darya 31 * 32 */ 27 33 public class PTAssistantPaintVisitor extends PaintVisitor { 28 34 … … 32 38 private final MapView mv; 33 39 40 /** 41 * Constructor 42 * 43 * @param g 44 * @param mv 45 */ 34 46 public PTAssistantPaintVisitor(Graphics g, MapView mv) { 35 47 super(g, mv); … … 141 153 } 142 154 155 /** 156 * Variation of the visit method that allows a special visualization of 157 * oneway roads 158 * 159 * @param nodes 160 * @param oneway 161 */ 143 162 public void visit(List<Node> nodes, int oneway) { 144 163 Node lastN = null; … … 270 289 } 271 290 291 /** 292 * Draws s stop_position as a blue circle; draws a platform as a blue square 293 * 294 * @param primitive 295 */ 272 296 protected void drawStop(OsmPrimitive primitive) { 273 297 … … 287 311 } 288 312 313 /** 314 * Draws the labels for the stops, which include the ordered position of the 315 * stop in the route and the ref numbers of other routes that use this stop 316 * 317 * @param primitive 318 * @param label 319 */ 289 320 protected void drawStopLabel(OsmPrimitive primitive, String label) { 290 321 … … 342 373 } 343 374 375 /** 376 * Compares route ref numbers 377 * @author darya 378 * 379 */ 344 380 private class RefTagComparator implements Comparator<String> { 345 381 … … 398 434 399 435 /** 400 * 436 * Visualizes the fix variants, assigns colors to them based on their order 401 437 * @param fixVariants 402 438 */ … … 538 574 } 539 575 576 /** 577 * Visuallizes the letters for each fix variant 578 * @param letter 579 * @param color 580 * @param letterX 581 * @param letterY 582 */ 540 583 private void drawFixVariantLetter(String letter, Color color, double letterX, double letterY) { 541 584 g.setColor(color); -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/PTAssistantPreferenceSetting.java
r32872 r32874 14 14 import org.openstreetmap.josm.tools.ImageProvider; 15 15 16 /** 17 * Displays the settings of the pt_assistant plugin under Preferences 18 * @author darya 19 * 20 */ 16 21 public class PTAssistantPreferenceSetting implements SubPreferenceSetting { 17 22 -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/ProceedDialog.java
r32871 r32874 15 15 import javax.swing.SwingUtilities; 16 16 17 /** 18 * Dialog that asks the user how to proceed after the first stage of testing 19 * (i.e. if the errors found in the first stage of testing should be fixed 20 * before continuing with the testing). 21 * 22 * @author darya 23 * 24 */ 17 25 public class ProceedDialog extends JPanel { 18 26 … … 44 52 45 53 if (true) { 46 JLabel label2 = new JLabel(" " + trn("{0} direction error", "{0} direction errors", numberOfDirectionErrors, numberOfDirectionErrors)); 54 JLabel label2 = new JLabel(" " + trn("{0} direction error", "{0} direction errors", 55 numberOfDirectionErrors, numberOfDirectionErrors)); 47 56 panel.add(label2); 48 57 label2.setAlignmentX(Component.LEFT_ALIGNMENT); … … 50 59 51 60 if (numberOfRoadTypeErrors != 0) { 52 JLabel label3 = new JLabel(" " + trn("{0} road type error", "{0} road type errors", numberOfRoadTypeErrors, numberOfRoadTypeErrors)); 61 JLabel label3 = new JLabel(" " + trn("{0} road type error", "{0} road type errors", 62 numberOfRoadTypeErrors, numberOfRoadTypeErrors)); 53 63 panel.add(label3); 54 64 label3.setAlignmentX(Component.LEFT_ALIGNMENT); … … 67 77 fixOptionButtonGroup.add(radioButtonDontFix); 68 78 panel.add(radioButtonFixAutomatically); 69 //panel.add(radioButtonFixManually);79 // panel.add(radioButtonFixManually); 70 80 panel.add(radioButtonDontFix); 71 81 radioButtonFixAutomatically.setAlignmentX(Component.LEFT_ALIGNMENT); -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/utils/RouteUtils.java
r32656 r32874 236 236 } 237 237 238 /** 239 * Checks if this way is suitable for public transport (not only for buses) 240 * @param way 241 * @return 242 */ 238 243 public static boolean isWaySuitableForPublicTransport(Way way) { 239 244 -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/Checker.java
r32793 r32874 135 135 136 136 if (testError.getCode() != PTAssistantValidatorTest.ERROR_CODE_STOP_BY_STOP 137 && testError.getCode() != PTAssistantValidatorTest.ERROR_CODE_DIRECTION) { 137 && testError.getCode() != PTAssistantValidatorTest.ERROR_CODE_DIRECTION 138 && testError.getCode() != PTAssistantValidatorTest.ERROR_CODE_CONSTRUCTION 139 && testError.getCode() != PTAssistantValidatorTest.ERROR_CODE_ROAD_TYPE) { 138 140 return null; 139 141 } -
applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/AbstractTest.java
r32871 r32874 54 54 public static final String PATH_TO_STOP_AREA_MANY_PLATFORMS = "test/data/stop-area-many-platforms.osm"; 55 55 56 56 57 public static final String PATH_TO_SEGMENT_TEST = "test/data/segment-test.osm"; 57 public static final String PATH_TO_REPEAT_FIX = "test/data/repeat-fix.osm";58 58 59 59 /** -
applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/SegmentCheckerTest.java
r32871 r32874 13 13 14 14 public class SegmentCheckerTest extends AbstractTest { 15 15 16 16 @Test 17 public void testStopByStopTest() { 18 17 public void test() { 18 19 19 20 File file = new File(AbstractTest.PATH_TO_SEGMENT_TEST); 20 21 DataSet ds = ImportUtils.importOsmFile(file, "testLayer"); 21 22 PTAssistantValidatorTest test = new PTAssistantValidatorTest(); 22 23 23 24 Relation route = null; 24 25 for (Relation r 25 26 for (Relation r: ds.getRelations()) { 26 27 if (RouteUtils.isTwoDirectionRoute(r)) { 27 28 route = r; … … 29 30 } 30 31 } 31 32 SegmentChecker.reset(); 32 33 33 SegmentChecker segmentChecker = new SegmentChecker(route, test); 34 34 segmentChecker.performStopByStopTest(); 35 35 assertEquals(SegmentChecker.getCorrectSegmentCount(), 27); 36 36 assertEquals(segmentChecker.getErrors().size(), 0); 37 } 38 39 /** 40 * Tests the stop-by-stop test 41 */ 42 @Test 43 public void testRepeatLastFix() { 44 File file = new File(AbstractTest.PATH_TO_REPEAT_FIX); 45 DataSet ds = ImportUtils.importOsmFile(file, "testLayer"); 46 PTAssistantValidatorTest test = new PTAssistantValidatorTest(); 47 48 Relation route123 = null; 49 Relation route130 = null; 50 Relation route168 = null; 51 Relation route184 = null; 52 53 for (Relation r : ds.getRelations()) { 54 if (r.getId() == 5379737) { 55 route123 = r; 56 } else if (r.getId() == 5379738) { 57 route130 = r; 58 } else if (r.getId() == 5379739) { 59 route168 = r; 60 } else if (r.getId() == 5379740) { 61 route184 = r; 62 } 63 } 64 65 SegmentChecker.reset(); 66 SegmentChecker segmentChecker123 = new SegmentChecker(route123, test); 67 SegmentChecker segmentChecker130 = new SegmentChecker(route130, test); 68 SegmentChecker segmentChecker168 = new SegmentChecker(route168, test); 69 SegmentChecker segmentChecker184 = new SegmentChecker(route184, test); 70 segmentChecker123.performStopByStopTest(); 71 // TestError error123 = segmentChecker123.getErrors().get(0); 72 // PTRouteSegment wrongSegment123 = SegmentChecker.getWrongSegment(error123); 73 segmentChecker130.performStopByStopTest(); 74 segmentChecker168.performStopByStopTest(); 75 segmentChecker184.performStopByStopTest(); 76 77 // Check the error number: 78 assertEquals(segmentChecker123.getErrors().size(), 1); 79 assertEquals(segmentChecker130.getErrors().size(), 1); 80 assertEquals(segmentChecker168.getErrors().size(), 1); 81 assertEquals(segmentChecker184.getErrors().size(), 0); 37 38 39 40 82 41 } 83 42 }
Note:
See TracChangeset
for help on using the changeset viewer.