Opened 16 years ago
Closed 9 years ago
#2211 closed enhancement (worksforme)
Expose GDALWarpOptions for AutoCreateWarpedVRT
Reported by: | ssakharov | Owned by: | tamas |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | CSharpBindings | Version: | svn-trunk |
Severity: | normal | Keywords: | |
Cc: |
Description
These options need to be available for the csharp binding so we can warp images and have the warped result get an added alpha band.
I tried hacking the following:
in options.i
%newobject AutoCreateWarpedVRT; %inline %{ GDALDatasetShadow *AutoCreateWarpedVRT( GDALDatasetShadow *src_ds,
const char *src_wkt = 0, const char *dst_wkt = 0, GDALResampleAlg eResampleAlg = GRA_NearestNeighbour, double maxerror = 0.0, int alphaBand = -1) {
GDALWarpOptions *psWO = 0; if (alphaBand != -1) {
psWO = GDALCreateWarpOptions(); psWO->nDstAlphaBand = alphaBand;
} GDALDatasetShadow *ds = GDALAutoCreateWarpedVRT( src_ds, src_wkt,
dst_wkt, eResampleAlg, maxerror, psWO );
if (ds == 0) {
/*throw CPLGetLastErrorMsg(); causes a SWIG_exception later*/
} return ds;
} %}
and in vrtwrap.cpp
I added at line 239, under the banner
/* -------------------------------------------------------------------- */ /* Create the VRTDataset and populate it with bands. */ /* -------------------------------------------------------------------- */
<snip existing code>
Add a band for alpha data if (psOptions->nDstAlphaBand != 0 && psOptions->nDstAlphaBand > psOptions->nBandCount) {
VRTWarpedRasterBand *poBand;
GDALRasterBand *poSrcBand = (GDALRasterBand *)
GDALGetRasterBand( hSrcDS, psOptions->nBandCount );
poDS->AddBand( poSrcBand->GetRasterDataType(), NULL );
poBand = (VRTWarpedRasterBand *) poDS->GetRasterBand( psOptions->nBandCount +1 ); poBand->CopyCommonInfoFrom( poSrcBand );
poBand->SetColorInterpretation(GCI_AlphaBand);
}
But, it seems to not even work in the slightest, the output dataset has 4 channels, but the 4th channel is undefined, and attempting to read anything from even the first band causes a io exception.
Change History (3)
comment:1 by , 16 years ago
Summary: | Expose GDALWarpOptions options for AutoCreateWarpedVRT → Expose GDALWarpOptions for AutoCreateWarpedVRT |
---|---|
Type: | defect → enhancement |
Version: | unspecified → svn-trunk |
comment:2 by , 16 years ago
comment:3 by , 9 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
This change would seem to imply a change in the GDALAutoCreateWarpedVRT() C ABI. This is also just one of dozens of options people might want to pass. It seems like a can of worm we are opening.
I am not in support of this change.