-
Notifications
You must be signed in to change notification settings - Fork 237
/
Copy pathoutput_object.cpp
76 lines (65 loc) · 1.77 KB
/
output_object.cpp
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
/*
OutputObject - any object (node, linestring, polygon) to be outputted to tiles
*/
#include "output_object.h"
#include "helpers.h"
#include "coordinates_geom.h"
#include <iostream>
using namespace std;
namespace geom = boost::geometry;
// **********************************************************
std::ostream& operator<<(std::ostream& os, OutputGeometryType geomType)
{
switch(geomType) {
case POINT_:
os << "POINT";
break;
case LINESTRING_:
os << "LINESTRING";
break;
case MULTILINESTRING_:
os << "MULTILINESTRING";
break;
case POLYGON_:
os << "POLYGON";
break;
}
return os;
}
void OutputObject::writeAttributes(
const AttributeStore& attributeStore,
vtzero::feature_builder& fbuilder,
char zoom
) const {
auto attr = attributeStore.getUnsafe(attributes);
for(auto const &it: attr) {
if (it->minzoom > zoom) continue;
// TODO: consider taking a data view that is stable
// Look for key
const std::string& key = attributeStore.keyStore.getKeyUnsafe(it->keyIndex);
if (it->hasStringValue()) {
fbuilder.add_property(key, it->stringValue());
} else if (it->hasBoolValue()) {
fbuilder.add_property(key, it->boolValue());
} else if (it->hasFloatValue()) {
fbuilder.add_property(key, it->floatValue());
}
}
}
bool OutputObject::compatible(const OutputObject &other) {
return geomType == other.geomType &&
z_order == other.z_order &&
attributes == other.attributes;
}
// Comparision functions
bool operator==(const OutputObject& x, const OutputObject& y) {
return
x.layer == y.layer &&
x.z_order == y.z_order &&
x.geomType == y.geomType &&
x.attributes == y.attributes &&
x.objectID == y.objectID;
}
bool operator==(const OutputObjectID& x, const OutputObjectID& y) {
return x.oo == y.oo && x.id == y.id;
}