-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: Allow to use interactive Datasets in unsafe_gdal functions in utilities.jl #167
Changes from all commits
8e59060
430c0fc
7d17803
3e6c9ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
""" | ||
gdalinfo(dataset::Dataset, options = String[]) | ||
gdalinfo(dataset::AbstractDataset, options = String[]) | ||
|
||
List various information about a GDAL supported raster dataset. | ||
|
||
|
@@ -11,15 +11,15 @@ List various information about a GDAL supported raster dataset. | |
### Returns | ||
String corresponding to the information about the raster dataset. | ||
""" | ||
function gdalinfo(dataset::Dataset, options = String[]) | ||
function gdalinfo(dataset::AbstractDataset, options = String[]) | ||
options = GDAL.gdalinfooptionsnew(options, C_NULL) | ||
result = GDAL.gdalinfo(dataset.ptr, options) | ||
GDAL.gdalinfooptionsfree(options) | ||
return result | ||
end | ||
|
||
""" | ||
unsafe_gdaltranslate(dataset::Dataset, options = String[]; dest = "/vsimem/tmp") | ||
unsafe_gdaltranslate(dataset::AbstractDataset, options = String[]; dest = "/vsimem/tmp") | ||
|
||
Convert raster data between different formats. | ||
|
||
|
@@ -32,19 +32,19 @@ Convert raster data between different formats. | |
The output dataset. | ||
""" | ||
function unsafe_gdaltranslate( | ||
dataset::Dataset, | ||
dataset::T, | ||
options = String[]; | ||
dest = "/vsimem/tmp" | ||
) | ||
) where {T<:AbstractDataset} | ||
options = GDAL.gdaltranslateoptionsnew(options, C_NULL) | ||
usage_error = Ref{Cint}() | ||
result = GDAL.gdaltranslate(dest, dataset.ptr, options, usage_error) | ||
GDAL.gdaltranslateoptionsfree(options) | ||
return Dataset(result) | ||
return T(result) | ||
end | ||
|
||
""" | ||
unsafe_gdalwarp(datasets::Vector{Dataset}, options = String[]; dest = "/vsimem/tmp") | ||
unsafe_gdalwarp(datasets::Vector{<:AbstractDataset}, options = String[]; dest = "/vsimem/tmp") | ||
|
||
Image reprojection and warping function. | ||
|
||
|
@@ -57,20 +57,20 @@ Image reprojection and warping function. | |
The output dataset. | ||
""" | ||
function unsafe_gdalwarp( | ||
datasets::Vector{Dataset}, | ||
datasets::Vector{T}, | ||
options = String[]; | ||
dest = "/vsimem/tmp" | ||
) | ||
) where T<:AbstractDataset | ||
options = GDAL.gdalwarpappoptionsnew(options, C_NULL) | ||
usage_error = Ref{Cint}() | ||
result = GDAL.gdalwarp(dest, C_NULL, | ||
length(datasets), [ds.ptr for ds in datasets], options, usage_error) | ||
GDAL.gdalwarpappoptionsfree(options) | ||
return Dataset(result) | ||
return T(result) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should still be |
||
end | ||
|
||
""" | ||
unsafe_gdalvectortranslate(datasets::Vector{Dataset}, options = String[]; dest = "/vsimem/tmp") | ||
unsafe_gdalvectortranslate(datasets::Vector{<:AbstractDataset}, options = String[]; dest = "/vsimem/tmp") | ||
|
||
Convert vector data between file formats. | ||
|
||
|
@@ -83,20 +83,20 @@ Convert vector data between file formats. | |
The output dataset. | ||
""" | ||
function unsafe_gdalvectortranslate( | ||
datasets::Vector{Dataset}, | ||
datasets::Vector{T}, | ||
options = String[]; | ||
dest = "/vsimem/tmp" | ||
) | ||
) where T<:AbstractDataset | ||
options = GDAL.gdalvectortranslateoptionsnew(options, C_NULL) | ||
usage_error = Ref{Cint}() | ||
result = GDAL.gdalvectortranslate(dest, C_NULL, length(datasets), | ||
[ds.ptr for ds in datasets], options, usage_error) | ||
GDAL.gdalvectortranslateoptionsfree(options) | ||
return Dataset(result) | ||
return T(result) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should still be |
||
end | ||
|
||
""" | ||
unsafe_gdaldem(dataset::Dataset, processing::String, options = String[]; dest = "/vsimem/tmp", colorfile) | ||
unsafe_gdaldem(dataset::AbstractDataset, processing::String, options = String[]; dest = "/vsimem/tmp", colorfile) | ||
|
||
Tools to analyze and visualize DEMs. | ||
|
||
|
@@ -115,12 +115,12 @@ Tools to analyze and visualize DEMs. | |
The output dataset. | ||
""" | ||
function unsafe_gdaldem( | ||
dataset::Dataset, | ||
dataset::T, | ||
processing::String, | ||
options = String[]; | ||
dest = "/vsimem/tmp", | ||
colorfile = C_NULL | ||
) | ||
) where T<:AbstractDataset | ||
if processing == "color-relief" | ||
@assert colorfile != C_NULL | ||
end | ||
|
@@ -129,11 +129,11 @@ function unsafe_gdaldem( | |
result = GDAL.gdaldemprocessing(dest, dataset.ptr, processing, colorfile, | ||
options, usage_error) | ||
GDAL.gdaldemprocessingoptionsfree(options) | ||
return Dataset(result) | ||
return T(result) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should still be |
||
end | ||
|
||
""" | ||
unsafe_gdalnearblack(dataset::Dataset, options = String[]; dest = "/vsimem/tmp") | ||
unsafe_gdalnearblack(dataset::AbstractDataset, options = String[]; dest = "/vsimem/tmp") | ||
|
||
Convert nearly black/white borders to exact value. | ||
|
||
|
@@ -146,19 +146,19 @@ Convert nearly black/white borders to exact value. | |
The output dataset. | ||
""" | ||
function unsafe_gdalnearblack( | ||
dataset::Dataset, | ||
dataset::T, | ||
options = String[]; | ||
dest = "/vsimem/tmp" | ||
) | ||
) where T<:AbstractDataset | ||
options = GDAL.gdalnearblackoptionsnew(options, C_NULL) | ||
usage_error = Ref{Cint}() | ||
result = GDAL.gdalnearblack(dest, C_NULL, dataset.ptr, options, usage_error) | ||
GDAL.gdalnearblackoptionsfree(options) | ||
return Dataset(result) | ||
return T(result) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should still be |
||
end | ||
|
||
""" | ||
unsafe_gdalgrid(dataset::Dataset, options = String[]; dest = "/vsimem/tmp") | ||
unsafe_gdalgrid(dataset::AbstractDataset, options = String[]; dest = "/vsimem/tmp") | ||
|
||
Create a raster from the scattered data. | ||
|
||
|
@@ -171,19 +171,19 @@ Create a raster from the scattered data. | |
The output dataset. | ||
""" | ||
function unsafe_gdalgrid( | ||
dataset::Dataset, | ||
dataset::T, | ||
options = String[]; | ||
dest = "/vsimem/tmp" | ||
) | ||
) where T<:AbstractDataset | ||
options = GDAL.gdalgridoptionsnew(options, C_NULL) | ||
usage_error = Ref{Cint}() | ||
result = GDAL.gdalgrid(dest, dataset.ptr, options, usage_error) | ||
GDAL.gdalgridoptionsfree(options) | ||
return Dataset(result) | ||
return T(result) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should still be |
||
end | ||
|
||
""" | ||
unsafe_gdalrasterize(dataset::Dataset, options = String[]; dest = "/vsimem/tmp") | ||
unsafe_gdalrasterize(dataset::AbstractDataset, options = String[]; dest = "/vsimem/tmp") | ||
|
||
Burn vector geometries into a raster. | ||
|
||
|
@@ -196,19 +196,19 @@ Burn vector geometries into a raster. | |
The output dataset. | ||
""" | ||
function unsafe_gdalrasterize( | ||
dataset::Dataset, | ||
dataset::T, | ||
options = String[]; | ||
dest = "/vsimem/tmp" | ||
) | ||
) where T<:AbstractDataset | ||
options = GDAL.gdalrasterizeoptionsnew(options, C_NULL) | ||
usage_error = Ref{Cint}() | ||
result = GDAL.gdalrasterize(dest, C_NULL, dataset.ptr, options, usage_error) | ||
GDAL.gdalrasterizeoptionsfree(options) | ||
return Dataset(result) | ||
return T(result) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should still be |
||
end | ||
|
||
""" | ||
unsafe_gdalbuildvrt(datasets::Vector{Dataset}, options = String[]; dest = "/vsimem/tmp") | ||
unsafe_gdalbuildvrt(datasets::Vector{<:AbstractDataset}, options = String[]; dest = "/vsimem/tmp") | ||
|
||
Build a VRT from a list of datasets. | ||
|
||
|
@@ -221,14 +221,14 @@ Build a VRT from a list of datasets. | |
The output dataset. | ||
""" | ||
function unsafe_gdalbuildvrt( | ||
datasets::Vector{Dataset}, | ||
datasets::Vector{T}, | ||
options = String[]; | ||
dest = "/vsimem/tmp" | ||
) | ||
) where T <:AbstractDataset | ||
options = GDAL.gdalbuildvrtoptionsnew(options, C_NULL) | ||
usage_error = Ref{Cint}() | ||
result = GDAL.gdalbuildvrt(dest, length(datasets), | ||
[ds.ptr for ds in datasets], C_NULL, options, usage_error) | ||
GDAL.gdalbuildvrtoptionsfree(options) | ||
return Dataset(result) | ||
return T(result) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should still be |
||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should still be
Dataset(result)
rather thanT(result)
(see #167 (comment) for context).