Skip to content
Snippets Groups Projects
Commit 31b205be authored by Ray Liu's avatar Ray Liu
Browse files

Added Date fields and getters for record and also added rangehelper

functions for longitude and latitude
parent 101cff32
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,7 @@ public class Record implements Comparable<Record> {
private final int year;
private final int month;
private final int day;
private final Date recDate;
/**
......@@ -29,6 +30,7 @@ public class Record implements Comparable<Record> {
this.year = year;
this.month = month;
this.day = day;
this.recDate = new Date(year,month,day);
}
......@@ -109,6 +111,15 @@ public class Record implements Comparable<Record> {
return day;
}
/**
* Gets date of the record
*
* @return The date of the record
*/
public Date getDate() {
return recDate;
}
@Override
public int compareTo(Record o) {
// TODO Auto-generated method stub
......
......@@ -34,4 +34,68 @@ public class RangeHelper {
}
else return null;
}
public static GeneralRange<Record> longitude(Bound boundtype) {
if (boundtype == Bound.ANY) {
GeneralRange<Record> range = p -> 0;
return range;
}
else return null;
}
public static GeneralRange<Record> longitude(Bound boundtype, int bound) {
if (boundtype == Bound.LOWER) {
GeneralRange<Record> range = p -> p.getLongitude() < bound ? 0 : 1;
return range;
}
else if (boundtype == Bound.UPPER) {
GeneralRange<Record> range = p -> p.getLongitude() > bound ? 0 : 1;
return range;
}
else if (boundtype == Bound.EQUALS) {
GeneralRange<Record> range = p -> p.getLongitude() == bound ? 0 : 1;
return range;
}
else return null;
}
public static GeneralRange<Record> longitude(Bound boundtype, int leftbound, int rightbound) {
if (boundtype == Bound.LOWHIGH) {
GeneralRange<Record> range = p -> p.getLongitude() < leftbound ? -1 : (p.getLongitude() > rightbound ? 1 : 0);
return range;
}
else return null;
}
public static GeneralRange<Record> latitude(Bound boundtype) {
if (boundtype == Bound.ANY) {
GeneralRange<Record> range = p -> 0;
return range;
}
else return null;
}
public static GeneralRange<Record> latitude(Bound boundtype, int bound) {
if (boundtype == Bound.LOWER) {
GeneralRange<Record> range = p -> p.getLatitude() < bound ? 0 : 1;
return range;
}
else if (boundtype == Bound.UPPER) {
GeneralRange<Record> range = p -> p.getLatitude() > bound ? 0 : 1;
return range;
}
else if (boundtype == Bound.EQUALS) {
GeneralRange<Record> range = p -> p.getLatitude() == bound ? 0 : 1;
return range;
}
else return null;
}
public static GeneralRange<Record> latitude(Bound boundtype, int leftbound, int rightbound) {
if (boundtype == Bound.LOWHIGH) {
GeneralRange<Record> range = p -> p.getLatitude() < leftbound ? -1 : (p.getLatitude() > rightbound ? 1 : 0);
return range;
}
else return null;
}
}
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