Newer
Older
* Copyright (C) 2005-2021 Centre National d'Etudes Spatiales (CNES)
*
* This file is part of Orfeo Toolbox
*
* https://www.orfeo-toolbox.org/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef otbPositionHelpers_h
#define otbPositionHelpers_h
#include "otbRepack.h"
#include "otbSarSensorModelAdapter.h"
namespace otb
{
template <typename ImageType>
inline
auto TransformIndexToPhysicalPoint(ImageType & im, typename ImageType::IndexType const& index)
{
typename ImageType::PointType p;
im.TransformIndexToPhysicalPoint(index, p);
return p;
}
template <typename IndexRep, typename ImageType>
inline
auto TransformPhysicalPointToContinuousIndex(ImageType & im, typename ImageType::PointType const& p)
{
// There is no ImageType::ContinuousIndex in otb images
// => work around it
// static_assert(std::is_same<typename ImageType::IndexValueType, double>::value, "");
static_assert(ImageType::ImageDimension == 2, "");
itk::ContinuousIndex<IndexRep, ImageType::ImageDimension> index;
im.TransformPhysicalPointToContinuousIndex(p, index);
return index;
}
template <typename Point3DType>
inline
auto WorldToCartesian(Point3DType const& lat_lon_hgt)
{
auto const p = otb::auto_repack(lat_lon_hgt);
itk::Point<double, 3> xyz;
otb::SarSensorModelAdapter::WorldToCartesian(p, xyz);
return xyz;
}
} // otb namespace
#endif // otbPositionHelpers_h