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 653 -
(hide annotations)
(download)
(as text)
Sat Mar 12 16:09:38 2011 UTC (14 years ago) by amb
File MIME type: text/x-chdr
File size: 4603 byte(s)
Sat Mar 12 16:09:38 2011 UTC (14 years ago) by amb
File MIME type: text/x-chdr
File size: 4603 byte(s)
Make the nodes super marker a boolean.
1 | amb | 110 | /*************************************** |
2 | A header file for the extended nodes. | ||
3 | amb | 151 | |
4 | Part of the Routino routing software. | ||
5 | amb | 110 | ******************/ /****************** |
6 | amb | 600 | This file Copyright 2008-2011 Andrew M. Bishop |
7 | amb | 110 | |
8 | amb | 151 | 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 | amb | 110 | ***************************************/ |
21 | |||
22 | |||
23 | #ifndef NODESX_H | ||
24 | #define NODESX_H /*+ To stop multiple inclusions. +*/ | ||
25 | |||
26 | #include <stdint.h> | ||
27 | |||
28 | amb | 449 | #include "types.h" |
29 | amb | 448 | #include "nodes.h" |
30 | |||
31 | amb | 199 | #include "typesx.h" |
32 | amb | 110 | |
33 | amb | 451 | #include "files.h" |
34 | amb | 110 | |
35 | amb | 451 | |
36 | amb | 110 | /* Data structures */ |
37 | |||
38 | |||
39 | /*+ An extended structure used for processing. +*/ | ||
40 | struct _NodeX | ||
41 | { | ||
42 | amb | 600 | node_t id; /*+ The node identifier; initially the OSM value, later the Node index, finally the first segment. +*/ |
43 | amb | 199 | |
44 | amb | 529 | latlong_t latitude; /*+ The node latitude. +*/ |
45 | latlong_t longitude; /*+ The node longitude. +*/ | ||
46 | amb | 469 | |
47 | amb | 529 | transports_t allow; /*+ The node allowed traffic. +*/ |
48 | amb | 537 | |
49 | uint16_t flags; /*+ The node flags. +*/ | ||
50 | amb | 110 | }; |
51 | |||
52 | /*+ A structure containing a set of nodes (memory format). +*/ | ||
53 | struct _NodesX | ||
54 | { | ||
55 | amb | 252 | char *filename; /*+ The name of the temporary file. +*/ |
56 | int fd; /*+ The file descriptor of the temporary file. +*/ | ||
57 | amb | 216 | |
58 | amb | 650 | index_t number; /*+ The number of extended nodes still being considered. +*/ |
59 | amb | 249 | |
60 | amb | 452 | #if !SLIM |
61 | |||
62 | amb | 651 | NodeX *data; /*+ The extended node data (when mapped into memory). +*/ |
63 | amb | 216 | |
64 | amb | 452 | #else |
65 | |||
66 | amb | 651 | NodeX cached[2]; /*+ Two cached nodes read from the file in slim mode. +*/ |
67 | amb | 452 | |
68 | #endif | ||
69 | |||
70 | amb | 278 | node_t *idata; /*+ The extended node IDs (sorted by ID). +*/ |
71 | amb | 216 | |
72 | amb | 552 | node_t *gdata; /*+ The final node indexes (sorted by ID). +*/ |
73 | amb | 249 | |
74 | amb | 552 | uint8_t *super; /*+ A marker for super nodes (same order as sorted nodes). +*/ |
75 | amb | 452 | |
76 | amb | 465 | index_t latbins; /*+ The number of bins containing latitude. +*/ |
77 | index_t lonbins; /*+ The number of bins containing longitude. +*/ | ||
78 | amb | 257 | |
79 | amb | 258 | ll_bin_t latzero; /*+ The bin number of the furthest south bin. +*/ |
80 | ll_bin_t lonzero; /*+ The bin number of the furthest west bin. +*/ | ||
81 | amb | 110 | }; |
82 | |||
83 | |||
84 | /* Functions */ | ||
85 | |||
86 | amb | 326 | NodesX *NewNodeList(int append); |
87 | void FreeNodeList(NodesX *nodesx,int keep); | ||
88 | amb | 110 | |
89 | void SaveNodeList(NodesX *nodesx,const char *filename); | ||
90 | |||
91 | amb | 249 | index_t IndexNodeX(NodesX* nodesx,node_t id); |
92 | amb | 110 | |
93 | amb | 538 | void AppendNode(NodesX* nodesx,node_t id,double latitude,double longitude,transports_t allow,uint16_t flags); |
94 | amb | 110 | |
95 | amb | 263 | void SortNodeList(NodesX *nodesx); |
96 | amb | 110 | |
97 | amb | 212 | void SortNodeListGeographically(NodesX* nodesx); |
98 | |||
99 | amb | 110 | void RemoveNonHighwayNodes(NodesX *nodesx,SegmentsX *segmentsx); |
100 | |||
101 | amb | 653 | void UpdateNodes(NodesX *nodesx,SegmentsX *segmentsx); |
102 | amb | 110 | |
103 | |||
104 | amb | 452 | /* Macros / inline functions */ |
105 | amb | 451 | |
106 | amb | 452 | #if !SLIM |
107 | amb | 451 | |
108 | amb | 651 | #define LookupNodeX(nodesx,index,position) &(nodesx)->data[index] |
109 | amb | 452 | |
110 | amb | 557 | #define PutBackNodeX(nodesx,index,position) /* nop */ |
111 | |||
112 | amb | 452 | #else |
113 | |||
114 | static NodeX *LookupNodeX(NodesX* nodesx,index_t index,int position); | ||
115 | |||
116 | amb | 552 | static void PutBackNodeX(NodesX* nodesx,index_t index,int position); |
117 | amb | 452 | |
118 | |||
119 | amb | 451 | /*++++++++++++++++++++++++++++++++++++++ |
120 | Lookup a particular extended node. | ||
121 | |||
122 | NodeX *LookupNodeX Returns a pointer to the extended node with the specified id. | ||
123 | |||
124 | NodesX* nodesx The set of nodes to process. | ||
125 | |||
126 | index_t index The node index to look for. | ||
127 | |||
128 | int position The position in the cache to use. | ||
129 | ++++++++++++++++++++++++++++++++++++++*/ | ||
130 | |||
131 | static inline NodeX *LookupNodeX(NodesX* nodesx,index_t index,int position) | ||
132 | { | ||
133 | amb | 464 | SeekFile(nodesx->fd,(off_t)index*sizeof(NodeX)); |
134 | amb | 451 | |
135 | amb | 651 | ReadFile(nodesx->fd,&nodesx->cached[position-1],sizeof(NodeX)); |
136 | amb | 451 | |
137 | amb | 651 | return(&nodesx->cached[position-1]); |
138 | amb | 451 | } |
139 | |||
140 | |||
141 | /*++++++++++++++++++++++++++++++++++++++ | ||
142 | amb | 552 | Put back an extended node's data. |
143 | amb | 451 | |
144 | NodesX* nodesx The set of nodes to process. | ||
145 | |||
146 | amb | 643 | index_t index The node index to put back. |
147 | amb | 451 | |
148 | int position The position in the cache to use. | ||
149 | ++++++++++++++++++++++++++++++++++++++*/ | ||
150 | |||
151 | amb | 552 | static inline void PutBackNodeX(NodesX* nodesx,index_t index,int position) |
152 | amb | 451 | { |
153 | amb | 552 | SeekFile(nodesx->fd,(off_t)index*sizeof(NodeX)); |
154 | amb | 451 | |
155 | amb | 651 | WriteFile(nodesx->fd,&nodesx->cached[position-1],sizeof(NodeX)); |
156 | amb | 451 | } |
157 | |||
158 | amb | 452 | #endif /* SLIM */ |
159 | amb | 451 | |
160 | amb | 452 | |
161 | amb | 110 | #endif /* NODESX_H */ |
Properties
Name | Value |
---|---|
cvs:description | Extended nodes header. |