Routino SVN Repository Browser

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

ViewVC logotype

Contents of /branches/destination-access/doc/LIBRARY.txt

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1829 - (show annotations) (download)
Sat Oct 17 14:17:17 2015 UTC (9 years, 5 months ago) by amb
File MIME type: text/plain
File size: 21374 byte(s)
Merge trunk back into routino-destination branch after completing the
loop and reverse changes.

1 Routino : Library
2 =================
3
4
5 Library Usage
6 -------------
7
8 This page describes the libroutino shared library that can be compiled
9 from the Routino source code and used in other programs.
10
11 Compilation
12 - - - - - -
13
14 The libroutino shared library is compiled by default when the Routino
15 source code is compiled. There are two versions; a normal version and a
16 'slim' version that uses less memory but is slower. The names of the
17 libraries are libroutino.so and libroutino-slim.so
18
19 Including
20 - - - - -
21
22 To use the Routino library in another program the source code for that
23 program should include the routino.h file. The functions that are
24 available in the library (both versions) are listed in this file along
25 with all of the constants and data types that are required.
26
27 Linking
28 - - - -
29
30 After compiling the program that uses the library it needs to be linked
31 to the library. For gcc this requires adding -lroutino or
32 -lroutino-slim to the linker command line, possibly with a -L...
33 parameter to specify the location of the library.
34
35 Example Library Interface Code
36 - - - - - - - - - - - - - - -
37
38 An example of a program that can link to the libroutino library is
39 provided in the Routino source code called router+lib.c. This is an
40 almost exact re-implementation of the standard Routino router program
41 using the libroutino library.
42
43
44 Library License
45 ---------------
46
47 The source code for the libroutino and libroutino-slim libraries is the
48 GNU Affero General Public License v3 the same as for the rest of the
49 Routino software.
50
51 Linking with AGPLv3 Source Code
52 - - - - - - - - - - - - - - - -
53
54 If libroutino is linked with other APGLv3 code then the same license
55 applies to the combination as to the two parts.
56
57 Linking with GPLv3 Source Code
58 - - - - - - - - - - - - - - -
59
60 The AGPLv3 license is almost identical to the GNU General Public
61 License v3 except that network interaction with an AGPLv3 program
62 requires the same source code access as distributing compiled GPLv3
63 programs. This means that libroutino can be linked or combined with
64 code that is released under the GPLv3 without changing the license of
65 that code.
66
67 If there is no network interaction with the resulting program then the
68 Routino source code can be treated as if it was GPLv3 code for the
69 purposes of distribution and use.
70
71 If there is network interaction with the resulting program then the
72 AGPLv3 license will apply since this is required by section 13 of the
73 GPLv3.
74 The Software Freedom Law Center description of the GPLv3 and AGPLv3
75 licenses describes combining GPLv3 and APGLv3.
76 My understanding is that only when modified Routino code is linked with
77 GPLv3 code does network interaction require the modified Routino code
78 to be released.
79
80 Linking with Other Source Code
81 - - - - - - - - - - - - - - -
82
83 Linking libroutino with code released under any other license must
84 preserve the terms of the Routino license on the combination if the
85 software is distributed or interacted with over a network.
86
87
88 Routino Library API
89 -------------------
90
91 Preprocessor Definitions
92 - - - - - - - - - - - -
93
94 A version number for the Routino API.
95 #define ROUTINO_API_VERSION 9
96
97 Error Definitions
98
99 No error.
100 #define ROUTINO_ERROR_NONE 0
101
102 A function was called without the database variable set.
103 #define ROUTINO_ERROR_NO_DATABASE 1
104
105 A function was called without the profile variable set.
106 #define ROUTINO_ERROR_NO_PROFILE 2
107
108 A function was called without the translation variable set.
109 #define ROUTINO_ERROR_NO_TRANSLATION 3
110
111 The specified database to load did not exist.
112 #define ROUTINO_ERROR_NO_DATABASE_FILES 11
113
114 The specified database could not be loaded.
115 #define ROUTINO_ERROR_BAD_DATABASE_FILES 12
116
117 The specified profiles XML file did not exist.
118 #define ROUTINO_ERROR_NO_PROFILES_XML 13
119
120 The specified profiles XML file could not be loaded.
121 #define ROUTINO_ERROR_BAD_PROFILES_XML 14
122
123 The specified translations XML file did not exist.
124 #define ROUTINO_ERROR_NO_TRANSLATIONS_XML 15
125
126 The specified translations XML file could not be loaded.
127 #define ROUTINO_ERROR_BAD_TRANSLATIONS_XML 16
128
129 The requested profile name does not exist in the loaded XML file.
130 #define ROUTINO_ERROR_NO_SUCH_PROFILE 21
131
132 The requested translation language does not exist in the loaded XML
133 file.
134 #define ROUTINO_ERROR_NO_SUCH_TRANSLATION 22
135
136 There is no highway near the coordinates to place a waypoint.
137 #define ROUTINO_ERROR_NO_NEARBY_HIGHWAY 31
138
139 The profile and database do not work together.
140 #define ROUTINO_ERROR_PROFILE_DATABASE_ERR 41
141
142 The profile being used has not been validated.
143 #define ROUTINO_ERROR_NOTVALID_PROFILE 42
144
145 The user specified profile contained invalid data.
146 #define ROUTINO_ERROR_BAD_USER_PROFILE 43
147
148 The routing options specified are not consistent with each other.
149 #define ROUTINO_ERROR_BAD_OPTIONS 51
150
151 There is a mismatch between the library and caller API version.
152 #define ROUTINO_ERROR_WRONG_API_VERSION 61
153
154 The progress function returned false.
155 #define ROUTINO_ERROR_PROGRESS_ABORTED 71
156
157 A route could not be found to waypoint 1.
158 #define ROUTINO_ERROR_NO_ROUTE_1 1001
159
160 A route could not be found to waypoint 2.
161 #define ROUTINO_ERROR_NO_ROUTE_2 1002
162
163 A route could not be found to waypoint 3.
164 #define ROUTINO_ERROR_NO_ROUTE_3 1003
165
166 Routino Option Definitions
167
168 Calculate the shortest route.
169 #define ROUTINO_ROUTE_SHORTEST 0
170
171 Calculate the quickest route.
172 #define ROUTINO_ROUTE_QUICKEST 1
173
174 Output an HTML route file.
175 #define ROUTINO_ROUTE_FILE_HTML 2
176
177 Output a GPX track file.
178 #define ROUTINO_ROUTE_FILE_GPX_TRACK 4
179
180 Output a GPX route file.
181 #define ROUTINO_ROUTE_FILE_GPX_ROUTE 8
182
183 Output a text file with important junctions.
184 #define ROUTINO_ROUTE_FILE_TEXT 16
185
186 Output a text file with all nodes and segments.
187 #define ROUTINO_ROUTE_FILE_TEXT_ALL 32
188
189 Output a single file type to stdout.
190 #define ROUTINO_ROUTE_FILE_STDOUT 64
191
192 Output a linked list of points containing the HTML file information but
193 as plain text.
194 #define ROUTINO_ROUTE_LIST_HTML 128
195
196 Output a linked list of points containing the HTML file information as
197 plain text and with all points.
198 #define ROUTINO_ROUTE_LIST_HTML_ALL 256
199
200 Output a linked list of points containing the text file information.
201 #define ROUTINO_ROUTE_LIST_TEXT 512
202
203 Output a linked list of points containing the text all file
204 information.
205 #define ROUTINO_ROUTE_LIST_TEXT_ALL 1024
206
207 Route between the points in a loop returning to the first point.
208 #define ROUTINO_ROUTE_LOOP 2048
209
210 Route between the points in reverse order.
211 #define ROUTINO_ROUTE_REVERSE 4096
212
213 Linked List Output Point Definitions
214
215 An unimportant, intermediate, node.
216 #define ROUTINO_POINT_UNIMPORTANT 0
217
218 A roundabout exit that is not taken.
219 #define ROUTINO_POINT_RB_NOT_EXIT 1
220
221 An un-interesting junction where the route continues without comment.
222 #define ROUTINO_POINT_JUNCT_CONT 2
223
224 The highway changes type but nothing else happens.
225 #define ROUTINO_POINT_CHANGE 3
226
227 An interesting junction to be described.
228 #define ROUTINO_POINT_JUNCT_IMPORT 4
229
230 The entrance to a roundabout.
231 #define ROUTINO_POINT_RB_ENTRY 5
232
233 The exit from a roundabout.
234 #define ROUTINO_POINT_RB_EXIT 6
235
236 The location of a mini-roundabout.
237 #define ROUTINO_POINT_MINI_RB 7
238
239 The location of a U-turn.
240 #define ROUTINO_POINT_UTURN 8
241
242 A waypoint.
243 #define ROUTINO_POINT_WAYPOINT 9
244
245 Profile Definitions
246
247 A Motorway highway.
248 #define ROUTINO_HIGHWAY_MOTORWAY 1
249
250 A Trunk highway.
251 #define ROUTINO_HIGHWAY_TRUNK 2
252
253 A Primary highway.
254 #define ROUTINO_HIGHWAY_PRIMARY 3
255
256 A Secondary highway.
257 #define ROUTINO_HIGHWAY_SECONDARY 4
258
259 A Tertiary highway.
260 #define ROUTINO_HIGHWAY_TERTIARY 5
261
262 A Unclassified highway.
263 #define ROUTINO_HIGHWAY_UNCLASSIFIED 6
264
265 A Residential highway.
266 #define ROUTINO_HIGHWAY_RESIDENTIAL 7
267
268 A Service highway.
269 #define ROUTINO_HIGHWAY_SERVICE 8
270
271 A Track highway.
272 #define ROUTINO_HIGHWAY_TRACK 9
273
274 A Cycleway highway.
275 #define ROUTINO_HIGHWAY_CYCLEWAY 10
276
277 A Path highway.
278 #define ROUTINO_HIGHWAY_PATH 11
279
280 A Steps highway.
281 #define ROUTINO_HIGHWAY_STEPS 12
282
283 A Ferry highway.
284 #define ROUTINO_HIGHWAY_FERRY 13
285
286 A Paved highway.
287 #define ROUTINO_PROPERTY_PAVED 1
288
289 A Multilane highway.
290 #define ROUTINO_PROPERTY_MULTILANE 2
291
292 A Bridge highway.
293 #define ROUTINO_PROPERTY_BRIDGE 3
294
295 A Tunnel highway.
296 #define ROUTINO_PROPERTY_TUNNEL 4
297
298 A Footroute highway.
299 #define ROUTINO_PROPERTY_FOOTROUTE 5
300
301 A Bicycleroute highway.
302 #define ROUTINO_PROPERTY_BICYCLEROUTE 6
303
304 Type Definitions
305 - - - - - - - -
306
307 Typedef Routino_Database
308
309 A data structure to hold a Routino database loaded from a file (the
310 contents are private).
311
312 typedef struct _Routino_Database Routino_Database
313
314 Typedef Routino_Waypoint
315
316 A data structure to hold a Routino waypoint found within the database
317 (the contents are private).
318
319 typedef struct _Routino_Waypoint Routino_Waypoint
320
321 Typedef Routino_Profile
322
323 A data structure to hold a Routino routing profile (the contents are
324 private).
325
326 typedef struct _Routino_Profile Routino_Profile
327
328 Typedef Routino_Translation
329
330 A data structure to hold a Routino translation (the contents are
331 private).
332
333 typedef struct _Routino_Translation Routino_Translation
334
335 Typedef Routino_UserProfile
336
337 A data structure to hold a routing profile that can be defined by the
338 user.
339
340 typedef struct _Routino_UserProfile Routino_UserProfile
341 struct _Routino_UserProfile
342 {
343 int transport; The type of transport.
344 float highway[14]; A floating point preference for travel on the
345 highway (range 0 to 1).
346 float speed[14]; The maximum speed on each type of highway
347 (km/hour).
348 float props[7]; A floating point preference for ways with this
349 attribute (range 0 to 1).
350 int oneway; A flag to indicate if one-way restrictions apply.
351 int turns; A flag to indicate if turn restrictions apply.
352 float weight; The weight of the vehicle (in tonnes).
353 float height; The height of the vehicle (in metres).
354 float width; The width of vehicle (in metres).
355 float length; The length of vehicle (in metres).
356 }
357
358 Typedef Routino_Output
359
360 Forward declaration of the Routino_Output data type.
361
362 typedef struct _Routino_Output Routino_Output
363
364 Type struct _Routino_Output
365
366 A linked list output of the calculated route whose contents depend on
367 the ROUTINO_ROUTE_LIST_* options selected.
368
369 struct _Routino_Output
370 {
371 Routino_Output* next; A pointer to the next route section.
372 float lon; The longitude of the point (radians).
373 float lat; The latitude of the point (radians).
374 float dist; The total distance travelled (kilometres) up to the
375 point.
376 float time; The total journey time (seconds) up to the point.
377 float speed; The speed (km/hr) for this section of the route
378 (ROUTINO_ROUTE_LIST_TEXT_ALL format only).
379 int type; The type of point (one of the ROUTINO_POINT_* values).
380 int turn; The amount to turn (degrees) for the next section of the
381 route (ROUTINO_ROUTE_LIST_TEXT or ROUTINO_ROUTE_LIST_HTML
382 or ROUTINO_ROUTE_LIST_HTML_ALL format).
383
384 int bearing; The compass direction (degrees) for the next section
385 of the route.
386 char* name; The name of the next section of the route
387 (ROUTINO_ROUTE_LIST_TEXT or ROUTINO_ROUTE_LIST_HTML
388 or ROUTINO_ROUTE_LIST_HTML_ALL format) or previous
389 section of the route (ROUTINO_ROUTE_LIST_TEXT_ALL
390 format).
391 char* desc1; The first part of the description of the next
392 section of route (ROUTINO_ROUTE_LIST_HTML or
393 ROUTINO_ROUTE_LIST_HTML format).
394 char* desc2; The second part of the description of the next
395 section of route (ROUTINO_ROUTE_LIST_HTML or
396 ROUTINO_ROUTE_LIST_HTML format).
397 char* desc3; The third part of the description, the total
398 distance and time at the end of the next section of
399 route (ROUTINO_ROUTE_LIST_HTML or
400 ROUTINO_ROUTE_LIST_HTML format).
401 }
402
403 Typedef Routino_ProgressFunc
404
405 A type of function that can be used as a callback to indicate routing
406 progress, if it returns false the router stops.
407
408 typedef int (*Routino_ProgressFunc)(double complete)
409
410 Variable Definitions
411 - - - - - - - - - -
412
413 Global Variable Routino_APIVersion
414
415 Contains the libroutino API version number.
416
417 const int Routino_APIVersion
418
419 Global Variable Routino_Version
420
421 Contains the Routino version number.
422
423 const char* Routino_Version
424
425 Global Variable Routino_errno
426
427 Contains the error number of the most recent Routino function (one of
428 the ROUTINO_ERROR_* values).
429
430 int Routino_errno
431
432 Function Definitions
433 - - - - - - - - - -
434
435 Global Function Routino_CalculateRoute()
436
437 Calculate a route using a loaded database, chosen profile, chosen
438 translation and set of waypoints.
439
440 Routino_Output* Routino_CalculateRoute ( Routino_Database* database,
441 Routino_Profile* profile, Routino_Translation* translation,
442 Routino_Waypoint** waypoints, int nwaypoints, int options,
443 Routino_ProgressFunc progress )
444
445 Routino_Output* Routino_CalculateRoute
446 Returns the head of a linked list of route data (if requested)
447 or NULL.
448
449 Routino_Database* database
450 The loaded database to use.
451
452 Routino_Profile* profile
453 The chosen routing profile to use.
454
455 Routino_Translation* translation
456 The chosen translation information to use.
457
458 Routino_Waypoint** waypoints
459 The set of waypoints.
460
461 int nwaypoints
462 The number of waypoints.
463
464 int options
465 The set of routing options (ROUTINO_ROUTE_*) ORed together.
466
467 Routino_ProgressFunc progress
468 A function to be called occasionally to report progress or NULL.
469
470 Global Function Routino_Check_API_Version()
471
472 Check the version of the library used by the caller against the library
473 version
474
475 int Routino_Check_API_Version ( int caller_version )
476
477 int Routino_Check_API_Version
478 Returns ROUTINO_ERROR_NONE if OK or ROUTINO_ERROR_WRONG_VERSION
479 if there is an error.
480
481 int caller_version
482 The version of the API used in the caller.
483
484 This function should not be called directly, use the macro
485 Routino_CheckAPIVersion() which takes no arguments.
486
487 A wrapper function to simplify the API version check.
488 #define Routino_CheckAPIVersion()
489
490 Global Function Routino_CreateProfileFromUserProfile()
491
492 Create a fully formed Routino Profile from a Routino User Profile.
493
494 Routino_Profile* Routino_CreateProfileFromUserProfile (
495 Routino_UserProfile* profile )
496
497 Routino_Profile* Routino_CreateProfileFromUserProfile
498 Returns an allocated Routino Profile.
499
500 Routino_UserProfile* profile
501 The user specified profile to convert (not modified by this).
502
503 Global Function Routino_CreateUserProfileFromProfile()
504
505 Create a Routino User Profile from a Routino Profile loaded from an XML
506 file.
507
508 Routino_UserProfile* Routino_CreateUserProfileFromProfile (
509 Routino_Profile* profile )
510
511 Routino_UserProfile* Routino_CreateUserProfileFromProfile
512 Returns an allocated Routino User Profile.
513
514 Routino_Profile* profile
515 The Routino Profile to convert (not modified by this).
516
517 Global Function Routino_DeleteRoute()
518
519 Delete the linked list created by Routino_CalculateRoute.
520
521 void Routino_DeleteRoute ( Routino_Output* output )
522
523 Routino_Output* output
524 The output to be deleted.
525
526 Global Function Routino_FindWaypoint()
527
528 Finds the nearest point in the database to the specified latitude and
529 longitude.
530
531 Routino_Waypoint* Routino_FindWaypoint ( Routino_Database* database,
532 Routino_Profile* profile, double latitude, double longitude, int
533 allow_destination )
534
535 Routino_Waypoint* Routino_FindWaypoint
536 Returns a pointer to a newly allocated Routino waypoint or NULL
537 if none could be found.
538
539 Routino_Database* database
540 The Routino database to use.
541
542 Routino_Profile* profile
543 The Routino profile to use.
544
545 double latitude
546 The latitude in degrees of the point.
547
548 double longitude
549 The longitude in degrees of the point.
550
551 int allow_destination
552 The option to allow routing to follow highways tagged as
553 'destination'.
554
555 Global Function Routino_FreeXMLProfiles()
556
557 Free the internal memory that was allocated for the Routino profiles
558 loaded from the XML file.
559
560 void Routino_FreeXMLProfiles ( void )
561
562 Global Function Routino_FreeXMLTranslations()
563
564 Free the internal memory that was allocated for the Routino
565 translations loaded from the XML file.
566
567 void Routino_FreeXMLTranslations ( void )
568
569 Global Function Routino_GetProfile()
570
571 Select a specific routing profile from the set of Routino profiles that
572 have been loaded from the XML file or NULL in case of an error.
573
574 Routino_Profile* Routino_GetProfile ( const char* name )
575
576 Routino_Profile* Routino_GetProfile
577 Returns a pointer to an internal data structure - do not free.
578
579 const char* name
580 The name of the profile to select.
581
582 Global Function Routino_GetProfileNames()
583
584 Return a list of the profile names that have been loaded from the XML
585 file.
586
587 char** Routino_GetProfileNames ( void )
588
589 char** Routino_GetProfileNames
590 Returns a NULL terminated list of strings - all allocated.
591
592 Global Function Routino_GetTranslation()
593
594 Select a specific translation from the set of Routino translations that
595 have been loaded from the XML file or NULL in case of an error.
596
597 Routino_Translation* Routino_GetTranslation ( const char* language )
598
599 Routino_Translation* Routino_GetTranslation
600 Returns a pointer to an internal data structure - do not free.
601
602 const char* language
603 The language to select (as a country code, e.g. 'en', 'de') or
604 an empty string for the first in the file or NULL for the
605 built-in English version.
606
607 Global Function Routino_GetTranslationLanguageFullNames()
608
609 Return a list of the full names of the translation languages that have
610 been loaded from the XML file.
611
612 char** Routino_GetTranslationLanguageFullNames ( void )
613
614 char** Routino_GetTranslationLanguageFullNames
615 Returns a NULL terminated list of strings - all allocated.
616
617 Global Function Routino_GetTranslationLanguages()
618
619 Return a list of the translation languages that have been loaded from
620 the XML file.
621
622 char** Routino_GetTranslationLanguages ( void )
623
624 char** Routino_GetTranslationLanguages
625 Returns a NULL terminated list of strings - all allocated.
626
627 Global Function Routino_LoadDatabase()
628
629 Load a database of files for Routino to use for routing.
630
631 Routino_Database* Routino_LoadDatabase ( const char* dirname, const
632 char* prefix )
633
634 Routino_Database* Routino_LoadDatabase
635 Returns a pointer to the database.
636
637 const char* dirname
638 The pathname of the directory containing the database files.
639
640 const char* prefix
641 The prefix of the database files.
642
643 Global Function Routino_ParseXMLProfiles()
644
645 Parse a Routino XML file containing profiles, must be called before
646 selecting a profile.
647
648 int Routino_ParseXMLProfiles ( const char* filename )
649
650 int Routino_ParseXMLProfiles
651 Returns non-zero in case of an error or zero if there was no
652 error.
653
654 const char* filename
655 The full pathname of the file to read.
656
657 Global Function Routino_ParseXMLTranslations()
658
659 Parse a Routino XML file containing translations, must be called before
660 selecting a translation.
661
662 int Routino_ParseXMLTranslations ( const char* filename )
663
664 int Routino_ParseXMLTranslations
665 Returns non-zero in case of an error or zero if there was no
666 error.
667
668 const char* filename
669 The full pathname of the file to read.
670
671 Global Function Routino_UnloadDatabase()
672
673 Close the database files that were opened by a call to
674 Routino_LoadDatabase().
675
676 void Routino_UnloadDatabase ( Routino_Database* database )
677
678 Routino_Database* database
679 The database to close.
680
681 Global Function Routino_ValidateProfile()
682
683 Validates that a selected routing profile is valid for use with the
684 selected routing database.
685
686 int Routino_ValidateProfile ( Routino_Database* database,
687 Routino_Profile* profile )
688
689 int Routino_ValidateProfile
690 Returns zero if OK or something else in case of an error.
691
692 Routino_Database* database
693 The Routino database to use.
694
695 Routino_Profile* profile
696 The Routino profile to validate.
697
698 --------
699
700 Copyright 2015 Andrew M. Bishop.