Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino
Contents of /trunk/src/ways.c
Parent Directory
|
Revision Log
Revision 681 -
(show 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)
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 | /*************************************** |
2 | Way data type functions. |
3 | |
4 | Part of the Routino routing software. |
5 | ******************/ /****************** |
6 | This file Copyright 2008-2011 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 | |
42 | ways=(Ways*)malloc(sizeof(Ways)); |
43 | |
44 | #if !SLIM |
45 | |
46 | ways->data=MapFile(filename); |
47 | |
48 | /* Copy the WaysFile structure from the loaded data */ |
49 | |
50 | ways->file=*((WaysFile*)ways->data); |
51 | |
52 | /* Set the pointers in the Ways structure. */ |
53 | |
54 | 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 | ways->incache[0]=NO_WAY; |
66 | ways->incache[1]=NO_WAY; |
67 | |
68 | ways->namesoffset=sizeof(WaysFile)+ways->file.number*sizeof(Way); |
69 | |
70 | ways->nincache=~0; |
71 | ways->ncached=NULL; |
72 | |
73 | #endif |
74 | |
75 | return(ways); |
76 | } |
77 | |
78 | |
79 | /*++++++++++++++++++++++++++++++++++++++ |
80 | 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 | |
83 | int WaysCompare Returns a comparison. |
84 | |
85 | Way *way1 The first way. |
86 | |
87 | Way *way2 The second way. |
88 | ++++++++++++++++++++++++++++++++++++++*/ |
89 | |
90 | int WaysCompare(Way *way1,Way *way2) |
91 | { |
92 | if(way1==way2) |
93 | return(0); |
94 | |
95 | if(way1->type!=way2->type) |
96 | return((int)way1->type - (int)way2->type); |
97 | |
98 | if(way1->allow!=way2->allow) |
99 | return((int)way1->allow - (int)way2->allow); |
100 | |
101 | if(way1->props!=way2->props) |
102 | return((int)way1->props - (int)way2->props); |
103 | |
104 | 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 | return(0); |
120 | } |
Properties
Name | Value |
---|---|
cvs:description | Functions for ways. |