GeoMagneticFieldFactory.java

  1. /* Copyright 2011-2012 Space Applications Services
  2.  * Licensed to CS Communication & Systèmes (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;

  18. import org.orekit.annotation.DefaultDataContext;
  19. import org.orekit.data.DataContext;

  20. /** Factory for different {@link GeoMagneticField} models.
  21.  * <p>
  22.  * This is a utility class, so its constructor is private.
  23.  * </p>
  24.  * @author Thomas Neidhart
  25.  * @author Evan Ward
  26.  * @see GeoMagneticFields
  27.  * @see LazyLoadedGeoMagneticFields
  28.  * @see DataContext#getGeoMagneticFields()
  29.  */
  30. public class GeoMagneticFieldFactory {

  31.     /** The currently supported geomagnetic field models. */
  32.     public enum FieldModel {
  33.         /** World Magnetic Model. */
  34.         WMM,
  35.         /** International Geomagnetic Reference Field. */
  36.         IGRF
  37.     }

  38.     /** Private constructor.
  39.      * <p>
  40.      * This class is a utility class, it should neither have a public nor a
  41.      * default constructor. This private constructor prevents the compiler from
  42.      * generating one automatically.
  43.      * </p>
  44.      */
  45.     private GeoMagneticFieldFactory() {
  46.     }

  47.     /**
  48.      * Get the instance of {@link GeoMagneticFields} that is called by methods in this
  49.      * class.
  50.      *
  51.      * @return the geomagnetic fields used by this factory.
  52.      * @since 10.1
  53.      */
  54.     @DefaultDataContext
  55.     public static LazyLoadedGeoMagneticFields getGeoMagneticFields() {
  56.         return DataContext.getDefault().getGeoMagneticFields();
  57.     }

  58.     /** Get the {@link GeoMagneticField} for the given model type and year.
  59.      * @param type the field model type
  60.      * @param year the decimal year
  61.      * @return a {@link GeoMagneticField} for the given year and model
  62.      * @see GeoMagneticField#getDecimalYear(int, int, int)
  63.      */
  64.     @DefaultDataContext
  65.     public static GeoMagneticField getField(final FieldModel type, final double year) {
  66.         return getGeoMagneticFields().getField(type, year);
  67.     }

  68.     /** Get the IGRF model for the given year.
  69.      * @param year the decimal year
  70.      * @return a {@link GeoMagneticField} for the given year
  71.      * @see GeoMagneticField#getDecimalYear(int, int, int)
  72.      */
  73.     @DefaultDataContext
  74.     public static GeoMagneticField getIGRF(final double year) {
  75.         return getGeoMagneticFields().getIGRF(year);
  76.     }

  77.     /** Get the WMM model for the given year.
  78.      * @param year the decimal year
  79.      * @return a {@link GeoMagneticField} for the given year
  80.      * @see GeoMagneticField#getDecimalYear(int, int, int)
  81.      */
  82.     @DefaultDataContext
  83.     public static GeoMagneticField getWMM(final double year) {
  84.         return getGeoMagneticFields().getWMM(year);
  85.     }

  86. }