Changeset 33453 in osm for applications/editors/josm
- Timestamp:
- 2017-07-18T10:27:57+02:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/data/PTRouteDataManager.java
r33055 r33453 50 50 for (RelationMember member : this.relation.getMembers()) { 51 51 52 if ( RouteUtils.isPTStop(member)) {52 if (PTStop.isPTStop(member)) { 53 53 54 54 // First, check if the stop already exists (i.e. there are -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/data/PTStop.java
r33445 r33453 189 189 190 190 /** 191 * Checks if the relation member refers to a stop in a public transport 192 * route. Some stops can be modeled with ways. 193 * 194 * @param rm 195 * relation member to be checked 196 * @return true if the relation member refers to a stop, false otherwise 197 */ 198 public static boolean isPTStop(RelationMember rm) { 199 return isPTStopPosition(rm) || isPTPlatform(rm); 200 } 201 202 /** 191 203 * checks whether the given relation member matches a Stop Position or not 192 204 * @param rm member to check -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/PTAssistantPaintVisitor.java
r33429 r33453 13 13 import java.util.List; 14 14 import java.util.Map; 15 import java.util.Map.Entry; 15 16 16 17 import org.openstreetmap.josm.Main; … … 23 24 import org.openstreetmap.josm.data.validation.PaintVisitor; 24 25 import org.openstreetmap.josm.gui.MapView; 26 import org.openstreetmap.josm.plugins.pt_assistant.data.PTStop; 25 27 import org.openstreetmap.josm.plugins.pt_assistant.data.PTWay; 26 28 import org.openstreetmap.josm.plugins.pt_assistant.utils.RouteUtils; … … 58 60 for (RelationMember rm : r.getMembers()) { 59 61 60 if ( RouteUtils.isPTStop(rm)) {61 62 drawStop(rm.getMember());63 62 if (PTStop.isPTStopPosition(rm)) { 63 drawStop(rm.getMember(), true); 64 } else if (PTStop.isPTPlatform(rm)) { 65 drawStop(rm.getMember(), false); 64 66 } else if (RouteUtils.isPTWay(rm)) { 65 67 if (rm.isWay()) { … … 76 78 77 79 for (RelationMember rm : r.getMembers()) { 78 if ( RouteUtils.isPTStop(rm) || (rm.getMember().isIncomplete() && (rm.isNode() || rm.hasRole("stop")80 if (PTStop.isPTStop(rm) || (rm.getMember().isIncomplete() && (rm.isNode() || rm.hasRole("stop") 79 81 || rm.hasRole("stop_entry_only") || rm.hasRole("stop_exit_only") || rm.hasRole("platform") 80 82 || rm.hasRole("platform_entry_only") || rm.hasRole("platform_exit_only")))) { 81 83 82 String label = "";84 StringBuilder sb = new StringBuilder(); 83 85 84 86 if (stopOrderMap.containsKey(rm.getUniqueId())) { 85 label = stopOrderMap.get(rm.getUniqueId()); 86 label = label + ";" + stopCount; 87 sb.append(stopOrderMap.get(rm.getUniqueId())) 88 .append(";") 89 .append(stopCount); 87 90 } else { 88 91 if (r.hasKey("ref")) { 89 label = label + r.get("ref");92 sb.append(r.get("ref")); 90 93 } else if (r.hasKey("name")) { 91 label = label + r.get("name");94 sb.append(r.get("name")); 92 95 } else { 93 label = "NA";96 sb.append("NA"); 94 97 } 95 label = label + " - " + stopCount; 96 } 97 98 stopOrderMap.put(rm.getUniqueId(), label); 98 sb.append(" - ") 99 .append(stopCount); 100 } 101 102 stopOrderMap.put(rm.getUniqueId(), sb.toString()); 99 103 try { 100 drawStopLabel(rm.getMember(), label);104 drawStopLabel(rm.getMember(), sb.toString()); 101 105 } catch (NullPointerException ex) { 102 106 // do nothing … … 164 168 continue; 165 169 } 166 this.drawSegment(lastN, n, new Color(128, 0, 128, 100), oneway);170 drawSegment(lastN, n, new Color(128, 0, 128, 100), oneway); 167 171 lastN = n; 168 172 } … … 281 285 protected void drawNode(Node n, Color color) { 282 286 if (mv == null || g == null) { 283 ;287 return; 284 288 } 285 289 Point p = mv.getPoint(n); … … 297 301 * @param primitive primitive 298 302 */ 299 protected void drawStop(OsmPrimitive primitive ) {303 protected void drawStop(OsmPrimitive primitive, Boolean stopPosition) { 300 304 301 305 // find the point to which the stop visualization will be linked: … … 306 310 g.setColor(Color.BLUE); 307 311 308 if ( primitive.hasTag("public_transport", "stop_position") && p != null) {312 if (stopPosition) { 309 313 g.fillOval(p.x - 8, p.y - 8, 16, 16); 310 314 } else { … … 359 363 Collections.sort(parentsLabelList, new RefTagComparator()); 360 364 361 String parentsLabel = "";365 StringBuilder sb = new StringBuilder(); 362 366 for (String s : parentsLabelList) { 363 parentsLabel = parentsLabel + s + ";";364 } 365 366 if ( !parentsLabel.equals("")) {367 sb.append(s).append(";"); 368 } 369 370 if (sb.length() > 0) { 367 371 // remove the last semicolon: 368 parentsLabel = parentsLabel.substring(0, parentsLabel.length() - 1);372 String parentsLabel = sb.substring(0, sb.length() - 1); 369 373 370 374 g.setColor(new Color(255, 20, 147)); … … 416 420 417 421 try { 418 int firstNumber1 = Integer. valueOf(firstNumberString1);419 int firstNumber2 = Integer. valueOf(firstNumberString2);422 int firstNumber1 = Integer.parseInt(firstNumberString1); 423 int firstNumber2 = Integer.parseInt(firstNumberString2); 420 424 if (firstNumber1 > firstNumber2) { 421 425 return 1; … … 443 447 HashMap<Way, List<Character>> wayColoring) { 444 448 445 drawFixVariantsWithParallelLines(wayColoring , fixVariants.size());449 drawFixVariantsWithParallelLines(wayColoring); 446 450 447 451 Color[] colors = { … … 457 461 double letterY = Main.map.mapView.getBounds().getMinY() + 100; 458 462 459 for (Character c : fixVariants.keySet()) { 463 for (Entry<Character, List<PTWay>> entry : fixVariants.entrySet()) { 464 Character c = entry.getKey(); 460 465 if (fixVariants.get(c) != null) { 461 // drawFixVariant(fixVariants.get(c), colors[colorIndex % 5]);462 466 drawFixVariantLetter(c.toString(), colors[colorIndex % 5], letterX, letterY); 463 467 colorIndex++; … … 483 487 } 484 488 485 protected void drawFixVariantsWithParallelLines(Map<Way, List<Character>> wayColoring , int numberOfFixVariants) {489 protected void drawFixVariantsWithParallelLines(Map<Way, List<Character>> wayColoring) { 486 490 487 491 HashMap<Character, Color> colors = new HashMap<>(); … … 492 496 colors.put('E', new Color(0, 255, 255, 200)); 493 497 494 for (Way way : wayColoring.keySet()) { 498 for (Entry<Way, List<Character>> entry : wayColoring.entrySet()) { 499 Way way = entry.getKey(); 495 500 List<Character> letterList = wayColoring.get(way); 496 501 List<Color> wayColors = new ArrayList<>(); -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/utils/RouteUtils.java
r33432 r33453 77 77 78 78 /** 79 * Checks if the relation member refers to a stop in a public transport80 * route. Some stops can be modeled with ways.81 *82 * @param rm83 * relation member to be checked84 * @return true if the relation member refers to a stop, false otherwise85 */86 public static boolean isPTStop(RelationMember rm) {87 88 if (rm.getType().equals(OsmPrimitiveType.NODE)) {89 return true;90 }91 92 return (rm.getType().equals(OsmPrimitiveType.WAY))93 && (rm.getWay().hasTag("public_transport", "platform")94 || rm.getWay().hasTag("highway", "platform")95 || rm.getWay().hasTag("railway", "platform"));96 }97 98 /**99 79 * Checks if the relation member refers to a way in a public transport 100 80 * route. Some OsmPrimitiveType.WAY have to be excluded because platforms -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/Checker.java
r33347 r33453 20 20 import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor; 21 21 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 22 import org.openstreetmap.josm.plugins.pt_assistant.data.PTStop; 22 23 import org.openstreetmap.josm.plugins.pt_assistant.gui.PTAssistantLayerManager; 23 import org.openstreetmap.josm.plugins.pt_assistant.utils.RouteUtils;24 24 25 25 /** … … 73 73 for (RelationMember rm : r.getMembers()) { 74 74 75 if ( RouteUtils.isPTStop(rm)) {75 if (PTStop.isPTStop(rm)) { 76 76 77 77 if (rm.getMember().hasTag("public_transport", "stop_position")) { … … 110 110 for (RelationMember rm : r.getMembers()) { 111 111 112 if (! RouteUtils.isPTStop(rm)) {112 if (!PTStop.isPTStop(rm)) { 113 113 114 114 if (rm.hasRole("forward") || rm.hasRole("backward")) { -
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/WayChecker.java
r33104 r33453 22 22 import org.openstreetmap.josm.data.validation.TestError; 23 23 import org.openstreetmap.josm.data.validation.TestError.Builder; 24 import org.openstreetmap.josm.plugins.pt_assistant.data.PTStop; 24 25 import org.openstreetmap.josm.plugins.pt_assistant.utils.RouteUtils; 25 26 … … 413 414 // copy PT stops first, PT ways last: 414 415 for (RelationMember rm : originalRelation.getMembers()) { 415 if ( RouteUtils.isPTStop(rm)) {416 if (PTStop.isPTStop(rm)) { 416 417 417 418 if (rm.getRole().equals("stop_position")) {
Note:
See TracChangeset
for help on using the changeset viewer.