Skip to content
Snippets Groups Projects
Commit 12ac6314 authored by Christopher Schankula's avatar Christopher Schankula :earth_africa:
Browse files

range search including lat / long

parent c784de31
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment