otbOGRIOHelper.h 3.81 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/*
 * Copyright (C) 2005-2017 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.
 */
20

21 22
#ifndef otbOGRIOHelper_h
#define otbOGRIOHelper_h
23 24 25 26

#include <vector>

#include "otbVectorData.h"
27
#include "otbOGRVersionProxy.h"
28

29 30 31
#include "OTBIOGDALExport.h"


32
class GDALDataset;
33 34 35 36 37
class OGRGeometryCollection;
class OGRLayer;
class OGRSpatialReference;
class OGRGeometry;

38

39
namespace otb
40 41
{

42
/** \class OGRIOHelper
43 44
 *  \brief This class IO OGR
 *
45 46
 *
 * \ingroup OTBIOGDAL
47
 */
48
class OTBIOGDAL_EXPORT OGRIOHelper: public itk::Object
49 50
{
public:
51 52 53 54 55 56
  /** Standard class typedefs. */
  typedef OGRIOHelper                   Self;
  typedef itk::Object                   Superclass;
  typedef itk::SmartPointer<Self>       Pointer;
  typedef itk::SmartPointer<const Self> ConstPointer;

57 58
  /** Template parameters typedefs */
  /** Data typedef */
59
  typedef VectorData<>                                    VectorDataType;
60 61
  typedef VectorDataType::DataTreeType           DataTreeType;
  typedef DataTreeType::TreeNodeType             InternalTreeNodeType;
62

63 64 65
  typedef VectorDataType::DataNodeType           DataNodeType;
  typedef DataNodeType::Pointer                  DataNodePointerType;

66 67
  /** Method for creation through the object factory. */
  itkNewMacro(Self);
OTB Bot's avatar
OTB Bot committed
68

69
  /** Run-time type information (and related methods). */
70
  itkTypeMacro(OGRIOHelper, itk::Object);
OTB Bot's avatar
OTB Bot committed
71

72
  /** Conversion tools */
73
  void ConvertOGRLayerToDataTreeNode(OGRLayer * layer, InternalTreeNodeType * documentPtr) const;
74

OTB Bot's avatar
OTB Bot committed
75 76

  unsigned int ProcessNodeWrite(InternalTreeNodeType * source,
77
                                GDALDataset * m_DataSource,
OTB Bot's avatar
OTB Bot committed
78 79 80 81
                                OGRGeometryCollection * ogrCollection,
                                OGRLayer * ogrCurrentLayer,
                                OGRSpatialReference * oSRS);

82
  /** Return a list of OGRLayer * */
OTB Bot's avatar
OTB Bot committed
83
  std::vector<OGRLayer*> ConvertDataTreeNodeToOGRLayers(InternalTreeNodeType * source,
84
                                                        GDALDataset * dummyDatasource,
85 86 87
                                                        OGRLayer* ogrCurrentLayer,
                                                        OGRSpatialReference * oSRS);

88 89 90 91 92 93
  void ConvertGeometryToPointNode(const OGRGeometry * ogrGeometry, DataNodePointerType node) const;

  void ConvertGeometryToLineNode(const OGRGeometry * ogrGeometry, DataNodePointerType node) const;

  void ConvertGeometryToPolygonNode(const OGRGeometry * ogrGeometry, DataNodePointerType node) const;

94 95
protected:
  OGRIOHelper();
96
  ~OGRIOHelper() override;
OTB Bot's avatar
OTB Bot committed
97 98

private:
99 100
  OGRIOHelper(const Self &) = delete;
  void operator =(const Self&) = delete;
101

102
  typedef DataNodeType::PointType                PointType;
103

104 105 106 107
  typedef DataNodeType::LineType                 LineType;
  typedef LineType::Pointer                      LinePointerType;
  typedef LineType::VertexListType               VertexListType;
  typedef VertexListType::ConstPointer           VertexListConstPointerType;
108

109 110 111 112
  typedef DataNodeType::PolygonType              PolygonType;
  typedef PolygonType::Pointer                   PolygonPointerType;
  typedef DataNodeType::PolygonListType          PolygonListType;
  typedef PolygonListType::Pointer               PolygonListPointerType;
113

114 115 116 117 118
}; // end class OGRIOHelper

} // end namespace otb

#endif