1package nasatrek23import "sort"45// The archived capture, as the crawler wrote it. A Trek capture marries two6// public NASA/USGS publications that know nothing of each other: a global7// equirectangular mosaic served by NASA's Trek tile services, and the IAU8// Gazetteer of Planetary Nomenclature's feature list for the same body. Its9// fields are declared in the order they marshal, and Normalize sorts its lists,10// so the Gazetteer listing its features differently does not masquerade as a new11// capture.1213type capture struct {14 Source string `json:"source"`15 Body string `json:"body"`16 Layer string `json:"layer"`17 MapSlug string `json:"mapSlug"`18 MapTitle string `json:"mapTitle"`19 Map mosaic `json:"map"`20 Variants []variant `json:"variants,omitempty"`21 Features []feature `json:"features"`22}2324// mosaic is the pyramid as captured. MaxZoom counts in the square world -- the25// deepest level actually taken, one above the Trek level it came from, because a26// Trek mosaic is two tiles wide and one tall where the square is one and one.27// LayerTitle names the mosaic the way a person knows it, which is what a lens28// picker shows.29type mosaic struct {30 MaxZoom int `json:"maxZoom"`31 Extension string `json:"extension"`32 LayerTitle string `json:"layerTitle"`33}3435// variant is a sibling mosaic of the same ground: another way of seeing the36// body, elevation beside photograph, captured into the same window. Its pyramid37// is its own; siblings need not agree on depth.38type variant struct {39 Layer string `json:"layer"`40 Title string `json:"title"`41 MaxZoom int `json:"maxZoom"`42 Extension string `json:"extension"`43}4445// feature is one Gazetteer entry as the feature list publishes it: the IAU's own46// identifier, planetocentric latitude, east-positive longitude in the47// Gazetteer's 0..360 spelling, diameter in kilometres, and the origin text48// explaining the name -- the one piece of prose the data carries.49type feature struct {50 ID int64 `json:"id"`51 Name string `json:"name"`52 Type string `json:"type"`53 Code string `json:"code"`54 Latitude float64 `json:"latitude"`55 Longitude float64 `json:"longitude"`56 DiameterKM float64 `json:"diameterKm"`57 Origin string `json:"origin,omitempty"`58}5960// normalize puts a capture into its canonical order. The crawler does this61// before archiving; the reader does it again because an archive holds captures62// older than the habit.63func (c *capture) normalize() {64 sort.Slice(c.Variants, func(a, b int) bool { return c.Variants[a].Layer < c.Variants[b].Layer })65 sort.Slice(c.Features, func(a, b int) bool { return c.Features[a].ID < c.Features[b].ID })66}