Changeset 33466 in osm
- Timestamp:
- 2017-07-24T22:32:59+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/data/PTRouteDataManager.java
r33453 r33466 27 27 28 28 /* Stores all relation members that are PTStops */ 29 private List<PTStop> pt stops = new ArrayList<>();29 private List<PTStop> ptStops = new ArrayList<>(); 30 30 31 31 /* Stores all relation members that are PTWays */ 32 private List<PTWay> pt ways = new ArrayList<>();32 private List<PTWay> ptWays = new ArrayList<>(); 33 33 34 34 /* … … 38 38 private Set<RelationMember> failedMembers = new HashSet<>(); 39 39 40 public PTRouteDataManager(Relation relation) throws IllegalArgumentException{40 public PTRouteDataManager(Relation relation) { 41 41 42 42 // It is assumed that the relation is a route. Build in a check here … … 63 63 // Squared distance of 0.000004 corresponds to 64 64 // around 100 m 65 if ( this.calculateDistanceSq(member, prev) < 0.000001) {65 if (calculateDistanceSq(member, prev) < 0.000001) { 66 66 stopExists = true; 67 67 } … … 93 93 try { 94 94 PTStop ptstop = new PTStop(member); 95 pt stops.add(ptstop);95 ptStops.add(ptstop); 96 96 prev = ptstop; 97 97 } catch (IllegalArgumentException ex) { … … 111 111 112 112 PTWay ptway = new PTWay(member); 113 pt ways.add(ptway);113 ptWays.add(ptway); 114 114 115 115 } else { … … 150 150 public PTWay getPTWay(Way inputWay) { 151 151 152 for (PTWay curr : pt ways) {152 for (PTWay curr : ptWays) { 153 153 154 154 if (curr.isWay() && curr.getWays().get(0) == inputWay) { … … 170 170 171 171 public List<PTStop> getPTStops() { 172 return this.ptstops;172 return ptStops; 173 173 } 174 174 175 175 public List<PTWay> getPTWays() { 176 return this.ptways;176 return ptWays; 177 177 } 178 178 179 179 public int getPTStopCount() { 180 return pt stops.size();180 return ptStops.size(); 181 181 } 182 182 183 183 public int getPTWayCount() { 184 return this.ptways.size();184 return ptWays.size(); 185 185 } 186 186 187 187 public PTStop getFirstStop() { 188 if ( this.ptstops.isEmpty()) {188 if (ptStops.isEmpty()) { 189 189 return null; 190 190 } 191 return this.ptstops.get(0);191 return ptStops.get(0); 192 192 } 193 193 194 194 public PTStop getLastStop() { 195 if ( this.ptstops.isEmpty()) {195 if (ptStops.isEmpty()) { 196 196 return null; 197 197 } 198 return this.ptstops.get(ptstops.size() - 1);198 return ptStops.get(ptStops.size() - 1); 199 199 } 200 200 201 201 public Set<RelationMember> getFailedMembers() { 202 return this.failedMembers;202 return failedMembers; 203 203 } 204 204 … … 209 209 */ 210 210 public Relation getRelation() { 211 return this.relation;211 return relation; 212 212 } 213 213 … … 219 219 */ 220 220 public PTStop getPTStop(long id) { 221 for (PTStop stop : this.ptstops) {221 for (PTStop stop : ptStops) { 222 222 if (stop.getStopPosition() != null && stop.getStopPosition().getId() == id) { 223 223 return stop; … … 239 239 */ 240 240 public PTWay getPTWay(long id) { 241 for (PTWay ptway : this.ptways) {241 for (PTWay ptway : ptWays) { 242 242 for (Way way : ptway.getWays()) { 243 243 if (way.getId() == id) { … … 258 258 259 259 List<PTWay> ptwaysThatContain = new ArrayList<>(); 260 for (PTWay ptway : pt ways) {260 for (PTWay ptway : ptWays) { 261 261 if (ptway.getWays().contains(way)) { 262 262 ptwaysThatContain.add(ptway); … … 276 276 277 277 List<PTWay> ptwaysThatContain = new ArrayList<>(); 278 for (PTWay ptway : pt ways) {278 for (PTWay ptway : ptWays) { 279 279 List<Way> ways = ptway.getWays(); 280 280 if (ways.get(0).firstNode() == node || ways.get(0).lastNode() == node … … 295 295 public boolean isDeadendNode(Node node) { 296 296 297 List<PTWay> referringPtways = this.findPTWaysThatContainAsEndNode(node); 298 if (referringPtways.size() <= 1) { 299 return true; 300 } 301 return false; 297 List<PTWay> referringPtways = findPTWaysThatContainAsEndNode(node); 298 return referringPtways.size() <= 1; 302 299 } 303 300 … … 312 309 public PTWay getNextPTWay(PTWay ptway) { 313 310 314 for (int i = 0; i < pt ways.size() - 1; i++) {315 if (pt ways.get(i) == ptway) {316 return pt ways.get(i + 1);311 for (int i = 0; i < ptWays.size() - 1; i++) { 312 if (ptWays.get(i) == ptway) { 313 return ptWays.get(i + 1); 317 314 } 318 315 } … … 331 328 public PTWay getPreviousPTWay(PTWay ptway) { 332 329 333 for (int i = 1; i < pt ways.size(); i++) {334 if (pt ways.get(i) == ptway) {335 return pt ways.get(i - 1);330 for (int i = 1; i < ptWays.size(); i++) { 331 if (ptWays.get(i) == ptway) { 332 return ptWays.get(i - 1); 336 333 } 337 334 } … … 352 349 List<Integer> potentialEndIndices = new ArrayList<>(); 353 350 354 for (int i = 0; i < pt ways.size(); i++) {355 if (pt ways.get(i).getWays().contains(start)) {351 for (int i = 0; i < ptWays.size(); i++) { 352 if (ptWays.get(i).getWays().contains(start)) { 356 353 potentialStartIndices.add(i); 357 354 } 358 if (pt ways.get(i).getWays().contains(end)) {355 if (ptWays.get(i).getWays().contains(end)) { 359 356 potentialEndIndices.add(i); 360 357 } … … 383 380 List<PTWay> result = new ArrayList<>(); 384 381 for (int i = mostSuitablePair[0]; i <= mostSuitablePair[1]; i++) { 385 result.add(pt ways.get(i));382 result.add(ptWays.get(i)); 386 383 } 387 384 return result; … … 419 416 } 420 417 418 /** 419 * Returns the first way of this route 420 * 421 * @return the first way of this route 422 */ 423 public Way getFirstWay() { 424 if (ptWays.isEmpty()) { 425 return null; 426 } 427 428 PTWay lastPTWay = ptWays.get(0); 429 if (lastPTWay == null || lastPTWay.getWays().isEmpty()) { 430 return null; 431 } 432 433 return lastPTWay.getWays().get(0); 434 } 435 421 436 /** 422 437 * Returns the last way of this route … … 425 440 */ 426 441 public Way getLastWay() { 427 PTWay lastPTWay = this.ptways.get(ptways.size() - 1); 428 if (lastPTWay == null) { 442 if (ptWays.isEmpty()) { 429 443 return null; 430 444 } 445 446 PTWay lastPTWay = ptWays.get(ptWays.size() - 1); 447 if (lastPTWay == null || lastPTWay.getWays().isEmpty()) { 448 return null; 449 } 450 431 451 return lastPTWay.getWays().get(lastPTWay.getWays().size() - 1); 432 452 }
Note:
See TracChangeset
for help on using the changeset viewer.