Routino SVN Repository Browser

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

ViewVC logotype

Annotation of /trunk/src/segmentsx.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 644 - (hide annotations) (download) (as text)
Sat Feb 26 17:20:40 2011 UTC (14 years, 1 month ago) by amb
File MIME type: text/x-chdr
File size: 6084 byte(s)
Renamed a couple of functions for clarity.

1 amb 110 /***************************************
2     A header file for the extended segments.
3 amb 151
4     Part of the Routino routing software.
5 amb 110 ******************/ /******************
6 amb 643 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 SEGMENTSX_H
24     #define SEGMENTSX_H /*+ To stop multiple inclusions. +*/
25    
26     #include <stdint.h>
27    
28 amb 449 #include "types.h"
29 amb 448 #include "segments.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 _SegmentX
41     {
42 amb 539 node_t node1; /*+ The id of the starting node; initially the OSM value, later the NodeX index. +*/
43     node_t node2; /*+ The id of the finishing node; initially the OSM value, later the NodeX index. +*/
44 amb 110
45 amb 643 index_t next2; /*+ The index of the next segment with the same node2. +*/
46    
47 amb 539 way_t way; /*+ The id of the way; initially the OSM value, later the WayX index. +*/
48 amb 203
49 amb 209 distance_t distance; /*+ The distance between the nodes. +*/
50 amb 110 };
51    
52    
53     /*+ A structure containing a set of segments (memory format). +*/
54     struct _SegmentsX
55     {
56 amb 256 char *filename; /*+ The name of the temporary file. +*/
57     int fd; /*+ The file descriptor of the temporary file. +*/
58 amb 216
59 amb 465 index_t xnumber; /*+ The number of unsorted extended nodes. +*/
60 amb 216
61 amb 452 #if !SLIM
62    
63 amb 643 SegmentX *xdata; /*+ The extended segment data (when mapped into memory). +*/
64 amb 256
65 amb 452 #else
66    
67 amb 643 SegmentX cached[2]; /*+ Two cached extended segments read from the file in slim mode. +*/
68     index_t incache[2]; /*+ The indexes of the cached extended segments. +*/
69 amb 452
70     #endif
71    
72 amb 465 index_t number; /*+ How many entries are still useful? +*/
73 amb 110
74 amb 643 node_t *idata; /*+ An index to the real node number of the segment. +*/
75 amb 209
76 amb 643 index_t *firstnode; /*+ The first segment index for each node. +*/
77 amb 558
78 amb 643 char *usednode; /*+ A flag to indicte if a node is used. +*/
79 amb 110 };
80    
81    
82     /* Functions */
83    
84    
85 amb 326 SegmentsX *NewSegmentList(int append);
86     void FreeSegmentList(SegmentsX *segmentsx,int keep);
87 amb 110
88     void SaveSegmentList(SegmentsX *segmentsx,const char *filename);
89    
90 amb 544 index_t IndexFirstSegmentX1(SegmentsX* segmentsx,node_t node);
91     index_t IndexNextSegmentX1(SegmentsX* segmentsx,index_t segindex,node_t node);
92 amb 256
93 amb 643 SegmentX *FirstSegmentX2(SegmentsX* segmentsx,index_t node,int position);
94     SegmentX *NextSegmentX2(SegmentsX* segmentsx,SegmentX *segmentx,index_t node,int position);
95 amb 279
96 amb 209 void AppendSegment(SegmentsX* segmentsx,way_t way,node_t node1,node_t node2,distance_t distance);
97 amb 110
98 amb 279 void SortSegmentList(SegmentsX* segmentsx);
99 amb 110
100 amb 204 void RemoveBadSegments(NodesX *nodesx,SegmentsX *segmentsx);
101 amb 110
102 amb 644 void MeasureSegments(SegmentsX *segmentsx,NodesX *nodesx,WaysX *waysx);
103 amb 110
104 amb 279 void DeduplicateSegments(SegmentsX* segmentsx,NodesX *nodesx,WaysX *waysx);
105 amb 110
106 amb 209 void CreateRealSegments(SegmentsX *segmentsx,WaysX *waysx);
107    
108 amb 110 void IndexSegments(SegmentsX* segmentsx,NodesX *nodesx);
109    
110 amb 644 void UpdateSegments(SegmentsX *segmentsx,NodesX *nodesx,WaysX *waysx);
111 amb 110
112 amb 643
113 amb 452 /* Macros / inline functions */
114 amb 451
115    
116 amb 452 #if !SLIM
117    
118     #define LookupSegmentX(segmentsx,index,position) &(segmentsx)->xdata[index]
119    
120 amb 643 #define IndexSegmentX(segmentsx,segmentx) ((segmentx)-&(segmentsx)->xdata[0])
121 amb 557
122 amb 643 #define PutBackSegmentX(segmentsx,index,position) /* nop */
123    
124 amb 452 #else
125    
126     static SegmentX *LookupSegmentX(SegmentsX* segmentsx,index_t index,int position);
127    
128 amb 643 static index_t IndexSegmentX(SegmentsX *segmentsx,SegmentX *segmentx);
129 amb 452
130 amb 643 static void PutBackSegmentX(SegmentsX* segmentsx,index_t index,int position);
131 amb 452
132    
133 amb 451 /*++++++++++++++++++++++++++++++++++++++
134     Lookup a particular extended segment.
135    
136     SegmentX *LookupSegmentX Returns a pointer to the extended segment with the specified id.
137    
138     SegmentsX* segmentsx The set of segments to process.
139    
140     index_t index The segment index to look for.
141    
142     int position The position in the cache to use.
143     ++++++++++++++++++++++++++++++++++++++*/
144    
145     static inline SegmentX *LookupSegmentX(SegmentsX* segmentsx,index_t index,int position)
146     {
147 amb 464 SeekFile(segmentsx->fd,(off_t)index*sizeof(SegmentX));
148 amb 451
149 amb 643 ReadFile(segmentsx->fd,&segmentsx->cached[position-1],sizeof(SegmentX));
150 amb 451
151 amb 643 segmentsx->incache[position-1]=index;
152    
153     return(&segmentsx->cached[position-1]);
154 amb 451 }
155    
156    
157     /*++++++++++++++++++++++++++++++++++++++
158 amb 643 Find the extended segment index for a particular extended segment pointer.
159 amb 451
160 amb 643 index_t IndexSegmentX Returns the index of the extended segment in the list.
161 amb 451
162 amb 643 SegmentsX *segmentsx The extended segments structure to use.
163 amb 451
164 amb 643 SegmentX *segmentx The extended segment whose index is to be found.
165 amb 451 ++++++++++++++++++++++++++++++++++++++*/
166    
167 amb 643 static inline index_t IndexSegmentX(SegmentsX *segmentsx,SegmentX *segmentx)
168 amb 451 {
169 amb 643 int i;
170 amb 451
171 amb 643 for(i=0;i<sizeof(segmentsx->cached)/sizeof(segmentsx->cached[0]);i++)
172     if(&segmentsx->cached[i]==segmentx)
173     return(segmentsx->incache[i]);
174 amb 451
175 amb 643 return(NO_SEGMENT);
176 amb 451 }
177    
178    
179     /*++++++++++++++++++++++++++++++++++++++
180 amb 643 Put back an extended segment's data.
181 amb 451
182     SegmentsX* segmentsx The set of segments to process.
183    
184 amb 643 index_t index The segment index to put back.
185 amb 451
186     int position The position in the cache to use.
187     ++++++++++++++++++++++++++++++++++++++*/
188    
189 amb 643 static inline void PutBackSegmentX(SegmentsX* segmentsx,index_t index,int position)
190 amb 451 {
191 amb 643 SeekFile(segmentsx->fd,(off_t)index*sizeof(SegmentX));
192 amb 451
193 amb 643 WriteFile(segmentsx->fd,&segmentsx->cached[position-1],sizeof(SegmentX));
194 amb 451 }
195    
196 amb 452 #endif /* SLIM */
197 amb 451
198 amb 452
199 amb 110 #endif /* SEGMENTSX_H */

Properties

Name Value
cvs:description Extended segments header.