Changeset 31040 in osm for applications/editors/josm/plugins/utilsplugin2/src/org
- Timestamp:
- 2015-03-01T23:34:35+01:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/utilsplugin2/src/org/openstreetmap/josm/plugins/utilsplugin2/actions/PasteRelationsAction.java
r30737 r31040 1 1 package org.openstreetmap.josm.plugins.utilsplugin2.actions; 2 2 3 import org.openstreetmap.josm.data.osm.*; 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 5 import java.awt.event.ActionEvent; 6 import java.awt.event.KeyEvent; 7 import java.util.ArrayList; 8 import java.util.Collection; 9 import java.util.HashMap; 10 import java.util.List; 11 import java.util.Map; 12 4 13 import org.openstreetmap.josm.Main; 5 import org.openstreetmap.josm.command.*; 6 import java.util.*; 7 import java.awt.event.KeyEvent; 14 import org.openstreetmap.josm.actions.JosmAction; 15 import org.openstreetmap.josm.command.ChangeCommand; 16 import org.openstreetmap.josm.command.Command; 17 import org.openstreetmap.josm.command.SequenceCommand; 18 import org.openstreetmap.josm.data.osm.OsmPrimitive; 19 import org.openstreetmap.josm.data.osm.PrimitiveData; 20 import org.openstreetmap.josm.data.osm.Relation; 21 import org.openstreetmap.josm.data.osm.RelationMember; 8 22 import org.openstreetmap.josm.tools.Shortcut; 9 import java.awt.event.ActionEvent;10 import org.openstreetmap.josm.actions.JosmAction;11 import static org.openstreetmap.josm.tools.I18n.tr;12 23 13 24 /** … … 33 44 for( PrimitiveData pdata : Main.pasteBuffer.getDirectlyAdded() ) { 34 45 OsmPrimitive p = getCurrentDataSet().getPrimitiveById(pdata.getUniqueId(), pdata.getType()); 35 for( Relation r : OsmPrimitive.getFilteredList(p.getReferrers(), Relation.class)) { 36 String role = relations.get(r); 37 for( RelationMember m : r.getMembers() ) { 38 if( m.getMember().equals(p) ) { 39 String newRole = m.getRole(); 40 if( newRole != null && role == null ) 41 role = newRole; 42 else if( newRole != null ? !newRole.equals(role) : role != null ) { 43 role = ""; 44 break; 45 } 46 } 47 } 48 relations.put(r, role); 46 if (p != null) { 47 for( Relation r : OsmPrimitive.getFilteredList(p.getReferrers(), Relation.class)) { 48 String role = relations.get(r); 49 for( RelationMember m : r.getMembers() ) { 50 if( m.getMember().equals(p) ) { 51 String newRole = m.getRole(); 52 if( newRole != null && role == null ) 53 role = newRole; 54 else if( newRole != null ? !newRole.equals(role) : role != null ) { 55 role = ""; 56 break; 57 } 58 } 59 } 60 relations.put(r, role); 61 } 49 62 } 50 63 } … … 56 69 for( OsmPrimitive p : selection ) { 57 70 if( !r.getMemberPrimitives().contains(p) && !r.equals(p) ) { 58 String role = relations.get(rel); 71 String role = relations.get(rel); 59 72 if ("associatedStreet".equals(r.get("type"))) { 60 73 if (p.get("highway") != null) {
Note:
See TracChangeset
for help on using the changeset viewer.