Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino
Annotation of /trunk/src/nodes.h
Parent Directory
|
Revision Log
Revision 65 -
(hide annotations)
(download)
(as text)
Thu Jan 22 18:57:16 2009 UTC (16 years, 1 month ago) by amb
File MIME type: text/x-chdr
File size: 2587 byte(s)
Thu Jan 22 18:57:16 2009 UTC (16 years, 1 month ago) by amb
File MIME type: text/x-chdr
File size: 2587 byte(s)
Remove the choice of indexed or non-indexed data structures.
1 | amb | 18 | /*************************************** |
2 | amb | 65 | $Header: /home/amb/CVS/routino/src/nodes.h,v 1.8 2009-01-22 18:57:16 amb Exp $ |
3 | amb | 18 | |
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 | amb | 65 | /*+ The number of bins for nodes - expect ~8,000,000 nodes and use 4*sqrt(N) bins. +*/ |
25 | #define NBINS_NODES 8192 | ||
26 | amb | 19 | |
27 | amb | 65 | /*+ The array size increment for nodes - expect ~8,000,000 nodes. +*/ |
28 | amb | 27 | #define INCREMENT_NODES 1024*1024 |
29 | amb | 19 | |
30 | amb | 27 | |
31 | amb | 18 | /* Simple Types */ |
32 | |||
33 | |||
34 | /*+ A node identifier. +*/ | ||
35 | typedef uint32_t node_t; | ||
36 | |||
37 | /*+ A node latitude or longitude. +*/ | ||
38 | typedef float latlong_t; | ||
39 | |||
40 | |||
41 | /* Data structures */ | ||
42 | |||
43 | |||
44 | /*+ A structure containing a single node. +*/ | ||
45 | typedef struct _Node | ||
46 | { | ||
47 | node_t id; /*+ The node identifier. +*/ | ||
48 | latlong_t latitude; /*+ The node latitude. +*/ | ||
49 | latlong_t longitude; /*+ The node longitude. +*/ | ||
50 | } | ||
51 | Node; | ||
52 | |||
53 | amb | 19 | /*+ A structure containing a set of nodes (mmap format). +*/ |
54 | typedef struct _Nodes | ||
55 | { | ||
56 | amb | 65 | uint32_t offset[NBINS_NODES]; /*+ An offset to the first entry in each bin. +*/ |
57 | uint32_t number; /*+ How many entries are used in total? +*/ | ||
58 | amb | 26 | Node nodes[1]; /*+ An array of nodes whose size is not limited to 1 |
59 | amb | 19 | (i.e. may overflow the end of this structure). +*/ |
60 | } | ||
61 | Nodes; | ||
62 | |||
63 | amb | 18 | /*+ A structure containing a set of nodes (memory format). +*/ |
64 | typedef struct _NodesMem | ||
65 | { | ||
66 | uint32_t alloced; /*+ How many entries are allocated? +*/ | ||
67 | amb | 19 | uint32_t number; /*+ How many entries are used? +*/ |
68 | amb | 18 | uint32_t sorted; /*+ Is the data sorted and therefore searchable? +*/ |
69 | amb | 19 | |
70 | amb | 65 | Nodes *nodes; /*+ The real data that will be memory mapped later. +*/ |
71 | amb | 18 | } |
72 | NodesMem; | ||
73 | |||
74 | |||
75 | /* Functions */ | ||
76 | |||
77 | amb | 40 | #include "segments.h" |
78 | amb | 18 | |
79 | amb | 40 | |
80 | amb | 18 | NodesMem *NewNodeList(void); |
81 | |||
82 | amb | 19 | Nodes *LoadNodeList(const char *filename); |
83 | Nodes *SaveNodeList(NodesMem *nodes,const char *filename); | ||
84 | amb | 18 | |
85 | amb | 19 | Node *FindNode(Nodes *nodes,node_t id); |
86 | amb | 18 | |
87 | amb | 32 | Node *AppendNode(NodesMem *nodes,node_t id,latlong_t latitude,latlong_t longitude); |
88 | amb | 18 | |
89 | void SortNodeList(NodesMem *nodes); | ||
90 | |||
91 | amb | 40 | void RemoveNonWayNodes(NodesMem *nodesmem,Nodes *nodes,Segments *segments); |
92 | |||
93 | amb | 32 | #define LookupNode(xxx,yyy) (&xxx->nodes[yyy]) |
94 | amb | 18 | |
95 | amb | 32 | |
96 | amb | 18 | #endif /* NODES_H */ |
Properties
Name | Value |
---|---|
cvs:description | Header file for nodes. |