1   /* Copyright 2013-2019 CS Systèmes d'Information
2    * Licensed to CS Systèmes d'Information (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.rugged.utils;
18  
19  import org.hipparchus.util.MathUtils;
20  import org.orekit.bodies.GeodeticPoint;
21  
22  /** Geodetic point whose longitude can be selected with respect to the 2π boundary.
23   * @author Luc Maisonobe
24   */
25  public class NormalizedGeodeticPoint extends GeodeticPoint {
26  
27      /** Serializable UID. */
28      private static final long serialVersionUID = 20141016l;
29  
30      /** Normalized longitude. */
31      private final double normalizedLongitude;
32  
33      /**
34       * Build a new instance. The angular coordinates will be normalized
35       * to ensure     that the latitude is between ±π/2 and the longitude
36       * is between lc-π and lc+π.
37       *
38       * @param latitude latitude of the point
39       * @param longitude longitude of the point
40       * @param altitude altitude of the point
41       * @param centralLongitude central longitude lc
42       */
43      public NormalizedGeodeticPoint(final double latitude, final double longitude,
44                                     final double altitude, final double centralLongitude) {
45          super(latitude, longitude, altitude);
46          this.normalizedLongitude = MathUtils.normalizeAngle(longitude, centralLongitude);
47      }
48  
49      /** Get the longitude.
50       * @return longitude, an angular value in the range [lc-π, lc+π],
51       * where l₀ was selected at construction
52       */
53      @Override
54      public double getLongitude() {
55          return normalizedLongitude;
56      }
57  
58      /** {@inheritDoc} */
59      @Override
60      public boolean equals(final Object object) {
61          // we override the method just to make it clear that we INTENTIONALLY
62          // consider normalized point are just similar to regular points
63          return super.equals(object);
64      }
65  
66      /** {@inheritDoc} */
67      @Override
68      public int hashCode() {
69          // we override the method just to make it clear that we INTENTIONALLY
70          // consider normalized point are just similar to regular points
71          return super.hashCode();
72      }
73  
74  }