Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino
Contents of /trunk/src/nodes.h
Parent Directory
|
Revision Log
Revision 1291 -
(show annotations)
(download)
(as text)
Wed May 1 18:32:57 2013 UTC (11 years, 10 months ago) by amb
File MIME type: text/x-chdr
File size: 5116 byte(s)
Wed May 1 18:32:57 2013 UTC (11 years, 10 months ago) by amb
File MIME type: text/x-chdr
File size: 5116 byte(s)
The GetLatLong function takes a pointer to the node as an argument - must be an optimisation for slim mode if not normal mode.
1 | /*************************************** |
2 | A header file for the nodes. |
3 | |
4 | Part of the Routino routing software. |
5 | ******************/ /****************** |
6 | This file Copyright 2008-2013 Andrew M. Bishop |
7 | |
8 | 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 | ***************************************/ |
21 | |
22 | |
23 | #ifndef NODES_H |
24 | #define NODES_H /*+ To stop multiple inclusions. +*/ |
25 | |
26 | #include <stdint.h> |
27 | #include <sys/types.h> |
28 | |
29 | #include "types.h" |
30 | |
31 | #include "files.h" |
32 | #include "profiles.h" |
33 | |
34 | |
35 | /* Data structures */ |
36 | |
37 | |
38 | /*+ A structure containing a single node. +*/ |
39 | struct _Node |
40 | { |
41 | index_t firstseg; /*+ The index of the first segment. +*/ |
42 | |
43 | ll_off_t latoffset; /*+ The node latitude offset within its bin. +*/ |
44 | ll_off_t lonoffset; /*+ The node longitude offset within its bin. +*/ |
45 | |
46 | transports_t allow; /*+ The types of transport that are allowed through the node. +*/ |
47 | nodeflags_t flags; /*+ Flags containing extra information (e.g. super-node, turn restriction). +*/ |
48 | }; |
49 | |
50 | |
51 | /*+ A structure containing the header from the file. +*/ |
52 | typedef struct _NodesFile |
53 | { |
54 | index_t number; /*+ The number of nodes in total. +*/ |
55 | index_t snumber; /*+ The number of super-nodes. +*/ |
56 | |
57 | ll_bin_t latbins; /*+ The number of bins containing latitude. +*/ |
58 | ll_bin_t lonbins; /*+ The number of bins containing longitude. +*/ |
59 | |
60 | ll_bin_t latzero; /*+ The bin number of the furthest south bin. +*/ |
61 | ll_bin_t lonzero; /*+ The bin number of the furthest west bin. +*/ |
62 | } |
63 | NodesFile; |
64 | |
65 | |
66 | /*+ A structure containing a set of nodes. +*/ |
67 | struct _Nodes |
68 | { |
69 | NodesFile file; /*+ The header data from the file. +*/ |
70 | |
71 | #if !SLIM |
72 | |
73 | void *data; /*+ The memory mapped data in the file. +*/ |
74 | |
75 | index_t *offsets; /*+ A pointer to the array of offsets in the file. +*/ |
76 | |
77 | Node *nodes; /*+ A pointer to the array of nodes in the file. +*/ |
78 | |
79 | #else |
80 | |
81 | int fd; /*+ The file descriptor for the file. +*/ |
82 | |
83 | index_t *offsets; /*+ An allocated array with a copy of the file offsets. +*/ |
84 | |
85 | off_t nodesoffset; /*+ The offset of the nodes within the file. +*/ |
86 | |
87 | Node cached[6]; /*+ Some cached nodes read from the file in slim mode. +*/ |
88 | index_t incache[6]; /*+ The indexes of the cached nodes. +*/ |
89 | |
90 | #endif |
91 | }; |
92 | |
93 | |
94 | /* Functions in nodes.c */ |
95 | |
96 | Nodes *LoadNodeList(const char *filename); |
97 | |
98 | index_t FindClosestNode(Nodes *nodes,Segments *segments,Ways *ways,double latitude,double longitude, |
99 | distance_t distance,Profile *profile,distance_t *bestdist); |
100 | |
101 | index_t FindClosestSegment(Nodes *nodes,Segments *segments,Ways *ways,double latitude,double longitude, |
102 | distance_t distance,Profile *profile, distance_t *bestdist, |
103 | index_t *bestnode1,index_t *bestnode2,distance_t *bestdist1,distance_t *bestdist2); |
104 | |
105 | void GetLatLong(Nodes *nodes,index_t index,Node *nodep,double *latitude,double *longitude); |
106 | |
107 | |
108 | /* Macros and inline functions */ |
109 | |
110 | /*+ Return true if this is a super-node. +*/ |
111 | #define IsSuperNode(xxx) (((xxx)->flags)&NODE_SUPER) |
112 | |
113 | /*+ Return true if this is a turn restricted node. +*/ |
114 | #define IsTurnRestrictedNode(xxx) (((xxx)->flags)&NODE_TURNRSTRCT) |
115 | |
116 | /*+ Return a Segment index given a Node pointer and a set of segments. +*/ |
117 | #define FirstSegment(xxx,yyy,ppp) LookupSegment((xxx),(yyy)->firstseg,ppp) |
118 | |
119 | /*+ Return the offset of a geographical region given a set of nodes. +*/ |
120 | #define LookupNodeOffset(xxx,yyy) ((xxx)->offsets[yyy]) |
121 | |
122 | |
123 | #if !SLIM |
124 | |
125 | /*+ Return a Node pointer given a set of nodes and an index. +*/ |
126 | #define LookupNode(xxx,yyy,ppp) (&(xxx)->nodes[yyy]) |
127 | |
128 | #else |
129 | |
130 | static Node *LookupNode(Nodes *nodes,index_t index,int position); |
131 | |
132 | |
133 | /*++++++++++++++++++++++++++++++++++++++ |
134 | Find the Node information for a particular node. |
135 | |
136 | Node *LookupNode Returns a pointer to the cached node information. |
137 | |
138 | Nodes *nodes The set of nodes to use. |
139 | |
140 | index_t index The index of the node. |
141 | |
142 | int position The position in the cache to store the value. |
143 | ++++++++++++++++++++++++++++++++++++++*/ |
144 | |
145 | static inline Node *LookupNode(Nodes *nodes,index_t index,int position) |
146 | { |
147 | if(nodes->incache[position-1]!=index) |
148 | { |
149 | SeekReadFile(nodes->fd,&nodes->cached[position-1],sizeof(Node),nodes->nodesoffset+(off_t)index*sizeof(Node)); |
150 | |
151 | nodes->incache[position-1]=index; |
152 | } |
153 | |
154 | return(&nodes->cached[position-1]); |
155 | } |
156 | |
157 | #endif |
158 | |
159 | |
160 | #endif /* NODES_H */ |
Properties
Name | Value |
---|---|
cvs:description | Header file for nodes. |