Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino
Contents of /branches/destination-access/src/nodes.h
Parent Directory
|
Revision Log
Revision 1629 -
(show annotations)
(download)
(as text)
Sun Mar 22 14:56:38 2015 UTC (9 years, 11 months ago) by amb
File MIME type: text/x-chdr
File size: 5493 byte(s)
Sun Mar 22 14:56:38 2015 UTC (9 years, 11 months ago) by amb
File MIME type: text/x-chdr
File size: 5493 byte(s)
Parse "access=destination" differently and store the information in the database for later use routing the first and last waypoints.
1 | /*************************************** |
2 | A header file for the nodes. |
3 | |
4 | Part of the Routino routing software. |
5 | ******************/ /****************** |
6 | This file Copyright 2008-2015 Andrew M. Bishop |
7 | |
8 | This program is free software: you can redistribute it and/or modify |
9 | it under the terms of the GNU Affero General Public License as published by |
10 | the Free Software Foundation, either version 3 of the License, or |
11 | (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU Affero General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU Affero General Public License |
19 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 | ***************************************/ |
21 | |
22 | |
23 | #ifndef NODES_H |
24 | #define NODES_H /*+ To stop multiple inclusions. +*/ |
25 | |
26 | #include <stdint.h> |
27 | #include <sys/types.h> |
28 | |
29 | #include "types.h" |
30 | |
31 | #include "cache.h" |
32 | #include "files.h" |
33 | #include "profiles.h" |
34 | |
35 | |
36 | /* Data structures */ |
37 | |
38 | |
39 | /*+ A structure containing a single node. +*/ |
40 | struct _Node |
41 | { |
42 | index_t firstseg; /*+ The index of the first segment. +*/ |
43 | |
44 | ll_off_t latoffset; /*+ The node latitude offset within its bin. +*/ |
45 | ll_off_t lonoffset; /*+ The node longitude offset within its bin. +*/ |
46 | |
47 | transports_t allow; /*+ The types of transport that are allowed through the node. +*/ |
48 | transports_t destination; /*+ The types of transport that are allowed through the node - only for access to waypoints. +*/ |
49 | |
50 | nodeflags_t flags; /*+ Flags containing extra information (e.g. super-node, turn restriction). +*/ |
51 | }; |
52 | |
53 | |
54 | /*+ A structure containing the header from the file. +*/ |
55 | typedef struct _NodesFile |
56 | { |
57 | index_t number; /*+ The number of nodes in total. +*/ |
58 | index_t snumber; /*+ The number of super-nodes. +*/ |
59 | |
60 | ll_bin_t latbins; /*+ The number of bins containing latitude. +*/ |
61 | ll_bin_t lonbins; /*+ The number of bins containing longitude. +*/ |
62 | |
63 | ll_bin_t latzero; /*+ The bin number of the furthest south bin. +*/ |
64 | ll_bin_t lonzero; /*+ The bin number of the furthest west bin. +*/ |
65 | } |
66 | NodesFile; |
67 | |
68 | |
69 | /*+ A structure containing a set of nodes. +*/ |
70 | struct _Nodes |
71 | { |
72 | NodesFile file; /*+ The header data from the file. +*/ |
73 | |
74 | #if !SLIM |
75 | |
76 | void *data; /*+ The memory mapped data in the file. +*/ |
77 | |
78 | index_t *offsets; /*+ A pointer to the array of offsets in the file. +*/ |
79 | |
80 | Node *nodes; /*+ A pointer to the array of nodes in the file. +*/ |
81 | |
82 | #else |
83 | |
84 | int fd; /*+ The file descriptor for the file. +*/ |
85 | |
86 | index_t *offsets; /*+ An allocated array with a copy of the file offsets. +*/ |
87 | |
88 | off_t nodesoffset; /*+ The offset of the nodes within the file. +*/ |
89 | |
90 | Node cached[6]; /*+ Some cached nodes read from the file in slim mode. +*/ |
91 | |
92 | NodeCache *cache; /*+ A RAM cache of nodes read from the file. +*/ |
93 | |
94 | #endif |
95 | }; |
96 | |
97 | |
98 | /* Functions in nodes.c */ |
99 | |
100 | Nodes *LoadNodeList(const char *filename); |
101 | |
102 | void DestroyNodeList(Nodes *nodes); |
103 | |
104 | index_t FindClosestNode(Nodes *nodes,Segments *segments,Ways *ways,double latitude,double longitude, |
105 | distance_t distance,Profile *profile,distance_t *bestdist); |
106 | |
107 | index_t FindClosestSegment(Nodes *nodes,Segments *segments,Ways *ways,double latitude,double longitude, |
108 | distance_t distance,Profile *profile, distance_t *bestdist, |
109 | index_t *bestnode1,index_t *bestnode2,distance_t *bestdist1,distance_t *bestdist2); |
110 | |
111 | void GetLatLong(Nodes *nodes,index_t index,Node *nodep,double *latitude,double *longitude); |
112 | |
113 | |
114 | /* Macros and inline functions */ |
115 | |
116 | /*+ Return true if this is a super-node. +*/ |
117 | #define IsSuperNode(xxx) (((xxx)->flags)&NODE_SUPER) |
118 | |
119 | /*+ Return true if this is a turn restricted node. +*/ |
120 | #define IsTurnRestrictedNode(xxx) (((xxx)->flags)&NODE_TURNRSTRCT) |
121 | |
122 | /*+ Return a Segment index given a Node pointer and a set of segments. +*/ |
123 | #define FirstSegment(xxx,yyy,ppp) LookupSegment((xxx),(yyy)->firstseg,ppp) |
124 | |
125 | /*+ Return the offset of a geographical region given a set of nodes. +*/ |
126 | #define LookupNodeOffset(xxx,yyy) ((xxx)->offsets[yyy]) |
127 | |
128 | |
129 | #if !SLIM |
130 | |
131 | /*+ Return a Node pointer given a set of nodes and an index. +*/ |
132 | #define LookupNode(xxx,yyy,ppp) (&(xxx)->nodes[yyy]) |
133 | |
134 | #else |
135 | |
136 | /* Prototypes */ |
137 | |
138 | static inline Node *LookupNode(Nodes *nodes,index_t index,int position); |
139 | |
140 | CACHE_NEWCACHE_PROTO(Node) |
141 | CACHE_DELETECACHE_PROTO(Node) |
142 | CACHE_FETCHCACHE_PROTO(Node) |
143 | CACHE_INVALIDATECACHE_PROTO(Node) |
144 | |
145 | |
146 | /* Inline functions */ |
147 | |
148 | CACHE_STRUCTURE(Node) |
149 | CACHE_NEWCACHE(Node) |
150 | CACHE_DELETECACHE(Node) |
151 | CACHE_FETCHCACHE(Node) |
152 | CACHE_INVALIDATECACHE(Node) |
153 | |
154 | |
155 | /*++++++++++++++++++++++++++++++++++++++ |
156 | Find the Node information for a particular node. |
157 | |
158 | Node *LookupNode Returns a pointer to the cached node information. |
159 | |
160 | Nodes *nodes The set of nodes to use. |
161 | |
162 | index_t index The index of the node. |
163 | |
164 | int position The position in the cache to store the value. |
165 | ++++++++++++++++++++++++++++++++++++++*/ |
166 | |
167 | static inline Node *LookupNode(Nodes *nodes,index_t index,int position) |
168 | { |
169 | nodes->cached[position-1]=*FetchCachedNode(nodes->cache,index,nodes->fd,nodes->nodesoffset); |
170 | |
171 | return(&nodes->cached[position-1]); |
172 | } |
173 | |
174 | #endif |
175 | |
176 | |
177 | #endif /* NODES_H */ |
Properties
Name | Value |
---|---|
cvs:description | Header file for nodes. |