/[projects]/dao/FuldDaekningWorker/src/dk/daoas/fulddaekning/BoundingBox.java
ViewVC logotype

Annotation of /dao/FuldDaekningWorker/src/dk/daoas/fulddaekning/BoundingBox.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2331 - (hide annotations) (download)
Fri Feb 20 08:58:19 2015 UTC (9 years, 3 months ago) by torben
File size: 1919 byte(s)
Some cleanup
1 torben 2145 package dk.daoas.fulddaekning;
2    
3     public class BoundingBox {
4 torben 2200
5 torben 2145
6     public static class BoundingBoxException extends Exception{
7     public BoundingBoxException(String reason) {
8     super(reason);
9     }
10    
11     private static final long serialVersionUID = 1L;
12     }
13 torben 2331
14 torben 2145 public double latitudeMax;
15 torben 2328 public double latitudeMin = Double.MAX_VALUE;
16 torben 2145
17     public double longitudeMax;
18 torben 2328 public double longitudeMin = Double.MAX_VALUE;
19 torben 2145
20    
21     @Override
22     public String toString() {
23 torben 2146 return "bbox: Latitude=" + latitudeMin +"/" + latitudeMax + " longitude=" + longitudeMin + "/" + longitudeMax;
24 torben 2145 }
25    
26     public void validateBbox() throws BoundingBoxException {
27 torben 2328
28 torben 2239 double latDiff = Math.abs(latitudeMax - latitudeMin);
29 torben 2264 if ( latDiff > 1.1) {
30 torben 2239 throw new BoundingBoxException("For stor latitude forskel / " + latDiff);
31     }
32 torben 2211
33 torben 2239 double lngDiff = Math.abs(longitudeMax - longitudeMin);
34 torben 2264 if ( lngDiff > 1.1) {
35 torben 2239 throw new BoundingBoxException("For stor longitude forskel / " + lngDiff);
36     }
37    
38 torben 2211 GeoPoint min = new GeoPoint(latitudeMin, longitudeMin);
39     GeoPoint max = new GeoPoint(latitudeMax, longitudeMax);
40     double afstand = GeoPoint.beregnAfstand(min, max);
41    
42 torben 2331 if (afstand >= 125.0) { //hvis cross afstand er over X km - så er postnummeret for stort
43 torben 2211 throw new BoundingBoxException("For stor cross afstand " + afstand);
44     }
45 torben 2145 }
46    
47 torben 2330 public void adjustToMargin(double kmMargin) {
48     double latMargin = GeoPoint.kmToLatitude(kmMargin);
49     double lngMargin = GeoPoint.kmToLongitude(kmMargin);
50 torben 2145
51 torben 2330 latitudeMax += latMargin;
52     latitudeMin -= latMargin;
53 torben 2200
54 torben 2330 longitudeMax += lngMargin;
55     longitudeMin -= lngMargin;
56 torben 2145 }
57    
58 torben 2247 @Override
59     public BoundingBox clone() {
60     BoundingBox bb = new BoundingBox();
61     bb.latitudeMax = this.latitudeMax;
62     bb.longitudeMax = this.longitudeMax;
63    
64     bb.latitudeMin = this.latitudeMin;
65     bb.longitudeMin = this.longitudeMin;
66    
67     return bb;
68     }
69    
70 torben 2145
71     }

  ViewVC Help
Powered by ViewVC 1.1.20