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.adjustment.measurements;
18  
19  import java.util.Collections;
20  import java.util.LinkedHashMap;
21  import java.util.Map;
22  import java.util.Set;
23  
24  import org.orekit.rugged.linesensor.SensorPixel;
25  
26  /** Container for mapping sensor pixels with sensor pixels or ground points.
27   * @author Lucie Labat-Allee
28   * @author Guylaine Prat
29   * @since 2.0
30   */
31  public class SensorMapping<T> {
32  
33      /** Default name for Rugged. */
34      private static final String RUGGED = "Rugged";
35  
36      /** Name of the sensor to which mapping applies. */
37      private final String sensorName;
38  
39      /** Name of the Rugged to which mapping applies. */
40      private final String ruggedName;
41  
42      /** Mapping from sensor to other (sensor or ground). */
43      private final Map<SensorPixel, T> mapping;
44  
45  
46      /** Build a new instance (with default Rugged name).
47       * @param sensorName name of the sensor to which mapping applies
48       */
49      public SensorMapping(final String sensorName) {
50          this(sensorName, RUGGED);
51      }
52  
53      /** Build a new instance with a specific Rugged name.
54       * @param sensorName name of the sensor to which mapping applies
55       * @param ruggedName name of the Rugged to which mapping applies
56       */
57      public SensorMapping(final String sensorName, final String ruggedName) {
58  
59          this.sensorName     = sensorName;
60          this.ruggedName     = ruggedName;
61          this.mapping = new LinkedHashMap<SensorPixel, T>();
62      }
63  
64      /** Get the name of the sensor to which mapping applies.
65       * @return name of the sensor to which mapping applies
66       */
67      public String getSensorName() {
68          return sensorName;
69      }
70  
71      /** Get the name of the Rugged to which mapping applies.
72       * @return name of the Rugged to which mapping applies
73       */
74      public String getRuggedName() {
75          return ruggedName;
76      }
77  
78      /** Add a mapping between a sensor pixel and another point (sensor pixel or ground point).
79       * @param pixel sensor pixel
80       * @param point sensor pixel or ground point corresponding to the sensor pixel
81       */
82      public void addMapping(final SensorPixel pixel, final T point) {
83          mapping.put(pixel, point);
84      }
85  
86      /** Get all the mapping entries.
87       * @return an unmodifiable view of all mapping entries
88       */
89      public Set<Map.Entry<SensorPixel, T>> getMapping() {
90          return Collections.unmodifiableSet(mapping.entrySet());
91      }
92  }