idfm-api/types/README.md

4.1 KiB

navitia/types is a library for working with types returned by the Navitia API. GoDoc

Package types implements support for the types used in the Navitia API (see doc.navitia.io), simplified and modified for idiomatic Go use.

This is navitia/types v0.2. It is not API-Stable, and won't be until the v1 release of navitia, but it's getting closer ! This package was and is developped as a supporting library for the navitia API client but can be used to build other navitia API clients.

Install

Simply run go get -u github.com/govitia/navitia/types.

Coverage

Preview of the supported types, see the doc for more information, and the navitia.io doc for information about the remote API.

Type Name Description Navitia Name
Journey A journey (X-->Y) "journey"
Section A section of a Journey "section"
Region A region covered by the API "region"
Isochrone A region covered by the API "isochrone"
Container This contains a Place or a PTObject "place"/"pt_object"
Place Place is an empty interface, by convention used to identify an Address, StopPoint, StopArea, POI, Admin & Coordinates.
PTObject PTObject is an empty interface by convention used to identify a Public Transportation object
Line A public transit line. "line"
Route A specific route within a Line. "route"

And others, such as Display ["display_informations"], PTDateTime ["pt-date-time"], StopTime ["stop_time"]

Getting started

import (
	"fmt"

	"github.com/govitia/navitia/types"
)

func main() {
	data := []byte{"some journey's json"}
	var j types.Journey
	_ = j.UnmarshalJSON(data)
}

Going further

Obviously, this is a very simple example of what navitia/types can do, check out the documentation !

What's new in v0.2

  • Merge back into the navitia tree !
  • Container is now a type that can be used as a Place Container or as a PTObject Container, which helps everyone!
  • No more String methods
  • Better unmarshalling, including better error handling, along with better testing
  • Benchmarks !
  • Disruption support, along with what it entails.
  • Rename JourneyStatus to Effect
  • And others ! See git log for more information !

TODO

Documentation

  • Update readme.md to reflect new changes
  • Add links to the doc.navitia.io documentation to every type

Testing

  • (*PTDateTime).UnmarshalJSON
  • ErrInvalidPlaceContainer.Error
  • Equipment.Known
  • Every Type should have at least one file to be tested against
  • Globalise mutual code in unmarshal testers

Footnotes

I made this project as I wanted to explore and push my go skills, and I'm really up for you to contribute ! Send me a pull request and/or contact me if you have any questions! ( @aabizri on twitter)