Skip to content

Commit

Permalink
Merge pull request #132 from brickbots/planet_update
Browse files Browse the repository at this point in the history
Planets available on startup / Fix missing image crash
  • Loading branch information
brickbots authored Jan 27, 2024
2 parents 7bb6958 + 28fef91 commit 8931a2d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions python/PiFinder/cat_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ def resolve_image_name(catalog_object, source):
"""
returns the image path for this objects
"""
if catalog_object.image_name == "":
return ""

return f"{BASE_IMAGE_PATH}/{str(catalog_object.image_name)[-1]}/{catalog_object.image_name}_{source}.jpg"


Expand Down
16 changes: 16 additions & 0 deletions python/PiFinder/catalogs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
import time
import datetime
import pytz
from typing import List, Dict, DefaultDict, Optional
import numpy as np
import pandas as pd
Expand Down Expand Up @@ -256,6 +257,14 @@ def add(self, catalog: Catalog):
else:
logging.warning(f"Catalog {catalog.catalog_code} already exists")

def remove(self, catalog_code: str):
self.__refresh_code_to_pos()
if catalog_code in self._code_to_pos:
self.catalogs.pop(self._code_to_pos[catalog_code])
self._code_to_pos = {}
else:
logging.warning(f"Catalog {catalog.catalog_code} does not exist")

def get_codes(self) -> List[str]:
self.__refresh_code_to_pos()
return list(self._code_to_pos.keys())
Expand Down Expand Up @@ -356,6 +365,13 @@ def build(self) -> Catalogs:
self.catalog_dicts = {}
logging.debug(f"Loaded {len(composite_objects)} objects from database")
all_catalogs: Catalogs = self._get_catalogs(composite_objects, catalogs_info)
# Initialize planet catalog with whatever date we have for now
# This will be re-initialized on activation of Catalog ui module
# if we have GPS lock
planet_catalog: Catalog = PlanetCatalog(
datetime.datetime.now().replace(tzinfo=pytz.timezone("UTC"))
)
all_catalogs.add(planet_catalog)
return all_catalogs

def _build_composite(
Expand Down
1 change: 1 addition & 0 deletions python/PiFinder/ui/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def add_planets(self, dt):
Since we can't calc planet positions until we know the date/time
this is called once we have a GPS lock to add on the planets catalog
"""
self.catalogs.remove("PL")
self.catalogs.add(PlanetCatalog(dt))
self.catalog_tracker = CatalogTracker(
self.catalogs, self.shared_state, self._config_options
Expand Down

0 comments on commit 8931a2d

Please sign in to comment.