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 / format / vnext / model.go
model.go 10.0K
1package vnext23// Volume is the durable subject of one Atlas file.4type Volume struct {5 ID string6 Title string7 Worlds []World8 Assets []Asset9}1011// World is one coherent spatial environment or snapshot.12type World struct {13 ID string14 Title string15 CoordinateSpace CoordinateSpace16 Claims []Property17 FeatureSets []FeatureSet18 RasterPyramids []RasterPyramid19 Presentation Presentation20}2122// CoordinateSpace is the authoritative offline frame for a world.23type CoordinateSpace struct {24 ID string25 Kind string26 Unit string27 Definition string28 Extent [4]float6429 SourceZoom int6430 OriginX int6431 OriginY int6432 // FirstTile is deprecated. OriginX and OriginY are authoritative in the33 // native format; this source-only field exists until all callers migrate.34 FirstTile int6435 TileSize int6436 Size int6437}3839// FeatureSet carries semantic membership and its typed property contract.40type FeatureSet struct {41 ID string42 Title string43 SemanticType string44 Properties []Field45 Claims []Property46 Features []Feature47}4849// Feature separates spatial facts, typed claims, relationships, and evidence.50type Feature struct {51 ID string52 Title string53 Subtitle string54 Description string55 Center *Position56 Shard int6457 Geometry Geometry58 Properties []Property59 Relationships []Relationship60 Provenance []Provenance61}6263// GeometryKind identifies the interpretation of a coordinate sequence.64type GeometryKind uint86566const (67 GeometryPoint GeometryKind = iota + 168 GeometryLineString69 GeometryPolygon70)7172// Position is one x,y pair in a world's CoordinateSpace.73type Position [2]float647475// GeometryPart is one point, line, or polygon. Lines carry one ring; polygons76// carry an exterior ring followed by any holes.77type GeometryPart struct {78 Rings [][]Position79}8081// Geometry holds every part of a point, multi-line, or multi-polygon without82// flattening away the boundaries between pieces and holes.83type Geometry struct {84 Kind GeometryKind85 Parts []GeometryPart86}8788// Property is one typed feature claim identified independently of its label.89type Property struct {90 FieldID ID91 Field Field92 Value Value93}9495func (property Property) fieldID() ID {96 if !property.FieldID.isZero() {97 return property.FieldID98 }99 return property.Field.ID100}101102// Relationship is a first-class edge to another entity.103type Relationship struct {104 Predicate string105 Target string106}107108// Provenance records where a claim or feature came from.109type Provenance struct {110 Source string111 NativeID string112 CapturedAt string113}114115// RasterPyramid describes an offline tile matrix whose bytes remain opaque.116type RasterPyramid struct {117 ID string118 Name string119 Codec string120 TileSize int64121 MinZoom int64122 MaxZoom int64123 FullZoom int64124 SourceZoom int64125 Template string126 Formats []string127 Bounds *RasterRect128 Surface *RasterRect129 Interpolate bool130 Background string131 Shard int64132 Coverage []RasterCoverage133}134135type RasterRect struct {136 X float64137 Y float64138 Width float64139 Height float64140}141142type RasterCoverage struct {143 Zoom int64144 X int64145 Y int64146 W int64147 H int64148 Bits []byte149}150151// Presentation is replaceable render intent over semantic feature sets.152type Presentation struct {153 ID string154 Title string155 Layers []Layer156 Styles []Style157 Legend []LegendEntry158}159160// Layer selects a FeatureSet and applies one Style over a visibility range.161type Layer struct {162 ID string163 FeatureSet string164 Style string165 Group string166 LabelPolicy string167 Visible bool168 Order int64169 MinZoom int64170 MaxZoom int64171}172173// Style names the appearance of a layer without changing feature meaning.174type Style struct {175 ID string176 Symbol string177 Icon string178 IconAsset string179 IconPicture bool180 RenderAs string181 Stroke string182 Fill string183}184185// LegendEntry gives a layer its presented label and order.186type LegendEntry struct {187 Layer string188 Label string189 Order int64190}191192// Asset is a content-bearing supporting blob.193type Asset struct {194 ID string195 MediaType string196 Path string197 Data []byte198 Provenance string199}200201func coreField(name string, kind Kind, optional bool) Field {202 return Field{ID: CoreID(name), Name: name, Kind: kind, Optional: optional}203}204205func coreType(name string, fields ...Field) Type {206 return Type{ID: CoreID("type." + name), Name: name, Fields: fields}207}208209// StandardSchema is the Atlas-owned vocabulary. Extensions union into these210// types by ID and require no format release or central allocation.211func StandardSchema() Schema {212 return canonicalSchema(Schema{Types: []Type{213 coreType("volume",214 coreField("volume.id", KindString, false),215 coreField("volume.title", KindString, false)),216 coreType("world",217 coreField("world.id", KindString, false),218 coreField("world.title", KindString, false),219 coreField("world.coordinateSpace", KindString, false)),220 coreType("coordinate",221 coreField("coordinate.id", KindString, false),222 coreField("coordinate.world", KindString, false),223 coreField("coordinate.kind", KindString, false),224 coreField("coordinate.unit", KindString, false),225 coreField("coordinate.definition", KindString, false),226 coreField("coordinate.extent", KindBytes, false),227 coreField("coordinate.sourceZoom", KindInt64, false),228 coreField("coordinate.originX", KindInt64, false),229 coreField("coordinate.originY", KindInt64, false),230 coreField("coordinate.tileSize", KindInt64, false),231 coreField("coordinate.size", KindInt64, false)),232 coreType("featureSet",233 coreField("featureSet.id", KindString, false),234 coreField("featureSet.world", KindString, false),235 coreField("featureSet.title", KindString, false),236 coreField("featureSet.semanticType", KindString, false)),237 coreType("propertyDefinition",238 coreField("propertyDefinition.featureSet", KindString, false),239 coreField("propertyDefinition.field", KindID, false),240 coreField("propertyDefinition.name", KindString, false),241 coreField("propertyDefinition.kind", KindInt64, false),242 coreField("propertyDefinition.optional", KindBool, false)),243 coreType("feature",244 coreField("feature.id", KindString, false),245 coreField("feature.featureSet", KindString, false),246 coreField("feature.title", KindString, false),247 coreField("feature.subtitle", KindString, true),248 coreField("feature.description", KindString, true),249 coreField("feature.center", KindBytes, true),250 coreField("feature.shard", KindInt64, false),251 coreField("feature.geometry", KindBytes, false)),252 coreType("relationship",253 coreField("relationship.feature", KindString, false),254 coreField("relationship.predicate", KindString, false),255 coreField("relationship.target", KindString, false)),256 coreType("provenance",257 coreField("provenance.feature", KindString, false),258 coreField("provenance.source", KindString, false),259 coreField("provenance.nativeID", KindString, false),260 coreField("provenance.capturedAt", KindString, false)),261 coreType("rasterPyramid",262 coreField("rasterPyramid.id", KindString, false),263 coreField("rasterPyramid.world", KindString, false),264 coreField("rasterPyramid.name", KindString, false),265 coreField("rasterPyramid.codec", KindString, false),266 coreField("rasterPyramid.tileSize", KindInt64, false),267 coreField("rasterPyramid.minZoom", KindInt64, false),268 coreField("rasterPyramid.maxZoom", KindInt64, false),269 coreField("rasterPyramid.fullZoom", KindInt64, false),270 coreField("rasterPyramid.sourceZoom", KindInt64, false),271 coreField("rasterPyramid.template", KindString, false),272 coreField("rasterPyramid.bounds", KindBytes, true),273 coreField("rasterPyramid.surface", KindBytes, true),274 coreField("rasterPyramid.interpolate", KindBool, false),275 coreField("rasterPyramid.background", KindString, true),276 coreField("rasterPyramid.shard", KindInt64, false)),277 coreType("rasterFormat",278 coreField("rasterFormat.raster", KindString, false),279 coreField("rasterFormat.zoom", KindInt64, false),280 coreField("rasterFormat.format", KindString, false)),281 coreType("rasterCoverage",282 coreField("rasterCoverage.raster", KindString, false),283 coreField("rasterCoverage.zoom", KindInt64, false),284 coreField("rasterCoverage.x", KindInt64, false),285 coreField("rasterCoverage.y", KindInt64, false),286 coreField("rasterCoverage.w", KindInt64, false),287 coreField("rasterCoverage.h", KindInt64, false),288 coreField("rasterCoverage.bits", KindBytes, false)),289 coreType("presentation",290 coreField("presentation.id", KindString, false),291 coreField("presentation.world", KindString, false),292 coreField("presentation.title", KindString, false)),293 coreType("style",294 coreField("style.id", KindString, false),295 coreField("style.presentation", KindString, false),296 coreField("style.symbol", KindString, true),297 coreField("style.icon", KindString, true),298 coreField("style.iconAsset", KindString, true),299 coreField("style.iconPicture", KindBool, false),300 coreField("style.renderAs", KindString, true),301 coreField("style.stroke", KindString, true),302 coreField("style.fill", KindString, true)),303 coreType("layer",304 coreField("layer.id", KindString, false),305 coreField("layer.presentation", KindString, false),306 coreField("layer.featureSet", KindString, false),307 coreField("layer.style", KindString, false),308 coreField("layer.group", KindString, true),309 coreField("layer.labelPolicy", KindString, true),310 coreField("layer.visible", KindBool, false),311 coreField("layer.order", KindInt64, false),312 coreField("layer.minZoom", KindInt64, false),313 coreField("layer.maxZoom", KindInt64, false)),314 coreType("legend",315 coreField("legend.presentation", KindString, false),316 coreField("legend.layer", KindString, false),317 coreField("legend.label", KindString, false),318 coreField("legend.order", KindInt64, false)),319 coreType("asset",320 coreField("asset.id", KindString, false),321 coreField("asset.mediaType", KindString, false),322 coreField("asset.path", KindString, false),323 coreField("asset.provenance", KindString, true)),324 }})325}