Example usage for android.location GpsSatellite hasEphemeris

List of usage examples for android.location GpsSatellite hasEphemeris

Introduction

In this page you can find the example usage for android.location GpsSatellite hasEphemeris.

Prototype

public boolean hasEphemeris() 

Source Link

Document

Returns true if the GPS engine has ephemeris data for the satellite.

Usage

From source file:com.esri.cordova.geolocation.utils.JSONHelper.java

/**
 * Converts GpsStatus into JSON./*w w  w  .  jav a  2  s . co  m*/
 * @param gpsStatus Send a GpsStatus whenever the GPS fires
 * @return JSON representation of the satellite data
 */
public static String satelliteDataJSON(GpsStatus gpsStatus) {

    final Calendar calendar = Calendar.getInstance();
    final JSONObject json = new JSONObject();

    try {
        json.put("provider", SATELLITE_PROVIDER);
        json.put("timestamp", calendar.getTimeInMillis());

        if (gpsStatus.getSatellites() != null) {
            int count = 0;
            final int timeToFirstFix = gpsStatus.getTimeToFirstFix();

            for (GpsSatellite sat : gpsStatus.getSatellites()) {
                final JSONObject satelliteInfo = new JSONObject();

                satelliteInfo.put("PRN", sat.getPrn());
                satelliteInfo.put("timeToFirstFix", timeToFirstFix);
                satelliteInfo.put("usedInFix", sat.usedInFix());
                satelliteInfo.put("azimuth", sat.getAzimuth());
                satelliteInfo.put("elevation", sat.getElevation());
                satelliteInfo.put("hasEphemeris", sat.hasEphemeris());
                satelliteInfo.put("hasAlmanac", sat.hasAlmanac());
                satelliteInfo.put("SNR", sat.getSnr());

                json.put(Integer.toString(count), satelliteInfo);

                count++;
            }
        }
    } catch (JSONException exc) {
        logJSONException(exc);
    }

    return json.toString();
}

From source file:com.android.gpstest.GpsStatusFragment.java

private void updateStatus(GpsStatus status) {

    setStarted(true);// ww  w . ja va 2 s  . c o m
    // update the fix time regularly, since it is displaying relative time
    updateFixTime();

    Iterator<GpsSatellite> satellites = status.getSatellites().iterator();

    if (mPrns == null) {
        int length = status.getMaxSatellites();
        mPrns = new int[length];
        mSnrs = new float[length];
        mSvElevations = new float[length];
        mSvAzimuths = new float[length];
    }

    mSvCount = 0;
    mEphemerisMask = 0;
    mAlmanacMask = 0;
    mUsedInFixMask = 0;
    while (satellites.hasNext()) {
        GpsSatellite satellite = satellites.next();
        int prn = satellite.getPrn();
        int prnBit = (1 << (prn - 1));
        mPrns[mSvCount] = prn;
        mSnrs[mSvCount] = satellite.getSnr();
        mSvElevations[mSvCount] = satellite.getElevation();
        mSvAzimuths[mSvCount] = satellite.getAzimuth();
        if (satellite.hasEphemeris()) {
            mEphemerisMask |= prnBit;
        }
        if (satellite.hasAlmanac()) {
            mAlmanacMask |= prnBit;
        }
        if (satellite.usedInFix()) {
            mUsedInFixMask |= prnBit;
        }
        mSvCount++;
    }

    mAdapter.notifyDataSetChanged();
}