Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
… into andyhelp-master

[pull #32] Updated tests for new <speed> tag
  • Loading branch information
nguillaumin committed Aug 31, 2013
2 parents a2bf9c6 + 22645b0 commit 5a00dd3
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/me/guillaumin/android/osmtracker/db/DataHelper.java
Expand Up @@ -94,6 +94,9 @@ public void track(long trackId, Location location) {
if (location.hasAccuracy()) {
values.put(Schema.COL_ACCURACY, location.getAccuracy());
}
if (location.hasSpeed()) {
values.put(Schema.COL_SPEED, location.getSpeed());
}

SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
if (prefs.getBoolean(OSMTracker.Preferences.KEY_GPS_IGNORE_CLOCK, OSMTracker.Preferences.VAL_GPS_IGNORE_CLOCK)) {
Expand Down
6 changes: 5 additions & 1 deletion src/me/guillaumin/android/osmtracker/db/DatabaseHelper.java
Expand Up @@ -33,6 +33,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
+ Schema.COL_TRACK_ID + " integer not null,"
+ Schema.COL_LATITUDE + " double not null,"
+ Schema.COL_LONGITUDE + " double not null,"
+ Schema.COL_SPEED + " double null,"
+ Schema.COL_ELEVATION + " double null,"
+ Schema.COL_ACCURACY + " double null,"
+ Schema.COL_TIMESTAMP + " long not null" + ")";
Expand Down Expand Up @@ -112,9 +113,10 @@ public class DatabaseHelper extends SQLiteOpenHelper {
* v13: TBL_TRACK.COL_DIR is now deprecated (rxxx) v0.5.3 TODO: fill in correct revision and version
* v14: add TBL_TRACK.COL_OSM_UPLOAD_DATE, TBL_TRACK.COL_DESCRIPTION,
* TBL_TRACK.COL_TAGS and TBL_TRACK.COL_OSM_VISIBILITY for OSM upload - v0.6.0
* v15: add TBL_TRACKPOINT.COL_SPPED
*</pre>
*/
private static final int DB_VERSION = 14;
private static final int DB_VERSION = 15;

public DatabaseHelper(Context context) {
super(context, DB_NAME, null, DB_VERSION);
Expand Down Expand Up @@ -157,6 +159,8 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("alter table " + Schema.TBL_TRACK + " add column " + Schema.COL_TAGS + " text");
db.execSQL("alter table " + Schema.TBL_TRACK + " add column " + Schema.COL_OSM_VISIBILITY
+ " text default '"+OSMVisibility.Private+"'");
case 14:
db.execSQL("alter table " + Schema.TBL_TRACKPOINT + " add column " + Schema.COL_SPEED + " double null");
}

}
Expand Down
Expand Up @@ -428,6 +428,7 @@ public static final class Schema {
public static final String COL_UUID = "uuid";
public static final String COL_LONGITUDE = "longitude";
public static final String COL_LATITUDE = "latitude";
public static final String COL_SPEED = "speed";
public static final String COL_ELEVATION = "elevation";
public static final String COL_ACCURACY = "accuracy";
public static final String COL_NBSATELLITES = "nb_satellites";
Expand Down
Expand Up @@ -315,7 +315,13 @@ private void writeTrackPoints(String trackName, Writer fw, Cursor c, boolean fil
if(fillHDOP && ! c.isNull(c.getColumnIndex(Schema.COL_ACCURACY))) {
out.append("\t\t\t\t" + "<hdop>" + (c.getDouble(c.getColumnIndex(Schema.COL_ACCURACY)) / OSMTracker.HDOP_APPROXIMATION_FACTOR) + "</hdop>" + "\n");
}


if(! c.isNull(c.getColumnIndex(Schema.COL_SPEED))) {
out.append("\t\t\t\t" + "<extensions>\n");
out.append("\t\t\t\t\t" + "<speed>" + c.getDouble(c.getColumnIndex(Schema.COL_SPEED)) + "</speed>" + "\n");
out.append("\t\t\t\t" + "</extensions>\n");
}

out.append("\t\t\t" + "</trkpt>" + "\n");
fw.write(out.toString());

Expand Down
3 changes: 2 additions & 1 deletion tests/.classpath
Expand Up @@ -4,6 +4,7 @@
<classpathentry kind="src" path="gen"/>
<classpathentry combineaccessrules="false" kind="src" path="/osmtracker-android"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
14 changes: 10 additions & 4 deletions tests/assets/gpx/gpx-test.gpx
Expand Up @@ -2,7 +2,7 @@
<gpx xmlns="http://www.topografix.com/GPX/1/1" version="1.1" creator="OSMTracker for Android™ - http://osmtracker-android.googlecode.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd ">
<wpt lat="34.12" lon="18.45">
<ele>5812.2</ele>
<time>2012-03-12T16:46:38Z</time>
<time>2012-03-12T05:46:38Z</time>
<name><![CDATA[wp1]]></name>
<link href="http%3A%2F%2Flink1.com">
<text>http://link1.com</text>
Expand All @@ -12,7 +12,7 @@
</wpt>
<wpt lat="43.76" lon="31.89">
<ele>75.4</ele>
<time>2012-03-12T16:46:38Z</time>
<time>2012-03-12T05:46:38Z</time>
<name><![CDATA[wp2]]></name>
<link href="http%3A%2F%2Flink2.com">
<text>http://link2.com</text>
Expand All @@ -26,13 +26,19 @@
<trkseg>
<trkpt lat="12.34" lon="56.78">
<ele>4321.7</ele>
<time>2012-03-12T16:46:38Z</time>
<time>2012-03-12T05:46:38Z</time>
<hdop>0.10499999672174454</hdop>
<extensions>
<speed>45.79999923706055</speed>
</extensions>
</trkpt>
<trkpt lat="21.57" lon="12.6">
<ele>12.1</ele>
<time>2012-03-12T16:46:38Z</time>
<time>2012-03-12T05:46:38Z</time>
<hdop>0.05999999865889549</hdop>
<extensions>
<speed>12.600000381469727</speed>
</extensions>
</trkpt>
</trkseg>
</trk>
Expand Down
Expand Up @@ -12,7 +12,7 @@ public OSMUploadTest() {

@Override
protected void setUp() throws Exception {
MockData.mockBigTrack(getInstrumentation().getContext(), 2000, 2000);
// MockData.mockBigTrack(getInstrumentation().getContext(), 2000, 2000);
}

public void test() {
Expand Down

0 comments on commit 5a00dd3

Please sign in to comment.