Example usage for android.location GnssMeasurement getConstellationType

List of usage examples for android.location GnssMeasurement getConstellationType

Introduction

In this page you can find the example usage for android.location GnssMeasurement getConstellationType.

Prototype

@GnssStatus.ConstellationType
public int getConstellationType() 

Source Link

Document

Gets the constellation type.

Usage

From source file:com.google.android.apps.location.gps.gnsslogger.PlotFragment.java

/**
 *  Updates the CN0 versus Time plot data from a {@link GnssMeasurement}
 *//*from   ww  w. j  a  va2s . c om*/
protected void updateCnoTab(GnssMeasurementsEvent event) {
    long timeInSeconds = TimeUnit.NANOSECONDS.toSeconds(event.getClock().getTimeNanos());
    if (mInitialTimeSeconds < 0) {
        mInitialTimeSeconds = timeInSeconds;
    }

    // Building the texts message in analysis text view
    List<GnssMeasurement> measurements = sortByCarrierToNoiseRatio(new ArrayList<>(event.getMeasurements()));
    SpannableStringBuilder builder = new SpannableStringBuilder();
    double currentAverage = 0;
    if (measurements.size() >= NUMBER_OF_STRONGEST_SATELLITES) {
        mAverageCn0 = (mAverageCn0 * mMeasurementCount
                + (measurements.get(0).getCn0DbHz() + measurements.get(1).getCn0DbHz()
                        + measurements.get(2).getCn0DbHz() + measurements.get(3).getCn0DbHz())
                        / NUMBER_OF_STRONGEST_SATELLITES)
                / (++mMeasurementCount);
        currentAverage = (measurements.get(0).getCn0DbHz() + measurements.get(1).getCn0DbHz()
                + measurements.get(2).getCn0DbHz() + measurements.get(3).getCn0DbHz())
                / NUMBER_OF_STRONGEST_SATELLITES;
    }
    builder.append(getString(R.string.history_average_hint, sDataFormat.format(mAverageCn0) + "\n"));
    builder.append(getString(R.string.current_average_hint, sDataFormat.format(currentAverage) + "\n"));
    for (int i = 0; i < NUMBER_OF_STRONGEST_SATELLITES && i < measurements.size(); i++) {
        int start = builder.length();
        builder.append(mDataSetManager.getConstellationPrefix(measurements.get(i).getConstellationType())
                + measurements.get(i).getSvid() + ": " + sDataFormat.format(measurements.get(i).getCn0DbHz())
                + "\n");
        int end = builder.length();
        builder.setSpan(
                new ForegroundColorSpan(mColorMap.getColor(measurements.get(i).getSvid(),
                        measurements.get(i).getConstellationType())),
                start, end, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
    }
    builder.append(getString(R.string.satellite_number_sum_hint, measurements.size()));
    mAnalysisView.setText(builder);

    // Adding incoming data into Dataset
    mLastTimeReceivedSeconds = timeInSeconds - mInitialTimeSeconds;
    for (GnssMeasurement measurement : measurements) {
        int constellationType = measurement.getConstellationType();
        int svID = measurement.getSvid();
        if (constellationType != GnssStatus.CONSTELLATION_UNKNOWN) {
            mDataSetManager.addValue(CN0_TAB, constellationType, svID, mLastTimeReceivedSeconds,
                    measurement.getCn0DbHz());
        }
    }

    mDataSetManager.fillInDiscontinuity(CN0_TAB, mLastTimeReceivedSeconds);

    // Checks if the plot has reached the end of frame and resize
    if (mLastTimeReceivedSeconds > mCurrentRenderer.getXAxisMax()) {
        mCurrentRenderer.setXAxisMax(mLastTimeReceivedSeconds);
        mCurrentRenderer.setXAxisMin(mLastTimeReceivedSeconds - TIME_INTERVAL_SECONDS);
    }

    mChartView.invalidate();
}

From source file:com.google.android.apps.location.gps.gnsslogger.FileLogger.java

private void writeGnssMeasurementToFile(GnssClock clock, GnssMeasurement measurement) throws IOException {
    String clockStream = String.format("Raw,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s", SystemClock.elapsedRealtime(),
            clock.getTimeNanos(), clock.hasLeapSecond() ? clock.getLeapSecond() : "",
            clock.hasTimeUncertaintyNanos() ? clock.getTimeUncertaintyNanos() : "", clock.getFullBiasNanos(),
            clock.hasBiasNanos() ? clock.getBiasNanos() : "",
            clock.hasBiasUncertaintyNanos() ? clock.getBiasUncertaintyNanos() : "",
            clock.hasDriftNanosPerSecond() ? clock.getDriftNanosPerSecond() : "",
            clock.hasDriftUncertaintyNanosPerSecond() ? clock.getDriftUncertaintyNanosPerSecond() : "",
            clock.getHardwareClockDiscontinuityCount() + ",");
    mFileWriter.write(clockStream);//from w  w  w  .  j av a  2 s .  c  o  m

    String measurementStream = String.format("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s",
            measurement.getSvid(), measurement.getTimeOffsetNanos(), measurement.getState(),
            measurement.getReceivedSvTimeNanos(), measurement.getReceivedSvTimeUncertaintyNanos(),
            measurement.getCn0DbHz(), measurement.getPseudorangeRateMetersPerSecond(),
            measurement.getPseudorangeRateUncertaintyMetersPerSecond(),
            measurement.getAccumulatedDeltaRangeState(), measurement.getAccumulatedDeltaRangeMeters(),
            measurement.getAccumulatedDeltaRangeUncertaintyMeters(),
            measurement.hasCarrierFrequencyHz() ? measurement.getCarrierFrequencyHz() : "",
            measurement.hasCarrierCycles() ? measurement.getCarrierCycles() : "",
            measurement.hasCarrierPhase() ? measurement.getCarrierPhase() : "",
            measurement.hasCarrierPhaseUncertainty() ? measurement.getCarrierPhaseUncertainty() : "",
            measurement.getMultipathIndicator(), measurement.hasSnrInDb() ? measurement.getSnrInDb() : "",
            measurement.getConstellationType(),
            Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && measurement.hasAutomaticGainControlLevelDb()
                    ? measurement.getAutomaticGainControlLevelDb()
                    : "",
            measurement.hasCarrierFrequencyHz() ? measurement.getCarrierFrequencyHz() : "");
    mFileWriter.write(measurementStream);
    mFileWriter.newLine();
}