OTB  10.0.0
Orfeo Toolbox
otbOGRVectorDataIO.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2024 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  using Pointer = itk::SmartPointer<Self>;
54  using ConstPointer = itk::SmartPointer<const Self>;
55 
57  itkNewMacro(Self);
58 
61 
63  using ByteOrder = Superclass::ByteOrder;
64 
74  using VertexListConstPointerType = VertexListType::ConstPointer;
82  using SpacingType = Superclass::SpacingType;
83  using OriginType = Superclass::PointType;
84 
85  /*-------- This part of the interface deals with reading data. ------ */
86 
89  bool CanReadFile(const char*) const override;
90 
92  void Read(itk::DataObject* data) override;
93 
94  /*-------- This part of the interfaces deals with writing data. ----- */
95 
98  bool CanWriteFile(const char*) const override;
99 
101  void Write(const itk::DataObject* data, char** papszOptions = nullptr) override;
102 
103 protected:
106 
108  ~OGRVectorDataIO() override;
109 
110  /* virtual void InternalReadVectorDataInformation(){}; */
111 
112  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
113 
114 private:
115  OGRVectorDataIO(const Self&) = delete;
116  void operator=(const Self&) = delete;
117 
118  std::string GetOGRDriverName(std::string name) const;
119 
121 
122  GDALDataset* m_DataSource;
123 
124  const std::map<std::string, std::string> m_OGRExtensionsToDrivers = {
125  {".SHP", "ESRI Shapefile"}, {".TAB", "MapInfo File"}, {".GML", "GML"}, {".GPX", "GPX"}, {".SQLITE", "SQLite"}, {".KML", "KML"},
126  {".GMT", "OGR_GMT"}, {".GPKG", "GPKG"}, {".JSON", "GeoJSON"}, {".GEOJSON", "GeoJSON"}};
127 };
128 
129 } // end namespace otb
130 
131 #endif // otbOGRVectorDataIO_h
This class represents a node of data in a vector data hierarchy.
Definition: otbDataNode.h:74
itk::SmartPointer< Self > Pointer
Definition: otbDataNode.h:79
itk::Point< PrecisionType, VDimension > PointType
Definition: otbDataNode.h:93
ImageIO object for reading and writing OGR format vector data.
PolygonType::Pointer PolygonPointerType
VectorDataType::DataTreeType DataTreeType
itk::SmartPointer< const Self > ConstPointer
void operator=(const Self &)=delete
PolygonListType::Pointer PolygonListPointerType
Superclass::PointType OriginType
bool CanWriteFile(const char *) const override
~OGRVectorDataIO() override
VectorDataType::Pointer VectorDataPointerType
std::string GetOGRDriverName(std::string name) const
VertexListType::ConstPointer VertexListConstPointerType
void PrintSelf(std::ostream &os, itk::Indent indent) const override
void Write(const itk::DataObject *data, char **papszOptions=nullptr) override
bool CanReadFile(const char *) const override
void Read(itk::DataObject *data) override
void CloseInternalDataSource()
OGRVectorDataIO(const Self &)=delete
LineType::Pointer LinePointerType
VectorDataType::ChildrenListType ChildrenListType
DataNodeType::Pointer DataNodePointerType
VectorDataType::ConstPointer VectorDataConstPointerType
LineType::VertexListType VertexListType
This class is a generic all-purpose wrapping around an std::vector<itk::SmartPointer<ObjectType> >.
Definition: otbObjectList.h:41
itk::SmartPointer< Self > Pointer
Definition: otbObjectList.h:46
This class implement a PolyLineParametricPath for which a value can be set. The value is stored in th...
This class represent a 2D polygon.
Definition: otbPolygon.h:45
itk::SmartPointer< Self > Pointer
Definition: otbPolygon.h:50
Abstract superclass defines VectorData IO interface.
itk::Point< double, VDimension > PointType
itk::SmartPointer< Self > Pointer
itk::Vector< double, VDimension > SpacingType
itk::LightProcessObject Superclass
This class represents a hierarchy of vector data.
Definition: otbVectorData.h:62
itk::SmartPointer< Self > Pointer
Definition: otbVectorData.h:67
boost::adjacency_list< boost::vecS, boost::vecS, boost::directedS, DataNodePointerType > DataTreeType
Definition: otbVectorData.h:87
std::vector< DataNodePointerType > ChildrenListType
Definition: otbVectorData.h:90
itk::SmartPointer< const Self > ConstPointer
Definition: otbVectorData.h:68
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.