Changeset 6608 in josm
- Timestamp:
- 2014-01-03T12:24:30+01:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java
r6509 r6608 239 239 osm.accept(v); 240 240 } 241 // increase bbox by 0.001 degrees on each side. this is required 242 // especially if the bbox contains one single node, but helpful 243 // in most other cases as well. 244 v.enlargeBoundingBox(); 241 242 // Increase the bounding box by up to 100% to give more context. 243 v.enlargeBoundingBoxLogarithmically(100); 244 // Make the bounding box at least 0.0005 degrees (≈ 56 m) wide to 245 // ensure reasonable zoom level when zooming onto single nodes. 246 v.enlargeToMinDegrees(0.0005); 245 247 } 246 248 else if (mode.equals("download")) { -
trunk/src/org/openstreetmap/josm/data/osm/visitor/BoundingXYVisitor.java
r6380 r6608 123 123 } 124 124 125 /** 126 * Enlarges the bounding box up to <code>maxEnlargePercent</code>, depending on 127 * its size. If the bounding box is small, it will be enlarged more in relation 128 * to its beginning size. The larger the bounding box, the smaller the change, 129 * down to the minimum of 1% enlargement. 130 * 131 * Warning: if the bounding box only contains a single node, no expansion takes 132 * place because a node has no width/height. Use <code>enlargeToMinDegrees</code> 133 * instead. 134 * 135 * Example: You specify enlargement to be up to 100%. 136 * 137 * Bounding box is a small house: enlargement will be 95–100%, i.e. 138 * making enough space so that the house fits twice on the screen in 139 * each direction. 140 * 141 * Bounding box is a large landuse, like a forest: Enlargement will 142 * be 1–10%, i.e. just add a little border around the landuse. 143 * 144 * If the bounding box has not been set (<code>min</code> or <code>max</code> 145 * equal <code>null</code>) this method does not do anything. 146 * 147 * @param maxEnlargePercent 148 */ 149 public void enlargeBoundingBoxLogarithmically(double maxEnlargePercent) { 150 if (bounds == null) 151 return; 152 153 double diffEast = bounds.getMax().east() - bounds.getMin().east(); 154 double diffNorth = bounds.getMax().north() - bounds.getMin().north(); 155 156 double enlargeEast = Math.min(maxEnlargePercent - 10*Math.log(diffEast), 1)/100; 157 double enlargeNorth = Math.min(maxEnlargePercent - 10*Math.log(diffNorth), 1)/100; 158 System.out.println(enlargeEast); 159 160 visit(bounds.getMin().add(-enlargeEast/2, -enlargeNorth/2)); 161 visit(bounds.getMax().add(+enlargeEast/2, +enlargeNorth/2)); 162 } 163 164 165 /** 166 * Specify a degree larger than 0 in order to make the bounding box at least 167 * the specified amount of degrees high and wide. The value is ignored if the 168 * bounding box is already larger than the specified amount. 169 * 170 * If the bounding box has not been set (<code>min</code> or <code>max</code> 171 * equal <code>null</code>) this method does not do anything. 172 * 173 * If the bounding box contains objects and is to be enlarged, the objects 174 * will be centered within the new bounding box. 175 * 176 * @param minDegrees 177 */ 178 public void enlargeToMinDegrees(double minDegrees) { 179 if (bounds == null) 180 return; 181 182 EastNorth minEnlarge = Main.getProjection().latlon2eastNorth(new LatLon(0, minDegrees)); 183 184 visit(bounds.getMin().add(-minEnlarge.east()/2, -minEnlarge.north()/2)); 185 visit(bounds.getMax().add(+minEnlarge.east()/2, +minEnlarge.north()/2)); 186 } 187 188 125 189 @Override public String toString() { 126 190 return "BoundingXYVisitor["+bounds+"]";
Note:
See TracChangeset
for help on using the changeset viewer.