This repository has been archived by the owner on Sep 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 746
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6111c07
commit fae267e
Showing
5 changed files
with
391 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
/** | ||
* Connector to find routing. Connector based on service YOURS. | ||
* | ||
* @package App | ||
* | ||
* @copyright YetiForce Sp. z o.o | ||
* @license YetiForce Public License 3.0 (licenses/LicenseEN.txt or yetiforce.com) | ||
* @author Mariusz Krzaczkowski <[email protected]> | ||
* | ||
* @see https://wiki.openstreetmap.org/wiki/YOURS | ||
*/ | ||
|
||
namespace App\Map\Routing; | ||
|
||
/** | ||
* Connector for service YOURS to get routing. | ||
*/ | ||
class Yours extends Base | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function calculate() | ||
{ | ||
if (!\App\RequestUtil::isNetConnection()) { | ||
throw new \App\Exceptions\AppException('ERR_NO_INTERNET_CONNECTION'); | ||
} | ||
$coordinates = []; | ||
$travel = $distance = 0; | ||
$description = ''; | ||
foreach ($this->parsePoints() as $track) { | ||
$url = $this->url . '?format=geojson&flat=' . $track['startLat'] . '&flon=' . $track['startLon'] . '&tlat=' . $track['endLat'] . '&tlon=' . $track['endLon'] . '&lang=' . \App\Language::getLanguage() . '&instructions=1'; | ||
\App\Log::beginProfile("GET|Yours::calculate|{$url}", __NAMESPACE__); | ||
$response = (new \GuzzleHttp\Client(\App\RequestHttp::getOptions()))->request('GET', $url, [ | ||
'timeout' => 60, | ||
'http_errors' => false, | ||
]); | ||
\App\Log::endProfile("GET|Yours::calculate|{$url}", __NAMESPACE__); | ||
if (200 === $response->getStatusCode()) { | ||
$json = \App\Json::decode($response->getBody()); | ||
} else { | ||
throw new \App\Exceptions\AppException('Error with connection |' . $response->getReasonPhrase() . '|' . $response->getBody()); | ||
} | ||
$coordinates = array_merge($coordinates, $json['coordinates']); | ||
$description .= $json['properties']['description']; | ||
$travel += $json['properties']['traveltime']; | ||
$distance += $json['properties']['distance']; | ||
} | ||
$this->geoJson = [ | ||
'type' => 'LineString', | ||
'coordinates' => $coordinates, | ||
]; | ||
$this->travelTime = $travel; | ||
$this->distance = $distance; | ||
$this->description = $description; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function parsePoints(): array | ||
{ | ||
$tracks = []; | ||
$startLat = $this->start['lat']; | ||
$startLon = $this->start['lon']; | ||
if (!empty($this->indirectPoints)) { | ||
foreach ($this->indirectPoints as $tempLon) { | ||
$endLon = $tempLon['lon']; | ||
$endLat = $tempLon['lat']; | ||
$tracks[] = [ | ||
'startLat' => $startLat, | ||
'startLon' => $startLon, | ||
'endLat' => $endLat, | ||
'endLon' => $endLon, | ||
]; | ||
$startLat = $endLat; | ||
$startLon = $endLon; | ||
} | ||
} | ||
$tracks[] = [ | ||
'startLat' => $startLat, | ||
'startLon' => $startLon, | ||
'endLat' => $this->end['lat'], | ||
'endLon' => $this->end['lon'] | ||
]; | ||
return $tracks; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
/** | ||
* YetiForce shop PremiumSupport file. | ||
* | ||
* @package App | ||
* | ||
* @copyright YetiForce Sp. z o.o | ||
* @license YetiForce Public License 3.0 (licenses/LicenseEN.txt or yetiforce.com) | ||
* @author Mariusz Krzaczkowski <[email protected]> | ||
*/ | ||
|
||
namespace App\YetiForce\Shop\Product; | ||
|
||
/** | ||
* YetiForce shop PremiumSupport class. | ||
*/ | ||
class YetiForceHelp extends \App\YetiForce\Shop\AbstractBaseProduct | ||
{ | ||
/** {@inheritdoc} */ | ||
public $label = 'YetiForce Help'; | ||
|
||
/** {@inheritdoc} */ | ||
public $category = 'Support'; | ||
|
||
/** {@inheritdoc} */ | ||
public $website = 'https://yetiforce.com/en/marketplace/support'; | ||
|
||
/** {@inheritdoc} */ | ||
public $prices = [ | ||
'Micro' => 50, | ||
'Small' => 80, | ||
'Medium' => 200, | ||
'Large' => 400, | ||
'Corporation' => 800 | ||
]; | ||
/** {@inheritdoc} */ | ||
public $featured = true; | ||
|
||
/** {@inheritdoc} */ | ||
public function getAdditionalButtons(): array | ||
{ | ||
return [ | ||
\Vtiger_Link_Model::getInstanceFromValues([ | ||
'linklabel' => 'Website', | ||
'relatedModuleName' => '_Base', | ||
'linkicon' => 'fas fa-globe', | ||
'linkhref' => true, | ||
'linkExternal' => true, | ||
'linktarget' => '_blank', | ||
'linkurl' => $this->website, | ||
'linkclass' => 'btn-info', | ||
'showLabel' => 1, | ||
]), | ||
]; | ||
} | ||
} |
Oops, something went wrong.