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/waysx.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 651 - (hide annotations) (download) (as text)
Sun Feb 27 16:31:34 2011 UTC (14 years ago) by amb
File MIME type: text/x-chdr
File size: 4121 byte(s)
Rename the xdata and xcached members of the nodesx, segmentsx and waysx
structures.

1 amb 110 /***************************************
2     A header file for the extended Ways structure.
3 amb 151
4     Part of the Routino routing software.
5 amb 110 ******************/ /******************
6 amb 650 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 WAYSX_H
24     #define WAYSX_H /*+ To stop multiple inclusions. +*/
25    
26     #include <stdint.h>
27    
28 amb 449 #include "types.h"
29    
30 amb 199 #include "typesx.h"
31 amb 262 #include "ways.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 containing a single way. +*/
40     struct _WayX
41     {
42 amb 539 way_t id; /*+ The way identifier; the OSM value. +*/
43 amb 203
44 amb 310 index_t prop; /*+ The index of the properties of the way in the compacted list. +*/
45    
46 amb 262 Way way; /*+ The real Way data. +*/
47 amb 110 };
48    
49    
50     /*+ A structure containing a set of ways (memory format). +*/
51     struct _WaysX
52     {
53 amb 262 char *filename; /*+ The name of the temporary file (for the WaysX). +*/
54     int fd; /*+ The file descriptor of the temporary file (for the WaysX). +*/
55 amb 216
56 amb 650 index_t number; /*+ The number of extended ways still being considered. +*/
57 amb 216
58 amb 452 #if !SLIM
59    
60 amb 651 WayX *data; /*+ The extended ways data (when mapped into memory). +*/
61 amb 262
62 amb 452 #else
63    
64 amb 651 WayX cached[2]; /*+ Two cached ways read from the file in slim mode. +*/
65 amb 452
66     #endif
67    
68 amb 465 index_t cnumber; /*+ How many entries are there after compacting? +*/
69 amb 203
70 amb 310 index_t *idata; /*+ The index of the extended data for the Ways (sorted by ID). +*/
71 amb 203
72 amb 262 char *nfilename; /*+ The name of the temporary file (for the names). +*/
73 amb 555 int nfd; /*+ The file descriptor of the temporary file (for the names). +*/
74 amb 203
75 amb 262 uint32_t nlength; /*+ How long is the string of name entries? +*/
76 amb 110 };
77    
78    
79     /* Functions */
80    
81    
82 amb 326 WaysX *NewWayList(int append);
83     void FreeWayList(WaysX *waysx,int keep);
84 amb 110
85 amb 398 void SaveWayList(WaysX *waysx,const char *filename);
86 amb 110
87 amb 262 index_t IndexWayX(WaysX* waysx,way_t id);
88 amb 110
89 amb 262 void AppendWay(WaysX* waysx,way_t id,Way *way,const char *name);
90 amb 203
91 amb 110 void SortWayList(WaysX *waysx);
92    
93 amb 499 void CompactWayList(WaysX *waysx);
94 amb 451
95 amb 499
96 amb 452 /* Macros / inline functions */
97 amb 451
98 amb 452 #if !SLIM
99 amb 451
100 amb 651 #define LookupWayX(waysx,index,position) &(waysx)->data[index]
101 amb 452
102 amb 557 #define PutBackWayX(waysx,index,position) /* nop */
103    
104 amb 452 #else
105    
106     static WayX *LookupWayX(WaysX* waysx,index_t index,int position);
107    
108 amb 557 static void PutBackWayX(WaysX* waysx,index_t index,int position);
109 amb 452
110 amb 557
111 amb 451 /*++++++++++++++++++++++++++++++++++++++
112 amb 505 Lookup a particular extended way.
113 amb 451
114     WayX *LookupWayX Returns a pointer to the extended way with the specified id.
115    
116     WaysX* waysx The set of ways to process.
117    
118     index_t index The way index to look for.
119    
120     int position The position in the cache to use.
121     ++++++++++++++++++++++++++++++++++++++*/
122    
123     static inline WayX *LookupWayX(WaysX* waysx,index_t index,int position)
124     {
125 amb 464 SeekFile(waysx->fd,(off_t)index*sizeof(WayX));
126 amb 451
127 amb 651 ReadFile(waysx->fd,&waysx->cached[position-1],sizeof(WayX));
128 amb 451
129 amb 651 return(&waysx->cached[position-1]);
130 amb 451 }
131    
132 amb 505
133     /*++++++++++++++++++++++++++++++++++++++
134     Put back an extended way.
135    
136     WaysX* waysx The set of ways to process.
137    
138     index_t index The way index to put back.
139    
140     int position The position in the cache to use.
141     ++++++++++++++++++++++++++++++++++++++*/
142    
143     static inline void PutBackWayX(WaysX* waysx,index_t index,int position)
144     {
145     SeekFile(waysx->fd,(off_t)index*sizeof(WayX));
146    
147 amb 651 WriteFile(waysx->fd,&waysx->cached[position-1],sizeof(WayX));
148 amb 505 }
149    
150 amb 452 #endif /* SLIM */
151 amb 451
152 amb 452
153 amb 110 #endif /* WAYSX_H */

Properties

Name Value
cvs:description Extended ways header.