Skip to content

Commit

Permalink
readme
Browse files Browse the repository at this point in the history
  • Loading branch information
pietercolpaert committed Aug 28, 2011
1 parent 3a37de5 commit 9f7d305
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 144 deletions.
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@ For The DataTank (TDT) see next chapter. We created a module upon our own generi

What this module can do:
* It handles data from:
* NMBS
* NS
* De Lijn
* MIVB
* All kinds of GTFS
* ... more to come

- NMBS
- NS
- De Lijn
- MIVB
- All kinds of GTFS
- ... more to come

* It creates a RESTful API for
* Liveboard: live departure and arrival times
* Connections: a route from A to B
* Vehicle: realtime information about a certain vehicle
* Stations: station information

- Liveboard: live departure and arrival times
- Connections: a route from A to B
- Vehicle: realtime information about a certain vehicle
- Stations: station information

# The DataTank

Expand Down
3 changes: 1 addition & 2 deletions modules/DL/methods.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@

class DL{
public static $methods = array (
"Stations",
"Liveboard"

);
}
?>
5 changes: 2 additions & 3 deletions modules/MIVB/methods.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
*/
class MIVB{
public static $methods = array (
"Stations",
"Liveboard"
);

}


//alias
class STIB{
class STIB extends MIVB{

}

Expand Down
31 changes: 13 additions & 18 deletions modules/NMBS/Liveboard.class.php
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
<?php
/* Copyright (C) 2011 by iRail vzw/asbl
/**
* Copyright (C) 2011 by iRail vzw/asbl
*
* Author: Jan Vansteenlandt <jan aŧ iRail.be>
* Author: Pieter Colpaert <pieter aŧ iRail.be>
* License: AGPLv3
* @author Jan Vansteenlandt <jan aŧ iRail.be>
* @author Pieter Colpaert <pieter aŧ iRail.be>
* @license AGPLv3
*
* This file is currently being used for testpurposes. It returns some testdata we use for our analysis tool. (stats.php)
*/
include_once("modules/NMBS/Stations.class.php");
include_once("modules/iRailTools.class.php");

include_once("modules/AMethod.php");
include_once("modules/iRail/Stations.class.php");
include_once("modules/iRail/iRailTools.class.php");

class Liveboard extends AMethod{
class Liveboard extends AResource{

private $lang;
private $system;
private $time;
private $direction;
private $date;
private $station;

private $station;

public function __construct(){
parent::__construct("Liveboard");
$this->time = date("H:i");
$this->direction = "departures";
}
Expand Down Expand Up @@ -77,11 +73,12 @@ public function call(){
}

$request = TDT::HttpRequest($url);
//var_dump($request);
error_log('The Data: ' . $request->data);
if(isset($request->error)){
throw new HttpOutTDTException($url);
}

$object = simplexml_load_string($request->data);


return $object;


Expand All @@ -101,7 +98,6 @@ public function call(){
}

/**
* Small algorithm I wrote:
* It will remove the duplicates from an array the php way. Since a PHP array will need to recopy everything to be reindexed, I figured this would go faster if we did the deleting when copying.
*/
private static function removeDuplicates($nodes){
Expand Down Expand Up @@ -131,5 +127,4 @@ public static function getDoc(){
}
}


?>
95 changes: 44 additions & 51 deletions modules/NMBS/Stations.class.php
Original file line number Diff line number Diff line change
@@ -1,59 +1,52 @@
<?php
/* Copyright (C) 2011 by iRail vzw/asbl
*
* Author: Pieter Colpaert <pieter aŧ iRail.be>
* License: AGPLv3
/**
* @copyright (C) 2011 by iRail vzw/asbl
* @author Pieter Colpaert <pieter aŧ iRail.be>
* @license AGPLv3
*
* Lists all stations for a certain system
*/

include_once("modules/AMethod.php");

class Stations extends AMethod{

private $lang,$system = "NMBS";

public function __construct(){
parent::__construct("Stations");
}

public static function getParameters(){
return array("lang" => "Language for the stations",
"system" => "The name of the public transport company: for instance De Lijn, or NMBS"
);
}

public static function getRequiredParameters(){
return array();
}

public function setParameter($key,$val){
if($key == "lang"){
$this->lang = $val;
}

if($key == "system"){
if(in_array($val,iRailTools::ALLOWED_SYSTEMS)){
$this->system = $val;
}
}
}

public function call(){
$o = new StdClass();

$o->stations[]
return $o;
}

public static function getAllowedPrintMethods(){
return array("xml","json","php", "jsonp","html");
}


public static function getDoc(){
return "Stations will return a list of all known stops of a system";
}
class Stations extends AResource{

private $lang = "EN";

/**
* If language has not been given, just return the english ones
*/
public static function getParameters(){
return array("lang" => "Language for the stations");
}

/**
* No required parameters for the stations resource
*/
public static function getRequiredParameters(){
return array();
}

public function setParameter($key,$val){
if($key == "lang"){
$this->lang = $val;
}
}

/**
* This function should get all stations from the NMBS/SNCB and return them.
* Can't we get all information from DBPedia?
* Does Open Street Map has a SPARQL end-point?
*/
public function call(){
return new StdClass();
}

public static function getAllowedPrintMethods(){
return array("xml","json","php", "jsonp","html", "kml");
}

public static function getDoc(){
return "Stations will return a list of all known stops of a system";
}
}

?>
20 changes: 0 additions & 20 deletions modules/NMBS/methods.php

This file was deleted.

8 changes: 5 additions & 3 deletions modules/NMBS/tools.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?php
/** Copyright (C) 2011 by iRail vzw/asbl
/**
*
* This is a class with static tools for you to use on the NMBS scraper. It contains stuff that is needed by all other classes
*
* @package data/NMBS
* @copyright (C) 2011 by iRail vzw/asbl
* @package modules/NMBS
*/

class tools{
Expand Down Expand Up @@ -61,6 +63,6 @@ public static function addQuarter($time){
}
return $hours. ":" . $minutes;
}
}
}

?>
2 changes: 0 additions & 2 deletions modules/NS/methods.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
*/
class NS{
public static $methods = array (
"Stations",
"Liveboard"
);
}

Expand Down
35 changes: 0 additions & 35 deletions modules/stations.xsd

This file was deleted.

0 comments on commit 9f7d305

Please sign in to comment.