Skip to content

Commit

Permalink
hide write command as it's not implemented yet.
Browse files Browse the repository at this point in the history
  • Loading branch information
bdon committed Sep 15, 2024
1 parent e96521b commit ca52938
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 26 deletions.
7 changes: 1 addition & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ var cli struct {
Input string `arg:"" help:"Input archive file." type:"existingfile"`
HeaderJson string `help:"Input header JSON file (written by show --header-json)." type:"existingfile"`
Metadata string `help:"Input metadata JSON (written by show --metadata)." type:"existingfile"`
} `cmd:"" help:"Write header data or metadata to an existing archive."`
} `cmd:"" help:"Write header data or metadata to an existing archive." hidden:""`

Extract struct {
Input string `arg:"" help:"Input local or remote archive."`
Expand Down Expand Up @@ -170,11 +170,6 @@ func main() {
if err != nil {
logger.Fatalf("Failed to extract, %v", err)
}
case "write <input>":
err := pmtiles.Write(logger, cli.Write.Input, cli.Write.HeaderJson, cli.Write.Metadata)
if err != nil {
logger.Fatalf("Failed to write, %v", err)
}
case "convert <input> <output>":
path := cli.Convert.Input
output := cli.Convert.Output
Expand Down
19 changes: 8 additions & 11 deletions pmtiles/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,21 @@ import (
)

func Write(logger *log.Logger, inputArchive string, newHeaderJsonFile string, newMetadataFile string) error {

if newMetadataFile == "" {
if newHeaderJsonFile == "" {
return fmt.Errorf("No data to write.")
}

// we can write the header in-place without writing the whole file.
return nil
}

// write metadata:
// always writes in this order:
// copy the header
// copy the root directory
// write the new the metadata
// copy the leaf directories
// copy the tile data
file, err := os.OpenFile(inputArchive, os.O_RDWR, 0666)

buf := make([]byte, 127)
Expand All @@ -34,12 +40,3 @@ func Write(logger *log.Logger, inputArchive string, newHeaderJsonFile string, ne
}
return nil
}


// write metadata:
// always writes in this order:
// copy the header
// copy the root directory
// write the new the metadata
// copy the leaf directories
// copy the tile data
9 changes: 0 additions & 9 deletions pmtiles/write_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package pmtiles

import (
// "log"
"os"
"io"
"io/ioutil"
Expand All @@ -11,19 +10,11 @@ import (
)

func TestWriteHeader(t *testing.T) {
// logger := log.New(os.Stdout, "", log.Ldate|log.Ltime|log.Lshortfile)

tempDir, _ := ioutil.TempDir("", "testing")
defer os.RemoveAll(tempDir)
src, _ := os.Open("fixtures/test_fixture_1.pmtiles")
defer src.Close()
dest, _ := os.Create(filepath.Join(tempDir, "test.pmtiles"))
defer dest.Close()
_, _ = io.Copy(dest, src)

assert.Nil(t, nil)

// var input map[string]interface{}
// json.Unmarshal(b.Bytes(), &input)
// assert.Equal(t, "tippecanoe v2.5.0", input["generator"])
}

0 comments on commit ca52938

Please sign in to comment.