Routino SVN Repository Browser

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

ViewVC logotype

Contents of /trunk/src/segments.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 26 - (show annotations) (download) (as text)
Sat Jan 10 11:53:49 2009 UTC (16 years, 3 months ago) by amb
File MIME type: text/x-chdr
File size: 3946 byte(s)
About to add the super-segment functionality using Segments data type to hold
them.

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

Properties

Name Value
cvs:description Header file for segments.