Changeset 26888 in osm for applications/editors/josm/plugins/reltoolbox/src
- Timestamp:
- 2011-10-14T23:36:20+02:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/reltoolbox/src/relcontext/actions
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/SplittingMultipolygons.java
r26887 r26888 341 341 otherRing.putSourceWayFirst(); 342 342 343 Map<Relation, Relation> relationCache = new HashMap<Relation, Relation>(); 343 344 for( TheRing otherRing : otherWays ) 344 commands.addAll(otherRing.getCommands(false)); 345 commands.addAll(theRing.getCommands()); 345 commands.addAll(otherRing.getCommands(false, relationCache)); 346 commands.addAll(theRing.getCommands(relationCache)); 347 TheRing.updateCommandsWithRelations(commands, relationCache); 346 348 resultingCommands.add(new SequenceCommand(tr("Complete multipolygon for way {0}", 347 349 DefaultNameFormatter.getInstance().format(ring)), commands)); -
applications/editors/josm/plugins/reltoolbox/src/relcontext/actions/TheRing.java
r26887 r26888 66 66 redistributeSegments(rings); 67 67 List<Relation> relations = new ArrayList<Relation>(); 68 Map<Relation, Relation> relationCache = new HashMap<Relation, Relation>(); 68 69 for( TheRing r : rings ) { 69 commands.addAll(r.getCommands()); 70 commands.addAll(r.getCommands(relationCache)); 70 71 relations.add(r.getRelation()); 71 72 } 73 updateCommandsWithRelations(commands, relationCache); 72 74 return relations; 73 75 } … … 277 279 278 280 public List<Command> getCommands() { 279 return getCommands(true); 281 return getCommands(true, null); 282 } 283 284 public List<Command> getCommands( Map<Relation, Relation> relationChangeMap ) { 285 return getCommands(true, relationChangeMap); 280 286 } 281 287 … … 284 290 * The first way is copied from the source one, ChangeCommand is issued in this case. 285 291 */ 286 public List<Command> getCommands( boolean createMultipolygon ) { 292 public List<Command> getCommands( boolean createMultipolygon, Map<Relation, Relation> relationChangeMap ) { 287 293 Way sourceCopy = new Way(source); 288 294 if( createMultipolygon ) { … … 303 309 for( OsmPrimitive p : source.getReferrers() ) { 304 310 if( p instanceof Relation ) { 305 Relation rel = new Relation((Relation)p); 306 relationCommands.add(new ChangeCommand((Relation)p, rel)); 311 Relation rel = null; 312 if( relationChangeMap != null ) { 313 if( relationChangeMap.containsKey((Relation)p) ) 314 rel = relationChangeMap.get((Relation)p); 315 else { 316 rel = new Relation((Relation)p); 317 relationChangeMap.put((Relation)p, rel); 318 } 319 } else { 320 rel = new Relation((Relation)p); 321 relationCommands.add(new ChangeCommand((Relation)p, rel)); 322 } 307 323 for( int i = 0; i < rel.getMembersCount(); i++ ) 308 324 if( rel.getMember(i).getMember().equals(source) ) … … 342 358 commands.add(new AddCommand(relation)); 343 359 return commands; 360 } 361 362 public static void updateCommandsWithRelations( List<Command> commands, Map<Relation, Relation> relationCache ) { 363 for( Relation src : relationCache.keySet() ) 364 commands.add(new ChangeCommand(src, relationCache.get(src))); 344 365 } 345 366
Note:
See TracChangeset
for help on using the changeset viewer.