/[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 2707 - (hide annotations) (download)
Sun Sep 27 13:21:45 2015 UTC (8 years, 9 months ago) by torben
File size: 1652 byte(s)
Use another K-d Tree implementation
1 torben 2145 package dk.daoas.fulddaekning;
2    
3 torben 2590 public class BoundingBox implements Cloneable{
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 2707 Adresse min = new Adresse(latitudeMin, longitudeMin);
39     Adresse max = new Adresse(latitudeMax, longitudeMax);
40 torben 2585 double afstand = GeoPointHelper.beregnAfstand(min, max);
41 torben 2211
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    
48 torben 2247 @Override
49     public BoundingBox clone() {
50     BoundingBox bb = new BoundingBox();
51     bb.latitudeMax = this.latitudeMax;
52     bb.longitudeMax = this.longitudeMax;
53    
54     bb.latitudeMin = this.latitudeMin;
55     bb.longitudeMin = this.longitudeMin;
56    
57     return bb;
58     }
59    
60 torben 2145
61     }

  ViewVC Help
Powered by ViewVC 1.1.20