Changeset 32822 in osm for applications/editors/josm/plugins/pt_assistant/src
- Timestamp:
- 2016-08-16T14:03:50+02:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/NodeChecker.java
r32797 r32822 5 5 import java.lang.reflect.InvocationTargetException; 6 6 import java.util.ArrayList; 7 import java.util.HashMap;8 7 import java.util.List; 9 8 … … 99 98 TestError e = new TestError(this.test, Severity.WARNING, 100 99 tr("PT: Stop position or platform is not part of a stop area relation"), 101 PTAssistantValidatorTest.ERROR_CODE_NO DE_PART_OF_STOP_AREA, primitives);100 PTAssistantValidatorTest.ERROR_CODE_NOT_PART_OF_STOP_AREA, primitives); 102 101 errors.add(e); 103 102 } 104 103 } 105 104 106 /**107 * Checks if the given stop_position belongs to the same route relations as108 * its related platform(s). *109 *110 * @param n111 */112 protected void performStopPositionComparePlatformRelations() {113 114 HashMap<Long, Long> stopPositionRelationIds = new HashMap<>();115 HashMap<Long, Long> platformRelationIds = new HashMap<>();116 117 // Loop through all referrer relations118 for (Relation referrer : OsmPrimitive.getFilteredList(node.getReferrers(), Relation.class)) {119 120 // Create list of relations the stop position belongs to121 if (referrer.get("type") == "route") {122 stopPositionRelationIds.put(referrer.getId(), referrer.getId());123 }124 125 // Create list of relations the related platform(s) belongs to126 else if (referrer.get("public_transport") == "stop_area") {127 for (RelationMember stopAreaMember : referrer.getMembers()) {128 OsmPrimitive stopAreaMemberFoo = stopAreaMember.getMember();129 if (stopAreaMemberFoo.get("public_transport") == "platform") {130 for (Relation stopAreaMemberReferrer : OsmPrimitive131 .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 the stop_position has no referrers at all. If it has no142 // referrers, then no error should be reported (changed on 11.08.2016 by143 // darya):144 if (stopPositionRelationIds.isEmpty()) {145 return;146 }147 148 // Check if route relation lists are identical149 if (stopPositionRelationIds.equals(platformRelationIds)) {150 return;151 }152 153 List<OsmPrimitive> primitives = new ArrayList<>(1);154 primitives.add(node);155 TestError e = new TestError(this.test, Severity.WARNING,156 tr("PT: Stop position and its related platform(s) have different route relations"),157 PTAssistantValidatorTest.ERROR_CODE_STOP_POSITION_COMPARE_RELATIONS, primitives);158 errors.add(e);159 }160 105 161 106 /** -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/PTAssistantValidatorTest.java
r32804 r32822 46 46 public static final int ERROR_CODE_STOP_NOT_SERVED = 3753; 47 47 public static final int ERROR_CODE_STOP_BY_STOP = 3754; 48 public static final int ERROR_CODE_STOP_POSITION_COMPARE_RELATIONS = 3755; 49 public static final int ERROR_CODE_NODE_PART_OF_STOP_AREA = 3761; 50 public static final int ERROR_CODE_STOP_AREA_MEMBERS_EXCESS = 3762; 51 public static final int ERROR_CODE_STOP_AREA_STOP_POSITION = 3763; 52 public static final int ERROR_CODE_STOP_AREA_PLATFORM = 3764; 53 public static final int ERROR_CODE_STOP_AREA_NO_STOPS = 3765; 54 public static final int ERROR_CODE_STOP_AREA_MANY_STOPS = 3765; 55 public static final int ERROR_CODE_STOP_AREA_NO_PLATFORM = 3766; 56 public static final int ERROR_CODE_STOP_AREA_MANY_PLATFORMS = 3767; 57 public static final int ERROR_CODE_STOP_AREA_MEMBERS_RELATIONS = 3768; 48 public static final int ERROR_CODE_NOT_PART_OF_STOP_AREA = 3761; 49 public static final int ERROR_CODE_STOP_AREA_NO_STOPS = 3762; 50 public static final int ERROR_CODE_STOP_AREA_NO_PLATFORM = 3763; 51 public static final int ERROR_CODE_STOP_AREA_COMPARE_RELATIONS = 3764; 52 58 53 59 54 … … 86 81 // check if stop positions are in any stop_area relation: 87 82 nodeChecker.performNodePartOfStopAreaTest(); 88 89 // Check if stop positions belong the same route relation as related platform(s) 90 nodeChecker.performStopPositionComparePlatformRelations(); 83 91 84 } 92 85 … … 115 108 // Check if stop area relation has one stop position. 116 109 stopChecker.performStopAreaStopPositionTest(); 117 118 // Check if stop area relation has more than one stop position.119 stopChecker.performStopAreaMultiStopPositionTest();120 110 121 111 // Check if stop area relation has one platform. 122 112 stopChecker.performStopAreaPlatformTest(); 123 124 // Check if stop area relation has more than one platform.125 stopChecker.performStopArea MultiPlatformTest();113 114 // Check if stop position(s) belong the same route relation as related platform(s) 115 stopChecker.performStopAreaRelationsTest(); 126 116 127 117 // Attach thrown errors -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/StopChecker.java
r32791 r32822 6 6 import java.util.List; 7 7 import java.util.Set; 8 import java.util.HashMap; 8 9 9 10 import org.openstreetmap.josm.data.osm.OsmPrimitive; 10 11 import org.openstreetmap.josm.data.osm.Relation; 12 import org.openstreetmap.josm.data.osm.RelationMember; 11 13 import org.openstreetmap.josm.data.validation.Severity; 12 14 import org.openstreetmap.josm.data.validation.Test; … … 50 52 } 51 53 52 /**53 * Checks if the given stop area relation has more than one stop position.54 */55 protected void performStopAreaMultiStopPositionTest() {56 57 // Count members tagged as stop position.58 int countStopPosition = 0;59 for (OsmPrimitive member : members) {60 if (StopUtils.verifyStopAreaStopPosition(member)) {61 countStopPosition++;62 63 }64 }65 66 // No errors if there are more than one stop position.67 if (countStopPosition <= 1) {68 return;69 }70 71 // Throw error message72 List<OsmPrimitive> primitives = new ArrayList<>(1);73 primitives.add(relation);74 TestError e = new TestError(this.test, Severity.WARNING, tr("PT: Stop area relation has several stop positions"),75 PTAssistantValidatorTest.ERROR_CODE_STOP_AREA_MANY_STOPS, primitives);76 errors.add(e);77 78 }79 54 80 55 /** … … 101 76 102 77 /** 103 * Checks if the given stop area relation has more than one platform. 78 * Checks if the stop_position(s) of an stop area belong to the same route relations as 79 * its related platform(s). 80 * 81 * @param n 104 82 */ 105 protected void performStopAreaMultiPlatformTest() { 106 107 // Count members tagged as platformn. 108 int countPlatform = 0; 83 protected void performStopAreaRelationsTest() { 84 85 HashMap<Long, Long> stopPositionRelationIds = new HashMap<>(); 86 HashMap<Long, Long> platformRelationIds = new HashMap<>(); 87 88 89 // Loop through all members 109 90 for (OsmPrimitive member : members) { 110 if (StopUtils.verifyStopAreaPlatform(member)) { 111 countPlatform++; 91 92 // For stop positions... 93 if (StopUtils.verifyStopAreaStopPosition(member)) { 94 95 // Create a list of assigned route relations 96 for (Relation referrer : OsmPrimitive.getFilteredList(member.getReferrers(), Relation.class)) { 97 if (referrer.get("type") == "route") { 98 stopPositionRelationIds.put(referrer.getId(), referrer.getId()); 99 } 100 } 101 } 102 103 // For platforms... 104 else if (StopUtils.verifyStopAreaPlatform(member)) { 112 105 113 } 106 // Create a list of assigned route relations 107 for (Relation referrer : OsmPrimitive.getFilteredList(member.getReferrers(), Relation.class)) { 108 if (referrer.get("type") == "route") { 109 platformRelationIds.put(referrer.getId(), referrer.getId()); 110 } 111 } 112 } 114 113 } 115 114 116 // No errors if there are more than one platformnn. 117 if (countPlatform <= 1) { 115 // Check if the stop_position has no referrers at all. If it has no 116 // referrers, then no error should be reported (changed on 11.08.2016 by 117 // darya): 118 if (stopPositionRelationIds.isEmpty()) { 118 119 return; 119 120 } 120 121 122 // Check if route relation lists are identical 123 if (stopPositionRelationIds.equals(platformRelationIds)) { 124 return; 125 } 126 121 127 // Throw error message 122 128 List<OsmPrimitive> primitives = new ArrayList<>(1); 123 129 primitives.add(relation); 124 TestError e = new TestError(this.test, Severity.WARNING, tr("PT: Stop area relation has several platforms"), 125 PTAssistantValidatorTest.ERROR_CODE_STOP_AREA_MANY_PLATFORMS, primitives); 130 TestError e = new TestError(this.test, Severity.WARNING, 131 tr("PT: Route relations of stop position(s) and platform(s) of stop area memebrs diverge"), 132 PTAssistantValidatorTest.ERROR_CODE_STOP_AREA_COMPARE_RELATIONS, primitives); 126 133 errors.add(e); 127 128 134 } 129 135
Note:
See TracChangeset
for help on using the changeset viewer.