osmtransit

package module
v0.0.0-...-ac08b79 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2021 License: Apache-2.0 Imports: 5 Imported by: 1

README

coopgo/osmtransit

made-with-Go GitHub go.mod Go version of a Go module go.dev reference

Package coopgo/osmtransit is a Golang library to extract transit data from OpenStreetMap PBF files.

The main features of this package are :

  • Scan OSM files in the osm.pbf format (example : https://download.geofabrik.de/europe/france-latest.osm.pbf)
  • Extract transit data (stops, routes, ...)
  • Uses GTFS data structures from the coopgo/gtfs library to return transit data (ability to convert OSM transit data to partial GTFS files/CSV files using this library -still under development there-)

Supported transit objects (and TODO list) :

  • Stops
  • Stop Areas

...

Usage

You can get retrieve transit objects through :

  • A channel for concurrent processing using parser.Extract(...)
  • A slice of TransitData objects using parser.TransitData()
  • A structured transit feed using parser.TransitFeed()

Check out examples in the examples folder.

Project Status

This library is still in development.

Contributing

We welcome any contributions following theses guidelines :

  • Write simple, clear and maintainable code and avoid technical debt.
  • Leave the code cleaner than when you started.
  • Refactoring existing code for better performance, better readability or better testing wins over creating a new feature.

If you want to contribute, you can fork the repository and create a pull request.

Bug report

For reporting a bug, you can open an issue using the Bug Report template. Try to write a bug report that is easy to understand and explain how to reproduce the bug. Do not duplicate an existing issue and keep each issue specific to an individual bug.

License

coopgo/osmtransit is under the Apache 2.0 license. Please refer to the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NoStop

func NoStop(p *Parser)

func NoStopArea

func NoStopArea(p *Parser)

Types

type Parser

type Parser struct {
	File *os.File

	Stops     bool
	StopAreas bool
}

Parser is the struct that contains all the options and data to parse OSM PBF files.

func NewParser

func NewParser(file string, opts ...ParserOption) (*Parser, error)

NewParser creates a new custom parser.

Use self referential functions design to configure. See more: https://commandcenter.blogspot.com/2014/01/self-referential-functions-and-design.html

func (*Parser) Extract

func (p *Parser) Extract(transit chan TransitData)

Extract parses OSM data and extracts transit data

func (*Parser) TransitData

func (p *Parser) TransitData() []TransitData

Parse returns transit data in a slice from an OSM pbf file

type ParserOption

type ParserOption func(*Parser)

ParserOption is a function that sets a certain config on a Parser.

This is part of the self referential functions design. See more: https://commandcenter.blogspot.com/2014/01/self-referential-functions-and-design.html

type Stop

func StopFromNode

func StopFromNode(n *osm.Node) Stop

func (Stop) Type

func (s Stop) Type() TransitDataType

type StopArea

type StopArea struct {
	Id   string
	Name string
	Code string
	Lat  float64
	Long float64
}

func StopAreaFromNode

func StopAreaFromNode(n *osm.Node) StopArea

func (StopArea) Type

func (s StopArea) Type() TransitDataType

type TransitData

type TransitData interface {
	Type() TransitDataType
}

type TransitDataType

type TransitDataType int
const (
	StopType TransitDataType = iota
	StopAreaType
)

type TransitFeed

type TransitFeed gtfs.FeedSerializable

Directories

Path Synopsis
examples
stopslist Module

Jump to

Keyboard shortcuts

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