1 package au.gov.amsa.ais.router.model; 2 3 public final class Rectangle implements Region { 4 private final float minLat; 5 private final float maxLat; 6 private final float minLon; 7 private final float maxLon; 8 9 private Rectangle(float minLat, float maxLat, float minLon, float maxLon) { 10 this.minLat = minLat; 11 this.maxLat = maxLat; 12 this.minLon = minLon; 13 this.maxLon = maxLon; 14 } 15 16 public float minLat() { 17 return minLat; 18 } 19 20 public float maxLat() { 21 return maxLat; 22 } 23 24 public float minLon() { 25 return minLon; 26 } 27 28 public float maxLon() { 29 return maxLon; 30 } 31 32 public static Builder builder() { 33 return new Builder(); 34 } 35 36 public static class Builder { 37 38 private float minLat; 39 private float maxLat; 40 private float minLon; 41 private float maxLon; 42 43 private Builder() { 44 } 45 46 public Builder minLat(float minLat) { 47 this.minLat = minLat; 48 return this; 49 } 50 51 public Builder maxLat(float maxLat) { 52 this.maxLat = maxLat; 53 return this; 54 } 55 56 public Builder minLon(float minLon) { 57 this.minLon = minLon; 58 return this; 59 } 60 61 public Builder maxLon(float maxLon) { 62 this.maxLon = maxLon; 63 return this; 64 } 65 66 public Rectangle build() { 67 return new Rectangle(minLat, maxLat, minLon, maxLon); 68 } 69 } 70 71 @Override 72 public boolean contains(float lat, float lon) { 73 return minLat <= lat && maxLat >= lat && minLon <= lon && maxLon >= lon; 74 } 75 76 }