Skip to content

Commit

Permalink
GH-89: Fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-ueding committed Feb 3, 2024
1 parent f9ab771 commit 4cb1690
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion geo_activity_playground/core/cache_migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from geo_activity_playground.core.paths import activities_path
from geo_activity_playground.core.paths import activity_timeseries_dir
from geo_activity_playground.core.paths import work_tracker_path
from geo_activity_playground.core.tasks import work_tracker_path

logger = logging.getLogger(__name__)

Expand Down
12 changes: 1 addition & 11 deletions geo_activity_playground/core/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,10 @@ def path_creator() -> pathlib.Path:


cache_dir = make_path(pathlib.Path("Cache"))
activity_timeseries_dir = make_path(cache_dir / "Activity Timeseries")
activity_timeseries_dir = lambda: make_path(cache_dir() / "Activity Timeseries")

activities_path = lambda: cache_dir() / "activities.parquet"


def activity_timeseries_path(activity_id: int) -> pathlib.Path:
return activity_timeseries_dir() / f"{activity_id}.parquet"


def work_tracker_path(name: str) -> pathlib.Path:
return cache_dir() / f"work-tracker-{name}.pickle"


def osm_tile_path(x: int, y: int, zoom: int) -> pathlib.Path:
path = pathlib.Path("Open Street Map Tiles") / f"{zoom}/{x}/{y}.png"
path.parent.mkdir(parents=True, exist_ok=True)
return path
6 changes: 5 additions & 1 deletion geo_activity_playground/core/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
import pickle
from typing import Any

from geo_activity_playground.core.paths import work_tracker_path
from geo_activity_playground.core.paths import cache_dir


def work_tracker_path(name: str) -> pathlib.Path:
return cache_dir() / f"work-tracker-{name}.pickle"


@contextlib.contextmanager
Expand Down
8 changes: 6 additions & 2 deletions geo_activity_playground/core/tiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@
import requests
from PIL import Image

from geo_activity_playground.core.paths import osm_tile_path

logger = logging.getLogger(__name__)


def osm_tile_path(x: int, y: int, zoom: int) -> pathlib.Path:
path = pathlib.Path("Open Street Map Tiles") / f"{zoom}/{x}/{y}.png"
path.parent.mkdir(parents=True, exist_ok=True)
return path


def compute_tile(lat: float, lon: float, zoom: int) -> tuple[int, int]:
x = np.radians(lon)
y = np.arcsinh(np.tan(np.radians(lat)))
Expand Down

0 comments on commit 4cb1690

Please sign in to comment.