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 ssakharov, 16 years ago

Summary: Expose GDALWarpOptions options for AutoCreateWarpedVRTExpose GDALWarpOptions for AutoCreateWarpedVRT
Type: defectenhancement
Version: unspecifiedsvn-trunk

comment:2 by warmerdam, 16 years ago

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.

comment:3 by Kyle Shannon, 9 years ago

Resolution: worksforme
Status: newclosed

This was touched on in #5138 and subsequently reverted in #5363. It was decided to keep AutoCreateWarpedVRT() as simple as possible. Closing as stale, and addressed in other tickets.

Note: See TracTickets for help on using tickets.