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
19 import org.orekit.annotation.DefaultDataContext;
20 import org.orekit.data.DataContext;
21
22 /** Factory for different {@link GeoMagneticField} models.
23 * <p>
24 * This is a utility class, so its constructor is private.
25 * </p>
26 * @author Thomas Neidhart
27 * @author Evan Ward
28 * @see GeoMagneticFields
29 * @see LazyLoadedGeoMagneticFields
30 * @see DataContext#getGeoMagneticFields()
31 */
32 public class GeoMagneticFieldFactory {
33
34 /** The currently supported geomagnetic field models. */
35 public enum FieldModel {
36 /** World Magnetic Model. */
37 WMM,
38 /** International Geomagnetic Reference Field. */
39 IGRF
40 }
41
42 /** Private constructor.
43 * <p>
44 * This class is a utility class, it should neither have a public nor a
45 * default constructor. This private constructor prevents the compiler from
46 * generating one automatically.
47 * </p>
48 */
49 private GeoMagneticFieldFactory() {
50 }
51
52 /**
53 * Get the instance of {@link GeoMagneticFields} that is called by methods in this
54 * class.
55 *
56 * @return the geomagnetic fields used by this factory.
57 * @since 10.1
58 */
59 @DefaultDataContext
60 public static LazyLoadedGeoMagneticFields getGeoMagneticFields() {
61 return DataContext.getDefault().getGeoMagneticFields();
62 }
63
64 /** Get the {@link GeoMagneticField} for the given model type and year.
65 * @param type the field model type
66 * @param year the decimal year
67 * @return a {@link GeoMagneticField} for the given year and model
68 * @see GeoMagneticField#getDecimalYear(int, int, int)
69 */
70 @DefaultDataContext
71 public static GeoMagneticField getField(final FieldModel type, final double year) {
72 return getGeoMagneticFields().getField(type, year);
73 }
74
75 /** Get the IGRF model for the given year.
76 * @param year the decimal year
77 * @return a {@link GeoMagneticField} for the given year
78 * @see GeoMagneticField#getDecimalYear(int, int, int)
79 */
80 @DefaultDataContext
81 public static GeoMagneticField getIGRF(final double year) {
82 return getGeoMagneticFields().getIGRF(year);
83 }
84
85 /** Get the WMM model for the given year.
86 * @param year the decimal year
87 * @return a {@link GeoMagneticField} for the given year
88 * @see GeoMagneticField#getDecimalYear(int, int, int)
89 */
90 @DefaultDataContext
91 public static GeoMagneticField getWMM(final double year) {
92 return getGeoMagneticFields().getWMM(year);
93 }
94
95 }