1 |
package dk.daoas.fulddaekning; |
package dk.daoas.fulddaekning; |
2 |
|
|
3 |
|
import geocode.GeoPoint; |
4 |
|
|
5 |
public class BoundingBox { |
public class BoundingBox { |
6 |
|
|
7 |
|
|
12 |
|
|
13 |
private static final long serialVersionUID = 1L; |
private static final long serialVersionUID = 1L; |
14 |
} |
} |
15 |
|
|
|
//public static final double LATITUDE_MARGIN = 0.02702703; |
|
|
//public static final double LONGUTUDE_MARGIN = 0.046875; |
|
|
|
|
16 |
public double latitudeMax; |
public double latitudeMax; |
17 |
public double latitudeMin; |
public double latitudeMin = Double.MAX_VALUE; |
18 |
|
|
19 |
public double longitudeMax; |
public double longitudeMax; |
20 |
public double longitudeMin; |
public double longitudeMin = Double.MAX_VALUE; |
21 |
|
|
22 |
|
|
23 |
@Override |
@Override |
26 |
} |
} |
27 |
|
|
28 |
public void validateBbox() throws BoundingBoxException { |
public void validateBbox() throws BoundingBoxException { |
29 |
|
|
30 |
double latDiff = Math.abs(latitudeMax - latitudeMin); |
double latDiff = Math.abs(latitudeMax - latitudeMin); |
31 |
if ( latDiff > 1.1) { |
if ( latDiff > 1.1) { |
32 |
throw new BoundingBoxException("For stor latitude forskel / " + latDiff); |
throw new BoundingBoxException("For stor latitude forskel / " + latDiff); |
39 |
|
|
40 |
GeoPoint min = new GeoPoint(latitudeMin, longitudeMin); |
GeoPoint min = new GeoPoint(latitudeMin, longitudeMin); |
41 |
GeoPoint max = new GeoPoint(latitudeMax, longitudeMax); |
GeoPoint max = new GeoPoint(latitudeMax, longitudeMax); |
42 |
double afstand = GeoPoint.beregnAfstand(min, max); |
double afstand = GeoPointHelper.beregnAfstand(min, max); |
43 |
|
|
44 |
if (afstand >= 125.0) { //hvis cross afstand er over 80 km - så er postnummeret for stort |
if (afstand >= 125.0) { //hvis cross afstand er over X km - så er postnummeret for stort |
45 |
throw new BoundingBoxException("For stor cross afstand " + afstand); |
throw new BoundingBoxException("For stor cross afstand " + afstand); |
46 |
} |
} |
47 |
} |
} |
48 |
|
|
|
public void adjustToMargin() { |
|
|
Constants consts = Constants.getInstance(); |
|
|
|
|
|
latitudeMax += consts.getLatitudeMargin(); |
|
|
latitudeMin -= consts.getLatitudeMargin(); |
|
|
|
|
|
longitudeMax += consts.getLongitudeMargin(); |
|
|
longitudeMin -= consts.getLongitudeMargin(); |
|
|
} |
|
49 |
|
|
50 |
@Override |
@Override |
51 |
public BoundingBox clone() { |
public BoundingBox clone() { |