diff --git a/terracer/src/org/openstreetmap/josm/plugins/terracer/HouseNumberInputDialog.java b/terracer/src/org/openstreetmap/josm/plugins/terracer/HouseNumberInputDialog.java
index fe78d0647..28d66bd53 100644
|
a
|
b
|
public class HouseNumberInputDialog extends ExtendedDialog {
|
| 94 | 94 | String buildingType, boolean relationExists, List<Node> houseNumbers) { |
| 95 | 95 | super(MainApplication.getMainFrame(), |
| 96 | 96 | tr("Terrace a house"), |
| 97 | | new String[] {tr("OK"), tr("Cancel")}, |
| | 97 | new String[] { tr("Long side"), tr("Short side"), tr("Cancel") }, |
| 98 | 98 | true |
| 99 | 99 | ); |
| 100 | 100 | this.inputHandler = handler; |
| … |
… |
public class HouseNumberInputDialog extends ExtendedDialog {
|
| 106 | 106 | handler.dialog = this; |
| 107 | 107 | JPanel content = getInputPanel(); |
| 108 | 108 | setContent(content); |
| 109 | | setButtonIcons("ok", "cancel"); |
| | 109 | setButtonIcons("ok", "ok", "cancel"); |
| 110 | 110 | getJContentPane(); |
| 111 | 111 | initialize(); |
| 112 | 112 | setDefaultButton(1); |
diff --git a/terracer/src/org/openstreetmap/josm/plugins/terracer/HouseNumberInputHandler.java b/terracer/src/org/openstreetmap/josm/plugins/terracer/HouseNumberInputHandler.java
index b1003761b..eafaa212d 100644
|
a
|
b
|
public class HouseNumberInputHandler extends JosmAction implements FocusListener
|
| 128 | 128 | isOk &= checkNumberStringField(dialog.segments, tr("Segments"), |
| 129 | 129 | message); |
| 130 | 130 | |
| 131 | | JButton okButton = getButton(dialog, "OK"); |
| 132 | | if (okButton != null) |
| 133 | | okButton.setEnabled(isOk); |
| | 131 | JButton longSideButton = getButton(dialog, tr("Long side")); |
| | 132 | if (longSideButton != null) |
| | 133 | longSideButton.setEnabled(isOk); |
| | 134 | JButton shortSideButton = getButton(dialog, tr("Short side")); |
| | 135 | if (shortSideButton != null) |
| | 136 | shortSideButton.setEnabled(isOk); |
| 134 | 137 | if (isOk) { |
| 135 | 138 | |
| 136 | 139 | // For some reason the messageLabel doesn't want to show up |
| … |
… |
public class HouseNumberInputHandler extends JosmAction implements FocusListener
|
| 271 | 274 | // OK or Cancel button-actions |
| 272 | 275 | if (e.getSource() instanceof JButton) { |
| 273 | 276 | JButton button = (JButton) e.getSource(); |
| 274 | | if (tr("OK").equals(button.getActionCommand()) && button.isEnabled()) { |
| | 277 | if (tr("Long side").equals(button.getActionCommand()) && button.isEnabled()) { |
| 275 | 278 | if (validateInput()) { |
| 276 | 279 | saveValues(); |
| 277 | 280 | |
| … |
… |
public class HouseNumberInputHandler extends JosmAction implements FocusListener
|
| 287 | 290 | housenumbers, |
| 288 | 291 | streetName(), |
| 289 | 292 | doHandleRelation(), |
| 290 | | doKeepOutline(), buildingType()); |
| | 293 | doKeepOutline(), buildingType(), |
| | 294 | false); |
| | 295 | |
| | 296 | this.dialog.setVisible(false); |
| | 297 | } |
| | 298 | } else if (tr("Short side").equals(button.getActionCommand()) && button.isEnabled()) { |
| | 299 | if (validateInput()) { |
| | 300 | saveValues(); |
| | 301 | |
| | 302 | terracerAction.terraceBuilding( |
| | 303 | outline, |
| | 304 | init, |
| | 305 | street, |
| | 306 | associatedStreet, |
| | 307 | segments(), |
| | 308 | dialog.lo.getText(), |
| | 309 | dialog.hi.getText(), |
| | 310 | stepSize(), |
| | 311 | housenumbers, |
| | 312 | streetName(), |
| | 313 | doHandleRelation(), |
| | 314 | doKeepOutline(), buildingType(), |
| | 315 | true); |
| 291 | 316 | |
| 292 | 317 | this.dialog.setVisible(false); |
| 293 | 318 | } |
diff --git a/terracer/src/org/openstreetmap/josm/plugins/terracer/TerracerAction.java b/terracer/src/org/openstreetmap/josm/plugins/terracer/TerracerAction.java
index 094ff5339..3be7d0c14 100644
|
a
|
b
|
public final class TerracerAction extends JosmAction {
|
| 215 | 215 | // Special case of one outline and one address node. |
| 216 | 216 | // Don't open the dialog |
| 217 | 217 | terraceBuilding(outline, init, street, associatedStreet, 0, null, null, 0, |
| 218 | | housenumbers, streetname, associatedStreet != null, false, "yes"); |
| | 218 | housenumbers, streetname, associatedStreet != null, false, "yes", false); |
| 219 | 219 | } else { |
| 220 | 220 | String title = trn("Change {0} object", "Change {0} objects", sel.size(), sel.size()); |
| 221 | 221 | // show input dialog. |
| … |
… |
public final class TerracerAction extends JosmAction {
|
| 300 | 300 | * existing relation |
| 301 | 301 | * @param keepOutline If the outline way should be kept |
| 302 | 302 | * @param buildingValue The value for {@code building} key to add |
| | 303 | * @param invertSide If true, splits on the short side instead of the long side |
| 303 | 304 | */ |
| 304 | 305 | public void terraceBuilding(final Way outline, Node init, Way street, Relation associatedStreet, Integer segments, |
| 305 | 306 | String start, String end, int step, List<Node> housenumbers, String streetName, boolean handleRelations, |
| 306 | | boolean keepOutline, String buildingValue) { |
| | 307 | boolean keepOutline, String buildingValue, boolean invertSide) { |
| 307 | 308 | final int nb; |
| 308 | 309 | Integer to; |
| 309 | 310 | Integer from = null; |
| … |
… |
public final class TerracerAction extends JosmAction {
|
| 326 | 327 | } |
| 327 | 328 | |
| 328 | 329 | // now find which is the longest side connecting the first node |
| 329 | | Pair<Way, Way> interp = findFrontAndBack(outline); |
| | 330 | Pair<Way, Way> interp = findFrontAndBack(outline, invertSide); |
| 330 | 331 | |
| 331 | 332 | final boolean swap = init != null && (init.equals(interp.a.lastNode()) || init.equals(interp.b.lastNode())); |
| 332 | 333 | |
| … |
… |
public final class TerracerAction extends JosmAction {
|
| 595 | 596 | * segments to find the "sides". Sides are assumed to be single segments |
| 596 | 597 | * which cannot be contiguous. |
| 597 | 598 | * |
| 598 | | * @param w The way to analyse. |
| | 599 | * @param invertSide If true, forces the use of the alternative (adjacent) pair |
| | 600 | * of sides, effectively rotating the split axis. |
| 599 | 601 | * @return A pair of ways (front, back) pointing in the same directions. |
| 600 | 602 | */ |
| 601 | | private static Pair<Way, Way> findFrontAndBack(Way w) { |
| | 603 | private static Pair<Way, Way> findFrontAndBack(Way w, boolean invertSide) { |
| 602 | 604 | // calculate the "side-ness" score for each segment of the way |
| 603 | 605 | double[] sideness = calculateSideness(w); |
| 604 | 606 | |
| … |
… |
public final class TerracerAction extends JosmAction {
|
| 627 | 629 | side2 = (side2 + 1) % (w.getNodesCount() - 1); |
| 628 | 630 | } |
| 629 | 631 | |
| | 632 | // if inverted, shift the selection to the adjacent segments to use the |
| | 633 | // alternative pair of sides (e.g. top/bottom instead of left/right). |
| | 634 | if (invertSide) { |
| | 635 | side1 = (side1 + 1) % (w.getNodesCount() - 1); |
| | 636 | side2 = (side2 + 1) % (w.getNodesCount() - 1); |
| | 637 | } |
| | 638 | |
| 630 | 639 | // swap side1 and side2 into sorted order. |
| 631 | 640 | if (side1 > side2) { |
| 632 | 641 | int tmp = side2; |
diff --git a/terracer/target/terracer.jar b/terracer/target/terracer.jar
new file mode 100644
index 000000000..1dac45dbc
Binary files /dev/null and b/terracer/target/terracer.jar differ
diff --git a/terracer/test/unit/org/openstreetmap/josm/plugins/terracer/ReverseTerraceActionTest.java b/terracer/test/unit/org/openstreetmap/josm/plugins/terracer/ReverseTerraceActionTest.java
index cec7bf50a..0269bd3d7 100644
|
a
|
b
|
class ReverseTerraceActionTest {
|
| 51 | 51 | way2.addNode(way2.firstNode()); |
| 52 | 52 | dataSet.setSelected(way2); |
| 53 | 53 | new TerracerAction().terraceBuilding(way2, null, null, null, 5, |
| 54 | | "80", "88", 2, Collections.emptyList(), null, false, false, "apartments"); |
| | 54 | "80", "88", 2, Collections.emptyList(), null, false, false, "apartments", false); |
| 55 | 55 | final List<Way> addressedWays = dataSet.getWays().stream().filter(w -> w != way1) |
| 56 | 56 | .sorted(Comparator.comparingLong(w -> -w.getUniqueId())).collect(Collectors.toList()); |
| 57 | 57 | assertAll("Terrace should work as expected", () -> assertEquals(5, addressedWays.size()), |