-
Notifications
You must be signed in to change notification settings - Fork 23
/
PolygonHandle.h
144 lines (117 loc) · 3.6 KB
/
PolygonHandle.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
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
/*
Copyright (c) 2009-2022,
Ken Arroyo Ohori [email protected]
Hugo Ledoux [email protected]
Martijn Meijers [email protected]
All rights reserved.
This file is part of pprepair: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Licensees holding a valid commercial license may use this file in
accordance with the commercial license agreement provided with
the software.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef POLYGONHANDLE_H
#define POLYGONHANDLE_H
#include "definitions/definitions.h"
// Abstract class to store different types of attributes
class Field {
public:
// Destructor
virtual ~Field() = 0;
// Find the type of field
const virtual OGRFieldType getType() const = 0;
// Comparison
bool operator<(Field &f) const;
bool operator==(Field &f) const;
// Getters
virtual const char * getValueAsString();
virtual double getValueAsDouble();
virtual int getValueAsInt();
// Setters
virtual void setValueFromString(const char *v);
virtual void setValueFromDouble(double v);
virtual void setValueFromInt(int v);
};
// Specific classes
class StringField : public Field {
public:
StringField(const char *v);
~StringField();
bool operator<(const StringField &f) const;
bool operator==(const StringField &f) const;
const OGRFieldType getType() const;
const char * getValueAsString();
void setValueFromString(const char *v);
private:
char * contents;
};
class DoubleField : public Field {
public:
DoubleField(double v);
bool operator<(const DoubleField &f) const;
bool operator==(const DoubleField &f) const;
const OGRFieldType getType() const;
double getValueAsDouble();
void setValueFromDouble(double v);
private:
double contents;
};
class IntField : public Field {
public:
IntField(int v);
bool operator<(const IntField &f) const;
bool operator==(const IntField &f) const;
const OGRFieldType getType() const;
int getValueAsInt();
void setValueFromInt(int v);
private:
int contents;
};
// Store a tag
class PolygonHandle {
public:
// Constructors and destructors
PolygonHandle(unsigned int si = 0, char *of = NULL, unsigned int l = 0, long fid = 0);
virtual ~PolygonHandle();
// References
char * getOriginalFile();
unsigned int getLayer();
// Field information
void addField(Field *field);
Field * getSchemaField();
Field * getField(unsigned int i);
unsigned long getNumberOfFields();
// Checking whether it's a MultiPolygonHandle
virtual const bool isMultiPolygonHandle();
protected:
char *originalFile;
unsigned int layer;
//long featureID;
// The field to use as schema
// (could be changed to a set or regex to represent complex criteria)
unsigned int schemaIndex;
// Fields it contains
std::vector<Field *> fields;
};
// Trick to save memory when multiple tags are not present
class MultiPolygonHandle : public PolygonHandle {
public:
// Constructor. No need to start with less than two
MultiPolygonHandle(PolygonHandle *ph);
~MultiPolygonHandle();
// Checking whether it's a MultiPolygonHandle
virtual const bool isMultiPolygonHandle();
// Access functions to the individual PolygonHandles
bool hasHandle(PolygonHandle *handle);
void addHandle(PolygonHandle *handle);
const std::list<PolygonHandle *> *getHandles();
unsigned long numberOfHandles();
private:
std::list<PolygonHandle *> handles;
};
#endif