db

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2024 License: GPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection struct {
	ConnID    string `db:"conn_id"`
	Source    int    `db:"source"`
	TripID    string `db:"trip_id"`
	ServiceID string `db:"service_id"`

	FromStopID       string `db:"from_stop_id"`
	FromStopIDU      string `db:"from_stop_idu"`
	FromStopSequence string `db:"from_stop_sequence"`
	FromST           uint   `db:"from_stop_time"`
	FromSSIDU        string `db:"from_stop_sidu"`

	ToStopID       string `db:"to_stop_id"`
	ToStopIDU      string `db:"to_stop_idu"`
	ToStopSequence string `db:"to_stop_sequence"`
	ToSSIDU        string `db:"to_stop_sidu"`
	ToST           uint   `db:"to_stop_time"`
}

type ConnectionVerbose

type ConnectionVerbose struct {
	Source         int     `db:"source" json:"source,omitempty"`
	ConnID         string  `db:"conn_id" json:"conn_id,omitempty"`
	Duration       string  `db:"duration" json:"duration,omitempty"`
	FromStopID     string  `db:"from_stop_id" json:"from_stop_id,omitempty"`
	DirectionID    *int    `db:"direction_id" json:"direction_id,omitempty"`
	FromStopIDU    string  `db:"from_stop_idu" json:"from_stop_idu,omitempty"`
	FromStopSIDU   string  `db:"from_stop_sidu" json:"from_stop_sidu,omitempty"`
	FromStopLat    float64 `db:"from_stop_lat" json:"from_stop_lat,omitempty"`
	FromStopLon    float64 `db:"from_stop_lon" json:"from_stop_lon,omitempty"`
	FromStopName   string  `db:"from_stop_name" json:"from_stop_name,omitempty"`
	FromStopTime   uint    `db:"from_stop_time" json:"from_stop_time,omitempty"`
	RouteID        string  `db:"route_id" json:"route_id,omitempty"`
	RouteShortName *string `db:"route_short_name" json:"route_short_name,omitempty"`
	RouteLongName  *string `db:"route_long_name" json:"route_long_name,omitempty"`
	TripID         string  `db:"trip_id" json:"tid,omitempty"`
	ToStopID       string  `db:"to_stop_id" json:"to_stop_id,omitempty"`
	ToStopIDU      string  `db:"to_stop_idu" json:"to_stop_idu,omitempty"`
	ToStopSIDU     string  `db:"to_stop_sidu" json:"to_stop_sidu,omitempty"`
	ToStopLat      float64 `db:"to_stop_lat" json:"to_stop_lat,omitempty"`
	ToStopLon      float64 `db:"to_stop_lon" json:"to_stop_lon,omitempty"`
	ToStopName     string  `db:"to_stop_name" json:"to_stop_name,omitempty"`
	ToStopTime     uint    `db:"to_stop_time" json:"to_stop_time,omitempty"`
	TripHeadsign   *string `db:"trip_headsign" json:"trip_headsign,omitempty"`
}

type DBConnection

type DBConnection struct {
	DB           *sqlx.DB
	QueryTime    *time.Time
	QuerySources []int
}

func Initialize

func Initialize(
	mobsqlFilter *mobsql.SourcesetFilter,
	mobsqlRuntimeConfig *mobsql.RuntimeConfig,
	fromTime *time.Time,
) (*DBConnection, error)

func (*DBConnection) LoadConnections

func (c *DBConnection) LoadConnections(
	dateYYYYMMDD uint,
	fromSeconds,
	toSeconds uint,
) (*[]Connection, error)

LoadConnections loads the valid connections from the given input timespan

func (*DBConnection) LoadConnectionsVerbose

func (c *DBConnection) LoadConnectionsVerbose(connIDs []string) (*[]ConnectionVerbose, error)

LoadConnectionsVerbose loads the connections for the given connection IDs

func (*DBConnection) LoadStopWalks

func (c *DBConnection) LoadStopWalks(originPoint utilfuncs.Coord, maxWalkKM float64) (*[]StopWalk, error)

LoadStopWalks loads stopwalks given the input origin coordinate and a max distance in km to walk

func (*DBConnection) LoadTransfers

func (c *DBConnection) LoadTransfers(
	minTransferSeconds uint,
	maxTransferSeconds uint,
	walkspeedKmHr float64,
	transfersTbl,
	transfersGen bool,
) (*[]Transfer, error)

LoadTransfers load the transfers from the underlying _vtransferstbl (and eventually _vtransfersgen) views.

Note - IntArraysSortedFilter logic makes sures pairs are not duplicate e.g. [[1 3] [3 1] [5 1]] is reduced to [[1 3] [5 1]]

func (*DBConnection) QueryBoundsMatch

func (c *DBConnection) QueryBoundsMatch(coord utilfuncs.Coord) error

QueryBoundsMatch is a querying function that determines if the passed param matches for the mdbid for the DB conneciton min/max lat/lon

func (*DBConnection) QueryValue

func (c *DBConnection) QueryValue(query string, args []any) (string, error)

type StopWalk

type StopWalk struct {
	StopSIDU string   `db:"stop_sidu"`
	StopName string   `db:"stop_name"`
	DistKM   *float64 `db:"dist_km"`
}

type Transfer

type Transfer struct {
	FromSSIDU   string `db:"from_stop_sidu"`
	FromStopIDU string `db:"from_stop_idu"`
	FromStopID  string `db:"from_stop_id"`
	Source      int    `db:"source"`

	ToSSIDU    string `db:"to_stop_sidu"`
	ToStopIDU  string `db:"to_stop_idu"`
	ToStopID   string `db:"to_stop_id"`
	SourcePair int    `db:"source_pair"`

	TransferType     uint     `db:"transfer_type"`
	TransferCategory string   `db:"transfer_category"`
	MinTransferTime  *uint    `db:"min_transfer_time"`
	DistKM           *float64 `db:"dist_km"`

	TransferTime uint `db:"transfer_time"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL