Ticket #16706: 16706-improve.patch

File 16706-improve.patch, 1.8 KB (added by GerdP, 7 years ago)
  • src/org/openstreetmap/josm/data/osm/visitor/BoundingXYVisitor.java

     
    2727 * @author imi
    2828 */
    2929public class BoundingXYVisitor implements OsmPrimitiveVisitor, PrimitiveVisitor {
    30 
     30    private static final double ENLARGE = 0.0002;
    3131    private ProjectionBounds bounds;
    3232
    3333    @Override
     
    144144     * equal <code>null</code>) this method does not do anything.
    145145     */
    146146    public void enlargeBoundingBox() {
    147         final double enlarge = Config.getPref().getDouble("edit.zoom-enlarge-bbox", 0.001);
     147        final double enlarge = Config.getPref().getDouble("edit.zoom-enlarge-bbox", ENLARGE);
    148148        enlargeBoundingBox(enlarge, enlarge);
    149149    }
    150150
     
    187187        final LatLon max = ProjectionRegistry.getProjection().eastNorth2latlon(bounds.getMax());
    188188        final double deltaLat = max.lat() - min.lat();
    189189        final double deltaLon = max.lon() - min.lon();
    190         // [0.001, 0.1] degree -> [0.001, 0.0] degree enlargement
    191         final DoubleUnaryOperator enlargement = deg -> deg < 0.001
    192                 ? 0.001
    193                 : deg < 0.1
    194                 ? 0.001 - deg / 100
    195                 : 0.0;
     190        final double enlarge = Config.getPref().getDouble("edit.zoom-enlarge-bbox", ENLARGE);
     191
     192        final DoubleUnaryOperator enlargement = deltaDegress -> {
     193            if (deltaDegress < enlarge)
     194                return enlarge;
     195            if (deltaDegress < 0.1)
     196                return enlarge - deltaDegress / 100;
     197            return 0.0;
     198        };
    196199        enlargeBoundingBox(enlargement.applyAsDouble(deltaLon), enlargement.applyAsDouble(deltaLat));
    197200    }
    198201