SensorMapping.java

  1. /* Copyright 2013-2022 CS GROUP
  2.  * Licensed to CS GROUP (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. import java.util.Collections;
  19. import java.util.LinkedHashMap;
  20. import java.util.Map;
  21. import java.util.Set;

  22. import org.orekit.rugged.linesensor.SensorPixel;

  23. /** Container for mapping sensor pixels with sensor pixels or ground points.
  24.  * @author Lucie Labat-Allee
  25.  * @author Guylaine Prat
  26.  * @since 2.0
  27.  */
  28. public class SensorMapping<T> {

  29.     /** Default name for Rugged. */
  30.     private static final String RUGGED = "Rugged";

  31.     /** Name of the sensor to which mapping applies. */
  32.     private final String sensorName;

  33.     /** Name of the Rugged to which mapping applies. */
  34.     private final String ruggedName;

  35.     /** Mapping from sensor to other (sensor or ground). */
  36.     private final Map<SensorPixel, T> mapping;


  37.     /** Build a new instance (with default Rugged name).
  38.      * @param sensorName name of the sensor to which mapping applies
  39.      */
  40.     public SensorMapping(final String sensorName) {
  41.         this(sensorName, RUGGED);
  42.     }

  43.     /** Build a new instance with a specific Rugged name.
  44.      * @param sensorName name of the sensor to which mapping applies
  45.      * @param ruggedName name of the Rugged to which mapping applies
  46.      */
  47.     public SensorMapping(final String sensorName, final String ruggedName) {

  48.         this.sensorName     = sensorName;
  49.         this.ruggedName     = ruggedName;
  50.         this.mapping = new LinkedHashMap<SensorPixel, T>();
  51.     }

  52.     /** Get the name of the sensor to which mapping applies.
  53.      * @return name of the sensor to which mapping applies
  54.      */
  55.     public String getSensorName() {
  56.         return sensorName;
  57.     }

  58.     /** Get the name of the Rugged to which mapping applies.
  59.      * @return name of the Rugged to which mapping applies
  60.      */
  61.     public String getRuggedName() {
  62.         return ruggedName;
  63.     }

  64.     /** Add a mapping between a sensor pixel and another point (sensor pixel or ground point).
  65.      * @param pixel sensor pixel
  66.      * @param point sensor pixel or ground point corresponding to the sensor pixel
  67.      */
  68.     public void addMapping(final SensorPixel pixel, final T point) {
  69.         mapping.put(pixel, point);
  70.     }

  71.     /** Get all the mapping entries.
  72.      * @return an unmodifiable view of all mapping entries
  73.      */
  74.     public Set<Map.Entry<SensorPixel, T>> getMapping() {
  75.         return Collections.unmodifiableSet(mapping.entrySet());
  76.     }
  77. }