Browse Source

Merge pull request #7 from tccyp001/master

V2.0.0.1 Fixed a few issues
pull/8/head 2.0.0.1
mohammedkhider 7 years ago committed by GitHub
parent
commit
9defc8d4ab
  1. 15
      GNSSLogger/app/app.iml
  2. 2
      GNSSLogger/app/src/main/AndroidManifest.xml
  3. 5
      GNSSLogger/app/src/main/java/com/google/android/apps/location/gps/gnsslogger/PlotFragment.java
  4. 2
      GNSSLogger/app/src/main/res/values/strings.xml
  5. 1
      GNSSLogger/pseudorange/build.gradle
  6. 117
      GNSSLogger/pseudorange/src/main/java/com/google/location/lbs/gnss/gps/pseudorange/GpsTime.java

15
GNSSLogger/app/app.iml

@ -62,13 +62,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
@ -76,6 +69,13 @@
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
@ -127,5 +127,6 @@
<orderEntry type="library" exported="" name="animated-vector-drawable-26.0.0-alpha1" level="project" />
<orderEntry type="library" exported="" name="play-services-tasks-11.0.2" level="project" />
<orderEntry type="module" module-name="pseudorange" exported="" />
<orderEntry type="library" exported="" name="pseudorange-unspecified" level="project" />
</component>
</module>

2
GNSSLogger/app/src/main/AndroidManifest.xml

@ -9,6 +9,8 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"/>
<uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.WRITE_GSERVICES"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"

5
GNSSLogger/app/src/main/java/com/google/android/apps/location/gps/gnsslogger/PlotFragment.java

@ -38,10 +38,12 @@ import android.widget.Spinner;
import android.widget.TextView;
import com.google.location.lbs.gnss.gps.pseudorange.GpsNavigationMessageStore;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Locale;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import org.achartengine.ChartFactory;
@ -77,7 +79,8 @@ public class PlotFragment extends Fragment {
private static final int NUMBER_OF_STRONGEST_SATELLITES = 4;
/** Data format used to format the data in the text view */
private static final DecimalFormat sDataFormat = new DecimalFormat("##.#");
private static final DecimalFormat sDataFormat =
new DecimalFormat("##.#", new DecimalFormatSymbols(Locale.US));
private GraphicalView mChartView;

2
GNSSLogger/app/src/main/res/values/strings.xml

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_name">GnssLogger</string>
<string name="app_version">v2.0.0.0</string>
<string name="app_version">v2.0.0.1</string>
<string name="title_settings">Settings</string>
<string name="title_log">Log</string>

1
GNSSLogger/pseudorange/build.gradle

@ -40,6 +40,7 @@ dependencies {
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'joda-time:joda-time:2.9.4'
compile 'com.android.support:appcompat-v7:26.+'
testCompile 'junit:junit:4.12'
compile files('libs/guava-22.0-android.jar')

117
GNSSLogger/pseudorange/src/main/java/com/google/location/lbs/gnss/gps/pseudorange/GpsTime.java

@ -21,10 +21,8 @@ import com.google.common.base.Preconditions;
import com.google.common.primitives.Longs;
import java.util.Calendar;
import java.util.concurrent.TimeUnit;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.Instant;
import java.util.GregorianCalendar;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
/**
* A simple class to represent time unit used by GPS.
@ -46,27 +44,18 @@ public class GpsTime implements Comparable<GpsTime> {
TimeUnit.DAYS.toSeconds(GPS_DAYS_SINCE_JAVA_EPOCH);
public static final long GPS_UTC_EPOCH_OFFSET_NANOS =
TimeUnit.SECONDS.toNanos(GPS_UTC_EPOCH_OFFSET_SECONDS);
private static final ZonedDateTime LEAP_SECOND_DATE_1981 = getZonedDateTimeUTC(1981, 7, 1);
private static final ZonedDateTime LEAP_SECOND_DATE_2012 = getZonedDateTimeUTC(2012, 7, 1);
private static final ZonedDateTime LEAP_SECOND_DATE_2015 = getZonedDateTimeUTC(2015, 7, 1);
private static final ZonedDateTime LEAP_SECOND_DATE_2017 = getZonedDateTimeUTC(2017, 7, 1);
private static final long nanoSecPerSec = TimeUnit.SECONDS.toNanos(7);
private static final DateTimeZone UTC_ZONE = DateTimeZone.UTC;
private static final DateTime LEAP_SECOND_DATE_1981 =
new DateTime(1981, 7, 1, 0, 0, UTC_ZONE);
private static final DateTime LEAP_SECOND_DATE_2012 =
new DateTime(2012, 7, 1, 0, 0, UTC_ZONE);
private static final DateTime LEAP_SECOND_DATE_2015 =
new DateTime(2015, 7, 1, 0, 0, UTC_ZONE);
private static final DateTime LEAP_SECOND_DATE_2017 =
new DateTime(2017, 1, 1, 0, 0, UTC_ZONE);
// nanoseconds since GPS epoch (1980/1/6).
private long gpsNanos;
private static ZonedDateTime getZonedDateTimeUTC(int year, int month, int day) {
return getZonedDateTimeUTC(year, month, day, 0, 0, 0, 0);
}
private static ZonedDateTime getZonedDateTimeUTC(int year, int month, int day,
int hour, int minute, int sec, int nanoSec){
ZoneId zone = ZoneId.of("UTC");
ZonedDateTime zdt = ZonedDateTime.of(year, month, day, hour, minute, sec, nanoSec, zone);
return zdt;
}
private static long getMillisFromZonedDateTime(ZonedDateTime zdt) {
return zdt.toInstant().toEpochMilli();
}
/**
* Constructor for GpsTime. Input values are all in GPS time.
* @param year Year
@ -77,27 +66,23 @@ public class GpsTime implements Comparable<GpsTime> {
* @param second Second from 0 to 59
*/
public GpsTime(int year, int month, int day, int hour, int minute, double second) {
ZonedDateTime utcDateTime = getZonedDateTimeUTC(year, month, day, hour, minute,
(int) second, (int) ((second * nanoSecPerSec) % nanoSecPerSec));
DateTime utcDateTime = new DateTime(year, month, day, hour, minute,
(int) second, (int) (second * 1000) % 1000, UTC_ZONE);
// Since input time is already specify in GPS time, no need to count leap second here.
initGpsNanos(utcDateTime);
gpsNanos = TimeUnit.MILLISECONDS.toNanos(utcDateTime.getMillis())
- GPS_UTC_EPOCH_OFFSET_NANOS;
}
/**
* Constructor
* @param zDateTime is created using GPS time values.
* @param dateTime is created using GPS time values.
*/
public GpsTime(ZonedDateTime zDateTime) {
initGpsNanos(zDateTime);
}
public void initGpsNanos(ZonedDateTime zDateTime){
this.gpsNanos = TimeUnit.MILLISECONDS.toNanos(getMillisFromZonedDateTime(zDateTime))
public GpsTime(DateTime dateTime) {
gpsNanos = TimeUnit.MILLISECONDS.toNanos(dateTime.getMillis())
- GPS_UTC_EPOCH_OFFSET_NANOS;
}
/**
* Constructor
* @param gpsNanos nanoseconds since GPS epoch.
@ -108,21 +93,20 @@ public class GpsTime implements Comparable<GpsTime> {
/**
* Creates a GPS time using a UTC based date and time.
* @param zDateTime represents the current time in UTC time, must be after 2009
* @param dateTime represents the current time in UTC time, must be after 2009
*/
public static GpsTime fromUtc(ZonedDateTime zDateTime) {
return new GpsTime(TimeUnit.MILLISECONDS.toNanos(getMillisFromZonedDateTime(zDateTime))
public static GpsTime fromUtc(DateTime dateTime) {
return new GpsTime(
TimeUnit.MILLISECONDS.toNanos(dateTime.getMillis())
+ TimeUnit.SECONDS.toNanos(
GpsTime.getLeapSecond(zDateTime) - GPS_UTC_EPOCH_OFFSET_SECONDS));
GpsTime.getLeapSecond(dateTime) - GPS_UTC_EPOCH_OFFSET_SECONDS));
}
/**
* Creates a GPS time based upon the current time.
*/
public static GpsTime now() {
ZoneId zone = ZoneId.of("UTC");
ZonedDateTime current = ZonedDateTime.now(zone);
return fromUtc(current);
return fromUtc(DateTime.now(DateTimeZone.UTC));
}
/**
@ -147,9 +131,8 @@ public class GpsTime implements Comparable<GpsTime> {
Preconditions.checkArgument(yumaWeek < 1024);
// Estimate the multiplier of current week.
ZoneId zone = ZoneId.of("UTC");
ZonedDateTime current = ZonedDateTime.now(zone);
GpsTime refTime = new GpsTime(current);
DateTime currentTime = DateTime.now(UTC_ZONE);
GpsTime refTime = new GpsTime(currentTime);
Pair<Integer, Integer> refWeekSec = refTime.getGpsWeekSecond();
int weekMultiplier = refWeekSec.first / 1024;
@ -166,7 +149,7 @@ public class GpsTime implements Comparable<GpsTime> {
* @param time
* @return number of leap seconds since GPS epoch.
*/
public static int getLeapSecond(ZonedDateTime time) {
public static int getLeapSecond(DateTime time) {
if (LEAP_SECOND_DATE_2017.compareTo(time) <= 0) {
return 18;
} else if (LEAP_SECOND_DATE_2015.compareTo(time) <= 0) {
@ -217,16 +200,26 @@ public class GpsTime implements Comparable<GpsTime> {
return Pair.create(week, tow23b);
}
public long[] getBreakdownEpoch(TimeUnit... units) {
long nanos = this.gpsNanos;
long[] values = new long[units.length];
for (int idx = 0; idx < units.length; ++idx) {
TimeUnit unit = units[idx];
long value = unit.convert(nanos, TimeUnit.NANOSECONDS);
values[idx] = value;
nanos -= unit.toNanos(value);
}
return values;
}
/**
* @return Day of year in GPS time (GMT time)
*/
public static int getCurrentDayOfYear() {
ZoneId zone = ZoneId.of("UTC");
ZonedDateTime current = ZonedDateTime.now(zone);
DateTime current = DateTime.now(DateTimeZone.UTC);
// Since current is derived from UTC time, we need to add leap second here.
long gpsTimeMillis = getMillisFromZonedDateTime(current)
+ TimeUnit.SECONDS.toMillis(getLeapSecond(current));
ZonedDateTime gpsCurrent = ZonedDateTime.ofInstant(Instant.ofEpochMilli(gpsTimeMillis), ZoneId.of("UTC"));
long gpsTimeMillis = current.getMillis() + getLeapSecond(current);
DateTime gpsCurrent = new DateTime(gpsTimeMillis, UTC_ZONE);
return gpsCurrent.getDayOfYear();
}
@ -262,26 +255,24 @@ public class GpsTime implements Comparable<GpsTime> {
* @return the GPS time in Calendar.
*/
public Calendar getTimeInCalendar() {
return GregorianCalendar.from(getGpsDateTime());
return getGpsDateTime().toGregorianCalendar();
}
/**
* @return a ZonedDateTime with leap seconds considered.
* @return a DateTime with leap seconds considered.
*/
public ZonedDateTime getUtcDateTime() {
ZonedDateTime gpsDateTime = getGpsDateTime();
long gpsMillis = getMillisFromZonedDateTime(gpsDateTime)
- TimeUnit.SECONDS.toMillis(getLeapSecond(gpsDateTime));
return ZonedDateTime.ofInstant(Instant.ofEpochMilli(gpsMillis), ZoneId.of("UTC"));
public DateTime getUtcDateTime() {
DateTime gpsDateTime = getGpsDateTime();
return new DateTime(
gpsDateTime.getMillis() - TimeUnit.SECONDS.toMillis(getLeapSecond(gpsDateTime)), UTC_ZONE);
}
/**
* @return a ZonedDateTime based on the pure GPS time (without considering leap second).
* @return a DateTime based on the pure GPS time (without considering leap second).
*/
public ZonedDateTime getGpsDateTime() {
long gpsMillis = TimeUnit.NANOSECONDS.toMillis(gpsNanos + GPS_UTC_EPOCH_OFFSET_NANOS);
return ZonedDateTime.ofInstant(Instant.ofEpochMilli(gpsMillis), ZoneId.of("UTC"));
public DateTime getGpsDateTime() {
return new DateTime(TimeUnit.NANOSECONDS.toMillis(gpsNanos
+ GPS_UTC_EPOCH_OFFSET_NANOS), UTC_ZONE);
}
/**
@ -312,4 +303,4 @@ public class GpsTime implements Comparable<GpsTime> {
public int hashCode() {
return Longs.hashCode(getNanosSinceGpsEpoch());
}
}
}
Loading…
Cancel
Save