-
Notifications
You must be signed in to change notification settings - Fork 412
Expand file tree
/
Copy pathGeoJSON.h
More file actions
154 lines (106 loc) · 3.42 KB
/
Copy pathGeoJSON.h
File metadata and controls
154 lines (106 loc) · 3.42 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2021 Jared Erickson
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************/
#pragma once
#include <geos/export.h>
#include <map>
#include <vector>
#include <string>
#include <sstream>
#include <cctype>
#include <cstddef>
#include <geos/geom/Geometry.h>
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
#endif
namespace geos {
namespace geom {
class Geometry;
}
}
namespace geos {
namespace io {
class GEOS_DLL GeoJSONValue {
private:
enum class Type { NUMBER, STRING, NULLTYPE, BOOLEAN, OBJECT, ARRAY };
Type type;
union {
double d;
std::string s;
std::nullptr_t n;
bool b;
std::map<std::string, GeoJSONValue> o;
std::vector<GeoJSONValue> a;
};
void cleanup();
public:
struct GeoJSONTypeError {};
GeoJSONValue(double);
GeoJSONValue(const std::string&);
GeoJSONValue();
GeoJSONValue(bool);
GeoJSONValue(const std::map<std::string, GeoJSONValue>&);
GeoJSONValue(const std::vector<GeoJSONValue>&);
~GeoJSONValue();
GeoJSONValue(const GeoJSONValue&);
GeoJSONValue& operator=(const GeoJSONValue&);
double getNumber() const;
const std::string& getString() const;
std::nullptr_t getNull() const;
bool getBoolean() const;
const std::map<std::string, GeoJSONValue>& getObject() const;
const std::vector<GeoJSONValue>& getArray() const;
bool isNumber() const;
bool isString() const;
bool isNull() const;
bool isBoolean() const;
bool isObject() const;
bool isArray() const;
};
class GEOS_DLL GeoJSONFeature {
public:
GeoJSONFeature(std::unique_ptr<geom::Geometry> g,
const std::map<std::string, GeoJSONValue>& p);
GeoJSONFeature(std::unique_ptr<geom::Geometry> g,
std::map<std::string, GeoJSONValue>&& p);
GeoJSONFeature(std::unique_ptr<geom::Geometry> g,
const std::map<std::string, GeoJSONValue>& p,
const std::string& id);
GeoJSONFeature(std::unique_ptr<geom::Geometry> g,
std::map<std::string, GeoJSONValue>&& p, std::string id);
GeoJSONFeature(GeoJSONFeature const& other);
GeoJSONFeature(GeoJSONFeature&& other);
GeoJSONFeature& operator=(const GeoJSONFeature&);
GeoJSONFeature& operator=(GeoJSONFeature&&);
const geom::Geometry* getGeometry() const;
const std::map<std::string, GeoJSONValue>& getProperties() const;
const std::string& getId() const;
private:
std::unique_ptr<geom::Geometry> geometry;
std::map<std::string, GeoJSONValue> properties;
std::string id;
};
class GEOS_DLL GeoJSONFeatureCollection {
public:
GeoJSONFeatureCollection(const std::vector<GeoJSONFeature>& f);
GeoJSONFeatureCollection(std::vector<GeoJSONFeature>&& f);
const std::vector<GeoJSONFeature>& getFeatures() const;
private:
std::vector<GeoJSONFeature> features;
};
} // namespace geos::io
} // namespace geos
#ifdef _MSC_VER
#pragma warning(pop)
#endif