Skip to content

Commit

Permalink
default download threads to 4; fix tests [#68]
Browse files Browse the repository at this point in the history
  • Loading branch information
bdon committed Sep 11, 2023
1 parent 5f2877e commit fabb2b9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var cli struct {
Bucket string `help:"Remote bucket of input archive."`
Region string `help:"local GeoJSON Polygon or MultiPolygon file for area of interest." type:"existingfile"`
Maxzoom uint8 `help:"Maximum zoom level, inclusive."`
DownloadThreads int `default:1 help:"Number of download threads."`
DownloadThreads int `default:4 help:"Number of download threads."`
DryRun bool `help:"Calculate tiles to extract, but don't download them."`
Overfetch float32 `default:0.1 help:"What ratio of extra data to download to minimize # requests; 0.2 is 20%"`
} `cmd:"" help:"Create an archive from a larger archive for a subset of zoom levels or geographic region."`
Expand Down
26 changes: 15 additions & 11 deletions pmtiles/extract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,15 @@ func TestMergeRanges(t *testing.T) {
ranges = append(ranges, SrcDstRange{0, 0, 50})
ranges = append(ranges, SrcDstRange{60, 60, 60})

result := MergeRanges(ranges, 0.1)

assert.Equal(t, 1, len(result))
assert.Equal(t, SrcDstRange{0, 0, 120}, result[0].Rng)
assert.Equal(t, 2, len(result[0].CopyDiscards))
assert.Equal(t, CopyDiscard{50, 10}, result[0].CopyDiscards[0])
assert.Equal(t, CopyDiscard{60, 0}, result[0].CopyDiscards[1])
result, total_transfer_bytes := MergeRanges(ranges, 0.1)

assert.Equal(t, 1, result.Len())
assert.Equal(t, uint64(120), total_transfer_bytes)
front := result.Front().Value.(OverfetchRange)
assert.Equal(t, SrcDstRange{0, 0, 120}, front.Rng)
assert.Equal(t, 2, len(front.CopyDiscards))
assert.Equal(t, CopyDiscard{50, 10}, front.CopyDiscards[0])
assert.Equal(t, CopyDiscard{60, 0}, front.CopyDiscards[1])
}

func TestMergeRangesMultiple(t *testing.T) {
Expand All @@ -156,9 +158,11 @@ func TestMergeRangesMultiple(t *testing.T) {
ranges = append(ranges, SrcDstRange{60, 60, 10})
ranges = append(ranges, SrcDstRange{80, 80, 10})

result := MergeRanges(ranges, 0.3)
assert.Equal(t, 1, len(result))
assert.Equal(t, SrcDstRange{0, 0, 90}, result[0].Rng)
assert.Equal(t, 3, len(result[0].CopyDiscards))
result, total_transfer_bytes := MergeRanges(ranges, 0.3)
front := result.Front().Value.(OverfetchRange)
assert.Equal(t, uint64(90), total_transfer_bytes)
assert.Equal(t, 1, result.Len())
assert.Equal(t, SrcDstRange{0, 0, 90}, front.Rng)
assert.Equal(t, 3, len(front.CopyDiscards))
fmt.Println(result)
}

0 comments on commit fabb2b9

Please sign in to comment.