File: wkb.h

package info (click to toggle)
postgis 1.3.3-3
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 10,468 kB
  • ctags: 4,310
  • sloc: sql: 73,321; ansic: 35,513; xml: 6,160; java: 6,061; sh: 3,428; perl: 1,447; cpp: 987; makefile: 727; yacc: 276; python: 192
file content (119 lines) | stat: -rw-r--r-- 2,492 bytes parent folder | download | duplicates (2)
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
#include <inttypes.h>

/*
 * OGC WellKnownBinaryGeometry
 */

/*
 * 3d geometries are encode as in OGR by adding WKB3DOFFSET to the type.  
 */
#define WKB3DOFFSET 0x80000000

typedef unsigned char byte;
typedef uint32_t uint32;

typedef struct Point_t {
	double x;
	double y;
	double z;
} Point;

typedef struct LinearRing_t {
	uint32    numPoints;
	Point    points[1]; // [numPoints]
} LinearRing; 

enum wkbGeometryType {
	wkbPoint = 1,
	wkbLineString = 2,
	wkbPolygon = 3,
	wkbMultiPoint = 4,
	wkbMultiLineString = 5,
	wkbMultiPolygon = 6,
	wkbGeometryCollection = 7
};

enum wkbByteOrder {
	wkbXDR = 0,    // Big Endian
	wkbNDR = 1    // Little Endian
};

typedef struct WKBPoint_t {
	byte    byteOrder;
	uint32    wkbType;     // 1
	Point    point;
} WKBPoint;

typedef struct WKBLineString_t {
	byte    byteOrder;
	uint32    wkbType;    // 2
	uint32    numPoints;
	Point    points[1]; // [numPoints]
} WKBLineString;

typedef struct WKBPolygon_t {
	byte    byteOrder;
	uint32    wkbType;    // 3
	uint32    numRings;
	LinearRing    rings[1]; // [numRings]
} WKBPolygon;

typedef struct WKBMultiPoint_t {
	byte    byteOrder;
	uint32    wkbType;       // 4
	uint32    num_wkbPoints;
	WKBPoint    WKBPoints[1]; // [num_wkbPoints];
} WKBMultiPoint;

typedef struct WKBMultiLineString_t {
	byte    byteOrder;
	uint32    wkbType;    // 5
	uint32    num_wkbLineStrings;
	WKBLineString    WKBLineStrings[1]; // [num_wkbLineStrings];
} WKBMultiLineString;

typedef struct WKBMultiPolygon_t {
	byte    byteOrder;
	uint32    wkbType;    // 6
	uint32    num_wkbPolygons;
	WKBPolygon    wkbPolygons[1]; // [num_wkbPolygons];
} WKBMultiPolygon;

typedef struct WKBGeometryCollection_t {
	byte    byteOrder;
	uint32    wkbType;    // 7
	uint32    num_wkbGeometries;
	char    wkbGeometries[1]; // WKBGeometry [num_wkbGeometries];
} WKBGeometryCollection;

#if 0
typedef struct WKBGeometry_t {
	union {
		WKBPoint    point;
		WKBLineString    linestring;
		WKBPolygon    polygon;
		WKBGeometryCollection    collection;
		WKBMultiPoint    mpoint;
		WKBMultiLineString    mlinestring;
		WKBMultiPolygon    mpolygon;
	};
} WKBGeometry;
#endif

typedef struct WKBGeometry_t {
	byte    byteOrder;
	uint32    wkbType;
} WKBGeometry;

/* Functions prototype */
char getbyte(char *c);
void skipbyte(char **c);
char popbyte(char **c);
int popint(char **c);
int getint(char *c);
void skipint(char **c);
double popdouble(char **c);
double getdouble(char *c);
void skipdouble(char **c);
void dump_wkb(char *wkb);