Documentation
¶
Index ¶
- Constants
- func Compare(a, b string) int
- func CrawlTimeTables(logger *slog.Logger, bus *Busline) (map[int64]TimeTable, error)
- func DistanceOnEdges(lat1, lon1, lat2, lon2 float64) float64
- func GetTilesInBBoxForZoom(northWestLat, northWestLong, southEastLat, southEastLong float64, zoom int) ([]XYZ, Bounds)
- func Haversine(startLat, startLon, destLat, destLon float64) float64
- func Heading(startLat, startLon, destLat, destLon float64) float64
- func ReverseGeocodeStreet(lat, lon float64) (*string, error)
- func ServeTiles(logger *slog.Logger, pbfFilePath string, repo *Repository) func(w http.ResponseWriter, r *http.Request)
- type Alias
- type Bounds
- type Busline
- type Color
- type DOW
- type Data
- type Direction
- type FeatureRef
- type IDraw
- type JSONStyle
- type LineNumberAndTime
- type Lines
- type Member
- type Node
- type PBFData
- type Repository
- func (r *Repository) CleanupStreetPoints() error
- func (r *Repository) CreateBus(bus *Busline) error
- func (r *Repository) CreateStation(station *Station) error
- func (r *Repository) CreateStop(busId, stationId int64, stationIndex int) error
- func (r *Repository) GetAllFullBusses() ([]Busline, error)
- func (r *Repository) GetAllTimetables() ([]Station, error)
- func (r *Repository) GetBusByID(id int64) (*Busline, error)
- func (r *Repository) GetBusses(notCrawled bool) ([]Busline, error)
- func (r *Repository) GetFullStationsBusByID(id int64) (*Busline, error)
- func (r *Repository) GetStationByID(stationId int64) (*Station, error)
- func (r *Repository) GetStations() ([]Station, error)
- func (r *Repository) GetStationsForBus(busId int64) ([]int64, error)
- func (r *Repository) GetTimeTablesForStationAndBus(stationID, busID int64) ([]uint16, error)
- func (r *Repository) SaveTimeTables(busID int64, stationsTables map[int64]TimeTable) error
- func (r *Repository) UpdateStreetName(stationId int64, name string) error
- type S2Index
- type Station
- type Style
- type Tag
- type Tile
- type Time
- type TimeTable
- type Way
- type XYZ
Constants ¶
View Source
const ( DarkGrey = "#1E232B" MediumGrey = "#2A2E34" LightGrey = "#3B3F46" DarkYellow = "#EC9C04" MediumYellow = "#F5B301" LightYellow = "#FED053" SpecialTag = "special" DefaultTag = "default" MaxLevel = 200 MaxCells = 8000 ItemTypeNode = iota ItemTypeWay ItemTypeRelation )
View Source
const ( OSMNode = "node" OSMStop = "stop" OSMStopEntryOnly = "stop_entry_only" OSMStopExitOnly = "stop_exit_only" OSMPlatform = "platform" OSMPlatformEntryOnly = "platform_entry_only" OSMPlatformExitOnly = "platform_exit_only" OSMWay = "way" OSMRelation = "relation" )
View Source
const ( ForeignKeysSQL = `PRAGMA foreign_keys=on;` CreateBussesSQL = `` /* 274-byte string literal not displayed */ CreateStationsSQL = `` /* 188-byte string literal not displayed */ CreateBusStopsSQL = `` /* 333-byte string literal not displayed */ CreatePointsSQL = `` /* 392-byte string literal not displayed */ CreateDistancesSQL = `` /* 395-byte string literal not displayed */ CleanupPointsSQL = `DELETE FROM points WHERE 1;` CleanupDistancesSQL = `DELETE FROM distances WHERE 1;` InsertPointSQL = `INSERT INTO points (id, lat, lng, idx, is_stop, from_station_id, to_station_id) VALUES (?, ?, ?, ?, ?, ?, ?);` InsertDistanceSQL = `INSERT INTO distances (from_station_id, to_station_id, distance, minutes) VALUES (?, ?, ?, ?);` UpdateDistanceSQL = `UPDATE distances SET minutes = ? WHERE from_station_id = ? AND to_station_id = ?;` BussesListSQL = `SELECT id, dir, name, from_station, to_station, no, color, website, urban, metropolitan, crawled FROM busses;` StationsListSQL = `SELECT id, name, street_name, lat, lng, outside, board FROM stations ORDER BY name ASC, street_name ASC;` NotCrawledBussesListSQL = `` /* 131-byte string literal not displayed */ ShortBusByIDSQL = `` /* 266-byte string literal not displayed */ FullBusByIDSQL = `` /* 318-byte string literal not displayed */ GetTimeTablesForStationAndBusByIDSQL = `SELECT enc_time FROM time_tables WHERE station_id = ? AND bus_id = ?;` InsertTimeTablesSQL = `INSERT INTO time_tables (bus_id, station_id, enc_time) VALUES (?, ?, ?);` UpdateBussesSQL = `UPDATE busses SET crawled = true WHERE id = ?;` InsertBusSQL = `` /* 152-byte string literal not displayed */ InsertBusStopSQL = `INSERT INTO bus_stops (bus_id, station_id, station_index) VALUES (?, ?, ?);` InsertStationSQL = `INSERT INTO stations (id, name, lat, lng, outside, board) VALUES (?, ?, ?, ?, ?, ?);` StationByIDSQL = `SELECT name, lat, lng, outside, board FROM stations WHERE id = ?;` )
View Source
const ( RadiansPerDegree = math.Pi / 180.0 // DegreesPerRadian = 180.0 / math.Pi // EarthRadiusInMeters = 6378137.0 // earth radius in meters NauticalMilesInMeters = 1852 // nautical mile is 1852 meters )
Variables ¶
This section is empty.
Functions ¶
func CrawlTimeTables ¶
func DistanceOnEdges ¶
func GetTilesInBBoxForZoom ¶
func ReverseGeocodeStreet ¶
func ServeTiles ¶
func ServeTiles(logger *slog.Logger, pbfFilePath string, repo *Repository) func(w http.ResponseWriter, r *http.Request)
Types ¶
type Alias ¶
type Busline ¶
type Busline struct { OSMID int64 `json:"i"` SiblingOSMID int64 `json:"si"` Name string `json:"b"` From string `json:"f"` To string `json:"t"` Line string `json:"n"` Color string `json:"c"` Dir int `json:"d"` Link string `json:"w"` IsUrban bool `json:"u,omitempty"` IsMetropolitan bool `json:"m,omitempty"` WasCrawled bool `json:"p"` Stations []Station `json:"s"` }
func NewBusline ¶
func (*Busline) PrintStations ¶
type FeatureRef ¶
type LineNumberAndTime ¶
type Node ¶
type Node struct { Type string `json:"type,omitempty"` // ID int64 `json:"id,omitempty"` // Index int64 `json:"idx,omitempty"` // Lat float64 `json:"lat"` // Lon float64 `json:"lon"` // Tags map[string]string `json:"tags,omitempty"` // Members []Member `json:"members,omitempty"` // relation members Nodes []int64 `json:"nodes,omitempty"` // way nodes IsStop bool `json:"stop,omitempty"` // }
func GetPointByCoords ¶
https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Tile_numbers_to_lon..2Flat.
func NodeFromPbf ¶
func RelationFromPbf ¶
func (*Node) CleanupTags ¶
func (n *Node) CleanupTags()
type PBFData ¶
type PBFData struct { Places map[int64]Node Nodes map[int64]Node Ways map[int64]Way Findex S2Index }
func ReadPBFData ¶
func (*PBFData) GetFeatures ¶
type Repository ¶
func NewRepository ¶
func NewRepository(logger *slog.Logger, filePath string) (*Repository, error)
func (*Repository) CleanupStreetPoints ¶
func (r *Repository) CleanupStreetPoints() error
func (*Repository) CreateBus ¶
func (r *Repository) CreateBus(bus *Busline) error
func (*Repository) CreateStation ¶
func (r *Repository) CreateStation(station *Station) error
func (*Repository) CreateStop ¶
func (r *Repository) CreateStop(busId, stationId int64, stationIndex int) error
func (*Repository) GetAllFullBusses ¶
func (r *Repository) GetAllFullBusses() ([]Busline, error)
func (*Repository) GetAllTimetables ¶
func (r *Repository) GetAllTimetables() ([]Station, error)
func (*Repository) GetBusByID ¶
func (r *Repository) GetBusByID(id int64) (*Busline, error)
func (*Repository) GetFullStationsBusByID ¶
func (r *Repository) GetFullStationsBusByID(id int64) (*Busline, error)
func (*Repository) GetStationByID ¶
func (r *Repository) GetStationByID(stationId int64) (*Station, error)
func (*Repository) GetStations ¶
func (r *Repository) GetStations() ([]Station, error)
func (*Repository) GetStationsForBus ¶
func (r *Repository) GetStationsForBus(busId int64) ([]int64, error)
func (*Repository) GetTimeTablesForStationAndBus ¶
func (r *Repository) GetTimeTablesForStationAndBus(stationID, busID int64) ([]uint16, error)
func (*Repository) SaveTimeTables ¶
func (r *Repository) SaveTimeTables(busID int64, stationsTables map[int64]TimeTable) error
func (*Repository) UpdateStreetName ¶
func (r *Repository) UpdateStreetName(stationId int64, name string) error
type S2Index ¶
type S2Index map[s2.CellID][]FeatureRef
func (S2Index) GetFeatures ¶
func (s S2Index) GetFeatures(northWestPoint, southEastPoint Node) []FeatureRef
type Station ¶
type Station struct { OSMID int64 `json:"i"` Index int `json:"d"` Name string `json:"n"` Street sql.NullString `json:"-"` StreetName string `json:"s,omitempty"` Lat float64 `json:"lt"` Lon float64 `json:"ln"` HasBoard bool `json:"b,omitempty"` IsOutsideCity bool `json:"o,omitempty"` IsTerminal bool `json:"-"` Lines Lines `json:"l,omitempty"` }
func NewStation ¶
type Style ¶
func (*Style) UnmarshalJSON ¶
type Time ¶
type Time struct { Day DOW `json:"d,omitempty"` // div id="web_class_title" Hour int `json:"h,omitempty"` // div id="web_class_hours" Minute int `json:"m,omitempty"` // div id="web_class_minutes" IsOptional bool }
func (*Time) Decompress ¶
type Way ¶
func WayFromPbf ¶
Click to show internal directories.
Click to hide internal directories.