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 68 - (hide annotations) (download) (as text)
Thu Jan 22 19:39:30 2009 UTC (16 years, 2 months ago) by amb
File MIME type: text/x-chdr
File size: 3733 byte(s)
Removed the Way_TYPE() macro.

1 amb 21 /***************************************
2 amb 68 $Header: /home/amb/CVS/routino/src/ways.h,v 1.11 2009-01-22 19:39:30 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 amb 68
59 amb 30 Way_Unknown =15,
60 amb 50
61     Way_OneWay =16,
62     Way_Roundabout =32
63 amb 30 }
64     WayType;
65    
66    
67 amb 50 /*+ A way type identifier. +*/
68     typedef uint8_t wayallow_t;
69 amb 30
70 amb 50 /*+ The different allowed traffic on a way. +*/
71     typedef enum _AllowType
72     {
73     Allow_Foot = 1,
74     Allow_Bicycle = 2,
75     Allow_Horse = 4,
76     Allow_Motorbike = 8,
77     Allow_Motorcar = 16,
78     Allow_PSV = 32,
79     Allow_Goods = 64,
80 amb 54 Allow_HGV =128,
81     Allow_ALL =255
82 amb 50 }
83     AllowType;
84    
85    
86 amb 21 /* Data structures */
87    
88    
89     /*+ A structure containing a single way. +*/
90     typedef struct _Way
91     {
92 amb 50 way_t id; /*+ The way identifier. +*/
93     uint32_t name; /*+ An offset of the name of the way in the ways array. +*/
94     speed_t limit; /*+ The defined speed limit on the way. +*/
95     waytype_t type; /*+ The type of the way. +*/
96     wayallow_t allow; /*+ The type of traffic allowed on the way. +*/
97 amb 21 }
98     Way;
99    
100     /*+ A structure containing a set of ways (mmap format). +*/
101     typedef struct _Ways
102     {
103 amb 65 uint32_t offset[NBINS_WAYS]; /*+ An offset to the first entry in each bin. +*/
104     uint32_t number; /*+ How many entries are used in total? +*/
105 amb 26 Way ways[1]; /*+ An array of ways whose size is not limited to 1
106 amb 21 (i.e. may overflow the end of this structure). +*/
107     }
108     Ways;
109    
110     /*+ A structure containing a set of ways (memory format). +*/
111     typedef struct _WaysMem
112     {
113     uint32_t alloced; /*+ How many entries are allocated? +*/
114     uint32_t number; /*+ How many entries are used? +*/
115     uint32_t number_str; /*+ How many name entries are used? +*/
116     uint32_t sorted; /*+ Is the data sorted and therefore searchable? +*/
117    
118 amb 65 Ways *ways; /*+ The real data that will be memory mapped later. +*/
119 amb 21 char **names; /*+ An array of names. +*/
120     }
121     WaysMem;
122    
123    
124     /* Functions */
125    
126    
127     WaysMem *NewWayList(void);
128    
129     Ways *LoadWayList(const char *filename);
130     Ways *SaveWayList(WaysMem *ways,const char *filename);
131    
132     Way *FindWay(Ways *ways,way_t id);
133    
134 amb 30 Way *AppendWay(WaysMem *ways,way_t id,const char *name);
135 amb 21
136     void SortWayList(WaysMem *ways);
137    
138 amb 30 WayType TypeOfWay(const char *type);
139 amb 21
140 amb 54 AllowType AllowedType(const char *transport);
141    
142 amb 63 speed_t WaySpeed(Way *way);
143    
144 amb 32 #define LookupWay(xxx,yyy) (&xxx->ways[yyy])
145 amb 21
146 amb 32 #define WayName(xxx,yyy) ((char*)&xxx->ways[yyy->name])
147    
148    
149 amb 21 #endif /* WAYS_H */

Properties

Name Value
cvs:description Header file for ways.