How do I change the OpenRouteService::API_URL for "On-Premise" install of software
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu với provider OpenRouteService và API_URL được hard-code của nó, sau đó so sánh constructor của nó với entry point Pelias.php được mô tả trong issue. Xác định cách cung cấp API root của một hệ thống on-premise trong khi vẫn giữ nguyên việc xử lý version hiện có. Hoàn thành khi OpenRouteService có thể trỏ đến một URL on-premise thay vì chỉ endpoint được host.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I noticed the OpenRouteService::API_URL is being hard-coded into file Geocoder\Provider\OpenRouteService (vendor\geocoder-php\openrouteservice-provide\OpenRouteService.php)
Could someone please push the following code into the next version of OpenRouteService (updating Pelias would do the trick)
vendor\geocoder-php\pelias-provider\Pelias.php
/**
* @param HttpClient $client an HTTP adapter
* @param string $root url of Pelias API
* @param int $version version of Pelias API
*/
public function __construct(HttpClient $client, string $root, int $version = 1)
{
$this->_setPeliasApiRoot($root, $version);
parent::__construct($client);
}
/**
* Set the API root and version, see "_setPeliasApiRoot"
* @param string $root url of Pelias API
* @param int $version version of Pelias API
*/
public function set_Pelias_ApiRoot(string $root, int $version = 1)
{
return $this->_setPeliasApiRoot($root, $version);
}
/**
* Set the API root and version
* @param string $root url of Pelias API
* @param int $version version of Pelias API
*/
protected function _setPeliasApiRoot(string $root, int $version = 1)
{
$this->root = sprintf('%s/v%d', rtrim($root, '/'), $version);
$this->version = $version;
}
vendor\geocoder-php\openrouteservice-provider
const API_URL = 'https://api.openrouteservice.org/geocode';
const API_VERSION = 1;
/**
* @var string
*/
private $apiKey;
/**
* @param HttpClient $client an HTTP adapter
* @param string $apiKey an API key
*/
public function __construct(HttpClient $client, string $apiKey)
{
if (empty($apiKey)) {
throw new InvalidCredentials('No API key provided.');
}
$this->apiKey = $apiKey;
parent::__construct($client, self::API_URL, self::API_VERSION);
$this->_set_ORS_API_Root(self::API_URL, self::API_VERSION, TRUE);
}
/**
* Set the Openrouteservice URL
* @param string $root
* @param integer $version
* @param boolean $check_version
* @return void
*/
public function set_ORS_API_Root(string $root, $version, $check_version = false)
{
return $this->_set_ORS_API_Root($root, $version, $check_version);
}
/**
* Set the Openrouteservice URL
* @param string $root
* @param integer $version
* @param boolean $check_version
* @return void
*/
protected function _set_ORS_API_Root(string $root, $version, $check_version = false)
{
parent::_setPeliasApiRoot($root, $version);
if (filter_var($check_version, FILTER_VALIDATE_BOOLEAN)) {
$this->_check_ORS_API_Root_Version($root, $root, $version);
}
}
/**
* Openrouteservice does not use /v1 in first version, but plan to add
* /v2 in next version.
*
* @see https://ask.openrouteservice.org/t/pelias-version-in-api-url/1021
* @param string $root
* @param string $new_root
* @param string $version
* @return void
*/
protected function _check_ORS_API_Root_Version(string &$root, string $new_root, $version)
{
$version_ok = true;
$version_ok = ($version_ok && is_numeric($version));
$version_ok = ($version_ok && ($version === self::API_VERSION));
$version_ok = ($version_ok && is_string($new_root));
$version_ok = ($version_ok && !empty($new_root));
$version_ok = (bool) $version_ok;
if ($version_ok) {
$root = $new_root;
}
}
- Ngôn ngữ chính
- PHP
- Star
- 4k
- Fork
- 525
- Merge trung bình
- 8 phút
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của geocoder-php/Geocoder
-
Wrong LocationIQ BoundsĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
geocoder-php/Geocoder#1272 ·
-
question
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
geocoder-php/Geocoder#1267 · 2 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
geocoder-php/Geocoder#1266 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 38/100
geocoder-php/Geocoder#1244 · 2 bình luận · 2 reaction ·
-
Add Support for IPQueryĐang mởprovider
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
geocoder-php/Geocoder#1243 ·
Tất cả issue của geocoder-php/Geocoder
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Broken pathsĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
Automattic/custom-metadata#167 ·
-
Daemon delete dialog: "Remove all ExApps" checkbox and `removeExApps` parameter have no effectĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
Maintainer thường phản hồi trong vòng 1 ngày