Changeset 19532 in osm for applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/PathBuilder.java
- Timestamp:
- 2010-01-15T21:42:20+01:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/PathBuilder.java
r17380 r19532 14 14 public class PathBuilder { 15 15 16 private Map<Way, BitSet> wayRoutes = new HashMap<Way, BitSet>(); 16 private Map<Way, BitSet> wayRoutes = new HashMap<Way, BitSet>(); 17 private Collection<ConvertedWay> convertedWays; 17 18 18 19 public void addWay(Way way, RouteDefinition route) { … … 30 31 31 32 public Collection<ConvertedWay> getConvertedWays() { 32 Map<WayEnd, ConvertedWay> ways = new HashMap<WayEnd, ConvertedWay>(); 33 if (convertedWays == null) { 34 Map<WayEnd, ConvertedWay> ways = new HashMap<WayEnd, ConvertedWay>(); 33 35 34 for (Entry<Way, BitSet> wayEntry:wayRoutes.entrySet()) { 35 ConvertedWay way = new ConvertedWay(wayEntry.getValue(), wayEntry.getKey()); 36 for (Entry<Way, BitSet> wayEntry:wayRoutes.entrySet()) { 37 ConvertedWay way = new ConvertedWay(wayEntry.getValue(), wayEntry.getKey()); 36 38 37 ConvertedWay wayBefore = ways.get(way.getStart()); 38 ConvertedWay wayAfter = ways.get(way.getStop()); 39 ConvertedWay wayBefore = ways.get(way.getStart()); 40 ConvertedWay wayAfter = ways.get(way.getStop()); 39 41 40 if (wayBefore != null) { 41 removeWay(ways, wayBefore); 42 way.connect(wayBefore); 43 }42 if (wayBefore != null) { 43 removeWay(ways, wayBefore); 44 way.connect(wayBefore); 45 } 44 46 45 if (wayAfter != null) { 46 removeWay(ways, wayAfter); 47 way.connect(wayAfter); 47 if (wayAfter != null) { 48 removeWay(ways, wayAfter); 49 way.connect(wayAfter); 50 } 51 52 ways.put(way.getStart(), way); 53 ways.put(way.getStop(), way); 48 54 } 49 55 50 ways.put(way.getStart(), way); 51 ways.put(way.getStop(), way); 56 Set<ConvertedWay> uniqueWays = new HashSet<ConvertedWay>(); 57 uniqueWays.addAll(ways.values()); 58 convertedWays = uniqueWays; 52 59 } 53 54 Set<ConvertedWay> uniqueWays = new HashSet<ConvertedWay>(); 55 uniqueWays.addAll(ways.values()); 56 return uniqueWays; 60 return convertedWays; 57 61 } 58 62 … … 63 67 64 68 public void clear() { 69 convertedWays = null; 65 70 wayRoutes.clear(); 66 71 }
Note:
See TracChangeset
for help on using the changeset viewer.