-
Notifications
You must be signed in to change notification settings - Fork 0
/
lwin_twkb.h
55 lines (42 loc) · 1.48 KB
/
lwin_twkb.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
/**********************************************************************
*
* PostGIS - Spatial Types for PostgreSQL
*
*
* Copyright (C) 2015 Paul Ramsey
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU General Public Licence. See the LICENCE file.
**********************************************************************/
#include <math.h>
#include "pg_twkb.h"
#define TWKB_IN_MAXCOORDS 4
/**
* Used for passing the parse state between the parsing functions.
*/
typedef struct
{
/* Pointers to the bytes */
uint8_t *twkb; /* Points to start of TWKB */
uint8_t *twkb_end; /* Points to end of TWKB */
uint8_t *pos; /* Current read position */
uint32_t check; /* Simple validity checks on geometries */
uint32_t lwtype; /* Current type we are handling */
uint8_t has_bbox;
uint8_t has_size;
uint8_t has_idlist;
uint8_t has_z;
uint8_t has_m;
uint8_t is_empty;
/* Precision factors to convert ints to double */
double factor;
double factor_z;
double factor_m;
uint64_t size;
/* Info about current geometry */
uint8_t magic_byte; /* the magic byte contain info about if twkb contain id, size info, bboxes and precision */
int ndims; /* Number of dimensions */
int64_t *coords; /* An array to keep delta values from 4 dimensions */
} twkb_parse_state;
void header_from_twkb_state(twkb_parse_state *s);
double twkb_parse_state_double(twkb_parse_state *s, double factor);