Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

How do I change the OpenRouteService::API_URL for "On-Premise" install of software

Abierto
#1,157 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
php
Área
api

Línea de trabajo

Comienza con el proveedor OpenRouteService y su API_URL codificada de forma fija; después, compara su constructor con el punto de entrada Pelias.php descrito en el issue. Determina cómo se debe proporcionar la raíz de la API de una instalación on-premise, conservando el manejo de versiones existente. Se considera terminado cuando OpenRouteService puede apuntar a una URL on-premise en lugar de únicamente al endpoint alojado.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

improvement provider

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;
    }
}
Lenguaje dominante
PHP
Estrellas
4k
Forks
525
Merge medio
8 min
PR fusionados (30 d)
1

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de geocoder-php/Geocoder

Todos los issues de geocoder-php/Geocoder

Issues similares

Más issues de PHP

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.