Routino SVN Repository Browser

Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino

ViewVC logotype

Contents of /trunk/src/nodes.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 19 - (show annotations) (download) (as text)
Fri Jan 9 16:33:06 2009 UTC (16 years, 3 months ago) by amb
File MIME type: text/x-chdr
File size: 2514 byte(s)
Changed the format of the nodes data type again.

1 /***************************************
2 $Header: /home/amb/CVS/routino/src/nodes.h,v 1.2 2009-01-09 16:33:06 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 0 /* set to 0 to use a flat array, 1 for indexed. */
25
26 /*+ The array size increment for nodes. +*/
27 #define INCREMENT_NODES 1024
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 1024
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 #ifdef NBINS_NODES
68 off_t offset[NBINS_NODES+1]; /*+ An offset to the first entry in each bin. +*/
69 #else
70 uint32_t number; /*+ How many entries are used? +*/
71 #endif
72 Node nodes[1]; /*+ An array of nodes whose size is not limited to 1
73 (i.e. may overflow the end of this structure). +*/
74 }
75 Nodes;
76
77 /*+ A structure containing a set of nodes (memory format). +*/
78 typedef struct _NodesMem
79 {
80 uint32_t alloced; /*+ How many entries are allocated? +*/
81 uint32_t number; /*+ How many entries are used? +*/
82 uint32_t sorted; /*+ Is the data sorted and therefore searchable? +*/
83
84 Nodes *nodes; /*+ The real data +*/
85 }
86 NodesMem;
87
88
89 /* Functions */
90
91
92 NodesMem *NewNodeList(void);
93
94 Nodes *LoadNodeList(const char *filename);
95 Nodes *SaveNodeList(NodesMem *nodes,const char *filename);
96
97 Node *FindNode(Nodes *nodes,node_t id);
98
99 void AppendNode(NodesMem *nodes,node_t id,latlong_t latitude,latlong_t longitude);
100
101 void SortNodeList(NodesMem *nodes);
102
103
104 #endif /* NODES_H */

Properties

Name Value
cvs:description Header file for nodes.