| 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()) * enlargePercent/100; |
| 145 | double diffNorth = (bounds.getMax().north() - bounds.getMin().north()) * enlargePercent/100; |
| 146 | |
| 147 | EastNorth minEnlarge = Main.getProjection().latlon2eastNorth(new LatLon(0, minDegree)); |
| 148 | diffEast = Math.max(diffEast, minEnlarge.east()); |
| 149 | diffNorth = Math.max(diffNorth, minEnlarge.north()); |
| 150 | |
| 151 | visit(bounds.getMin().add(-diffEast/2, -diffNorth/2)); |
| 152 | visit(bounds.getMax().add(+diffEast/2, +diffNorth/2)); |
| 153 | } |
| 154 | |
| 155 | /** |
| 156 | * Enlarges the calculated bounding box by the specified percentage. A factor |
| 157 | * of 100 means that the bounding box will be twice as large. |
| 158 | * |
| 159 | * If the bounding box has not been set (<code>min</code> or <code>max</code> |
| 160 | * equal <code>null</code>) this method does not do anything. |
| 161 | * |
| 162 | * @param enlargePercent |
| 163 | */ |
| 164 | public void enlargeBoundingBoxByPercent(double enlargePercent) { |
| 165 | enlargeBoundingBoxByPercent(enlargePercent, 0); |
| 166 | } |
| 167 | |
| 168 | |