linting
Some checks failed
Build and deploy the backend to staging / Build and push image (pull_request) Successful in 2m51s
Run linting on the backend code / Build (pull_request) Successful in 37s
Run testing on the backend code / Build (pull_request) Failing after 3m8s
Build and deploy the backend to staging / Deploy to staging (pull_request) Successful in 24s

This commit is contained in:
2025-01-23 11:28:41 +01:00
parent 78f1dcaab4
commit b9356dc4ee
8 changed files with 173 additions and 91 deletions

View File

@@ -1,3 +1,4 @@
"""Module allowing connexion to overpass api and fectch data from OSM."""
from typing import Literal, List
import urllib
import json
@@ -9,8 +10,8 @@ from .caching_strategy import get_cache_key, CachingStrategy
ElementTypes = List[Literal['way', 'node', 'relation']]
def build_query(area: tuple, element_types: ElementTypes, selector: str,
conditions=[], out='center'):
def build_query(area: tuple, element_types: ElementTypes,
selector: str, conditions=[], out='center'):
"""
Constructs a query string for the Overpass API to retrieve OpenStreetMap (OSM) data.
@@ -62,7 +63,7 @@ def build_query(area: tuple, element_types: ElementTypes, selector: str,
return query
def send_overpass_query(query: str) -> dict:
def send_query(query: str) -> dict:
"""
Sends the Overpass QL query to the Overpass API and returns the parsed JSON response.
@@ -96,7 +97,7 @@ def send_overpass_query(query: str) -> dict:
try:
# Create a Request object with the specified URL, data, and headers
request = urllib.request.Request(overpass_url, data=data, headers=headers)
# Send the request and read the response
with urllib.request.urlopen(request) as response:
# Read and decode the response