[gdal-dev] Copying metadata - GDALGetMetadata returns nothing
in UMN MapServer WCS
Maarten Plieger
plieger at knmi.nl
Tue Jul 8 08:50:35 EDT 2008
Frank,
Thanks a lot for your help. I managed to pass the metadata through
mapserver with just a few lines of code, by modifying the files you
mentioned, and by adding a pointer named papszMetadata to mapserver.h.
The GDALDataset->SetMetadata (char **,"") and char ** GDALGetMetadata(
(GDALDataset *) poDS,""); functions do now also work with UMN Mapserver
WCS.
In the attachment a patch for UMN MapServer is provided which makes the
metadata functions work. What it does is basically get the metadata with
GDALGetMetadata in mapwcs.h, and set the metadata by using
GDALSetMetadata in mapgdal.c. I use CSLDuplicate and CSLDestroy to
duplicate and to destroy the metadata.
Duplicating the metadata means that is also needs to be destroyed. I
added an extra parameter to the function msWCSGetCoverageMetadata to say
whether it should Duplicate the global metadata or not.
This is the function: static int msWCSGetCoverageMetadata( layerObj
*layer, coverageMetadataObj *cm, int copymeta) ;
When copymeta is set to TRUE, the metadata is copied, and
cm->papszMetadata needs to be destroyed somewhere.
(I guess there is space for some improvement)
The patch can be applied on the mapserver-5.0.2 directory. (tar -xzvf
mapserver-5.0.2.tar.gz; patch -p0 <mapserver-5.0.2_metadata.patch)
You should be cautious when using metadata with multiple layers, I use
one layer at a time.
Best Regards,
Maarten
PS: if you want to use netcdf or hdf files with subdatasets using UMN
MapServer WCS, you should also apply the mapserver-5.0.2_mapstring patch
Frank Warmerdam schreef:
Maarten Plieger wrote:
> Hi,
> Currently I am working on a driver which writes NetCDF4/NetCDF3, with
> a lot of metadata. The idea is that metadata from the sourcefiles will
> be available in the destination file, when using for example
> gdal_translate.
> I am wondering why I can't retrieve metadata in the CreateCopy
> function, when I am using gdal in the WCS of UMN MapServer...
> I use this: papszMetadata = GDALGetMetadata( (GDALDataset *) poDS,"");
> This returns metadata when I use gdal_translate.
> The problem is that no metadata is returned when I use the driver in
> UMN MapServer WCS.
>
> I Guess it has something to do with mapserver creating a virtual
> layer, somewhere loosing the the information. Maybe mapserver thinks
> that only the raster data is necessary?
Maarten,
Yes, I believe this is the problem. MapServer essentially renders into
a memory bitmap wraps this as a MEM dataset, and then writes to the output
format from that. This loses all metadata except for the geolocation
(geotransform) which we recreate.
> I see this in my loggings of apache:
> GDAL: GDALDriver::Create(MEM,msSaveImageGDAL_temp,1440,720,1,Int16,(nil))
>
> Please Help! What am I doing wrong? I guess there is a simple
> solution? Or is it true that metadata is lost in mapserver...?
Generally, yes, that is what it means.
It is hard to know how to carry through metadata since a single WCS
layer could actually consist of many images. If you wish to experiment
with this, I believe we would need a special way for mapwcs.c to pass
a template source dataset to msSaveImage() to use as a source of metadata
when writing (finally in msSaveImageGDAL()).
I have not pursued this angle because it is not entirely clear what
metadata it would be desirable to preserve, and because it is not "natural"
given the mapserver data flow model.
Best regards,
--
Maarten Plieger
KNMI, R&D Information and Observation Technology, De Bilt
(t) +31 30 2206330
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mapserver-5.0.2_metadata.patch
Type: text/x-patch
Size: 5177 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/gdal-dev/attachments/20080708/702d70b1/mapserver-5.0.2_metadata.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mapserver-5.0.2_mapstring.patch
Type: text/x-patch
Size: 569 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/gdal-dev/attachments/20080708/702d70b1/mapserver-5.0.2_mapstring.bin
More information about the gdal-dev
mailing list