grass  7.8.6
About: GRASS (Geographic Resources Analysis Support System) is a raster- and vector-based GIS, image processing system, graphics production system and spatial modeling system.
  Fossies Dox: grass-7.8.6.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

timetables.c File Reference

Network Analysis library - timetables. More...

#include <stdio.h>
#include <stdlib.h>
#include <grass/gis.h>
#include <grass/vector.h>
#include <grass/dbmi.h>
#include <grass/glocale.h>
#include <grass/dgl/graph.h>
#include <grass/neta.h>
Include dependency graph for timetables.c:

Go to the source code of this file.


struct  neta_heap_data


int NetA_init_distinct (dbDriver *driver, dbString *sql, int **lengths, int **ids)
 Get number of distinct elements. More...
static int cmp_int (const void *a, const void *b)
int NetA_init_timetable_from_db (struct Map_info *In, int route_layer, int walk_layer, char *route_id, char *times, char *to_stop, char *walk_length, neta_timetable *timetable, int **route_ids, int **stop_ids)
 Initialises timetable from a database. More...
static neta_heap_datanew_heap_data (int conns, int v)
void NetA_update_dijkstra (int old_conns, int new_conns, int to, int new_dst, int v, int route, int rows, int update, neta_timetable_result *result, dglHeap_s *heap)
 Update Dijkstra structures. More...
int NetA_timetable_shortest_path (neta_timetable *timetable, int from_stop, int to_stop, int start_time, int min_change, int max_changes, int walking_change, neta_timetable_result *result)
 Computes the earliest arrival time. More...
int NetA_timetable_get_route_time (neta_timetable *timetable, int stop, int route)
 Get time. More...
void NetA_timetable_result_release (neta_timetable_result *result)
 Free neta_timetable_result structure. More...

Detailed Description

Network Analysis library - timetables.

Shortest path using timetables.

(C) 2009-2010 by Daniel Bundala, and the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Daniel Bundala (Google Summer of Code 2009)

Definition in file timetables.c.

Function Documentation

◆ cmp_int()

static int cmp_int ( const void *  a,
const void *  b 

Definition at line 91 of file timetables.c.

References a, and b.

Referenced by NetA_init_timetable_from_db().

◆ NetA_init_distinct()

int NetA_init_distinct ( dbDriver driver,
dbString sql,
int **  lengths,
int **  ids 

Get number of distinct elements.

driverDB driver
sqlSQl string
[out]listof lengths
[out]listof ids
number of distinct elements
-1 on failure

Definition at line 36 of file timetables.c.

References _, count, cur, db_close_cursor(), db_fetch(), db_get_column_value(), db_get_cursor_table(), db_get_string(), db_get_table_column(), db_get_value_int(), DB_NEXT, DB_OK, db_open_select_cursor(), DB_SEQUENTIAL, G_warning(), more(), and table.

Referenced by NetA_init_timetable_from_db().

◆ NetA_init_timetable_from_db()

int NetA_init_timetable_from_db ( struct Map_info In,
int  route_layer,
int  walk_layer,
char *  route_id,
char *  times,
char *  to_stop,
char *  walk_length,
neta_timetable *  timetable,
int **  route_ids,
int **  stop_ids 

Initialises timetable from a database.

Inpointer to Map_info structure
route_layerlayer number of routes
walk_layerlayer number of walkers
route_idid of route
timeslist of timestamps
walk_lengthwalk length as string
timetablepointer to neta_timetable
route_idslist of route ids
stop_idslits of stop ids
0 on success
non-zero value on failure

Definition at line 113 of file timetables.c.

References _, cmp_int(), field_info::database, db_close_cursor(), db_close_database_shutdown_driver(), db_fetch(), db_get_column_value(), db_get_cursor_table(), db_get_string(), db_get_table_column(), db_get_value_int(), db_init_string(), DB_NEXT, DB_OK, db_open_select_cursor(), DB_SEQUENTIAL, db_set_string(), db_start_driver_open_database(), field_info::driver, driver, G_fatal_error(), G_warning(), field_info::key, more(), NetA_init_distinct(), NULL, field_info::table, table, and Vect_get_field().

◆ NetA_timetable_get_route_time()

int NetA_timetable_get_route_time ( neta_timetable *  timetable,
int  stop,
int  route 

Get time.

Get time when route "route" arrives at stop "stop" or -1.

timetablepointer to neta_timetable structure
stop'stop' node id
routeroute id
-1 if not found

Definition at line 534 of file timetables.c.

◆ NetA_timetable_result_release()

void NetA_timetable_result_release ( neta_timetable_result *  result)

Free neta_timetable_result structure.

resultpointer to neta_timetable_result structure

Definition at line 550 of file timetables.c.

References G_free().

◆ NetA_timetable_shortest_path()

int NetA_timetable_shortest_path ( neta_timetable *  timetable,
int  from_stop,
int  to_stop,
int  start_time,
int  min_change,
int  max_changes,
int  walking_change,
neta_timetable_result *  result 

Computes the earliest arrival time.

Computes the earliest arrival time to to_stop from from_stop starting at start_time, or -1 if no path exists

timetablepointer to neta_timetable structure
from_stop'from' node
to_stop'to' stop
start_timestart timestamp
[out]resultpointer to neta_timetable_result
-1 on error

Definition at line 392 of file timetables.c.

References _, dglHeapExtractMin(), dglHeapFree(), dglHeapInit(), dglHeapInsertMin(), G_warning(), _dglHeapNode::key, NetA_update_dijkstra(), new_heap_data(), NULL, _dglHeapData::pv, and _dglHeapNode::value.

◆ NetA_update_dijkstra()

void NetA_update_dijkstra ( int  old_conns,
int  new_conns,
int  to,
int  new_dst,
int  v,
int  route,
int  rows,
int  update,
neta_timetable_result *  result,
dglHeap_s heap 

Update Dijkstra structures.

olc_connsold connection
new_connsnew connection
toold 'to' node
new_dstnew 'to' node
routeid of route
[out]resultpointer to neta_timetable_result structure

Definition at line 355 of file timetables.c.

References dglHeapInsertMin(), new_heap_data(), and _dglHeapData::pv.

Referenced by NetA_timetable_shortest_path().

◆ new_heap_data()

static neta_heap_data * new_heap_data ( int  conns,
int  v 

Definition at line 332 of file timetables.c.

References d.

Referenced by NetA_timetable_shortest_path(), and NetA_update_dijkstra().