1 package tim.prune.data;
4 * Class to hold a rectangle of latitude/longitude
5 * with minimum and maximum values for each
7 public class LatLonRectangle
9 private DoubleRange _latRange = null;
10 private DoubleRange _lonRange = null;
15 * @param inLatRange latitude range
16 * @param inLonRange longitude range
18 public LatLonRectangle(DoubleRange inLatRange, DoubleRange inLonRange)
20 _latRange = inLatRange;
21 _lonRange = inLonRange;
22 // MAYBE: Expand range by certain percentage
26 * @return true if the range is empty
28 public boolean isEmpty()
30 return _latRange == null || _lonRange == null
31 || !_latRange.hasData() || !_lonRange.hasData();
35 * Check if a point is within the rectangle
36 * @param inPoint point to check
37 * @return true if point within rectangle
39 public boolean containsPoint(DataPoint inPoint)
41 if (inPoint != null && !isEmpty())
43 double pointLat = inPoint.getLatitude().getDouble();
44 double pointLon = inPoint.getLongitude().getDouble();
45 return (pointLat >= _latRange.getMinimum() && pointLat <= _latRange.getMaximum()
46 && pointLon >= _lonRange.getMinimum() && pointLon <= _lonRange.getMaximum());