Skip to content
Snippets Groups Projects
Commit 0b7e462f authored by Emmanuel Christophe's avatar Emmanuel Christophe
Browse files

Automated merge with http://hg.orfeo-toolbox.org/OTB

parents 14657d8d 8d3678e5
No related branches found
No related tags found
No related merge requests found
/*=========================================================================
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 __otbWorldFile_h
#define __otbWorldFile_h
#include "itkObject.h"
namespace otb {
/**
* \class WorldFile
* \brief Handle the world file that associate geographic information to png, jpg
*
*/
class ITK_EXPORT WorldFile: public itk::Object
{
public:
typedef WorldFile Self;
typedef itk::Object Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Method for creation through the object factory. */
itkNewMacro( Self );
itkGetMacro(LonOrigin, double)
itkSetMacro(LonOrigin, double)
itkGetMacro(LatOrigin, double)
itkSetMacro(LatOrigin, double)
itkGetMacro(LonSpacing, double)
itkSetMacro(LonSpacing, double)
itkGetMacro(LatSpacing, double)
itkSetMacro(LatSpacing, double)
itkGetMacro(LonRotation, double)
itkSetMacro(LonRotation, double)
itkGetMacro(LatRotation, double)
itkSetMacro(LatRotation, double)
itkGetStringMacro(ImageFilename)
itkSetStringMacro(ImageFilename)
void Update()
{
if (m_ImageFilename.empty())
{
itkExceptionMacro(<< "The image filename must be provided");
}
std::string worldFilename;
int i = m_ImageFilename.find_last_of('.');
worldFilename = m_ImageFilename.substr(0,i) + ".wld";
std::ofstream file;
file.open(worldFilename.c_str());
file << std::setprecision(15);
file << m_LonSpacing << std::endl;
file << m_LatRotation << std::endl; //yes, in this order
file << m_LonRotation << std::endl;
file << m_LatSpacing << std::endl;
file << m_LonOrigin << std::endl;
file << m_LatOrigin << std::endl;
file.close();
}
protected:
WorldFile(): m_LonOrigin(0.0), m_LatOrigin(0.0),
m_LonSpacing(0.0), m_LatSpacing(0.0),
m_LonRotation(0.0), m_LatRotation(0.0),
m_ImageFilename("")
{};
~WorldFile() {};
private:
WorldFile(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
double m_LonOrigin;
double m_LatOrigin;
double m_LonSpacing;
double m_LatSpacing;
double m_LonRotation;
double m_LatRotation;
std::string m_ImageFilename;
};
} // end namespace otb
#endif
......@@ -60,6 +60,7 @@
#include "otbExtractROI.h"
#include "otbImageFileWriter.h"
#include "ossim/projection/ossimTileMapModel.h"
#include "otbWorldFile.h"
// Software Guide : EndCodeSnippet
int main( int argc, char* argv[] )
......@@ -246,20 +247,13 @@ int main( int argc, char* argv[] )
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
std::string worldFilename;
int i = outputFilename.find_last_of('.');
worldFilename = outputFilename.substr(0,i) + ".wld";
std::ofstream file;
file.open(worldFilename.c_str());
file << std::setprecision(15);
file << lonSpacing << std::endl;
file << 0.0 << std::endl;
file << 0.0 << std::endl;
file << latSpacing << std::endl;
file << lonUL << std::endl;
file << latUL << std::endl;
file.close();
otb::WorldFile::Pointer worldFile = otb::WorldFile::New();
worldFile->SetImageFilename(outputFilename);
worldFile->SetLonOrigin(lonUL);
worldFile->SetLatOrigin(latUL);
worldFile->SetLonSpacing(lonSpacing);
worldFile->SetLatSpacing(latSpacing);
worldFile->Update();
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment