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/routino.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1766 - (hide annotations) (download) (as text)
Tue Aug 4 18:06:39 2015 UTC (9 years, 7 months ago) by amb
Original Path: branches/libroutino/src/routino.h
File MIME type: text/x-chdr
File size: 12587 byte(s)
Add speed for each route segment (text-all version) and rename the
'string' parameter to 'name'. Increase API version to 2.

1 amb 1715 /***************************************
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 amb 1720 #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 amb 1715 #else
44 amb 1720 #ifdef LIBROUTINO
45     #define DLL_PUBLIC __attribute__ ((visibility ("default")))
46     #endif
47 amb 1715 #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 amb 1765 /* Routino library API version */
63 amb 1715
64 amb 1766 #define ROUTINO_API_VERSION 2 /*+ A version number for the Routino API. +*/
65 amb 1765
66    
67 amb 1756 /* Routino error constants */
68 amb 1747
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 amb 1760 #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 amb 1747
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 amb 1753 #define ROUTINO_ERROR_NOTVALID_PROFILE 42 /*+ The profile being used has not been validated. +*/
89 amb 1757 #define ROUTINO_ERROR_BAD_USER_PROFILE 43 /*+ The user specified profile contained invalid data. +*/
90 amb 1747
91 amb 1756 #define ROUTINO_ERROR_BAD_OPTIONS 51 /*+ The routing options specified are not consistent with each other. +*/
92    
93 amb 1765 #define ROUTINO_ERROR_WRONG_API_VERSION 61 /*+ There is a mismatch between the library and caller API version. +*/
94    
95 amb 1747 #define ROUTINO_ERROR_NO_ROUTE_1 1001 /*+ A route could not be found to waypoint 1. +*/
96     #define ROUTINO_ERROR_NO_ROUTE_2 1002 /*+ A route could not be found to waypoint 2. +*/
97     #define ROUTINO_ERROR_NO_ROUTE_3 1003 /*+ A route could not be found to waypoint 3. +*/
98     /* Higher values of the error number refer to later waypoints. */
99    
100    
101 amb 1756 /* Routino routing option constants */
102    
103     #define ROUTINO_ROUTE_SHORTEST 0 /*+ Calculate the shortest route. +*/
104     #define ROUTINO_ROUTE_QUICKEST 1 /*+ Calculate the quickest route. +*/
105    
106     #define ROUTINO_ROUTE_FILE_HTML 2 /*+ Output an HTML route file. +*/
107     #define ROUTINO_ROUTE_FILE_GPX_TRACK 4 /*+ Output a GPX track file. +*/
108     #define ROUTINO_ROUTE_FILE_GPX_ROUTE 8 /*+ Output a GPX route file. +*/
109     #define ROUTINO_ROUTE_FILE_TEXT 16 /*+ Output a text file with important junctions. +*/
110     #define ROUTINO_ROUTE_FILE_TEXT_ALL 32 /*+ Output a text file with all nodes and segments. +*/
111    
112     #define ROUTINO_ROUTE_FILE_STDOUT 64 /*+ Output a single file type to stdout. +*/
113    
114 amb 1758 #define ROUTINO_ROUTE_LIST_TEXT 128 /*+ Output a linked list of of waypoints containing the text file information. +*/
115     #define ROUTINO_ROUTE_LIST_TEXT_ALL 256 /*+ Output a linked list of of waypoints containing the text all file information. +*/
116 amb 1756
117 amb 1758
118     /* Routino output point types */
119    
120     #define ROUTINO_POINT_UNIMPORTANT 0 /*+ An unimportant, intermediate, node. +*/
121     #define ROUTINO_POINT_RB_NOT_EXIT 1 /*+ A roundabout exit that is not taken. +*/
122     #define ROUTINO_POINT_JUNCT_CONT 2 /*+ An un-interesting junction where the route continues without comment. +*/
123     #define ROUTINO_POINT_CHANGE 3 /*+ The highway changes type but nothing else happens. +*/
124     #define ROUTINO_POINT_JUNCT_IMPORT 4 /*+ An interesting junction to be described. +*/
125     #define ROUTINO_POINT_RB_ENTRY 5 /*+ The entrance to a roundabout. +*/
126     #define ROUTINO_POINT_RB_EXIT 6 /*+ The exit from a roundabout. +*/
127     #define ROUTINO_POINT_MINI_RB 7 /*+ The location of a mini-roundabout. +*/
128     #define ROUTINO_POINT_UTURN 8 /*+ The location of a U-turn. +*/
129     #define ROUTINO_POINT_WAYPOINT 9 /*+ A waypoint. +*/
130    
131    
132 amb 1757 /* Routino user profile array indexes */
133    
134     #define ROUTINO_HIGHWAY_MOTORWAY 1 /*+ A Motorway highway. +*/
135     #define ROUTINO_HIGHWAY_TRUNK 2 /*+ A Trunk highway. +*/
136     #define ROUTINO_HIGHWAY_PRIMARY 3 /*+ A Primary highway. +*/
137     #define ROUTINO_HIGHWAY_SECONDARY 4 /*+ A Secondary highway. +*/
138     #define ROUTINO_HIGHWAY_TERTIARY 5 /*+ A Tertiary highway. +*/
139     #define ROUTINO_HIGHWAY_UNCLASSIFIED 6 /*+ A Unclassified highway. +*/
140     #define ROUTINO_HIGHWAY_RESIDENTIAL 7 /*+ A Residential highway. +*/
141     #define ROUTINO_HIGHWAY_SERVICE 8 /*+ A Service highway. +*/
142     #define ROUTINO_HIGHWAY_TRACK 9 /*+ A Track highway. +*/
143     #define ROUTINO_HIGHWAY_CYCLEWAY 10 /*+ A Cycleway highway. +*/
144     #define ROUTINO_HIGHWAY_PATH 11 /*+ A Path highway. +*/
145     #define ROUTINO_HIGHWAY_STEPS 12 /*+ A Steps highway. +*/
146     #define ROUTINO_HIGHWAY_FERRY 13 /*+ A Ferry highway. +*/
147    
148     #define ROUTINO_PROPERTY_PAVED 1 /*+ A Paved highway. +*/
149     #define ROUTINO_PROPERTY_MULTILANE 2 /*+ A Multilane highway. +*/
150     #define ROUTINO_PROPERTY_BRIDGE 3 /*+ A Bridge highway. +*/
151     #define ROUTINO_PROPERTY_TUNNEL 4 /*+ A Tunnel highway. +*/
152     #define ROUTINO_PROPERTY_FOOTROUTE 5 /*+ A Footroute highway. +*/
153     #define ROUTINO_PROPERTY_BICYCLEROUTE 6 /*+ A Bicycleroute highway. +*/
154    
155    
156 amb 1738 /* Routino types */
157 amb 1715
158 amb 1760 /*+ A data structure to hold a Routino database loaded from a file (the contents are private). +*/
159 amb 1738 typedef struct _Routino_Database Routino_Database;
160 amb 1760
161     /*+ A data structure to hold a Routino waypoint found within the database (the contents are private). +*/
162 amb 1738 typedef struct _Routino_Waypoint Routino_Waypoint;
163 amb 1715
164 amb 1760 /*+ A data structure to hold a Routino routing profile (the contents are private). +*/
165 amb 1738 #ifdef LIBROUTINO
166     typedef struct _Profile Routino_Profile;
167 amb 1760 #else
168     typedef struct _Routino_Profile Routino_Profile;
169     #endif
170    
171     /*+ A data structure to hold a Routino translation (the contents are private). +*/
172     #ifdef LIBROUTINO
173 amb 1738 typedef struct _Translation Routino_Translation;
174     #else
175     typedef struct _Routino_Translation Routino_Translation;
176     #endif
177 amb 1715
178 amb 1760 /*+ A data structure to hold a routing profile that can be defined by the user. +*/
179 amb 1758 typedef struct _Routino_UserProfile
180     {
181     int transport; /*+ The type of transport. +*/
182 amb 1738
183 amb 1758 float highway[14]; /*+ A floating point preference for travel on the highway (range 0 to 1). +*/
184 amb 1757
185 amb 1758 float speed[14]; /*+ The maximum speed on each type of highway (km/hour). +*/
186 amb 1757
187 amb 1758 float props[7]; /*+ A floating point preference for ways with this attribute (range 0 to 1). +*/
188 amb 1757
189 amb 1758 int oneway; /*+ A flag to indicate if one-way restrictions apply. +*/
190     int turns; /*+ A flag to indicate if turn restrictions apply. +*/
191 amb 1757
192 amb 1758 float weight; /*+ The weight of the vehicle (in tonnes). +*/
193 amb 1757
194 amb 1758 float height; /*+ The height of the vehicle (in metres). +*/
195     float width; /*+ The width of vehicle (in metres). +*/
196     float length; /*+ The length of vehicle (in metres). +*/
197     }
198     Routino_UserProfile;
199 amb 1757
200    
201 amb 1758 /*+ Forward declaration of the Routino_Output data type. +*/
202     typedef struct _Routino_Output Routino_Output;
203    
204 amb 1760 /*+ A linked list output of the calculated route whose contents depend on the ROUTINO_ROUTE_LIST_* options selected. +*/
205 amb 1758 struct _Routino_Output
206     {
207     Routino_Output *next; /*+ A pointer to the next route section. +*/
208    
209     float lon; /*+ The longitude of the point (radians). +*/
210     float lat; /*+ The latitude of the point (radians). +*/
211    
212     float dist; /*+ The total distance travelled (metres). +*/
213 amb 1760 float time; /*+ The total journey time (seconds). +*/
214 amb 1758
215 amb 1766 float speed; /*+ The speed (km/hr) for this section of the route (ROUTINO_ROUTE_TEXT_ALL format only). +*/
216    
217 amb 1758 int type; /*+ The type of point (one of the ROUTINO_POINT_* values). +*/
218    
219 amb 1760 int turn; /*+ The amount to turn (degrees) for the next section of the route (ROUTINO_ROUTE_TEXT format only). +*/
220     int bearing; /*+ The compass direction (degrees) for the next section of the route. +*/
221    
222 amb 1766 char *name; /*+ The name of the next section of the route (ROUTINO_ROUTE_TEXT format) or previous section of the route (ROUTINO_ROUTE_TEXT_ALL format). +*/
223 amb 1758 };
224    
225    
226     /* Routino error number variable */
227    
228 amb 1765 /*+ Contains the libroutino API version number. +*/
229     extern int Routino_APIVersion;
230    
231 amb 1760 /*+ Contains the error number of the most recent Routino function (one of the ROUTINO_ERROR_* values). +*/
232 amb 1758 extern int Routino_errno;
233    
234    
235 amb 1738 /* Routino library functions */
236    
237 amb 1765 #define Routino_CheckAPIVersion() Routino_Check_API_Version(ROUTINO_API_VERSION) /*+ A wrapper function to simplify the API version check. +*/
238    
239     DLL_PUBLIC int Routino_Check_API_Version(int caller_version);
240    
241 amb 1738 DLL_PUBLIC Routino_Database *Routino_LoadDatabase(const char *dirname,const char *prefix);
242     DLL_PUBLIC void Routino_UnloadDatabase(Routino_Database *database);
243    
244     DLL_PUBLIC int Routino_ParseXMLProfiles(const char *filename);
245 amb 1755 DLL_PUBLIC char **Routino_GetProfileNames(void);
246 amb 1738 DLL_PUBLIC Routino_Profile *Routino_GetProfile(const char *name);
247     DLL_PUBLIC void Routino_FreeXMLProfiles(void);
248    
249     DLL_PUBLIC int Routino_ParseXMLTranslations(const char *filename);
250 amb 1755 DLL_PUBLIC char **Routino_GetTranslationLanguages(void);
251 amb 1738 DLL_PUBLIC Routino_Translation *Routino_GetTranslation(const char *language);
252     DLL_PUBLIC void Routino_FreeXMLTranslations(void);
253    
254 amb 1757 DLL_PUBLIC Routino_Profile *Routino_CreateProfileFromUserProfile(Routino_UserProfile *profile);
255     DLL_PUBLIC Routino_UserProfile *Routino_CreateUserProfileFromProfile(Routino_Profile *profile);
256    
257 amb 1748 DLL_PUBLIC int Routino_ValidateProfile(Routino_Database *database,Routino_Profile *profile);
258    
259 amb 1738 DLL_PUBLIC Routino_Waypoint *Routino_FindWaypoint(Routino_Database *database,Routino_Profile *profile,double latitude,double longitude);
260    
261 amb 1758 DLL_PUBLIC Routino_Output *Routino_CalculateRoute(Routino_Database *database,Routino_Profile *profile,Routino_Translation *translation,
262     Routino_Waypoint **waypoints,int nwaypoints,int options);
263 amb 1738
264 amb 1758 DLL_PUBLIC void Routino_DeleteRoute(Routino_Output *output);
265 amb 1738
266 amb 1758
267 amb 1715 /* Handle compilation with a C++ compiler */
268    
269     #ifdef __cplusplus
270     }
271     #endif
272    
273     #endif /* ROUTINO_H */