clone

an offline map explorer where each world, from a game map to a city's open data, ships as one .atlas file

feat/atlas-next-horizon
atlas / internal / generate / sources / mapgenie / capture.go
capture.go 4.1K
1package mapgenie23import "encoding/json"45// The archived capture, as MapGenie's map endpoint spells it. These are the6// only declarations in Atlas that carry MapGenie's field names, and they carry7// them because bytes on disk are not negotiable: the archive holds years of8// responses in exactly this shape, and reading them means naming their fields.9//10// Only what the interchange document needs is declared. A capture holds a great11// deal else -- marketing copy, asset URLs, tracking configuration, an embedded12// copy of the game record on every map -- and the way to keep it out of Atlas is13// to not have a field for it.1415type rawMap struct {16 ID int64 `json:"id"`17 Title string `json:"title"`18 Slug string `json:"slug"`19 InitialLatitude float64 `json:"initial_latitude"`20 InitialLongitude float64 `json:"initial_longitude"`21 Config rawConfig `json:"config"`22 Game rawGame `json:"game"`23 Groups []rawGroup `json:"groups"`24 Regions []rawRegion `json:"regions"`25}2627type rawGame struct {28 ID int64 `json:"id"`29 Title string `json:"title"`30 Slug string `json:"slug"`31}3233type rawConfig struct {34 TileSets []rawTileSet `json:"tile_sets"`35}3637// rawTileSet names one raster of a map. Its zoom range, bounds and encoding38// reach the document only as the deriver's frame: what a bundle carries is the39// derived pyramid's account of itself, never the publisher's account of what it40// offered, but only the publisher can say which tiles a complete level was41// supposed to hold.42type rawTileSet struct {43 Name string `json:"name"`44 Path string `json:"path"`45 MinZoom int `json:"min_zoom"`46 MaxZoom int `json:"max_zoom"`47 Extension string `json:"extension"`48 Bounds map[string]rawBound `json:"bounds"`49}5051type rawBound struct {52 X rawRange `json:"x"`53 Y rawRange `json:"y"`54}5556type rawRange struct {57 Min int `json:"min"`58 Max int `json:"max"`59}6061// rawGroup is a legend section. It is a heading and a colour default, and62// nothing hangs off it that a category does not restate.63type rawGroup struct {64 ID int64 `json:"id"`65 Title string `json:"title"`66 Color string `json:"color"`67 IconColor string `json:"icon_color"`68 Categories []rawCategory `json:"categories"`69}7071// rawCategory is one legend row, one point layer and one icon slot at once.72type rawCategory struct {73 ID int64 `json:"id"`74 Title string `json:"title"`75 // Icon is a key into the archived artwork, not a file name.76 Icon string `json:"icon"`77 Color string `json:"color"`78 IconColor string `json:"icon_color"`79 // DisplayType is MapGenie's own render field. It reaches exactly one line of80 // this package, where it is spoken as atlas.render.as, and goes no further.81 DisplayType string `json:"display_type"`82 Visible bool `json:"visible"`83 Locations []rawLocation `json:"locations"`84}8586type rawLocation struct {87 ID int64 `json:"id"`88 Title string `json:"title"`89 Description string `json:"description"`90 // Coordinates arrive as JSON numbers on some maps and as quoted strings on91 // others, so they are held raw and read by number.92 Latitude json.RawMessage `json:"latitude"`93 Longitude json.RawMessage `json:"longitude"`94 // RegionID is the region whose ground this pin stands on.95 RegionID *int64 `json:"region_id"`96}9798// rawRegion is a named piece of ground, standing outside the legend entirely.99type rawRegion struct {100 ID int64 `json:"id"`101 Title string `json:"title"`102 Subtitle string `json:"subtitle"`103 Description string `json:"description"`104 ParentRegionID *int64 `json:"parent_region_id"`105 CenterX json.RawMessage `json:"center_x"`106 CenterY json.RawMessage `json:"center_y"`107 Features []rawFeature `json:"features"`108}109110type rawFeature struct {111 Geometry rawGeometry `json:"geometry"`112}113114type rawGeometry struct {115 Type string `json:"type"`116 Coordinates json.RawMessage `json:"coordinates"`117}