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/ways.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1078 - (show annotations) (download) (as text)
Fri Sep 28 16:34:20 2012 UTC (12 years, 6 months ago) by amb
File MIME type: text/x-csrc
File size: 3128 byte(s)
Rename some variables so that pointers to nodes, segments, ways and relations
use the Hungarian notation "p" suffix (only applies to the router, not
planetsplitter).

1 /***************************************
2 Way data type functions.
3
4 Part of the Routino routing software.
5 ******************/ /******************
6 This file Copyright 2008-2012 Andrew M. Bishop
7
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU Affero General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU Affero General Public License for more details.
17
18 You should have received a copy of the GNU Affero General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ***************************************/
21
22
23 #include <stdlib.h>
24
25 #include "ways.h"
26
27 #include "files.h"
28
29
30 /*++++++++++++++++++++++++++++++++++++++
31 Load in a way list from a file.
32
33 Ways *LoadWayList Returns the way list.
34
35 const char *filename The name of the file to load.
36 ++++++++++++++++++++++++++++++++++++++*/
37
38 Ways *LoadWayList(const char *filename)
39 {
40 Ways *ways;
41 #if SLIM
42 int i;
43 #endif
44
45 ways=(Ways*)malloc(sizeof(Ways));
46
47 #if !SLIM
48
49 ways->data=MapFile(filename);
50
51 /* Copy the WaysFile structure from the loaded data */
52
53 ways->file=*((WaysFile*)ways->data);
54
55 /* Set the pointers in the Ways structure. */
56
57 ways->ways =(Way *)(ways->data+sizeof(WaysFile));
58 ways->names=(char*)(ways->data+sizeof(WaysFile)+ways->file.number*sizeof(Way));
59
60 #else
61
62 ways->fd=ReOpenFile(filename);
63
64 /* Copy the WaysFile header structure from the loaded data */
65
66 ReadFile(ways->fd,&ways->file,sizeof(WaysFile));
67
68 for(i=0;i<sizeof(ways->cached)/sizeof(ways->cached[0]);i++)
69 ways->incache[i]=NO_WAY;
70
71 ways->namesoffset=sizeof(WaysFile)+ways->file.number*sizeof(Way);
72
73 for(i=0;i<sizeof(ways->cached)/sizeof(ways->cached[0]);i++)
74 ways->ncached[i]=NULL;
75
76 #endif
77
78 return(ways);
79 }
80
81
82 /*++++++++++++++++++++++++++++++++++++++
83 Return 0 if the two ways are the same (in respect of their types and limits),
84 otherwise return positive or negative to allow sorting.
85
86 int WaysCompare Returns a comparison.
87
88 Way *way1p The first way.
89
90 Way *way2p The second way.
91 ++++++++++++++++++++++++++++++++++++++*/
92
93 int WaysCompare(Way *way1p,Way *way2p)
94 {
95 if(way1p==way2p)
96 return(0);
97
98 if(way1p->type!=way2p->type)
99 return((int)way1p->type - (int)way2p->type);
100
101 if(way1p->allow!=way2p->allow)
102 return((int)way1p->allow - (int)way2p->allow);
103
104 if(way1p->props!=way2p->props)
105 return((int)way1p->props - (int)way2p->props);
106
107 if(way1p->speed!=way2p->speed)
108 return((int)way1p->speed - (int)way2p->speed);
109
110 if(way1p->weight!=way2p->weight)
111 return((int)way1p->weight - (int)way2p->weight);
112
113 if(way1p->height!=way2p->height)
114 return((int)way1p->height - (int)way2p->height);
115
116 if(way1p->width!=way2p->width)
117 return((int)way1p->width - (int)way2p->width);
118
119 if(way1p->length!=way2p->length)
120 return((int)way1p->length - (int)way2p->length);
121
122 return(0);
123 }

Properties

Name Value
cvs:description Functions for ways.