-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Implement add_marker to add a marker to the Aladin Lite view
- Loading branch information
Showing
4 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from typing import Tuple, Union | ||
|
||
from astropy.coordinates import SkyCoord | ||
from ipyaladin.utils._coordinate_parser import parse_coordinate_string | ||
|
||
|
||
class Marker: | ||
"""A class representing a marker in Aladin Lite.""" | ||
|
||
def __init__( | ||
self, | ||
position: Union[str, SkyCoord, Tuple[float, float]], | ||
title: str, | ||
description: str, | ||
) -> None: | ||
self.title = title | ||
self.description = description | ||
if isinstance(position, SkyCoord): | ||
self.position = f"{position.ra.deg} {position.dec.deg}" | ||
elif isinstance(position, str): | ||
sc = parse_coordinate_string(position) | ||
self.position = f"{sc.ra.deg} {sc.dec.deg}" | ||
else: | ||
self.position = f"{position[0]} {position[1]}" | ||
|
||
def to_dict(self) -> dict: | ||
"""Convert the marker to a dictionary. | ||
Returns | ||
------- | ||
dict | ||
The marker as a dictionary | ||
""" | ||
return { | ||
"position": self.position, | ||
"title": self.title, | ||
"description": self.description, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters