Documentation ¶
Overview ¶
Package mobsql is an interface for downloading and loading one or multiple GTFS archives (pulled from the Mobility Database catalog) into a SQLite database.
The database (seeded through mobsql) mirrors GTFS's specification (e.g. there is a transfers, stop_times, stops, agency tables etc.); however each GTFS table also has an additional 'feed_id' column. The feed_id column refers to Mobility Database mdb_id field. Besides that, GTFS schema is imported as 1-to-1 for GTFS schedule specification sans several exceptions (such as stop_times conversion of departure_time to int). Exceptions can be seen by examining the config package's Schema variable (and noting Conversion fields set on LoadColumn specs).
The only package endconsumers of this API should import and use directly is the top level git.sr.ht/~mil/mobsql; everything is aliased from there. Subpackages are internal implementations & may change between versions. See aliased package implementations for documentation on each function and type.
There are 6 primary functions exposed by mobsql's API:
InitializeRuntime: Initializes a Mobsql 'runtime' which represents a a connection to the SQLite DB & configuration params which all other API operations depend on.
FeedsearchFilterToFeedIDs: Converts a 'filter specification' to a set of feed IDs which all Feed* operations operate based on. Filter specification is a broad way of searching the Mobility Database for arbitrary GTFS feeds to operate on.
Feed{Load,Compute,Purge,Status}: The main logic of the application. Allows load (downloading & importing GTFS to the DB), status (checking the GTFS feeds that have been loaded), compute (converting SQL views into materialized tables based on the origin GTFS tables), and purge (removing GTFS data from the SQLite database).
The general usage pattern for using Mobsql as an API is:
Create a runtime via InitializeRuntime()
Determine which GTFS feed IDs you will use either by using FeedsearchFilterToFeedIDs() OR by manually referencing the Mobility Database (https://database.mobilitydata.org/) for the feed id (MDBID) needed
Run Feed{Load,Compute,Status,Purge} by passing the runtime and the feedID(s)
The CLI (cli package) implements all the above functionality (1-3) and should be understood as a good reference implementation for using Mobsql as a Go library in practice.
Index ¶
- Constants
- func FeedsearchFilterToFeedIDs(runtime *MobsqlRuntime, filter *FeedsearchFilter) ([]int, error)
- type ComputedTable
- type FeedOpResult
- type FeedStatusInfo
- type FeedsearchFilter
- type LoadColumn
- type MobsqlRuntime
- type PurgeTablesOption
- type RuntimeConfig
- type SchemaExtra
- type TableSpec
- type View
Constants ¶
const DTypeInt uint = apptypes.DTypeInt
const DTypeReal uint = apptypes.DTypeReal
const DTypeText uint = apptypes.DTypeText
Variables ¶
This section is empty.
Functions ¶
func FeedsearchFilterToFeedIDs ¶ added in v0.6.0
func FeedsearchFilterToFeedIDs(runtime *MobsqlRuntime, filter *FeedsearchFilter) ([]int, error)
Types ¶
type ComputedTable ¶ added in v0.4.0
type ComputedTable = apptypes.ComputedTable
type FeedOpResult ¶ added in v0.6.0
type FeedOpResult = apptypes.FeedOpResult
func FeedCompute ¶ added in v0.6.0
func FeedCompute(runtime *MobsqlRuntime, feedIDs []int) (*FeedOpResult, error)
func FeedLoad ¶ added in v0.6.0
func FeedLoad(runtime *MobsqlRuntime, feedIDs []int) (*FeedOpResult, error)
func FeedPurge ¶ added in v0.6.0
func FeedPurge(runtime *MobsqlRuntime, feedIDs []int, options PurgeTablesOption) (*FeedOpResult, error)
type FeedStatusInfo ¶ added in v0.6.0
type FeedStatusInfo = apistatus.FeedStatusInfo
func FeedStatus ¶ added in v0.6.0
func FeedStatus(runtime *MobsqlRuntime, feedIDs []int) ([]FeedStatusInfo, error)
type FeedsearchFilter ¶ added in v0.6.0
type FeedsearchFilter = apifeedsearch.FeedsearchFilter
type LoadColumn ¶ added in v0.4.0
type LoadColumn = apptypes.LoadColumn
type MobsqlRuntime ¶ added in v0.4.0
type MobsqlRuntime = apptypes.MobsqlRuntime
func InitializeRuntime ¶ added in v0.4.0
func InitializeRuntime(config *RuntimeConfig) (*MobsqlRuntime, error)
type PurgeTablesOption ¶ added in v0.5.0
type PurgeTablesOption = apipurge.PurgeTablesOption
const PurgeTablesOptionAll PurgeTablesOption = apipurge.PurgeTablesOptionAll
const PurgeTablesOptionComputed PurgeTablesOption = apipurge.PurgeTablesOptionComputed
const PurgeTablesOptionGTFS PurgeTablesOption = apipurge.PurgeTablesOptionGTFS
type RuntimeConfig ¶ added in v0.4.0
type RuntimeConfig = apptypes.RuntimeConfig
type SchemaExtra ¶ added in v0.4.0
type SchemaExtra = apptypes.SchemaExtra
Directories ¶
Path | Synopsis |
---|---|
api
|
|
Package main is the CLI interface for mobsql consuming the mobsql API.
|
Package main is the CLI interface for mobsql consuming the mobsql API. |
Package config contains the data structures used to represent the database schema for seeding and loading
|
Package config contains the data structures used to represent the database schema for seeding and loading |
util
|
|
utildownload
Package utildownload contains some internal download functions utilized by the primary mobsql app logic.
|
Package utildownload contains some internal download functions utilized by the primary mobsql app logic. |
utilfiles
Package utildownload contains internal helper functions related to file IO utilized by the primary mobsql app logic.
|
Package utildownload contains internal helper functions related to file IO utilized by the primary mobsql app logic. |
utilfuncs
Package utildownload contains internal helper functions utilized by the primary mobsql app logic.
|
Package utildownload contains internal helper functions utilized by the primary mobsql app logic. |
utillog
Package utillog is a simple logging interface with three different types of log messages that can be enabled via the 3 variables LogInfo, LogWarn, and LogDebug.
|
Package utillog is a simple logging interface with three different types of log messages that can be enabled via the 3 variables LogInfo, LogWarn, and LogDebug. |