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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 27 - (hide annotations) (download) (as text)
Sat Jan 10 13:39:30 2009 UTC (16 years, 2 months ago) by amb
File MIME type: text/x-chdr
File size: 3868 byte(s)
Increase the increment for the indexed array case.

1 amb 24 /***************************************
2 amb 27 $Header: /home/amb/CVS/routino/src/segments.h,v 1.3 2009-01-10 13:39:30 amb Exp $
3 amb 24
4     A header file for the segments.
5     ******************/ /******************
6     Written by Andrew M. Bishop
7    
8     This file Copyright 2009 Andrew M. Bishop
9     It may be distributed under the GNU Public License, version 2, or
10     any higher version. See section COPYING of the GNU Public license
11     for conditions under which this file may be redistributed.
12     ***************************************/
13    
14    
15     #ifndef SEGMENTS_H
16     #define SEGMENTS_H /*+ To stop multiple inclusions. +*/
17    
18     #include <stdint.h>
19    
20 amb 26 #include "nodes.h"
21     #include "ways.h"
22 amb 24
23 amb 26
24 amb 24 /* Constants */
25    
26    
27     #if 1 /* set to 0 to use a flat array, 1 for indexed. */
28    
29     /*+ The number of bins for segments. +*/
30     #define NBINS_SEGMENTS 2048
31    
32     #else
33    
34     #undef NBINS_SEGMENTS
35    
36     #endif
37    
38 amb 27 /*+ The array size increment for segments. +*/
39     #define INCREMENT_SEGMENTS 1024*1024
40 amb 24
41 amb 27
42 amb 24 /* Simple Types */
43    
44    
45     /*+ A short distance, measured in metres (up to ~65.5km). +*/
46     typedef uint16_t distance_short_t;
47    
48     /*+ A short duration, measured in centiseconds (up to ~11 minutes). +*/
49     typedef uint16_t duration_short_t;
50    
51    
52     /*+ A long distance, measured in metres. +*/
53     typedef uint32_t distance_t;
54    
55     /*+ Conversion from distance_t to kilometres. +*/
56     #define distance_to_km(xx) ((double)(xx)/1000.0)
57    
58     /*+ Conversion from metres to distance_t. +*/
59     #define km_to_distance(xx) ((distance_t)((double)(xx)*1000.0))
60    
61     /*+ A duration, measured in centiseconds. +*/
62     typedef uint32_t duration_t;
63    
64     /*+ Conversion from duration_t to minutes. +*/
65     #define duration_to_minutes(xx) ((double)(xx)/6000.0)
66    
67     /*+ Conversion from duration_t to hours. +*/
68     #define duration_to_hours(xx) ((double)(xx)/360000.0)
69    
70     /*+ Conversion from hours to duration_t. +*/
71     #define hours_to_duration(xx) ((duration_t)((double)(xx)*360000.0))
72    
73    
74     /* Data structures */
75    
76    
77     /*+ A structure containing a single segment. +*/
78     typedef struct _Segment
79     {
80     node_t node1; /*+ The starting node. +*/
81     node_t node2; /*+ The finishing node. +*/
82     way_t way; /*+ The way associated with the segment. +*/
83     distance_short_t distance; /*+ The distance between the nodes. +*/
84     duration_short_t duration; /*+ The time duration to travel between the nodes. +*/
85     }
86     Segment;
87    
88     /*+ A structure containing a set of segments (mmap format). +*/
89     typedef struct _Segments
90     {
91 amb 26 uint32_t number; /*+ How many entries are used? +*/
92 amb 24 #ifdef NBINS_SEGMENTS
93 amb 26 uint32_t offset[NBINS_SEGMENTS+1]; /*+ An offset to the first entry in each bin. +*/
94 amb 24 #endif
95     Segment segments[1]; /*+ An array of segments whose size is not limited to 1
96     (i.e. may overflow the end of this structure). +*/
97     }
98     Segments;
99    
100     /*+ A structure containing a set of segments (memory format). +*/
101     typedef struct _SegmentsMem
102     {
103     uint32_t alloced; /*+ How many entries are allocated? +*/
104     uint32_t number; /*+ How many entries are used? +*/
105     uint32_t sorted; /*+ Is the data sorted and therefore searchable? +*/
106    
107     Segments *segments; /*+ The real data +*/
108     }
109     SegmentsMem;
110    
111    
112 amb 26 /* Functions in segments.c */
113 amb 24
114    
115     SegmentsMem *NewSegmentList(void);
116    
117     Segments *LoadSegmentList(const char *filename);
118     Segments *SaveSegmentList(SegmentsMem *segments,const char *filename);
119    
120     Segment *FindFirstSegment(Segments *segments,node_t node);
121     Segment *FindNextSegment(Segments *segments,Segment *segment);
122    
123     void AppendSegment(SegmentsMem *segments,node_t node1,node_t node2,way_t way);
124    
125     void SortSegmentList(SegmentsMem *segments);
126    
127     void FixupSegmentLengths(SegmentsMem *segments,Nodes *nodes,Ways *ways);
128    
129     distance_t Distance(Node *node1,Node *node2);
130    
131    
132 amb 26 /* Functions in supersegments.c */
133    
134    
135     void ChooseSuperSegments(SegmentsMem *supersegments,Nodes *nodes,Segments *segments,Ways *ways);
136    
137    
138 amb 24 #endif /* SEGMENTS_H */

Properties

Name Value
cvs:description Header file for segments.