Report location accuracy
Этот коммит содержится в:
@@ -27,7 +27,7 @@ import java.util.Date;
|
|||||||
|
|
||||||
public class DatabaseHelper extends SQLiteOpenHelper {
|
public class DatabaseHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
public static final int DATABASE_VERSION = 1;
|
public static final int DATABASE_VERSION = 2;
|
||||||
public static final String DATABASE_NAME = "traccar.db";
|
public static final String DATABASE_NAME = "traccar.db";
|
||||||
|
|
||||||
public interface DatabaseHandler<T> {
|
public interface DatabaseHandler<T> {
|
||||||
@@ -79,6 +79,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
|||||||
"altitude REAL," +
|
"altitude REAL," +
|
||||||
"speed REAL," +
|
"speed REAL," +
|
||||||
"course REAL," +
|
"course REAL," +
|
||||||
|
"accuracy REAL," +
|
||||||
"battery REAL)");
|
"battery REAL)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,6 +98,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
|||||||
values.put("altitude", position.getAltitude());
|
values.put("altitude", position.getAltitude());
|
||||||
values.put("speed", position.getSpeed());
|
values.put("speed", position.getSpeed());
|
||||||
values.put("course", position.getCourse());
|
values.put("course", position.getCourse());
|
||||||
|
values.put("accuracy", position.getCourse());
|
||||||
values.put("battery", position.getBattery());
|
values.put("battery", position.getBattery());
|
||||||
|
|
||||||
db.insertOrThrow("position", null, values);
|
db.insertOrThrow("position", null, values);
|
||||||
@@ -129,6 +131,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
|
|||||||
position.setAltitude(cursor.getDouble(cursor.getColumnIndex("altitude")));
|
position.setAltitude(cursor.getDouble(cursor.getColumnIndex("altitude")));
|
||||||
position.setSpeed(cursor.getDouble(cursor.getColumnIndex("speed")));
|
position.setSpeed(cursor.getDouble(cursor.getColumnIndex("speed")));
|
||||||
position.setCourse(cursor.getDouble(cursor.getColumnIndex("course")));
|
position.setCourse(cursor.getDouble(cursor.getColumnIndex("course")));
|
||||||
|
position.setAccuracy(cursor.getDouble(cursor.getColumnIndex("accuracy")));
|
||||||
position.setBattery(cursor.getDouble(cursor.getColumnIndex("battery")));
|
position.setBattery(cursor.getDouble(cursor.getColumnIndex("battery")));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
package org.traccar.client;
|
package org.traccar.client;
|
||||||
|
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
|
import android.location.LocationManager;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@@ -32,6 +33,9 @@ public class Position {
|
|||||||
altitude = location.getAltitude();
|
altitude = location.getAltitude();
|
||||||
speed = location.getSpeed() * 1.943844; // speed in knots
|
speed = location.getSpeed() * 1.943844; // speed in knots
|
||||||
course = location.getBearing();
|
course = location.getBearing();
|
||||||
|
if (location.getProvider() != null && !location.getProvider().equals(LocationManager.GPS_PROVIDER)) {
|
||||||
|
accuracy = location.getAccuracy();
|
||||||
|
}
|
||||||
this.battery = battery;
|
this.battery = battery;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,6 +119,16 @@ public class Position {
|
|||||||
this.course = course;
|
this.course = course;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private double accuracy;
|
||||||
|
|
||||||
|
public double getAccuracy() {
|
||||||
|
return accuracy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccuracy(double accuracy) {
|
||||||
|
this.accuracy = accuracy;
|
||||||
|
}
|
||||||
|
|
||||||
private double battery;
|
private double battery;
|
||||||
|
|
||||||
public double getBattery() {
|
public double getBattery() {
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ public class ProtocolFormatter {
|
|||||||
.appendQueryParameter("speed", String.valueOf(position.getSpeed()))
|
.appendQueryParameter("speed", String.valueOf(position.getSpeed()))
|
||||||
.appendQueryParameter("bearing", String.valueOf(position.getCourse()))
|
.appendQueryParameter("bearing", String.valueOf(position.getCourse()))
|
||||||
.appendQueryParameter("altitude", String.valueOf(position.getAltitude()))
|
.appendQueryParameter("altitude", String.valueOf(position.getAltitude()))
|
||||||
|
.appendQueryParameter("accuracy", String.valueOf(position.getAccuracy()))
|
||||||
.appendQueryParameter("batt", String.valueOf(position.getBattery()));
|
.appendQueryParameter("batt", String.valueOf(position.getBattery()));
|
||||||
|
|
||||||
if (alarm != null) {
|
if (alarm != null) {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
|
|
||||||
package org.traccar.client;
|
package org.traccar.client;
|
||||||
|
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -24,8 +23,6 @@ public class DatabaseHelperTest {
|
|||||||
|
|
||||||
DatabaseHelper databaseHelper = new DatabaseHelper(RuntimeEnvironment.application);
|
DatabaseHelper databaseHelper = new DatabaseHelper(RuntimeEnvironment.application);
|
||||||
|
|
||||||
SQLiteDatabase db = databaseHelper.getWritableDatabase();
|
|
||||||
|
|
||||||
Position position = new Position("123456789012345", new Location("gps"), 0);
|
Position position = new Position("123456789012345", new Location("gps"), 0);
|
||||||
position.setTime(new Date(0));
|
position.setTime(new Date(0));
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class ProtocolFormatterTest {
|
|||||||
position.setTime(new Date(0));
|
position.setTime(new Date(0));
|
||||||
|
|
||||||
String url = ProtocolFormatter.formatRequest("http://localhost:5055", position);
|
String url = ProtocolFormatter.formatRequest("http://localhost:5055", position);
|
||||||
assertEquals("http://localhost:5055?id=123456789012345×tamp=0&lat=0.0&lon=0.0&speed=0.0&bearing=0.0&altitude=0.0&batt=0.0", url);
|
assertEquals("http://localhost:5055?id=123456789012345×tamp=0&lat=0.0&lon=0.0&speed=0.0&bearing=0.0&altitude=0.0&accuracy=0.0&batt=0.0", url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -33,7 +33,7 @@ public class ProtocolFormatterTest {
|
|||||||
position.setTime(new Date(0));
|
position.setTime(new Date(0));
|
||||||
|
|
||||||
String url = ProtocolFormatter.formatRequest("http://localhost:8888/path", position);
|
String url = ProtocolFormatter.formatRequest("http://localhost:8888/path", position);
|
||||||
assertEquals("http://localhost:8888/path?id=123456789012345×tamp=0&lat=0.0&lon=0.0&speed=0.0&bearing=0.0&altitude=0.0&batt=0.0", url);
|
assertEquals("http://localhost:8888/path?id=123456789012345×tamp=0&lat=0.0&lon=0.0&speed=0.0&bearing=0.0&altitude=0.0&accuracy=0.0&batt=0.0", url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -43,6 +43,6 @@ public class ProtocolFormatterTest {
|
|||||||
position.setTime(new Date(0));
|
position.setTime(new Date(0));
|
||||||
|
|
||||||
String url = ProtocolFormatter.formatRequest("http://localhost:5055/path", position, "alert message");
|
String url = ProtocolFormatter.formatRequest("http://localhost:5055/path", position, "alert message");
|
||||||
assertEquals("http://localhost:5055/path?id=123456789012345×tamp=0&lat=0.0&lon=0.0&speed=0.0&bearing=0.0&altitude=0.0&batt=0.0&alarm=alert%20message", url);
|
assertEquals("http://localhost:5055/path?id=123456789012345×tamp=0&lat=0.0&lon=0.0&speed=0.0&bearing=0.0&altitude=0.0&accuracy=0.0&batt=0.0&alarm=alert%20message", url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user