Skip to content

Bring the TLE backend to parity with the current stapi-spec #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions stapi_fastapi_tle/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ async def search_opportunities(
except IndexError:
alt = 0
passes = self.satellite.passes(
start=validated.properties.datetime[0],
end=validated.properties.datetime[1],
start=validated.datetime[0],
end=validated.datetime[1],
lon=validated.geometry.coordinates[0],
lat=validated.geometry.coordinates[1],
alt=alt,
Expand Down
7 changes: 2 additions & 5 deletions stapi_fastapi_tle/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
)

from stapi_fastapi.models.constraints import Constraints as BaseConstraints
from stapi_fastapi.models.opportunity import OpportunityRequest
from stapi_fastapi.models.opportunity import OpportunityRequest, OpportunityProperties


class Satellite(BaseModel):
Expand All @@ -33,10 +33,7 @@ def tle_lines(self) -> tuple[str, str, str]:
return self.tle.split("\n")


class PassProperties(BaseModel):
datetime: AwareDatetime
start: AwareDatetime
end: AwareDatetime
class PassProperties(OpportunityProperties):
view_off_nadir: float = Field(..., alias="view:off_nadir")
view_azimuth: float = Field(..., alias="view:azimuth")
view_elevation: float = Field(..., alias="view:elevation")
Expand Down
6 changes: 5 additions & 1 deletion stapi_fastapi_tle/satellite.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,18 @@ def passes(
bbox=[lon, lat, alt, lon, lat, alt],
),
properties={
"datetime": t.utc_datetime(),
"datetime": [
t.utc_datetime() - self._model.block_time[0],
t.utc_datetime() + self._model.block_time[1]
],
"start": t.utc_datetime() - self._model.block_time[0],
"end": t.utc_datetime() + self._model.block_time[1],
"view:off_nadir": off_nadir,
"view:azimuth": (azimuth.degrees + 180) % 360,
"view:elevation": elevation.degrees,
"sun:elevation": 0,
"sun:azimuth": 0,
"product_id": "mock:standard",
},
)
)
Expand Down