1   /* Copyright 2013-2016 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.linesensor;
18  
19  import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
20  import org.orekit.rugged.errors.DumpManager;
21  import org.orekit.rugged.errors.RuggedException;
22  import org.orekit.rugged.los.TimeDependentLOS;
23  import org.orekit.time.AbsoluteDate;
24  
25  /** Line sensor model.
26   * @author Luc Maisonobe
27   */
28  public class LineSensor {
29  
30      /** Name of the sensor. */
31      private final String name;
32  
33      /** Datation model. */
34      private final LineDatation datationModel;
35  
36      /** Sensor position. */
37      private final Vector3D position;
38  
39      /** Pixels lines-of-sight. */
40      private final TimeDependentLOS los;
41  
42      /** Simple constructor.
43       * @param name name of the sensor
44       * @param datationModel datation model
45       * @param position sensor position in spacecraft frame
46       * @param los pixels lines-of-sight in spacecraft frame
47       * @see org.orekit.rugged.los.LOSBuilder
48       */
49      public LineSensor(final String name, final LineDatation datationModel,
50                        final Vector3D position, final TimeDependentLOS los) {
51  
52          this.name          = name;
53          this.datationModel = datationModel;
54          this.position      = position;
55          this.los           = los;
56  
57      }
58  
59      /** Get the name of the sensor.
60       * @return name of the sensor
61       */
62      public String getName() {
63          return name;
64      }
65  
66      /** Get the number of pixels.
67       * @return number of pixels
68       */
69      public int getNbPixels() {
70          return los.getNbPixels();
71      }
72  
73      /** Get the pixel normalized line-of-sight at some date.
74       * @param date current date
75       * @param i pixel index (must be between 0 and {@link #getNbPixels()} - 1
76       * @return pixel normalized line-of-sight
77       * @exception RuggedException if date cannot be handled
78       */
79      public Vector3D getLos(final AbsoluteDate date, final int i)
80          throws RuggedException {
81          final Vector3D l = los.getLOS(i, date);
82          DumpManager.dumpSensorLOS(this, date, i, l);
83          return l;
84      }
85  
86      /** Get the date.
87       * @param lineNumber line number
88       * @return date corresponding to line number
89       * @exception RuggedException if date cannot be handled
90       */
91      public AbsoluteDate getDate(final double lineNumber)
92          throws RuggedException {
93          final AbsoluteDate date = datationModel.getDate(lineNumber);
94          DumpManager.dumpSensorDatation(this, lineNumber, date);
95          return date;
96      }
97  
98      /** Get the line number.
99       * @param date date
100      * @return line number corresponding to date
101      * @exception RuggedException if date cannot be handled
102      */
103     public double getLine(final AbsoluteDate date)
104         throws RuggedException {
105         final double lineNumber = datationModel.getLine(date);
106         DumpManager.dumpSensorDatation(this, lineNumber, date);
107         return lineNumber;
108     }
109 
110     /** Get the rate of lines scanning.
111      * @param lineNumber line number
112      * @return rate of lines scanning (lines / seconds)
113      */
114     public double getRate(final double lineNumber) {
115         final double rate = datationModel.getRate(lineNumber);
116         DumpManager.dumpSensorRate(this, lineNumber, rate);
117         return rate;
118     }
119 
120     /** Get the sensor position.
121      * @return position
122      */
123     public Vector3D getPosition() {
124         return position;
125     }
126 
127 }