OTB  9.0.0
Orfeo Toolbox
otbSarSensorModel.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2024 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbSarSensorModel_h
22 #define otbSarSensorModel_h
23 
25 #include "otbImageMetadata.h"
26 #include "otbSARMetadata.h"
27 #include "otbGeocentricTransform.h"
28 
29 #include "itkPoint.h"
30 #include <string>
31 #include <tuple>
32 
33 namespace otb
34 {
35 
37 {
38 public:
39 
40  /*-------------------------------[ Typedefs ]--------------------------------*/
41  using Point2DType = itk::Point<double, 2>;
42  using Point3DType = itk::Point<double, 3>;
43 
44  using Vector3DType = itk::Point<double, 3>;
45 
48 
49  using OrbitIterator = std::vector<Orbit>::const_iterator;
50 
51  /*-------------------------------[ Special functions ]-----------------------*/
53  std::string productType,
54  SARParam sarParam,
56  unsigned int polynomial_degree = 8);
57 
58  explicit SarSensorModel(const ImageMetadata & imd, unsigned int polynomial_degree = 8);
59  virtual ~SarSensorModel() = default;
60 
61  SarSensorModel(const SarSensorModel&) = delete; // non construction-copyable
62  SarSensorModel& operator=(const SarSensorModel&) = delete; // non copyable
63 
64  /*-------------------------------[ Result types ]----------------------------*/
68  {
70  // double rangeTime;
73  };
74 
77  struct LineSampleYZ
78  {
81  };
82 
83  /*-------------------------------[ Doppler related functions ]---------------*/
85  void WorldToLineSample(const Point3DType& inGeoPoint,
86  Point2DType& outLineSample) const;
87 
88 
108  void WorldToLineSampleYZ(const Point3DType& inGeoPoint, Point2DType& cr, Point2DType& yz) const;
109 
134  Point3DType const& ecefGround, ZeroDopplerInfo const& zdi, double rangeTime) const;
135 
147  double CalculateRangeTime(
148  Point3DType const& ecefGround, Point3DType const& sensorPos) const;
149 
159  bool WorldToSatPositionAndVelocity(const Point3DType& inGeoPoint, Point3DType& satellitePosition, Point3DType& satelliteVelocity) const;
160 
162  bool LineToSatPositionAndVelocity(double line, Point3DType& satellitePosition, Point3DType& satelliteVelocity) const;
163 
188  const Point3DType& inGeoPoint,
189  TimeType & azimuthTime,
190  double & rangeTime,
191  Point3DType& sensorPos,
192  Vector3DType& sensorVel) const;
193 
194  void LineSampleHeightToWorld(const Point2DType& imPt,
195  double heightAboveEllipsoid,
196  Point3DType& worldPt) const;
197 
198  void LineSampleToWorld(const Point2DType& imPt,
199  Point3DType& worldPt) const;
200 
214  TimeType ZeroDopplerTimeLookup(Point3DType const& ecefGround) const;
215 
238  std::tuple<TimeType, OrbitIterator, OrbitIterator>
239  ZeroDopplerTimeLookupInternal(Point3DType const& ecefGround) const;
240 
252  ZeroDopplerInfo ZeroDopplerLookup(Point3DType const& inEcefPoint) const;
253 
254 
255  /*-------------------------------[ Burst related functions ]-----------------*/
257  bool Deburst(std::vector<std::pair<unsigned long, unsigned long>>& lines,
258  std::pair<unsigned long, unsigned long>& samples,
259  bool onlyValidSample = false);
260 
261 
273  bool BurstExtraction(const unsigned int burst_index, std::pair<unsigned long,unsigned long> & lines,
274  std::pair<unsigned long,unsigned long> & samples, bool allPixels = false);
275 
291  bool DeburstAndConcatenate(std::vector<std::pair<unsigned long,unsigned long> >& linesBursts,
292  std::vector<std::pair<unsigned long,unsigned long> >& samplesBursts,
293  unsigned int & linesOffset, unsigned int first_burstInd,
294  bool inputWithInvalidPixels=false);
295 
310  bool Overlap(std::pair<unsigned long, unsigned long>& linesUp, std::pair<unsigned long, unsigned long>& linesLow,
311  std::pair<unsigned long, unsigned long>& samplesUp, std::pair<unsigned long, unsigned long>& samplesLow, unsigned int burstIndUp,
312  bool inputWithInvalidPixels = false);
313 
319 
327  static void DeburstLineToImageLine(const std::vector<std::pair<unsigned long,unsigned long> >& lines,
328  unsigned long deburstLine,
329  unsigned long & imageLine);
330 
339  static bool ImageLineToDeburstLine(const std::vector<std::pair<unsigned long,unsigned long> >& lines,
340  unsigned long imageLine,
341  unsigned long & deburstLine);
342 
343 
344 private:
346 
357 
369  std::pair<Point3DType, Vector3DType> interpolateSensorPosVel(TimeType azimuthTime) const;
370 
382  std::pair<Point3DType, Vector3DType> interpolateSensorPosVel(
383  TimeType azimuthTime,
384  OrbitIterator itrecord1) const;
385 
392  double AzimuthTimeToLine(const TimeType & azimuthTime) const;
393 
394  double SlantRangeToGroundRange(double slantRange,
395  const TimeType & azimuthTime) const;
396 
397 
398  double ApplyCoordinateConversion(double in,
399  const TimeType& azimuthTime,
400  const std::vector<CoordinateConversionRecord> & records) const;
401 
402  const GCP & findClosestGCP(const Point2DType& imPt, const Projection::GCPParam & gcpParam) const;
403 
404  Point3DType projToSurface(const GCP & gcp,
405  const Point2DType & imPt,
406  std::function<double(double, double)> heightFunction) const;
407 
408  TimeType LineToAzimuthTime(double line) const;
409 
411  itk::Point<double, 3> EcefToWorld(const itk::Point<double, 3> & ecefPoint) const;
412 
414  itk::Point<double, 3> WorldToEcef(const itk::Point<double, 3> & worldPoint) const;
415 
416  std::string m_ProductType;
419 
422 
424  double m_RangeTimeOffset; // Offset in seconds
425 
426  // True if the input product is a ground product
427  bool m_IsGrd;
428 
429  // Let's use a single precision for Lagrangian interpolation that is decided
430  // once, when the SarSensorModel is instantiated.
432  unsigned int m_polynomial_degree;
433 
436 };
437 
438 }
439 
440 #endif
otb::SarSensorModel::ZeroDopplerTimeLookupInternal
std::tuple< TimeType, OrbitIterator, OrbitIterator > ZeroDopplerTimeLookupInternal(Point3DType const &ecefGround) const
otb::SarSensorModel::ZeroDopplerInfo
Definition: otbSarSensorModel.h:67
otb::SarSensorModel::Doppler0ToLineSampleYZ
LineSampleYZ Doppler0ToLineSampleYZ(Point3DType const &ecefGround, ZeroDopplerInfo const &zdi, double rangeTime) const
otb::SarSensorModel::ZeroDopplerInfo::azimuthTime
TimeType azimuthTime
Definition: otbSarSensorModel.h:69
otb::SarSensorModel::m_FirstLineTime
TimeType m_FirstLineTime
Definition: otbSarSensorModel.h:420
otb::SarSensorModel::AzimuthTimeToLine
double AzimuthTimeToLine(const TimeType &azimuthTime) const
otb::SarSensorModel
Definition: otbSarSensorModel.h:36
otb::SarSensorModel::WorldToLineSampleYZ
void WorldToLineSampleYZ(const Point3DType &inGeoPoint, Point2DType &cr, Point2DType &yz) const
otb::SarSensorModel::searchLagrangianNeighbourhood
OrbitIterator searchLagrangianNeighbourhood(TimeType azimuthTime) const
otb::SarSensorModel::LineSampleYZ::yz
Point2DType yz
Definition: otbSarSensorModel.h:80
otb::SarSensorModel::SarSensorModel
SarSensorModel(std::string productType, SARParam sarParam, Projection::GCPParam gcps, unsigned int polynomial_degree=8)
otb::SarSensorModel::WorldToLineSample
void WorldToLineSample(const Point3DType &inGeoPoint, Point2DType &outLineSample) const
otb::SarSensorModel::WorldToEcef
itk::Point< double, 3 > WorldToEcef(const itk::Point< double, 3 > &worldPoint) const
otb::SarSensorModel::findClosestGCP
const GCP & findClosestGCP(const Point2DType &imPt, const Projection::GCPParam &gcpParam) const
otb::SarSensorModel::OptimizeTimeOffsetsFromGcps
void OptimizeTimeOffsetsFromGcps()
otb::SarSensorModel::m_LastLineTime
TimeType m_LastLineTime
Definition: otbSarSensorModel.h:421
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::SarSensorModel::LineSampleYZ::col_row
Point2DType col_row
Definition: otbSarSensorModel.h:79
otb::SarSensorModel::LineSampleYZ
Definition: otbSarSensorModel.h:77
otb::SarSensorModel::m_polynomial_degree
unsigned int m_polynomial_degree
Definition: otbSarSensorModel.h:432
otb::SarSensorModel::ImageLineToDeburstLine
static bool ImageLineToDeburstLine(const std::vector< std::pair< unsigned long, unsigned long > > &lines, unsigned long imageLine, unsigned long &deburstLine)
otb::SarSensorModel::LineToSatPositionAndVelocity
bool LineToSatPositionAndVelocity(double line, Point3DType &satellitePosition, Point3DType &satelliteVelocity) const
otb::SarSensorModel::m_ProductType
std::string m_ProductType
Definition: otbSarSensorModel.h:416
otbSARMetadata.h
otb::SarSensorModel::ZeroDopplerLookup
ZeroDopplerInfo ZeroDopplerLookup(Point3DType const &inEcefPoint) const
otb::SarSensorModel::WorldToSatPositionAndVelocity
bool WorldToSatPositionAndVelocity(const Point3DType &inGeoPoint, Point3DType &satellitePosition, Point3DType &satelliteVelocity) const
otb::GeocentricTransform::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbGeocentricTransform.h:45
otb::SarSensorModel::ZeroDopplerInfo::sensorPos
Point3DType sensorPos
Definition: otbSarSensorModel.h:71
otb::SarSensorModel::m_SarParam
SARParam m_SarParam
Definition: otbSarSensorModel.h:418
otb::SARParam
SAR sensors parameters.
Definition: otbSARMetadata.h:211
otb::SarSensorModel::OrbitIterator
std::vector< Orbit >::const_iterator OrbitIterator
Definition: otbSarSensorModel.h:49
otb::SarSensorModel::interpolateSensorPosVel
std::pair< Point3DType, Vector3DType > interpolateSensorPosVel(TimeType azimuthTime) const
otb::SarSensorModel::m_EcefToWorldTransform
otb::GeocentricTransform< otb::TransformDirection::INVERSE, double >::Pointer m_EcefToWorldTransform
Definition: otbSarSensorModel.h:434
otb::SarSensorModel::Overlap
bool Overlap(std::pair< unsigned long, unsigned long > &linesUp, std::pair< unsigned long, unsigned long > &linesLow, std::pair< unsigned long, unsigned long > &samplesUp, std::pair< unsigned long, unsigned long > &samplesLow, unsigned int burstIndUp, bool inputWithInvalidPixels=false)
otb::LagrangianOrbitInterpolator
Definition: otbLagrangianOrbitInterpolator.h:45
otb::SarSensorModel::SlantRangeToGroundRange
double SlantRangeToGroundRange(double slantRange, const TimeType &azimuthTime) const
otbGeocentricTransform.h
otb::SarSensorModel::operator=
SarSensorModel & operator=(const SarSensorModel &)=delete
otb::SarSensorModel::DeburstLineToImageLine
static void DeburstLineToImageLine(const std::vector< std::pair< unsigned long, unsigned long > > &lines, unsigned long deburstLine, unsigned long &imageLine)
otb::SarSensorModel::CalculateRangeTime
double CalculateRangeTime(Point3DType const &ecefGround, Point3DType const &sensorPos) const
otb::SarSensorModel::m_GCP
Projection::GCPParam m_GCP
Definition: otbSarSensorModel.h:417
otb::SarSensorModel::m_RangeTimeOffset
double m_RangeTimeOffset
Definition: otbSarSensorModel.h:424
otb::SarSensorModel::WorldToAzimuthRangeTime
bool WorldToAzimuthRangeTime(const Point3DType &inGeoPoint, TimeType &azimuthTime, double &rangeTime, Point3DType &sensorPos, Vector3DType &sensorVel) const
otb::SarSensorModel::EcefToWorld
itk::Point< double, 3 > EcefToWorld(const itk::Point< double, 3 > &ecefPoint) const
otbLagrangianOrbitInterpolator.h
otb::SarSensorModel::m_WorldToEcefTransform
otb::GeocentricTransform< otb::TransformDirection::FORWARD, double >::Pointer m_WorldToEcefTransform
Definition: otbSarSensorModel.h:435
otb::SarSensorModel::BurstExtraction
bool BurstExtraction(const unsigned int burst_index, std::pair< unsigned long, unsigned long > &lines, std::pair< unsigned long, unsigned long > &samples, bool allPixels=false)
otb::SarSensorModel::Deburst
bool Deburst(std::vector< std::pair< unsigned long, unsigned long >> &lines, std::pair< unsigned long, unsigned long > &samples, bool onlyValidSample=false)
otb::SarSensorModel::LineSampleHeightToWorld
void LineSampleHeightToWorld(const Point2DType &imPt, double heightAboveEllipsoid, Point3DType &worldPt) const
otb::SarSensorModel::Vector3DType
itk::Point< double, 3 > Vector3DType
Definition: otbSarSensorModel.h:44
otb::SarSensorModel::UpdateImageMetadata
void UpdateImageMetadata(ImageMetadata &imd)
otb::ImageMetadata
Generic class containing image metadata used in OTB.
Definition: otbImageMetadata.h:270
otb::MetaData::TimePoint
Represents a point in Time.
Definition: otbDateTime.h:94
otb::SarSensorModel::DeburstAndConcatenate
bool DeburstAndConcatenate(std::vector< std::pair< unsigned long, unsigned long > > &linesBursts, std::vector< std::pair< unsigned long, unsigned long > > &samplesBursts, unsigned int &linesOffset, unsigned int first_burstInd, bool inputWithInvalidPixels=false)
otb::SarSensorModel::m_OrbitInterpolator
LagrangianOrbitInterpolator m_OrbitInterpolator
Definition: otbSarSensorModel.h:431
otb::SarSensorModel::projToSurface
Point3DType projToSurface(const GCP &gcp, const Point2DType &imPt, std::function< double(double, double)> heightFunction) const
otb::SarSensorModel::ZeroDopplerTimeLookup
TimeType ZeroDopplerTimeLookup(Point3DType const &ecefGround) const
otb::SarSensorModel::ApplyCoordinateConversion
double ApplyCoordinateConversion(double in, const TimeType &azimuthTime, const std::vector< CoordinateConversionRecord > &records) const
otb::Projection::GCPParam
This structure handles the list of the GCP parameters.
Definition: otbGeometryMetadata.h:88
otbImageMetadata.h
otb::SarSensorModel::LineSampleToWorld
void LineSampleToWorld(const Point2DType &imPt, Point3DType &worldPt) const
otb::SarSensorModel::LineToAzimuthTime
TimeType LineToAzimuthTime(double line) const
otb::SarSensorModel::~SarSensorModel
virtual ~SarSensorModel()=default
otb::SarSensorModel::Point2DType
itk::Point< double, 2 > Point2DType
Definition: otbSarSensorModel.h:41
otb::SarSensorModel::m_IsGrd
bool m_IsGrd
Definition: otbSarSensorModel.h:427
otb::MetaData::Duration
Represents a duration.
Definition: otbDateTime.h:162
otb::SarSensorModel::m_AzimuthTimeOffset
DurationType m_AzimuthTimeOffset
Definition: otbSarSensorModel.h:423
otb::SarSensorModel::Point3DType
itk::Point< double, 3 > Point3DType
Definition: otbSarSensorModel.h:42
otb::SarSensorModel::ZeroDopplerInfo::sensorVel
Vector3DType sensorVel
Definition: otbSarSensorModel.h:72
otb::GCP
This GCP class is used to manage the GCP parameters in OTB.
Definition: otbGeometryMetadata.h:43