Routino SVN Repository Browser

Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino

ViewVC logotype

Contents of /trunk/src/nodesx.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1308 - (show annotations) (download) (as text)
Fri May 10 19:01:58 2013 UTC (11 years, 10 months ago) by amb
File MIME type: text/x-chdr
File size: 5494 byte(s)
Make no-op macros look like real statements.

1 /***************************************
2 A header file for the extended nodes.
3
4 Part of the Routino routing software.
5 ******************/ /******************
6 This file Copyright 2008-2013 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 NODESX_H
24 #define NODESX_H /*+ To stop multiple inclusions. +*/
25
26 #include <stdint.h>
27
28 #include "types.h"
29 #include "nodes.h"
30
31 #include "typesx.h"
32
33 #include "cache.h"
34 #include "files.h"
35
36
37 /* Data structures */
38
39
40 /*+ An extended structure used for processing. +*/
41 struct _NodeX
42 {
43 node_t id; /*+ The node identifier; initially the OSM value, later the Node index, finally the first segment. +*/
44
45 latlong_t latitude; /*+ The node latitude. +*/
46 latlong_t longitude; /*+ The node longitude. +*/
47
48 transports_t allow; /*+ The node allowed traffic. +*/
49 nodeflags_t flags; /*+ The node flags. +*/
50 };
51
52 /*+ A structure containing a set of nodes (memory format). +*/
53 struct _NodesX
54 {
55 char *filename; /*+ The name of the intermediate file (for the NodesX). +*/
56 char *filename_tmp; /*+ The name of the temporary file (for the NodesX). +*/
57
58 int fd; /*+ The file descriptor of the open file (for the NodesX). +*/
59
60 index_t number; /*+ The number of extended nodes still being considered. +*/
61
62 #if !SLIM
63
64 NodeX *data; /*+ The extended node data (when mapped into memory). +*/
65
66 #else
67
68 NodeX cached[3]; /*+ Three cached extended nodes read from the file in slim mode. +*/
69 index_t incache[3]; /*+ The indexes of the cached extended nodes. +*/
70
71 NodeXCache *cache; /*+ A RAM cache of extended nodes read from the file. +*/
72
73 #endif
74
75 node_t *idata; /*+ The extended node IDs (sorted by ID). +*/
76
77 index_t *pdata; /*+ The node indexes after pruning. +*/
78
79 index_t *gdata; /*+ The final node indexes (sorted geographically). +*/
80
81 BitMask *super; /*+ A bit-mask marker for super nodes (same order as sorted nodes). +*/
82
83 index_t latbins; /*+ The number of bins containing latitude. +*/
84 index_t lonbins; /*+ The number of bins containing longitude. +*/
85
86 ll_bin_t latzero; /*+ The bin number of the furthest south bin. +*/
87 ll_bin_t lonzero; /*+ The bin number of the furthest west bin. +*/
88 };
89
90
91 /* Functions in nodesx.c */
92
93 NodesX *NewNodeList(int append,int readonly);
94 void FreeNodeList(NodesX *nodesx,int keep);
95
96 void AppendNodeList(NodesX *nodesx,node_t id,double latitude,double longitude,transports_t allow,nodeflags_t flags);
97 void FinishNodeList(NodesX *nodesx);
98
99 index_t IndexNodeX(NodesX *nodesx,node_t id);
100
101 void SortNodeList(NodesX *nodesx);
102
103 void RemoveNonHighwayNodes(NodesX *nodesx,SegmentsX *segmentsx,int keep);
104
105 void RemovePrunedNodes(NodesX *nodesx,SegmentsX *segmentsx);
106
107 void SortNodeListGeographically(NodesX *nodesx);
108
109 void SaveNodeList(NodesX *nodesx,const char *filename,SegmentsX *segmentsx);
110
111
112 /* Macros and inline functions */
113
114 #if !SLIM
115
116 #define LookupNodeX(nodesx,index,position) &(nodesx)->data[index]
117
118 #define PutBackNodeX(nodesx,nodex) while(0) { /* nop */ }
119
120 #else
121
122 /* Prototypes */
123
124 static inline NodeX *LookupNodeX(NodesX *nodesx,index_t index,int position);
125
126 static inline void PutBackNodeX(NodesX *nodesx,NodeX *nodex);
127
128 CACHE_NEWCACHE_PROTO(NodeX)
129 CACHE_DELETECACHE_PROTO(NodeX)
130 CACHE_FETCHCACHE_PROTO(NodeX)
131 CACHE_REPLACECACHE_PROTO(NodeX)
132 CACHE_INVALIDATECACHE_PROTO(NodeX)
133
134
135 /* Inline functions */
136
137 CACHE_STRUCTURE(NodeX)
138 CACHE_NEWCACHE(NodeX)
139 CACHE_DELETECACHE(NodeX)
140 CACHE_FETCHCACHE(NodeX)
141 CACHE_REPLACECACHE(NodeX)
142 CACHE_INVALIDATECACHE(NodeX)
143
144
145 /*++++++++++++++++++++++++++++++++++++++
146 Lookup a particular extended node with the specified id from the file on disk.
147
148 NodeX *LookupNodeX Returns a pointer to a cached copy of the extended node.
149
150 NodesX *nodesx The set of nodes to use.
151
152 index_t index The node index to look for.
153
154 int position The position in the cache to use.
155 ++++++++++++++++++++++++++++++++++++++*/
156
157 static inline NodeX *LookupNodeX(NodesX *nodesx,index_t index,int position)
158 {
159 nodesx->cached[position-1]=*FetchCachedNodeX(nodesx->cache,index,nodesx->fd,0);
160
161 nodesx->incache[position-1]=index;
162
163 return(&nodesx->cached[position-1]);
164 }
165
166
167 /*++++++++++++++++++++++++++++++++++++++
168 Put back an extended node's data into the file on disk.
169
170 NodesX *nodesx The set of nodes to modify.
171
172 NodeX *nodex The extended node to be put back.
173 ++++++++++++++++++++++++++++++++++++++*/
174
175 static inline void PutBackNodeX(NodesX *nodesx,NodeX *nodex)
176 {
177 int position1=nodex-&nodesx->cached[0];
178
179 ReplaceCachedNodeX(nodesx->cache,nodex,nodesx->incache[position1],nodesx->fd,0);
180 }
181
182 #endif /* SLIM */
183
184
185 #endif /* NODESX_H */

Properties

Name Value
cvs:description Extended nodes header.