Giter Site home page Giter Site logo

airport-route-api's Introduction

Aiport route API

Description

Sample HTTP API for flight route search based on neo4j.

Route graph

Development

With docker:

	$ docker-compose up

Run it with local node.js:

	$ docker run --publish=7474:7474 --publish=7687:7687 --env NEO4J_AUTH=none -v $PWD/import:/var/lib/neo4j/import -v $PWD/data:/data -v $PWD/logs:/logs neo4j

	$ export NEO4J_HOST=localhost && npm run start

Neo4j browser is here: http://localhost:7474/browser/

Call the HTTP API:

	$ curl "http://localhost:3000/routes?from=TLL&to=TAY"		

Possible routes are sorted by total distance. By default it returns only the route with shortes total distance. The additional parameter "&limit=n" allows to specify the number of results.

Sample response:

{
  "routes": [
    {
      "segments": [
        {
          "type": "FLIGHT",
          "origin": "TLL",
          "destination": "HEL",
          "distance": 100885.66230018
        },
        {
          "type": "FLIGHT",
          "origin": "HEL",
          "destination": "TAY",
          "distance": 244270.39073097
        }
      ],
      "totalDistance": 345156.05303115
    },
    {
      "segments": [
        {
          "type": "FLIGHT",
          "origin": "TLL",
          "destination": "HEL",
          "distance": 100885.66230018
        },
        {
          "type": "FLIGHT",
          "origin": "HEL",
          "destination": "TAY",
          "distance": 244270.39073097
        }
      ],
      "totalDistance": 345156.05303115
    },
    {
      "segments": [
        {
          "type": "ALTERNATIVE",
          "origin": "TLL",
          "destination": "HEN",
          "distance": 81922.767905472
        },
        {
          "type": "ALTERNATIVE",
          "origin": "HEN",
          "destination": "HEL",
          "distance": 18981.858630461
        },
        {
          "type": "FLIGHT",
          "origin": "HEL",
          "destination": "TAY",
          "distance": 244270.39073097
        }
      ],
      "totalDistance": 345175.0172669
    },
    {
      "segments": [
        {
          "type": "ALTERNATIVE",
          "origin": "TLL",
          "destination": "HEN",
          "distance": 81922.767905472
        },
        {
          "type": "ALTERNATIVE",
          "origin": "HEN",
          "destination": "HEL",
          "distance": 18981.858630461
        },
        {
          "type": "FLIGHT",
          "origin": "HEL",
          "destination": "TAY",
          "distance": 244270.39073097
        }
      ],
      "totalDistance": 345175.0172669
    },
    {
      "segments": [
        {
          "type": "ALTERNATIVE",
          "origin": "TLL",
          "destination": "HEM",
          "distance": 94386.935666986
        },
        {
          "type": "ALTERNATIVE",
          "origin": "HEM",
          "destination": "HEL",
          "distance": 8234.2516641968
        },
        {
          "type": "FLIGHT",
          "origin": "HEL",
          "destination": "TAY",
          "distance": 244270.39073097
        }
      ],
      "totalDistance": 346891.57806215
    },
    {
      "segments": [
        {
          "type": "ALTERNATIVE",
          "origin": "TLL",
          "destination": "HEM",
          "distance": 94386.935666986
        },
        {
          "type": "ALTERNATIVE",
          "origin": "HEM",
          "destination": "HEL",
          "distance": 8234.2516641968
        },
        {
          "type": "FLIGHT",
          "origin": "HEL",
          "destination": "TAY",
          "distance": 244270.39073097
        }
      ],
      "totalDistance": 346891.57806215
    }
  ]
}

Data

Data downloaded from openflight.org

Airports

Fetch airport data:

	$ curl https://raw.githubusercontent.com/jpatokal/openflights/master/data/airports.dat --output import/airports.dat

Some insights about the data:

	$ wc -l import/airports.dat 

	7184 data/airports.dat

	$ head -n 2 import/airports.dat

	1,"Goroka Airport","Goroka","Papua New Guinea","GKA","AYGA",-6.081689834590001,145.391998291,5282,10,"U","Pacific/Port_Moresby","airport","OurAirports"
	2,"Madang Airport","Madang","Papua New Guinea","MAG","AYMD",-5.20707988739,145.789001465,20,10,"U","Pacific/Port_Moresby","airport","OurAirports"

Each entry contains the following information:

Airport ID, Name, City, Country, IATA, ICAO, Latitude, Longitude, Altitude, Timezone, DST Daylight savings time, Tz database time zone, Type, Source

Routes

Fetch routes data:

	$ curl https://raw.githubusercontent.com/jpatokal/openflights/master/data/routes.dat --output import/routes.dat

	$ wc -l data/routes.dat 
	67663 import/routes.dat

	$ head data/routes.dat 
	2B,410,AER,2965,KZN,2990,,0,CR2

Distances

Calculate distances:

	$ npm run paths

Additional links

Neo4j match clause

Neo4j spatial functions

openflight.org

airport-route-api's People

Contributors

haavala avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.