Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino
Annotation of /trunk/src/waysx.h
Parent Directory
|
Revision Log
Revision 1120 -
(hide annotations)
(download)
(as text)
Thu Nov 1 20:00:27 2012 UTC (12 years, 4 months ago) by amb
File MIME type: text/x-chdr
File size: 4330 byte(s)
Thu Nov 1 20:00:27 2012 UTC (12 years, 4 months ago) by amb
File MIME type: text/x-chdr
File size: 4330 byte(s)
Introduce a new'--append' option for appending data from a file to the currently parsed data. Rename the intermediate file used for storing data to be appended to. Add a function to call after appending to a file which closes the file and renames it to a temporary filename which is used for the remaining processing.
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 | 964 | This file Copyright 2008-2012 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 | 1100 | way_t id; /*+ The way identifier; initially the OSM value, later the Way index. +*/ |
43 | amb | 203 | |
44 | amb | 1090 | Way way; /*+ The real way data. +*/ |
45 | amb | 110 | }; |
46 | |||
47 | |||
48 | /*+ A structure containing a set of ways (memory format). +*/ | ||
49 | struct _WaysX | ||
50 | { | ||
51 | amb | 1120 | char *filename; /*+ The name of the intermediate file (for the WaysX). +*/ |
52 | char *filename_tmp; /*+ The name of the temporary file (for the WaysX). +*/ | ||
53 | amb | 216 | |
54 | amb | 1120 | int fd; /*+ The file descriptor of the open file (for the WaysX). +*/ |
55 | |||
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 | 964 | WayX cached[3]; /*+ Three cached extended ways read from the file in slim mode. +*/ |
65 | index_t incache[3]; /*+ The indexes of the cached extended ways. +*/ | ||
66 | amb | 452 | |
67 | #endif | ||
68 | |||
69 | amb | 755 | way_t *idata; /*+ The extended way IDs (sorted by ID). +*/ |
70 | amb | 203 | |
71 | amb | 1100 | index_t *cdata; /*+ The compacted way IDs (same order as sorted ways). +*/ |
72 | amb | 1093 | |
73 | amb | 1120 | char *nfilename_tmp; /*+ The name of the temporary file (for the WaysX names). +*/ |
74 | amb | 203 | |
75 | amb | 1120 | int nfd; /*+ The file descriptor of the temporary file (for the WaysX names). +*/ |
76 | |||
77 | amb | 680 | uint32_t nlength; /*+ The length of the string of name entries. +*/ |
78 | amb | 110 | }; |
79 | |||
80 | |||
81 | amb | 680 | /* Functions in waysx.c */ |
82 | amb | 110 | |
83 | |||
84 | amb | 326 | WaysX *NewWayList(int append); |
85 | void FreeWayList(WaysX *waysx,int keep); | ||
86 | amb | 1120 | void FinishWayList(WaysX *waysx); |
87 | amb | 110 | |
88 | amb | 398 | void SaveWayList(WaysX *waysx,const char *filename); |
89 | amb | 110 | |
90 | amb | 682 | index_t IndexWayX(WaysX *waysx,way_t id); |
91 | amb | 110 | |
92 | amb | 682 | void AppendWay(WaysX *waysx,way_t id,Way *way,const char *name); |
93 | amb | 203 | |
94 | amb | 110 | void SortWayList(WaysX *waysx); |
95 | |||
96 | amb | 1100 | void CompactWayList(WaysX *waysx,SegmentsX *segmentsx); |
97 | amb | 451 | |
98 | amb | 499 | |
99 | amb | 452 | /* Macros / inline functions */ |
100 | amb | 451 | |
101 | amb | 452 | #if !SLIM |
102 | amb | 451 | |
103 | amb | 651 | #define LookupWayX(waysx,index,position) &(waysx)->data[index] |
104 | amb | 452 | |
105 | amb | 942 | #define PutBackWayX(waysx,wayx) /* nop */ |
106 | amb | 557 | |
107 | amb | 452 | #else |
108 | |||
109 | amb | 682 | static WayX *LookupWayX(WaysX *waysx,index_t index,int position); |
110 | amb | 452 | |
111 | amb | 942 | static void PutBackWayX(WaysX *waysx,WayX *wayx); |
112 | amb | 452 | |
113 | amb | 557 | |
114 | amb | 451 | /*++++++++++++++++++++++++++++++++++++++ |
115 | amb | 680 | Lookup a particular extended way with the specified id from the file on disk. |
116 | amb | 451 | |
117 | amb | 680 | WayX *LookupWayX Returns a pointer to a cached copy of the extended way. |
118 | amb | 451 | |
119 | amb | 682 | WaysX *waysx The set of ways to use. |
120 | amb | 451 | |
121 | index_t index The way index to look for. | ||
122 | |||
123 | int position The position in the cache to use. | ||
124 | ++++++++++++++++++++++++++++++++++++++*/ | ||
125 | |||
126 | amb | 682 | static inline WayX *LookupWayX(WaysX *waysx,index_t index,int position) |
127 | amb | 451 | { |
128 | amb | 887 | SeekReadFile(waysx->fd,&waysx->cached[position-1],sizeof(WayX),(off_t)index*sizeof(WayX)); |
129 | amb | 451 | |
130 | amb | 942 | waysx->incache[position-1]=index; |
131 | |||
132 | amb | 651 | return(&waysx->cached[position-1]); |
133 | amb | 451 | } |
134 | |||
135 | amb | 505 | |
136 | /*++++++++++++++++++++++++++++++++++++++ | ||
137 | amb | 680 | Put back an extended way's data into the file on disk. |
138 | amb | 505 | |
139 | amb | 682 | WaysX *waysx The set of ways to use. |
140 | amb | 505 | |
141 | amb | 942 | WayX *wayx The extended way to be put back. |
142 | amb | 505 | ++++++++++++++++++++++++++++++++++++++*/ |
143 | |||
144 | amb | 942 | static inline void PutBackWayX(WaysX *waysx,WayX *wayx) |
145 | amb | 505 | { |
146 | amb | 942 | int position1=wayx-&waysx->cached[0]; |
147 | |||
148 | SeekWriteFile(waysx->fd,&waysx->cached[position1],sizeof(WayX),(off_t)waysx->incache[position1]*sizeof(WayX)); | ||
149 | amb | 505 | } |
150 | |||
151 | amb | 452 | #endif /* SLIM */ |
152 | amb | 451 | |
153 | amb | 452 | |
154 | amb | 110 | #endif /* WAYSX_H */ |
Properties
Name | Value |
---|---|
cvs:description | Extended ways header. |