1   /* Copyright 2002-2024 Thales Alenia Space
2    * Licensed to CS GROUP (CS) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * CS licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *   http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.orekit.models.earth.weather;
18  
19  import java.util.Map;
20  
21  import org.hipparchus.util.MathUtils;
22  
23  /** Grid entry in Global Pressure Temperature models.
24   * @author Luc Maisonobe
25   * @since 12.1
26   */
27  class GridEntry {
28  
29      /** Conversion factor from degrees to mill arcseconds. */
30      public static final int DEG_TO_MAS = 3600000;
31  
32      /** Latitude (radian). */
33      private final double latitude;
34  
35      /** Latitude key (mas). */
36      private final int latKey;
37  
38      /** Longitude (radian). */
39      private final double longitude;
40  
41      /** Longitude key (mas). */
42      private final int lonKey;
43  
44      /** Undulation. */
45      private final double undulation;
46  
47      /** Height correction. */
48      private final double hS;
49  
50      /** Seasonal models. */
51      private Map<SeasonalModelType, SeasonalModel> models;
52  
53      /** Build an entry from its components.
54       * @param latitude latitude (radian)
55       * @param latKey latitude key (mas)
56       * @param longitude longitude (radian)
57       * @param lonKey longitude key (mas)
58       * @param undulation undulation (m)
59       * @param hS height correction
60       * @param models seasonal models
61       */
62      GridEntry(final double latitude, final int latKey, final double longitude, final int lonKey,
63                final double undulation, final double hS, final Map<SeasonalModelType, SeasonalModel> models) {
64  
65          this.latitude     = latitude;
66          this.latKey       = latKey;
67          this.longitude    = longitude;
68          this.lonKey       = lonKey;
69          this.undulation   = undulation;
70          this.hS           = hS;
71          this.models       = models;
72      }
73  
74      /** Build a new entry 360° to the East of instance.
75       * @return new wrapping entry (always same type as instance)
76       */
77      public GridEntry buildWrappedEntry() {
78          return new GridEntry(latitude, latKey,
79                               longitude + MathUtils.TWO_PI,
80                               lonKey + DEG_TO_MAS * 360,
81                               undulation, hS,
82                               models);
83      }
84  
85      /** Get latitude (radian).
86       * @return latitude (radian)
87       */
88      double getLatitude() {
89          return latitude;
90      }
91  
92      /** Get latitude key (mas).
93       * @return latitude key (mas)
94       */
95      int getLatKey() {
96          return latKey;
97      }
98  
99      /** Get longitude (radian).
100      * @return longitude (radian)
101      */
102     double getLongitude() {
103         return longitude;
104     }
105 
106     /** Get longitude key (mas).
107      * @return longitude key (mas)
108      */
109     int getLonKey() {
110         return lonKey;
111     }
112 
113     /** Get undulation.
114      * @return undulation
115      */
116     double getUndulation() {
117         return undulation;
118     }
119 
120     /** Get height correction.
121      * @return height correction
122      */
123     double getHs() {
124         return hS;
125     }
126 
127     /** Get a model.
128      * @param type model type
129      * @return model
130      */
131     SeasonalModel getModel(final SeasonalModelType type) {
132         return models.get(type);
133     }
134 
135 }