1 /*========================================================================= 2 3 Program: Visualization Toolkit 4 Module: vtkGDALVectorReader.h 5 6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 7 All rights reserved. 8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 9 10 This software is distributed WITHOUT ANY WARRANTY; without even 11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 12 PURPOSE. See the above copyright notice for more information. 13 14 =========================================================================*/ 15 // .NAME vtkGDALVectorReader - Read vector file formats using GDAL. 16 // .SECTION Description 17 // vtkGDALVectorReader is a source object that reads vector files and uses 18 // GDAL as the underlying library for the task. GDAL is required for this 19 // reader. The output of the reader is a vtkMultiBlockDataSet 20 // 21 // This filter uses the ActiveLayer member to only load entries from the 22 // specified layer (when ActiveLayer >= 0). 23 // 24 // .SECTION See Also 25 // vtkMultiBlockDataSet 26 27 #ifndef vtkGDALVectorReader_h 28 #define vtkGDALVectorReader_h 29 30 #include "vtkMultiBlockDataSetAlgorithm.h" 31 #include "vtkIOGDALModule.h" // For export macro 32 33 #include <map> // STL required. 34 35 class VTKIOGDAL_EXPORT vtkGDALVectorReader : public vtkMultiBlockDataSetAlgorithm 36 { 37 public: 38 static vtkGDALVectorReader* New(); 39 virtual void PrintSelf( ostream& os, vtkIndent indent ); 40 vtkTypeMacro(vtkGDALVectorReader,vtkMultiBlockDataSetAlgorithm); 41 42 vtkSetStringMacro(FileName); 43 vtkGetStringMacro(FileName); 44 45 // Description: 46 // Return number of layers. 47 int GetNumberOfLayers(); 48 49 // Description: 50 // Given a index return layer type (eg point, line, polygon). 51 int GetLayerType(int layerIndex=0); 52 53 // Description: 54 // Given a layer index return number of features (shapes). 55 int GetFeatureCount(int layerIndex=0); 56 57 // Description: 58 // Return the active layer type (eg point, line, polygon). 59 int GetActiveLayerType(); 60 61 // Description: 62 // Return the number of features in the active layer (shapes). 63 int GetActiveLayerFeatureCount(); 64 65 // Description: 66 // Set and Get the active layer. 67 // If ActiveLayer is less than 0 (the default is -1), then all 68 // layers are read. Otherwise, only the specified layer is read. 69 vtkSetMacro(ActiveLayer,int); 70 vtkGetMacro(ActiveLayer,int); 71 72 // Description: 73 // Set and Get whether features are appended to a single 74 // vtkPolyData. Turning the option on is useful when a shapefile has 75 // a number of features which could otherwise lead to a huge 76 // multiblock structure. 77 vtkSetMacro(AppendFeatures, int); 78 vtkGetMacro(AppendFeatures, int); 79 vtkBooleanMacro(AppendFeatures, int); 80 81 //BTX 82 // Description: 83 // Return projection string belong to each layer. 84 std::map<int, std::string> GetLayersProjection(); 85 //ETX 86 87 // Description: 88 // Return projection string belong to a layer. 89 const char* GetLayerProjection(int layerIndex); 90 91 // Description: 92 // Set/get whether feature IDs should be generated. 93 // Some GDAL primitives (e.g., a polygon with a hole 94 // in its interior) are represented by multiple VTK 95 // cells. If you wish to identify the primitive 96 // responsible for a VTK cell, turn this on. It is 97 // off by default for backwards compatibility. 98 // The array of feature IDs will be the active 99 // cell-data pedigree IDs. 100 vtkSetMacro(AddFeatureIds,int); 101 vtkGetMacro(AddFeatureIds,int); 102 vtkBooleanMacro(AddFeatureIds,int); 103 104 protected: 105 vtkGDALVectorReader(); 106 virtual ~vtkGDALVectorReader(); 107 108 int RequestInformation( vtkInformation*, vtkInformationVector**, vtkInformationVector* ); 109 int RequestData( vtkInformation*, vtkInformationVector**, vtkInformationVector* ); 110 111 int InitializeInternal(); 112 113 /// The name of the file that will be opened on the next call to RequestData() 114 char* FileName; 115 116 int ActiveLayer; 117 int AppendFeatures; 118 int AddFeatureIds; 119 120 //BTX 121 class Internal; 122 123 /// Private per-file metadata 124 vtkGDALVectorReader::Internal* Implementation; 125 126 /// Global variable indicating whether the OGR library has been registered yet or not. 127 static int OGRRegistered; 128 129 /// Mapping of layer to projection. 130 std::map<int, std::string> LayersProjection; 131 //ETX 132 133 private: 134 vtkGDALVectorReader(const vtkGDALVectorReader&); // Not implemented. 135 void operator=(const vtkGDALVectorReader&); // Not implemented. 136 }; 137 138 #endif // vtkGDALVectorReader_h 139