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 1350 - (show annotations) (download) (as text)
Thu May 30 16:53:27 2013 UTC (11 years, 9 months ago) by amb
File MIME type: text/x-chdr
File size: 5575 byte(s)
Delete the non-highway nodes by searching for them in the ways rather than
marking them when processing the segments.

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 index_t knumber; /*+ The number of extended nodes kept for next time. +*/
62
63 #if !SLIM
64
65 NodeX *data; /*+ The extended node data (when mapped into memory). +*/
66
67 #else
68
69 NodeX cached[3]; /*+ Three cached extended nodes read from the file in slim mode. +*/
70 index_t incache[3]; /*+ The indexes of the cached extended nodes. +*/
71
72 NodeXCache *cache; /*+ A RAM cache of extended nodes read from the file. +*/
73
74 #endif
75
76 node_t *idata; /*+ The extended node IDs (sorted by ID). +*/
77
78 index_t *pdata; /*+ The node indexes after pruning. +*/
79
80 index_t *gdata; /*+ The final node indexes (sorted geographically). +*/
81
82 BitMask *super; /*+ A bit-mask marker for super nodes (same order as sorted nodes). +*/
83
84 index_t latbins; /*+ The number of bins containing latitude. +*/
85 index_t lonbins; /*+ The number of bins containing longitude. +*/
86
87 ll_bin_t latzero; /*+ The bin number of the furthest south bin. +*/
88 ll_bin_t lonzero; /*+ The bin number of the furthest west bin. +*/
89 };
90
91
92 /* Functions in nodesx.c */
93
94 NodesX *NewNodeList(int append,int readonly);
95 void FreeNodeList(NodesX *nodesx,int keep);
96
97 void AppendNodeList(NodesX *nodesx,node_t id,double latitude,double longitude,transports_t allow,nodeflags_t flags);
98 void FinishNodeList(NodesX *nodesx);
99
100 index_t IndexNodeX(NodesX *nodesx,node_t id);
101
102 void SortNodeList(NodesX *nodesx);
103
104 void RemoveNonHighwayNodes(NodesX *nodesx,WaysX *waysx,int keep);
105
106 void RemovePrunedNodes(NodesX *nodesx,SegmentsX *segmentsx);
107
108 void SortNodeListGeographically(NodesX *nodesx);
109
110 void SaveNodeList(NodesX *nodesx,const char *filename,SegmentsX *segmentsx);
111
112
113 /* Macros and inline functions */
114
115 #if !SLIM
116
117 #define LookupNodeX(nodesx,index,position) &(nodesx)->data[index]
118
119 #define PutBackNodeX(nodesx,nodex) while(0) { /* nop */ }
120
121 #else
122
123 /* Prototypes */
124
125 static inline NodeX *LookupNodeX(NodesX *nodesx,index_t index,int position);
126
127 static inline void PutBackNodeX(NodesX *nodesx,NodeX *nodex);
128
129 CACHE_NEWCACHE_PROTO(NodeX)
130 CACHE_DELETECACHE_PROTO(NodeX)
131 CACHE_FETCHCACHE_PROTO(NodeX)
132 CACHE_REPLACECACHE_PROTO(NodeX)
133 CACHE_INVALIDATECACHE_PROTO(NodeX)
134
135
136 /* Inline functions */
137
138 CACHE_STRUCTURE(NodeX)
139 CACHE_NEWCACHE(NodeX)
140 CACHE_DELETECACHE(NodeX)
141 CACHE_FETCHCACHE(NodeX)
142 CACHE_REPLACECACHE(NodeX)
143 CACHE_INVALIDATECACHE(NodeX)
144
145
146 /*++++++++++++++++++++++++++++++++++++++
147 Lookup a particular extended node with the specified id from the file on disk.
148
149 NodeX *LookupNodeX Returns a pointer to a cached copy of the extended node.
150
151 NodesX *nodesx The set of nodes to use.
152
153 index_t index The node index to look for.
154
155 int position The position in the cache to use.
156 ++++++++++++++++++++++++++++++++++++++*/
157
158 static inline NodeX *LookupNodeX(NodesX *nodesx,index_t index,int position)
159 {
160 nodesx->cached[position-1]=*FetchCachedNodeX(nodesx->cache,index,nodesx->fd,0);
161
162 nodesx->incache[position-1]=index;
163
164 return(&nodesx->cached[position-1]);
165 }
166
167
168 /*++++++++++++++++++++++++++++++++++++++
169 Put back an extended node's data into the file on disk.
170
171 NodesX *nodesx The set of nodes to modify.
172
173 NodeX *nodex The extended node to be put back.
174 ++++++++++++++++++++++++++++++++++++++*/
175
176 static inline void PutBackNodeX(NodesX *nodesx,NodeX *nodex)
177 {
178 int position1=nodex-&nodesx->cached[0];
179
180 ReplaceCachedNodeX(nodesx->cache,nodex,nodesx->incache[position1],nodesx->fd,0);
181 }
182
183 #endif /* SLIM */
184
185
186 #endif /* NODESX_H */

Properties

Name Value
cvs:description Extended nodes header.