Changeset 36484 in osm for applications/editors/josm/plugins
- Timestamp:
- 2026-02-12T17:33:22+01:00 (2 days ago)
- Location:
- applications/editors/josm/plugins/terracer
- Files:
-
- 4 edited
-
src/org/openstreetmap/josm/plugins/terracer/HouseNumberInputDialog.java (modified) (2 diffs)
-
src/org/openstreetmap/josm/plugins/terracer/HouseNumberInputHandler.java (modified) (3 diffs)
-
src/org/openstreetmap/josm/plugins/terracer/TerracerAction.java (modified) (6 diffs)
-
test/unit/org/openstreetmap/josm/plugins/terracer/ReverseTerraceActionTest.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/terracer/src/org/openstreetmap/josm/plugins/terracer/HouseNumberInputDialog.java
r36483 r36484 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 ); … … 107 107 JPanel content = getInputPanel(); 108 108 setContent(content); 109 setButtonIcons("ok", "cancel"); 109 setButtonIcons("ok", "ok", "cancel"); 110 110 getJContentPane(); 111 111 initialize(); -
applications/editors/josm/plugins/terracer/src/org/openstreetmap/josm/plugins/terracer/HouseNumberInputHandler.java
r36483 r36484 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 … … 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(); … … 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); -
applications/editors/josm/plugins/terracer/src/org/openstreetmap/josm/plugins/terracer/TerracerAction.java
r36483 r36484 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()); … … 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; … … 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())); … … 597 598 * 598 599 * @param w The way to analyse. 600 * @param invertSide If true, forces the use of the alternative (adjacent) pair 601 * of sides, effectively rotating the split axis. 599 602 * @return A pair of ways (front, back) pointing in the same directions. 600 603 */ 601 private static Pair<Way, Way> findFrontAndBack(Way w) { 604 private static Pair<Way, Way> findFrontAndBack(Way w, boolean invertSide) { 602 605 // calculate the "side-ness" score for each segment of the way 603 606 double[] sideness = calculateSideness(w); … … 624 627 if (sideLength(w, side1) > sideLength(w, side1 + 1) 625 628 && Math.abs(sideness[side1] - sideness[(side1 + 1) % (w.getNodesCount() - 1)]) < 0.001) { 629 side1 = (side1 + 1) % (w.getNodesCount() - 1); 630 side2 = (side2 + 1) % (w.getNodesCount() - 1); 631 } 632 633 // if inverted, shift the selection to the adjacent segments to use the 634 // alternative pair of sides (e.g. top/bottom instead of left/right). 635 if (invertSide) { 626 636 side1 = (side1 + 1) % (w.getNodesCount() - 1); 627 637 side2 = (side2 + 1) % (w.getNodesCount() - 1); … … 791 801 * The value to sort 792 802 */ 793 p ublicfinal double x;803 private final double x; 794 804 /** 795 805 * The index in the original array 796 806 */ 797 p ublicfinal int i;807 private final int i; 798 808 799 809 SortWithIndex(double a, int b) { -
applications/editors/josm/plugins/terracer/test/unit/org/openstreetmap/josm/plugins/terracer/ReverseTerraceActionTest.java
r36483 r36484 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());
Note:
See TracChangeset
for help on using the changeset viewer.
