diff options
| author | Alex Schofield <git@ajschof.me> | 2026-05-04 20:58:05 +0100 |
|---|---|---|
| committer | Alex Schofield <git@ajschof.me> | 2026-05-04 20:58:05 +0100 |
| commit | 754f7dc26ddc82a11c45a114cbdd49c17786ae7b (patch) | |
| tree | 28ba577fbcade97848819b71832df97b54151720 | |
| parent | 683d05d4f77d1ddf0d753c627610aed0f1a4eaae (diff) | |
| download | fuelnearme-754f7dc26ddc82a11c45a114cbdd49c17786ae7b.tar.gz fuelnearme-754f7dc26ddc82a11c45a114cbdd49c17786ae7b.zip | |
remove arg radius parsing from process_stations()
| -rw-r--r-- | fnme/cli.py | 2 | ||||
| -rw-r--r-- | fnme/station.py | 9 |
2 files changed, 5 insertions, 6 deletions
diff --git a/fnme/cli.py b/fnme/cli.py index 385af76..aa49ec1 100644 --- a/fnme/cli.py +++ b/fnme/cli.py @@ -49,7 +49,7 @@ def main(): print(f"Last updated: {last_modified}") - df_filtered = process_stations(df, args, location) + df_filtered = process_stations(df, args.radius, location) sorted_stations_list = sort_stations(df_filtered, args.sort) diff --git a/fnme/station.py b/fnme/station.py index 6cfc5d1..82d17cc 100644 --- a/fnme/station.py +++ b/fnme/station.py @@ -1,4 +1,3 @@ -import argparse import math from typing import Any, Dict, List, Tuple @@ -9,13 +8,13 @@ from fnme.constants import SORT_KV def process_stations( - dframe: pd.DataFrame, arguments: argparse.Namespace, loc: Tuple[float, float] + dframe: pd.DataFrame, rad: int, loc: Tuple[float, float] ) -> List[Dict[str, Any]]: def bounding_box() -> pd.DataFrame: lat, lon = loc - deg_lat = arguments.radius / 69.0 - deg_lon = arguments.radius / (69.0 * math.cos(math.radians(lat))) + deg_lat = rad / 69.0 + deg_lon = rad / (69.0 * math.cos(math.radians(lat))) return dframe[ dframe["forecourts.location.latitude"].between(lat - deg_lat, lat + deg_lat) & dframe["forecourts.location.longitude"].between( @@ -42,7 +41,7 @@ def process_stations( df["forecourts.location.longitude"].to_numpy(), ).round(1) - df = df[df["distance"] < arguments.radius] + df = df[df["distance"] < rad] df = df.assign( e5_price=pence_to_pounds(df["forecourts.fuel_price.E5"]), |
