1 /***************************************
2 $Header: /home/amb/routino/src/RCS/segments.h,v 1.34 2009/11/14 19:39:20 amb Exp $
4 A header file for the segments.
6 Part of the Routino routing software.
7 ******************/ /******************
8 This file Copyright 2008,2009 Andrew M. Bishop
10 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.
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.
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 ***************************************/
26 #define SEGMENTS_H /*+ To stop multiple inclusions. +*/
37 /*+ A structure containing a single segment. +*/
40 index_t node1; /*+ The index of the starting node. +*/
41 index_t node2; /*+ The index of the finishing node. +*/
43 index_t next2; /*+ The index of the next segment sharing node2. +*/
45 index_t way; /*+ The index of the way associated with the segment. +*/
47 distance_t distance; /*+ The distance between the nodes. +*/
51 /*+ A structure containing a set of segments (mmap format). +*/
54 uint32_t number; /*+ How many segments in total? +*/
55 uint32_t snumber; /*+ How many super-segments? +*/
56 uint32_t nnumber; /*+ How many normal segments? +*/
58 Segment *segments; /*+ An array of segments. +*/
60 void *data; /*+ The memory mapped data. +*/
67 /*+ Return a segment pointer given a set of segments and an index. +*/
68 #define LookupSegment(xxx,yyy) (&(xxx)->segments[yyy])
70 /*+ Return a segment index given a set of segments and a pointer. +*/
71 #define IndexSegment(xxx,yyy) ((yyy)-&(xxx)->segments[0])
73 /*+ Return true if this is a normal segment. +*/
74 #define IsNormalSegment(xxx) (((xxx)->distance)&SEGMENT_NORMAL)
76 /*+ Return true if this is a super-segment. +*/
77 #define IsSuperSegment(xxx) (((xxx)->distance)&SEGMENT_SUPER)
79 /*+ Return true if the segment is oneway towards the specified node. +*/
80 #define IsOnewayTo(xxx,yyy) ((xxx)->node1==(yyy)?((xxx)->distance&ONEWAY_2TO1):((xxx)->distance&ONEWAY_1TO2))
82 /*+ Return true if the segment is oneway from the specified node. +*/
83 #define IsOnewayFrom(xxx,yyy) ((xxx)->node2==(yyy)?((xxx)->distance&ONEWAY_2TO1):((xxx)->distance&ONEWAY_1TO2))
85 /*+ Return the other node in the segment that is not the specified node. +*/
86 #define OtherNode(xxx,yyy) ((xxx)->node1==(yyy)?(xxx)->node2:(xxx)->node1)
92 Segments *LoadSegmentList(const char *filename);
94 Segment *NextSegment(Segments* segments,Segment *segment,index_t node);
96 distance_t Distance(double lat1,double lon1,double lat2,double lon2);
98 duration_t Duration(Segment *segment,Way *way,Profile *profile);
101 #endif /* SEGMENTS_H */