1 |
torben |
2145 |
package dk.daoas.fulddaekning;
|
2 |
|
|
|
3 |
|
|
public class BoundingBox {
|
4 |
|
|
|
5 |
|
|
public static class BoundingBoxException extends Exception{
|
6 |
|
|
public BoundingBoxException(String reason) {
|
7 |
|
|
super(reason);
|
8 |
|
|
}
|
9 |
|
|
|
10 |
|
|
private static final long serialVersionUID = 1L;
|
11 |
|
|
}
|
12 |
|
|
|
13 |
|
|
public static final double LATITUDE_MARGIN = 0.02702703;
|
14 |
|
|
public static final double LONGUTUDE_MARGIN = 0.046875;
|
15 |
|
|
|
16 |
|
|
public double latitudeMax;
|
17 |
|
|
public double latitudeMin;
|
18 |
|
|
|
19 |
|
|
public double longitudeMax;
|
20 |
|
|
public double longitudeMin;
|
21 |
|
|
|
22 |
|
|
|
23 |
|
|
@Override
|
24 |
|
|
public String toString() {
|
25 |
torben |
2146 |
return "bbox: Latitude=" + latitudeMin +"/" + latitudeMax + " longitude=" + longitudeMin + "/" + longitudeMax;
|
26 |
torben |
2145 |
}
|
27 |
|
|
|
28 |
|
|
public void validateBbox() throws BoundingBoxException {
|
29 |
|
|
if ( Math.abs(latitudeMax-latitudeMin)> 1.0)
|
30 |
|
|
throw new BoundingBoxException("For stor latitude forskel");
|
31 |
|
|
|
32 |
|
|
if ( Math.abs(longitudeMax-longitudeMin)> 1.0)
|
33 |
|
|
throw new BoundingBoxException("For stor longitude forskel");
|
34 |
|
|
}
|
35 |
|
|
|
36 |
|
|
public void adjustToMargin() {
|
37 |
|
|
latitudeMax += LATITUDE_MARGIN;
|
38 |
|
|
latitudeMin -= LATITUDE_MARGIN;
|
39 |
|
|
|
40 |
|
|
longitudeMax += LONGUTUDE_MARGIN;
|
41 |
|
|
longitudeMin -= LONGUTUDE_MARGIN;
|
42 |
|
|
}
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
}
|