Changeset 33416 in osm for applications/editors/josm/plugins/pt_assistant
- Timestamp:
- 2017-06-28T17:40:23+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/actions/SplitRoundaboutAction.java
r33415 r33416 24 24 import org.openstreetmap.josm.actions.SplitWayAction.SplitWayResult; 25 25 import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask; 26 import org.openstreetmap.josm.actions.relation.DownloadSelectedIncompleteMembersAction; 26 27 import org.openstreetmap.josm.command.ChangeCommand; 27 28 import org.openstreetmap.josm.command.Command; … … 35 36 import org.openstreetmap.josm.data.osm.RelationMember; 36 37 import org.openstreetmap.josm.data.osm.Way; 38 import org.openstreetmap.josm.gui.dialogs.relation.DownloadRelationMemberTask; 37 39 import org.openstreetmap.josm.plugins.pt_assistant.utils.RouteUtils; 38 40 import org.openstreetmap.josm.tools.Pair; … … 77 79 rbbox.getBottomRightLon() + lonOffset); 78 80 Future<?> future = task.download(false, area, null); 81 79 82 Main.worker.submit(() -> { 80 83 try { 81 84 future.get(); 82 continueAfterDownload(roundabout);85 downloadIncompleteRelations(roundabout); 83 86 } catch (InterruptedException | ExecutionException e1) { 84 87 Main.error(e1); … … 117 120 } 118 121 122 private void downloadIncompleteRelations(Way roundabout) { 123 124 List<Relation> parents = getPTRouteParents(roundabout); 125 parents.removeIf(r -> !r.hasIncompleteMembers()); 126 if(parents.isEmpty()) 127 continueAfterDownload(roundabout); 128 129 Future <?>future = Main.worker.submit(new DownloadRelationMemberTask( 130 parents, 131 DownloadSelectedIncompleteMembersAction.buildSetOfIncompleteMembers(parents), 132 Main.getLayerManager().getEditLayer())); 133 134 Main.worker.submit(() -> { 135 try { 136 future.get(); 137 continueAfterDownload(roundabout); 138 } catch (InterruptedException | ExecutionException e1) { 139 Main.error(e1); 140 return; 141 } 142 }); 143 } 144 119 145 public Command getUpdateRelationsCommand(Map<Relation, 120 146 List<Integer>> savedPositions, … … 151 177 Way entryWay = entryExitWays.a; 152 178 Way exitWay = entryExitWays.b; 179 180 if(entryWay == null || exitWay == null) 181 return; 153 182 154 183 //get the entry and exit nodes, exit if not found … … 195 224 //the ways returned are the one exactly before and after the roundabout 196 225 Pair<Way, Way> ret = new Pair<>(null, null); 197 ret.a = r.getMember(position-1).getWay(); 198 ret.b = r.getMember(position).getWay(); 226 227 RelationMember before = r.getMember(position-1); 228 if(before.isWay()) 229 ret.a = before.getWay(); 230 231 RelationMember after = r.getMember(position); 232 if(after.isWay()) 233 ret.b = after.getWay(); 234 199 235 return ret; 200 236 } … … 212 248 parents.remove(roundabout); 213 249 for(Way parent: parents) { 214 for(Relation r : OsmPrimitive.getFilteredList( 215 parent.getReferrers(), Relation.class)) { 216 if(RouteUtils.isPTRoute(r)) 250 if(!getPTRouteParents(parent).isEmpty()) { 217 251 return false; 218 252 } … … 225 259 226 260 public Command getRemoveRoundaboutFromRelationsCommand(Way roundabout) { 227 List <Relation> referrers = OsmPrimitive.getFilteredList(228 roundabout.getReferrers(), Relation.class);229 referrers.removeIf(r -> !RouteUtils.isPTRoute(r));230 231 261 List<Command> commands = new ArrayList<>(); 232 referrers.forEach(r -> {262 getPTRouteParents(roundabout).forEach(r -> { 233 263 Relation c = new Relation(r); 234 264 c.removeMembersFor(roundabout); … … 244 274 245 275 Map<Relation, List<Integer>> savedPositions = new HashMap<>(); 246 List <Relation> referrers = OsmPrimitive.getFilteredList( 247 roundabout.getReferrers(), Relation.class); 248 referrers.removeIf(r -> !RouteUtils.isPTRoute(r)); 249 250 for(Relation curr : referrers) { 276 277 for(Relation curr : getPTRouteParents(roundabout)) { 251 278 for(int j = 0; j < curr.getMembersCount(); j++) { 252 279 if(curr.getMember(j).getUniqueId() == roundabout.getUniqueId()) { … … 260 287 261 288 return savedPositions; 289 } 290 291 private List<Relation> getPTRouteParents(Way roundabout) { 292 List <Relation> referrers = OsmPrimitive.getFilteredList( 293 roundabout.getReferrers(), Relation.class); 294 referrers.removeIf(r -> !RouteUtils.isPTRoute(r)); 295 return referrers; 262 296 } 263 297
Note:
See TracChangeset
for help on using the changeset viewer.