/
tileData.h
101 lines (66 loc) · 2.48 KB
/
tileData.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
#pragma once
#include "glm/vec3.hpp"
#include "data/properties.h"
#include <vector>
#include <string>
/*
Tile Coordinates:
A point in the geometry of a tile is represented with 32-bit floating point
x, y, and z coordinates. Coordinates represent normalized displacement from
the origin (i.e. lower-left corner) of a tile.
(0.0, 1.0) ---------- (1.0, 1.0)
| | N
^ +y | W <|> E
| | S
| +x |
(0.0, 0.0) ----->---- (1.0, 0.0)
Coordinates that fall outside the range [0.0, 1.0] are permissible, as tile
servers may choose not to clip certain geometries to tile boundaries, but these
points are clipped in the client-side geometry processing.
Z coordinates are expected to be normalized to the same scale as x, y coordinates.
Data heirarchy:
TileData is a heirarchical container of structs modeled after the geoJSON spec:
http://geojson.org/geojson-spec.html
A <TileData> contains a collection of <Layer>s
A <Layer> contains a name and a collection of <Feature>s
A <Feature> contains a <GeometryType> denoting what variety of geometry is
contained in the feature, a <Properties> struct describing the feature, and
one collection each of <Point>s, <Line>s, and <Polygon>s. Only the geometry
collection corresponding to the feature's geometryType should contain data.
A <Properties> contains a sorted vector of key-value pairs storing the
properties of a <Feature>
A <Polygon> is a collection of <Line>s representing the contours of a polygon.
Contour winding rules follow the conventions of the OpenGL red book described
here: http://www.glprogramming.com/red/chapter11.html
A <Line> is a collection of <Point>s.
A <Point> is 3 32-bit floating point coordinates representing x, y, and z
(in that order).
*/
namespace Tangram {
enum GeometryType {
unknown,
points,
lines,
polygons
};
typedef glm::vec3 Point;
typedef std::vector<Point> Line;
typedef std::vector<Line> Polygon;
struct Feature {
Feature() {}
Feature(int32_t _sourceId) { props.sourceId = _sourceId; }
GeometryType geometryType = GeometryType::polygons;
std::vector<Point> points;
std::vector<Line> lines;
std::vector<Polygon> polygons;
Properties props;
};
struct Layer {
Layer(const std::string& _name) : name(_name) {}
std::string name;
std::vector<Feature> features;
};
struct TileData {
std::vector<Layer> layers;
};
}