-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgeojson.hh
100 lines (80 loc) · 2.12 KB
/
geojson.hh
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
#ifndef GEO_JSON_HH
#define GEO_JSON_HH
#ifdef WT_BUILDING
#include "Wt/WDllDefs.h"
#else
#ifndef WT_API
#define WT_API
#endif
#endif
#include <string>
#include <vector>
#include "gason.h"
/////////////////////////////////////////////////////////////////////////////////////////////////////
//coord_t
/////////////////////////////////////////////////////////////////////////////////////////////////////
class coord_t
{
public:
coord_t(double x_, double y_) :
x(x_),
y(y_)
{
}
double x;
double y;
};
///////////////////////////////////////////////////////////////////////////////////////
//polygon_t
///////////////////////////////////////////////////////////////////////////////////////
class polygon_t
{
public:
polygon_t()
{};
std::vector<coord_t> m_coord;
};
///////////////////////////////////////////////////////////////////////////////////////
//geometry_t
///////////////////////////////////////////////////////////////////////////////////////
class geometry_t
{
public:
geometry_t()
{};
std::string m_type; //"Polygon", "Point"
std::vector<polygon_t> m_polygons;
};
///////////////////////////////////////////////////////////////////////////////////////
//feature_t
///////////////////////////////////////////////////////////////////////////////////////
class feature_t
{
public:
feature_t()
{};
std::string m_name;
std::vector<geometry_t> m_geometry;
};
/////////////////////////////////////////////////////////////////////////////////////////////////////
//geojson_t
/////////////////////////////////////////////////////////////////////////////////////////////////////
class WT_API geojson_t
{
public:
geojson_t()
{
}
int convert(const char* file_name);
//storage is a list of features
std::vector<feature_t> m_feature;
private:
int parse_root(JsonValue value);
int parse_features(JsonValue value);
int parse_feature(JsonValue value);
int parse_geometry(JsonValue value, feature_t &feature);
int parse_coordinates(JsonValue value, const std::string &type, feature_t &feature);
int dump_value(JsonValue value, int indent = 0);
void dump_string(const char *s);
};
#endif