-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathvtkGeoJSONFeature.h
106 lines (84 loc) · 3.77 KB
/
vtkGeoJSONFeature.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*=========================================================================
Program: Visualization Toolkit
Module: vtkGeoJSONFeature.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkGeoJSONFeature - Convert GeoJSON objects/Geometries into vtkPolyData
// .SECTION Description
// Outputs a vtkPolyData containing geometry from the input
// Geo JSON data (http://www.geojson.org)
#ifndef __vtkGeoJSONFeature_h
#define __vtkGeoJSONFeature_h
// VTK Includes
#include "vtkDataObject.h"
#include "vtk_jsoncpp.h" // For json parser
class vtkPolyData;
class vtkStdString;
// Currently implemented geoJSON compatible Geometries
#define POINT "Point"
#define MULTI_POINT "MultiPoint"
#define LINE_STRING "LineString"
#define MULTI_LINE_STRING "MultiLineString"
#define POLYGON "Polygon"
#define MULTI_POLYGON "MultiPolygon"
#define GEOMETRY_COLLECTION "GeometryCollection"
class vtkGeoJSONFeature : public vtkDataObject
{
public:
static vtkGeoJSONFeature *New();
virtual void PrintSelf(ostream &os, vtkIndent indent);
vtkTypeMacro(vtkGeoJSONFeature,vtkDataObject);
// Description:
//Extract the geometry and properties corresponding to the geoJSON feature stored at root
void ExtractGeoJSONFeature(Json::Value root, vtkPolyData *outputData);
// Description:
//Return the vtkPolyData corresponding to the geoJSON feature stord in featureRoot
vtkPolyData *GetOutput();
protected:
vtkGeoJSONFeature();
~vtkGeoJSONFeature();
// Description:
// vtkPolyData containing the polydata generated from the geoJSON feature
vtkPolyData *outputData;
// Description:
// Json::Value featureRoot corresponds to the root of the geoJSON feature
// from which the geometry and properties are to be extracted
Json::Value featureRoot;
// Description:
// Extract geoJSON geometry into vtkPolyData *
void ExtractGeoJSONFeatureGeometry(Json::Value root, vtkPolyData *outputData);
// Description:
// In extractXXXX() Extract geoJSON geometries XXXX into outputData
vtkPolyData *ExtractPoint(Json::Value coordinates, vtkPolyData *outputData);
vtkPolyData *ExtractLineString(Json::Value coordinates, vtkPolyData *outputData);
vtkPolyData *ExtractPolygon(Json::Value coordinate, vtkPolyData *outputData);
// Description:
// extractMultiXXXX extracts an array of geometries XXXX into the outputData
vtkPolyData *ExtractMultiPoint(Json::Value coordinates, vtkPolyData *outputData);
vtkPolyData *ExtractMultiLineString(Json::Value coordinateArray, vtkPolyData *outputData);
vtkPolyData *ExtractMultiPolygon(Json::Value coordinateArray, vtkPolyData *outputData);
// Description:
// Check if the root contains corresponding appropriate geometry in the
// Jsoncpp root
bool IsPoint(Json::Value root);
bool IsMultiPoint(Json::Value root);
bool IsLineString(Json::Value root); //To Do.
bool IsMultiLineString(Json::Value root); //To Do.
bool IsPolygon(Json::Value root); //To Do.
bool IsMultiPolygon(Json::Value root); //To Do.
// Description:
// Point[] from its JSON equivalent
double *CreatePoint(Json::Value coordinates);
// Description:
// Case insensitive string comparison
bool IsEqual(vtkStdString str1, vtkStdString str2);
private:
vtkGeoJSONFeature(const vtkGeoJSONFeature&); //Not implemented
void operator=(const vtkGeoJSONFeature&); //Not implemented
};
#endif // __vtkGeoJSONFeature_h