otbImageEnvelope.cxx 3.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*=========================================================================

  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.

=========================================================================*/
18 19
#include "otbWrapperApplication.h"
#include "otbWrapperApplicationFactory.h"
20 21 22

#include "otbImageToEnvelopeVectorDataFilter.h"

23 24 25 26
namespace otb
{
namespace Wrapper
{
27

28
class ImageEnvelope : public Application
29
{
30 31 32 33 34 35
public:
  /** Standard class typedefs. */
  typedef ImageEnvelope                 Self;
  typedef Application                   Superclass;
  typedef itk::SmartPointer<Self>       Pointer;
  typedef itk::SmartPointer<const Self> ConstPointer;
36

37 38
  /** Standard macro */
  itkNewMacro(Self);
39

40
  itkTypeMacro(ImageEnvelope, otb::Application);
41

42 43 44
  /** Filters typedef */
  typedef otb::ImageToEnvelopeVectorDataFilter
      <FloatVectorImageType, VectorDataType>          EnvelopeFilterType;
45

46 47
private:
  ImageEnvelope()
48
  {
49 50 51 52 53 54 55 56 57
    SetName("ImageEnvelope");
    SetDescription("Extracts an image envelope.");

    // Documentation
    SetDocName("Image Envelope Application");
    SetDocLongDescription("Build a vector data containing the polygon of the image envelope.");
    SetDocLimitations("None");
    SetDocAuthors("OTB-Team");
    SetDocSeeAlso(" ");
58
 
59
    AddDocTag(Tags::Geometry);
60
  }
61 62

  virtual ~ImageEnvelope()
63
  {
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
  }

  void DoCreateParameters()
    {
    AddParameter(ParameterType_InputImage,  "in",   "Input Image");
    SetParameterDescription("in", "Input image.");
    
    AddParameter(ParameterType_OutputVectorData,  "out",   "Output Vector Data");
    SetParameterDescription("out", "Vector data file containing the envelope");
    
    AddParameter(ParameterType_Float, "ae",  "AverageElevation");
    SetParameterDescription("ae", "If no DEM is used, provide the height value (default is 0 meters)");
    SetDefaultParameterFloat("ae", 0.0);
    MandatoryOff("ae");
    
    AddParameter(ParameterType_String, "dem",  "DEMDirectory");
    SetParameterDescription("dem", "Use DEM tiles to derive height values (AverageElevation option is ignored in this case)");
    MandatoryOff("dem");
    
    AddParameter(ParameterType_String, "proj",  "Projection");
    SetParameterDescription("proj", "Projection to be used to compute the envelope (default is WGS84)");
    MandatoryOff("proj");
    
87 88 89
   // Doc example parameter settings
    SetDocExampleParameterValue("in", "sensor_stereo_left.tif");
    SetDocExampleParameterValue("out", "ImageEnvelope.shp");
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
    }

  void DoUpdateParameters()
    {
    // Nothing to be done
    }

  void DoExecute()
    {
    FloatVectorImageType::Pointer input = GetParameterImage("in");
    
    m_Envelope = EnvelopeFilterType::New();
    m_Envelope->SetInput(input);
    
    if (HasValue("dem"))
105
      {
106
      m_Envelope->SetDEMDirectory(GetParameterString("dem"));
107
      }
108
    else
109
      {
110
      m_Envelope->SetAverageElevation(GetParameterFloat("ae"));
111
      }
112 113 114 115 116 117
    
    if (HasValue("proj"))
      {
      m_Envelope->SetOutputProjectionRef(GetParameterString("proj"));
      }
    
OTB Bot's avatar
STYLE  
OTB Bot committed
118
    SetParameterOutputVectorData("out", m_Envelope->GetOutput());
119
    }
120

121
  EnvelopeFilterType::Pointer m_Envelope;
122

123 124 125
};

}
126
}
127 128

OTB_APPLICATION_EXPORT(otb::Wrapper::ImageEnvelope)