1 |
package dk.daoas.fulddaekning; |
package dk.daoas.fulddaekning; |
2 |
|
|
3 |
public class BoundingBox { |
public class BoundingBox implements Cloneable{ |
4 |
|
|
5 |
|
|
6 |
public static class BoundingBoxException extends Exception{ |
public static class BoundingBoxException extends Exception{ |
10 |
|
|
11 |
private static final long serialVersionUID = 1L; |
private static final long serialVersionUID = 1L; |
12 |
} |
} |
13 |
|
|
|
//public static final double LATITUDE_MARGIN = 0.02702703; |
|
|
//public static final double LONGUTUDE_MARGIN = 0.046875; |
|
|
|
|
14 |
public double latitudeMax; |
public double latitudeMax; |
15 |
public double latitudeMin = Double.MAX_VALUE; |
public double latitudeMin = Double.MAX_VALUE; |
16 |
|
|
35 |
throw new BoundingBoxException("For stor longitude forskel / " + lngDiff); |
throw new BoundingBoxException("For stor longitude forskel / " + lngDiff); |
36 |
} |
} |
37 |
|
|
38 |
GeoPoint min = new GeoPoint(latitudeMin, longitudeMin); |
Adresse min = new Adresse(latitudeMin, longitudeMin); |
39 |
GeoPoint max = new GeoPoint(latitudeMax, longitudeMax); |
Adresse max = new Adresse(latitudeMax, longitudeMax); |
40 |
double afstand = GeoPoint.beregnAfstand(min, max); |
double afstand = GeoPointHelper.beregnAfstand(min, max); |
41 |
|
|
42 |
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 |
43 |
throw new BoundingBoxException("For stor cross afstand " + afstand); |
throw new BoundingBoxException("For stor cross afstand " + afstand); |
44 |
} |
} |
45 |
} |
} |
46 |
|
|
|
public void adjustToMargin(double kmMargin) { |
|
|
double latMargin = GeoPoint.kmToLatitude(kmMargin); |
|
|
double lngMargin = GeoPoint.kmToLongitude(kmMargin); |
|
|
|
|
|
latitudeMax += latMargin; |
|
|
latitudeMin -= latMargin; |
|
|
|
|
|
longitudeMax += lngMargin; |
|
|
longitudeMin -= lngMargin; |
|
|
} |
|
47 |
|
|
48 |
@Override |
@Override |
49 |
public BoundingBox clone() { |
public BoundingBox clone() { |