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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 390 - (hide annotations) (download) (as text)
Fri May 14 18:22:08 2010 UTC (14 years, 10 months ago) by amb
File MIME type: text/x-csrc
File size: 10864 byte(s)
Remove highway type aliases from HighwayType() function.

1 amb 364 /***************************************
2 amb 390 $Header: /home/amb/CVS/routino/src/types.c,v 1.2 2010-05-14 18:22:08 amb Exp $
3 amb 364
4     Functions for handling the data types.
5    
6     Part of the Routino routing software.
7     ******************/ /******************
8     This file Copyright 2008-2010 Andrew M. Bishop
9    
10     This program is free software: you can redistribute it and/or modify
11     it under the terms of the GNU Affero General Public License as published by
12     the Free Software Foundation, either version 3 of the License, or
13     (at your option) any later version.
14    
15     This program is distributed in the hope that it will be useful,
16     but WITHOUT ANY WARRANTY; without even the implied warranty of
17     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18     GNU Affero General Public License for more details.
19    
20     You should have received a copy of the GNU Affero General Public License
21     along with this program. If not, see <http://www.gnu.org/licenses/>.
22     ***************************************/
23    
24    
25     #include <string.h>
26    
27     #include "types.h"
28    
29    
30     /*++++++++++++++++++++++++++++++++++++++
31     Decide on the type of a way given the "highway" parameter.
32    
33     Highway HighwayType Returns the highway type of the way.
34    
35     const char *highway The string containing the type of the way.
36     ++++++++++++++++++++++++++++++++++++++*/
37    
38     Highway HighwayType(const char *highway)
39     {
40     switch(*highway)
41     {
42     case 'c':
43     if(!strcmp(highway,"cycleway")) return(Way_Cycleway);
44     return(Way_Count);
45    
46     case 'm':
47 amb 390 if(!strcmp(highway,"motorway")) return(Way_Motorway);
48 amb 364 return(Way_Count);
49    
50     case 'p':
51 amb 390 if(!strcmp(highway,"primary")) return(Way_Primary);
52 amb 364 if(!strcmp(highway,"path")) return(Way_Path);
53     return(Way_Count);
54    
55     case 'r':
56     if(!strcmp(highway,"residential")) return(Way_Residential);
57     return(Way_Count);
58    
59     case 's':
60 amb 390 if(!strcmp(highway,"secondary")) return(Way_Secondary);
61 amb 364 if(!strcmp(highway,"service")) return(Way_Service);
62     if(!strcmp(highway,"steps")) return(Way_Steps);
63     return(Way_Count);
64    
65     case 't':
66 amb 390 if(!strcmp(highway,"trunk")) return(Way_Trunk);
67 amb 364 if(!strcmp(highway,"tertiary")) return(Way_Tertiary);
68     if(!strcmp(highway,"track")) return(Way_Track);
69     return(Way_Count);
70    
71     case 'u':
72     if(!strcmp(highway,"unclassified")) return(Way_Unclassified);
73     return(Way_Count);
74    
75     default:
76     ;
77     }
78    
79     return(Way_Count);
80     }
81    
82    
83     /*++++++++++++++++++++++++++++++++++++++
84     Decide on the type of transport given the name of it.
85    
86     Transport TransportType Returns the type of the transport.
87    
88     const char *transport The string containing the method of transport.
89     ++++++++++++++++++++++++++++++++++++++*/
90    
91     Transport TransportType(const char *transport)
92     {
93     switch(*transport)
94     {
95     case 'b':
96     if(!strcmp(transport,"bicycle"))
97     return(Transport_Bicycle);
98     break;
99    
100     case 'f':
101     if(!strcmp(transport,"foot"))
102     return(Transport_Foot);
103     break;
104    
105     case 'g':
106     if(!strcmp(transport,"goods"))
107     return(Transport_Goods);
108     break;
109    
110     case 'h':
111     if(!strcmp(transport,"horse"))
112     return(Transport_Horse);
113     if(!strcmp(transport,"hgv"))
114     return(Transport_HGV);
115     break;
116    
117     case 'm':
118     if(!strcmp(transport,"moped"))
119     return(Transport_Moped);
120     if(!strcmp(transport,"motorbike"))
121     return(Transport_Motorbike);
122     if(!strcmp(transport,"motorcar"))
123     return(Transport_Motorcar);
124     break;
125    
126     case 'p':
127     if(!strcmp(transport,"psv"))
128     return(Transport_PSV);
129     break;
130    
131     case 'w':
132     if(!strcmp(transport,"wheelchair"))
133     return(Transport_Wheelchair);
134     break;
135    
136     default:
137     return(Transport_None);
138     }
139    
140     return(Transport_None);
141     }
142    
143    
144     /*++++++++++++++++++++++++++++++++++++++
145     Decide on the type of property given the name of it.
146    
147     Property PropertyType Returns the type of the property.
148    
149     const char *property The string containing the method of property.
150     ++++++++++++++++++++++++++++++++++++++*/
151    
152     Property PropertyType(const char *property)
153     {
154     switch(*property)
155     {
156     case 'b':
157     if(!strcmp(property,"bridge"))
158     return(Property_Bridge);
159     break;
160    
161     case 'm':
162     if(!strcmp(property,"multilane"))
163     return(Property_Multilane);
164     break;
165    
166     case 'p':
167     if(!strcmp(property,"paved"))
168     return(Property_Paved);
169     break;
170    
171     case 't':
172     if(!strcmp(property,"tunnel"))
173     return(Property_Tunnel);
174     break;
175    
176     default:
177     return(Property_None);
178     }
179    
180     return(Property_None);
181     }
182    
183    
184     /*++++++++++++++++++++++++++++++++++++++
185     A string containing the name of a type of highway.
186    
187     const char *HighwayName Returns the name.
188    
189     Highway highway The highway type.
190     ++++++++++++++++++++++++++++++++++++++*/
191    
192     const char *HighwayName(Highway highway)
193     {
194     switch(highway)
195     {
196     case Way_Motorway:
197     return("motorway");
198     case Way_Trunk:
199     return("trunk");
200     case Way_Primary:
201     return("primary");
202     case Way_Secondary:
203     return("secondary");
204     case Way_Tertiary:
205     return("tertiary");
206     case Way_Unclassified:
207     return("unclassified");
208     case Way_Residential:
209     return("residential");
210     case Way_Service:
211     return("service");
212     case Way_Track:
213     return("track");
214     case Way_Cycleway:
215     return("cycleway");
216     case Way_Path:
217     return("path");
218     case Way_Steps:
219     return("steps");
220    
221     case Way_Count:
222     ;
223    
224     case Way_OneWay:
225     case Way_Roundabout:
226     ;
227     }
228    
229     return(NULL);
230     }
231    
232    
233     /*++++++++++++++++++++++++++++++++++++++
234     A string containing the name of a type of transport.
235    
236     const char *TransportName Returns the name.
237    
238     Transport transport The transport type.
239     ++++++++++++++++++++++++++++++++++++++*/
240    
241     const char *TransportName(Transport transport)
242     {
243     switch(transport)
244     {
245     case Transport_None:
246     return("NONE");
247    
248     case Transport_Foot:
249     return("foot");
250     case Transport_Horse:
251     return("horse");
252     case Transport_Wheelchair:
253     return("wheelchair");
254     case Transport_Bicycle:
255     return("bicycle");
256     case Transport_Moped:
257     return("moped");
258     case Transport_Motorbike:
259     return("motorbike");
260     case Transport_Motorcar:
261     return("motorcar");
262     case Transport_Goods:
263     return("goods");
264     case Transport_HGV:
265     return("hgv");
266     case Transport_PSV:
267     return("psv");
268     }
269    
270     return(NULL);
271     }
272    
273    
274     /*++++++++++++++++++++++++++++++++++++++
275     A string containing the name of a highway property.
276    
277     const char *PropertyName Returns the name.
278    
279     Property property The property type.
280     ++++++++++++++++++++++++++++++++++++++*/
281    
282     const char *PropertyName(Property property)
283     {
284     switch(property)
285     {
286     case Property_None:
287     return("NONE");
288    
289     case Property_Paved:
290     return("paved");
291    
292     case Property_Multilane:
293     return("multilane");
294    
295     case Property_Bridge:
296     return("bridge");
297    
298     case Property_Tunnel:
299     return("tunnel");
300    
301     case Property_Count:
302     ;
303     }
304    
305     return(NULL);
306     }
307    
308    
309     /*++++++++++++++++++++++++++++++++++++++
310     A string containing the names of allowed transports on a way.
311    
312     const char *AllowedNameList Returns the list of names.
313    
314     wayallow_t allowed The allowed type.
315     ++++++++++++++++++++++++++++++++++++++*/
316    
317     const char *AllowedNameList(wayallow_t allowed)
318     {
319     static char string[256];
320    
321     string[0]=0;
322    
323     if(allowed & Allow_Foot)
324     strcat(string,"foot");
325    
326     if(allowed & Allow_Horse)
327     {
328     if(*string) strcat(string,", ");
329     strcat(string,"horse");
330     }
331    
332     if(allowed & Allow_Wheelchair)
333     {
334     if(*string) strcat(string,", ");
335     strcat(string,"wheelchair");
336     }
337    
338     if(allowed & Allow_Bicycle)
339     {
340     if(*string) strcat(string,", ");
341     strcat(string,"bicycle");
342     }
343    
344     if(allowed & Allow_Moped)
345     {
346     if(*string) strcat(string,", ");
347     strcat(string,"moped");
348     }
349    
350     if(allowed & Allow_Motorbike)
351     {
352     if(*string) strcat(string,", ");
353     strcat(string,"motorbike");
354     }
355    
356     if(allowed & Allow_Motorcar)
357     {
358     if(*string) strcat(string,", ");
359     strcat(string,"motorcar");
360     }
361    
362     if(allowed & Allow_Goods)
363     {
364     if(*string) strcat(string,", ");
365     strcat(string,"goods");
366     }
367    
368     if(allowed & Allow_HGV)
369     {
370     if(*string) strcat(string,", ");
371     strcat(string,"hgv");
372     }
373    
374     if(allowed & Allow_PSV)
375     {
376     if(*string) strcat(string,", ");
377     strcat(string,"psv");
378     }
379    
380     return(string);
381     }
382    
383    
384     /*++++++++++++++++++++++++++++++++++++++
385     A string containing the names of the properties of a way.
386    
387     const char *PropertiesNameList Returns the list of names.
388    
389     wayprop_t properties The properties of the way.
390     ++++++++++++++++++++++++++++++++++++++*/
391    
392     const char *PropertiesNameList(wayprop_t properties)
393     {
394     static char string[256];
395    
396     string[0]=0;
397    
398     if(properties & Properties_Paved)
399     {
400     if(*string) strcat(string,", ");
401     strcat(string,"paved");
402     }
403    
404     if(properties & Properties_Multilane)
405     {
406     if(*string) strcat(string,", ");
407     strcat(string,"multilane");
408     }
409    
410     if(properties & Properties_Bridge)
411     {
412     if(*string) strcat(string,", ");
413     strcat(string,"bridge");
414     }
415    
416     if(properties & Properties_Tunnel)
417     {
418     if(*string) strcat(string,", ");
419     strcat(string,"tunnel");
420     }
421    
422     return(string);
423     }
424    
425    
426     /*++++++++++++++++++++++++++++++++++++++
427     Returns a list of all the highway types.
428    
429     const char *HighwayList Return a list of all the highway types.
430     ++++++++++++++++++++++++++++++++++++++*/
431    
432     const char *HighwayList(void)
433     {
434     return " motorway = Motorway\n"
435     " trunk = Trunk\n"
436     " primary = Primary\n"
437     " secondary = Secondary\n"
438     " tertiary = Tertiary\n"
439     " unclassified = Unclassified\n"
440     " residential = Residential\n"
441     " service = Service\n"
442     " track = Track\n"
443     " cycleway = Cycleway\n"
444     " path = Path\n"
445     " steps = Steps\n"
446     ;
447     }
448    
449    
450     /*++++++++++++++++++++++++++++++++++++++
451     Returns a list of all the transport types.
452    
453     const char *TransportList Return a list of all the transport types.
454     ++++++++++++++++++++++++++++++++++++++*/
455    
456     const char *TransportList(void)
457     {
458     return " foot = Foot\n"
459     " bicycle = Bicycle\n"
460     " wheelchair = Wheelchair\n"
461     " horse = Horse\n"
462     " moped = Moped (Small motorbike, limited speed)\n"
463     " motorbike = Motorbike\n"
464     " motorcar = Motorcar\n"
465     " goods = Goods (Small lorry, van)\n"
466     " hgv = HGV (Heavy Goods Vehicle - large lorry)\n"
467     " psv = PSV (Public Service Vehicle - bus, coach)\n"
468     ;
469     }
470    
471    
472     /*++++++++++++++++++++++++++++++++++++++
473     Returns a list of all the property types.
474    
475     const char *PropertyList Return a list of all the highway proprties.
476     ++++++++++++++++++++++++++++++++++++++*/
477    
478     const char *PropertyList(void)
479     {
480     return " paved = Paved (suitable for normal wheels)\n"
481     " multilane = Multiple lanes\n"
482     " bridge = Bridge\n"
483     " Tunnel = Tunnel\n"
484     ;
485     }

Properties

Name Value
cvs:description Move the type checking/printing functions from way.c to type.c.