VTK
vtkGeoJSONFeature.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkGeoJSONFeature.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 =========================================================================*/
23 #ifndef vtkGeoJSONFeature_h
24 #define vtkGeoJSONFeature_h
25 
26 // VTK Includes
27 #include "vtkDataObject.h"
28 #include "vtkIOGeoJSONModule.h" // For export macro
29 #include "vtk_jsoncpp.h" // For json parser
30 
31 class vtkPolyData;
32 
33 // Currently implemented geoJSON compatible Geometries
34 #define GeoJSON_POINT "Point"
35 #define GeoJSON_MULTI_POINT "MultiPoint"
36 #define GeoJSON_LINE_STRING "LineString"
37 #define GeoJSON_MULTI_LINE_STRING "MultiLineString"
38 #define GeoJSON_POLYGON "Polygon"
39 #define GeoJSON_MULTI_POLYGON "MultiPolygon"
40 #define GeoJSON_GEOMETRY_COLLECTION "GeometryCollection"
41 
42 class VTKIOGEOJSON_EXPORT vtkGeoJSONFeature : public vtkDataObject
43 {
44 public:
45  static vtkGeoJSONFeature* New();
46  virtual void PrintSelf(ostream& os, vtkIndent indent) override;
48 
50 
55  vtkSetMacro(OutlinePolygons, bool);
56  vtkGetMacro(OutlinePolygons, bool);
57  vtkBooleanMacro(OutlinePolygons, bool);
59 
64  void ExtractGeoJSONFeature(const Json::Value& root, vtkPolyData* outputData);
65 
66 protected:
68  ~vtkGeoJSONFeature() override;
69 
74  Json::Value featureRoot;
75 
79  char* FeatureId;
80 
86 
90  void ExtractGeoJSONFeatureGeometry(const Json::Value& root, vtkPolyData* outputData);
91 
93 
96  vtkPolyData* ExtractPoint(const Json::Value& coordinates, vtkPolyData* outputData);
97  vtkPolyData* ExtractLineString(const Json::Value& coordinates, vtkPolyData* outputData);
98  vtkPolyData* ExtractPolygon(const Json::Value& coordinates, vtkPolyData* outputData);
100 
102 
105  vtkPolyData* ExtractMultiPoint(const Json::Value& coordinates, vtkPolyData* outputData);
106  vtkPolyData* ExtractMultiLineString(const Json::Value& coordinates, vtkPolyData* outputData);
107  vtkPolyData* ExtractMultiPolygon(const Json::Value& coordinates, vtkPolyData* outputData);
109 
111 
115  bool IsPoint(const Json::Value& root);
116  bool IsMultiPoint(const Json::Value& root);
117  bool IsLineString(const Json::Value& root); // To Do.
118  bool IsMultiLineString(const Json::Value& root); // To Do.
119  bool IsPolygon(const Json::Value& root); // To Do.
120  bool IsMultiPolygon(const Json::Value& root); // To Do.
122 
126  bool CreatePoint(const Json::Value& coordinates, double point[3]);
127 
128  void InsertFeatureProperties(vtkPolyData* outputData);
129 
130 private:
131  vtkGeoJSONFeature(const vtkGeoJSONFeature&) = delete;
132  void operator=(const vtkGeoJSONFeature&) = delete;
133 };
134 
135 #endif // vtkGeoJSONFeature_h
vtkDataObject::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkX3D::point
Definition: vtkX3D.h:242
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkGeoJSONFeature::featureRoot
Json::Value featureRoot
Json::Value featureRoot corresponds to the root of the geoJSON feature from which the geometry and pr...
Definition: vtkGeoJSONFeature.h:74
vtkGeoJSONFeature::OutlinePolygons
bool OutlinePolygons
Set/get option to generate the border outlining each polygon, so that the output cells are polyine da...
Definition: vtkGeoJSONFeature.h:85
vtkGeoJSONFeature::FeatureId
char * FeatureId
Id of current GeoJSON feature being parsed.
Definition: vtkGeoJSONFeature.h:79
vtkDataObject.h
vtkGeoJSONFeature
Represents GeoJSON feature geometry & properties.
Definition: vtkGeoJSONFeature.h:42
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
vtkDataObject
general representation of visualization data
Definition: vtkDataObject.h:58
vtkDataObject::New
static vtkDataObject * New()