Documentation
¶
Index ¶
- Constants
- Variables
- func GetMediaCaptions(nasaID string) (string, error)
- type APIParam
- type APODImage
- type APODParams
- type Date
- type EPICDate
- type EPICImage
- type EPICImages
- type EPICParams
- type ErrorHTTPStatus
- type ErrorRoverCameraMissing
- type LatLon
- type ManifestPhoto
- type MarsPhotosParams
- type Media
- type MediaAssets
- type MediaMetadata
- type MediaParams
- type MissionManifest
- type ParamEncoder
- type Quaternions
- type Rover
- type RoverCamera
- type RoverPhoto
- type RoverPhotos
- type StringList
- type XYZ
Constants ¶
const Version = "0.4.1"
Version is the package version.
Variables ¶
var ( // ErrorNoAPIKey is returned with no API key is given. ErrorNoAPIKey = errors.New("no API key provided; get one at https://api.nasa.gov") // ErrorNoMetadata is returned if a media asset has no metadata. ErrorNoMetadata = errors.New("media has no metadata") // ErrorNoCaptions is returned if a media asset has no captions. ErrorNoCaptions = errors.New("media has no captions") // ErrorNoQuery is returned if there are no search parameters provided. ErrorNoQuery = errors.New("must provide at least one search parameter") // ErrorParamsMismatch is returned when the wrong type of ParamEncoder is used. ErrorParamsMismatch = errors.New("wrong param type passed") // ErrorNoResults is returned when a query that must return items finds none. ErrorNoResults = errors.New("no results found") // ErrorRoverUnsupported is returned when photos are requested for a rover that has no // supported image source. ErrorRoverUnsupported = errors.New("rover is not supported") )
var ( RoverCuriosity = Rover{ Name: "Curiosity", Slug: "curiosity", Cameras: []RoverCamera{RoverCameraFHAZ, RoverCameraRHAZ, RoverCameraMAST, RoverCameraCHEMCAM, RoverCameraMAHLI, RoverCameraMARDI, RoverCameraNAVCAM}, LandingDate: time.Date(2012, 8, 6, 0, 0, 0, 0, time.UTC), LaunchDate: time.Date(2011, 11, 26, 0, 0, 0, 0, time.UTC), Status: "active", } RoverPerseverance = Rover{ Name: "Perseverance", Slug: "perseverance", Cameras: []RoverCamera{ RoverCameraEDLRUCAM, RoverCameraEDLRDCAM, RoverCameraEDLDDCAM, RoverCameraEDLPUCAM1, RoverCameraEDLPUCAM2, RoverCameraNAVCAMLEFT, RoverCameraNAVCAMRIGHT, RoverCameraMCZLEFT, RoverCameraMCZRIGHT, RoverCameraFRONTHAZCAMLEFTA, RoverCameraFRONTHAZCAMRIGHTA, RoverCameraREARHAZCAMLEFT, RoverCameraREARHAZCAMRIGHT, RoverCameraSKYCAM, RoverCameraSHERLOCWATSON, RoverCameraSUPERCAMRMI, RoverCameraLCAM, }, LandingDate: time.Date(2021, 2, 18, 0, 0, 0, 0, time.UTC), LaunchDate: time.Date(2020, 7, 30, 0, 0, 0, 0, time.UTC), Status: "active", } RoverOpportunity = Rover{ Name: "Opportunity", Slug: "opportunity", Cameras: []RoverCamera{RoverCameraFHAZ, RoverCameraRHAZ, RoverCameraNAVCAM, RoverCameraPANCAM, RoverCameraMI}, LandingDate: time.Date(2004, 1, 25, 0, 0, 0, 0, time.UTC), LaunchDate: time.Date(2003, 7, 7, 0, 0, 0, 0, time.UTC), Status: "complete", } RoverSpirit = Rover{ Name: "Spirit", Slug: "spirit", Cameras: []RoverCamera{RoverCameraFHAZ, RoverCameraRHAZ, RoverCameraNAVCAM, RoverCameraPANCAM, RoverCameraMI}, LandingDate: time.Date(2004, 1, 4, 0, 0, 0, 0, time.UTC), LaunchDate: time.Date(2003, 6, 10, 0, 0, 0, 0, time.UTC), Status: "complete", } // Rovers is a convenience slice for iterating through every supported rover when // building UI pickers or issuing batch calls. Rovers = []Rover{ RoverCuriosity, RoverPerseverance, RoverOpportunity, RoverSpirit, } )
Defines Rovers to be used in Mars rover API requests.
var ( // RoverCameraFHAZ is the Front Hazard Avoidance Camera. RoverCameraFHAZ = RoverCamera{ Name: "FHAZ", FullName: "Front Hazard Avoidance Camera", Slug: "fhaz", } // RoverCameraRHAZ is the Rear Hazard Avoidance Camera. RoverCameraRHAZ = RoverCamera{ Name: "RHAZ", FullName: "Rear Hazard Avoidance Camera", Slug: "rhaz", } // RoverCameraMAST is the Mast Camera. RoverCameraMAST = RoverCamera{ Name: "MAST", FullName: "Mast Camera", Slug: "mast", } // RoverCameraCHEMCAM is the Chemistry and Camera Complex. RoverCameraCHEMCAM = RoverCamera{ Name: "CHEMCAM", FullName: "Chemistry and Camera Complex", Slug: "chemcam", } // RoverCameraMAHLI is the Mars Hand Lens Imager. RoverCameraMAHLI = RoverCamera{ Name: "MAHLI", FullName: "Mars Hand Lens Imager", Slug: "mahli", } // RoverCameraMARDI is the Mars Descent Imager. RoverCameraMARDI = RoverCamera{ Name: "MARDI", FullName: "Mars Descent Imager", Slug: "mardi", } // RoverCameraNAVCAM is the Navigation Camera. RoverCameraNAVCAM = RoverCamera{ Name: "NAVCAM", FullName: "Navigation Camera", Slug: "navcam", } // RoverCameraPANCAM is the Panoramic Camera. RoverCameraPANCAM = RoverCamera{ Name: "PANCAM", FullName: "Panoramic Camera", Slug: "pancam", } // RoverCameraMI is the Microscopic Imager. RoverCameraMI = RoverCamera{ Name: "MI", FullName: "Microscopic Imager", Slug: "mi", } // RoverCameraEDLRUCAM is the Entry, Descent, and Landing Rover Up-Look Camera. RoverCameraEDLRUCAM = RoverCamera{ Name: "EDL_RUCAM", FullName: "Entry, Descent, and Landing Rover Up-Look Camera", Slug: "edl_rucam", } // RoverCameraEDLRDCAM is the Entry, Descent, and Landing Rover Down-Look Camera. RoverCameraEDLRDCAM = RoverCamera{ Name: "EDL_RDCAM", FullName: "Entry, Descent, and Landing Rover Down-Look Camera", Slug: "edl_rdcam", } // RoverCameraEDLDDCAM is the Entry, Descent, and Landing Descent Stage Down-Look Camera. RoverCameraEDLDDCAM = RoverCamera{ Name: "EDL_DDCAM", FullName: "Entry, Descent, and Landing Descent Stage Down-Look Camera", Slug: "edl_ddcam", } // RoverCameraEDLPUCAM1 is the Entry, Descent, and Landing Parachute Up-Look Camera A. RoverCameraEDLPUCAM1 = RoverCamera{ Name: "EDL_PUCAM1", FullName: "Entry, Descent, and Landing Parachute Up-Look Camera A", Slug: "edl_pucam1", } // RoverCameraEDLPUCAM2 is the Entry, Descent, and Landing Parachute Up-Look Camera B. RoverCameraEDLPUCAM2 = RoverCamera{ Name: "EDL_PUCAM2", FullName: "Entry, Descent, and Landing Parachute Up-Look Camera B", Slug: "edl_pucam2", } // RoverCameraNAVCAMLEFT is the Perseverance Navigation Camera (Left). RoverCameraNAVCAMLEFT = RoverCamera{ Name: "NAVCAM_LEFT", FullName: "Navigation Camera - Left", Slug: "navcam_left", } // RoverCameraNAVCAMRIGHT is the Perseverance Navigation Camera (Right). RoverCameraNAVCAMRIGHT = RoverCamera{ Name: "NAVCAM_RIGHT", FullName: "Navigation Camera - Right", Slug: "navcam_right", } // RoverCameraMCZLEFT is the Mastcam-Z Left Camera. RoverCameraMCZLEFT = RoverCamera{ Name: "MCZ_LEFT", FullName: "Mastcam-Z Left Camera", Slug: "mcz_left", } // RoverCameraMCZRIGHT is the Mastcam-Z Right Camera. RoverCameraMCZRIGHT = RoverCamera{ Name: "MCZ_RIGHT", FullName: "Mastcam-Z Right Camera", Slug: "mcz_right", } // RoverCameraFRONTHAZCAMLEFTA is the Front Hazard Avoidance Camera (Left A). RoverCameraFRONTHAZCAMLEFTA = RoverCamera{ Name: "FRONT_HAZCAM_LEFT_A", FullName: "Front Hazard Avoidance Camera - Left", Slug: "front_hazcam_left_a", } // RoverCameraFRONTHAZCAMRIGHTA is the Front Hazard Avoidance Camera (Right A). RoverCameraFRONTHAZCAMRIGHTA = RoverCamera{ Name: "FRONT_HAZCAM_RIGHT_A", FullName: "Front Hazard Avoidance Camera - Right", Slug: "front_hazcam_right_a", } // RoverCameraREARHAZCAMLEFT is the Rear Hazard Avoidance Camera (Left). RoverCameraREARHAZCAMLEFT = RoverCamera{ Name: "REAR_HAZCAM_LEFT", FullName: "Rear Hazard Avoidance Camera - Left", Slug: "rear_hazcam_left", } // RoverCameraREARHAZCAMRIGHT is the Rear Hazard Avoidance Camera (Right). RoverCameraREARHAZCAMRIGHT = RoverCamera{ Name: "REAR_HAZCAM_RIGHT", FullName: "Rear Hazard Avoidance Camera - Right", Slug: "rear_hazcam_right", } // RoverCameraSKYCAM is the SkyCam instrument. RoverCameraSKYCAM = RoverCamera{ Name: "SKYCAM", FullName: "SkyCam", Slug: "skycam", } // RoverCameraSHERLOCWATSON is the SHERLOC WATSON instrument. RoverCameraSHERLOCWATSON = RoverCamera{ Name: "SHERLOC_WATSON", FullName: "SHERLOC WATSON", Slug: "sherloc_watson", } // RoverCameraSUPERCAMRMI is the SuperCam Remote Micro-Imager. RoverCameraSUPERCAMRMI = RoverCamera{ Name: "SUPERCAM_RMI", FullName: "SuperCam Remote Micro-Imager", Slug: "supercam_rmi", } // RoverCameraLCAM is the Lander Vision System Camera. RoverCameraLCAM = RoverCamera{ Name: "LCAM", FullName: "Lander Vision System Camera", Slug: "lcam", } // RoverCameras is an easily iteratable array of cameras. RoverCameras = []RoverCamera{ RoverCameraFHAZ, RoverCameraRHAZ, RoverCameraMAST, RoverCameraCHEMCAM, RoverCameraMAHLI, RoverCameraMARDI, RoverCameraNAVCAM, RoverCameraPANCAM, RoverCameraMI, RoverCameraEDLRUCAM, RoverCameraEDLRDCAM, RoverCameraEDLDDCAM, RoverCameraEDLPUCAM1, RoverCameraEDLPUCAM2, RoverCameraNAVCAMLEFT, RoverCameraNAVCAMRIGHT, RoverCameraMCZLEFT, RoverCameraMCZRIGHT, RoverCameraFRONTHAZCAMLEFTA, RoverCameraFRONTHAZCAMRIGHTA, RoverCameraREARHAZCAMLEFT, RoverCameraREARHAZCAMRIGHT, RoverCameraSKYCAM, RoverCameraSHERLOCWATSON, RoverCameraSUPERCAMRMI, RoverCameraLCAM, } )
Functions ¶
func GetMediaCaptions ¶
GetMediaCaptions returns the captions for the given nasaID. TODO: Maybe parse the captions in later versions.
Types ¶
type APIParam ¶
type APIParam struct {
APIKey string
}
APIParam is used when only an API key is needed. Most NASA endpoints require at least this parameter.
type APODImage ¶
type APODImage struct {
Date Date `json:"date"`
Title string `json:"title"`
URL string `json:"url"`
HDURL string `json:"hdurl"`
Explanation string `json:"explanation"`
MediaType string `json:"media_type"`
Copyright string `json:"copyright"`
// ThumbnailURL is only set for YouTube videos when APODParams.Thumbs is true.
ThumbnailURL string `json:"thumbnail_url"`
// Deprecated: The APOD feed has no service version; it is always empty.
ServiceVersion string `json:"service_version"`
}
APODImage represents an Astronomy Picture Of the Day. Most callers obtain an APODImage via APOD or APODList rather than instantiating the struct directly.
URL is the image (or video embed for videos) and HDURL the full-size image, matching the retired api.nasa.gov service. Explanation and Copyright may contain HTML.
func APOD ¶
func APOD(p ParamEncoder) (APODImage, error)
APOD returns the Astronomy Picture Of the Day for APODParams.Date, or the latest one when Date is not set. Other APODParams filters are ignored; see APODList.
func APODList ¶ added in v0.2.0
func APODList(p ParamEncoder) ([]APODImage, error)
APODList returns APOD images for a StartDate/EndDate range (oldest first) or Count random images. Count returns ErrorNoResults if no images are found. With neither set it behaves like APOD.
type APODParams ¶
type APODParams struct {
// Deprecated: The APOD feed does not require an API key; it is ignored.
APIKey string
Date time.Time
// Deprecated: HDURL is always populated when available; HD is ignored.
HD bool
StartDate time.Time
EndDate time.Time
// Count returns this many random images, fetched one date at a time.
Count int
// Thumbs sets APODImage.ThumbnailURL for YouTube videos.
Thumbs bool
}
APODParams wraps the APOD filters used by APOD and APODList, such as Date or StartDate/EndDate.
func (*APODParams) Encode
deprecated
func (p *APODParams) Encode() (string, error)
Encode returns the query string for the retired api.nasa.gov APOD service.
Deprecated: APOD and APODList no longer use it.
type Date ¶
Date is a time.Time wrapper.
func (*Date) UnmarshalJSON ¶
UnmarshalJSON unmarshals a date formatted as YYYY-MM-DD.
type EPICDate ¶
EPICDate is a time.Time wrapper used to parse the EPIC date response.
func (*EPICDate) UnmarshalJSON ¶
UnmarshalJSON unmarshals a date formatted as YYYY-MM-DD HH-MM-SS.
type EPICImage ¶
type EPICImage struct {
Date EPICDate `json:"date"`
Identifier string `json:"identifier"`
Caption string `json:"caption"`
Image string `json:"image"`
Version string `json:"version"`
Coords struct {
Centroid LatLon `json:"centroid_coordinates"`
Dscovr XYZ `json:"dscovr_j2000_position"`
Lunar XYZ `json:"lunar_j2000_position"`
Sun XYZ `json:"sun_j2000_position"`
Attitude Quaternions `json:"attitude_quaternions"`
} `json:"coords"`
URL struct {
Natural string
Enhanced string
Thumb struct {
Natural string
Enhanced string
} `json:"-"`
} `json:"-"`
}
EPICImage represents an image from the Earth Polychromatic Imaging Camera. The helper populates archive URLs so clients can link directly to the natural or enhanced imagery returned by the EPIC API.
type EPICImages ¶
type EPICImages []*EPICImage
EPICImages is an array of pointers to EPICImage returned by the EPIC helper.
func EPIC ¶
func EPIC(p ParamEncoder) (EPICImages, error)
EPIC fetches imagery metadata from the Earth Polychromatic Imaging Camera. Populate EPICParams with the desired collection and optional date; when Date is omitted the function returns the most recent image for the requested collection. The helper also annotates each image with convenient archive download URLs.
type EPICParams ¶
EPICParams wraps the EPIC API params. Provide the desired collection (natural or enhanced), optional Date, and API key if required.
func (*EPICParams) Encode ¶
func (p *EPICParams) Encode() (string, error)
Encode returns a string representation for the given API type.
type ErrorHTTPStatus ¶ added in v0.3.0
ErrorHTTPStatus is returned when an API responds with a non-2xx status code. Body holds the raw response body, which often contains the API's own error message.
func (*ErrorHTTPStatus) Error ¶ added in v0.3.0
func (e *ErrorHTTPStatus) Error() string
type ErrorRoverCameraMissing ¶
type ErrorRoverCameraMissing struct {
// contains filtered or unexported fields
}
ErrorRoverCameraMissing is returned if the rover does not have the camera available.
func (*ErrorRoverCameraMissing) Error ¶
func (e *ErrorRoverCameraMissing) Error() string
type LatLon ¶
LatLon represents latitude/longitude coordinates as returned by several NASA endpoints, including EPIC image metadata.
type ManifestPhoto ¶
type ManifestPhoto struct {
Sol int `json:"sol"`
EarthDate Date `json:"earth_date"`
TotalPhotos int `json:"total_photos"`
Cameras []string `json:"cameras"`
}
ManifestPhoto stores info about mission manifest photos.
type MarsPhotosParams ¶
type MarsPhotosParams struct {
// APIKey is not used: NASA's raw image feeds do not require one.
//
// Deprecated: The Mars photo sources ignore it.
APIKey string
Sol int
EarthDate time.Time
Camera RoverCamera
Page int
}
MarsPhotosParams wraps the Mars photo filters. Use it with MarsRoverPhotos or MarsRoverPhotosLatest to supply a sol or earth date, camera, and page.
func (*MarsPhotosParams) Encode ¶
func (p *MarsPhotosParams) Encode() (string, error)
Encode returns a string representation for the given API type.
type Media ¶
type Media struct {
Metadata struct {
TotalHits int `json:"total_hits"`
} `json:"metadata"`
Items []struct {
Data []struct {
Center string `json:"center"`
Album []string `json:"album"`
SecondaryCreator string `json:"secondary_creator"`
Keywords []string `json:"keywords"`
Description string `json:"description"`
Description508 string `json:"description_508"`
MediaType string `json:"media_type"`
NasaID string `json:"nasa_id"`
DateCreated time.Time `json:"date_created"`
Location string `json:"location"`
Photographer string `json:"photographer"`
Title string `json:"title"`
} `json:"data"`
Links []struct {
Render string `json:"render"`
Href string `json:"href"`
Rel string `json:"rel"`
Prompt string `json:"prompt"`
Width int `json:"width"`
Height int `json:"height"`
Size int64 `json:"size"`
} `json:"links"`
Href string `json:"href"`
} `json:"items"`
Links []struct {
Prompt string `json:"prompt"`
Href string `json:"href"`
Rel string `json:"rel"`
} `json:"links"`
Version string `json:"version"`
Href string `json:"href"`
}
Media represents a NASA Image and Video Library search response. The structure maps directly to the Collection+JSON payload returned by the /search endpoint.
func MediaSearch ¶
func MediaSearch(p ParamEncoder) (Media, error)
MediaSearch queries the NASA Image and Video Library /search endpoint using the provided MediaParams. At least one search parameter must be supplied; the helper unmarshals the Collection+JSON response into a Media value for easier consumption.
type MediaAssets ¶
type MediaAssets struct {
Items []struct {
Href string `json:"href"`
} `json:"items"`
Version string `json:"version"`
Href string `json:"href"`
}
MediaAssets represents the results from the media asset manifest endpoint, describing downloadable resources for a media item identified by NASA ID.
func GetMediaAssets ¶
func GetMediaAssets(nasaID string) (MediaAssets, error)
GetMediaAssets retrieves the media asset manifest for the given NASA ID, returning download links for each available rendition (image, video, metadata, etc.).
type MediaMetadata ¶
type MediaMetadata struct {
// TODO: Split these off into structs based on their namespace.
// TODO: Parse the weird timestamps: "2006:01:02 15:04:05" and "2006:01:02 15:04:05-0700"
AVAILAlbum StringList `json:"AVAIL:Album"`
AVAILCenter string `json:"AVAIL:Center"`
AVAILDateCreated string `json:"AVAIL:DateCreated"`
AVAILDescription string `json:"AVAIL:Description"`
AVAILDescription508 string `json:"AVAIL:Description508"`
AVAILKeywords []string `json:"AVAIL:Keywords"`
AVAILLocation string `json:"AVAIL:Location"`
AVAILMediaType string `json:"AVAIL:MediaType"`
AVAILNASAID string `json:"AVAIL:NASAID"`
AVAILOwner string `json:"AVAIL:Owner"`
AVAILPhotographer string `json:"AVAIL:Photographer"`
AVAILSecondaryCreator string `json:"AVAIL:SecondaryCreator"`
AVAILTitle string `json:"AVAIL:Title"`
CompositeImageSize string `json:"Composite:ImageSize"`
CompositeMegapixels float64 `json:"Composite:Megapixels"`
EXIFColorSpace string `json:"EXIF:ColorSpace"`
EXIFComponentsConfiguration string `json:"EXIF:ComponentsConfiguration"`
EXIFCreateDate string `json:"EXIF:CreateDate"`
EXIFExifVersion string `json:"EXIF:ExifVersion"`
EXIFFlashpixVersion string `json:"EXIF:FlashpixVersion"`
EXIFImageDescription string `json:"EXIF:ImageDescription"`
EXIFResolutionUnit string `json:"EXIF:ResolutionUnit"`
EXIFXResolution int `json:"EXIF:XResolution"`
EXIFYCbCrPositioning string `json:"EXIF:YCbCrPositioning"`
EXIFYResolution int `json:"EXIF:YResolution"`
ExifToolExifToolVersion float64 `json:"ExifTool:ExifToolVersion"`
FileBitsPerSample int `json:"File:BitsPerSample"`
FileColorComponents int `json:"File:ColorComponents"`
FileCurrentIPTCDigest string `json:"File:CurrentIPTCDigest"`
FileDirectory string `json:"File:Directory"`
FileEncodingProcess string `json:"File:EncodingProcess"`
FileExifByteOrder string `json:"File:ExifByteOrder"`
FileFileAccessDate string `json:"File:FileAccessDate"`
FileFileInodeChangeDate string `json:"File:FileInodeChangeDate"`
FileFileModifyDate string `json:"File:FileModifyDate"`
FileFileName string `json:"File:FileName"`
FileFilePermissions string `json:"File:FilePermissions"`
FileFileSize string `json:"File:FileSize"`
FileFileType string `json:"File:FileType"`
FileFileTypeExtension string `json:"File:FileTypeExtension"`
FileImageHeight int `json:"File:ImageHeight"`
FileImageWidth int `json:"File:ImageWidth"`
FileMIMEType string `json:"File:MIMEType"`
FileYCbCrSubSampling string `json:"File:YCbCrSubSampling"`
IPTCApplicationRecordVersion int `json:"IPTC:ApplicationRecordVersion"`
IPTCKeywords StringList `json:"IPTC:Keywords"`
JFIFJFIFVersion float64 `json:"JFIF:JFIFVersion"`
JFIFResolutionUnit string `json:"JFIF:ResolutionUnit"`
JFIFXResolution int `json:"JFIF:XResolution"`
JFIFYResolution int `json:"JFIF:YResolution"`
SourceFile string `json:"SourceFile"`
XMPCreateDate string `json:"XMP:CreateDate"`
XMPCreatedate string `json:"XMP:Createdate"`
XMPCredit string `json:"XMP:Credit"`
XMPDateCreated string `json:"XMP:DateCreated"`
XMPDescription string `json:"XMP:Description"`
XMPImageDescription string `json:"XMP:ImageDescription"`
XMPNasaID string `json:"XMP:Nasa_id"`
XMPSource string `json:"XMP:Source"`
XMPTitle string `json:"XMP:Title"`
XMPXMPToolkit string `json:"XMP:XMPToolkit"`
}
MediaMetadata holds metadata info for a media resource. Use GetMediaMetadata to fetch the metadata JSON and unmarshal it into this structure.
func GetMediaMetadata ¶
func GetMediaMetadata(nasaID string) (MediaMetadata, error)
GetMediaMetadata gets the metadata for media with the provided NASA ID. The helper first resolves the metadata location and then retrieves the JSON payload.
type MediaParams ¶
type MediaParams struct {
Query string
Center string
Description string
Description508 string
Keywords string
Location string
MediaType string
NasaID string
Page int
PageSize int
Photographer string
SecondaryCreator string
Title string
YearStart string
YearEnd string
}
MediaParams wraps the Image and Video Library (media) search parameters. At least one non-pagination filter, such as Query, NasaID, or Keywords, must be specified before a search can be performed.
func (*MediaParams) Encode ¶
func (p *MediaParams) Encode() (string, error)
Encode returns a string representation for the given API type.
type MissionManifest ¶
type MissionManifest struct {
Name string `json:"name"`
LandingDate Date `json:"landing_date"`
LaunchDate Date `json:"launch_date"`
Status string `json:"status"`
// MaxSol and MaxDate are the sol and UTC capture date of the most recent full-frame
// photos.
MaxSol int `json:"max_sol"`
MaxDate Date `json:"max_date"`
// TotalPhotos is the image count reported by the rover's source. For Perseverance,
// Opportunity and Spirit it counts full frames only; for Curiosity it also counts
// thumbnails and subframes.
TotalPhotos int `json:"total_photos"`
// Photos is not populated, since building it requires one request per sol.
Photos []ManifestPhoto `json:"photos"`
}
MissionManifest represents rover mission details. MarsMissionManifest fills in a partial manifest: Photos is always empty.
func MarsMissionManifest ¶
func MarsMissionManifest(p ParamEncoder, rover Rover) (MissionManifest, error)
MarsMissionManifest returns a partial mission manifest for the rover, fetched live (see RoverPhoto for the sources). See MissionManifest for which fields are populated.
Curiosity, Perseverance, Opportunity and Spirit are supported. A custom Rover returns ErrorRoverUnsupported.
type ParamEncoder ¶
ParamEncoder is the interface passed to most API methods.
type Quaternions ¶
type Quaternions struct {
Q0 float64 `json:"q0"`
Q1 float64 `json:"q1"`
Q2 float64 `json:"q2"`
Q3 float64 `json:"q3"`
}
Quaternions represents spacecraft attitude quaternions. EPIC responses embed this orientation information for the DSCOVR spacecraft.
type Rover ¶
type Rover struct {
Name string
Slug string
Cameras []RoverCamera
LandingDate time.Time
LaunchDate time.Time
Status string
}
Rover represents a Mars rover. Use the predefined Rover* values when calling MarsRoverPhotos or MarsMissionManifest to avoid constructing your own instance.
type RoverCamera ¶
RoverCamera represents a rover camera type. Refer to the exported RoverCamera* variables for valid camera selections per rover.
type RoverPhoto ¶
type RoverPhoto struct {
// ID is the feed's numeric image ID. Only Curiosity provides one; it is 0 for the
// other rovers.
ID int `json:"id"`
// ImageID is the source's image identifier, available for every rover. For Opportunity
// and Spirit it is the PDS product ID.
ImageID string `json:"image_id"`
Sol int `json:"sol"`
Image string `json:"img_src"`
// EarthDate is the UTC calendar date of TakenAt.
EarthDate Date `json:"earth_date"`
// TakenAt is when the image was captured, in UTC.
TakenAt time.Time `json:"taken_at"`
Camera struct {
// ID and RoverID were database IDs in the retired API and are always 0.
ID int `json:"id"`
Name string `json:"name"`
FullName string `json:"full_name"`
RoverID int `json:"rover_id"`
// Instrument is the source's own instrument name, such as "NAV_LEFT_B". Opportunity
// and Spirit report FRONT_HAZCAM, REAR_HAZCAM, NAVCAM, PANCAM or MI. Photos from
// instruments that do not belong to one of the rover's RoverCameras use it as
// their Name and FullName.
Instrument string `json:"instrument"`
} `json:"camera"`
// Rover describes the rover that took the photo. ID, MaxSol, MaxDate and TotalPhotos
// are not populated; use MarsMissionManifest for mission statistics.
Rover struct {
ID int `json:"id"`
Name string `json:"name"`
LandingDate Date `json:"landing_date"`
LaunchDate Date `json:"launch_date"`
Status string `json:"status"`
MaxSol int `json:"max_sol"`
MaxDate Date `json:"max_date"`
TotalPhotos int `json:"total_photos"`
Cameras []struct {
Name string `json:"name"`
FullName string `json:"full_name"`
} `json:"cameras"`
} `json:"rover"`
}
RoverPhoto represents a single full-frame Mars rover image, fetched live from NASA's raw image feeds (Curiosity and Perseverance) or the PDS Imaging Atlas (Opportunity and Spirit).
func MarsRoverPhotosLatest ¶
func MarsRoverPhotosLatest(p ParamEncoder, rover Rover) ([]*RoverPhoto, error)
MarsRoverPhotosLatest returns the full-frame photos from the most recent sol that has any, fetched live (see RoverPhoto for the sources). The Camera and Page fields of MarsPhotosParams are applied to that sol; Sol and EarthDate are ignored.
Curiosity, Perseverance, Opportunity and Spirit are supported. A custom Rover returns ErrorRoverUnsupported.
type RoverPhotos ¶
type RoverPhotos struct {
Photos []*RoverPhoto `json:"photos"`
Page int
Total int
}
RoverPhotos wraps an array of RoverPhoto pointers along with the requested page number and the total number of matching photos across all pages. Use MarsRoverPhotos to populate this type.
func MarsRoverPhotos ¶
func MarsRoverPhotos(p ParamEncoder, rover Rover) (RoverPhotos, error)
MarsRoverPhotos returns full-frame photos for the given MarsPhotosParams and Rover, fetched live (see RoverPhoto for the sources). Photos are selected by EarthDate (the UTC date each image was captured) when it is set, otherwise by Sol, and can be narrowed to one Camera. A Page of 1 or more returns that page of 25 photos; otherwise every matching photo is returned.
Curiosity, Perseverance, Opportunity and Spirit are supported. A custom Rover returns ErrorRoverUnsupported.
type StringList ¶ added in v0.3.1
type StringList []string
StringList is a []string that also accepts a single JSON string, which some metadata fields use when they hold only one value.
func (*StringList) UnmarshalJSON ¶ added in v0.3.1
func (l *StringList) UnmarshalJSON(b []byte) error
UnmarshalJSON unmarshals either a JSON string or an array of strings.