Commit 11f19d86 authored by Chris Scott's avatar Chris Scott

Adding accuracy, speed to persistence

parent 7dd786bf
...@@ -9,6 +9,9 @@ public class Location { ...@@ -9,6 +9,9 @@ public class Location {
private String latitude; private String latitude;
private String longitude; private String longitude;
private Date recordedAt; private Date recordedAt;
private String accuracy;
private String speed;
private Long id; private Long id;
public Long getId() { public Long getId() {
...@@ -17,7 +20,6 @@ public class Location { ...@@ -17,7 +20,6 @@ public class Location {
public void setId(Long id) { public void setId(Long id) {
this.id = id; this.id = id;
} }
public String getLatitude() { public String getLatitude() {
return latitude; return latitude;
} }
...@@ -36,12 +38,26 @@ public class Location { ...@@ -36,12 +38,26 @@ public class Location {
public void setRecordedAt(Date recordedAt) { public void setRecordedAt(Date recordedAt) {
this.recordedAt = recordedAt; this.recordedAt = recordedAt;
} }
public String getAccuracy() {
return accuracy;
}
public void setAccuracy(String accuracy) {
this.accuracy = accuracy;
}
public String getSpeed() {
return speed;
}
public void setSpeed(String speed) {
this.speed = speed;
}
public static Location fromAndroidLocation(android.location.Location originalLocation) { public static Location fromAndroidLocation(android.location.Location originalLocation) {
Location location = new Location(); Location location = new Location();
location.setRecordedAt(new Date(originalLocation.getTime())); location.setRecordedAt(new Date(originalLocation.getTime()));
location.setLongitude(String.valueOf(originalLocation.getLongitude())); location.setLongitude(String.valueOf(originalLocation.getLongitude()));
location.setLatitude(String.valueOf(originalLocation.getLatitude())); location.setLatitude(String.valueOf(originalLocation.getLatitude()));
location.setAccuracy(String.valueOf(originalLocation.getAccuracy()));
location.setSpeed(String.valueOf(originalLocation.getSpeed()));
return location; return location;
} }
......
...@@ -7,21 +7,23 @@ import android.database.sqlite.SQLiteOpenHelper; ...@@ -7,21 +7,23 @@ import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log; import android.util.Log;
public class LocationOpenHelper extends SQLiteOpenHelper { public class LocationOpenHelper extends SQLiteOpenHelper {
private static final String SQLITE_DATABASE_NAME = "cordova_bg_locations"; private static final String SQLITE_DATABASE_NAME = "cordova_bg_locations";
private static final int DATABASE_VERSION = 1; private static final int DATABASE_VERSION = 1;
public static final String LOCATION_TABLE_NAME = "location"; public static final String LOCATION_TABLE_NAME = "location";
private static final String LOCATION_TABLE_COLUMNS = private static final String LOCATION_TABLE_COLUMNS =
" id INTEGER PRIMARY KEY AUTOINCREMENT," + " id INTEGER PRIMARY KEY AUTOINCREMENT," +
" recordedAt TEXT," + " recordedAt TEXT," +
" accuracy TEXT," +
" speed TEXT," +
" latitude TEXT," + " latitude TEXT," +
" longitude TEXT"; " longitude TEXT";
private static final String LOCATION_TABLE_CREATE = private static final String LOCATION_TABLE_CREATE =
"CREATE TABLE " + LOCATION_TABLE_NAME + " (" + "CREATE TABLE " + LOCATION_TABLE_NAME + " (" +
LOCATION_TABLE_COLUMNS + LOCATION_TABLE_COLUMNS +
");"; ");";
LocationOpenHelper(Context context) { LocationOpenHelper(Context context) {
super(context, SQLITE_DATABASE_NAME, null, DATABASE_VERSION); super(context, SQLITE_DATABASE_NAME, null, DATABASE_VERSION);
} }
@Override @Override
...@@ -30,9 +32,9 @@ public class LocationOpenHelper extends SQLiteOpenHelper { ...@@ -30,9 +32,9 @@ public class LocationOpenHelper extends SQLiteOpenHelper {
Log.d(this.getClass().getName(), LOCATION_TABLE_CREATE); Log.d(this.getClass().getName(), LOCATION_TABLE_CREATE);
} }
@Override @Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
} }
\ No newline at end of file
...@@ -78,6 +78,8 @@ public class SQLiteLocationDAO implements LocationDAO { ...@@ -78,6 +78,8 @@ public class SQLiteLocationDAO implements LocationDAO {
l.setRecordedAt(stringToDate(c.getString(c.getColumnIndex("recordedAt")))); l.setRecordedAt(stringToDate(c.getString(c.getColumnIndex("recordedAt"))));
l.setLatitude(c.getString(c.getColumnIndex("latitude"))); l.setLatitude(c.getString(c.getColumnIndex("latitude")));
l.setLongitude(c.getString(c.getColumnIndex("longitude"))); l.setLongitude(c.getString(c.getColumnIndex("longitude")));
l.setAccuracy(c.getString(c.getColumnIndex("accuracy")));
l.setSpeed(c.getString(c.getColumnIndex("speed")));
return l; return l;
} }
...@@ -87,7 +89,8 @@ public class SQLiteLocationDAO implements LocationDAO { ...@@ -87,7 +89,8 @@ public class SQLiteLocationDAO implements LocationDAO {
values.put("latitude", location.getLatitude()); values.put("latitude", location.getLatitude());
values.put("longitude", location.getLongitude()); values.put("longitude", location.getLongitude());
values.put("recordedAt", dateToString(location.getRecordedAt())); values.put("recordedAt", dateToString(location.getRecordedAt()));
values.put("accuracy", location.getAccuracy());
values.put("speed", location.getSpeed());
return values; return values;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment