Changeset 33433 in osm
- Timestamp:
- 2017-07-10T11:06:12+02:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/actions/SortPTStopsAction.java
r33432 r33433 51 51 for (int i = 0; i < members.size(); i++) { 52 52 RelationMember rm = members.get(i); 53 String role = rm.getRole(); 54 if (role != null && (role.startsWith("platform") || role.startsWith("stop"))) 53 if (PTStop.isPTPlatform(rm) || PTStop.isPTStopPosition(rm)) 55 54 stops.add(rm); 56 55 else { … … 62 61 63 62 Map<String, PTStop> stopsByName = new HashMap<>(); 63 List<PTStop> unnamed = new ArrayList<>(); 64 64 stops.forEach(rm -> { 65 65 String name = getStopName(rm.getMember()); … … 69 69 else 70 70 stopsByName.get(name).addStopElement(rm); 71 } else { 72 unnamed.add(new PTStop(rm)); 71 73 } 72 74 }); … … 76 78 Map<Way, List<PTStop>> wayStop = new HashMap<>(); 77 79 ptstops.forEach(stop -> { 80 Way way = assigner.get(stop); 81 if (!wayStop.containsKey(way)) 82 wayStop.put(way, new ArrayList<PTStop>()); 83 wayStop.get(way).add(stop); 84 }); 85 86 unnamed.forEach(stop -> { 78 87 Way way = assigner.get(stop); 79 88 if (!wayStop.containsKey(way)) … … 103 112 private static String getStopName(OsmPrimitive p) { 104 113 for (Relation ref : Utils.filteredCollection(p.getReferrers(), Relation.class)) { 105 if (ref.hasTag("type", "public_transport") && ref.hasTag("public_transport", "stop_area") && ref.getName() != null) { 114 if (ref.hasTag("type", "public_transport") 115 && ref.hasTag("public_transport", "stop_area") 116 && ref.getName() != null) { 106 117 return ref.getName(); 107 118 } -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/data/PTStop.java
r33432 r33433 42 42 * used in the plugin 43 43 */ 44 public PTStop(RelationMember other) throws IllegalArgumentException{44 public PTStop(RelationMember other) { 45 45 46 46 super(other); 47 47 48 // if ((other.hasRole("stop") || other.hasRole("stop_entry_only") || 49 // other.hasRole("stop_exit_only")) 50 // && other.getType().equals(OsmPrimitiveType.NODE)) { 51 52 if (other.getMember().hasTag("public_transport", "stop_position")) { 53 54 this.stopPosition = other.getNode(); 55 this.name = stopPosition.get("name"); 56 setStopPositionRM(other); 57 // } else if (other.getRole().equals("platform") || 58 // other.getRole().equals("platform_entry_only") 59 // || other.getRole().equals("platform_exit_only")) { 60 } else if (other.getMember().hasTag("highway", "bus_stop") 61 || other.getMember().hasTag("public_transport", "platform") 62 || other.getMember().hasTag("highway", "platform") || other.getMember().hasTag("railway", "platform")) { 63 64 this.platform = other.getMember(); 65 this.name = platform.get("name"); 66 setPlatformRM(other); 67 48 if (isPTStopPosition(other)) { 49 stopPosition = other.getNode(); 50 name = stopPosition.get("name"); 51 setStopPositionRM(new RelationMember("stop", other.getMember())); 52 } else if (isPTPlatform(other)) { 53 platform = other.getMember(); 54 name = platform.get("name"); 55 setPlatformRM(new RelationMember("platform", other.getMember())); 68 56 } else { 69 57 throw new IllegalArgumentException( 70 58 "The RelationMember type does not match its role " + other.getMember().getName()); 71 59 } 72 73 60 } 74 61 … … 85 72 public boolean addStopElement(RelationMember member) { 86 73 87 // each element is only allowed once per stop 88 89 // add stop position: 90 // if (member.hasRole("stop") || member.hasRole("stop_entry_only") || 91 // member.hasRole("stop_exit_only")) { 92 if (member.getMember().hasTag("public_transport", "stop_position")) { 93 if (member.getType().equals(OsmPrimitiveType.NODE) && stopPosition == null) { 94 this.stopPosition = member.getNode(); 95 stopPositionRM = member; 96 return true; 97 } 98 } 99 100 // add platform: 101 // if (member.getRole().equals("platform") || 102 // member.getRole().equals("platform_entry_only") 103 // || member.getRole().equals("platform_exit_only")) { 104 if (member.getMember().hasTag("highway", "bus_stop") 105 || member.getMember().hasTag("public_transport", "platform") 106 || member.getMember().hasTag("highway", "platform") 107 || member.getMember().hasTag("railway", "platform")) { 108 if (platform == null) { 109 platform = member.getMember(); 110 platformRM = member; 111 return true; 112 } 74 if (stopPosition == null && isPTStopPosition(member)) { 75 this.stopPosition = member.getNode(); 76 stopPositionRM = new RelationMember("stop", member.getMember()); 77 return true; 78 } else if (platform == null && isPTPlatform(member)) { 79 platform = member.getMember(); 80 platformRM = new RelationMember("platform", member.getMember()); 81 return true; 113 82 } 114 83 115 84 return false; 116 117 85 } 118 86 … … 210 178 } 211 179 212 if (this.platform != null 213 && (this.platform == other.getPlatform() || this.platform == other.getStopPosition())) { 214 return true; 215 } 216 217 return false; 180 return this.platform != null 181 && (this.platform == other.getPlatform() 182 || this.platform == other.getStopPosition()); 183 } 184 185 /** 186 * checks whether the given relation member matches a Stop Position or not 187 * @param rm member to check 188 * @return true if it matches, false otherwise 189 */ 190 public static boolean isPTStopPosition(RelationMember rm) { 191 return rm.getMember().hasTag("public_transport", "stop_position") 192 && rm.getType().equals(OsmPrimitiveType.NODE); 193 } 194 195 /** 196 * checks whether the given relation member matches a Platform or not 197 * @param rm member to check 198 * @return true if it matches, false otherwise 199 */ 200 public static boolean isPTPlatform(RelationMember rm) { 201 return rm.getMember().hasTag("highway", "bus_stop") 202 || rm.getMember().hasTag("public_transport", "platform") 203 || rm.getMember().hasTag("highway", "platform") 204 || rm.getMember().hasTag("railway", "platform"); 218 205 } 219 206 … … 233 220 this.stopPositionRM = stopPositionRM; 234 221 } 235 236 222 }
Note:
See TracChangeset
for help on using the changeset viewer.