Smrender
 All Data Structures Files Functions Variables Macros
osm_inplace.h
1 /* Copyright 2011-2015 Bernhard R. Fischer, 2048R/5C5FFD47 <bf@abenteuerland.at>
2  *
3  * This file is part of Smrender (originally Smfilter).
4  *
5  * Smrender is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, version 3 of the License.
8  *
9  * Smrender is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with Smrender. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef OSM_INPLACE_H
19 #define OSM_INPLACE_H
20 
21 #include <stdint.h>
22 #include <time.h>
23 
24 #include "bstring.h"
25 
26 
27 #define JAN2004 1072915200
28 
29 #define get_v(x,y) get_value("v",x,y)
30 
31 enum {OSM_NA, OSM_NODE, OSM_WAY, OSM_REL};
32 enum {ROLE_NA, ROLE_EMPTY, ROLE_INNER, ROLE_OUTER, ROLE_VIA, ROLE_FROM,
33  ROLE_TO, ROLE_LINK, ROLE_FORWARD, ROLE_BACKWARD, ROLE_STOP, ROLE_LABEL,
34  ROLE_ADMIN_CENTRE, ROLE_FORWARD_STOP, ROLE_BACKWARD_STOP, ROLE_PLATFORM,
35  ROLE_MAIN_STREAM};
36 
37 
38 #define SIZEOF_OSM_OBJ(x) ((x)->type == OSM_NODE ? sizeof(osm_node_t) : \
39  (x)->type == OSM_WAY ? sizeof(osm_way_t) : \
40  (x)->type == OSM_REL ? sizeof(osm_rel_t) : 0)
41 
42 
43 struct otag
44 {
45  bstring_t k, v;
46 };
47 
48 typedef struct osm_obj
49 {
50  short type;
51  short vis;
52  int64_t id;
53  int ver, cs, uid;
54  time_t tim;
55  short tag_cnt;
56  struct otag *otag;
57 } osm_obj_t;
58 
59 typedef struct osm_node
60 {
61  osm_obj_t obj;
62  double lat, lon;
63 } osm_node_t;
64 
65 typedef struct osm_way
66 {
67  osm_obj_t obj;
68  int ref_cnt;
69  int64_t *ref;
70 } osm_way_t;
71 
72 struct rmember
73 {
74  short type;
75  int64_t id;
76  short role;
77 };
78 
79 typedef struct osm_rel
80 {
81  osm_obj_t obj;
82  short mem_cnt;
83  struct rmember *mem;
84 } osm_rel_t;
85 
86 typedef union osm_storage
87 {
88  osm_obj_t o;
89  osm_node_t n;
90  osm_way_t w;
91  osm_rel_t r;
93 
94 
95 time_t parse_time(bstring_t);
96 void free_obj(osm_obj_t*);
97 osm_node_t *malloc_node(short );
98 osm_way_t *malloc_way(short , int );
99 osm_rel_t *malloc_rel(short , short );
100 size_t onode_mem(void);
101 size_t onode_freed(void);
102 void osm_obj_default(osm_obj_t *);
103 void osm_way_default(osm_way_t *);
104 void osm_node_default(osm_node_t *);
105 const char *role_str(int );
106 int strrole(const bstring_t *);
107 const char *type_str(int );
108 
109 #endif
110 
Definition: osm_inplace.h:72
Definition: osm_inplace.h:48
Definition: osm_inplace.h:86
Definition: osm_inplace.h:59
Definition: osm_inplace.h:43
Definition: osm_inplace.h:79
Definition: bstring.h:28
Definition: osm_inplace.h:65