1 /***************************************
2 $Header: /home/amb/routino/src/RCS/types.c,v 1.3 2010/05/27 17:25:23 amb Exp $
4 Functions for handling the data types.
6 Part of the Routino routing software.
7 ******************/ /******************
8 This file Copyright 2008-2010 Andrew M. Bishop
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.
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.
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 ***************************************/
30 /*++++++++++++++++++++++++++++++++++++++
31 Decide on the type of a way given the "highway" parameter.
33 Highway HighwayType Returns the highway type of the way.
35 const char *highway The string containing the type of the way.
36 ++++++++++++++++++++++++++++++++++++++*/
38 Highway HighwayType(const char *highway)
43 if(!strcmp(highway,"cycleway")) return(Way_Cycleway);
47 if(!strcmp(highway,"motorway")) return(Way_Motorway);
51 if(!strcmp(highway,"primary")) return(Way_Primary);
52 if(!strcmp(highway,"path")) return(Way_Path);
56 if(!strcmp(highway,"residential")) return(Way_Residential);
60 if(!strcmp(highway,"secondary")) return(Way_Secondary);
61 if(!strcmp(highway,"service")) return(Way_Service);
62 if(!strcmp(highway,"steps")) return(Way_Steps);
66 if(!strcmp(highway,"trunk")) return(Way_Trunk);
67 if(!strcmp(highway,"tertiary")) return(Way_Tertiary);
68 if(!strcmp(highway,"track")) return(Way_Track);
72 if(!strcmp(highway,"unclassified")) return(Way_Unclassified);
83 /*++++++++++++++++++++++++++++++++++++++
84 Decide on the type of transport given the name of it.
86 Transport TransportType Returns the type of the transport.
88 const char *transport The string containing the method of transport.
89 ++++++++++++++++++++++++++++++++++++++*/
91 Transport TransportType(const char *transport)
96 if(!strcmp(transport,"bicycle"))
97 return(Transport_Bicycle);
101 if(!strcmp(transport,"foot"))
102 return(Transport_Foot);
106 if(!strcmp(transport,"goods"))
107 return(Transport_Goods);
111 if(!strcmp(transport,"horse"))
112 return(Transport_Horse);
113 if(!strcmp(transport,"hgv"))
114 return(Transport_HGV);
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);
127 if(!strcmp(transport,"psv"))
128 return(Transport_PSV);
132 if(!strcmp(transport,"wheelchair"))
133 return(Transport_Wheelchair);
137 return(Transport_None);
140 return(Transport_None);
144 /*++++++++++++++++++++++++++++++++++++++
145 Decide on the type of property given the name of it.
147 Property PropertyType Returns the type of the property.
149 const char *property The string containing the method of property.
150 ++++++++++++++++++++++++++++++++++++++*/
152 Property PropertyType(const char *property)
157 if(!strcmp(property,"bridge"))
158 return(Property_Bridge);
162 if(!strcmp(property,"multilane"))
163 return(Property_Multilane);
167 if(!strcmp(property,"paved"))
168 return(Property_Paved);
172 if(!strcmp(property,"tunnel"))
173 return(Property_Tunnel);
177 return(Property_None);
180 return(Property_None);
184 /*++++++++++++++++++++++++++++++++++++++
185 A string containing the name of a type of highway.
187 const char *HighwayName Returns the name.
189 Highway highway The highway type.
190 ++++++++++++++++++++++++++++++++++++++*/
192 const char *HighwayName(Highway highway)
206 case Way_Unclassified:
207 return("unclassified");
208 case Way_Residential:
209 return("residential");
233 /*++++++++++++++++++++++++++++++++++++++
234 A string containing the name of a type of transport.
236 const char *TransportName Returns the name.
238 Transport transport The transport type.
239 ++++++++++++++++++++++++++++++++++++++*/
241 const char *TransportName(Transport transport)
250 case Transport_Horse:
252 case Transport_Wheelchair:
253 return("wheelchair");
254 case Transport_Bicycle:
256 case Transport_Moped:
258 case Transport_Motorbike:
260 case Transport_Motorcar:
262 case Transport_Goods:
269 case Transport_Count:
277 /*++++++++++++++++++++++++++++++++++++++
278 A string containing the name of a highway property.
280 const char *PropertyName Returns the name.
282 Property property The property type.
283 ++++++++++++++++++++++++++++++++++++++*/
285 const char *PropertyName(Property property)
295 case Property_Multilane:
298 case Property_Bridge:
301 case Property_Tunnel:
312 /*++++++++++++++++++++++++++++++++++++++
313 A string containing the names of allowed transports on a way.
315 const char *AllowedNameList Returns the list of names.
317 wayallow_t allowed The allowed type.
318 ++++++++++++++++++++++++++++++++++++++*/
320 const char *AllowedNameList(wayallow_t allowed)
322 static char string[256];
326 if(allowed & Allow_Foot)
327 strcat(string,"foot");
329 if(allowed & Allow_Horse)
331 if(*string) strcat(string,", ");
332 strcat(string,"horse");
335 if(allowed & Allow_Wheelchair)
337 if(*string) strcat(string,", ");
338 strcat(string,"wheelchair");
341 if(allowed & Allow_Bicycle)
343 if(*string) strcat(string,", ");
344 strcat(string,"bicycle");
347 if(allowed & Allow_Moped)
349 if(*string) strcat(string,", ");
350 strcat(string,"moped");
353 if(allowed & Allow_Motorbike)
355 if(*string) strcat(string,", ");
356 strcat(string,"motorbike");
359 if(allowed & Allow_Motorcar)
361 if(*string) strcat(string,", ");
362 strcat(string,"motorcar");
365 if(allowed & Allow_Goods)
367 if(*string) strcat(string,", ");
368 strcat(string,"goods");
371 if(allowed & Allow_HGV)
373 if(*string) strcat(string,", ");
374 strcat(string,"hgv");
377 if(allowed & Allow_PSV)
379 if(*string) strcat(string,", ");
380 strcat(string,"psv");
387 /*++++++++++++++++++++++++++++++++++++++
388 A string containing the names of the properties of a way.
390 const char *PropertiesNameList Returns the list of names.
392 wayprop_t properties The properties of the way.
393 ++++++++++++++++++++++++++++++++++++++*/
395 const char *PropertiesNameList(wayprop_t properties)
397 static char string[256];
401 if(properties & Properties_Paved)
403 if(*string) strcat(string,", ");
404 strcat(string,"paved");
407 if(properties & Properties_Multilane)
409 if(*string) strcat(string,", ");
410 strcat(string,"multilane");
413 if(properties & Properties_Bridge)
415 if(*string) strcat(string,", ");
416 strcat(string,"bridge");
419 if(properties & Properties_Tunnel)
421 if(*string) strcat(string,", ");
422 strcat(string,"tunnel");
429 /*++++++++++++++++++++++++++++++++++++++
430 Returns a list of all the highway types.
432 const char *HighwayList Return a list of all the highway types.
433 ++++++++++++++++++++++++++++++++++++++*/
435 const char *HighwayList(void)
437 return " motorway = Motorway\n"
439 " primary = Primary\n"
440 " secondary = Secondary\n"
441 " tertiary = Tertiary\n"
442 " unclassified = Unclassified\n"
443 " residential = Residential\n"
444 " service = Service\n"
446 " cycleway = Cycleway\n"
453 /*++++++++++++++++++++++++++++++++++++++
454 Returns a list of all the transport types.
456 const char *TransportList Return a list of all the transport types.
457 ++++++++++++++++++++++++++++++++++++++*/
459 const char *TransportList(void)
461 return " foot = Foot\n"
462 " bicycle = Bicycle\n"
463 " wheelchair = Wheelchair\n"
465 " moped = Moped (Small motorbike, limited speed)\n"
466 " motorbike = Motorbike\n"
467 " motorcar = Motorcar\n"
468 " goods = Goods (Small lorry, van)\n"
469 " hgv = HGV (Heavy Goods Vehicle - large lorry)\n"
470 " psv = PSV (Public Service Vehicle - bus, coach)\n"
475 /*++++++++++++++++++++++++++++++++++++++
476 Returns a list of all the property types.
478 const char *PropertyList Return a list of all the highway proprties.
479 ++++++++++++++++++++++++++++++++++++++*/
481 const char *PropertyList(void)
483 return " paved = Paved (suitable for normal wheels)\n"
484 " multilane = Multiple lanes\n"