Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
cmd
daemon
.dockerignore
Dockerfile.openflights-dev
Dockerfile.openflightsd
LICENSE
Makefile
README.md
api_server.go
circle.yml
client.go
code_store.go
csv_store.go
filters.go
generated.go
id_store.go
local_api_client.go
openflights.go
openflights.pb.go
openflights.pb.gw.go
openflights.proto
openflights_test.go
server_client.go
util.go

README.md

CircleCI Go Report Card GoDoc MIT License

Please donate to OpenFlights!

If you do use this, I ask you to donate to OpenFlights, the source for all the data in here as of now, at http://openflights.org/donate. Seriously, if you can afford it, the OpenFlights team is responsible for putting all this data together and maintaining it, and we owe it to them to support their work.

Introduction

Note the custom import path!

import (
  "go.pedge.io/openflights"
)

Openflights is a package that exposes the data from http://openflights.org/data.html, available within https://github.com/jpatokal/openflights/tree/master/data.

Flights uses protobuf and gRPC to auto-generate a protobuf/grpc API stubs, and a HTTP/JSON API. See openflights.proto for the API definition. The HTTP endpoints should be relatively straightfoward.

The binary openflightsd is a server binary that hosts the API. make install will install this, which you can then run with ${GOPATH}/bin/openflightsd, or make launch will build a Docker image that is ~13MB as of now, and launch this Docker image with the default ports set. Then, you can curl http://0.0.0.0:8080/api/airports/code/sfo as a quick check.

The openflights package for golang adds some golang-specific additional functionality around the generated protocol buffers code. See openflights.go for publically-exposed structures.

The binaries gen-openflights-csv-store and gen-openflights-id-store will generate the data for you in either a CSVStore or IDStore. Note that this is how generated.go is generated.

The binary openflights is a CLI for the server. If OPENFLIGHTS_ADDRESS is set, this will connect to a running instance of openflightsd:

$ OPENFLIGHTS_ADDRESS=0.0.0.0:1747 openflights miles --min 500 vie-bru-ewr/mem-ord-ams-vie

Otherwise, this will create an effective server inside the CLI, doing all the initial calculations (slower):

$ openflights miles --min 500 vie-bru-ewr

The only command available right now is miles, which will calculate the miles of a route, given by space-separated airport codes. The flag --min will use a minimum miles for a segment, useful for airline mileage calculations.

$ openflights miles --min 500 vie-bru-ewr-mem-ord-ams-vie
VIE-BRU 576mi
BRU-EWR 3681mi
EWR-MEM 946mi
MEM-ORD 500mi (491mi actual)
ORD-AMS 4120mi
AMS-VIE 598mi

10421mi (10412mi actual)

Future Work

Please contact me if you want to help out!