Changeset 32567 in osm for applications/editors/josm/plugins/pt_assistant/src
- Timestamp:
- 2016-07-05T00:28:27+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant
- Files:
-
- 2 added
- 6 edited
-
PTAssistantPlugin.java (modified) (3 diffs)
-
actions/AddStopPositionAction.java (added)
-
gui/PTAssistantLayer.java (modified) (2 diffs)
-
utils/RouteUtils.java (modified) (2 diffs)
-
validation/PTAssistantValidatorTest.java (added)
-
validation/RouteChecker.java (modified) (2 diffs)
-
validation/SegmentChecker.java (modified) (4 diffs)
-
validation/WayChecker.java (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/PTAssistantPlugin.java
r32522 r32567 2 2 package org.openstreetmap.josm.plugins.pt_assistant; 3 3 4 import javax.swing.JMenuItem; 5 6 import org.openstreetmap.josm.Main; 4 7 import org.openstreetmap.josm.data.validation.OsmValidator; 8 import org.openstreetmap.josm.gui.MainMenu; 9 import org.openstreetmap.josm.gui.MapFrame; 5 10 import org.openstreetmap.josm.plugins.Plugin; 6 11 import org.openstreetmap.josm.plugins.PluginInformation; 7 import org.openstreetmap.josm.plugins.pt_assistant.validation.PTAssitantValidatorTest; 12 import org.openstreetmap.josm.plugins.pt_assistant.actions.AddStopPositionAction; 13 import org.openstreetmap.josm.plugins.pt_assistant.validation.PTAssistantValidatorTest; 14 import org.openstreetmap.josm.tools.ImageProvider; 8 15 9 16 /** … … 14 21 */ 15 22 public class PTAssistantPlugin extends Plugin { 16 23 24 private JMenuItem addStopPositionMenu; 25 17 26 /** 18 27 * Main constructor. … … 25 34 super(info); 26 35 27 // OsmValidator.addTest(PlatformsFirstTest.class); 28 // OsmValidator.addTest(RoadTypeTest.class); 29 // OsmValidator.addTest(DirectionTest.class); 30 // OsmValidator.addTest(GapTest.class); 36 OsmValidator.addTest(PTAssistantValidatorTest.class); 31 37 32 OsmValidator.addTest(PTAssitantValidatorTest.class);33 38 AddStopPositionAction addStopPositionAction = new AddStopPositionAction(); 39 addStopPositionMenu = MainMenu.add(Main.main.menu.toolsMenu, addStopPositionAction, false); 34 40 35 41 } 42 43 /** 44 * Called when the JOSM map frame is created or destroyed. 45 */ 46 @Override 47 public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) { 48 if (oldFrame == null && newFrame != null) { 49 addStopPositionMenu.setEnabled(true); 50 } else if (oldFrame != null && newFrame == null) { 51 addStopPositionMenu.setEnabled(false); 52 } 53 } 36 54 37 38 39 55 /** 56 * Returns a ImageProvider for the given string or null if in headless mode. 57 * 58 * @param s 59 * The name of the file where the picture is. 60 * @return A ImageProvider object for the given string or null if in 61 * headless mode. 62 */ 63 public static ImageProvider getProvider(String s) { 64 if (Main.main == null) { 65 return null; 66 } 67 return new ImageProvider(s); 68 } 40 69 41 70 } -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/PTAssistantLayer.java
r32540 r32567 176 176 } 177 177 178 Main.map.repaint(); 178 Main.map.mapView.repaint(); 179 179 } 180 180 … … 200 200 201 201 this.primitives.clear(); 202 Main.map.repaint(); 202 Main.map.mapView.repaint(); 203 203 } 204 204 -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/utils/RouteUtils.java
r32415 r32567 4 4 import org.openstreetmap.josm.data.osm.Relation; 5 5 import org.openstreetmap.josm.data.osm.RelationMember; 6 import org.openstreetmap.josm.data.osm.Way;7 6 8 7 /** … … 114 113 } 115 114 116 /**117 * Checks if the type of the way is suitable for buses to go on it. The118 * direction of the way (i.e. one-way roads) is irrelevant for this test.119 *120 * TODO: this test is duplicated in WayChecker, remove it here when the old121 * implementation is not needed anymore.122 *123 * @deprecated124 *125 * @param way126 * to be checked127 * @return true if the way is suitable for buses, false otherwise.128 */129 public static boolean isWaySuitableForBuses(Way way) {130 if (way.hasTag("highway", "motorway") || way.hasTag("highway", "trunk") || way.hasTag("highway", "primary")131 || way.hasTag("highway", "secondary") || way.hasTag("highway", "tertiary")132 || way.hasTag("highway", "unclassified") || way.hasTag("highway", "road")133 || way.hasTag("highway", "residential") || way.hasTag("highway", "service")134 || way.hasTag("highway", "motorway_link") || way.hasTag("highway", "trunk_link")135 || way.hasTag("highway", "primary_link") || way.hasTag("highway", "secondary_link")136 || way.hasTag("highway", "tertiary_link") || way.hasTag("highway", "living_street")137 || way.hasTag("highway", "bus_guideway") || way.hasTag("highway", "road")138 || way.hasTag("cycleway", "share_busway") || way.hasTag("cycleway", "shared_lane")) {139 return true;140 }141 142 if (way.hasTag("highway", "pedestrian") && (way.hasTag("bus", "yes") || way.hasTag("psv", "yes")143 || way.hasTag("bus", "designated") || way.hasTag("psv", "designated"))) {144 return true;145 }146 147 return false;148 }149 150 public static boolean hasIncompleteMembers(Relation r) {151 if (r == null) {152 return true;153 }154 for (RelationMember rm : r.getMembers()) {155 if ((rm.isNode() && rm.getNode().isIncomplete()) || (rm.isWay() && rm.getWay().isIncomplete())156 || (rm.isRelation() && rm.getRelation().isIncomplete())) {157 return true;158 }159 }160 161 return false;162 }163 164 115 } -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/RouteChecker.java
r32497 r32567 65 65 TestError e = new TestError(this.test, Severity.WARNING, 66 66 tr("PT: Route contains a gap that can be fixed by sorting"), 67 PTAssitantValidatorTest.ERROR_CODE_SORTING, relation); 67 PTAssistantValidatorTest.ERROR_CODE_SORTING, relation); 68 68 this.errors.add(e); 69 69 … … 112 112 113 113 protected static Command fixSortingError(TestError testError) { 114 if (testError.getCode() != PTAssitantValidatorTest.ERROR_CODE_SORTING) { 114 if (testError.getCode() != PTAssistantValidatorTest.ERROR_CODE_SORTING) { 115 115 return null; 116 116 } -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/SegmentChecker.java
r32522 r32567 52 52 highlighted.add(rm.getMember()); 53 53 TestError e = new TestError(this.test, Severity.WARNING, tr("PT: Relation member roles do not match tags"), 54 PTAssitantValidatorTest.ERROR_CODE_RELAITON_MEMBER_ROLES, primitives, highlighted); 54 PTAssistantValidatorTest.ERROR_CODE_RELAITON_MEMBER_ROLES, primitives, highlighted); 55 55 this.errors.add(e); 56 56 } … … 112 112 TestError e = new TestError(this.test, Severity.WARNING, 113 113 tr("PT: Route should start and end with a stop_position"), 114 PTAssitantValidatorTest.ERROR_CODE_END_STOP, primitives, highlighted); 114 PTAssistantValidatorTest.ERROR_CODE_END_STOP, primitives, highlighted); 115 115 this.errors.add(e); 116 116 return; … … 130 130 131 131 TestError e = new TestError(this.test, Severity.WARNING, tr("PT: First or last way needs to be split"), 132 PTAssitantValidatorTest.ERROR_CODE_SPLIT_WAY, primitives, highlighted); 132 PTAssistantValidatorTest.ERROR_CODE_SPLIT_WAY, primitives, highlighted); 133 133 this.errors.add(e); 134 134 } … … 146 146 highlighted.add(endStop.getStopPosition()); 147 147 TestError e = new TestError(this.test, Severity.WARNING, tr("PT: First or last way needs to be split"), 148 PTAssitantValidatorTest.ERROR_CODE_SPLIT_WAY, primitives, highlighted); 148 PTAssistantValidatorTest.ERROR_CODE_SPLIT_WAY, primitives, highlighted); 149 149 this.errors.add(e); 150 150 } -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/WayChecker.java
r32557 r32567 121 121 TestError e = new TestError(this.test, Severity.WARNING, 122 122 tr("PT: Route type does not match the type of the road it passes on"), 123 PTAssitantValidatorTest.ERROR_CODE_ROAD_TYPE, primitives, highlighted); 123 PTAssistantValidatorTest.ERROR_CODE_ROAD_TYPE, primitives, highlighted); 124 124 errors.add(e); 125 125 … … 132 132 highlighted.add(way); 133 133 TestError e = new TestError(this.test, Severity.WARNING, tr("PT: Road is under construction"), 134 PTAssitantValidatorTest.ERROR_CODE_CONSTRUCTION, primitives, highlighted); 134 PTAssistantValidatorTest.ERROR_CODE_CONSTRUCTION, primitives, highlighted); 135 135 errors.add(e); 136 136 } … … 180 180 TestError e = new TestError(this.test, Severity.WARNING, 181 181 tr("PT: Route passes a oneway road in the wrong direction"), 182 PTAssitantValidatorTest.ERROR_CODE_DIRECTION, primitives, highlighted); 182 PTAssistantValidatorTest.ERROR_CODE_DIRECTION, primitives, highlighted); 183 183 this.errors.add(e); 184 184 return; … … 221 221 protected static Command fixErrorByRemovingWay(TestError testError) { 222 222 223 if (testError.getCode() != PTAssitantValidatorTest.ERROR_CODE_ROAD_TYPE 224 && testError.getCode() != PTAssitantValidatorTest.ERROR_CODE_DIRECTION) { 223 if (testError.getCode() != PTAssistantValidatorTest.ERROR_CODE_ROAD_TYPE 224 && testError.getCode() != PTAssistantValidatorTest.ERROR_CODE_DIRECTION) { 225 225 return null; 226 226 } … … 279 279 protected static Command fixErrorByZooming(TestError testError) { 280 280 281 if (testError.getCode() != PTAssitantValidatorTest.ERROR_CODE_DIRECTION) { 281 if (testError.getCode() != PTAssistantValidatorTest.ERROR_CODE_DIRECTION) { 282 282 return null; 283 283 } … … 337 337 GenericRelationEditor editor = new GenericRelationEditor(layer, r, r.getMembersFor(primitives)); 338 338 RelationDialogManager.getRelationDialogManager().register(layer, r, editor); 339 340 341 339 editor.setVisible(true); 342 // editor.requestFocus(); 343 // editor.requestFocusInWindow(); 344 345 // editor.firePropertyChange("focusedWindow", editor, editor); 346 // editor.setRelation(r); 340 347 341 348 342 }
Note:
See TracChangeset
for help on using the changeset viewer.
