Skip to content

Commit

Permalink
Add nits.
Browse files Browse the repository at this point in the history
  • Loading branch information
dabhicusp committed Jul 11, 2023
1 parent b514385 commit dc419ae
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions weather_mv/loader_pipeline/bq.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,12 @@ def extract_rows(self, uri: str, coordinates: t.List[t.Dict]) -> t.Iterator[t.Di

longitude = ((row['longitude'] + 180) % 360) - 180
row[GEO_POINT_COLUMN] = fetch_geo_point(row['latitude'], longitude)
row[GEO_POLYGON_COLUMN] = fetch_geo_polygon(row['latitude'], longitude,
self.lat_grid_resolution, self.lon_grid_resolution
) if not self.skip_creating_polygon else None

if not self.skip_creating_polygon:
row[GEO_POLYGON_COLUMN] = fetch_geo_polygon(row['latitude'], longitude,
self.lat_grid_resolution, self.lon_grid_resolution)
else:
row[GEO_POLYGON_COLUMN] = None
# 'row' ends up looking like:
# {'latitude': 88.0, 'longitude': 2.0, 'time': '2015-01-01 06:00:00', 'd': -2.0187, 'cc': 0.007812,
# 'z': 50049.8, 'data_import_time': '2020-12-05 00:12:02.424573 UTC', ...}
Expand Down Expand Up @@ -350,6 +353,7 @@ def fetch_geo_point(lat: float, long: float) -> str:

def fetch_geo_polygon(latitude: float, longitude: float, lat_grid_resolution: float, lon_grid_resolution: float) -> str:
"""Create a Polygon based on latitude, longitude and resolution.
Example ::
* - . - *
| |
Expand All @@ -373,6 +377,7 @@ def fetch_geo_polygon(latitude: float, longitude: float, lat_grid_resolution: fl

def bound_point(latitude: float, longitude: float, lat_grid_resolution: float, lon_grid_resolution: float) -> t.List:
"""Calculate the bound point based on latitude, longitude and grid resolution.
Example ::
* - . - *
| |
Expand All @@ -398,6 +403,7 @@ def bound_point(latitude: float, longitude: float, lat_grid_resolution: float, l
def get_lat_lon_range(value: float, lat_lon: str, is_point_out_of_bound: bool,
lat_grid_resolution: float, lon_grid_resolution: float) -> t.List:
"""Calculate the latitude, longitude point range point latitude, longitude and grid resolution.
Example ::
* - . - *
| |
Expand Down

0 comments on commit dc419ae

Please sign in to comment.