Changeset 32222 in osm for applications
- Timestamp:
- 2016-06-08T00:50:46+02:00 (8 years ago)
- Location:
- applications/editors/josm
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/utils/RouteUtils.java
r32221 r32222 49 49 public static boolean isPTStop(RelationMember rm) { 50 50 51 return !isPTWay(rm); 51 if (rm.getType().equals(OsmPrimitiveType.NODE)) { 52 return true; 53 } 54 55 if (rm.getType().equals(OsmPrimitiveType.RELATION)) { 56 if (rm.getRole().equals("stop_area")) { 57 return true; 58 } else { 59 return false; 60 } 61 } 62 63 Way w = rm.getWay(); 64 65 if (w.hasTag("public_transport", "platform") || w.hasTag("highway", "platform") 66 || w.hasTag("railway", "platform") || w.hasTag("public_transport", "platform_entry_only") 67 || w.hasTag("highway", "platform_entry_only") || w.hasTag("railway", "platform_entry_only") 68 || w.hasTag("public_transport", "platform_exit_only") || w.hasTag("highway", "platform_exit_only") || w.hasTag("railway", "platform_exit_only")) { 69 return true; 70 } 71 72 return false; 52 73 53 74 } … … 65 86 public static boolean isPTWay(RelationMember rm) { 66 87 67 if (rm.hasRole("") && OsmPrimitiveType.WAY.equals(rm.getType())) { 68 Way way = rm.getWay(); 69 if (!way.hasTag("public_transport", "platform") && !way.hasTag("highway", "platform") 70 && !way.hasTag("railway", "platform")) { 71 return true; 72 } 73 } 74 75 return false; 88 return !isPTStop(rm); 76 89 } 77 90 … … 100 113 } 101 114 102 103 115 } -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/GapTest.java
r32221 r32222 79 79 80 80 /** 81 * Checks if there is a gap for a given list of ways 81 * Checks if there is a gap for a given list of ways. It does not check if 82 * the way actually stands for a public transport platform - that should be 83 * checked beforehand. 82 84 * 83 85 * @param waysToCheck … … 177 179 final List<RelationMember> ways = new ArrayList<>(); 178 180 for (RelationMember member : members) { 179 if (member.hasRole("") && OsmPrimitiveType.WAY.equals(member.getType())) { // FIXME 180 ways.add(member); 181 } else { // stops (and if the relation has anything 182 // besides ways and stops: 183 stops.add(member); 181 if (RouteUtils.isPTWay(member)) { 182 if (member.getRole().equals("")) { 183 ways.add(member); 184 } else { 185 RelationMember modifiedMember = new RelationMember("", member.getWay()); 186 ways.add(modifiedMember); 187 } 188 189 } else { // stops: 190 if (member.getRole().equals("stop_positon")) { 191 // it is not expected that stop_positions could be relations 192 if (member.getType().equals(OsmPrimitiveType.NODE)) { 193 RelationMember modifiedMember = new RelationMember("stop", member.getNode()); 194 stops.add(modifiedMember); 195 } else { // if it is a primitive of type way: 196 RelationMember modifiedMember = new RelationMember("stop", member.getWay()); 197 stops.add(modifiedMember); 198 } 199 } else { // if it is not a stop_position: 200 stops.add(member); 201 } 202 184 203 } 185 204 } … … 218 237 for (RelationMember rm : originalRelation.getMembers()) { 219 238 if (RouteUtils.isPTStop(rm)) { 220 modifiedMembers.add(rm); 239 if (rm.hasRole("stop_position")) { 240 // it is not expected that stop_positions could be relations 241 if (rm.getType().equals(OsmPrimitiveType.NODE)) { 242 RelationMember modifiedMember = new RelationMember("stop", rm.getNode()); 243 modifiedMembers.add(modifiedMember); 244 } else { // if it is a primitive of type "way": 245 RelationMember modifiedMember = new RelationMember("stop", rm.getWay()); 246 modifiedMembers.add(modifiedMember); 247 } 248 } else { 249 modifiedMembers.add(rm); 250 } 251 221 252 } 222 223 } 224 // add ways of a public transport route (if they are not overshoots): 225 for (RelationMember rm: originalRelation.getMembers()) { 226 if (RouteUtils.isPTWay(rm) && !overshootList.contains(rm)) { 227 modifiedMembers.add(rm); 253 254 } 255 // add ways of a public transport route (if they are not 256 // overshoots): 257 for (RelationMember rm : originalRelation.getMembers()) { 258 if (RouteUtils.isPTWay(rm) && !overshootList.contains(rm)) { 259 260 if (rm.getRole().equals("")) { 261 modifiedMembers.add(rm); 262 } else { 263 RelationMember modifiedMember = new RelationMember("", rm.getWay()); 264 modifiedMembers.add(modifiedMember); 265 } 228 266 } 229 267 } -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/RoadTypeTest.java
r32221 r32222 10 10 import org.openstreetmap.josm.command.SequenceCommand; 11 11 import org.openstreetmap.josm.data.osm.OsmPrimitive; 12 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 12 13 import org.openstreetmap.josm.data.osm.Relation; 13 14 import org.openstreetmap.josm.data.osm.RelationMember; … … 31 32 32 33 if (RouteUtils.isTwoDirectionRoute(r)) { 33 34 34 35 List<RelationMember> members = r.getMembers(); 35 36 36 37 for (RelationMember rm : members) { 37 38 if (RouteUtils.isPTWay(rm)) { 38 39 39 40 Way way = rm.getWay(); 40 41 // at this point, the relation has already been checked to … … 42 43 boolean isCorrectRoadType = true; 43 44 if (r.hasTag("route", "bus") || r.hasTag("route", "share_taxi")) { 45 if (way.getId()==388339788 || way.getId() == 388339789) { 46 47 } 44 48 if (!RouteUtils.isWaySuitableForBuses(way)) { 45 49 isCorrectRoadType = false; … … 72 76 73 77 if (!isCorrectRoadType) { 78 74 79 List<OsmPrimitive> primitiveList = new ArrayList<>(2); 75 80 primitiveList.add(0, r); … … 91 96 List<Command> commands = new ArrayList<>(50); 92 97 93 if (testError.getTester().getClass().equals( GapTest.class) && testError.isFixable()) {98 if (testError.getTester().getClass().equals(RoadTypeTest.class) && testError.isFixable()) { 94 99 List<OsmPrimitive> primitiveList = (List<OsmPrimitive>) testError.getPrimitives(); 95 100 Relation originalRelation = (Relation) primitiveList.get(0); … … 99 104 List<RelationMember> modifiedRelationMembers = new ArrayList<>(originalRelation.getMembersCount()-1); 100 105 101 // copy stop-related members first, public transportways last:106 // copy PT stops first, PT ways last: 102 107 for (RelationMember rm: originalRelation.getMembers()) { 103 108 if (RouteUtils.isPTStop(rm)) { 104 modifiedRelationMembers.add(rm); 109 110 if (rm.getRole().equals("stop_position")) { 111 if (rm.getType().equals(OsmPrimitiveType.NODE)) { 112 RelationMember newMember = new RelationMember("stop", rm.getNode()); 113 modifiedRelationMembers.add(newMember); 114 } else { // if it is a way: 115 RelationMember newMember = new RelationMember("stop", rm.getWay()); 116 modifiedRelationMembers.add(newMember); 117 } 118 } else { 119 // if the relation member does not have the role "stop_position": 120 modifiedRelationMembers.add(rm); 121 } 122 105 123 } 106 124 } 107 125 126 // now copy PT ways: 108 127 for (RelationMember rm: originalRelation.getMembers()) { 109 128 if (RouteUtils.isPTWay(rm)) { 110 129 Way wayToCheck = rm.getWay(); 111 130 if (wayToCheck != wayToRemove) { 112 modifiedRelationMembers.add(rm); 131 if (rm.getRole().equals("forward") || rm.getRole().equals("backward")) { 132 RelationMember modifiedMember = new RelationMember("", wayToCheck); 133 modifiedRelationMembers.add(modifiedMember); 134 } else { 135 modifiedRelationMembers.add(rm); 136 } 113 137 } 114 138 } … … 129 153 return commands.get(0); 130 154 } 155 131 156 132 157 return new SequenceCommand(tr("Remove way from route if it does not match the route type"), commands); }
Note:
See TracChangeset
for help on using the changeset viewer.