--- dao/FuldDaekningWorker/src/dk/daoas/fulddaekning/BoundingBox.java 2014/04/30 08:15:48 2145 +++ dao/FuldDaekningWorker/src/dk/daoas/fulddaekning/BoundingBox.java 2014/09/11 20:44:20 2211 @@ -1,6 +1,7 @@ package dk.daoas.fulddaekning; public class BoundingBox { + public static class BoundingBoxException extends Exception{ public BoundingBoxException(String reason) { @@ -10,8 +11,8 @@ private static final long serialVersionUID = 1L; } - public static final double LATITUDE_MARGIN = 0.02702703; - public static final double LONGUTUDE_MARGIN = 0.046875; + //public static final double LATITUDE_MARGIN = 0.02702703; + //public static final double LONGUTUDE_MARGIN = 0.046875; public double latitudeMax; public double latitudeMin; @@ -22,23 +23,34 @@ @Override public String toString() { - return "bbox: Latitude=" + latitudeMax +"/" + latitudeMin + " longitude=" + longitudeMax + "/" + longitudeMin; + return "bbox: Latitude=" + latitudeMin +"/" + latitudeMax + " longitude=" + longitudeMin + "/" + longitudeMax; } public void validateBbox() throws BoundingBoxException { + if ( Math.abs(latitudeMax-latitudeMin)> 1.0) throw new BoundingBoxException("For stor latitude forskel"); if ( Math.abs(longitudeMax-longitudeMin)> 1.0) - throw new BoundingBoxException("For stor longitude forskel"); + throw new BoundingBoxException("For stor longitude forskel"); + + GeoPoint min = new GeoPoint(latitudeMin, longitudeMin); + GeoPoint max = new GeoPoint(latitudeMax, longitudeMax); + double afstand = GeoPoint.beregnAfstand(min, max); + + if (afstand >= 90.0) { //hvis cross størrelsen er over 90 km - så er postnummeret for stort + throw new BoundingBoxException("For stor cross afstand " + afstand); + } } public void adjustToMargin() { - latitudeMax += LATITUDE_MARGIN; - latitudeMin -= LATITUDE_MARGIN; + Constants consts = Constants.getInstance(); + + latitudeMax += consts.getLatitudeMargin(); + latitudeMin -= consts.getLatitudeMargin(); - longitudeMax += LONGUTUDE_MARGIN; - longitudeMin -= LONGUTUDE_MARGIN; + longitudeMax += consts.getLongitudeMargin(); + longitudeMin -= consts.getLongitudeMargin(); }