Skip to content

Commit

Permalink
//fix interior way
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre Grimaud committed Apr 11, 2016
1 parent 9149a5d commit 8481e4b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,17 @@ public function validParameters($parameters = [])

private function calculateRoute()
{
$referenceStart = array_search($this->route->getStart()->gate, Gate::listGates());
$referenceEnd = array_search($this->route->getEnd()->gate, Gate::listGates());

$referenceStart = array_search($this->route->getStart()->gate, Gate::listGates($this->route->getWay()));
$referenceEnd = array_search($this->route->getEnd()->gate, Gate::listGates($this->route->getWay()));
$dataCalculated = [
'time' => 0,
'timeReference' => 0,
'kms' => 0
];

if ($referenceStart >= $referenceEnd) {
while ($referenceStart < count(Gate::listGates())) {
while ($referenceStart < count(Gate::listGates($this->route->getWay()))) {
$section = $this->sectionCollection->getItems($this->route->getWay(),
$referenceStart);
$this->route->setSection($section);
Expand All @@ -164,7 +164,7 @@ private function calculateRoute()
}
//and restart
$cursor = 0;
while ($cursor <= $referenceEnd) {
while ($cursor < $referenceEnd) {
$section = $this->sectionCollection->getItems($this->route->getWay(), $cursor);
$this->route->setSection($section);
foreach ($section->getData() as $field => $number) {
Expand Down
17 changes: 14 additions & 3 deletions src/Gate.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ private function setGate($gateName)
/**
* @return array
*/
public static function listGates()
public static function listGates($way = 'exterior')
{
//order exterior way
return [
$gatesExterior = [
'chapelle',
'maillot',
'auteuil',
Expand All @@ -50,6 +49,18 @@ public static function listGates()
'bercy',
'bagnolet',
];

$gatesInterior = [
'chapelle',
'bagnolet',
'bercy',
'italie',
'orleans',
'auteuil',
'maillot',
];

return $way == 'exterior' ? $gatesExterior : $gatesInterior;
}

/**
Expand Down

0 comments on commit 8481e4b

Please sign in to comment.