Changeset 32415 in osm for applications/editors/josm/plugins/pt_assistant
- Timestamp:
- 2016-06-27T00:49:06+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/data/PTStop.java
r32367 r32415 52 52 * already has an attribute with that role. 53 53 */ 54 p ublicboolean addStopElement(RelationMember member) {54 protected boolean addStopElement(RelationMember member) { 55 55 56 56 // each element is only allowed once per stop … … 97 97 } 98 98 99 p ublicString getName() {99 protected String getName() { 100 100 return this.name; 101 101 } -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/utils/RouteUtils.java
r32367 r32415 1 1 package org.openstreetmap.josm.plugins.pt_assistant.utils; 2 2 3 import static org.openstreetmap.josm.tools.I18n.tr;4 5 import java.util.ArrayList;6 import java.util.List;7 8 import javax.swing.JCheckBox;9 import javax.swing.JOptionPane;10 11 import org.openstreetmap.josm.actions.DownloadPrimitiveAction;12 import org.openstreetmap.josm.data.osm.OsmPrimitive;13 3 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 14 import org.openstreetmap.josm.data.osm.PrimitiveId;15 4 import org.openstreetmap.josm.data.osm.Relation; 16 5 import org.openstreetmap.josm.data.osm.RelationMember; … … 45 34 || r.hasTag("route", "tram") || r.hasTag("route", "light_rail") || r.hasTag("route", "subway") 46 35 || r.hasTag("route", "train")) { 47 return true; 36 37 if (!r.hasTag("bus", "on_demand")) { 38 return true; 39 } 40 48 41 } 49 42 return false; … … 60 53 public static boolean isPTStop(RelationMember rm) { 61 54 62 if (rm.getType().equals(OsmPrimitiveType.NODE)) { 55 if (rm.hasRole("stop") || rm.hasRole("stop_entry_only") || rm.hasRole("stop_exit_only") 56 || rm.hasRole("platform") || rm.hasRole("platform_entry_only") || rm.hasRole("platform_exit_only")) { 63 57 64 if (rm.hasRole("stop") || rm.hasRole("stop_entry_only") || rm.hasRole("stop_exit_only") 65 || rm.hasRole("platform") || rm.hasRole("platform_entry_only") 66 || rm.hasRole("platform_exit_only")) { 58 if (rm.getType().equals(OsmPrimitiveType.NODE)) { 67 59 68 60 if (rm.getNode().hasTag("public_transport", "stop_position") 69 61 || rm.getNode().hasTag("highway", "bus_stop") 70 62 || rm.getNode().hasTag("public_transport", "platform") 71 || rm.getNode().hasTag("public_transport", "platform_entry_only") 72 || rm.getNode().hasTag("public_transport", "platform_exit_only") 73 || rm.getNode().hasTag("highway", "platform") 74 || rm.getNode().hasTag("highway", "platform_entry_only") 75 || rm.getNode().hasTag("highway", "platform_exit_only") 76 || rm.getNode().hasTag("railway", "platform") 77 || rm.getNode().hasTag("railway", "platform_entry_only") 78 || rm.getNode().hasTag("railway", "platform_exit_only")) { 63 || rm.getNode().hasTag("highway", "platform") || rm.getNode().hasTag("railway", "platform")) { 64 return true; 65 66 } 67 } 68 69 if (rm.getType().equals(OsmPrimitiveType.WAY)) { 70 if (rm.getWay().hasTag("public_transport", "platform") || rm.getWay().hasTag("highway", "platform") 71 || rm.getWay().hasTag("railway", "platform")) { 79 72 return true; 80 73 } 81 }82 }83 84 if (rm.getType().equals(OsmPrimitiveType.WAY)) {85 if (rm.getWay().hasTag("public_transport", "platform")86 || rm.getWay().hasTag("public_transport", "platform_entry_only")87 || rm.getWay().hasTag("public_transport", "platform_exit_only")88 || rm.getWay().hasTag("highway", "platform") || rm.getWay().hasTag("highway", "platform_entry_only")89 || rm.getWay().hasTag("highway", "platform_exist_only") || rm.getWay().hasTag("railway", "platform")90 || rm.getWay().hasTag("railway", "platform_entry_only")91 || rm.getWay().hasTag("railway", "platform_exit_only")) {92 return true;93 74 } 94 75 } … … 115 96 116 97 if (rm.getType().equals(OsmPrimitiveType.WAY)) { 98 if (rm.getWay().hasTag("public_transport", "platform") || rm.getWay().hasTag("highway", "platform") 99 || rm.getWay().hasTag("railway", "platform")) { 100 return false; 101 } 117 102 return true; 118 103 } -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/PTAssitantValidatorTest.java
r32367 r32415 7 7 8 8 import javax.swing.JOptionPane; 9 import javax.swing.SwingUtilities; 10 9 10 import org.openstreetmap.josm.Main; 11 11 import org.openstreetmap.josm.command.ChangeCommand; 12 12 import org.openstreetmap.josm.command.Command; 13 13 import org.openstreetmap.josm.command.SequenceCommand; 14 import org.openstreetmap.josm.data.osm.DataSet; 14 15 import org.openstreetmap.josm.data.osm.OsmPrimitive; 15 16 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; … … 24 25 import org.openstreetmap.josm.plugins.pt_assistant.actions.IncompleteMembersDownloadThread; 25 26 import org.openstreetmap.josm.plugins.pt_assistant.gui.IncompleteMembersDownloadDialog; 27 import org.openstreetmap.josm.plugins.pt_assistant.gui.PTAssistantLayer; 26 28 import org.openstreetmap.josm.plugins.pt_assistant.gui.ProceedDialog; 27 29 import org.openstreetmap.josm.plugins.pt_assistant.utils.RouteUtils; … … 31 33 public static final int ERROR_CODE_SORTING = 3711; 32 34 public static final int ERROR_CODE_ROAD_TYPE = 3721; 35 public static final int ERROR_CODE_CONSTRUCTION = 3722; 33 36 public static final int ERROR_CODE_DIRECTION = 3731; 34 37 public static final int ERROR_CODE_END_STOP = 3141; … … 36 39 public static final int ERROR_CODE_RELAITON_MEMBER_ROLES = 3143; 37 40 41 private PTAssistantLayer layer; 42 38 43 public PTAssitantValidatorTest() { 39 44 super(tr("Public Transport Assistant tests"), 40 45 tr("Check if route relations are compatible with public transport version 2")); 46 47 layer = new PTAssistantLayer(); 48 DataSet.addSelectionListener(layer); 41 49 42 50 } … … 60 68 return; 61 69 } 70 71 // if (!Main.getLayerManager().containsLayer(layer)) { 72 // Main.getLayerManager().addLayer(layer); 73 // } 74 // layer.clear(); 75 // layer.addPrimitive(r); 62 76 63 77 // Check individual ways using the oneway direction test and the road … … 192 206 // Check if the creation of the route data model in the segment checker 193 207 // worked. If it did not, it means the roles in the route relation do 194 // not match the tags of the route members. 208 // not match the tags of the route members. 195 209 if (!segmentChecker.getErrors().isEmpty()) { 196 210 this.errors.addAll(segmentChecker.getErrors()); … … 202 216 // TODO: perform segment test 203 217 this.errors.addAll(segmentChecker.getErrors()); 204 //performDummyTest(r);218 // performDummyTest(r); 205 219 } 206 220 … … 211 225 public boolean isFixable(TestError testError) { 212 226 if (testError.getCode() == ERROR_CODE_DIRECTION || testError.getCode() == ERROR_CODE_ROAD_TYPE 213 || testError.getCode() == ERROR_CODE_SORTING) { 227 || testError.getCode() == ERROR_CODE_CONSTRUCTION || testError.getCode() == ERROR_CODE_SORTING) { 214 228 return true; 215 229 } … … 222 236 List<Command> commands = new ArrayList<>(); 223 237 224 if (testError.getCode() == ERROR_CODE_DIRECTION || testError.getCode() == ERROR_CODE_ROAD_TYPE) { 238 if (testError.getCode() == ERROR_CODE_DIRECTION || testError.getCode() == ERROR_CODE_ROAD_TYPE 239 || testError.getCode() == ERROR_CODE_CONSTRUCTION) { 225 240 commands.add(fixErrorByRemovingWay(testError)); 226 241 } -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/RoadTypeTest.java
r32266 r32415 22 22 23 23 public static final int ERROR_CODE_ROAD_TYPE = 3721; 24 public static final int ERROR_CODE_CONSTRUCTION = 3722; 24 25 25 26 public RoadTypeTest() { … … 87 88 tr("PT: Route type does not match the type of the road it passes on"), ERROR_CODE_ROAD_TYPE, 88 89 primitives, highlighted)); 90 } 91 92 if ((way.hasTag("highway", "construction") || way.hasTag("railway", "construction")) && way.hasKey("construction")) { 93 List<Relation> primitives = new ArrayList<>(1); 94 primitives.add(r); 95 List<Way> highlighted = new ArrayList<>(1); 96 highlighted.add(way); 97 TestError e = new TestError(this, Severity.WARNING, 98 tr("PT: Road is under construction"), 99 PTAssitantValidatorTest.ERROR_CODE_CONSTRUCTION, primitives, highlighted); 100 errors.add(e); 89 101 } 90 102 … … 168 180 @Override 169 181 public boolean isFixable(TestError testError) { 170 if (testError.getCode() == ERROR_CODE_ROAD_TYPE) { 182 if (testError.getCode() == ERROR_CODE_ROAD_TYPE || testError.getCode() == ERROR_CODE_CONSTRUCTION) { 171 183 return true; 172 184 } -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/WayChecker.java
r32353 r32415 95 95 96 96 } 97 98 if ((way.hasTag("highway", "construction") || way.hasTag("railway", "construction")) && way.hasKey("construction")) { 99 List<Relation> primitives = new ArrayList<>(1); 100 primitives.add(relation); 101 List<Way> highlighted = new ArrayList<>(1); 102 highlighted.add(way); 103 TestError e = new TestError(this.test, Severity.WARNING, 104 tr("PT: Road is under construction"), 105 PTAssitantValidatorTest.ERROR_CODE_CONSTRUCTION, primitives, highlighted); 106 errors.add(e); 107 } 97 108 } 98 109 }
Note:
See TracChangeset
for help on using the changeset viewer.