/[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 2146 by torben, Wed Apr 30 09:02:39 2014 UTC revision 2264 by torben, Tue Feb 10 16:34:55 2015 UTC
# Line 1  Line 1 
1  package dk.daoas.fulddaekning;  package dk.daoas.fulddaekning;
2    
3  public class BoundingBox {  public class BoundingBox {
4                    
5                    
6          public static class BoundingBoxException extends Exception{          public static class BoundingBoxException extends Exception{
7                  public BoundingBoxException(String reason) {                  public BoundingBoxException(String reason) {
# Line 10  public class BoundingBox { Line 11  public class BoundingBox {
11                  private static final long serialVersionUID = 1L;                                  private static final long serialVersionUID = 1L;                
12          }          }
13                    
14          public static final double LATITUDE_MARGIN = 0.02702703;          //public static final double LATITUDE_MARGIN = 0.02702703;
15          public static final double LONGUTUDE_MARGIN = 0.046875;          //public static final double LONGUTUDE_MARGIN = 0.046875;
16                    
17          public double latitudeMax;          public double latitudeMax;
18          public double latitudeMin;          public double latitudeMin;
# Line 26  public class BoundingBox { Line 27  public class BoundingBox {
27          }          }
28                    
29          public void validateBbox() throws BoundingBoxException {          public void validateBbox() throws BoundingBoxException {
                 if ( Math.abs(latitudeMax-latitudeMin)> 1.0)  
                         throw new BoundingBoxException("For stor latitude forskel");  
30                                    
31                  if ( Math.abs(longitudeMax-longitudeMin)> 1.0)                  double latDiff = Math.abs(latitudeMax - latitudeMin);          
32                          throw new BoundingBoxException("For stor longitude forskel");                                    if ( latDiff > 1.1) {
33                            throw new BoundingBoxException("For stor latitude forskel / " + latDiff);
34                    }
35                    
36                    double lngDiff = Math.abs(longitudeMax - longitudeMin);
37                    if ( lngDiff > 1.1) {
38                            throw new BoundingBoxException("For stor longitude forskel / " + lngDiff);
39                    }
40                    
41                    GeoPoint min = new GeoPoint(latitudeMin, longitudeMin);
42                    GeoPoint max = new GeoPoint(latitudeMax, longitudeMax);
43                    double afstand = GeoPoint.beregnAfstand(min, max);
44                    
45                    if (afstand >= 125.0) { //hvis cross afstand er over 80 km - så er postnummeret for stort
46                            throw new BoundingBoxException("For stor cross afstand " + afstand);
47                    }
48          }          }
49                    
50          public void adjustToMargin() {          public void adjustToMargin() {
51                  latitudeMax += LATITUDE_MARGIN;                  Constants consts = Constants.getInstance();
52                  latitudeMin -= LATITUDE_MARGIN;                  
53                    latitudeMax += consts.getLatitudeMargin();
54                    latitudeMin -= consts.getLatitudeMargin();
55                    
56                    longitudeMax += consts.getLongitudeMargin();
57                    longitudeMin -= consts.getLongitudeMargin();
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                    bb.latitudeMin = this.latitudeMin;
67                    bb.longitudeMin = this.longitudeMin;
68                                    
69                  longitudeMax += LONGUTUDE_MARGIN;                  return bb;
                 longitudeMin -= LONGUTUDE_MARGIN;  
70          }          }
71                    
72    

Legend:
Removed from v.2146  
changed lines
  Added in v.2264

  ViewVC Help
Powered by ViewVC 1.1.20