VTK  9.1.0
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
31class 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
42class VTKIOGEOJSON_EXPORT vtkGeoJSONFeature : public vtkDataObject
43{
44public:
46 void PrintSelf(ostream& os, vtkIndent indent) override;
48
52 int GetDataObjectType() override { return VTK_GEO_JSON_FEATURE; }
53
55
60 vtkSetMacro(OutlinePolygons, bool);
61 vtkGetMacro(OutlinePolygons, bool);
62 vtkBooleanMacro(OutlinePolygons, bool);
64
69 void ExtractGeoJSONFeature(const Json::Value& root, vtkPolyData* outputData);
70
71protected:
74
79 Json::Value featureRoot;
80
84 char* FeatureId;
85
91
95 void ExtractGeoJSONFeatureGeometry(const Json::Value& root, vtkPolyData* outputData);
96
98
101 vtkPolyData* ExtractPoint(const Json::Value& coordinates, vtkPolyData* outputData);
102 vtkPolyData* ExtractLineString(const Json::Value& coordinates, vtkPolyData* outputData);
103 vtkPolyData* ExtractPolygon(const Json::Value& coordinates, vtkPolyData* outputData);
105
107
110 vtkPolyData* ExtractMultiPoint(const Json::Value& coordinates, vtkPolyData* outputData);
111 vtkPolyData* ExtractMultiLineString(const Json::Value& coordinates, vtkPolyData* outputData);
112 vtkPolyData* ExtractMultiPolygon(const Json::Value& coordinates, vtkPolyData* outputData);
114
116
120 bool IsPoint(const Json::Value& root);
121 bool IsMultiPoint(const Json::Value& root);
122 bool IsLineString(const Json::Value& root); // To Do.
123 bool IsMultiLineString(const Json::Value& root); // To Do.
124 bool IsPolygon(const Json::Value& root); // To Do.
125 bool IsMultiPolygon(const Json::Value& root); // To Do.
127
131 bool CreatePoint(const Json::Value& coordinates, double point[3]);
132
134
135private:
136 vtkGeoJSONFeature(const vtkGeoJSONFeature&) = delete;
137 void operator=(const vtkGeoJSONFeature&) = delete;
138};
139
140#endif // vtkGeoJSONFeature_h
general representation of visualization data
Represents GeoJSON feature geometry & properties.
vtkPolyData * ExtractMultiLineString(const Json::Value &coordinates, vtkPolyData *outputData)
extractMultiXXXX extracts an array of geometries XXXX into the outputData
void InsertFeatureProperties(vtkPolyData *outputData)
char * FeatureId
Id of current GeoJSON feature being parsed.
static vtkGeoJSONFeature * New()
bool IsPoint(const Json::Value &root)
Check if the root contains corresponding appropriate geometry in the Jsoncpp root.
bool IsPolygon(const Json::Value &root)
Check if the root contains corresponding appropriate geometry in the Jsoncpp root.
void ExtractGeoJSONFeature(const Json::Value &root, vtkPolyData *outputData)
Extract the geometry corresponding to the geoJSON feature stored at root Assign any feature propertie...
bool IsMultiLineString(const Json::Value &root)
Check if the root contains corresponding appropriate geometry in the Jsoncpp root.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Json::Value featureRoot
Json::Value featureRoot corresponds to the root of the geoJSON feature from which the geometry and pr...
vtkPolyData * ExtractPolygon(const Json::Value &coordinates, vtkPolyData *outputData)
In extractXXXX() Extract geoJSON geometries XXXX into outputData.
bool IsMultiPoint(const Json::Value &root)
Check if the root contains corresponding appropriate geometry in the Jsoncpp root.
bool CreatePoint(const Json::Value &coordinates, double point[3])
Point[] from its JSON equivalent.
bool IsLineString(const Json::Value &root)
Check if the root contains corresponding appropriate geometry in the Jsoncpp root.
vtkPolyData * ExtractMultiPoint(const Json::Value &coordinates, vtkPolyData *outputData)
extractMultiXXXX extracts an array of geometries XXXX into the outputData
bool OutlinePolygons
Set/get option to generate the border outlining each polygon, so that the output cells are polyine da...
int GetDataObjectType() override
Returns VTK_GEO_JSON_FEATURE.
vtkPolyData * ExtractMultiPolygon(const Json::Value &coordinates, vtkPolyData *outputData)
extractMultiXXXX extracts an array of geometries XXXX into the outputData
~vtkGeoJSONFeature() override
vtkPolyData * ExtractPoint(const Json::Value &coordinates, vtkPolyData *outputData)
In extractXXXX() Extract geoJSON geometries XXXX into outputData.
void ExtractGeoJSONFeatureGeometry(const Json::Value &root, vtkPolyData *outputData)
Extract geoJSON geometry into vtkPolyData *.
vtkPolyData * ExtractLineString(const Json::Value &coordinates, vtkPolyData *outputData)
In extractXXXX() Extract geoJSON geometries XXXX into outputData.
bool IsMultiPolygon(const Json::Value &root)
Check if the root contains corresponding appropriate geometry in the Jsoncpp root.
a simple class to control print indentation
Definition: vtkIndent.h:113
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:195
@ point
Definition: vtkX3D.h:242
#define VTK_GEO_JSON_FEATURE
Definition: vtkType.h:124