gomo | 226b7b7 | 2018-12-12 16:49:39 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.location; |
| 18 | |
| 19 | import android.annotation.SystemApi; |
| 20 | import android.os.Parcel; |
| 21 | import android.os.Parcelable; |
| 22 | |
| 23 | /** |
| 24 | * Holds the characteristics of the reflecting plane that a satellite signal has bounced from. |
| 25 | * |
| 26 | * @hide |
| 27 | */ |
| 28 | @SystemApi |
| 29 | public final class GnssReflectingPlane implements Parcelable { |
| 30 | |
| 31 | /** Represents latitude in degrees of the reflecting plane */ |
| 32 | private double mLatitudeDegrees; |
| 33 | /** Represents longitude in degrees of the reflecting plane. */ |
| 34 | private double mLongitudeDegrees; |
| 35 | /** |
| 36 | * Represents altitude in meters above the WGS 84 reference ellipsoid of the reflection point in |
| 37 | * the plane |
| 38 | */ |
| 39 | private double mAltitudeMeters; |
| 40 | |
| 41 | /** Represents azimuth clockwise from north of the reflecting plane in degrees. */ |
| 42 | private double mAzimuthDegrees; |
| 43 | |
| 44 | private GnssReflectingPlane(Builder builder) { |
| 45 | mLatitudeDegrees = builder.mLatitudeDegrees; |
| 46 | mLongitudeDegrees = builder.mLongitudeDegrees; |
| 47 | mAltitudeMeters = builder.mAltitudeMeters; |
| 48 | mAzimuthDegrees = builder.mAzimuthDegrees; |
| 49 | } |
| 50 | |
| 51 | /** Gets the latitude in degrees of the reflecting plane. */ |
| 52 | public double getLatitudeDegrees() { |
| 53 | return mLatitudeDegrees; |
| 54 | } |
| 55 | |
| 56 | /** Gets the longitude in degrees of the reflecting plane. */ |
| 57 | public double getLongitudeDegrees() { |
| 58 | return mLongitudeDegrees; |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Gets the altitude in meters above the WGS 84 reference ellipsoid of the reflecting point |
| 63 | * within the plane |
| 64 | */ |
| 65 | public double getAltitudeMeters() { |
| 66 | return mAltitudeMeters; |
| 67 | } |
| 68 | |
| 69 | /** Gets the azimuth clockwise from north of the reflecting plane in degrees. */ |
| 70 | public double getAzimuthDegrees() { |
| 71 | return mAzimuthDegrees; |
| 72 | } |
| 73 | |
| 74 | @Override |
| 75 | public int describeContents() { |
| 76 | return 0; |
| 77 | } |
| 78 | |
| 79 | public static final Creator<GnssReflectingPlane> CREATOR = |
| 80 | new Creator<GnssReflectingPlane>() { |
| 81 | @Override |
| 82 | public GnssReflectingPlane createFromParcel(Parcel parcel) { |
| 83 | GnssReflectingPlane reflectingPlane = |
| 84 | new Builder() |
| 85 | .setLatitudeDegrees(parcel.readDouble()) |
| 86 | .setLongitudeDegrees(parcel.readDouble()) |
| 87 | .setAltitudeMeters(parcel.readDouble()) |
| 88 | .setAzimuthDegrees(parcel.readDouble()) |
| 89 | .build(); |
| 90 | return reflectingPlane; |
| 91 | } |
| 92 | |
| 93 | @Override |
| 94 | public GnssReflectingPlane[] newArray(int i) { |
| 95 | return new GnssReflectingPlane[i]; |
| 96 | } |
| 97 | }; |
| 98 | |
| 99 | @Override |
| 100 | public String toString() { |
| 101 | final String format = " %-29s = %s\n"; |
| 102 | StringBuilder builder = new StringBuilder("ReflectingPlane:\n"); |
| 103 | builder.append(String.format(format, "LatitudeDegrees = ", mLatitudeDegrees)); |
| 104 | builder.append(String.format(format, "LongitudeDegrees = ", mLongitudeDegrees)); |
| 105 | builder.append(String.format(format, "AltitudeMeters = ", mAltitudeMeters)); |
| 106 | builder.append(String.format(format, "AzimuthDegrees = ", mAzimuthDegrees)); |
| 107 | return builder.toString(); |
| 108 | } |
| 109 | |
| 110 | @Override |
| 111 | public void writeToParcel(Parcel parcel, int flags) { |
| 112 | parcel.writeDouble(mLatitudeDegrees); |
| 113 | parcel.writeDouble(mLongitudeDegrees); |
| 114 | parcel.writeDouble(mAltitudeMeters); |
| 115 | parcel.writeDouble(mAzimuthDegrees); |
| 116 | } |
| 117 | |
| 118 | /** Builder for {@link GnssReflectingPlane} */ |
gomo | 3796ab1 | 2019-02-20 23:21:11 -0800 | [diff] [blame] | 119 | public static final class Builder { |
gomo | 226b7b7 | 2018-12-12 16:49:39 -0800 | [diff] [blame] | 120 | /** For documentation, see corresponding fields in {@link GnssReflectingPlane}. */ |
| 121 | private double mLatitudeDegrees; |
| 122 | |
| 123 | private double mLongitudeDegrees; |
| 124 | private double mAltitudeMeters; |
| 125 | private double mAzimuthDegrees; |
| 126 | |
| 127 | /** Sets the latitude in degrees of the reflecting plane. */ |
| 128 | public Builder setLatitudeDegrees(double latitudeDegrees) { |
| 129 | mLatitudeDegrees = latitudeDegrees; |
| 130 | return this; |
| 131 | } |
| 132 | |
| 133 | /** Sets the longitude in degrees of the reflecting plane. */ |
| 134 | public Builder setLongitudeDegrees(double longitudeDegrees) { |
| 135 | mLongitudeDegrees = longitudeDegrees; |
| 136 | return this; |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * Sets the altitude in meters above the WGS 84 reference ellipsoid of the reflecting point |
| 141 | * within the plane |
| 142 | */ |
| 143 | public Builder setAltitudeMeters(double altitudeMeters) { |
| 144 | mAltitudeMeters = altitudeMeters; |
| 145 | return this; |
| 146 | } |
| 147 | |
| 148 | /** Sets the azimuth clockwise from north of the reflecting plane in degrees. */ |
| 149 | public Builder setAzimuthDegrees(double azimuthDegrees) { |
| 150 | mAzimuthDegrees = azimuthDegrees; |
| 151 | return this; |
| 152 | } |
| 153 | |
| 154 | /** Builds a {@link GnssReflectingPlane} object as specified by this builder. */ |
| 155 | public GnssReflectingPlane build() { |
| 156 | return new GnssReflectingPlane(this); |
| 157 | } |
| 158 | } |
| 159 | } |