7a5a94aedbd0fe2bf7dd75be6f070946bcf9cc80
[routino] / src / ways.h
1 /***************************************
2  $Header: /home/amb/routino/src/RCS/ways.h,v 1.37 2010/05/29 13:54:24 amb Exp $
3
4  A header file for the ways.
5
6  Part of the Routino routing software.
7  ******************/ /******************
8  This file Copyright 2008-2010 Andrew M. Bishop
9
10  This program is free software: you can redistribute it and/or modify
11  it under the terms of the GNU Affero General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  GNU Affero General Public License for more details.
19
20  You should have received a copy of the GNU Affero General Public License
21  along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  ***************************************/
23
24
25 #ifndef WAYS_H
26 #define WAYS_H    /*+ To stop multiple inclusions. +*/
27
28 #include <stdint.h>
29
30 #include "types.h"
31
32
33 /* Data structures */
34
35
36 /*+ A structure containing a single way (members ordered to minimise overall size). +*/
37 struct _Way
38 {
39  index_t    name;               /*+ The offset of the name of the way in the names array. +*/
40
41  wayallow_t allow;              /*+ The type of traffic allowed on the way. +*/
42
43  waytype_t  type;               /*+ The highway type of the way. +*/
44
45  wayprop_t  props;              /*+ The properties of the way. +*/
46
47  speed_t    speed;              /*+ The defined maximum speed limit of the way. +*/
48
49  weight_t   weight;             /*+ The defined maximum weight of traffic on the way. +*/
50  height_t   height;             /*+ The defined maximum height of traffic on the way. +*/
51  width_t    width;              /*+ The defined maximum width of traffic on the way. +*/
52  length_t   length;             /*+ The defined maximum length of traffic on the way. +*/
53 };
54
55
56 /*+ A structure containing a set of ways (mmap format). +*/
57 struct _Ways
58 {
59  uint32_t   number;             /*+ How many ways are stored? +*/
60  uint32_t   onumber;            /*+ How many ways were there originally? +*/
61
62  wayallow_t allow;              /*+ The types of traffic that were seen when parsing. +*/
63  wayprop_t  props;              /*+ The properties that were seen when parsing. +*/
64
65  Way       *ways;               /*+ An array of ways. +*/
66  char      *names;              /*+ An array of characters containing the names. +*/
67
68  void      *data;               /*+ The memory mapped data. +*/
69 };
70
71
72 /* Macros */
73
74
75 /*+ Return a Way* pointer given a set of ways and an index. +*/
76 #define LookupWay(xxx,yyy)     (&(xxx)->ways[yyy])
77
78 /*+ Return the raw name of a way given the Way pointer and a set of ways. +*/
79 #define WayNameRaw(xxx,yyy)        (&(xxx)->names[(yyy)->name])
80
81 /*+ Decide if a way has a name or not. +*/
82 #define WayNamed(xxx,yyy)          ((xxx)->names[(yyy)->name])
83
84 /*+ Return the name of a way if it has one or the name of the highway type otherwise. +*/
85 #define WayNameHighway(xxx,yyy)    (WayNamed(xxx,yyy)?WayNameRaw(xxx,yyy):HighwayName(HIGHWAY(yyy->type)))
86
87
88 /* Functions */
89
90
91 Ways *LoadWayList(const char *filename);
92
93 int WaysCompare(Way *way1,Way *way2);
94
95
96 #endif /* WAYS_H */