Check out the latest version of Routino: svn co http://routino.org/svn/trunk routino
Contents of /trunk/src/routino.h
Parent Directory
|
Revision Log
Revision 1784 -
(show annotations)
(download)
(as text)
Sat Aug 15 13:08:37 2015 UTC (9 years, 7 months ago) by amb
File MIME type: text/x-chdr
File size: 13560 byte(s)
Sat Aug 15 13:08:37 2015 UTC (9 years, 7 months ago) by amb
File MIME type: text/x-chdr
File size: 13560 byte(s)
Merge libroutino branch back into the trunk.
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 | /* Routino library API version */ |
63 | |
64 | #define ROUTINO_API_VERSION 5 /*+ A version number for the Routino API. +*/ |
65 | |
66 | |
67 | /* Routino error constants */ |
68 | |
69 | #define ROUTINO_ERROR_NONE 0 /*+ No error. +*/ |
70 | |
71 | #define ROUTINO_ERROR_NO_DATABASE 1 /*+ A function was called without the database variable set. +*/ |
72 | #define ROUTINO_ERROR_NO_PROFILE 2 /*+ A function was called without the profile variable set. +*/ |
73 | #define ROUTINO_ERROR_NO_TRANSLATION 3 /*+ A function was called without the translation variable set. +*/ |
74 | |
75 | #define ROUTINO_ERROR_NO_DATABASE_FILES 11 /*+ The specified database to load did not exist. +*/ |
76 | #define ROUTINO_ERROR_BAD_DATABASE_FILES 12 /*+ The specified database could not be loaded. +*/ |
77 | #define ROUTINO_ERROR_NO_PROFILES_XML 13 /*+ The specified profiles XML file did not exist. +*/ |
78 | #define ROUTINO_ERROR_BAD_PROFILES_XML 14 /*+ The specified profiles XML file could not be loaded. +*/ |
79 | #define ROUTINO_ERROR_NO_TRANSLATIONS_XML 15 /*+ The specified translations XML file did not exist. +*/ |
80 | #define ROUTINO_ERROR_BAD_TRANSLATIONS_XML 16 /*+ The specified translations XML file could not be loaded. +*/ |
81 | |
82 | #define ROUTINO_ERROR_NO_SUCH_PROFILE 21 /*+ The requested profile name does not exist in the loaded XML file. +*/ |
83 | #define ROUTINO_ERROR_NO_SUCH_TRANSLATION 22 /*+ The requested translation language does not exist in the loaded XML file. +*/ |
84 | |
85 | #define ROUTINO_ERROR_NO_NEARBY_HIGHWAY 31 /*+ There is no highway near the coordinates to place a waypoint. +*/ |
86 | |
87 | #define ROUTINO_ERROR_PROFILE_DATABASE_ERR 41 /*+ The profile and database do not work together. +*/ |
88 | #define ROUTINO_ERROR_NOTVALID_PROFILE 42 /*+ The profile being used has not been validated. +*/ |
89 | #define ROUTINO_ERROR_BAD_USER_PROFILE 43 /*+ The user specified profile contained invalid data. +*/ |
90 | |
91 | #define ROUTINO_ERROR_BAD_OPTIONS 51 /*+ The routing options specified are not consistent with each other. +*/ |
92 | |
93 | #define ROUTINO_ERROR_WRONG_API_VERSION 61 /*+ There is a mismatch between the library and caller API version. +*/ |
94 | |
95 | #define ROUTINO_ERROR_PROGRESS_ABORTED 71 /*+ The progress function returned false. +*/ |
96 | |
97 | #define ROUTINO_ERROR_NO_ROUTE_1 1001 /*+ A route could not be found to waypoint 1. +*/ |
98 | #define ROUTINO_ERROR_NO_ROUTE_2 1002 /*+ A route could not be found to waypoint 2. +*/ |
99 | #define ROUTINO_ERROR_NO_ROUTE_3 1003 /*+ A route could not be found to waypoint 3. +*/ |
100 | /* Higher values of the error number refer to later waypoints. */ |
101 | |
102 | |
103 | /* Routino routing option constants */ |
104 | |
105 | #define ROUTINO_ROUTE_SHORTEST 0 /*+ Calculate the shortest route. +*/ |
106 | #define ROUTINO_ROUTE_QUICKEST 1 /*+ Calculate the quickest route. +*/ |
107 | |
108 | #define ROUTINO_ROUTE_FILE_HTML 2 /*+ Output an HTML route file. +*/ |
109 | #define ROUTINO_ROUTE_FILE_GPX_TRACK 4 /*+ Output a GPX track file. +*/ |
110 | #define ROUTINO_ROUTE_FILE_GPX_ROUTE 8 /*+ Output a GPX route file. +*/ |
111 | #define ROUTINO_ROUTE_FILE_TEXT 16 /*+ Output a text file with important junctions. +*/ |
112 | #define ROUTINO_ROUTE_FILE_TEXT_ALL 32 /*+ Output a text file with all nodes and segments. +*/ |
113 | |
114 | #define ROUTINO_ROUTE_FILE_STDOUT 64 /*+ Output a single file type to stdout. +*/ |
115 | |
116 | #define ROUTINO_ROUTE_LIST_HTML 128 /*+ Output a linked list of of waypoints containing the HTML file information but as plain text. +*/ |
117 | #define ROUTINO_ROUTE_LIST_TEXT 256 /*+ Output a linked list of of waypoints containing the text file information. +*/ |
118 | #define ROUTINO_ROUTE_LIST_TEXT_ALL 512 /*+ Output a linked list of of waypoints containing the text all file information. +*/ |
119 | |
120 | |
121 | /* Routino output point types */ |
122 | |
123 | #define ROUTINO_POINT_UNIMPORTANT 0 /*+ An unimportant, intermediate, node. +*/ |
124 | #define ROUTINO_POINT_RB_NOT_EXIT 1 /*+ A roundabout exit that is not taken. +*/ |
125 | #define ROUTINO_POINT_JUNCT_CONT 2 /*+ An un-interesting junction where the route continues without comment. +*/ |
126 | #define ROUTINO_POINT_CHANGE 3 /*+ The highway changes type but nothing else happens. +*/ |
127 | #define ROUTINO_POINT_JUNCT_IMPORT 4 /*+ An interesting junction to be described. +*/ |
128 | #define ROUTINO_POINT_RB_ENTRY 5 /*+ The entrance to a roundabout. +*/ |
129 | #define ROUTINO_POINT_RB_EXIT 6 /*+ The exit from a roundabout. +*/ |
130 | #define ROUTINO_POINT_MINI_RB 7 /*+ The location of a mini-roundabout. +*/ |
131 | #define ROUTINO_POINT_UTURN 8 /*+ The location of a U-turn. +*/ |
132 | #define ROUTINO_POINT_WAYPOINT 9 /*+ A waypoint. +*/ |
133 | |
134 | |
135 | /* Routino user profile array indexes */ |
136 | |
137 | #define ROUTINO_HIGHWAY_MOTORWAY 1 /*+ A Motorway highway. +*/ |
138 | #define ROUTINO_HIGHWAY_TRUNK 2 /*+ A Trunk highway. +*/ |
139 | #define ROUTINO_HIGHWAY_PRIMARY 3 /*+ A Primary highway. +*/ |
140 | #define ROUTINO_HIGHWAY_SECONDARY 4 /*+ A Secondary highway. +*/ |
141 | #define ROUTINO_HIGHWAY_TERTIARY 5 /*+ A Tertiary highway. +*/ |
142 | #define ROUTINO_HIGHWAY_UNCLASSIFIED 6 /*+ A Unclassified highway. +*/ |
143 | #define ROUTINO_HIGHWAY_RESIDENTIAL 7 /*+ A Residential highway. +*/ |
144 | #define ROUTINO_HIGHWAY_SERVICE 8 /*+ A Service highway. +*/ |
145 | #define ROUTINO_HIGHWAY_TRACK 9 /*+ A Track highway. +*/ |
146 | #define ROUTINO_HIGHWAY_CYCLEWAY 10 /*+ A Cycleway highway. +*/ |
147 | #define ROUTINO_HIGHWAY_PATH 11 /*+ A Path highway. +*/ |
148 | #define ROUTINO_HIGHWAY_STEPS 12 /*+ A Steps highway. +*/ |
149 | #define ROUTINO_HIGHWAY_FERRY 13 /*+ A Ferry highway. +*/ |
150 | |
151 | #define ROUTINO_PROPERTY_PAVED 1 /*+ A Paved highway. +*/ |
152 | #define ROUTINO_PROPERTY_MULTILANE 2 /*+ A Multilane highway. +*/ |
153 | #define ROUTINO_PROPERTY_BRIDGE 3 /*+ A Bridge highway. +*/ |
154 | #define ROUTINO_PROPERTY_TUNNEL 4 /*+ A Tunnel highway. +*/ |
155 | #define ROUTINO_PROPERTY_FOOTROUTE 5 /*+ A Footroute highway. +*/ |
156 | #define ROUTINO_PROPERTY_BICYCLEROUTE 6 /*+ A Bicycleroute highway. +*/ |
157 | |
158 | |
159 | /* Routino types */ |
160 | |
161 | /*+ A data structure to hold a Routino database loaded from a file (the contents are private). +*/ |
162 | typedef struct _Routino_Database Routino_Database; |
163 | |
164 | /*+ A data structure to hold a Routino waypoint found within the database (the contents are private). +*/ |
165 | typedef struct _Routino_Waypoint Routino_Waypoint; |
166 | |
167 | /*+ A data structure to hold a Routino routing profile (the contents are private). +*/ |
168 | #ifdef LIBROUTINO |
169 | typedef struct _Profile Routino_Profile; |
170 | #else |
171 | typedef struct _Routino_Profile Routino_Profile; |
172 | #endif |
173 | |
174 | /*+ A data structure to hold a Routino translation (the contents are private). +*/ |
175 | #ifdef LIBROUTINO |
176 | typedef struct _Translation Routino_Translation; |
177 | #else |
178 | typedef struct _Routino_Translation Routino_Translation; |
179 | #endif |
180 | |
181 | /*+ A data structure to hold a routing profile that can be defined by the user. +*/ |
182 | typedef struct _Routino_UserProfile |
183 | { |
184 | int transport; /*+ The type of transport. +*/ |
185 | |
186 | float highway[14]; /*+ A floating point preference for travel on the highway (range 0 to 1). +*/ |
187 | |
188 | float speed[14]; /*+ The maximum speed on each type of highway (km/hour). +*/ |
189 | |
190 | float props[7]; /*+ A floating point preference for ways with this attribute (range 0 to 1). +*/ |
191 | |
192 | int oneway; /*+ A flag to indicate if one-way restrictions apply. +*/ |
193 | int turns; /*+ A flag to indicate if turn restrictions apply. +*/ |
194 | |
195 | float weight; /*+ The weight of the vehicle (in tonnes). +*/ |
196 | |
197 | float height; /*+ The height of the vehicle (in metres). +*/ |
198 | float width; /*+ The width of vehicle (in metres). +*/ |
199 | float length; /*+ The length of vehicle (in metres). +*/ |
200 | } |
201 | Routino_UserProfile; |
202 | |
203 | |
204 | /*+ Forward declaration of the Routino_Output data type. +*/ |
205 | typedef struct _Routino_Output Routino_Output; |
206 | |
207 | /*+ A linked list output of the calculated route whose contents depend on the ROUTINO_ROUTE_LIST_* options selected. +*/ |
208 | struct _Routino_Output |
209 | { |
210 | Routino_Output *next; /*+ A pointer to the next route section. +*/ |
211 | |
212 | float lon; /*+ The longitude of the point (radians). +*/ |
213 | float lat; /*+ The latitude of the point (radians). +*/ |
214 | |
215 | float dist; /*+ The total distance travelled (metres). +*/ |
216 | float time; /*+ The total journey time (seconds). +*/ |
217 | |
218 | float speed; /*+ The speed (km/hr) for this section of the route (ROUTINO_ROUTE_LIST_TEXT_ALL format only). +*/ |
219 | |
220 | int type; /*+ The type of point (one of the ROUTINO_POINT_* values). +*/ |
221 | |
222 | int turn; /*+ The amount to turn (degrees) for the next section of the route (ROUTINO_ROUTE_LIST_TEXT or ROUTINO_ROUTE_LIST_HTML format). +*/ |
223 | int bearing; /*+ The compass direction (degrees) for the next section of the route. +*/ |
224 | |
225 | char *name; /*+ The name of the next section of the route (ROUTINO_ROUTE_LIST_TEXT or ROUTINO_ROUTE_LIST_HTML format) or previous section of the route (ROUTINO_ROUTE_LIST_TEXT_ALL format). +*/ |
226 | |
227 | char *desc1; /*+ The first part of the description of the next section of route (ROUTINO_ROUTE_LIST_HTML format only). +*/ |
228 | char *desc2; /*+ The second part of the description of the next section of route (ROUTINO_ROUTE_LIST_HTML format only). +*/ |
229 | char *desc3; /*+ The third part of the description, the total distance and time (ROUTINO_ROUTE_LIST_HTML format only). +*/ |
230 | }; |
231 | |
232 | |
233 | /*+ A type of function that can be used as a callback to indicate routing progress, if it returns false the router stops. +*/ |
234 | typedef int (*Routino_ProgressFunc)(double complete); |
235 | |
236 | |
237 | /* Routino error number variable */ |
238 | |
239 | /*+ Contains the libroutino API version number. +*/ |
240 | DLL_PUBLIC extern int Routino_APIVersion; |
241 | |
242 | /*+ Contains the error number of the most recent Routino function (one of the ROUTINO_ERROR_* values). +*/ |
243 | DLL_PUBLIC extern int Routino_errno; |
244 | |
245 | |
246 | /* Routino library functions */ |
247 | |
248 | #define Routino_CheckAPIVersion() Routino_Check_API_Version(ROUTINO_API_VERSION) /*+ A wrapper function to simplify the API version check. +*/ |
249 | |
250 | DLL_PUBLIC int Routino_Check_API_Version(int caller_version); |
251 | |
252 | DLL_PUBLIC Routino_Database *Routino_LoadDatabase(const char *dirname,const char *prefix); |
253 | DLL_PUBLIC void Routino_UnloadDatabase(Routino_Database *database); |
254 | |
255 | DLL_PUBLIC int Routino_ParseXMLProfiles(const char *filename); |
256 | DLL_PUBLIC char **Routino_GetProfileNames(void); |
257 | DLL_PUBLIC Routino_Profile *Routino_GetProfile(const char *name); |
258 | DLL_PUBLIC void Routino_FreeXMLProfiles(void); |
259 | |
260 | DLL_PUBLIC int Routino_ParseXMLTranslations(const char *filename); |
261 | DLL_PUBLIC char **Routino_GetTranslationLanguages(void); |
262 | DLL_PUBLIC Routino_Translation *Routino_GetTranslation(const char *language); |
263 | DLL_PUBLIC void Routino_FreeXMLTranslations(void); |
264 | |
265 | DLL_PUBLIC Routino_Profile *Routino_CreateProfileFromUserProfile(Routino_UserProfile *profile); |
266 | DLL_PUBLIC Routino_UserProfile *Routino_CreateUserProfileFromProfile(Routino_Profile *profile); |
267 | |
268 | DLL_PUBLIC int Routino_ValidateProfile(Routino_Database *database,Routino_Profile *profile); |
269 | |
270 | DLL_PUBLIC Routino_Waypoint *Routino_FindWaypoint(Routino_Database *database,Routino_Profile *profile,double latitude,double longitude); |
271 | |
272 | DLL_PUBLIC Routino_Output *Routino_CalculateRoute(Routino_Database *database,Routino_Profile *profile,Routino_Translation *translation, |
273 | Routino_Waypoint **waypoints,int nwaypoints,int options,Routino_ProgressFunc progress); |
274 | |
275 | DLL_PUBLIC void Routino_DeleteRoute(Routino_Output *output); |
276 | |
277 | |
278 | /* Handle compilation with a C++ compiler */ |
279 | |
280 | #ifdef __cplusplus |
281 | } |
282 | #endif |
283 | |
284 | #endif /* ROUTINO_H */ |