VTK  9.3.1
vtkGeoJSONFeature.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
11 #ifndef vtkGeoJSONFeature_h
12 #define vtkGeoJSONFeature_h
13 
14 // VTK Includes
15 #include "vtkDataObject.h"
16 #include "vtkIOGeoJSONModule.h" // For export macro
17 #include "vtk_jsoncpp.h" // For json parser
18 
19 VTK_ABI_NAMESPACE_BEGIN
20 class vtkPolyData;
21 
22 // Currently implemented geoJSON compatible Geometries
23 #define GeoJSON_POINT "Point"
24 #define GeoJSON_MULTI_POINT "MultiPoint"
25 #define GeoJSON_LINE_STRING "LineString"
26 #define GeoJSON_MULTI_LINE_STRING "MultiLineString"
27 #define GeoJSON_POLYGON "Polygon"
28 #define GeoJSON_MULTI_POLYGON "MultiPolygon"
29 #define GeoJSON_GEOMETRY_COLLECTION "GeometryCollection"
30 
31 class VTKIOGEOJSON_EXPORT vtkGeoJSONFeature : public vtkDataObject
32 {
33 public:
34  static vtkGeoJSONFeature* New();
35  void PrintSelf(ostream& os, vtkIndent indent) override;
37 
41  int GetDataObjectType() override { return VTK_GEO_JSON_FEATURE; }
42 
44 
49  vtkSetMacro(OutlinePolygons, bool);
50  vtkGetMacro(OutlinePolygons, bool);
51  vtkBooleanMacro(OutlinePolygons, bool);
53 
58  void ExtractGeoJSONFeature(const Json::Value& root, vtkPolyData* outputData);
59 
60 protected:
62  ~vtkGeoJSONFeature() override;
63 
68  Json::Value featureRoot;
69 
73  char* FeatureId;
74 
80 
84  void ExtractGeoJSONFeatureGeometry(const Json::Value& root, vtkPolyData* outputData);
85 
87 
90  vtkPolyData* ExtractPoint(const Json::Value& coordinates, vtkPolyData* outputData);
91  vtkPolyData* ExtractLineString(const Json::Value& coordinates, vtkPolyData* outputData);
92  vtkPolyData* ExtractPolygon(const Json::Value& coordinates, vtkPolyData* outputData);
94 
96 
99  vtkPolyData* ExtractMultiPoint(const Json::Value& coordinates, vtkPolyData* outputData);
100  vtkPolyData* ExtractMultiLineString(const Json::Value& coordinates, vtkPolyData* outputData);
101  vtkPolyData* ExtractMultiPolygon(const Json::Value& coordinates, vtkPolyData* outputData);
103 
105 
109  bool IsPoint(const Json::Value& root);
110  bool IsMultiPoint(const Json::Value& root);
111  bool IsLineString(const Json::Value& root); // To Do.
112  bool IsMultiLineString(const Json::Value& root); // To Do.
113  bool IsPolygon(const Json::Value& root); // To Do.
114  bool IsMultiPolygon(const Json::Value& root); // To Do.
116 
120  bool CreatePoint(const Json::Value& coordinates, double point[3]);
121 
122  void InsertFeatureProperties(vtkPolyData* outputData);
123 
124 private:
125  vtkGeoJSONFeature(const vtkGeoJSONFeature&) = delete;
126  void operator=(const vtkGeoJSONFeature&) = delete;
127 };
128 
129 VTK_ABI_NAMESPACE_END
130 #endif // vtkGeoJSONFeature_h
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static vtkDataObject * New()
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
int GetDataObjectType() override
Returns VTK_GEO_JSON_FEATURE.
Represents GeoJSON feature geometry & properties.
bool OutlinePolygons
Set/get option to generate the border outlining each polygon, so that the output cells are polyine da...
a simple class to control print indentation
Definition: vtkIndent.h:28
char * FeatureId
Id of current GeoJSON feature being parsed.
#define VTK_GEO_JSON_FEATURE
Definition: vtkType.h:112
Json::Value featureRoot
Json::Value featureRoot corresponds to the root of the geoJSON feature from which the geometry and pr...
general representation of visualization data
Definition: vtkDataObject.h:54