Ignore:
Timestamp:
2010-05-02T22:39:56+02:00 (14 years ago)
Author:
lambertus
Message:

josm terracer plugin: Switch to josm.gui.ExtendedDialog (instead of JDialog) to use built-in ESC and ENTER keys functionality. Allow non-numeric addresses (like 12a or 34-2) in the 'lowest number' field if only one number is entered. Don't terrace the building outline if only one number is entered.

Location:
applications/editors/josm/plugins/terracer/src/terracer
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/terracer/src/terracer/HouseNumberInputDialog.java

    r21022 r21094  
    1818import java.awt.GridBagLayout;
    1919import java.awt.GridLayout;
     20import java.awt.event.ActionEvent;
     21
    2022import java.util.TreeSet;
    2123
     
    2325import javax.swing.JButton;
    2426import javax.swing.JCheckBox;
    25 import javax.swing.JDialog;
    2627import javax.swing.JLabel;
    2728import javax.swing.JOptionPane;
     
    3435import org.openstreetmap.josm.data.osm.OsmPrimitive;
    3536import org.openstreetmap.josm.data.osm.Way;
    36 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingComboBox;
     37import org.openstreetmap.josm.gui.ExtendedDialog;
     38import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingComboBox;
    3739import org.openstreetmap.josm.tools.GBC;
    3840
     
    4850 *
    4951 */
    50 public class HouseNumberInputDialog extends JDialog {
     52public class HouseNumberInputDialog extends ExtendedDialog {
    5153    /*
    5254    final static String MIN_NUMBER = "plugin.terracer.lowest_number";
     
    6466    private Container jContentPane;
    6567    private JPanel inputPanel;
    66     private JPanel buttonPanel;
    6768    private JLabel loLabel;
    6869    JTextField lo;
     
    7475    JTextField segments;
    7576    JTextArea messageLabel;
    76     JButton okButton;
    77     JButton cancelButton;
    7877    private JLabel interpolationLabel;
    7978    Choice interpolation;
     
    8180    JCheckBox deleteOutlineCheckBox;
    8281
     82        HouseNumberInputHandler inputHandler;
     83       
    8384    /**
    8485     * @param street If street is not null, we assume, the name of the street to be fixed
     
    8687     * @param relationExists If the buildings can be added to an existing relation or not.
    8788     */
    88     public HouseNumberInputDialog(Way street, boolean relationExists) {
    89         super(JOptionPane.getFrameForComponent(Main.parent));
     89    public HouseNumberInputDialog(HouseNumberInputHandler handler, Way street, boolean relationExists) {
     90        super(Main.parent,
     91                tr("Terrace a house"),
     92                new String[] { tr("OK"), tr("Cancel")},
     93                true
     94        );
     95        this.inputHandler = handler;
    9096        this.street = street;
    9197        this.relationExists = relationExists;
     98        handler.dialog = this;
     99        JPanel content = getInputPanel();
     100        setContent(content);
     101        setButtonIcons(new String[] {"ok.png", "cancel.png" });
     102        getJContentPane();
    92103        initialize();
    93     }
    94 
    95     /**
     104        setupDialog();
     105        setVisible(true);
     106    }
     107
     108        /**
    96109     * This method initializes this
    97110     *
     
    99112     */
    100113    private void initialize() {
    101         this.setTitle(tr("Terrace a house"));
    102         getJContentPane();
    103         SwingUtilities.invokeLater(new Runnable() { public void run() { lo.requestFocus(); } } );
    104         this.pack();
    105         this.setLocationRelativeTo(Main.parent);
    106     }
    107 
     114        this.lo.addFocusListener(this.inputHandler);
     115        this.hi.addFocusListener(this.inputHandler);
     116        this.segments.addFocusListener(this.inputHandler);
     117                this.interpolation.addItemListener(this.inputHandler);
     118    }
     119       
    108120    /**
    109121     * This method initializes jContentPane
     
    113125    private Container getJContentPane() {
    114126        if (jContentPane == null) {
     127       
    115128            messageLabel = new JTextArea();
    116129            messageLabel.setText(DEFAULT_MESSAGE);
     
    121134            messageLabel.setBackground(new Color(238, 238, 238));
    122135            messageLabel.setEditable(false);
     136           
    123137            jContentPane = this.getContentPane();
    124             jContentPane.setLayout(new BoxLayout(jContentPane,
    125                     BoxLayout.Y_AXIS));
     138            jContentPane.setLayout(new BoxLayout(jContentPane, BoxLayout.Y_AXIS));
    126139            jContentPane.add(messageLabel, jContentPane);
    127140            jContentPane.add(getInputPanel(), jContentPane);
    128             jContentPane.add(getButtonPanel(), jContentPane);
    129141        }
    130142        return jContentPane;
     
    176188    }
    177189
    178     /**
    179      * This method initializes buttonPanel
    180      *
    181      * @return javax.swing.JPanel
    182      */
    183     private JPanel getButtonPanel() {
    184         if (buttonPanel == null) {
    185             buttonPanel = new JPanel();
    186             buttonPanel.setLayout(new FlowLayout());
    187             buttonPanel.add(getOkButton(), null);
    188             buttonPanel.add(getCancelButton(), null);
    189         }
    190         return buttonPanel;
     190        /**
     191     * Overrides the default actions. Will not close the window when upload trace is clicked
     192     */
     193    @Override protected void buttonAction(final ActionEvent evt) {
     194        String a = evt.getActionCommand();
     195        this.inputHandler.actionPerformed(evt);
    191196    }
    192197
     
    251256
    252257    /**
    253      * This method initializes okButton
    254      *
    255      * @return javax.swing.JButton
    256      */
    257     private JButton getOkButton() {
    258         if (okButton == null) {
    259             okButton = new JButton();
    260             okButton.setText(tr("OK"));
    261             okButton.setName("OK");
    262         }
    263         return okButton;
    264     }
    265 
    266     /**
    267      * This method initializes cancelButton
    268      *
    269      * @return javax.swing.JButton
    270      */
    271     private JButton getCancelButton() {
    272         if (cancelButton == null) {
    273             cancelButton = new JButton();
    274             cancelButton.setText(tr("Cancel"));
    275             cancelButton.setName("CANCEL");
    276         }
    277         return cancelButton;
    278     }
    279 
    280     /**
    281258     * This method initializes interpolation
    282259     *
     
    290267        }
    291268        return interpolation;
    292     }
    293 
    294     /**
    295      * Registers the handler as a listener to all relevant events.
    296      *
    297      * @param handler the handler
    298      */
    299     public void addHandler(HouseNumberInputHandler handler) {
    300         this.hi.addActionListener(handler);
    301         this.hi.addFocusListener(handler);
    302 
    303         this.lo.addActionListener(handler);
    304         this.lo.addFocusListener(handler);
    305 
    306         this.segments.addActionListener(handler);
    307         this.segments.addFocusListener(handler);
    308 
    309         this.okButton.addActionListener(handler);
    310         this.cancelButton.addActionListener(handler);
    311 
    312         this.interpolation.addItemListener(handler);
    313 
    314269    }
    315270
  • applications/editors/josm/plugins/terracer/src/terracer/HouseNumberInputHandler.java

    r19658 r21094  
    1111
    1212import java.awt.Color;
     13import java.awt.Component;
     14import java.awt.Container;
    1315import java.awt.event.ActionEvent;
    1416import java.awt.event.ActionListener;
     
    2022import javax.swing.JButton;
    2123import javax.swing.JTextField;
    22 import javax.swing.event.ChangeEvent;
    23 import javax.swing.event.ChangeListener;
     24import javax.swing.JOptionPane;
    2425
    2526import org.openstreetmap.josm.Main;
    2627import org.openstreetmap.josm.data.osm.Way;
    2728import org.openstreetmap.josm.data.osm.Relation;
     29import org.openstreetmap.josm.actions.JosmAction;
    2830
    2931/**
     
    3739 * @author casualwalker
    3840 */
    39 public class HouseNumberInputHandler implements ChangeListener, ItemListener,
    40         ActionListener, FocusListener {
    41 
     41 public class HouseNumberInputHandler extends JosmAction implements ActionListener, FocusListener, ItemListener {
    4242    private TerracerAction terracerAction;
    4343    private Way outline, street;
    4444    private Relation associatedStreet;
    45     private HouseNumberInputDialog dialog;
     45    public HouseNumberInputDialog dialog;
    4646
    4747    /**
     
    6161        this.street = street;
    6262        this.associatedStreet = associatedStreet;
    63         dialog = new HouseNumberInputDialog(street, associatedStreet != null);
    64         dialog.addHandler(this);
    65 
    66         dialog.setVisible(true);
    67         dialog.setTitle(title);
    68 
    69     }
    70 
     63       
     64        // This dialog is started modal
     65        this.dialog = new HouseNumberInputDialog(this, street, associatedStreet != null);
     66       
     67        // We're done
     68    }
     69
     70        /**
     71         * Find a button with a certain caption.
     72         * Loops recursively through all objects to find all buttons.
     73         * Function returns on the first match.
     74         *
     75         * @param root A container object that is recursively searched for other containers or buttons
     76         * @param caption The caption of the button that is being searched
     77         *
     78         * @return The first button that matches the caption or null if not found
     79         */
     80        private static JButton getButton(Container root, String caption) {
     81                Component children[] = root.getComponents();
     82         for (Component child : children) {
     83                JButton b;
     84                if (child instanceof JButton) {
     85                                b = (JButton) child;
     86                                if (caption.equals(b.getText())) return b;
     87                        } else if (child instanceof Container) {
     88                  b = getButton((Container)child, caption);
     89                  if (b != null) return b;
     90             }
     91         }
     92                return null;
     93        }
     94       
    7195    /**
    7296     * Validate the current input fields.
     
    76100     * Should be triggered each time the input changes.
    77101     */
    78     private void validateInput() {
     102    private boolean validateInput() {
    79103        boolean isOk = true;
    80104        StringBuffer message = new StringBuffer();
     
    83107        isOk = isOk && checkSegmentsFromHousenumber(message);
    84108        isOk = isOk && checkSegments(message);
    85         isOk = isOk
    86                 && checkNumberStringField(dialog.lo, tr("Lowest number"),
    87                         message);
     109
     110        // Allow non numeric characters for the low number as long as there is no high number of the segmentcount is 1
     111        if (dialog.hi.getText().length() > 0 | segments() > 1) {
     112                    isOk = isOk
     113                            && checkNumberStringField(dialog.lo, tr("Lowest number"),
     114                                    message);
     115                }
    88116        isOk = isOk
    89117                && checkNumberStringField(dialog.hi, tr("Highest number"),
     
    94122
    95123        if (isOk) {
    96             dialog.okButton.setEnabled(true);
     124            JButton okButton = getButton(dialog, "OK");
     125            if (okButton != null)
     126                okButton.setEnabled(true);
     127           
     128            // For some reason the messageLabel doesn't want to show up
    97129            dialog.messageLabel.setForeground(Color.black);
    98             dialog.messageLabel
    99                     .setText(tr(HouseNumberInputDialog.DEFAULT_MESSAGE));
    100 
     130            dialog.messageLabel.setText(tr(HouseNumberInputDialog.DEFAULT_MESSAGE));
     131            return true;
    101132        } else {
    102             dialog.okButton.setEnabled(false);
    103             dialog.messageLabel.setForeground(Color.red);
    104             dialog.messageLabel.setText(message.toString());
     133            JButton okButton = getButton(dialog, "OK");
     134            if (okButton != null)
     135                        okButton.setEnabled(false);
     136                               
     137                // For some reason the messageLabel doesn't want to show up, so a MessageDialog is shown instead. Someone more knowledgeable might fix this.
     138                dialog.messageLabel.setForeground(Color.red);
     139                dialog.messageLabel.setText(message.toString());
     140                JOptionPane.showMessageDialog(null, message.toString(), tr("Error"), JOptionPane.ERROR_MESSAGE);
     141
     142            return false;
    105143        }
    106144    }
     
    119157            if (numberFrom().intValue() > numberTo().intValue()) {
    120158                appendMessageNewLine(message);
    121                 message
    122                         .append(tr("Lowest housenumber cannot be higher than highest housenumber"));
     159                message.append(tr("Lowest housenumber cannot be higher than highest housenumber"));
    123160                return false;
    124161            }
     
    147184            if (segments % stepSize() != 0) {
    148185                appendMessageNewLine(message);
    149                 message
    150                         .append(tr("Housenumbers do not match odd/even setting"));
     186                message.append(tr("Housenumbers do not match odd/even setting"));
    151187                return false;
    152188            }
     
    222258
    223259    /* (non-Javadoc)
    224      * @see javax.swing.event.ChangeListener#stateChanged(javax.swing.event.ChangeEvent)
    225      */
    226     public void stateChanged(ChangeEvent e) {
    227         validateInput();
    228 
    229     }
    230 
    231     /* (non-Javadoc)
    232260     * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
     261     * Called when the user selects from a pulldown selection
    233262     */
    234263    public void itemStateChanged(ItemEvent e) {
     
    240269     */
    241270    public void actionPerformed(final ActionEvent e) {
    242 
    243271        // OK or Cancel button-actions
    244272        if (e.getSource() instanceof JButton) {
    245273            JButton button = (JButton) e.getSource();
    246             if ("OK".equals(button.getName())) {
    247                 saveValues();
    248                 terracerAction.terraceBuilding(
    249                     outline,
    250                     street,
    251                     associatedStreet,
    252                     segments(),
    253                     numberFrom(),
    254                     numberTo(),
    255                     stepSize(),
    256                     streetName(),
    257                     doHandleRelation(),
    258                     doDeleteOutline());
    259 
    260                 this.dialog.dispose();
    261             } else if ("CANCEL".equals(button.getName())) {
     274            if ("OK".equals(button.getActionCommand()) & button.isEnabled()) {
     275                if (validateInput()) {
     276                            saveValues();
     277                           
     278                                terracerAction.terraceBuilding(
     279                                    outline,
     280                                    street,
     281                                    associatedStreet,
     282                                    segments(),
     283                                    dialog.lo.getText(),
     284                                    dialog.hi.getText(),
     285                                    stepSize(),
     286                                    streetName(),
     287                                    doHandleRelation(),
     288                                    doDeleteOutline());
     289                               
     290                            this.dialog.dispose();
     291                        }
     292            } else if ("Cancel".equals(button.getActionCommand())) {
    262293                this.dialog.dispose();
    263294            }
    264295        } else {
    265             // anything else is a change in the input
     296            // Anything else is a change in the input (we don't get here though)
    266297            validateInput();
    267298        }
    268 
    269299    }
    270300
     
    327357        if (street != null)
    328358            return null;
     359           
    329360        Object selected = dialog.streetComboBox.getSelectedItem();
    330361        if (selected == null) {
     
    345376     */
    346377    public boolean doHandleRelation() {
    347         return dialog.handleRelationCheckBox.isSelected();
     378        if (this.dialog == null) {
     379                JOptionPane.showMessageDialog(null, "dialog", "alert", JOptionPane.ERROR_MESSAGE);
     380        }
     381        if (this.dialog.handleRelationCheckBox == null) {
     382                JOptionPane.showMessageDialog(null, "checkbox", "alert", JOptionPane.ERROR_MESSAGE);
     383                return true;
     384        }  else {
     385                return this.dialog.handleRelationCheckBox.isSelected();
     386        }
    348387    }
    349388
     
    359398     */
    360399    public void focusGained(FocusEvent e) {
    361         validateInput();
     400                // Empty, but placeholder is required
    362401    }
    363402
     
    366405     */
    367406    public void focusLost(FocusEvent e) {
     407        if (e.getOppositeComponent() == null)
     408                return;
     409
    368410        validateInput();
    369411    }
  • applications/editors/josm/plugins/terracer/src/terracer/TerracerAction.java

    r20084 r21094  
    2525import org.openstreetmap.josm.actions.JosmAction;
    2626import org.openstreetmap.josm.command.AddCommand;
     27import org.openstreetmap.josm.command.ChangePropertyCommand;
    2728import org.openstreetmap.josm.command.ChangeCommand;
    2829import org.openstreetmap.josm.command.Command;
     
    5758    // repeated terraces. this is the easiest, but not necessarily nicest, way.
    5859    // private static String lastSelectedValue = "";
    59 
     60       
     61        Collection<Command> commands;
     62       
    6063    public TerracerAction() {
    6164        super(tr("Terrace a building"), "terrace",
     
    149152    }
    150153
     154        public Integer getNumber(String number) {
     155                try {
     156            return Integer.parseInt(number);
     157        } catch (NumberFormatException ex) {
     158            return null;
     159        }
     160        }
     161       
    151162    /**
    152163     * Terraces a single, closed, quadrilateral way.
     
    159170     * @param outline The closed, quadrilateral way to terrace.
    160171     * @param street The street, the buildings belong to (may be null)
     172     * @param associatedStreet
     173     * @param From
     174     * @param To
     175     * @param streetName the name of a street (may be null). Used if not null and street is null.
    161176     * @param handleRelations If the user likes to add a relation or extend an existing relation
    162177     * @param deleteOutline If the outline way should be deleted, when done
    163178     */
    164     public void terraceBuilding(Way outline, Way street, Relation associatedStreet, Integer segments, Integer from,
    165             Integer to, int step, String streetName, boolean handleRelations, boolean deleteOutline) {
     179    public void terraceBuilding(Way outline,
     180                                Way street,
     181                                Relation associatedStreet,
     182                                Integer segments,
     183                                String From,
     184                                String To,
     185                                int step,
     186                                String streetName,
     187                                boolean handleRelations,
     188                                boolean deleteOutline) {
    166189        final int nb;
     190       
     191        Integer to, from;
     192        to = getNumber(To);
     193        from = getNumber(From);
    167194        if (to != null && from != null) {
    168195            nb = 1 + (to.intValue() - from.intValue()) / step;
     
    176203                            + " from " + from + " to " + to + " step " + step);
    177204        }
    178 
     205               
    179206        // now find which is the longest side connecting the first node
    180207        Pair<Way, Way> interp = findFrontAndBack(outline);
     
    186213        Node[][] new_nodes = new Node[2][nb + 1];
    187214
    188         Collection<Command> commands = new LinkedList<Command>();
     215        this.commands = new LinkedList<Command>();
    189216        Collection<Way> ways = new LinkedList<Way>();
    190217
    191         // create intermediate nodes by interpolating.
    192         for (int i = 0; i <= nb; ++i) {
    193             new_nodes[0][i] = interpolateAlong(interp.a, frontLength * i / nb);
    194             new_nodes[1][i] = interpolateAlong(interp.b, backLength * i / nb);
    195             commands.add(new AddCommand(new_nodes[0][i]));
    196             commands.add(new AddCommand(new_nodes[1][i]));
    197         }
    198 
    199         // assemble new quadrilateral, closed ways
    200         for (int i = 0; i < nb; ++i) {
    201             Way terr = new Way();
    202             // Using Way.nodes.add rather than Way.addNode because the latter
    203             // doesn't
    204             // exist in older versions of JOSM.
    205             terr.addNode(new_nodes[0][i]);
    206             terr.addNode(new_nodes[0][i + 1]);
    207             terr.addNode(new_nodes[1][i + 1]);
    208             terr.addNode(new_nodes[1][i]);
    209             terr.addNode(new_nodes[0][i]);
    210            
    211             // add the tags of the outline to each building (e.g. source=*)
    212             TagCollection.from(outline).applyTo(terr);
    213            
    214             if (from != null) {
    215                 // only, if the user has specified house numbers
    216                 terr.put("addr:housenumber", "" + (from + i * step));
    217             }
    218             terr.put("building", "yes");
    219             if (street != null) {
    220                 terr.put("addr:street", street.get("name"));
    221             } else if (streetName != null) {
    222                 terr.put("addr:street", streetName);
    223             }
    224             ways.add(terr);
    225             commands.add(new AddCommand(terr));
    226         }
    227 
    228         if (handleRelations) { // create a new relation or merge with existing
    229             if (associatedStreet == null) {  // create a new relation
    230                 associatedStreet = new Relation();
    231                 associatedStreet.put("type", "associatedStreet");
    232                 if (street != null) { // a street was part of the selection
    233                     associatedStreet.put("name", street.get("name"));
    234                     associatedStreet.addMember(new RelationMember("street", street));
    235                 } else {
    236                     associatedStreet.put("name", streetName);
    237                 }
    238                 for (Way w : ways) {
    239                     associatedStreet.addMember(new RelationMember("house", w));
    240                 }
    241                 commands.add(new AddCommand(associatedStreet));
    242             }
    243             else { // relation exists already - add new members
    244                 Relation newAssociatedStreet = new Relation(associatedStreet);
    245                 for (Way w : ways) {
    246                     newAssociatedStreet.addMember(new RelationMember("house", w));
    247                 }
    248                 commands.add(new ChangeCommand(associatedStreet, newAssociatedStreet));
    249             }
    250         }
    251 
    252         if (deleteOutline) {
    253             commands.add(DeleteCommand.delete(Main.main.getEditLayer(), Collections.singleton(outline), true, true));
    254         }
    255 
    256         Main.main.undoRedo.add(new SequenceCommand(tr("Terrace"), commands));
    257         Main.main.getCurrentDataSet().setSelected(ways);
     218                if (nb > 1) {
     219                    // create intermediate nodes by interpolating.
     220                    for (int i = 0; i <= nb; ++i) {
     221                        new_nodes[0][i] = interpolateAlong(interp.a, frontLength * i / nb);
     222                        new_nodes[1][i] = interpolateAlong(interp.b, backLength * i / nb);
     223                        this.commands.add(new AddCommand(new_nodes[0][i]));
     224                        this.commands.add(new AddCommand(new_nodes[1][i]));
     225                    }
     226
     227                    // assemble new quadrilateral, closed ways
     228                    for (int i = 0; i < nb; ++i) {
     229                        Way terr = new Way();
     230                        // Using Way.nodes.add rather than Way.addNode because the latter
     231                        // doesn't
     232                        // exist in older versions of JOSM.
     233                        terr.addNode(new_nodes[0][i]);
     234                        terr.addNode(new_nodes[0][i + 1]);
     235                        terr.addNode(new_nodes[1][i + 1]);
     236                        terr.addNode(new_nodes[1][i]);
     237                        terr.addNode(new_nodes[0][i]);
     238                       
     239                        // add the tags of the outline to each building (e.g. source=*)
     240                        TagCollection.from(outline).applyTo(terr);
     241                               
     242                                String number = Integer.toString(from + i * step);
     243
     244                        terr = addressBuilding(terr, street, streetName, number);
     245
     246                        ways.add(terr);
     247                        this.commands.add(new AddCommand(terr));
     248                    }
     249
     250                    if (deleteOutline) {
     251                        this.commands.add(DeleteCommand.delete(Main.main.getEditLayer(), Collections.singleton(outline), true, true));
     252                    }
     253                } else {
     254                        // Single building, just add the address details
     255                        Way newOutline;
     256                        newOutline = addressBuilding(outline, street, streetName, From);
     257                        ways.add(newOutline);
     258                        this.commands.add(new ChangeCommand(outline, newOutline));
     259                }
     260               
     261                if (handleRelations) { // create a new relation or merge with existing
     262                    if (associatedStreet == null) {  // create a new relation
     263                        associatedStreet = new Relation();
     264                        associatedStreet.put("type", "associatedStreet");
     265                        if (street != null) { // a street was part of the selection
     266                            associatedStreet.put("name", street.get("name"));
     267                            associatedStreet.addMember(new RelationMember("street", street));
     268                        } else {
     269                            associatedStreet.put("name", streetName);
     270                        }
     271                        for (Way w : ways) {
     272                            associatedStreet.addMember(new RelationMember("house", w));
     273                        }
     274                        this.commands.add(new AddCommand(associatedStreet));
     275                    }
     276                    else { // relation exists already - add new members
     277                        Relation newAssociatedStreet = new Relation(associatedStreet);
     278                        for (Way w : ways) {
     279                            newAssociatedStreet.addMember(new RelationMember("house", w));
     280                        }
     281                        this.commands.add(new ChangeCommand(associatedStreet, newAssociatedStreet));
     282                    }
     283                }
     284                Main.main.undoRedo.add(new SequenceCommand(tr("Terrace"), commands));
     285                if (nb > 1) {
     286                        // Select the new building outlines (for quick reversing)
     287                    Main.main.getCurrentDataSet().setSelected(ways);
     288                } else if (street != null) {
     289                        // Select the way (for quick selection of a new house (with the same way))
     290                    Main.main.getCurrentDataSet().setSelected(street);
     291                }
     292    }
     293
     294    /**
     295     * Adds address details to a single building
     296     *
     297     * @param outline The closed, quadrilateral way to add the address to.
     298     * @param street The street, the buildings belong to (may be null)
     299     * @param streetName the name of a street (may be null). Used if not null and street is null.
     300     * @param number The house number
     301     * @return the way with added address details
     302     */
     303    private Way addressBuilding(Way outline, Way street, String streetName, String number) {
     304        Way changedOutline = outline;
     305        if (number != null) {
     306            // only, if the user has specified house numbers
     307            this.commands.add(new ChangePropertyCommand(changedOutline, "addr:housenumber", number));
     308        }
     309        changedOutline.put("building", "yes");
     310        if (street != null) {
     311            this.commands.add(new ChangePropertyCommand(changedOutline, "addr:street", street.get("name")));
     312        } else if (streetName != null) {
     313            this.commands.add(new ChangePropertyCommand(changedOutline, "addr:street", streetName));
     314        }
     315        return changedOutline;
    258316    }
    259317
Note: See TracChangeset for help on using the changeset viewer.