Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino
Annotation of /trunk/src/nodesx.h
Parent Directory
|
Revision Log
Revision 539 -
(hide annotations)
(download)
(as text)
Sun Dec 5 14:43:37 2010 UTC (14 years, 3 months ago) by amb
File MIME type: text/x-chdr
File size: 5951 byte(s)
Sun Dec 5 14:43:37 2010 UTC (14 years, 3 months ago) by amb
File MIME type: text/x-chdr
File size: 5951 byte(s)
Updated the comments for clarity.
1 | amb | 110 | /*************************************** |
2 | amb | 539 | $Header: /home/amb/CVS/routino/src/nodesx.h,v 1.34 2010-12-05 14:43:37 amb Exp $ |
3 | amb | 110 | |
4 | A header file for the extended nodes. | ||
5 | amb | 151 | |
6 | Part of the Routino routing software. | ||
7 | amb | 110 | ******************/ /****************** |
8 | amb | 326 | This file Copyright 2008-2010 Andrew M. Bishop |
9 | amb | 110 | |
10 | amb | 151 | 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 | amb | 110 | ***************************************/ |
23 | |||
24 | |||
25 | #ifndef NODESX_H | ||
26 | #define NODESX_H /*+ To stop multiple inclusions. +*/ | ||
27 | |||
28 | #include <stdint.h> | ||
29 | |||
30 | amb | 449 | #include "types.h" |
31 | amb | 448 | #include "nodes.h" |
32 | |||
33 | amb | 199 | #include "typesx.h" |
34 | amb | 110 | |
35 | amb | 451 | #include "files.h" |
36 | amb | 110 | |
37 | amb | 451 | |
38 | amb | 110 | /* Data structures */ |
39 | |||
40 | |||
41 | /*+ An extended structure used for processing. +*/ | ||
42 | struct _NodeX | ||
43 | { | ||
44 | amb | 539 | node_t id; /*+ The node identifier; initially the OSM value, later the Node index. +*/ |
45 | amb | 199 | |
46 | amb | 529 | latlong_t latitude; /*+ The node latitude. +*/ |
47 | latlong_t longitude; /*+ The node longitude. +*/ | ||
48 | amb | 469 | |
49 | amb | 529 | transports_t allow; /*+ The node allowed traffic. +*/ |
50 | amb | 537 | |
51 | uint16_t flags; /*+ The node flags. +*/ | ||
52 | amb | 110 | }; |
53 | |||
54 | /*+ A structure containing a set of nodes (memory format). +*/ | ||
55 | struct _NodesX | ||
56 | { | ||
57 | amb | 252 | char *filename; /*+ The name of the temporary file. +*/ |
58 | int fd; /*+ The file descriptor of the temporary file. +*/ | ||
59 | amb | 216 | |
60 | amb | 465 | index_t xnumber; /*+ The number of unsorted extended nodes. +*/ |
61 | amb | 249 | |
62 | amb | 452 | #if !SLIM |
63 | |||
64 | amb | 252 | NodeX *xdata; /*+ The extended node data (sorted). +*/ |
65 | amb | 216 | |
66 | amb | 452 | #else |
67 | |||
68 | NodeX xcached[2]; /*+ Two cached nodes read from the file in slim mode. +*/ | ||
69 | |||
70 | #endif | ||
71 | |||
72 | amb | 465 | index_t number; /*+ How many entries are still useful? +*/ |
73 | amb | 110 | |
74 | amb | 278 | node_t *idata; /*+ The extended node IDs (sorted by ID). +*/ |
75 | amb | 216 | |
76 | amb | 281 | uint8_t *super; /*+ A marker for super nodes (same order sorted nodes). +*/ |
77 | amb | 249 | |
78 | amb | 452 | #if !SLIM |
79 | |||
80 | amb | 281 | Node *ndata; /*+ The actual nodes (same order as geographically sorted nodes). +*/ |
81 | amb | 257 | |
82 | amb | 452 | #else |
83 | |||
84 | amb | 448 | char *nfilename; /*+ The name of the temporary file for nodes in slim mode. +*/ |
85 | int nfd; /*+ The file descriptor of the temporary file. +*/ | ||
86 | |||
87 | Node ncached[2]; /*+ Two cached nodes read from the file in slim mode. +*/ | ||
88 | |||
89 | amb | 452 | #endif |
90 | |||
91 | amb | 465 | index_t latbins; /*+ The number of bins containing latitude. +*/ |
92 | index_t lonbins; /*+ The number of bins containing longitude. +*/ | ||
93 | amb | 257 | |
94 | amb | 258 | ll_bin_t latzero; /*+ The bin number of the furthest south bin. +*/ |
95 | ll_bin_t lonzero; /*+ The bin number of the furthest west bin. +*/ | ||
96 | amb | 257 | |
97 | amb | 465 | index_t latlonbin; /*+ A temporary index into the offsets array. +*/ |
98 | amb | 281 | |
99 | amb | 258 | index_t *offsets; /*+ An array of offset to the first node in each bin. +*/ |
100 | amb | 110 | }; |
101 | |||
102 | |||
103 | /* Functions */ | ||
104 | |||
105 | amb | 326 | NodesX *NewNodeList(int append); |
106 | void FreeNodeList(NodesX *nodesx,int keep); | ||
107 | amb | 110 | |
108 | void SaveNodeList(NodesX *nodesx,const char *filename); | ||
109 | |||
110 | amb | 249 | index_t IndexNodeX(NodesX* nodesx,node_t id); |
111 | amb | 110 | |
112 | amb | 538 | void AppendNode(NodesX* nodesx,node_t id,double latitude,double longitude,transports_t allow,uint16_t flags); |
113 | amb | 110 | |
114 | amb | 263 | void SortNodeList(NodesX *nodesx); |
115 | amb | 110 | |
116 | amb | 212 | void SortNodeListGeographically(NodesX* nodesx); |
117 | |||
118 | amb | 110 | void RemoveNonHighwayNodes(NodesX *nodesx,SegmentsX *segmentsx); |
119 | |||
120 | amb | 212 | void CreateRealNodes(NodesX *nodesx,int iteration); |
121 | amb | 110 | |
122 | amb | 209 | void IndexNodes(NodesX *nodesx,SegmentsX *segmentsx); |
123 | amb | 110 | |
124 | |||
125 | amb | 452 | /* Macros / inline functions */ |
126 | amb | 451 | |
127 | amb | 452 | #if !SLIM |
128 | amb | 451 | |
129 | amb | 452 | #define LookupNodeX(nodesx,index,position) &(nodesx)->xdata[index] |
130 | |||
131 | #define LookupNodeXNode(nodesx,index,position) &(nodesx)->ndata[index] | ||
132 | |||
133 | #else | ||
134 | |||
135 | static NodeX *LookupNodeX(NodesX* nodesx,index_t index,int position); | ||
136 | |||
137 | static Node *LookupNodeXNode(NodesX* nodesx,index_t index,int position); | ||
138 | |||
139 | static void PutBackNodeXNode(NodesX* nodesx,index_t index,int position); | ||
140 | |||
141 | |||
142 | amb | 451 | /*++++++++++++++++++++++++++++++++++++++ |
143 | Lookup a particular extended node. | ||
144 | |||
145 | NodeX *LookupNodeX Returns a pointer to the extended node with the specified id. | ||
146 | |||
147 | NodesX* nodesx The set of nodes to process. | ||
148 | |||
149 | index_t index The node index to look for. | ||
150 | |||
151 | int position The position in the cache to use. | ||
152 | ++++++++++++++++++++++++++++++++++++++*/ | ||
153 | |||
154 | static inline NodeX *LookupNodeX(NodesX* nodesx,index_t index,int position) | ||
155 | { | ||
156 | amb | 464 | SeekFile(nodesx->fd,(off_t)index*sizeof(NodeX)); |
157 | amb | 451 | |
158 | amb | 452 | ReadFile(nodesx->fd,&nodesx->xcached[position-1],sizeof(NodeX)); |
159 | amb | 451 | |
160 | amb | 452 | return(&nodesx->xcached[position-1]); |
161 | amb | 451 | } |
162 | |||
163 | |||
164 | /*++++++++++++++++++++++++++++++++++++++ | ||
165 | Lookup a particular extended node's normal node. | ||
166 | |||
167 | Node *LookupNodeXNode Returns a pointer to the node with the specified id. | ||
168 | |||
169 | NodesX* nodesx The set of nodes to process. | ||
170 | |||
171 | index_t index The node index to look for. | ||
172 | |||
173 | int position The position in the cache to use. | ||
174 | ++++++++++++++++++++++++++++++++++++++*/ | ||
175 | |||
176 | static inline Node *LookupNodeXNode(NodesX* nodesx,index_t index,int position) | ||
177 | { | ||
178 | amb | 464 | SeekFile(nodesx->nfd,(off_t)index*sizeof(Node)); |
179 | amb | 451 | |
180 | amb | 452 | ReadFile(nodesx->nfd,&nodesx->ncached[position-1],sizeof(Node)); |
181 | amb | 451 | |
182 | amb | 452 | return(&nodesx->ncached[position-1]); |
183 | amb | 451 | } |
184 | |||
185 | |||
186 | /*++++++++++++++++++++++++++++++++++++++ | ||
187 | Put back an extended node's normal node. | ||
188 | |||
189 | NodesX* nodesx The set of nodes to process. | ||
190 | |||
191 | index_t index The node index to look for. | ||
192 | |||
193 | int position The position in the cache to use. | ||
194 | ++++++++++++++++++++++++++++++++++++++*/ | ||
195 | |||
196 | static inline void PutBackNodeXNode(NodesX* nodesx,index_t index,int position) | ||
197 | { | ||
198 | amb | 464 | SeekFile(nodesx->nfd,(off_t)index*sizeof(Node)); |
199 | amb | 451 | |
200 | amb | 452 | WriteFile(nodesx->nfd,&nodesx->ncached[position-1],sizeof(Node)); |
201 | amb | 451 | } |
202 | |||
203 | amb | 452 | #endif /* SLIM */ |
204 | amb | 451 | |
205 | amb | 452 | |
206 | amb | 110 | #endif /* NODESX_H */ |
Properties
Name | Value |
---|---|
cvs:description | Extended nodes header. |