diff --git a/src/search/BasicSearch.java b/src/search/BasicSearch.java index ec7894aa92b82a9f8d845bf7091c968987bfc82c..1a906ba07e4dff7115f89bd0e13689c925d6c50a 100644 --- a/src/search/BasicSearch.java +++ b/src/search/BasicSearch.java @@ -17,6 +17,10 @@ import sort.RangeHelper; * */ public class BasicSearch { + public static BasicSearchResult range(Integer taxonId, Integer yearLo, Integer yearHi){ + return range(taxonId, yearLo, yearHi, -90.0, 90.0, -180.0, 180.0); + } + /** * Returns all records matching any of the children of the given TaxonID and in the * date range given @@ -25,7 +29,7 @@ public class BasicSearch { * @param yearHi The upper bound on the year range * @return */ - public static BasicSearchResult range(Integer taxonId, Integer yearLo, Integer yearHi){ + public static BasicSearchResult range(Integer taxonId, Integer yearLo, Integer yearHi, Double latLo, Double latHi, Double longLo, Double longHi){ GeneralRange<Record> a0 = RangeHelper.date(Bound.ANY); if ((yearLo != null) && (yearHi != null)) { @@ -34,8 +38,16 @@ public class BasicSearch { a0 = RangeHelper.date(Bound.LOWHIGH, lower, upper); } - GeneralRange<Record> a2 = r -> 0; - GeneralRange<Record> a3 = r -> 0; + GeneralRange<Record> a2 = RangeHelper.latitude(Bound.ANY); + GeneralRange<Record> a3 = RangeHelper.longitude(Bound.ANY); + + if ((latLo != null) && (latHi != null)) { + a2 = RangeHelper.latitude(Bound.LOWHIGH, latLo, latHi); + } + + if ((longLo != null) && (longHi != null)) { + a3 = RangeHelper.longitude(Bound.LOWHIGH, longLo, longHi); + } GeneralRange<Record> a1; diff --git a/src/sort/RangeHelper.java b/src/sort/RangeHelper.java index 2a960cb7eb51ac84d9f7c4af06e0cdd44b59eb5d..4110115eb5eb703fad41dd28d92a30d2d33325fc 100644 --- a/src/sort/RangeHelper.java +++ b/src/sort/RangeHelper.java @@ -84,7 +84,7 @@ public class RangeHelper { * @param bound -Value of bound * @return -General range that matches the bound */ - public static GeneralRange<Record> longitude(Bound boundtype, float bound) { + public static GeneralRange<Record> longitude(Bound boundtype, double bound) { if (boundtype == Bound.LOWER) { GeneralRange<Record> range = p -> p.getLongitude() < bound ? 0 : 1; return range; @@ -94,7 +94,7 @@ public class RangeHelper { return range; } else if (boundtype == Bound.EQUALS) { - GeneralRange<Record> range = p -> Float.compare(p.getLongitude(), bound) ; + GeneralRange<Record> range = p -> Double.compare(p.getLongitude(), bound) ; return range; } else return null; @@ -108,7 +108,7 @@ public class RangeHelper { * @param rightbound -Value of right bound * @return -General range that matches the bound */ - public static GeneralRange<Record> longitude(Bound boundtype, float leftbound, float rightbound) { + public static GeneralRange<Record> longitude(Bound boundtype, double leftbound, double rightbound) { if (boundtype == Bound.LOWHIGH) { GeneralRange<Record> range = p -> p.getLongitude() < leftbound ? -1 : (p.getLongitude() > rightbound ? 1 : 0); return range; @@ -138,7 +138,7 @@ public class RangeHelper { * @param bound -Value of bound * @return -General range that matches the bound */ - public static GeneralRange<Record> latitude(Bound boundtype, float bound) { + public static GeneralRange<Record> latitude(Bound boundtype, double bound) { if (boundtype == Bound.LOWER) { GeneralRange<Record> range = p -> p.getLatitude() < bound ? 0 : 1; return range; @@ -148,7 +148,7 @@ public class RangeHelper { return range; } else if (boundtype == Bound.EQUALS) { - GeneralRange<Record> range = p -> Float.compare(p.getLatitude(), bound); + GeneralRange<Record> range = p -> Double.compare(p.getLatitude(), bound); return range; } else return null; @@ -163,7 +163,7 @@ public class RangeHelper { * @param rightbound -Value of right bound * @return -General range that matches the bound */ - public static GeneralRange<Record> latitude(Bound boundtype, int leftbound, int rightbound) { + public static GeneralRange<Record> latitude(Bound boundtype, double leftbound, double rightbound) { if (boundtype == Bound.LOWHIGH) { GeneralRange<Record> range = p -> p.getLatitude() < leftbound ? -1 : (p.getLatitude() > rightbound ? 1 : 0); return range;