Ticket #18204: 18204.patch

File 18204.patch, 2.6 KB (added by GerdP, 7 years ago)

experimental patch

  • src/org/openstreetmap/josm/gui/NavigatableComponent.java

     
    103103
    104104    /** Snap distance */
    105105    public static final IntegerProperty PROP_SNAP_DISTANCE = new IntegerProperty("mappaint.node.snap-distance", 10);
     106    /** Snap distance for way segments */
     107    public static final IntegerProperty PROP_SEGMENT_SNAP_DISTANCE = new IntegerProperty("mappaint.segment.snap-distance", 10);
    106108    /** Zoom steps to get double scale */
    107109    public static final DoubleProperty PROP_ZOOM_RATIO = new DoubleProperty("zoom.ratio", 2.0);
    108110    /** Divide intervals between native resolution levels to smaller steps if they are much larger than zoom ratio */
     
    938940        DataSet ds = MainApplication.getLayerManager().getActiveDataSet();
    939941
    940942        if (ds != null) {
    941             double dist, snapDistanceSq = PROP_SNAP_DISTANCE.get();
    942             snapDistanceSq *= snapDistanceSq;
     943            int snapDistance = PROP_SNAP_DISTANCE.get();
     944            double dist, snapDistanceSq;
     945            if (snapDistance > getState().getViewHeight() || snapDistance > getState().getViewWidth()) {
     946                Logging.error(PROP_SNAP_DISTANCE.getKey() + " used with zero height or width in view " + getState());
     947            }
     948            snapDistanceSq = (double) snapDistance * snapDistance;
    943949
    944950            for (Node n : ds.searchNodes(getBBox(p, PROP_SNAP_DISTANCE.get()))) {
    945951                if (predicate.test(n)
     
    11471153        DataSet ds = MainApplication.getLayerManager().getActiveDataSet();
    11481154
    11491155        if (ds != null) {
    1150             double snapDistanceSq = Config.getPref().getInt("mappaint.segment.snap-distance", 10);
    1151             snapDistanceSq *= snapDistanceSq;
     1156            int snapDistance = PROP_SEGMENT_SNAP_DISTANCE.get();
     1157            if (snapDistance >= getState().getViewHeight() || snapDistance >= getState().getViewWidth()) {
     1158                Logging.error(PROP_SEGMENT_SNAP_DISTANCE.getKey() + " used with zero height or width in view " + getState());
     1159            }
     1160            double snapDistanceSq = (double) snapDistance * snapDistance;
    11521161
    1153             for (Way w : ds.searchWays(getBBox(p, Config.getPref().getInt("mappaint.segment.snap-distance", 10)))) {
     1162            for (Way w : ds.searchWays(getBBox(p, snapDistance))) {
    11541163                if (!predicate.test(w)) {
    11551164                    continue;
    11561165                }