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 74 - (hide annotations) (download) (as text)
Fri Jan 23 16:09:09 2009 UTC (16 years, 2 months ago) by amb
File MIME type: text/x-chdr
File size: 4336 byte(s)
Add enumerated type Transport.
Replace variables of AllowType with Transport where more appropriate.
Replace AllowType with Allowed.
Replace WayType with Highway.

1 amb 21 /***************************************
2 amb 74 $Header: /home/amb/CVS/routino/src/ways.h,v 1.12 2009-01-23 16:09:09 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 74 /*+ The type of a way. +*/
41 amb 50 typedef uint8_t waytype_t;
42 amb 21
43 amb 50 /*+ The different types of a way. +*/
44 amb 74 typedef enum _Highway
45 amb 30 {
46 amb 74 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 amb 30 Way_Bridleway =10,
56     Way_Cycleway =11,
57     Way_Footway =12,
58 amb 68
59 amb 30 Way_Unknown =15,
60 amb 50
61     Way_OneWay =16,
62     Way_Roundabout =32
63 amb 30 }
64 amb 74 Highway;
65 amb 30
66    
67 amb 74 /*+ The type of a method of transport. +*/
68     typedef uint8_t transport_t;
69    
70     /*+ The different methods of transport. +*/
71     typedef enum _Transport
72     {
73     Transport_None = 0,
74    
75     Transport_Foot = 1,
76     Transport_Bicycle = 2,
77     Transport_Horse = 3,
78     Transport_Motorbike = 4,
79     Transport_Motorcar = 5,
80     Transport_PSV = 6,
81     Transport_Goods = 7,
82     Transport_HGV = 8
83     }
84     Transport;
85    
86    
87     /*+ The allowed traffic on a way. +*/
88 amb 50 typedef uint8_t wayallow_t;
89 amb 30
90 amb 50 /*+ The different allowed traffic on a way. +*/
91 amb 74 typedef enum _Allowed
92 amb 50 {
93 amb 74 Allow_Foot =1<<(Transport_Foot -1),
94     Allow_Bicycle =1<<(Transport_Bicycle -1),
95     Allow_Horse =1<<(Transport_Horse -1),
96     Allow_Motorbike =1<<(Transport_Motorbike-1),
97     Allow_Motorcar =1<<(Transport_Motorcar -1),
98     Allow_PSV =1<<(Transport_PSV -1),
99     Allow_Goods =1<<(Transport_Goods -1),
100     Allow_HGV =1<<(Transport_HGV -1),
101    
102 amb 54 Allow_ALL =255
103 amb 50 }
104 amb 74 Allowed;
105 amb 50
106    
107 amb 21 /* Data structures */
108    
109    
110     /*+ A structure containing a single way. +*/
111     typedef struct _Way
112     {
113 amb 50 way_t id; /*+ The way identifier. +*/
114     uint32_t name; /*+ An offset of the name of the way in the ways array. +*/
115     speed_t limit; /*+ The defined speed limit on the way. +*/
116     waytype_t type; /*+ The type of the way. +*/
117     wayallow_t allow; /*+ The type of traffic allowed on the way. +*/
118 amb 21 }
119     Way;
120    
121     /*+ A structure containing a set of ways (mmap format). +*/
122     typedef struct _Ways
123     {
124 amb 65 uint32_t offset[NBINS_WAYS]; /*+ An offset to the first entry in each bin. +*/
125     uint32_t number; /*+ How many entries are used in total? +*/
126 amb 26 Way ways[1]; /*+ An array of ways whose size is not limited to 1
127 amb 21 (i.e. may overflow the end of this structure). +*/
128     }
129     Ways;
130    
131     /*+ A structure containing a set of ways (memory format). +*/
132     typedef struct _WaysMem
133     {
134     uint32_t alloced; /*+ How many entries are allocated? +*/
135     uint32_t number; /*+ How many entries are used? +*/
136     uint32_t number_str; /*+ How many name entries are used? +*/
137     uint32_t sorted; /*+ Is the data sorted and therefore searchable? +*/
138    
139 amb 65 Ways *ways; /*+ The real data that will be memory mapped later. +*/
140 amb 21 char **names; /*+ An array of names. +*/
141     }
142     WaysMem;
143    
144    
145     /* Functions */
146    
147    
148     WaysMem *NewWayList(void);
149    
150     Ways *LoadWayList(const char *filename);
151     Ways *SaveWayList(WaysMem *ways,const char *filename);
152    
153     Way *FindWay(Ways *ways,way_t id);
154    
155 amb 30 Way *AppendWay(WaysMem *ways,way_t id,const char *name);
156 amb 21
157     void SortWayList(WaysMem *ways);
158    
159 amb 74 Highway HighwayType(const char *highway);
160     Transport TransportType(const char *transport);
161 amb 21
162 amb 63 speed_t WaySpeed(Way *way);
163    
164 amb 32 #define LookupWay(xxx,yyy) (&xxx->ways[yyy])
165 amb 21
166 amb 32 #define WayName(xxx,yyy) ((char*)&xxx->ways[yyy->name])
167    
168    
169 amb 21 #endif /* WAYS_H */

Properties

Name Value
cvs:description Header file for ways.