Commit 7396492a authored by Emmanuel Christophe's avatar Emmanuel Christophe

work in progress

parent ae0cf050
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __otbNetworkedQuadTreeTransform_h
#define __otbNetworkedQuadTreeTransform_h
#include <iostream>
#include <sstream>
#include <stdio.h>
// #include "projection/ossimNetworkedQuadTreeTransform.h"
#include "itkTransform.h"
#include "itkExceptionObject.h"
#include "itkMacro.h"
#include "base/ossimGpt.h"
#include "base/ossimDpt.h"
#include "projection/ossimProjection.h"
#include "base/ossimEllipsoid.h"
#include "base/ossimEllipsoidFactory.h"
#include "base/ossimString.h"
#include "ossim/projection/ossimNetworkedQuadTreeModel.h"
#include "otbMapProjection.h"
namespace otb
{
/** \class otbNetworkedQuadTreeTransform
* \brief to do
**/
template <InverseOrForwardTransformationEnum transform,
class TScalarType = double,
unsigned int NInputDimensions=2,
unsigned int NOutputDimensions=2>
class ITK_EXPORT NetworkedQuadTreeTransform: public itk::Transform<TScalarType, // Data type for scalars
NInputDimensions, // Number of dimensions in the input space
NOutputDimensions> // Number of dimensions in the output space
{
public :
/** Standard class typedefs. */
typedef itk::Transform< TScalarType,
NInputDimensions,
NOutputDimensions > Superclass;
typedef NetworkedQuadTreeTransform Self;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
typedef typename Superclass::ScalarType ScalarType;
typedef ossimNetworkedQuadTreeModel OssimNetworkedQuadTreeTransformType;
typedef itk::Point<ScalarType,NInputDimensions > InputPointType;
typedef itk::Point<ScalarType,NOutputDimensions > OutputPointType;
/** Method for creation through the object factory. */
itkNewMacro( Self );
/** Run-time type information (and related methods). */
itkTypeMacro( NetworkedQuadTreeTransform, Transform );
typedef InverseOrForwardTransformationEnum DirectionOfMappingEnumType;
itkStaticConstMacro(DirectionOfMapping,DirectionOfMappingEnumType,transform);
itkStaticConstMacro(InputSpaceDimension, unsigned int, NInputDimensions);
itkStaticConstMacro(OutputSpaceDimension, unsigned int, NOutputDimensions);
itkStaticConstMacro(SpaceDimension, unsigned int, NInputDimensions);
itkStaticConstMacro(ParametersDimension, unsigned int,NInputDimensions*(NInputDimensions+1));
void SetLevel(unsigned char level);
// virtual void SetEllipsoid ();
// void SetEllipsoid (const ossimEllipsoid &ellipsoid);
// void SetEllipsoid(std::string code);
// void SetEllipsoid(const double &major_axis, const double &minor_axis);
OutputPointType TransformPoint(const InputPointType &point) const;
virtual InputPointType Origin();
// virtual double GetFalseNorthing() const;
// virtual double GetFalseEasting() const;
// virtual double GetStandardParallel1() const;
// virtual double GetStandardParallel2() const;
// virtual std::string GetProjectionName() const;
// virtual bool IsGeographic() const;
// virtual double GetA() const;
// virtual double GetB() const;
// virtual double GetF() const;
// virtual OutputPointType GetMetersPerPixel() const;
// virtual OutputPointType GetDecimalDegreesPerPixel() const;
// virtual void SetAB(double a, double b);
// virtual void SetOrigin(const InputPointType &origin);
// virtual void SetMetersPerPixel(const OutputPointType &point);
// virtual void SetDecimalDegreesPerPixel(const OutputPointType &point);
// virtual void ComputeDegreesPerPixel(const InputPointType &ground, const OutputPointType &metersPerPixel, double &deltaLat, double &deltaLon);
// virtual void ComputeMetersPerPixel(const InputPointType &center, double deltaDegreesPerPixelLat, double deltaDegreesPerPixelLon, OutputPointType &metersPerPixel);
// virtual void ComputeMetersPerPixel(double deltaDegreesPerPixelLat, double deltaDegreesPerPixelLon, OutputPointType &metersPerPixel);
// //virtual void SetMatrix(double rotation, const OutputPointType &scale, const OutputPointType &translation);
// void SetFalseEasting(double falseEasting);
virtual void PrintMap() const ;
protected:
NetworkedQuadTreeTransform();
virtual ~NetworkedQuadTreeTransform();
OssimNetworkedQuadTreeTransformType* m_NetworkedQuadTreeTransform;
private :
NetworkedQuadTreeTransform(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
};
} // namespace otb
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbNetworkedQuadTreeTransform.txx"
#endif
#endif
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __otbNetworkedQuadTreeTransform_txx
#define __otbNetworkedQuadTreeTransform_txx
#include "otbNetworkedQuadTreeTransform.h"
#include "otbMacro.h"
namespace otb
{
template<InverseOrForwardTransformationEnum Transform, class TScalarType, unsigned int NInputDimensions, unsigned int NOutputDimensions>
NetworkedQuadTreeTransform<Transform, TScalarType, NInputDimensions, NOutputDimensions>
::NetworkedQuadTreeTransform() : Superclass(SpaceDimension,ParametersDimension)
{
m_NetworkedQuadTreeTransform = new OssimNetworkedQuadTreeTransformType();
}
template<InverseOrForwardTransformationEnum Transform, class TScalarType, unsigned int NInputDimensions, unsigned int NOutputDimensions>
NetworkedQuadTreeTransform<Transform, TScalarType, NInputDimensions, NOutputDimensions>
::~NetworkedQuadTreeTransform()
{
delete m_NetworkedQuadTreeTransform;
}
template<InverseOrForwardTransformationEnum Transform, class TScalarType, unsigned int NInputDimensions, unsigned int NOutputDimensions>
typename NetworkedQuadTreeTransform<Transform, TScalarType, NInputDimensions, NOutputDimensions>::OutputPointType
NetworkedQuadTreeTransform<Transform, TScalarType, NInputDimensions, NOutputDimensions>
::TransformPoint(const InputPointType & point) const
{
OutputPointType outputPoint;
switch(DirectionOfMapping)
{
case INVERSE:
{
otbMsgDevMacro(<< "Cartographic coordinates: (" << point[0] << "," << point[1] << ")");
//from "itk::point" to "ossim::ossimDpt"
ossimDpt ossimDPoint(point[0], point[1]);
//map projection
ossimGpt ossimGPoint;
// ossimGPoint=m_NetworkedQuadTreeTransform->inverse(ossimDPoint);
m_NetworkedQuadTreeTransform->lineSampleToWorld(ossimDPoint, ossimGPoint);
// otbGenericMsgDebugMacro(<< "Inverse : " << std::endl << m_NetworkedQuadTreeTransform->print(std::cout));
outputPoint[0]=ossimGPoint.lon;
outputPoint[1]=ossimGPoint.lat;
otbMsgDevMacro(<< "Geographic coordinates (long/lat) : (" << outputPoint[0] << "," << outputPoint[1] << ")");
break;
}
case FORWARD:
{
otbMsgDevMacro(<< "Geographic coordinates (long/lat) : (" << point[1] << "," << point[0] << ")");
//from "itk::point" to "ossim::ossimGpt"
ossimGpt ossimGPoint(point[1], point[0]);
//map projection
ossimDpt ossimDPoint;
// ossimDPoint=m_NetworkedQuadTreeTransform->forward(ossimGPoint);
m_NetworkedQuadTreeTransform->worldToLineSample(ossimGPoint, ossimDPoint);
// otbGenericMsgDebugMacro(<< "Forward : ========================= " << std::endl << m_NetworkedQuadTreeTransform->print(std::cout));
outputPoint[0]=ossimDPoint.x;
outputPoint[1]=ossimDPoint.y;
otbMsgDevMacro(<< "Cartographic coordinates: (" << outputPoint[0] << "," << outputPoint[1] << ")");
break;
}
default:
{
itkExceptionMacro(<<"Model is INVERSE or FORWARD only !!");
break;
}
}
return outputPoint;
}
///\return The geographic point corresponding to (0,0)
template<InverseOrForwardTransformationEnum Transform, class TScalarType, unsigned int NInputDimensions, unsigned int NOutputDimensions>
typename NetworkedQuadTreeTransform<Transform, TScalarType, NInputDimensions, NOutputDimensions>::InputPointType
NetworkedQuadTreeTransform<Transform, TScalarType, NInputDimensions, NOutputDimensions>
::Origin()
{
ossimGpt ossimOrigin=m_NetworkedQuadTreeTransform->origin();
InputPointType otbOrigin;
otbOrigin[0]= ossimOrigin.lat;
otbOrigin[1]= ossimOrigin.lon;
return otbOrigin;
}
template<InverseOrForwardTransformationEnum Transform, class TScalarType, unsigned int NInputDimensions, unsigned int NOutputDimensions>
void
NetworkedQuadTreeTransform<Transform, TScalarType, NInputDimensions, NOutputDimensions>
::PrintMap() const
{
std::cout << m_NetworkedQuadTreeTransform->print(std::cout);
}
template<InverseOrForwardTransformationEnum Transform, class TScalarType, unsigned int NInputDimensions, unsigned int NOutputDimensions>
void NetworkedQuadTreeTransform<Transform, TScalarType, NInputDimensions, NOutputDimensions>
::SetLevel(unsigned char level)
{
m_NetworkedQuadTreeTransform->setDepth(level);
}
} // namespace otb
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment