Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino
Contents of /trunk/src/segmentsx.h
Parent Directory
|
Revision Log
Revision 451 -
(show annotations)
(download)
(as text)
Tue Jul 13 17:43:51 2010 UTC (14 years, 8 months ago) by amb
File MIME type: text/x-chdr
File size: 6089 byte(s)
Tue Jul 13 17:43:51 2010 UTC (14 years, 8 months ago) by amb
File MIME type: text/x-chdr
File size: 6089 byte(s)
Move the functions for slim mode out into the header file and make it inline.
1 | /*************************************** |
2 | $Header: /home/amb/CVS/routino/src/segmentsx.h,v 1.23 2010-07-13 17:43:51 amb Exp $ |
3 | |
4 | A header file for the extended segments. |
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 SEGMENTSX_H |
26 | #define SEGMENTSX_H /*+ To stop multiple inclusions. +*/ |
27 | |
28 | #include <stdint.h> |
29 | |
30 | #include "types.h" |
31 | #include "segments.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 _SegmentX |
43 | { |
44 | node_t node1; /*+ The id of the starting node. +*/ |
45 | node_t node2; /*+ The id of the finishing node. +*/ |
46 | |
47 | way_t way; /*+ The id of the way. +*/ |
48 | |
49 | distance_t distance; /*+ The distance between the nodes. +*/ |
50 | }; |
51 | |
52 | |
53 | /*+ A structure containing a set of segments (memory format). +*/ |
54 | struct _SegmentsX |
55 | { |
56 | char *filename; /*+ The name of the temporary file. +*/ |
57 | int fd; /*+ The file descriptor of the temporary file. +*/ |
58 | |
59 | uint32_t xnumber; /*+ The number of unsorted extended nodes. +*/ |
60 | |
61 | SegmentX *xdata; /*+ The extended segment data (unsorted). +*/ |
62 | SegmentX cached[2]; /*+ Two cached segments read from the file in slim mode. +*/ |
63 | |
64 | uint32_t number; /*+ How many entries are still useful? +*/ |
65 | |
66 | node_t *idata; /*+ The extended segment data (sorted by node1 then node2). +*/ |
67 | index_t *firstnode; /*+ The first segment index for each node. +*/ |
68 | |
69 | Segment *sdata; /*+ The segment data (same order as n1data). +*/ |
70 | |
71 | char *sfilename; /*+ The name of the temporary file for segments in slim mode. +*/ |
72 | int sfd; /*+ The file descriptor of the temporary file. +*/ |
73 | |
74 | Segment scached[2]; /*+ Two cached segments read from the file in slim mode. +*/ |
75 | }; |
76 | |
77 | |
78 | /* Functions */ |
79 | |
80 | |
81 | SegmentsX *NewSegmentList(int append); |
82 | void FreeSegmentList(SegmentsX *segmentsx,int keep); |
83 | |
84 | void SaveSegmentList(SegmentsX *segmentsx,const char *filename); |
85 | |
86 | static SegmentX *LookupSegmentX(SegmentsX* segmentsx,index_t index,int position); |
87 | |
88 | static Segment *LookupSegmentXSegment(SegmentsX* segmentsx,index_t index,int position); |
89 | static void PutBackSegmentXSegment(SegmentsX* segmentsx,index_t index,int position); |
90 | |
91 | index_t IndexFirstSegmentX(SegmentsX* segmentsx,node_t node); |
92 | |
93 | index_t IndexNextSegmentX(SegmentsX* segmentsx,index_t segindex,index_t nodeindex); |
94 | |
95 | void AppendSegment(SegmentsX* segmentsx,way_t way,node_t node1,node_t node2,distance_t distance); |
96 | |
97 | void SortSegmentList(SegmentsX* segmentsx); |
98 | |
99 | void RemoveBadSegments(NodesX *nodesx,SegmentsX *segmentsx); |
100 | |
101 | void UpdateSegments(SegmentsX *segmentsx,NodesX *nodesx,WaysX *waysx); |
102 | |
103 | void RotateSegments(SegmentsX* segmentsx); |
104 | |
105 | void DeduplicateSegments(SegmentsX* segmentsx,NodesX *nodesx,WaysX *waysx); |
106 | |
107 | void CreateRealSegments(SegmentsX *segmentsx,WaysX *waysx); |
108 | |
109 | void IndexSegments(SegmentsX* segmentsx,NodesX *nodesx); |
110 | |
111 | |
112 | /* Inline the frequently called functions */ |
113 | |
114 | /*+ The command line '--slim' option. +*/ |
115 | extern int option_slim; |
116 | |
117 | /*++++++++++++++++++++++++++++++++++++++ |
118 | Lookup a particular extended segment. |
119 | |
120 | SegmentX *LookupSegmentX Returns a pointer to the extended segment with the specified id. |
121 | |
122 | SegmentsX* segmentsx The set of segments to process. |
123 | |
124 | index_t index The segment index to look for. |
125 | |
126 | int position The position in the cache to use. |
127 | ++++++++++++++++++++++++++++++++++++++*/ |
128 | |
129 | static inline SegmentX *LookupSegmentX(SegmentsX* segmentsx,index_t index,int position) |
130 | { |
131 | assert(index!=NO_SEGMENT); /* Must be a valid segment */ |
132 | |
133 | if(option_slim) |
134 | { |
135 | SeekFile(segmentsx->fd,index*sizeof(SegmentX)); |
136 | |
137 | ReadFile(segmentsx->fd,&segmentsx->cached[position-1],sizeof(SegmentX)); |
138 | |
139 | return(&segmentsx->cached[position-1]); |
140 | } |
141 | else |
142 | { |
143 | return(&segmentsx->xdata[index]); |
144 | } |
145 | } |
146 | |
147 | |
148 | /*++++++++++++++++++++++++++++++++++++++ |
149 | Lookup a particular extended segment's normal segment. |
150 | |
151 | Segment *LookupSegmentXSegment Returns a pointer to the segment with the specified id. |
152 | |
153 | SegmentsX* segmentsx The set of segments to process. |
154 | |
155 | index_t index The segment index to look for. |
156 | |
157 | int position The position in the cache to use. |
158 | ++++++++++++++++++++++++++++++++++++++*/ |
159 | |
160 | static inline Segment *LookupSegmentXSegment(SegmentsX* segmentsx,index_t index,int position) |
161 | { |
162 | assert(index!=NO_SEGMENT); /* Must be a valid segment */ |
163 | |
164 | if(option_slim) |
165 | { |
166 | SeekFile(segmentsx->sfd,index*sizeof(Segment)); |
167 | |
168 | ReadFile(segmentsx->sfd,&segmentsx->scached[position-1],sizeof(Segment)); |
169 | |
170 | return(&segmentsx->scached[position-1]); |
171 | } |
172 | else |
173 | { |
174 | return(&segmentsx->sdata[index]); |
175 | } |
176 | } |
177 | |
178 | |
179 | /*++++++++++++++++++++++++++++++++++++++ |
180 | Put back an extended segment's normal segment. |
181 | |
182 | SegmentsX* segmentsx The set of segments to process. |
183 | |
184 | index_t index The segment index to look for. |
185 | |
186 | int position The position in the cache to use. |
187 | ++++++++++++++++++++++++++++++++++++++*/ |
188 | |
189 | static inline void PutBackSegmentXSegment(SegmentsX* segmentsx,index_t index,int position) |
190 | { |
191 | assert(index!=NO_SEGMENT); /* Must be a valid segment */ |
192 | |
193 | if(option_slim) |
194 | { |
195 | SeekFile(segmentsx->sfd,index*sizeof(Segment)); |
196 | |
197 | WriteFile(segmentsx->sfd,&segmentsx->scached[position-1],sizeof(Segment)); |
198 | } |
199 | } |
200 | |
201 | |
202 | #endif /* SEGMENTSX_H */ |
Properties
Name | Value |
---|---|
cvs:description | Extended segments header. |