Routino SVN Repository Browser

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

ViewVC logotype

Annotation of /trunk/src/nodes.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 90 - (hide annotations) (download) (as text)
Thu Jan 29 19:31:52 2009 UTC (16 years, 1 month ago) by amb
File MIME type: text/x-chdr
File size: 3136 byte(s)
Intermediate version while transitioning data format for nodes and segments.

1 amb 18 /***************************************
2 amb 90 $Header: /home/amb/CVS/routino/src/nodes.h,v 1.12 2009-01-29 19:31:52 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 array size increment for nodes - expect ~8,000,000 nodes. +*/
25 amb 27 #define INCREMENT_NODES 1024*1024
26 amb 19
27 amb 90 /*+ A flag to mark super-nodes. +*/
28     #define SUPER_NODE 0x80000000
29 amb 27
30 amb 90
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 amb 88 uint32_t firstseg; /*+ The index of the first segment. +*/
48     latlong_t latitude; /*+ The node latitude. +*/
49     latlong_t longitude; /*+ The node longitude. +*/
50 amb 18 }
51     Node;
52    
53 amb 88 /*+ An extended structure used for processing. +*/
54     typedef struct _NodeEx
55     {
56     node_t id; /*+ The node identifier. +*/
57 amb 89 int super; /*+ A marker for super nodes. +*/
58 amb 88
59     Node node; /*+ The real node data. +*/
60     }
61     NodeEx;
62    
63 amb 19 /*+ A structure containing a set of nodes (mmap format). +*/
64     typedef struct _Nodes
65     {
66 amb 65 uint32_t number; /*+ How many entries are used in total? +*/
67 amb 88
68     Node *nodes; /*+ An array of nodes. +*/
69    
70     void *data; /*+ The memory mapped data. +*/
71 amb 19 }
72     Nodes;
73    
74 amb 18 /*+ A structure containing a set of nodes (memory format). +*/
75     typedef struct _NodesMem
76     {
77 amb 88 uint32_t sorted; /*+ Is the data sorted and therefore searchable? +*/
78 amb 18 uint32_t alloced; /*+ How many entries are allocated? +*/
79 amb 19 uint32_t number; /*+ How many entries are used? +*/
80    
81 amb 88 NodeEx *xdata; /*+ The extended node data. +*/
82 amb 18 }
83     NodesMem;
84    
85    
86     /* Functions */
87    
88 amb 40 #include "segments.h"
89 amb 18
90 amb 40
91 amb 18 NodesMem *NewNodeList(void);
92    
93 amb 19 Nodes *LoadNodeList(const char *filename);
94 amb 89 void SaveNodeList(NodesMem *nodesmem,const char *filename);
95 amb 18
96 amb 89 NodeEx *FindNode(NodesMem* nodesmem,node_t id);
97 amb 18
98 amb 89 NodeEx *AppendNode(NodesMem *nodesmem,node_t id,latlong_t latitude,latlong_t longitude);
99 amb 18
100 amb 88 void SortNodeList(NodesMem *nodesmem);
101 amb 40
102 amb 88 void RemoveNonHighwayNodes(NodesMem *nodes,SegmentsMem *segments);
103 amb 18
104 amb 90 void FixupNodes(NodesMem *nodesmem,SegmentsMem* segmentsmem,int iteration);
105 amb 32
106 amb 88 #define LookupNode(xxx,yyy) (&(xxx)->nodes[yyy])
107    
108 amb 90 #define LookupNodeEx(xxx,yyy) (&(xxx)->xdata[(yyy)&(~SUPER_NODE)])
109 amb 89
110     #define IndexNode(xxx,yyy) ((yyy)-&(xxx)->nodes[0])
111    
112     #define IndexNodeEx(xxx,yyy) ((yyy)-&(xxx)->xdata[0])
113    
114 amb 90 #define FirstSegment(xxx,yyy) (((xxx)->nodes[yyy].firstseg)&(~SUPER_NODE))
115 amb 88
116 amb 90 #define IsSuperNode(xxx) (((xxx)->firstseg)&SUPER_NODE)
117 amb 89
118 amb 90 #define NODE(xxx) ((xxx)&(~SUPER_NODE))
119    
120    
121 amb 18 #endif /* NODES_H */

Properties

Name Value
cvs:description Header file for nodes.