Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino
Annotation of /trunk/src/segments.h
Parent Directory
|
Revision Log
Revision 303 -
(hide annotations)
(download)
(as text)
Sat Nov 14 19:39:20 2009 UTC (15 years, 4 months ago) by amb
File MIME type: text/x-chdr
File size: 3359 byte(s)
Sat Nov 14 19:39:20 2009 UTC (15 years, 4 months ago) by amb
File MIME type: text/x-chdr
File size: 3359 byte(s)
If a selected waypoint is not very close to an existing node then insert a fake node in the segment that comes closest and use that instead.
1 | amb | 24 | /*************************************** |
2 | amb | 303 | $Header: /home/amb/CVS/routino/src/segments.h,v 1.34 2009-11-14 19:39:20 amb Exp $ |
3 | amb | 24 | |
4 | A header file for the segments. | ||
5 | amb | 151 | |
6 | Part of the Routino routing software. | ||
7 | amb | 24 | ******************/ /****************** |
8 | amb | 151 | This file Copyright 2008,2009 Andrew M. Bishop |
9 | amb | 24 | |
10 | amb | 151 | This program is free software: you can redistribute it and/or modify |
11 | it under the terms of the GNU Affero General Public License as published by | ||
12 | the Free Software Foundation, either version 3 of the License, or | ||
13 | (at your option) any later version. | ||
14 | |||
15 | This program is distributed in the hope that it will be useful, | ||
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | GNU Affero General Public License for more details. | ||
19 | |||
20 | You should have received a copy of the GNU Affero General Public License | ||
21 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
22 | amb | 24 | ***************************************/ |
23 | |||
24 | |||
25 | #ifndef SEGMENTS_H | ||
26 | #define SEGMENTS_H /*+ To stop multiple inclusions. +*/ | ||
27 | |||
28 | #include <stdint.h> | ||
29 | |||
30 | amb | 96 | #include "types.h" |
31 | amb | 82 | #include "profiles.h" |
32 | amb | 24 | |
33 | amb | 26 | |
34 | amb | 24 | /* Data structures */ |
35 | |||
36 | |||
37 | amb | 109 | /*+ A structure containing a single segment. +*/ |
38 | struct _Segment | ||
39 | amb | 88 | { |
40 | amb | 109 | index_t node1; /*+ The index of the starting node. +*/ |
41 | index_t node2; /*+ The index of the finishing node. +*/ | ||
42 | amb | 88 | |
43 | amb | 109 | index_t next2; /*+ The index of the next segment sharing node2. +*/ |
44 | amb | 88 | |
45 | amb | 109 | index_t way; /*+ The index of the way associated with the segment. +*/ |
46 | |||
47 | distance_t distance; /*+ The distance between the nodes. +*/ | ||
48 | }; | ||
49 | |||
50 | |||
51 | amb | 24 | /*+ A structure containing a set of segments (mmap format). +*/ |
52 | amb | 109 | struct _Segments |
53 | amb | 24 | { |
54 | amb | 232 | uint32_t number; /*+ How many segments in total? +*/ |
55 | uint32_t snumber; /*+ How many super-segments? +*/ | ||
56 | uint32_t nnumber; /*+ How many normal segments? +*/ | ||
57 | amb | 88 | |
58 | amb | 104 | Segment *segments; /*+ An array of segments. +*/ |
59 | amb | 88 | |
60 | amb | 104 | void *data; /*+ The memory mapped data. +*/ |
61 | amb | 109 | }; |
62 | amb | 24 | |
63 | |||
64 | amb | 109 | /* Macros */ |
65 | amb | 24 | |
66 | |||
67 | amb | 303 | /*+ Return a segment pointer given a set of segments and an index. +*/ |
68 | amb | 109 | #define LookupSegment(xxx,yyy) (&(xxx)->segments[yyy]) |
69 | amb | 24 | |
70 | amb | 303 | /*+ Return a segment index given a set of segments and a pointer. +*/ |
71 | #define IndexSegment(xxx,yyy) ((yyy)-&(xxx)->segments[0]) | ||
72 | |||
73 | amb | 109 | /*+ Return true if this is a normal segment. +*/ |
74 | amb | 208 | #define IsNormalSegment(xxx) (((xxx)->distance)&SEGMENT_NORMAL) |
75 | amb | 24 | |
76 | amb | 109 | /*+ Return true if this is a super-segment. +*/ |
77 | amb | 208 | #define IsSuperSegment(xxx) (((xxx)->distance)&SEGMENT_SUPER) |
78 | amb | 24 | |
79 | amb | 109 | /*+ Return true if the segment is oneway towards the specified node. +*/ |
80 | amb | 208 | #define IsOnewayTo(xxx,yyy) ((xxx)->node1==(yyy)?((xxx)->distance&ONEWAY_2TO1):((xxx)->distance&ONEWAY_1TO2)) |
81 | amb | 24 | |
82 | amb | 109 | /*+ Return true if the segment is oneway from the specified node. +*/ |
83 | amb | 208 | #define IsOnewayFrom(xxx,yyy) ((xxx)->node2==(yyy)?((xxx)->distance&ONEWAY_2TO1):((xxx)->distance&ONEWAY_1TO2)) |
84 | amb | 97 | |
85 | amb | 109 | /*+ Return the other node in the segment that is not the specified node. +*/ |
86 | amb | 208 | #define OtherNode(xxx,yyy) ((xxx)->node1==(yyy)?(xxx)->node2:(xxx)->node1) |
87 | amb | 97 | |
88 | amb | 24 | |
89 | amb | 109 | /* Functions */ |
90 | amb | 39 | |
91 | amb | 24 | |
92 | amb | 109 | Segments *LoadSegmentList(const char *filename); |
93 | amb | 88 | |
94 | amb | 109 | Segment *NextSegment(Segments* segments,Segment *segment,index_t node); |
95 | amb | 88 | |
96 | amb | 219 | distance_t Distance(double lat1,double lon1,double lat2,double lon2); |
97 | amb | 99 | |
98 | amb | 82 | duration_t Duration(Segment *segment,Way *way,Profile *profile); |
99 | amb | 63 | |
100 | amb | 32 | |
101 | amb | 24 | #endif /* SEGMENTS_H */ |
Properties
Name | Value |
---|---|
cvs:description | Header file for segments. |