/[projects]/dao/DaoAdresseVedligehold/src/main/java/dk/daoas/adressevedligehold/afstandandenrute/BoundingBox.java
ViewVC logotype

Annotation of /dao/DaoAdresseVedligehold/src/main/java/dk/daoas/adressevedligehold/afstandandenrute/BoundingBox.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2878 - (hide annotations) (download)
Sat Jan 30 14:05:53 2016 UTC (8 years, 4 months ago) by torben
File size: 1728 byte(s)
WIP: Merge AfstandAndenRute(FulddaekningWorker) into this project
1 torben 2878 package dk.daoas.adressevedligehold.afstandandenrute;
2    
3     import dk.daoas.adressevedligehold.beans.Address;
4    
5     public class BoundingBox implements Cloneable{
6    
7    
8     public static class BoundingBoxException extends Exception{
9     public BoundingBoxException(String reason) {
10     super(reason);
11     }
12    
13     private static final long serialVersionUID = 1L;
14     }
15    
16     public double latitudeMax;
17     public double latitudeMin = Double.MAX_VALUE;
18    
19     public double longitudeMax;
20     public double longitudeMin = Double.MAX_VALUE;
21    
22    
23     @Override
24     public String toString() {
25     return "bbox: Latitude=" + latitudeMin +"/" + latitudeMax + " longitude=" + longitudeMin + "/" + longitudeMax;
26     }
27    
28     public void validateBbox() throws BoundingBoxException {
29    
30     double latDiff = Math.abs(latitudeMax - latitudeMin);
31     if ( latDiff > 1.1) {
32     throw new BoundingBoxException("For stor latitude forskel / " + latDiff);
33     }
34    
35     double lngDiff = Math.abs(longitudeMax - longitudeMin);
36     if ( lngDiff > 1.1) {
37     throw new BoundingBoxException("For stor longitude forskel / " + lngDiff);
38     }
39    
40     Address min = new Address(latitudeMin, longitudeMin);
41     Address max = new Address(latitudeMax, longitudeMax);
42     double afstand = GeoPointHelper.beregnAfstand(min, max);
43    
44     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);
46     }
47     }
48    
49    
50     @Override
51     public BoundingBox clone() {
52     BoundingBox bb = new BoundingBox();
53     bb.latitudeMax = this.latitudeMax;
54     bb.longitudeMax = this.longitudeMax;
55    
56     bb.latitudeMin = this.latitudeMin;
57     bb.longitudeMin = this.longitudeMin;
58    
59     return bb;
60     }
61    
62    
63     }

  ViewVC Help
Powered by ViewVC 1.1.20