Routino SVN Repository Browser

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

ViewVC logotype

Annotation of /trunk/src/ways.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 65 - (hide annotations) (download) (as text)
Thu Jan 22 18:57:16 2009 UTC (16 years, 2 months ago) by amb
File MIME type: text/x-chdr
File size: 3766 byte(s)
Remove the choice of indexed or non-indexed data structures.

1 amb 21 /***************************************
2 amb 65 $Header: /home/amb/CVS/routino/src/ways.h,v 1.10 2009-01-22 18:57:16 amb Exp $
3 amb 21
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 amb 65 /*+ The number of bins for ways - expect ~1,000,000 ways and use 4*sqrt(N) bins. +*/
25     #define NBINS_WAYS 4096
26 amb 21
27 amb 65 /*+ The array size increment for ways - expect ~1,000,000 ways. +*/
28 amb 27 #define INCREMENT_WAYS 256*1024
29 amb 21
30 amb 27
31 amb 21 /* Simple Types */
32    
33    
34     /*+ A way identifier. +*/
35     typedef uint32_t way_t;
36    
37     /*+ The speed limit of the way. +*/
38     typedef uint8_t speed_t;
39    
40 amb 30 /*+ A way type identifier. +*/
41 amb 50 typedef uint8_t waytype_t;
42 amb 21
43 amb 50 /*+ The different types of a way. +*/
44 amb 30 typedef enum _WayType
45     {
46     Way_Motorway =1,
47     Way_Trunk =2,
48     Way_Primary =3,
49     Way_Tertiary =4,
50     Way_Secondary =5,
51     Way_Unclassfied=6,
52     Way_Residential=7,
53     Way_Service =8,
54     Way_Track =9,
55     Way_Bridleway =10,
56     Way_Cycleway =11,
57     Way_Footway =12,
58     Way_Unknown =15,
59 amb 50
60     Way_OneWay =16,
61     Way_Roundabout =32
62 amb 30 }
63     WayType;
64    
65 amb 57 #define Way_TYPE(xx) ((xx)&0x1f)
66 amb 30
67    
68 amb 50 /*+ A way type identifier. +*/
69     typedef uint8_t wayallow_t;
70 amb 30
71 amb 50 /*+ The different allowed traffic on a way. +*/
72     typedef enum _AllowType
73     {
74     Allow_Foot = 1,
75     Allow_Bicycle = 2,
76     Allow_Horse = 4,
77     Allow_Motorbike = 8,
78     Allow_Motorcar = 16,
79     Allow_PSV = 32,
80     Allow_Goods = 64,
81 amb 54 Allow_HGV =128,
82     Allow_ALL =255
83 amb 50 }
84     AllowType;
85    
86    
87 amb 21 /* Data structures */
88    
89    
90     /*+ A structure containing a single way. +*/
91     typedef struct _Way
92     {
93 amb 50 way_t id; /*+ The way identifier. +*/
94     uint32_t name; /*+ An offset of the name of the way in the ways array. +*/
95     speed_t limit; /*+ The defined speed limit on the way. +*/
96     waytype_t type; /*+ The type of the way. +*/
97     wayallow_t allow; /*+ The type of traffic allowed on the way. +*/
98 amb 21 }
99     Way;
100    
101     /*+ A structure containing a set of ways (mmap format). +*/
102     typedef struct _Ways
103     {
104 amb 65 uint32_t offset[NBINS_WAYS]; /*+ An offset to the first entry in each bin. +*/
105     uint32_t number; /*+ How many entries are used in total? +*/
106 amb 26 Way ways[1]; /*+ An array of ways whose size is not limited to 1
107 amb 21 (i.e. may overflow the end of this structure). +*/
108     }
109     Ways;
110    
111     /*+ A structure containing a set of ways (memory format). +*/
112     typedef struct _WaysMem
113     {
114     uint32_t alloced; /*+ How many entries are allocated? +*/
115     uint32_t number; /*+ How many entries are used? +*/
116     uint32_t number_str; /*+ How many name entries are used? +*/
117     uint32_t sorted; /*+ Is the data sorted and therefore searchable? +*/
118    
119 amb 65 Ways *ways; /*+ The real data that will be memory mapped later. +*/
120 amb 21 char **names; /*+ An array of names. +*/
121     }
122     WaysMem;
123    
124    
125     /* Functions */
126    
127    
128     WaysMem *NewWayList(void);
129    
130     Ways *LoadWayList(const char *filename);
131     Ways *SaveWayList(WaysMem *ways,const char *filename);
132    
133     Way *FindWay(Ways *ways,way_t id);
134    
135 amb 30 Way *AppendWay(WaysMem *ways,way_t id,const char *name);
136 amb 21
137     void SortWayList(WaysMem *ways);
138    
139 amb 30 WayType TypeOfWay(const char *type);
140 amb 21
141 amb 54 AllowType AllowedType(const char *transport);
142    
143 amb 63 speed_t WaySpeed(Way *way);
144    
145 amb 32 #define LookupWay(xxx,yyy) (&xxx->ways[yyy])
146 amb 21
147 amb 32 #define WayName(xxx,yyy) ((char*)&xxx->ways[yyy->name])
148    
149    
150 amb 21 #endif /* WAYS_H */

Properties

Name Value
cvs:description Header file for ways.