1 /***************************************
2 $Header: /home/amb/routino/src/RCS/types.c,v 1.6 2010/09/17 17:43:41 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,"ferry")) return(Way_Ferry);
51 if(!strcmp(highway,"motorway")) return(Way_Motorway);
55 if(!strcmp(highway,"primary")) return(Way_Primary);
56 if(!strcmp(highway,"path")) return(Way_Path);
60 if(!strcmp(highway,"residential")) return(Way_Residential);
64 if(!strcmp(highway,"secondary")) return(Way_Secondary);
65 if(!strcmp(highway,"service")) return(Way_Service);
66 if(!strcmp(highway,"steps")) return(Way_Steps);
70 if(!strcmp(highway,"trunk")) return(Way_Trunk);
71 if(!strcmp(highway,"tertiary")) return(Way_Tertiary);
72 if(!strcmp(highway,"track")) return(Way_Track);
76 if(!strcmp(highway,"unclassified")) return(Way_Unclassified);
87 /*++++++++++++++++++++++++++++++++++++++
88 Decide on the type of transport given the name of it.
90 Transport TransportType Returns the type of the transport.
92 const char *transport The string containing the method of transport.
93 ++++++++++++++++++++++++++++++++++++++*/
95 Transport TransportType(const char *transport)
100 if(!strcmp(transport,"bicycle"))
101 return(Transport_Bicycle);
105 if(!strcmp(transport,"foot"))
106 return(Transport_Foot);
110 if(!strcmp(transport,"goods"))
111 return(Transport_Goods);
115 if(!strcmp(transport,"horse"))
116 return(Transport_Horse);
117 if(!strcmp(transport,"hgv"))
118 return(Transport_HGV);
122 if(!strcmp(transport,"moped"))
123 return(Transport_Moped);
124 if(!strcmp(transport,"motorbike"))
125 return(Transport_Motorbike);
126 if(!strcmp(transport,"motorcar"))
127 return(Transport_Motorcar);
131 if(!strcmp(transport,"psv"))
132 return(Transport_PSV);
136 if(!strcmp(transport,"wheelchair"))
137 return(Transport_Wheelchair);
141 return(Transport_None);
144 return(Transport_None);
148 /*++++++++++++++++++++++++++++++++++++++
149 Decide on the type of property given the name of it.
151 Property PropertyType Returns the type of the property.
153 const char *property The string containing the method of property.
154 ++++++++++++++++++++++++++++++++++++++*/
156 Property PropertyType(const char *property)
161 if(!strcmp(property,"bicycleroute"))
162 return(Property_BicycleRoute);
164 if(!strcmp(property,"bridge"))
165 return(Property_Bridge);
169 if(!strcmp(property,"footroute"))
170 return(Property_FootRoute);
174 if(!strcmp(property,"multilane"))
175 return(Property_Multilane);
179 if(!strcmp(property,"paved"))
180 return(Property_Paved);
184 if(!strcmp(property,"tunnel"))
185 return(Property_Tunnel);
189 return(Property_None);
192 return(Property_None);
196 /*++++++++++++++++++++++++++++++++++++++
197 A string containing the name of a type of highway.
199 const char *HighwayName Returns the name.
201 Highway highway The highway type.
202 ++++++++++++++++++++++++++++++++++++++*/
204 const char *HighwayName(Highway highway)
218 case Way_Unclassified:
219 return("unclassified");
220 case Way_Residential:
221 return("residential");
247 /*++++++++++++++++++++++++++++++++++++++
248 A string containing the name of a type of transport.
250 const char *TransportName Returns the name.
252 Transport transport The transport type.
253 ++++++++++++++++++++++++++++++++++++++*/
255 const char *TransportName(Transport transport)
264 case Transport_Horse:
266 case Transport_Wheelchair:
267 return("wheelchair");
268 case Transport_Bicycle:
270 case Transport_Moped:
272 case Transport_Motorbike:
274 case Transport_Motorcar:
276 case Transport_Goods:
283 case Transport_Count:
291 /*++++++++++++++++++++++++++++++++++++++
292 A string containing the name of a highway property.
294 const char *PropertyName Returns the name.
296 Property property The property type.
297 ++++++++++++++++++++++++++++++++++++++*/
299 const char *PropertyName(Property property)
309 case Property_Multilane:
312 case Property_Bridge:
315 case Property_Tunnel:
318 case Property_FootRoute:
321 case Property_BicycleRoute:
322 return("bicycleroute");
332 /*++++++++++++++++++++++++++++++++++++++
333 A string containing the names of allowed transports on a way.
335 const char *AllowedNameList Returns the list of names.
337 allow_t allowed The allowed type.
338 ++++++++++++++++++++++++++++++++++++++*/
340 const char *AllowedNameList(allow_t allowed)
342 static char string[256];
346 if(allowed & Allow_Foot)
347 strcat(string,"foot");
349 if(allowed & Allow_Horse)
351 if(*string) strcat(string,", ");
352 strcat(string,"horse");
355 if(allowed & Allow_Wheelchair)
357 if(*string) strcat(string,", ");
358 strcat(string,"wheelchair");
361 if(allowed & Allow_Bicycle)
363 if(*string) strcat(string,", ");
364 strcat(string,"bicycle");
367 if(allowed & Allow_Moped)
369 if(*string) strcat(string,", ");
370 strcat(string,"moped");
373 if(allowed & Allow_Motorbike)
375 if(*string) strcat(string,", ");
376 strcat(string,"motorbike");
379 if(allowed & Allow_Motorcar)
381 if(*string) strcat(string,", ");
382 strcat(string,"motorcar");
385 if(allowed & Allow_Goods)
387 if(*string) strcat(string,", ");
388 strcat(string,"goods");
391 if(allowed & Allow_HGV)
393 if(*string) strcat(string,", ");
394 strcat(string,"hgv");
397 if(allowed & Allow_PSV)
399 if(*string) strcat(string,", ");
400 strcat(string,"psv");
407 /*++++++++++++++++++++++++++++++++++++++
408 A string containing the names of the properties of a way.
410 const char *PropertiesNameList Returns the list of names.
412 wayprop_t properties The properties of the way.
413 ++++++++++++++++++++++++++++++++++++++*/
415 const char *PropertiesNameList(wayprop_t properties)
417 static char string[256];
421 if(properties & Properties_Paved)
423 if(*string) strcat(string,", ");
424 strcat(string,"paved");
427 if(properties & Properties_Multilane)
429 if(*string) strcat(string,", ");
430 strcat(string,"multilane");
433 if(properties & Properties_Bridge)
435 if(*string) strcat(string,", ");
436 strcat(string,"bridge");
439 if(properties & Properties_Tunnel)
441 if(*string) strcat(string,", ");
442 strcat(string,"tunnel");
445 if(properties & Properties_FootRoute)
447 if(*string) strcat(string,", ");
448 strcat(string,"footroute");
451 if(properties & Properties_BicycleRoute)
453 if(*string) strcat(string,", ");
454 strcat(string,"bicycleroute");
461 /*++++++++++++++++++++++++++++++++++++++
462 Returns a list of all the highway types.
464 const char *HighwayList Return a list of all the highway types.
465 ++++++++++++++++++++++++++++++++++++++*/
467 const char *HighwayList(void)
469 return " motorway = Motorway\n"
471 " primary = Primary\n"
472 " secondary = Secondary\n"
473 " tertiary = Tertiary\n"
474 " unclassified = Unclassified\n"
475 " residential = Residential\n"
476 " service = Service\n"
478 " cycleway = Cycleway\n"
486 /*++++++++++++++++++++++++++++++++++++++
487 Returns a list of all the transport types.
489 const char *TransportList Return a list of all the transport types.
490 ++++++++++++++++++++++++++++++++++++++*/
492 const char *TransportList(void)
494 return " foot = Foot\n"
495 " bicycle = Bicycle\n"
496 " wheelchair = Wheelchair\n"
498 " moped = Moped (Small motorbike, limited speed)\n"
499 " motorbike = Motorbike\n"
500 " motorcar = Motorcar\n"
501 " goods = Goods (Small lorry, van)\n"
502 " hgv = HGV (Heavy Goods Vehicle - large lorry)\n"
503 " psv = PSV (Public Service Vehicle - bus, coach)\n"
508 /*++++++++++++++++++++++++++++++++++++++
509 Returns a list of all the property types.
511 const char *PropertyList Return a list of all the highway proprties.
512 ++++++++++++++++++++++++++++++++++++++*/
514 const char *PropertyList(void)
516 return " paved = Paved (suitable for normal wheels)\n"
517 " multilane = Multiple lanes\n"
520 " footroute = A route marked for foot travel\n"
521 " bicycleroute = A route marked for bicycle travel\n"