Skip to content

Commit

Permalink
feat: add proxy parameter for get_osm func.
Browse files Browse the repository at this point in the history
Because I need to pass the GFW.

enzet#151
  • Loading branch information
LaoshuBaby committed Apr 15, 2023
1 parent f080e50 commit c43864f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion map_machine/osm/osm_getter.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ class NetworkError(Exception):


def get_osm(
boundary_box: BoundaryBox, cache_file_path: Path, to_update: bool = False
boundary_box: BoundaryBox, cache_file_path: Path, to_update: bool = False, proxy = None
) -> str:
"""
Download OSM data from the web or get if from the cache.
:param boundary_box: borders of the map part to download
:param cache_file_path: cache file to store downloaded OSM data
:param to_update: update cache files
:param proxy: specify proxy used while downloading
"""
if not to_update and cache_file_path.is_file():
with cache_file_path.open(encoding="utf-8") as output_file:
Expand Down
4 changes: 2 additions & 2 deletions map_machine/slippy/tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def load_osm_data(self, cache_path: Path) -> OSMData:
cache_file_path: Path = (
cache_path / f"{self.get_extended_boundary_box().get_format()}.osm"
)
get_osm(self.get_extended_boundary_box(), cache_file_path)
get_osm(self.get_extended_boundary_box(), cache_file_path, proxy=proxy)

osm_data: OSMData = OSMData()
osm_data.parse_osm_file(cache_file_path)
Expand Down Expand Up @@ -256,7 +256,7 @@ def load_osm_data(self, cache_path: Path) -> OSMData:
cache_file_path: Path = (
cache_path / f"{self.boundary_box.get_format()}.osm"
)
get_osm(self.boundary_box, cache_file_path)
get_osm(self.boundary_box, cache_file_path, proxy=proxy)

osm_data: OSMData = OSMData()
osm_data.parse_osm_file(cache_file_path)
Expand Down

0 comments on commit c43864f

Please sign in to comment.