@@ -42,10 +42,16 @@ class WEBPDataset final : public GDALPamDataset
4242
4343 CPL_DISALLOW_COPY_ASSIGN (WEBPDataset)
4444
45+ CPLErr GetGeoTransform (GDALGeoTransform >,
46+ std::string &osWorldFilename) const ;
47+
4548 public:
4649 WEBPDataset ();
4750 ~WEBPDataset () override ;
4851
52+ char **GetFileList () override ;
53+
54+ CPLErr GetGeoTransform (GDALGeoTransform >) const override ;
4955 CPLErr IRasterIO (GDALRWFlag, int , int , int , int , void *, int , int ,
5056 GDALDataType, int , BANDMAP_TYPE, GSpacing nPixelSpace,
5157 GSpacing nLineSpace, GSpacing nBandSpace,
@@ -173,6 +179,54 @@ WEBPDataset::~WEBPDataset()
173179 VSIFree (pabyUncompressed);
174180}
175181
182+ /* ***********************************************************************/
183+ /* GetFileList() */
184+ /* ***********************************************************************/
185+
186+ char **WEBPDataset::GetFileList ()
187+ {
188+ char **papszFileList = GDALPamDataset::GetFileList ();
189+ GDALGeoTransform gt;
190+ std::string osWorldFilename;
191+ CPL_IGNORE_RET_VAL (GetGeoTransform (gt, osWorldFilename));
192+ if (!osWorldFilename.empty ())
193+ {
194+ papszFileList = CSLAddString (papszFileList, osWorldFilename.c_str ());
195+ }
196+ return papszFileList;
197+ }
198+
199+ /* ***********************************************************************/
200+ /* GetGeoTransform() */
201+ /* ***********************************************************************/
202+
203+ CPLErr WEBPDataset::GetGeoTransform (GDALGeoTransform >) const
204+ {
205+ std::string osWorldFilename;
206+ return GetGeoTransform (gt, osWorldFilename);
207+ }
208+
209+ CPLErr WEBPDataset::GetGeoTransform (GDALGeoTransform >,
210+ std::string &osWorldFilename) const
211+ {
212+ bool bGeoTransformValid = GDALPamDataset::GetGeoTransform (gt) == CE_None;
213+ if (!bGeoTransformValid)
214+ {
215+ char *pszWldFilename = nullptr ;
216+ bGeoTransformValid =
217+ GDALReadWorldFile2 (GetDescription (), " .wld" , gt,
218+ oOvManager.GetSiblingFiles (), &pszWldFilename) ||
219+ GDALReadWorldFile2 (GetDescription (), " .wpw" , gt,
220+ oOvManager.GetSiblingFiles (), &pszWldFilename) ||
221+ GDALReadWorldFile2 (GetDescription (), " .webpw" , gt,
222+ oOvManager.GetSiblingFiles (), &pszWldFilename);
223+ if (bGeoTransformValid)
224+ osWorldFilename = pszWldFilename;
225+ CPLFree (pszWldFilename);
226+ }
227+ return bGeoTransformValid ? CE_None : CE_Failure;
228+ }
229+
176230/* ***********************************************************************/
177231/* GetMetadataDomainList() */
178232/* ***********************************************************************/
@@ -1083,6 +1137,14 @@ GDALDataset *WEBPDataset::CreateCopy(const char *pszFilename,
10831137 return nullptr ;
10841138 }
10851139
1140+ // Do we need a world file?
1141+ if (CPLFetchBool (papszOptions, " WORLDFILE" , false ))
1142+ {
1143+ GDALGeoTransform gt;
1144+ poSrcDS->GetGeoTransform (gt);
1145+ GDALWriteWorldFile (pszFilename, " wld" , gt.data ());
1146+ }
1147+
10861148 /* -------------------------------------------------------------------- */
10871149 /* Re-open dataset, and copy any auxiliary pam information. */
10881150 /* -------------------------------------------------------------------- */
0 commit comments