package model type VectorLayer struct { ID string `json:"id"` Fields map[string]string `json:"fields"` Description string `json:"description,omitempty"` Minzoom *int `json:"minzoom,omitempty"` Maxzoom *int `json:"maxzoom,omitempty"` } type TileJSON struct { TileJSON string `json:"tilejson"` Tiles []string `json:"tiles"` VectorLayers []VectorLayer `json:"vector_layers"` Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` Version string `json:"version,omitempty"` Attribution string `json:"attribution,omitempty"` Scheme string `json:"scheme,omitempty"` MinZoom *int `json:"minzoom,omitempty"` MaxZoom *int `json:"maxzoom,omitempty"` Bounds []float64 `json:"bounds,omitempty"` Center []float64 `json:"center,omitempty"` FillZoom *int `json:"fillZoom,omitempty"` Grids []string `json:"grids,omitempty"` Data []string `json:"data,omitempty"` Legend string `json:"legend,omitempty"` Format string `json:"format,omitempty"` } func NewVectorLayer(id string, fields map[string]string, opts ...func(*VectorLayer)) VectorLayer { layer := VectorLayer{ ID: id, Fields: fields, } for _, opt := range opts { opt(&layer) } return layer } func WithVectorLayerDescription(description string) func(*VectorLayer) { return func(v *VectorLayer) { v.Description = description } } func WithVectorLayerMinzoom(minzoom int) func(*VectorLayer) { return func(v *VectorLayer) { v.Minzoom = &minzoom } } func WithVectorLayerMaxzoom(maxzoom int) func(*VectorLayer) { return func(v *VectorLayer) { v.Maxzoom = &maxzoom } } func NewTileJSON(tiles []string, VectorLayers []VectorLayer, opts ...func(*TileJSON)) TileJSON { tileJSON := TileJSON{ TileJSON: "3.0.0", Tiles: tiles, VectorLayers: VectorLayers, } for _, opt := range opts { opt(&tileJSON) } return tileJSON } func WithTileJSONName(name string) func(*TileJSON) { return func(t *TileJSON) { t.Name = name } } func WithTileJSONDescription(description string) func(*TileJSON) { return func(t *TileJSON) { t.Description = description } } func WithTileJSONVersion(version string) func(*TileJSON) { return func(t *TileJSON) { t.Version = version } } func WithTileJSONAttribution(attribution string) func(*TileJSON) { return func(t *TileJSON) { t.Attribution = attribution } } func WithTileJSONScheme(scheme string) func(*TileJSON) { return func(t *TileJSON) { t.Scheme = scheme } } func WithTileJSONFormat(format string) func(*TileJSON) { return func(t *TileJSON) { t.Format = format } } func WithTileJSONBounds(bounds []float64) func(*TileJSON) { return func(t *TileJSON) { t.Bounds = bounds } } func WithTileJSONCenter(center []float64) func(*TileJSON) { return func(t *TileJSON) { t.Center = center } } func WithTileJSONFillZoom(fillZoom int) func(*TileJSON) { return func(t *TileJSON) { t.FillZoom = &fillZoom } } func WithTileJSONGrids(grids []string) func(*TileJSON) { return func(t *TileJSON) { t.Grids = grids } } func WithTileJSONData(data []string) func(*TileJSON) { return func(t *TileJSON) { t.Data = data } } func WithTileJSONLegend(legend string) func(*TileJSON) { return func(t *TileJSON) { t.Legend = legend } } func WithTileJSONMinZoom(minZoom int) func(*TileJSON) { return func(t *TileJSON) { t.MinZoom = &minZoom } } func WithTileJSONMaxZoom(maxZoom int) func(*TileJSON) { return func(t *TileJSON) { t.MaxZoom = &maxZoom } }