Changeset 32783 in osm for applications/editors
- Timestamp:
- 2016-08-08T18:48:10+02:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/pt_assistant
- Files:
-
- 9 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/ProceedDialog.java
r32540 r32783 60 60 61 61 radioButtonFixAutomatically = new JRadioButton("Fix all errors automatically and proceed"); 62 radioButtonFixManually = new JRadioButton("I will fix the erro s manually and click the button to proceed");62 radioButtonFixManually = new JRadioButton("I will fix the errors manually and click the button to proceed"); 63 63 radioButtonDontFix = new JRadioButton("Do not fix anything and proceed with further tests", true); 64 64 ButtonGroup fixOptionButtonGroup = new ButtonGroup(); -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/NodeChecker.java
r32650 r32783 6 6 import java.util.ArrayList; 7 7 import java.util.List; 8 import java.util.Set; 9 import java.util.LinkedList; 10 import java.util.Collection; 11 import java.util.HashMap; 12 import java.util.Collections; 8 13 9 14 import javax.swing.JOptionPane; … … 18 23 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 19 24 import org.openstreetmap.josm.data.osm.Way; 25 import org.openstreetmap.josm.data.osm.Relation; 26 import org.openstreetmap.josm.data.osm.RelationMember; 20 27 import org.openstreetmap.josm.data.validation.Severity; 21 28 import org.openstreetmap.josm.data.validation.Test; 22 29 import org.openstreetmap.josm.data.validation.TestError; 23 30 import org.openstreetmap.josm.plugins.pt_assistant.utils.RouteUtils; 31 import org.openstreetmap.josm.plugins.pt_assistant.utils.StopUtils; 24 32 25 33 public class NodeChecker extends Checker { … … 81 89 } 82 90 } 91 92 /** 93 * Checks if the given stop_position node belongs to any stop_area relation 94 * 95 * @param n 96 */ 97 protected void performNodePartOfStopAreaTest() { 98 99 if (!StopUtils.verifyIfMemberOfStopArea(node)) { 100 101 List<OsmPrimitive> primitives = new ArrayList<>(1); 102 primitives.add(node); 103 TestError e = new TestError(this.test, Severity.WARNING, tr("PT: Stop position or platform is not part of a stop area relation"), 104 PTAssistantValidatorTest.ERROR_CODE_NODE_PART_OF_STOP_AREA, primitives); 105 errors.add(e); 106 } 107 } 108 109 /** 110 * Checks if the given stop_position belongs to the same route relations as it's related platform(s). * 111 * @param n 112 */ 113 protected void performStopPositionComparePlatformRelations() { 114 115 HashMap<Long, Long> stopPositionRelationIds = new HashMap<>(); 116 HashMap<Long, Long> platformRelationIds = new HashMap<>(); 117 118 // Loop through all referrer relations 119 for (Relation referrer : OsmPrimitive.getFilteredList(node.getReferrers(), Relation.class)) { 120 121 // Create list of relations the stop position belongs to 122 if (referrer.get("type") == "route") { 123 stopPositionRelationIds.put(referrer.getId(), referrer.getId()); 124 } 125 126 // Create list of relations the related platform(s) belongs to 127 else if (referrer.get("public_transport") == "stop_area") { 128 for (RelationMember stopAreaMember : referrer.getMembers()) { 129 Node stopAreaMemberFoo = stopAreaMember.getNode(); 130 if (stopAreaMemberFoo.get("public_transport") == "platform") { 131 for (Relation stopAreaMemberReferrer : OsmPrimitive.getFilteredList(stopAreaMemberFoo.getReferrers(), Relation.class)) { 132 if (stopAreaMemberReferrer.get("type") == "route") { 133 platformRelationIds.put(stopAreaMemberReferrer.getId(), stopAreaMemberReferrer.getId()); 134 } 135 } 136 } 137 } 138 } 139 } 140 141 // Check if route relation lists are identical 142 if (stopPositionRelationIds.equals(platformRelationIds)) { 143 return; 144 } 145 146 List<OsmPrimitive> primitives = new ArrayList<>(1); 147 primitives.add(node); 148 TestError e = new TestError(this.test, Severity.WARNING, tr("PT: Stop position and it's related platform(s) have different route relations"), 149 PTAssistantValidatorTest.ERROR_CODE_STOP_POSITION_COMPARE_RELATIONS, primitives); 150 errors.add(e); 151 } 152 83 153 84 154 /** -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/PTAssistantValidatorTest.java
r32776 r32783 5 5 import java.lang.reflect.InvocationTargetException; 6 6 import java.util.ArrayList; 7 import java.util.Collection; 8 import java.util.LinkedList; 7 9 import java.util.List; 10 import java.util.Set; 8 11 9 12 import javax.swing.JOptionPane; … … 14 17 import org.openstreetmap.josm.data.osm.DataSet; 15 18 import org.openstreetmap.josm.data.osm.Node; 19 import org.openstreetmap.josm.data.osm.OsmPrimitive; 16 20 import org.openstreetmap.josm.data.osm.Relation; 17 21 import org.openstreetmap.josm.data.osm.Way; … … 29 33 import org.openstreetmap.josm.plugins.pt_assistant.gui.ProceedDialog; 30 34 import org.openstreetmap.josm.plugins.pt_assistant.utils.RouteUtils; 35 import org.openstreetmap.josm.plugins.pt_assistant.utils.StopUtils; 31 36 import org.openstreetmap.josm.plugins.pt_assistant.utils.StopToWayAssigner; 32 37 … … 44 49 public static final int ERROR_CODE_STOP_NOT_SERVED = 3753; 45 50 public static final int ERROR_CODE_STOP_BY_STOP = 3754; 51 public static final int ERROR_CODE_STOP_POSITION_COMPARE_RELATIONS = 3755; 52 public static final int ERROR_CODE_NODE_PART_OF_STOP_AREA = 3761; 53 public static final int ERROR_CODE_STOP_AREA_MEMBERS_EXCESS = 3762; 54 public static final int ERROR_CODE_STOP_AREA_STOP_POSITION = 3763; 55 public static final int ERROR_CODE_STOP_AREA_PLATFORM = 3764; 56 public static final int ERROR_CODE_STOP_AREA_NO_STOPS = 3765; 57 public static final int ERROR_CODE_STOP_AREA_MANY_STOPS = 3765; 58 public static final int ERROR_CODE_STOP_AREA_NO_PLATFORM = 3766; 59 public static final int ERROR_CODE_STOP_AREA_MANY_PLATFORMS = 3767; 60 public static final int ERROR_CODE_STOP_AREA_MEMBERS_RELATIONS = 3768; 61 46 62 47 63 private PTAssistantLayer layer; … … 65 81 NodeChecker nodeChecker = new NodeChecker(n, this); 66 82 67 // check for solitary stop positions:83 // select only stop_positions 68 84 if (n.hasTag("public_transport", "stop_position")) { 85 86 // check if stop positions are on a way: 69 87 nodeChecker.performSolitaryStopPositionTest(); 70 } 71 72 // check that platforms are not part of any way: 88 89 // check if stop positions are in any stop_area relation: 90 nodeChecker.performNodePartOfStopAreaTest(); 91 92 // Check if stop positions belong the same route relation as related platform(s) 93 nodeChecker.performStopPositionComparePlatformRelations(); 94 } 95 96 // select only platforms 73 97 if (n.hasTag("public_transport", "platform")) { 98 99 // check that platforms are not part of any way: 74 100 nodeChecker.performPlatformPartOfWayTest(); 75 } 76 101 102 // check if platforms are in any stop_area relation: 103 nodeChecker.performNodePartOfStopAreaTest(); 104 } 105 77 106 this.errors.addAll(nodeChecker.getErrors()); 78 107 … … 81 110 @Override 82 111 public void visit(Relation r) { 112 113 // Do some testing on stop area relations 114 if (StopUtils.isStopArea(r)) { 115 116 StopChecker stopChecker = new StopChecker(r, this); 117 118 // Check if stop area relation has one stop position. 119 stopChecker.performStopAreaStopPositionTest(); 120 121 // Check if stop area relation has more than one stop position. 122 stopChecker.performStopAreaMultiStopPositionTest(); 123 124 // Check if stop area relation has one platform. 125 stopChecker.performStopAreaPlatformTest(); 126 127 // Check if stop area relation has more than one platform. 128 stopChecker.performStopAreaMultiPlatformTest(); 129 130 // Attach thrown errors 131 this.errors.addAll(stopChecker.getErrors()); 132 } 83 133 84 134 if (!RouteUtils.isTwoDirectionRoute(r)) { -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/WayChecker.java
r32656 r32783 230 230 231 231 /** 232 * Checks if the current way touches its neighbo ring was correctly232 * Checks if the current way touches its neighbouring was correctly 233 233 * 234 234 * @param prev -
applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/AbstractTest.java
r32707 r32783 46 46 47 47 public static final String PATH_TO_SOLITARY_STOP_POSITION = "test/data/solitary-stop-position.osm"; 48 49 public static final String PATH_TO_STOP_AREA_MEMBERS = "test/data/stop-area-members.osm"; 50 public static final String PATH_TO_STOP_AREA_RELATIONS = "test/data/stop-area-relations.osm"; 51 public static final String PATH_TO_STOP_AREA_NO_STOPS = "test/data/stop-area-no-stops.osm"; 52 public static final String PATH_TO_STOP_AREA_MANY_STOPS = "test/data/stop-area-many-stops.osm"; 53 public static final String PATH_TO_STOP_AREA_NO_PLATFORMS = "test/data/stop-area-no-platform.osm"; 54 public static final String PATH_TO_STOP_AREA_MANY_PLATFORMS = "test/data/stop-area-many-platforms.osm"; 55 48 56 49 57 public static final String PATH_TO_SEGMENT_TEST = "test/data/segment-test.osm";
Note:
See TracChangeset
for help on using the changeset viewer.