Skip to content

Commit

Permalink
add HasVSIHandler to test if a VSIHandler is registered for a given p…
Browse files Browse the repository at this point in the history
…refix
  • Loading branch information
vincentvaroquauxads committed Sep 11, 2024
1 parent d610839 commit 89f29df
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions godal.go
Original file line number Diff line number Diff line change
Expand Up @@ -3898,6 +3898,15 @@ func RegisterVSIHandler(prefix string, handler KeySizerReaderAt, opts ...VSIHand
return nil
}

// HasVSIHandler returns true if a VSIHandler is registered for this prefix
func HasVSIHandler(prefix string) bool {
if handlers == nil {
return false
}
_, ok := handlers[prefix]
return ok
}

// BuildVRT runs the GDALBuildVRT function and creates a VRT dataset from a list of datasets
func BuildVRT(dstVRTName string, sourceDatasets []string, switches []string, opts ...BuildVRTOption) (*Dataset, error) {
bvo := buildVRTOpts{}
Expand Down
2 changes: 2 additions & 0 deletions godal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3463,11 +3463,13 @@ func (mvp mvpHandler) ReadAtMulti(k string, buf [][]byte, off []int64) ([]int, e
func TestVSIPrefix(t *testing.T) {
tifdat, _ := ioutil.ReadFile("testdata/test.tif")

assert.False(t, HasVSIHandler("prefix://"))
// stripPrefix false
vpa := vpHandler{datas: make(map[string]KeySizerReaderAt)}
vpa.datas["prefix://test.tif"] = mbufHandler{tifdat}
err := RegisterVSIHandler("prefix://", vpa, VSIHandlerStripPrefix(false))
assert.NoError(t, err)
assert.True(t, HasVSIHandler("prefix://"))

ds, err := Open("prefix://test.tif")
if err != nil {
Expand Down

0 comments on commit 89f29df

Please sign in to comment.