Changeset 35818 in osm for applications/editors/josm


Ignore:
Timestamp:
2021-09-24T08:14:42+02:00 (3 years ago)
Author:
GerdP
Message:

fix #21315: Using buildings_tools with a double click produces invalid buildings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/buildings_tools/src/org/openstreetmap/josm/plugins/buildings_tools/DrawBuildingAction.java

    r35756 r35818  
    6464    private Point drawStartPos;
    6565    private Point mousePos;
     66    /** Force a reasonable dimension */
     67    private static final double MIN_LEN_WIDTH = 1E-6;
    6668
    6769    final transient Building building = new Building();
     
    244246        if (isRectDrawing()) {
    245247            building.setPlaceRect(p);
     248            if (building.getLength() < MIN_LEN_WIDTH)
     249                return Mode.Drawing;
    246250            return shift ? Mode.DrawingAngFix : Mode.None;
    247251        } else if (ToolSettings.Shape.CIRCLE == ToolSettings.getShape()) {
     
    251255                building.setPlace(p, ToolSettings.getWidth(), ToolSettings.getLenStep(), shift);
    252256            }
     257            if (building.getLength() < MIN_LEN_WIDTH)
     258                return Mode.Drawing;
    253259            MainApplication.getMap().statusLine.setDist(building.getLength());
    254             this.nextMode = Mode.None;
    255             return this.nextMode;
     260            return Mode.None;
    256261        } else {
    257262            building.setPlace(p, ToolSettings.getWidth(), ToolSettings.getLenStep(), shift);
     263            if (building.getLength() < MIN_LEN_WIDTH)
     264                return Mode.Drawing;
    258265            MainApplication.getMap().statusLine.setDist(building.getLength());
    259             this.nextMode = ToolSettings.getWidth() == 0 ? Mode.DrawingWidth : Mode.None;
    260             return this.nextMode;
     266            return ToolSettings.getWidth() == 0 ? Mode.DrawingWidth : Mode.None;
    261267        }
    262268    }
     
    264270    private Mode modeDrawingWidth() {
    265271        building.setWidth(getEastNorth());
    266         MainApplication.getMap().statusLine.setDist(Math.abs(building.getWidth()));
    267         return Mode.None;
     272        double width = Math.abs(building.getWidth());
     273        MainApplication.getMap().statusLine.setDist(width);
     274        return width < MIN_LEN_WIDTH ? Mode.DrawingWidth : Mode.None;
    268275    }
    269276
Note: See TracChangeset for help on using the changeset viewer.