Skip to content

Commit

Permalink
golang conventions on enum
Browse files Browse the repository at this point in the history
  • Loading branch information
nathreed committed May 17, 2024
1 parent ae71daf commit b5d75ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions mbtiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ type MbTilesMetadata map[string]string
type MbTilesFormat string

const (
Pbf MbTilesFormat = "pbf"
Jpg MbTilesFormat = "jpg"
Png MbTilesFormat = "png"
WebP MbTilesFormat = "webp"
MbTilesFormatPbf MbTilesFormat = "pbf"
MbTilesFormatJpg MbTilesFormat = "jpg"
MbTilesFormatPng MbTilesFormat = "png"
MbTilesFormatWebP MbTilesFormat = "webp"
)

type CreateMetadataOptions struct {
Expand All @@ -32,7 +32,7 @@ type CreateMetadataOptions struct {
func CreateMetadata(tj *TileJSON, opts CreateMetadataOptions) MbTilesMetadata {
format := opts.Format
if string(format) == "" {
format = Pbf
format = MbTilesFormatPbf
}
meta := MbTilesMetadata{
"name": tj.Name,
Expand Down Expand Up @@ -76,7 +76,7 @@ func CreateMetadata(tj *TileJSON, opts CreateMetadataOptions) MbTilesMetadata {
}

// mbtiles spec requires the json field for vector format and it's not meaningful for rasters
if opts.Format == Pbf {
if opts.Format == MbTilesFormatPbf {
metaJSONField := CreateMetadataJSON(tj)
if metaJSONBytes, err := json.Marshal(metaJSONField); err == nil {
meta["json"] = string(metaJSONBytes)
Expand Down
2 changes: 1 addition & 1 deletion writers.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func NewWriters(args Args, tj *TileJSON) (writer TileWriter, bulkWriter TileBulk
meta := CreateMetadata(tj, CreateMetadataOptions{
Filename: args.TileJSON,
Version: args.Version,
Format: Pbf,
Format: MbTilesFormatPbf,
})
err = mbWriter.BulkWriteMetadata(meta)
return
Expand Down

0 comments on commit b5d75ed

Please sign in to comment.