Routino SVN Repository Browser

Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino

ViewVC logotype

Contents of /branches/libroutino/src/routino.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1758 - (show annotations) (download) (as text)
Thu Jul 30 18:36:07 2015 UTC (9 years, 8 months ago) by amb
File MIME type: text/x-chdr
File size: 11271 byte(s)
Add the ability to request a linked list output representing the route
when using the routino library.

1 /***************************************
2 Routino library header file.
3
4 Part of the Routino routing software.
5 ******************/ /******************
6 This file Copyright 2015 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 #ifndef ROUTINO_H
24 #define ROUTINO_H /*+ To stop multiple inclusions. +*/
25
26 /* Limit the exported symbols in the library */
27
28 #if defined(_MSC_VER)
29 #ifdef LIBROUTINO
30 #define DLL_PUBLIC __declspec(dllexport)
31 #else
32 #define DLL_PUBLIC __declspec(dllimport)
33 #endif
34 #endif
35
36 #if defined(__GNUC__) && __GNUC__ >= 4
37 #if defined(__MINGW32__) || defined(__CYGWIN__)
38 #ifdef LIBROUTINO
39 #define DLL_PUBLIC __attribute__ ((dllexport))
40 #else
41 #define DLL_PUBLIC __attribute__ ((dllimport))
42 #endif
43 #else
44 #ifdef LIBROUTINO
45 #define DLL_PUBLIC __attribute__ ((visibility ("default")))
46 #endif
47 #endif
48 #endif
49
50 #ifndef DLL_PUBLIC
51 #define DLL_PUBLIC
52 #endif
53
54
55 /* Handle compilation with a C++ compiler */
56
57 #ifdef __cplusplus
58 extern "C"
59 {
60 #endif
61
62
63 /* Routino error constants */
64
65 #define ROUTINO_ERROR_NONE 0 /*+ No error. +*/
66
67 #define ROUTINO_ERROR_NO_DATABASE 1 /*+ A function was called without the database variable set. +*/
68 #define ROUTINO_ERROR_NO_PROFILE 2 /*+ A function was called without the profile variable set. +*/
69 #define ROUTINO_ERROR_NO_TRANSLATION 3 /*+ A function was called without the translation variable set. +*/
70
71 #define ROUTINO_ERROR_NO_DATABASE_FILES 11 /*+ The specified database to load did not exist. +*/
72 #define ROUTINO_ERROR_BAD_DATABASE_FILES 12 /*+ The specified database could not be loaded. +*/
73 #define ROUTINO_ERROR_NO_PROFILES_XML 13 /*+ The specified profiles XML file did not exist. +*/
74 #define ROUTINO_ERROR_BAD_PROFILES_XML 14 /*+ The specified profiles XML file could not be loaded. +*/
75 #define ROUTINO_ERROR_NO_TRANSLATIONS_XML 11 /*+ The specified translations XML file did not exist. +*/
76 #define ROUTINO_ERROR_BAD_TRANSLATIONS_XML 12 /*+ The specified translations XML file could not be loaded. +*/
77
78 #define ROUTINO_ERROR_NO_SUCH_PROFILE 21 /*+ The requested profile name does not exist in the loaded XML file. +*/
79 #define ROUTINO_ERROR_NO_SUCH_TRANSLATION 22 /*+ The requested translation language does not exist in the loaded XML file. +*/
80
81 #define ROUTINO_ERROR_NO_NEARBY_HIGHWAY 31 /*+ There is no highway near the coordinates to place a waypoint. +*/
82
83 #define ROUTINO_ERROR_PROFILE_DATABASE_ERR 41 /*+ The profile and database do not work together. +*/
84 #define ROUTINO_ERROR_NOTVALID_PROFILE 42 /*+ The profile being used has not been validated. +*/
85 #define ROUTINO_ERROR_BAD_USER_PROFILE 43 /*+ The user specified profile contained invalid data. +*/
86
87 #define ROUTINO_ERROR_BAD_OPTIONS 51 /*+ The routing options specified are not consistent with each other. +*/
88
89 #define ROUTINO_ERROR_NO_ROUTE_1 1001 /*+ A route could not be found to waypoint 1. +*/
90 #define ROUTINO_ERROR_NO_ROUTE_2 1002 /*+ A route could not be found to waypoint 2. +*/
91 #define ROUTINO_ERROR_NO_ROUTE_3 1003 /*+ A route could not be found to waypoint 3. +*/
92 /* Higher values of the error number refer to later waypoints. */
93
94
95 /* Routino routing option constants */
96
97 #define ROUTINO_ROUTE_SHORTEST 0 /*+ Calculate the shortest route. +*/
98 #define ROUTINO_ROUTE_QUICKEST 1 /*+ Calculate the quickest route. +*/
99
100 #define ROUTINO_ROUTE_FILE_HTML 2 /*+ Output an HTML route file. +*/
101 #define ROUTINO_ROUTE_FILE_GPX_TRACK 4 /*+ Output a GPX track file. +*/
102 #define ROUTINO_ROUTE_FILE_GPX_ROUTE 8 /*+ Output a GPX route file. +*/
103 #define ROUTINO_ROUTE_FILE_TEXT 16 /*+ Output a text file with important junctions. +*/
104 #define ROUTINO_ROUTE_FILE_TEXT_ALL 32 /*+ Output a text file with all nodes and segments. +*/
105
106 #define ROUTINO_ROUTE_FILE_STDOUT 64 /*+ Output a single file type to stdout. +*/
107
108 #define ROUTINO_ROUTE_LIST_TEXT 128 /*+ Output a linked list of of waypoints containing the text file information. +*/
109 #define ROUTINO_ROUTE_LIST_TEXT_ALL 256 /*+ Output a linked list of of waypoints containing the text all file information. +*/
110
111
112 /* Routino output point types */
113
114 #define ROUTINO_POINT_UNIMPORTANT 0 /*+ An unimportant, intermediate, node. +*/
115 #define ROUTINO_POINT_RB_NOT_EXIT 1 /*+ A roundabout exit that is not taken. +*/
116 #define ROUTINO_POINT_JUNCT_CONT 2 /*+ An un-interesting junction where the route continues without comment. +*/
117 #define ROUTINO_POINT_CHANGE 3 /*+ The highway changes type but nothing else happens. +*/
118 #define ROUTINO_POINT_JUNCT_IMPORT 4 /*+ An interesting junction to be described. +*/
119 #define ROUTINO_POINT_RB_ENTRY 5 /*+ The entrance to a roundabout. +*/
120 #define ROUTINO_POINT_RB_EXIT 6 /*+ The exit from a roundabout. +*/
121 #define ROUTINO_POINT_MINI_RB 7 /*+ The location of a mini-roundabout. +*/
122 #define ROUTINO_POINT_UTURN 8 /*+ The location of a U-turn. +*/
123 #define ROUTINO_POINT_WAYPOINT 9 /*+ A waypoint. +*/
124
125
126 /* Routino user profile array indexes */
127
128 #define ROUTINO_HIGHWAY_MOTORWAY 1 /*+ A Motorway highway. +*/
129 #define ROUTINO_HIGHWAY_TRUNK 2 /*+ A Trunk highway. +*/
130 #define ROUTINO_HIGHWAY_PRIMARY 3 /*+ A Primary highway. +*/
131 #define ROUTINO_HIGHWAY_SECONDARY 4 /*+ A Secondary highway. +*/
132 #define ROUTINO_HIGHWAY_TERTIARY 5 /*+ A Tertiary highway. +*/
133 #define ROUTINO_HIGHWAY_UNCLASSIFIED 6 /*+ A Unclassified highway. +*/
134 #define ROUTINO_HIGHWAY_RESIDENTIAL 7 /*+ A Residential highway. +*/
135 #define ROUTINO_HIGHWAY_SERVICE 8 /*+ A Service highway. +*/
136 #define ROUTINO_HIGHWAY_TRACK 9 /*+ A Track highway. +*/
137 #define ROUTINO_HIGHWAY_CYCLEWAY 10 /*+ A Cycleway highway. +*/
138 #define ROUTINO_HIGHWAY_PATH 11 /*+ A Path highway. +*/
139 #define ROUTINO_HIGHWAY_STEPS 12 /*+ A Steps highway. +*/
140 #define ROUTINO_HIGHWAY_FERRY 13 /*+ A Ferry highway. +*/
141
142 #define ROUTINO_PROPERTY_PAVED 1 /*+ A Paved highway. +*/
143 #define ROUTINO_PROPERTY_MULTILANE 2 /*+ A Multilane highway. +*/
144 #define ROUTINO_PROPERTY_BRIDGE 3 /*+ A Bridge highway. +*/
145 #define ROUTINO_PROPERTY_TUNNEL 4 /*+ A Tunnel highway. +*/
146 #define ROUTINO_PROPERTY_FOOTROUTE 5 /*+ A Footroute highway. +*/
147 #define ROUTINO_PROPERTY_BICYCLEROUTE 6 /*+ A Bicycleroute highway. +*/
148
149
150 /* Routino types */
151
152 typedef struct _Routino_Database Routino_Database;
153 typedef struct _Routino_Waypoint Routino_Waypoint;
154
155 #ifdef LIBROUTINO
156 typedef struct _Profile Routino_Profile;
157 typedef struct _Translation Routino_Translation;
158 #else
159 typedef struct _Routino_Profile Routino_Profile;
160 typedef struct _Routino_Translation Routino_Translation;
161 #endif
162
163 /*+ A data structure to hold a transport type profile. +*/
164 typedef struct _Routino_UserProfile
165 {
166 int transport; /*+ The type of transport. +*/
167
168 float highway[14]; /*+ A floating point preference for travel on the highway (range 0 to 1). +*/
169
170 float speed[14]; /*+ The maximum speed on each type of highway (km/hour). +*/
171
172 float props[7]; /*+ A floating point preference for ways with this attribute (range 0 to 1). +*/
173
174 int oneway; /*+ A flag to indicate if one-way restrictions apply. +*/
175 int turns; /*+ A flag to indicate if turn restrictions apply. +*/
176
177 float weight; /*+ The weight of the vehicle (in tonnes). +*/
178
179 float height; /*+ The height of the vehicle (in metres). +*/
180 float width; /*+ The width of vehicle (in metres). +*/
181 float length; /*+ The length of vehicle (in metres). +*/
182 }
183 Routino_UserProfile;
184
185
186 /*+ Forward declaration of the Routino_Output data type. +*/
187 typedef struct _Routino_Output Routino_Output;
188
189 /*+ A linked list output equivalent to the data in the text file output. +*/
190 struct _Routino_Output
191 {
192 Routino_Output *next; /*+ A pointer to the next route section. +*/
193
194 float lon; /*+ The longitude of the point (radians). +*/
195 float lat; /*+ The latitude of the point (radians). +*/
196
197 float dist; /*+ The total distance travelled (metres). +*/
198 float time; /*+ The total journet time (seconds). +*/
199
200 int type; /*+ The type of point (one of the ROUTINO_POINT_* values). +*/
201 int turn; /*+ The amount to turn for the next section of the route (degrees). +*/
202 int bearing; /*+ The compass direction for the next section of the route (degrees). +*/
203
204 char *string; /*+ The name of the next section of the route. +*/
205 };
206
207
208 /* Routino error number variable */
209
210 /*+ Contains the error number of the most recent Routino error. +*/
211 extern int Routino_errno;
212
213
214 /* Routino library functions */
215
216 DLL_PUBLIC Routino_Database *Routino_LoadDatabase(const char *dirname,const char *prefix);
217 DLL_PUBLIC void Routino_UnloadDatabase(Routino_Database *database);
218
219 DLL_PUBLIC int Routino_ParseXMLProfiles(const char *filename);
220 DLL_PUBLIC char **Routino_GetProfileNames(void);
221 DLL_PUBLIC Routino_Profile *Routino_GetProfile(const char *name);
222 DLL_PUBLIC void Routino_FreeXMLProfiles(void);
223
224 DLL_PUBLIC int Routino_ParseXMLTranslations(const char *filename);
225 DLL_PUBLIC char **Routino_GetTranslationLanguages(void);
226 DLL_PUBLIC Routino_Translation *Routino_GetTranslation(const char *language);
227 DLL_PUBLIC void Routino_FreeXMLTranslations(void);
228
229 DLL_PUBLIC Routino_Profile *Routino_CreateProfileFromUserProfile(Routino_UserProfile *profile);
230 DLL_PUBLIC Routino_UserProfile *Routino_CreateUserProfileFromProfile(Routino_Profile *profile);
231
232 DLL_PUBLIC int Routino_ValidateProfile(Routino_Database *database,Routino_Profile *profile);
233
234 DLL_PUBLIC Routino_Waypoint *Routino_FindWaypoint(Routino_Database *database,Routino_Profile *profile,double latitude,double longitude);
235
236 DLL_PUBLIC Routino_Output *Routino_CalculateRoute(Routino_Database *database,Routino_Profile *profile,Routino_Translation *translation,
237 Routino_Waypoint **waypoints,int nwaypoints,int options);
238
239 DLL_PUBLIC void Routino_DeleteRoute(Routino_Output *output);
240
241
242 /* Handle compilation with a C++ compiler */
243
244 #ifdef __cplusplus
245 }
246 #endif
247
248 #endif /* ROUTINO_H */