Changeset 24107 in osm for applications/editors/josm/plugins
- Timestamp:
- 2010-11-07T13:44:50+01:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/OSMStreet.java
r24094 r24107 19 19 20 20 import org.openstreetmap.josm.data.osm.OsmPrimitive; 21 import org.openstreetmap.josm.data.osm.Relation; 21 22 22 23 /** … … 52 53 } 53 54 55 /** 56 * Lazy creation of children list. 57 */ 54 58 private void lazyCreateChildren() { 55 59 if (children == null) { … … 58 62 } 59 63 64 /** 65 * Adds an associated address to the street. 66 * 67 * @param aNode the address node to add 68 */ 60 69 public void addAddress(OSMAddress aNode) { 61 70 lazyCreateAddresses(); … … 63 72 } 64 73 74 /** 75 * Lazy creation of address list. 76 */ 65 77 private void lazyCreateAddresses() { 66 78 if (addresses == null) { … … 69 81 } 70 82 83 /** 84 * Checks for addresses. 85 * 86 * @return true, if street has one or more associated addresses. 87 */ 71 88 public boolean hasAddresses() { 72 89 return addresses != null && addresses.size() > 0; … … 136 153 } 137 154 155 /** 156 * Checks if the attached way has an associated street relation. 157 * 158 * @return true, if this street has an "associatedStreet" relation. 159 */ 160 public boolean hasAssociatedStreetRelation() { 161 OsmPrimitive osm = getOsmObject(); 162 for (OsmPrimitive refs : osm.getReferrers()) { 163 if (refs instanceof Relation) { 164 Relation rel = (Relation) refs; 165 if (TagUtils.isAssociatedStreetRelation(rel)) { 166 return true; 167 } 168 } 169 } 170 return false; 171 } 172 138 173 /* (non-Javadoc) 139 174 * @see org.openstreetmap.josm.plugins.addressEdit.NodeEntityBase#toString() -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/AddressEditDialog.java
r24106 r24107 58 58 import org.openstreetmap.josm.plugins.fixAddresses.gui.actions.ApplyAllGuessesAction; 59 59 import org.openstreetmap.josm.plugins.fixAddresses.gui.actions.AssignAddressToStreetAction; 60 import org.openstreetmap.josm.plugins.fixAddresses.gui.actions.ConvertAllToRelationAction; 60 61 import org.openstreetmap.josm.plugins.fixAddresses.gui.actions.ConvertToRelationAction; 61 62 import org.openstreetmap.josm.plugins.fixAddresses.gui.actions.GuessAddressDataAction; … … 84 85 private RemoveAddressTagsAction removeAddressTagsAction = new RemoveAddressTagsAction(); 85 86 private ConvertToRelationAction convertToRelationAction = new ConvertToRelationAction(); 87 private ConvertAllToRelationAction convertAllToRelationAction = new ConvertAllToRelationAction(); 86 88 87 89 private AbstractAddressEditAction[] actions = new AbstractAddressEditAction[] { … … 91 93 selectAddressesInMapAction, 92 94 removeAddressTagsAction, 93 convertToRelationAction 95 convertToRelationAction, 96 convertAllToRelationAction 94 97 }; 95 98 private JLabel streetLabel; … … 130 133 headerPanel.add(streetLabel); 131 134 132 JPanel streetButtonPanel = new JPanel(new GridLayout(1, 4));135 JPanel streetButtonPanel = new JPanel(new GridLayout(1, 3)); 133 136 SideButton convertToRel = new SideButton(convertToRelationAction); 134 137 streetButtonPanel.add(convertToRel); 138 // SideButton convertAllToRel = new SideButton(convertAllToRelationAction); 139 // streetButtonPanel.add(convertAllToRel); 140 // add filler 141 streetButtonPanel.add(new JPanel()); 142 streetButtonPanel.add(new JPanel()); 135 143 136 144 streetPanel.add(streetButtonPanel, BorderLayout.SOUTH); -
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/gui/actions/ConvertToRelationAction.java
r24106 r24107 32 32 super(tr("Convert to relation."), "convert2rel_24", "Create relation between street and related addresses."); 33 33 } 34 35 /** 36 * Instantiates a new convert to relation action. 37 * 38 * @param name the name of the action 39 * @param iconName the icon name 40 * @param tooltip the tool tip to show on hover 41 */ 42 public ConvertToRelationAction(String name, String iconName, String tooltip) { 43 super(name, iconName, tooltip); 44 } 34 45 46 /* (non-Javadoc) 47 * @see org.openstreetmap.josm.plugins.fixAddresses.gui.actions.AbstractAddressEditAction#addressEditActionPerformed(org.openstreetmap.josm.plugins.fixAddresses.gui.AddressEditSelectionEvent) 48 */ 35 49 @Override 36 50 public void addressEditActionPerformed(AddressEditSelectionEvent ev) { … … 38 52 39 53 if (streetNode != null) { 40 beginTransaction(tr("Create address relation for ") + " '" + streetNode.getName() + "'"); 41 42 Relation r = new Relation(); 43 commands.add(new AddCommand(r)); 44 commands.add(new ChangePropertyCommand(r, TagUtils.NAME_TAG, streetNode.getName())); 45 commands.add(new ChangePropertyCommand(r, TagUtils.RELATION_TYPE, TagUtils.ASSOCIATEDSTREET_RELATION_TYPE)); 46 47 r.addMember(new RelationMember(TagUtils.STREET_RELATION_ROLE, streetNode.getOsmObject())); 48 for (OSMAddress addrNode : streetNode.getAddresses()) { 49 beginObjectTransaction(addrNode); 50 r.addMember(new RelationMember(TagUtils.HOUSE_RELATION_ROLE, addrNode.getOsmObject())); 51 addrNode.setStreetName(null); 52 finishObjectTransaction(addrNode); 53 } 54 finishTransaction(); 54 createRelationForStreet(streetNode); 55 55 } 56 56 } 57 57 58 /** 59 * Creates the 'associatedStreet' relation for a given street by adding all addresses which 60 * matches the name of the street. 61 * 62 * @param streetNode the street node 63 */ 64 protected void createRelationForStreet(OSMStreet streetNode) { 65 if (streetNode == null || !streetNode.hasAddresses()) return; 66 67 beginTransaction(tr("Create address relation for ") + " '" + streetNode.getName() + "'"); 68 // Create the relation 69 Relation r = new Relation(); 70 commands.add(new AddCommand(r)); 71 commands.add(new ChangePropertyCommand(r, TagUtils.NAME_TAG, streetNode.getName())); 72 commands.add(new ChangePropertyCommand(r, TagUtils.RELATION_TYPE, TagUtils.ASSOCIATEDSTREET_RELATION_TYPE)); 73 // add street with role 'street' 74 r.addMember(new RelationMember(TagUtils.STREET_RELATION_ROLE, streetNode.getOsmObject())); 75 76 // add address members 77 for (OSMAddress addrNode : streetNode.getAddresses()) { 78 beginObjectTransaction(addrNode); 79 r.addMember(new RelationMember(TagUtils.HOUSE_RELATION_ROLE, addrNode.getOsmObject())); 80 addrNode.setStreetName(null); // remove street name 81 finishObjectTransaction(addrNode); 82 } 83 finishTransaction(); 84 } 85 86 /* (non-Javadoc) 87 * @see org.openstreetmap.josm.plugins.fixAddresses.gui.actions.AbstractAddressEditAction#addressEditActionPerformed(org.openstreetmap.josm.plugins.fixAddresses.AddressEditContainer) 88 */ 58 89 @Override 59 90 public void addressEditActionPerformed(AddressEditContainer container) { … … 61 92 } 62 93 94 /* (non-Javadoc) 95 * @see org.openstreetmap.josm.plugins.fixAddresses.gui.actions.AbstractAddressEditAction#updateEnabledState(org.openstreetmap.josm.plugins.fixAddresses.AddressEditContainer) 96 */ 63 97 @Override 64 98 protected void updateEnabledState(AddressEditContainer container) { … … 66 100 } 67 101 102 /* (non-Javadoc) 103 * @see org.openstreetmap.josm.plugins.fixAddresses.gui.actions.AbstractAddressEditAction#updateEnabledState(org.openstreetmap.josm.plugins.fixAddresses.gui.AddressEditSelectionEvent) 104 */ 68 105 @Override 69 106 protected void updateEnabledState(AddressEditSelectionEvent event) { … … 71 108 72 109 OSMStreet street = event.getSelectedStreet(); 73 setEnabled(street != null && street.hasAddresses() );110 setEnabled(street != null && street.hasAddresses() && !street.hasAssociatedStreetRelation()); 74 111 } 75 112
Note:
See TracChangeset
for help on using the changeset viewer.