Routino SVN Repository Browser

Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino

ViewVC logotype

Contents of /trunk/src/ways.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 32 - (show annotations) (download) (as text)
Sun Jan 11 09:33:59 2009 UTC (16 years, 2 months ago) by amb
File MIME type: text/x-chdr
File size: 3350 byte(s)
Some small changes to the nodes, segments and ways functions.

1 /***************************************
2 $Header: /home/amb/CVS/routino/src/ways.h,v 1.5 2009-01-11 09:33:59 amb Exp $
3
4 A header file for the ways.
5 ******************/ /******************
6 Written by Andrew M. Bishop
7
8 This file Copyright 2009 Andrew M. Bishop
9 It may be distributed under the GNU Public License, version 2, or
10 any higher version. See section COPYING of the GNU Public license
11 for conditions under which this file may be redistributed.
12 ***************************************/
13
14
15 #ifndef WAYS_H
16 #define WAYS_H /*+ To stop multiple inclusions. +*/
17
18 #include <stdint.h>
19
20
21 /* Constants */
22
23
24 #if 1 /* set to 0 to use a flat array, 1 for indexed. */
25
26 /*+ The number of bins for ways. +*/
27 #define NBINS_WAYS 1024
28
29 #else
30
31 #undef NBINS_WAYS
32
33 #endif
34
35 /*+ The array size increment for ways. +*/
36 #define INCREMENT_WAYS 256*1024
37
38
39 /* Simple Types */
40
41
42 /*+ A way identifier. +*/
43 typedef uint32_t way_t;
44
45 /*+ The speed limit of the way. +*/
46 typedef uint8_t speed_t;
47
48 /*+ A way type identifier. +*/
49 typedef uint16_t waytype_t;
50
51 typedef enum _WayType
52 {
53 Way_Motorway =1,
54 Way_Trunk =2,
55 Way_Primary =3,
56 Way_Tertiary =4,
57 Way_Secondary =5,
58 Way_Unclassfied=6,
59 Way_Residential=7,
60
61 Way_HighestRoutable=7,
62
63 Way_Service =8,
64 Way_Track =9,
65 Way_Bridleway =10,
66 Way_Cycleway =11,
67 Way_Footway =12,
68 Way_Unknown =15,
69 }
70 WayType;
71
72 #define Way_TYPE(xx) ((xx)&0x0f)
73
74 #define Way_ONEWAY 16
75 #define Way_ROUNDABOUT 32
76 #define Way_NOTROUTABLE 128
77
78
79 /* Data structures */
80
81
82 /*+ A structure containing a single way. +*/
83 typedef struct _Way
84 {
85 way_t id; /*+ The way identifier. +*/
86 uint32_t name; /*+ An offset of the name of the way in the ways array. +*/
87 speed_t limit; /*+ The defined speed limit on the way. +*/
88 speed_t speed; /*+ The assumed speed limit on the way. +*/
89 waytype_t type; /*+ The type of the way. +*/
90 }
91 Way;
92
93 /*+ A structure containing a set of ways (mmap format). +*/
94 typedef struct _Ways
95 {
96 uint32_t number; /*+ How many entries are used? +*/
97 #ifdef NBINS_WAYS
98 uint32_t offset[NBINS_WAYS+1]; /*+ An offset to the first entry in each bin. +*/
99 #endif
100 Way ways[1]; /*+ An array of ways whose size is not limited to 1
101 (i.e. may overflow the end of this structure). +*/
102 }
103 Ways;
104
105 /*+ A structure containing a set of ways (memory format). +*/
106 typedef struct _WaysMem
107 {
108 uint32_t alloced; /*+ How many entries are allocated? +*/
109 uint32_t number; /*+ How many entries are used? +*/
110 uint32_t number_str; /*+ How many name entries are used? +*/
111 uint32_t sorted; /*+ Is the data sorted and therefore searchable? +*/
112
113 Ways *ways; /*+ The real data +*/
114 char **names; /*+ An array of names. +*/
115 }
116 WaysMem;
117
118
119 /* Functions */
120
121
122 WaysMem *NewWayList(void);
123
124 Ways *LoadWayList(const char *filename);
125 Ways *SaveWayList(WaysMem *ways,const char *filename);
126
127 Way *FindWay(Ways *ways,way_t id);
128
129 Way *AppendWay(WaysMem *ways,way_t id,const char *name);
130
131 void SortWayList(WaysMem *ways);
132
133 WayType TypeOfWay(const char *type);
134
135 #define LookupWay(xxx,yyy) (&xxx->ways[yyy])
136
137 #define WayName(xxx,yyy) ((char*)&xxx->ways[yyy->name])
138
139
140 #endif /* WAYS_H */

Properties

Name Value
cvs:description Header file for ways.