Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino
Contents of /trunk/src/nodesx.h
Parent Directory
|
Revision Log
Revision 552 -
(show annotations)
(download)
(as text)
Mon Dec 20 17:38:29 2010 UTC (14 years, 2 months ago) by amb
File MIME type: text/x-chdr
File size: 4875 byte(s)
Mon Dec 20 17:38:29 2010 UTC (14 years, 2 months ago) by amb
File MIME type: text/x-chdr
File size: 4875 byte(s)
Don't maintain a copy of the whole set of Nodes along with the NodeXs but generate the Node from the NodeX when written to disk. Create a lookup table between the original index and the geographically sorted index.
1 | /*************************************** |
2 | $Header: /home/amb/CVS/routino/src/nodesx.h,v 1.35 2010-12-20 17:38:29 amb Exp $ |
3 | |
4 | A header file for the extended nodes. |
5 | |
6 | Part of the Routino routing software. |
7 | ******************/ /****************** |
8 | This file Copyright 2008-2010 Andrew M. Bishop |
9 | |
10 | 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 | ***************************************/ |
23 | |
24 | |
25 | #ifndef NODESX_H |
26 | #define NODESX_H /*+ To stop multiple inclusions. +*/ |
27 | |
28 | #include <stdint.h> |
29 | |
30 | #include "types.h" |
31 | #include "nodes.h" |
32 | |
33 | #include "typesx.h" |
34 | |
35 | #include "files.h" |
36 | |
37 | |
38 | /* Data structures */ |
39 | |
40 | |
41 | /*+ An extended structure used for processing. +*/ |
42 | struct _NodeX |
43 | { |
44 | node_t id; /*+ The node identifier; initially the OSM value, later the Node index. +*/ |
45 | |
46 | latlong_t latitude; /*+ The node latitude. +*/ |
47 | latlong_t longitude; /*+ The node longitude. +*/ |
48 | |
49 | transports_t allow; /*+ The node allowed traffic. +*/ |
50 | |
51 | uint16_t flags; /*+ The node flags. +*/ |
52 | }; |
53 | |
54 | /*+ A structure containing a set of nodes (memory format). +*/ |
55 | struct _NodesX |
56 | { |
57 | char *filename; /*+ The name of the temporary file. +*/ |
58 | int fd; /*+ The file descriptor of the temporary file. +*/ |
59 | |
60 | index_t xnumber; /*+ The number of unsorted extended nodes. +*/ |
61 | |
62 | #if !SLIM |
63 | |
64 | NodeX *xdata; /*+ The extended node data (sorted). +*/ |
65 | |
66 | #else |
67 | |
68 | NodeX xcached[2]; /*+ Two cached nodes read from the file in slim mode. +*/ |
69 | |
70 | #endif |
71 | |
72 | index_t number; /*+ How many entries are still useful? +*/ |
73 | |
74 | node_t *idata; /*+ The extended node IDs (sorted by ID). +*/ |
75 | |
76 | node_t *gdata; /*+ The final node indexes (sorted by ID). +*/ |
77 | |
78 | uint8_t *super; /*+ A marker for super nodes (same order as sorted nodes). +*/ |
79 | |
80 | index_t latbins; /*+ The number of bins containing latitude. +*/ |
81 | index_t lonbins; /*+ The number of bins containing longitude. +*/ |
82 | |
83 | ll_bin_t latzero; /*+ The bin number of the furthest south bin. +*/ |
84 | ll_bin_t lonzero; /*+ The bin number of the furthest west bin. +*/ |
85 | |
86 | index_t latlonbin; /*+ A temporary index into the offsets array. +*/ |
87 | |
88 | index_t *offsets; /*+ An array of offset to the first node in each bin. +*/ |
89 | }; |
90 | |
91 | |
92 | /* Functions */ |
93 | |
94 | NodesX *NewNodeList(int append); |
95 | void FreeNodeList(NodesX *nodesx,int keep); |
96 | |
97 | void SaveNodeList(NodesX *nodesx,const char *filename); |
98 | |
99 | index_t IndexNodeX(NodesX* nodesx,node_t id); |
100 | |
101 | void AppendNode(NodesX* nodesx,node_t id,double latitude,double longitude,transports_t allow,uint16_t flags); |
102 | |
103 | void SortNodeList(NodesX *nodesx); |
104 | |
105 | void SortNodeListGeographically(NodesX* nodesx); |
106 | |
107 | void RemoveNonHighwayNodes(NodesX *nodesx,SegmentsX *segmentsx); |
108 | |
109 | void CreateRealNodes(NodesX *nodesx,int iteration); |
110 | |
111 | void IndexNodes(NodesX *nodesx,SegmentsX *segmentsx); |
112 | |
113 | |
114 | /* Macros / inline functions */ |
115 | |
116 | #if !SLIM |
117 | |
118 | #define LookupNodeX(nodesx,index,position) &(nodesx)->xdata[index] |
119 | |
120 | #else |
121 | |
122 | static NodeX *LookupNodeX(NodesX* nodesx,index_t index,int position); |
123 | |
124 | static void PutBackNodeX(NodesX* nodesx,index_t index,int position); |
125 | |
126 | |
127 | /*++++++++++++++++++++++++++++++++++++++ |
128 | Lookup a particular extended node. |
129 | |
130 | NodeX *LookupNodeX Returns a pointer to the extended node with the specified id. |
131 | |
132 | NodesX* nodesx The set of nodes to process. |
133 | |
134 | index_t index The node index to look for. |
135 | |
136 | int position The position in the cache to use. |
137 | ++++++++++++++++++++++++++++++++++++++*/ |
138 | |
139 | static inline NodeX *LookupNodeX(NodesX* nodesx,index_t index,int position) |
140 | { |
141 | SeekFile(nodesx->fd,(off_t)index*sizeof(NodeX)); |
142 | |
143 | ReadFile(nodesx->fd,&nodesx->xcached[position-1],sizeof(NodeX)); |
144 | |
145 | return(&nodesx->xcached[position-1]); |
146 | } |
147 | |
148 | |
149 | /*++++++++++++++++++++++++++++++++++++++ |
150 | Put back an extended node's data. |
151 | |
152 | NodesX* nodesx The set of nodes to process. |
153 | |
154 | index_t index The node index to look for. |
155 | |
156 | int position The position in the cache to use. |
157 | ++++++++++++++++++++++++++++++++++++++*/ |
158 | |
159 | static inline void PutBackNodeX(NodesX* nodesx,index_t index,int position) |
160 | { |
161 | SeekFile(nodesx->fd,(off_t)index*sizeof(NodeX)); |
162 | |
163 | WriteFile(nodesx->fd,&nodesx->xcached[position-1],sizeof(NodeX)); |
164 | } |
165 | |
166 | #endif /* SLIM */ |
167 | |
168 | |
169 | #endif /* NODESX_H */ |
Properties
Name | Value |
---|---|
cvs:description | Extended nodes header. |