/[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 2707 by torben, Sun Sep 27 13:21:45 2015 UTC
# Line 1  Line 1 
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{
# Line 10  public class BoundingBox { Line 10  public class BoundingBox {
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;          public double latitudeMin = Double.MAX_VALUE;
16                    
17          public double longitudeMax;          public double longitudeMax;
18          public double longitudeMin;          public double longitudeMin = Double.MAX_VALUE;
19                    
20                    
21          @Override          @Override
# Line 27  public class BoundingBox { Line 24  public class BoundingBox {
24          }          }
25                    
26          public void validateBbox() throws BoundingBoxException {          public void validateBbox() throws BoundingBoxException {
27                    
28                  double latDiff = Math.abs(latitudeMax - latitudeMin);                            double latDiff = Math.abs(latitudeMax - latitudeMin);          
29                  if ( latDiff > 1.0) {                  if ( latDiff > 1.1) {
30                          throw new BoundingBoxException("For stor latitude forskel / " + latDiff);                          throw new BoundingBoxException("For stor latitude forskel / " + latDiff);
31                  }                  }
32                                    
33                  double lngDiff = Math.abs(longitudeMax - longitudeMin);                  double lngDiff = Math.abs(longitudeMax - longitudeMin);
34                  if ( lngDiff > 1.0) {                  if ( lngDiff > 1.1) {
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 >= 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
43                          throw new BoundingBoxException("For stor cross afstand " + afstand);                          throw new BoundingBoxException("For stor cross afstand " + afstand);
44                  }                  }
45          }          }
46                    
47          public void adjustToMargin() {          
48                  Constants consts = Constants.getInstance();          @Override
49            public BoundingBox clone() {
50                    BoundingBox bb = new BoundingBox();
51                    bb.latitudeMax = this.latitudeMax;
52                    bb.longitudeMax = this.longitudeMax;
53                                    
54                  latitudeMax += consts.getLatitudeMargin();                  bb.latitudeMin = this.latitudeMin;
55                  latitudeMin -= consts.getLatitudeMargin();                  bb.longitudeMin = this.longitudeMin;
56                                    
57                  longitudeMax += consts.getLongitudeMargin();                  return bb;
                 longitudeMin -= consts.getLongitudeMargin();  
58          }          }
59                    
60    

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

  ViewVC Help
Powered by ViewVC 1.1.20