All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.jenetics.jpx.geom.Ellipsoid Maven / Gradle / Ivy

There is a newer version: 3.2.0
Show newest version
/*
 * Java GPX Library (jpx-1.1.2).
 * Copyright (c) 2017-2017 Franz Wilhelmstötter
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Author:
 *    Franz Wilhelmstötter ([email protected])
 */
package io.jenetics.jpx.geom;

import static java.util.Objects.requireNonNull;

import java.io.Serializable;

/**
 * Represents an earth ellipsoid, which is a mathematical figure approximating
 * the shape of the Earth, used as a reference frame for computations in
 * geodesy, astronomy and the geosciences. Various different ellipsoids have
 * been used as approximations.
 *
 * @see Earth ellipsoid
 * @see Geoid
 *
 * @author Franz Wilhelmstötter
 * @version 1.0
 * @since 1.0
 */
public final class Ellipsoid implements Serializable {

	private static final long serialVersionUID = 1L;

	/**
	 * The ellipsoid of the World Geodetic System: WGS 84
	 *
	 * @see 
	 *     WGS-84
	 */
	public static final Ellipsoid WGS84 = of(
		"WGS-84",
		6_378_137,
		6_356_752.314245,
		298.257223563
	);

	/**
	 * The ellipsoid of the International Earth Rotation and Reference
	 * Systems Service (1989)
	 *
	 * @see IERS-89
	 */
	public static final Ellipsoid IERS_1989 = of(
		"IERS-1989",
		6_378_136,
		6_356_751.302,
		298.257
	);

	/**
	 * The ellipsoid of the International Earth Rotation and Reference
	 * Systems Service (2003)
	 *
	 * @see IERS-89
	 */
	public static final Ellipsoid IERS_2003 = of(
		"IERS-2003",
		6_378_136.6,
		6_356_751.9,
		298.25642
	);

	/**
	 * The default ellipsoid: WGSC-84
	 */
	public static final Ellipsoid DEFAULT = WGS84;

	private final String _name;
	private final double _a;
	private final double _b;
	private final double _f;

	/**
	 * Create a new earth ellipsoid with the given parameters.
	 *
	 * @param name the name of the earth ellipsoid model
	 * @param a the equatorial radius, in meter
	 * @param b the polar radius, in meter
	 * @param f the inverse flattening
	 * @throws NullPointerException if the given {@code name} is {@code null}
	 */
	private Ellipsoid(
		final String name,
		final double a,
		final double b,
		final double f
	) {
		_name = requireNonNull(name);
		_a = a;
		_b = b;
		_f = f;
	}

	/**
	 * Return the name of the earth ellipsoid model.
	 *
	 * @return the name of the earth ellipsoid model
	 */
	public String getName() {
		return _name;
	}

	/**
	 * Return the equatorial radius, in meter.
	 *
	 * @return the equatorial radius, in meter
	 */
	public double A() {
		return _a;
	}

	/**
	 * Return the polar radius, in meter.
	 *
	 * @return the polar radius, in meter
	 */
	public double B() {
		return _b;
	}

	/**
	 * Return the inverse flattening.
	 *
	 * @return the inverse flattening
	 */
	public double F() {
		return _f;
	}

	/**
	 * Create a new earth ellipsoid with the given parameters.
	 *
	 * @param name the name of the earth ellipsoid model
	 * @param a the equatorial radius, in meter
	 * @param b the polar radius, in meter
	 * @param f the inverse flattening
	 * @return  a new earth ellipsoid with the given parameters
	 */
	public static Ellipsoid of(
		final String name,
		final double a,
		final double b,
		final double f
	) {
		return new Ellipsoid(name, a, b, f);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy