• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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.FlaggedApi;
20 import android.annotation.FloatRange;
21 import android.annotation.NonNull;
22 import android.annotation.SystemApi;
23 import android.location.flags.Flags;
24 import android.os.Parcel;
25 import android.os.Parcelable;
26 
27 import com.android.internal.util.Preconditions;
28 
29 /**
30  * A class contains Klobuchar ionospheric model coefficients used by GPS, BDS, QZSS.
31  *
32  * <p>This is defined in IS-GPS-200 section 20.3.3.5.1.7.
33  *
34  * @hide
35  */
36 @FlaggedApi(Flags.FLAG_GNSS_ASSISTANCE_INTERFACE)
37 @SystemApi
38 public final class KlobucharIonosphericModel implements Parcelable {
39     /** Alpha0 coefficientin seconds. */
40     double mAlpha0;
41     /** Alpha1 coefficient in seconds per semi-circle. */
42     double mAlpha1;
43     /** Alpha2 coefficient in seconds per semi-circle squared. */
44     double mAlpha2;
45     /** Alpha3 coefficient in seconds per semi-circle cubed. */
46     double mAlpha3;
47     /** Beta0 coefficient in seconds. */
48     double mBeta0;
49     /** Beta1 coefficient in seconds per semi-circle. */
50     double mBeta1;
51     /** Beta2 coefficient in seconds per semi-circle squared. */
52     double mBeta2;
53     /** Beta3 coefficient in seconds per semi-circle cubed. */
54     double mBeta3;
55 
KlobucharIonosphericModel(Builder builder)56     private KlobucharIonosphericModel(Builder builder) {
57         Preconditions.checkArgumentInRange(builder.mAlpha0, -1.193e-7f, 1.193e-7f, "Alpha0");
58         Preconditions.checkArgumentInRange(builder.mAlpha1, -9.54e-7f, 9.54e-7f, "Alpha1");
59         Preconditions.checkArgumentInRange(builder.mAlpha2, -7.63e-6f, 7.63e-6f, "Alpha2");
60         Preconditions.checkArgumentInRange(builder.mAlpha3, -7.63e-6f, 7.63e-6f, "Alpha3");
61         Preconditions.checkArgumentInRange(builder.mBeta0, -262144.0f, 262144.0f, "Beta0");
62         Preconditions.checkArgumentInRange(builder.mBeta1, -2097152.0f, 2097152.0f, "Beta1");
63         Preconditions.checkArgumentInRange(builder.mBeta2, -8388608.0f, 8388608.0f, "Beta2");
64         Preconditions.checkArgumentInRange(builder.mBeta3, -8388608.0f, 8388608.0f, "Beta3");
65         mAlpha0 = builder.mAlpha0;
66         mAlpha1 = builder.mAlpha1;
67         mAlpha2 = builder.mAlpha2;
68         mAlpha3 = builder.mAlpha3;
69         mBeta0 = builder.mBeta0;
70         mBeta1 = builder.mBeta1;
71         mBeta2 = builder.mBeta2;
72         mBeta3 = builder.mBeta3;
73     }
74 
75     /** Returns the alpha0 coefficient in seconds. */
76     @FloatRange(from = -1.193e-7f, to = 1.193e-7f)
getAlpha0()77     public double getAlpha0() {
78         return mAlpha0;
79     }
80 
81     /** Returns the alpha1 coefficient in seconds per semi-circle. */
82     @FloatRange(from = -9.54e-7f, to = 9.54e-7f)
getAlpha1()83     public double getAlpha1() {
84         return mAlpha1;
85     }
86 
87     /** Returns the alpha2 coefficient in seconds per semi-circle squared. */
88     @FloatRange(from = -7.63e-6f, to = 7.63e-6f)
getAlpha2()89     public double getAlpha2() {
90         return mAlpha2;
91     }
92 
93     /** Returns the alpha3 coefficient in seconds per semi-circle cubed. */
94     @FloatRange(from = -7.63e-6f, to = 7.63e-6f)
getAlpha3()95     public double getAlpha3() {
96         return mAlpha3;
97     }
98 
99     /** Returns the beta0 coefficient in seconds. */
100     @FloatRange(from = -262144.0f, to = 262144.0f)
getBeta0()101     public double getBeta0() {
102         return mBeta0;
103     }
104 
105     /** Returns the beta1 coefficient in seconds per semi-circle. */
106     @FloatRange(from = -2097152.0f, to = 2097152.0f)
getBeta1()107     public double getBeta1() {
108         return mBeta1;
109     }
110 
111     /** Returns the beta2 coefficient in seconds per semi-circle squared. */
112     @FloatRange(from = -8388608.0f, to = 8388608.0f)
getBeta2()113     public double getBeta2() {
114         return mBeta2;
115     }
116 
117     /** Returns the beta3 coefficient in seconds per semi-circle cubed. */
118     @FloatRange(from = -8388608.0f, to = 8388608.0f)
getBeta3()119     public double getBeta3() {
120         return mBeta3;
121     }
122 
123     public static final @NonNull Creator<KlobucharIonosphericModel> CREATOR =
124             new Creator<KlobucharIonosphericModel>() {
125                 @Override
126                 @NonNull
127                 public KlobucharIonosphericModel createFromParcel(Parcel in) {
128                     return new KlobucharIonosphericModel.Builder()
129                             .setAlpha0(in.readDouble())
130                             .setAlpha1(in.readDouble())
131                             .setAlpha2(in.readDouble())
132                             .setAlpha3(in.readDouble())
133                             .setBeta0(in.readDouble())
134                             .setBeta1(in.readDouble())
135                             .setBeta2(in.readDouble())
136                             .setBeta3(in.readDouble())
137                             .build();
138                 }
139                 @Override
140                 public KlobucharIonosphericModel[] newArray(int size) {
141                     return new KlobucharIonosphericModel[size];
142                 }
143             };
144 
145 
146     @Override
describeContents()147     public int describeContents() {
148         return 0;
149     }
150 
151     @Override
writeToParcel(@onNull Parcel parcel, int flags)152     public void writeToParcel(@NonNull Parcel parcel, int flags) {
153         parcel.writeDouble(mAlpha0);
154         parcel.writeDouble(mAlpha1);
155         parcel.writeDouble(mAlpha2);
156         parcel.writeDouble(mAlpha3);
157         parcel.writeDouble(mBeta0);
158         parcel.writeDouble(mBeta1);
159         parcel.writeDouble(mBeta2);
160         parcel.writeDouble(mBeta3);
161     }
162 
163     @Override
164     @NonNull
toString()165     public String toString() {
166         StringBuilder builder = new StringBuilder("KlobucharIonosphericModel[");
167         builder.append("alpha0 = ").append(mAlpha0);
168         builder.append(", alpha1 = ").append(mAlpha1);
169         builder.append(", alpha2 = ").append(mAlpha2);
170         builder.append(", alpha3 = ").append(mAlpha3);
171         builder.append(", beta0 = ").append(mBeta0);
172         builder.append(", beta1 = ").append(mBeta1);
173         builder.append(", beta2 = ").append(mBeta2);
174         builder.append(", beta3 = ").append(mBeta3);
175         builder.append("]");
176         return builder.toString();
177     }
178 
179     /** Builder for {@link KlobucharIonosphericModel} */
180     public static final class Builder {
181         private double mAlpha0;
182         private double mAlpha1;
183         private double mAlpha2;
184         private double mAlpha3;
185         private double mBeta0;
186         private double mBeta1;
187         private double mBeta2;
188         private double mBeta3;
189 
190         /** Sets the alpha0 coefficient in seconds. */
191         @NonNull
setAlpha0(@loatRangefrom = -1.193e-7f, to = 1.193e-7f) double alpha0)192         public Builder setAlpha0(@FloatRange(from = -1.193e-7f, to = 1.193e-7f) double alpha0) {
193             mAlpha0 = alpha0;
194             return this;
195         }
196 
197         /** Sets the alpha1 coefficient in seconds per semi-circle. */
198         @NonNull
setAlpha1(@loatRangefrom = -9.54e-7f, to = 9.54e-7f) double alpha1)199         public Builder setAlpha1(@FloatRange(from = -9.54e-7f, to = 9.54e-7f) double alpha1) {
200             mAlpha1 = alpha1;
201             return this;
202         }
203 
204         /** Sets the alpha2 coefficient in seconds per semi-circle squared. */
205         @NonNull
setAlpha2(@loatRangefrom = -7.63e-6f, to = 7.63e-6f) double alpha2)206         public Builder setAlpha2(@FloatRange(from = -7.63e-6f, to = 7.63e-6f) double alpha2) {
207             mAlpha2 = alpha2;
208             return this;
209         }
210 
211         /** Sets the alpha3 coefficient in seconds per semi-circle cubed. */
212         @NonNull
setAlpha3(@loatRangefrom = -7.63e-6f, to = 7.63e-6f) double alpha3)213         public Builder setAlpha3(@FloatRange(from = -7.63e-6f, to = 7.63e-6f) double alpha3) {
214             mAlpha3 = alpha3;
215             return this;
216         }
217 
218         /** Sets the beta0 coefficient in seconds. */
219         @NonNull
setBeta0(@loatRangefrom = -262144.0f, to = 262144.0f) double beta0)220         public Builder setBeta0(@FloatRange(from = -262144.0f, to = 262144.0f) double beta0) {
221             mBeta0 = beta0;
222             return this;
223         }
224 
225         /** Sets the beta1 coefficient in seconds per semi-circle. */
226         @NonNull
setBeta1(@loatRangefrom = -2097152.0f, to = 2097152.0f) double beta1)227         public Builder setBeta1(@FloatRange(from = -2097152.0f, to = 2097152.0f) double beta1) {
228             mBeta1 = beta1;
229             return this;
230         }
231 
232         /** Sets the beta2 coefficient in seconds per semi-circle squared. */
233         @NonNull
setBeta2(@loatRangefrom = -8388608.0f, to = 8388608.0f) double beta2)234         public Builder setBeta2(@FloatRange(from = -8388608.0f, to = 8388608.0f) double beta2) {
235             mBeta2 = beta2;
236             return this;
237         }
238 
239         /** Sets the beta3 coefficient in seconds per semi-circle cubed. */
240         @NonNull
setBeta3(@loatRangefrom = -8388608.0f, to = 8388608.0f) double beta3)241         public Builder setBeta3(@FloatRange(from = -8388608.0f, to = 8388608.0f) double beta3) {
242             mBeta3 = beta3;
243             return this;
244         }
245 
246         /** Builds a {@link KlobucharIonosphericModel} instance as specified by this builder. */
247         @NonNull
build()248         public KlobucharIonosphericModel build() {
249             return new KlobucharIonosphericModel(this);
250         }
251     }
252 }
253