| | 125 | /** |
| | 126 | * Enlarges the calculated bounding box by the specified percentage. A factor |
| | 127 | * of 100 means that the bounding box will be twice as large. |
| | 128 | * |
| | 129 | * Specify a degree larger than 0 in order to make the bounding box at least |
| | 130 | * the specified amount of degrees high and wide. The minimum is applied after |
| | 131 | * enlarging the bounding box by percentage. The value is ignored if the |
| | 132 | * bounding box is already larger than the specified amount. |
| | 133 | * |
| | 134 | * If the bounding box has not been set (<code>min</code> or <code>max</code> |
| | 135 | * equal <code>null</code>) this method does not do anything. |
| | 136 | * |
| | 137 | * @param enlargePercent |
| | 138 | * @param minEnlargeEastNorth |
| | 139 | */ |
| | 140 | public void enlargeBoundingBoxByPercent(double enlargePercent, double minDegree) { |
| | 141 | if (bounds == null) |
| | 142 | return; |
| | 143 | |
| | 144 | double diffEast = bounds.getMax().east() - bounds.getMin().east(); |
| | 145 | double diffNorth = bounds.getMax().north() - bounds.getMin().north(); |
| | 146 | |
| | 147 | double enlargeEast = Math.min(enlargePercent - 10*Math.log(diffEast), 1); |
| | 148 | double enlargeNorth = Math.min(enlargePercent - 10*Math.log(diffNorth), 1); |
| | 149 | |
| | 150 | diffEast *= enlargeEast/100; |
| | 151 | diffNorth *= enlargeNorth/100; |
| | 152 | |
| | 153 | EastNorth minEnlarge = Main.getProjection().latlon2eastNorth(new LatLon(0, minDegree)); |
| | 154 | diffEast = Math.max(diffEast, minEnlarge.east()); |
| | 155 | diffNorth = Math.max(diffNorth, minEnlarge.north()); |
| | 156 | |
| | 157 | visit(bounds.getMin().add(-diffEast/2, -diffNorth/2)); |
| | 158 | visit(bounds.getMax().add(+diffEast/2, +diffNorth/2)); |
| | 159 | } |
| | 160 | |
| | 161 | /** |
| | 162 | * Enlarges the calculated bounding box by the specified percentage. A factor |
| | 163 | * of 100 means that the bounding box will be twice as large. |
| | 164 | * |
| | 165 | * If the bounding box has not been set (<code>min</code> or <code>max</code> |
| | 166 | * equal <code>null</code>) this method does not do anything. |
| | 167 | * |
| | 168 | * @param enlargePercent |
| | 169 | */ |
| | 170 | public void enlargeBoundingBoxByPercent(double enlargePercent) { |
| | 171 | enlargeBoundingBoxByPercent(enlargePercent, 0); |
| | 172 | } |
| | 173 | |
| | 174 | |