OTB  6.7.0
Orfeo Toolbox
otbOGRVectorDataIO.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbOGRVectorDataIO_h
22 #define otbOGRVectorDataIO_h
23 
24 #include <string>
25 #include <map>
26 #include <cassert>
27 
28 #include "otbVectorDataIOBase.h"
29 #include "otbVectorData.h"
30 
31 #include "OTBIOGDALExport.h"
32 
33 namespace otb
34 {
35 
47 class OTBIOGDAL_EXPORT OGRVectorDataIO
48  : public VectorDataIOBase
49 {
50 public:
51 
57 
59  itkNewMacro(Self);
60 
63 
65  typedef Superclass::ByteOrder ByteOrder;
66 
79  typedef VertexListType::ConstPointer VertexListConstPointerType;
89 
90  /*-------- This part of the interface deals with reading data. ------ */
91 
94  bool CanReadFile(const char*) const override;
95 
97  void Read(itk::DataObject* data) override;
98 
99  /*-------- This part of the interfaces deals with writing data. ----- */
100 
103  bool CanWriteFile(const char*) const override;
104 
106  void Write(const itk::DataObject* data, char ** papszOptions = nullptr) override;
107 
108 protected:
110  OGRVectorDataIO();
111 
113  ~OGRVectorDataIO() override;
114 
115  /* virtual void InternalReadVectorDataInformation(){}; */
116 
117  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
118 
119 private:
120  OGRVectorDataIO(const Self &) = delete;
121  void operator =(const Self&) = delete;
122 
123  std::string GetOGRDriverName(std::string name) const;
124 
125  void CloseInternalDataSource();
126 
127  GDALDataset * m_DataSource;
128 
129  const std::map<std::string, std::string>
130  m_OGRExtensionsToDrivers = {
131  { ".SHP", "ESRI Shapefile"},
132  { ".TAB", "MapInfo File"},
133  { ".GML", "GML"},
134  { ".GPX", "GPX"},
135  { ".SQLITE", "SQLite"},
136  {".KML", "KML"},
137  { ".GMT", "OGR_GMT"},
138  { ".GPKG", "GPKG"},
139  { ".JSON", "GeoJSON"},
140  { ".GEOJSON", "GeoJSON"}
141  };
142 };
143 
144 } // end namespace otb
145 
146 #endif // otbOGRVectorDataIO_h
DataNodeType::PolygonType PolygonType
VectorDataType::ConstPointer VectorDataConstPointerType
InternalTreeNodeType::ChildrenListType ChildrenListType
VectorDataIOBase Superclass
OTBApplicationEngine_EXPORT int Read(const std::string &filename, Application::Pointer application)
std::vector< Pointer > ChildrenListType
This class implement a PolyLineParametricPath for which a value can be set. The value is stored in th...
DataNodeType::PointType PointType
DataTreeType::ConstPointer DataTreeConstPointerType
ImageIO object for reading and writing OGR format vector data.
This class represents a node of data in a vector data hierarchy.
Definition: otbDataNode.h:75
Superclass::SpacingType SpacingType
This class represent a 2D polygon.
Definition: otbPolygon.h:44
PolygonListType::Pointer PolygonListPointerType
VectorDataType::Pointer VectorDataPointerType
VectorDataType::DataNodeType DataNodeType
VertexListType::ConstPointer VertexListConstPointerType
VectorDataType::DataTreeType DataTreeType
This class is a generic all-purpose wrapping around an std::vector<itk::SmartPointer<ObjectType> >...
Definition: otbObjectList.h:40
itk::SmartPointer< Self > Pointer
DataTreeType::Pointer DataTreePointerType
Superclass::ByteOrder ByteOrder
Abstract superclass defines VectorData IO interface.
LineType::VertexListType VertexListType
DataNodeType::PolygonListType PolygonListType
DataTreeType::TreeNodeType InternalTreeNodeType
OTBApplicationEngine_EXPORT void Write(const std::string &filename, Application::Pointer application)
PolygonType::Pointer PolygonPointerType
DataNodeType::LineType LineType
This class represents a hierarchy of vector data.
Definition: otbVectorData.h:58
VectorImageType::SpacingType SpacingType
Definition: mvdTypes.h:181
LineType::Pointer LinePointerType
itk::SmartPointer< const Self > ConstPointer
DataNodeType::Pointer DataNodePointerType
VectorImageType::PointType PointType
Definition: mvdTypes.h:189
VectorData< double, 2 > VectorDataType
Superclass::PointType OriginType