--- dao/FuldDaekningWorker/src/dk/daoas/fulddaekning/BoundingBox.java 2014/04/30 09:02:39 2146 +++ dao/FuldDaekningWorker/src/dk/daoas/fulddaekning/BoundingBox.java 2014/09/19 09:37:37 2221 @@ -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; @@ -26,19 +27,30 @@ } 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 >= 80.0) { //hvis cross afstand er over 80 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(); }