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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2239 by torben, Wed Dec 10 07:36:40 2014 UTC revision 2585 by torben, Sun Jun 14 14:28:21 2015 UTC
# Line 1  Line 1 
1  package dk.daoas.fulddaekning;  package dk.daoas.fulddaekning;
2    
3    import geocode.GeoPoint;
4    
5  public class BoundingBox {  public class BoundingBox {
6                                    
7                    
# Line 10  public class BoundingBox { Line 12  public class BoundingBox {
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
# Line 27  public class BoundingBox { Line 26  public class BoundingBox {
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.0) {                  if ( latDiff > 1.1) {
32                          throw new BoundingBoxException("For stor latitude forskel / " + latDiff);                          throw new BoundingBoxException("For stor latitude forskel / " + latDiff);
33                  }                  }
34                                    
35                  double lngDiff = Math.abs(longitudeMax - longitudeMin);                  double lngDiff = Math.abs(longitudeMax - longitudeMin);
36                  if ( lngDiff > 1.0) {                  if ( lngDiff > 1.1) {
37                          throw new BoundingBoxException("For stor longitude forskel / " + lngDiff);                          throw new BoundingBoxException("For stor longitude forskel / " + lngDiff);
38                  }                  }
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 >= 80.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                    
49          public void adjustToMargin() {          public void adjustToMargin(double kmMargin) {
50                  Constants consts = Constants.getInstance();                  double latMargin = GeoPointHelper.kmToLatitude(kmMargin);
51                    double lngMargin = GeoPointHelper.kmToLongitude(kmMargin);
52                    
53                    latitudeMax += latMargin;
54                    latitudeMin -= latMargin;
55                    
56                    longitudeMax += lngMargin;
57                    longitudeMin -= lngMargin;
58            }
59            
60            @Override
61            public BoundingBox clone() {
62                    BoundingBox bb = new BoundingBox();
63                    bb.latitudeMax = this.latitudeMax;
64                    bb.longitudeMax = this.longitudeMax;
65                                    
66                  latitudeMax += consts.getLatitudeMargin();                  bb.latitudeMin = this.latitudeMin;
67                  latitudeMin -= consts.getLatitudeMargin();                  bb.longitudeMin = this.longitudeMin;
68                                    
69                  longitudeMax += consts.getLongitudeMargin();                  return bb;
                 longitudeMin -= consts.getLongitudeMargin();  
70          }          }
71                    
72    

Legend:
Removed from v.2239  
changed lines
  Added in v.2585

  ViewVC Help
Powered by ViewVC 1.1.20