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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 681 - (hide annotations) (download) (as text)
Sun Apr 24 18:01:24 2011 UTC (13 years, 11 months ago) by amb
File MIME type: text/x-csrc
File size: 2981 byte(s)
Make the comments more consistent.

1 amb 7 /***************************************
2     Way data type functions.
3 amb 157
4     Part of the Routino routing software.
5 amb 7 ******************/ /******************
6 amb 681 This file Copyright 2008-2011 Andrew M. Bishop
7 amb 7
8 amb 157 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 amb 7 ***************************************/
21    
22    
23     #include <stdlib.h>
24    
25 amb 20 #include "ways.h"
26 amb 7
27 amb 449 #include "files.h"
28 amb 7
29 amb 449
30 amb 7 /*++++++++++++++++++++++++++++++++++++++
31 amb 20 Load in a way list from a file.
32    
33 amb 681 Ways *LoadWayList Returns the way list.
34 amb 20
35     const char *filename The name of the file to load.
36     ++++++++++++++++++++++++++++++++++++++*/
37    
38     Ways *LoadWayList(const char *filename)
39     {
40 amb 87 Ways *ways;
41    
42     ways=(Ways*)malloc(sizeof(Ways));
43    
44 amb 460 #if !SLIM
45 amb 87
46 amb 460 ways->data=MapFile(filename);
47 amb 87
48 amb 460 /* Copy the WaysFile structure from the loaded data */
49 amb 87
50 amb 460 ways->file=*((WaysFile*)ways->data);
51 amb 87
52 amb 460 /* Set the pointers in the Ways structure. */
53 amb 87
54 amb 460 ways->ways =(Way *)(ways->data+sizeof(WaysFile));
55     ways->names=(char*)(ways->data+sizeof(WaysFile)+ways->file.number*sizeof(Way));
56    
57     #else
58    
59     ways->fd=ReOpenFile(filename);
60    
61     /* Copy the WaysFile header structure from the loaded data */
62    
63     ReadFile(ways->fd,&ways->file,sizeof(WaysFile));
64    
65 amb 564 ways->incache[0]=NO_WAY;
66     ways->incache[1]=NO_WAY;
67    
68 amb 460 ways->namesoffset=sizeof(WaysFile)+ways->file.number*sizeof(Way);
69    
70     ways->nincache=~0;
71     ways->ncached=NULL;
72    
73     #endif
74    
75 amb 87 return(ways);
76 amb 20 }
77    
78    
79     /*++++++++++++++++++++++++++++++++++++++
80 amb 201 Return 0 if the two ways are the same (in respect of their types and limits),
81     otherwise return positive or negative to allow sorting.
82 amb 181
83 amb 201 int WaysCompare Returns a comparison.
84 amb 181
85     Way *way1 The first way.
86    
87     Way *way2 The second way.
88     ++++++++++++++++++++++++++++++++++++++*/
89    
90 amb 201 int WaysCompare(Way *way1,Way *way2)
91 amb 181 {
92     if(way1==way2)
93 amb 201 return(0);
94 amb 181
95 amb 201 if(way1->type!=way2->type)
96     return((int)way1->type - (int)way2->type);
97 amb 181
98 amb 201 if(way1->allow!=way2->allow)
99     return((int)way1->allow - (int)way2->allow);
100    
101 amb 298 if(way1->props!=way2->props)
102     return((int)way1->props - (int)way2->props);
103    
104 amb 201 if(way1->speed!=way2->speed)
105     return((int)way1->speed - (int)way2->speed);
106    
107     if(way1->weight!=way2->weight)
108     return((int)way1->weight - (int)way2->weight);
109    
110     if(way1->height!=way2->height)
111     return((int)way1->height - (int)way2->height);
112    
113     if(way1->width!=way2->width)
114     return((int)way1->width - (int)way2->width);
115    
116     if(way1->length!=way2->length)
117     return((int)way1->length - (int)way2->length);
118    
119 amb 181 return(0);
120     }

Properties

Name Value
cvs:description Functions for ways.