OTB  9.0.0
Orfeo Toolbox
otbOGRVectorDataIO.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 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 : public VectorDataIOBase
48 {
49 public:
53  typedef itk::SmartPointer<Self> Pointer;
54  typedef itk::SmartPointer<const Self> ConstPointer;
55 
57  itkNewMacro(Self);
58 
61 
63  typedef Superclass::ByteOrder ByteOrder;
64 
68  typedef DataTreeType::TreeNodeType InternalTreeNodeType;
69  typedef InternalTreeNodeType::ChildrenListType ChildrenListType;
70  typedef DataTreeType::Pointer DataTreePointerType;
71  typedef DataTreeType::ConstPointer DataTreeConstPointerType;
77  typedef VertexListType::ConstPointer VertexListConstPointerType;
85  typedef Superclass::SpacingType SpacingType;
86  typedef Superclass::PointType OriginType;
87 
88  /*-------- This part of the interface deals with reading data. ------ */
89 
92  bool CanReadFile(const char*) const override;
93 
95  void Read(itk::DataObject* data) override;
96 
97  /*-------- This part of the interfaces deals with writing data. ----- */
98 
101  bool CanWriteFile(const char*) const override;
102 
104  void Write(const itk::DataObject* data, char** papszOptions = nullptr) override;
105 
106 protected:
108  OGRVectorDataIO();
109 
111  ~OGRVectorDataIO() override;
112 
113  /* virtual void InternalReadVectorDataInformation(){}; */
114 
115  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
116 
117 private:
118  OGRVectorDataIO(const Self&) = delete;
119  void operator=(const Self&) = delete;
120 
121  std::string GetOGRDriverName(std::string name) const;
122 
123  void CloseInternalDataSource();
124 
125  GDALDataset* m_DataSource;
126 
127  const std::map<std::string, std::string> m_OGRExtensionsToDrivers = {
128  {".SHP", "ESRI Shapefile"}, {".TAB", "MapInfo File"}, {".GML", "GML"}, {".GPX", "GPX"}, {".SQLITE", "SQLite"}, {".KML", "KML"},
129  {".GMT", "OGR_GMT"}, {".GPKG", "GPKG"}, {".JSON", "GeoJSON"}, {".GEOJSON", "GeoJSON"}};
130 };
131 
132 } // end namespace otb
133 
134 #endif // otbOGRVectorDataIO_h
otb::OGRVectorDataIO::PolygonPointerType
PolygonType::Pointer PolygonPointerType
Definition: otbOGRVectorDataIO.h:80
otb::DataNode::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbDataNode.h:79
otb::OGRVectorDataIO::LineType
DataNodeType::LineType LineType
Definition: otbOGRVectorDataIO.h:75
otb::OGRVectorDataIO::ByteOrder
Superclass::ByteOrder ByteOrder
Definition: otbOGRVectorDataIO.h:60
otbVectorDataIOBase.h
otb::OGRVectorDataIO::PolygonType
DataNodeType::PolygonType PolygonType
Definition: otbOGRVectorDataIO.h:79
otb::OGRVectorDataIO::VectorDataType
VectorData< double, 2 > VectorDataType
Definition: otbOGRVectorDataIO.h:66
otb::OGRVectorDataIO::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbOGRVectorDataIO.h:53
otb::DataNode::PointType
itk::Point< PrecisionType, VDimension > PointType
Definition: otbDataNode.h:93
otb::OGRVectorDataIO::OriginType
Superclass::PointType OriginType
Definition: otbOGRVectorDataIO.h:86
otb::VectorData::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbVectorData.h:64
otb::VectorData
This class represents a hierarchy of vector data.
Definition: otbVectorData.h:58
otb::DataNode
This class represents a node of data in a vector data hierarchy.
Definition: otbDataNode.h:73
otb::Wrapper::XML::Write
OTBApplicationEngine_EXPORT void Write(const std::string &filename, Application::Pointer application)
otb::OGRVectorDataIO::LinePointerType
LineType::Pointer LinePointerType
Definition: otbOGRVectorDataIO.h:78
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::OGRVectorDataIO::VectorDataConstPointerType
VectorDataType::ConstPointer VectorDataConstPointerType
Definition: otbOGRVectorDataIO.h:84
otb::OGRVectorDataIO::ChildrenListType
InternalTreeNodeType::ChildrenListType ChildrenListType
Definition: otbOGRVectorDataIO.h:69
otb::OGRVectorDataIO::VectorDataPointerType
VectorDataType::Pointer VectorDataPointerType
Definition: otbOGRVectorDataIO.h:83
otb::OGRVectorDataIO::PolygonListPointerType
PolygonListType::Pointer PolygonListPointerType
Definition: otbOGRVectorDataIO.h:82
otb::OGRVectorDataIO::DataTreeConstPointerType
DataTreeType::ConstPointer DataTreeConstPointerType
Definition: otbOGRVectorDataIO.h:71
otb::ObjectList::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbObjectList.h:46
otb::OGRVectorDataIO::InternalTreeNodeType
DataTreeType::TreeNodeType InternalTreeNodeType
Definition: otbOGRVectorDataIO.h:68
otb::OGRVectorDataIO::Self
OGRVectorDataIO Self
Definition: otbOGRVectorDataIO.h:51
otb::OGRVectorDataIO::DataTreePointerType
DataTreeType::Pointer DataTreePointerType
Definition: otbOGRVectorDataIO.h:70
otb::VectorData::DataTreeType
itk::TreeContainer< DataNodePointerType > DataTreeType
Definition: otbVectorData.h:79
otb::OGRVectorDataIO::PointType
DataNodeType::PointType PointType
Definition: otbOGRVectorDataIO.h:74
otb::OGRVectorDataIO::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbOGRVectorDataIO.h:54
otb::OGRVectorDataIO::PolygonListType
DataNodeType::PolygonListType PolygonListType
Definition: otbOGRVectorDataIO.h:81
otb::OGRVectorDataIO::SpacingType
Superclass::SpacingType SpacingType
Definition: otbOGRVectorDataIO.h:85
otb::OGRVectorDataIO::DataNodeType
VectorDataType::DataNodeType DataNodeType
Definition: otbOGRVectorDataIO.h:72
otb::PolyLineParametricPathWithValue::VertexListType
Superclass::VertexListType VertexListType
Definition: otbPolyLineParametricPathWithValue.h:70
otb::PolyLineParametricPathWithValue::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbPolyLineParametricPathWithValue.h:56
otb::Polygon::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbPolygon.h:50
otb::PolyLineParametricPathWithValue
This class implement a PolyLineParametricPath for which a value can be set. The value is stored in th...
Definition: otbPolyLineParametricPathWithValue.h:50
otb::Wrapper::XML::Read
OTBApplicationEngine_EXPORT int Read(const std::string &filename, Application::Pointer application)
otbVectorData.h
otb::OGRVectorDataIO::VertexListConstPointerType
VertexListType::ConstPointer VertexListConstPointerType
Definition: otbOGRVectorDataIO.h:77
otb::VectorData::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbVectorData.h:65
otb::Polygon
This class represent a 2D polygon.
Definition: otbPolygon.h:44
otb::ObjectList
This class is a generic all-purpose wrapping around an std::vector<itk::SmartPointer<ObjectType> >.
Definition: otbObjectList.h:40
otb::OGRVectorDataIO::VertexListType
LineType::VertexListType VertexListType
Definition: otbOGRVectorDataIO.h:76
otb::OGRVectorDataIO::DataTreeType
VectorDataType::DataTreeType DataTreeType
Definition: otbOGRVectorDataIO.h:67
otb::OGRVectorDataIO::DataNodePointerType
DataNodeType::Pointer DataNodePointerType
Definition: otbOGRVectorDataIO.h:73
otb::OGRVectorDataIO
ImageIO object for reading and writing OGR format vector data.
Definition: otbOGRVectorDataIO.h:47
otb::OGRVectorDataIO::Superclass
VectorDataIOBase Superclass
Definition: otbOGRVectorDataIO.h:52
otb::OGRVectorDataIO::m_DataSource
GDALDataset * m_DataSource
Definition: otbOGRVectorDataIO.h:125
otb::VectorDataIOBase
Abstract superclass defines VectorData IO interface.
Definition: otbVectorDataIOBase.h:60