-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStations.class.php
94 lines (83 loc) · 2.53 KB
/
Stations.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
/**
* This is a class which will return all available Haltes from De Lijn
*
* @package packages/Haltes
* @copyright (C) 2012 by iRail vzw/asbl
* @license AGPLv3
* @author Maarten Cautreels <maarten@flatturtle.com>
*/
include_once('DeLijnStationDao.php');
class DeLijnStations extends AReader
{
/**
* Class constructor
* @param $package
* @param $resource
* @param $RESTparameters
*/
public function __construct($package, $resource, $RESTparameters)
{
parent::__construct($package, $resource, $RESTparameters);
// Initialize possible params
$this->longitude = null;
$this->latitude = null;
$this->name = null;
$this->id = null;
$this->code = null;
$this->offset = 0;
$this->rowcount = 1024;
}
public static function getParameters()
{
return [
"longitude" => "Longitude",
"latitude" => "Latitude",
"name" => "Name",
"id" => "Id",
"offset" => "Offeset",
"code" => "Haltenummber",
"rowcount" => "Rowcount"
];
}
public static function getRequiredParameters()
{
return [];
}
public function setParameter($key, $val)
{
if ($key == "longitude") {
$this->longitude = $val;
} elseif ($key == "latitude") {
$this->latitude = $val;
} elseif ($key == "name") {
$this->name = $val;
} elseif ($key == "offset") {
$this->offset = $val;
} elseif ($key == "rowcount") {
$this->rowcount = $val;
} elseif ($key == "id") {
$this->id = $val;
} elseif ($key == "code") {
$this->code = $val;
}
}
public function read()
{
$stationDao = new StationDao();
if ($this->id != null) {
return $stationDao->getStationById($this->id);
} elseif ($this->code != null) {
return $stationDao->getStationByCode($this->code);
} elseif ($this->longitude != null && $this->latitude != null) {
return $stationDao->getClosestStations($this->longitude, $this->latitude);
} elseif ($this->name != null) {
return $stationDao->getStationsByName($this->name, $this->offset, $this->rowcount);
}
return $stationDao->getAllStations($this->offset, $this->rowcount);
}
public static function getDoc()
{
return "This resource contains haltes from De Lijn.";
}
}