001 /*
002 * Java GPX Library (jpx-3.1.0).
003 * Copyright (c) 2016-2023 Franz Wilhelmstötter
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 *
017 * Author:
018 * Franz Wilhelmstötter (franz.wilhelmstoetter@gmail.com)
019 */
020 package io.jenetics.jpx.geom;
021
022 import static java.util.Objects.requireNonNull;
023
024 import java.io.Serial;
025 import java.io.Serializable;
026
027 /**
028 * Represents an earth ellipsoid, which is a mathematical figure approximating
029 * the shape of the Earth, used as a reference frame for computations in
030 * geodesy, astronomy and the geosciences. Various different ellipsoids have
031 * been used as approximations.
032 *
033 * @see <a href="https://en.wikipedia.org/wiki/Earth_ellipsoid">Earth ellipsoid</a>
034 * @see Geoid
035 *
036 * @author <a href="mailto:franz.wilhelmstoetter@gmail.com">Franz Wilhelmstötter</a>
037 * @version 1.0
038 * @since 1.0
039 */
040 public final class Ellipsoid implements Serializable {
041
042 @Serial
043 private static final long serialVersionUID = 1L;
044
045 /**
046 * The ellipsoid of the <em>World Geodetic System: WGS 84</em>
047 *
048 * @see <a href="https://en.wikipedia.org/wiki/World_Geodetic_System#A_new_World_Geodetic_System:_WGS_84">
049 * WGS-84</a>
050 */
051 public static final Ellipsoid WGS84 = of(
052 "WGS-84",
053 6_378_137,
054 6_356_752.314245,
055 298.257223563
056 );
057
058 /**
059 * The ellipsoid of the <em>International Earth Rotation and Reference
060 * Systems Service (1989)</em>
061 *
062 * @see <a href="https://en.wikipedia.org/wiki/IERS">IERS-89</a>
063 */
064 public static final Ellipsoid IERS_1989 = of(
065 "IERS-1989",
066 6_378_136,
067 6_356_751.302,
068 298.257
069 );
070
071 /**
072 * The ellipsoid of the <em>International Earth Rotation and Reference
073 * Systems Service (2003)</em>
074 *
075 * @see <a href="https://en.wikipedia.org/wiki/IERS">IERS-89</a>
076 */
077 public static final Ellipsoid IERS_2003 = of(
078 "IERS-2003",
079 6_378_136.6,
080 6_356_751.9,
081 298.25642
082 );
083
084 /**
085 * The default ellipsoid: WGSC-84
086 */
087 public static final Ellipsoid DEFAULT = WGS84;
088
089 private final String _name;
090 private final double _a;
091 private final double _b;
092 private final double _f;
093
094 /**
095 * Create a new earth ellipsoid with the given parameters.
096 *
097 * @param name the name of the earth ellipsoid model
098 * @param a the equatorial radius, in meter
099 * @param b the polar radius, in meter
100 * @param f the inverse flattening
101 * @throws NullPointerException if the given {@code name} is {@code null}
102 */
103 private Ellipsoid(
104 final String name,
105 final double a,
106 final double b,
107 final double f
108 ) {
109 _name = requireNonNull(name);
110 _a = a;
111 _b = b;
112 _f = f;
113 }
114
115 /**
116 * Return the name of the earth ellipsoid model.
117 *
118 * @return the name of the earth ellipsoid model
119 */
120 public String getName() {
121 return _name;
122 }
123
124 /**
125 * Return the equatorial radius, in meter.
126 *
127 * @return the equatorial radius, in meter
128 */
129 public double A() {
130 return _a;
131 }
132
133 /**
134 * Return the polar radius, in meter.
135 *
136 * @return the polar radius, in meter
137 */
138 public double B() {
139 return _b;
140 }
141
142 /**
143 * Return the inverse flattening.
144 *
145 * @return the inverse flattening
146 */
147 public double F() {
148 return _f;
149 }
150
151 /**
152 * Create a new earth ellipsoid with the given parameters.
153 *
154 * @param name the name of the earth ellipsoid model
155 * @param a the equatorial radius, in meter
156 * @param b the polar radius, in meter
157 * @param f the inverse flattening
158 * @return a new earth ellipsoid with the given parameters
159 */
160 public static Ellipsoid of(
161 final String name,
162 final double a,
163 final double b,
164 final double f
165 ) {
166 return new Ellipsoid(name, a, b, f);
167 }
168
169 }
|