How to use the routingpy.routers.base.Router function in routingpy

To help you get started, we’ve selected a few routingpy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gis-ops / routing-py / tests / test_base.py View on Github external
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
"""Tests for client module."""

import responses
import requests
import time

import routingpy
from routingpy.routers import options, base
import tests as _test


class RouterMock(base.Router):
    def __init__(self, *args, **kwargs):
        super(RouterMock, self).__init__(*args, **kwargs)

    def directions(self, *args, **kwargs):
        return self._request(*args, **kwargs)

    def isochrones(self):
        pass

    def matrix(self):
        pass


class BaseTest(_test.TestCase):
    def setUp(self):
        self.router = RouterMock("https://httpbin.org/")
github gis-ops / routing-py / routingpy / routers / mapbox_osrm.py View on Github external
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
"""
Core client functionality, common across all API requests.
"""

from .base import Router, DEFAULT
from routingpy import convert, utils
from routingpy.direction import Direction, Directions
from routingpy.isochrone import Isochrone, Isochrones
from routingpy.matrix import Matrix


class MapboxOSRM(Router):
    """Performs requests to the OSRM API services."""

    _base_url = 'https://api.mapbox.com'

    def __init__(
            self,
            api_key,
            user_agent=None,
            timeout=DEFAULT,
            retry_timeout=None,
            requests_kwargs=None,
            retry_over_query_limit=False,
            skip_api_error=None
    ):
        """
        Initializes a Mapbox OSRM client.
github gis-ops / routing-py / routingpy / routers / heremaps.py View on Github external
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#

from .base import Router, DEFAULT
from routingpy import convert
from routingpy.direction import Direction, Directions
from routingpy.isochrone import Isochrones, Isochrone
from routingpy.matrix import Matrix

from operator import itemgetter


class HereMaps(Router):
    """Performs requests to the HERE Maps API services."""

    _DEFAULT_BASE_URL = 'https://route.api.here.com/routing/7.2'

    def __init__(
        self,
        app_id=None,
        app_code=None,
        user_agent=None,
        timeout=DEFAULT,
        retry_timeout=None,
        requests_kwargs=None,
        retry_over_query_limit=False,
        skip_api_error=None
    ):
        """
github gis-ops / routing-py / routingpy / routers / osrm.py View on Github external
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#

from .base import Router, DEFAULT
from routingpy import convert, utils
from routingpy.direction import Directions, Direction
from routingpy.matrix import Matrix


class OSRM(Router):
    """Performs requests to the OSRM API services."""

    _DEFAULT_BASE_URL = 'https://router.project-osrm.org'

    def __init__(
            self,
            base_url=_DEFAULT_BASE_URL,
            user_agent=None,
            timeout=DEFAULT,
            retry_timeout=None,
            requests_kwargs=None,
            retry_over_query_limit=False,
            skip_api_error=None
    ):
        """
        Initializes an OSRM client.
github gis-ops / routing-py / routingpy / routers / graphhopper.py View on Github external
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#

from .base import Router, DEFAULT
from routingpy import convert
from routingpy import utils
from routingpy.direction import Direction, Directions
from routingpy.isochrone import Isochrone, Isochrones
from routingpy.matrix import Matrix


class Graphhopper(Router):
    """Performs requests to the Graphhopper API services."""

    _DEFAULT_BASE_URL = "https://graphhopper.com/api/1"

    def __init__(
            self,
            api_key=None,
            base_url=_DEFAULT_BASE_URL,
            user_agent=None,
            timeout=DEFAULT,
            retry_timeout=None,
            requests_kwargs={},
            retry_over_query_limit=False,
            skip_api_error=None
    ):
        """
github gis-ops / routing-py / routingpy / routers / google.py View on Github external
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#

from .base import Router, DEFAULT
from routingpy import convert, utils
from routingpy.direction import Directions, Direction
from routingpy.matrix import Matrix

from operator import itemgetter


class Google(Router):
    """Performs requests to the Google API services."""

    _base_url = "https://maps.googleapis.com/maps/api"

    def __init__(
            self,
            api_key,
            user_agent=None,
            timeout=DEFAULT,
            retry_timeout=None,
            requests_kwargs={},
            retry_over_query_limit=True,
            skip_api_error=None
    ):
        """
        Initializes a Google client.
github gis-ops / routing-py / routingpy / routers / openrouteservice.py View on Github external
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#

from .base import Router, DEFAULT
from routingpy import utils
from routingpy.direction import Direction
from routingpy.isochrone import Isochrone, Isochrones
from routingpy.matrix import Matrix


class ORS(Router):
    """Performs requests to the ORS API services."""

    _DEFAULT_BASE_URL = 'https://api.openrouteservice.org'

    def __init__(
            self,
            api_key=None,
            base_url=_DEFAULT_BASE_URL,
            user_agent=None,
            timeout=DEFAULT,
            retry_timeout=None,
            requests_kwargs=None,
            retry_over_query_limit=False,
            skip_api_error=None
    ):
        """
github gis-ops / routing-py / routingpy / routers / valhalla.py View on Github external
# the License.
#
"""
Core client functionality, common across all API requests.
"""

from .base import Router, DEFAULT
from routingpy import utils
from routingpy.direction import Direction
from routingpy.isochrone import Isochrone, Isochrones
from routingpy.matrix import Matrix

from operator import itemgetter


class Valhalla(Router):
    """Performs requests to a Valhalla instance."""
    def __init__(
            self,
            base_url,
            api_key=None,
            user_agent=None,
            timeout=DEFAULT,
            retry_timeout=None,
            requests_kwargs=None,
            retry_over_query_limit=False,
            skip_api_error=None
    ):
        """
        Initializes a Valhalla client.

        :param api_key: Mapbox API key. Required if base_url='https://api.mapbox.com/valhalla/v1'.