1 /***************************************
2 $Header: /home/amb/routino/src/RCS/nodes.h,v 1.30 2009/11/14 19:39:19 amb Exp $
4 A header file for the nodes.
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 NODES_H /*+ To stop multiple inclusions. +*/
37 /*+ A structure containing a single node. +*/
40 index_t firstseg; /*+ The index of the first segment. +*/
42 ll_off_t latoffset; /*+ The node latitude offset within its bin. +*/
43 ll_off_t lonoffset; /*+ The node longitude offset within its bin. +*/
47 /*+ A structure containing a set of nodes (mmap format). +*/
50 uint32_t number; /*+ How many nodes in total? +*/
51 uint32_t snumber; /*+ How many super-nodes? +*/
53 uint32_t latbins; /*+ The number of bins containing latitude. +*/
54 uint32_t lonbins; /*+ The number of bins containing longitude. +*/
56 ll_bin_t latzero; /*+ The bin number of the furthest south bin. +*/
57 ll_bin_t lonzero; /*+ The bin number of the furthest west bin. +*/
59 index_t *offsets; /*+ An array of offset to the first node in each bin. +*/
61 Node *nodes; /*+ An array of nodes. +*/
63 void *data; /*+ The memory mapped data. +*/
69 /*+ Return a Node pointer given a set of nodes and an index. +*/
70 #define LookupNode(xxx,yyy) (&(xxx)->nodes[yyy])
72 /*+ Return a Segment points given a Node pointer and a set of segments. +*/
73 #define FirstSegment(xxx,yyy,zzz) LookupSegment((xxx),SEGMENT((yyy)->nodes[zzz].firstseg))
75 /*+ Return true if this is a super-node. +*/
76 #define IsSuperNode(xxx,yyy) (((xxx)->nodes[yyy].firstseg)&NODE_SUPER)
82 Nodes *LoadNodeList(const char *filename);
84 index_t FindClosestNode(Nodes* nodes,Segments *segments,Ways *ways,double latitude,double longitude,
85 distance_t distance,Profile *profile,distance_t *bestdist);
87 Segment *FindClosestSegment(Nodes* nodes,Segments *segments,Ways *ways,double latitude,double longitude,
88 distance_t distance,Profile *profile, distance_t *bestdist,
89 index_t *bestnode1,index_t *bestnode2,distance_t *bestdist1,distance_t *bestdist2);
91 void GetLatLong(Nodes *nodes,index_t index,double *latitude,double *longitude);