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 26 -
(show annotations)
(download)
(as text)
Sat Jan 10 11:53:49 2009 UTC (16 years, 2 months ago) by amb
File MIME type: text/x-chdr
File size: 2511 byte(s)
Sat Jan 10 11:53:49 2009 UTC (16 years, 2 months ago) by amb
File MIME type: text/x-chdr
File size: 2511 byte(s)
About to add the super-segment functionality using Segments data type to hold them.
1 | /*************************************** |
2 | $Header: /home/amb/CVS/routino/src/nodes.h,v 1.4 2009-01-10 11:53:48 amb Exp $ |
3 | |
4 | A header file for the nodes. |
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 NODES_H |
16 | #define NODES_H /*+ To stop multiple inclusions. +*/ |
17 | |
18 | #include <stdint.h> |
19 | |
20 | |
21 | /* Constants */ |
22 | |
23 | |
24 | #if 1 /* set to 0 to use a flat array, 1 for indexed. */ |
25 | |
26 | /*+ The array size increment for nodes. +*/ |
27 | #define INCREMENT_NODES 512 |
28 | |
29 | /*+ The number of bins for nodes. +*/ |
30 | #define NBINS_NODES 2048 |
31 | |
32 | #else |
33 | |
34 | /*+ The array size increment for nodes. +*/ |
35 | #define INCREMENT_NODES 512*2048 |
36 | |
37 | #undef NBINS_NODES |
38 | |
39 | #endif |
40 | |
41 | |
42 | /* Simple Types */ |
43 | |
44 | |
45 | /*+ A node identifier. +*/ |
46 | typedef uint32_t node_t; |
47 | |
48 | /*+ A node latitude or longitude. +*/ |
49 | typedef float latlong_t; |
50 | |
51 | |
52 | /* Data structures */ |
53 | |
54 | |
55 | /*+ A structure containing a single node. +*/ |
56 | typedef struct _Node |
57 | { |
58 | node_t id; /*+ The node identifier. +*/ |
59 | latlong_t latitude; /*+ The node latitude. +*/ |
60 | latlong_t longitude; /*+ The node longitude. +*/ |
61 | } |
62 | Node; |
63 | |
64 | /*+ A structure containing a set of nodes (mmap format). +*/ |
65 | typedef struct _Nodes |
66 | { |
67 | uint32_t number; /*+ How many entries are used? +*/ |
68 | #ifdef NBINS_NODES |
69 | uint32_t offset[NBINS_NODES+1];/*+ An offset to the first entry in each bin. +*/ |
70 | #endif |
71 | Node nodes[1]; /*+ An array of nodes whose size is not limited to 1 |
72 | (i.e. may overflow the end of this structure). +*/ |
73 | } |
74 | Nodes; |
75 | |
76 | /*+ A structure containing a set of nodes (memory format). +*/ |
77 | typedef struct _NodesMem |
78 | { |
79 | uint32_t alloced; /*+ How many entries are allocated? +*/ |
80 | uint32_t number; /*+ How many entries are used? +*/ |
81 | uint32_t sorted; /*+ Is the data sorted and therefore searchable? +*/ |
82 | |
83 | Nodes *nodes; /*+ The real data +*/ |
84 | } |
85 | NodesMem; |
86 | |
87 | |
88 | /* Functions */ |
89 | |
90 | |
91 | NodesMem *NewNodeList(void); |
92 | |
93 | Nodes *LoadNodeList(const char *filename); |
94 | Nodes *SaveNodeList(NodesMem *nodes,const char *filename); |
95 | |
96 | Node *FindNode(Nodes *nodes,node_t id); |
97 | |
98 | void AppendNode(NodesMem *nodes,node_t id,latlong_t latitude,latlong_t longitude); |
99 | |
100 | void SortNodeList(NodesMem *nodes); |
101 | |
102 | |
103 | #endif /* NODES_H */ |
Properties
Name | Value |
---|---|
cvs:description | Header file for nodes. |