#544 closed defect (fixed)
If a raster source image does not have a .wld file, then we should look at any wms_extent data
Reported by: | Owned by: | warmerdam | |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | WMS Server | Version: | 4.1 |
Severity: | normal | Keywords: | |
Cc: | jmckenna@… |
Description
Raster images require georegistration information, which can be given with .wld files in the same directory as the source images. However, when using mapserver as a WMS server, this georegistration information can be derived from the "wms_extent" tag in the METADATA section of the LAYER object, and the size of the image. The patches below to mapdrawgdal.c, mapraster.c, mapresample.c will add this support when GDAL is used to read raster images. The logic is, if a .wld file cannot be found, then try the "wms_extent" tag. If this is not found either, then continue as before. Index: mapdrawgdal.c =================================================================== RCS file: /data2/cvsroot/mapserver/mapdrawgdal.c,v retrieving revision 1.13 diff -r1.13 mapdrawgdal.c 238,239c238,255 < GDALReadWorldFile((char *)GDALGetDescription(hDS), < "wld", adfGeoTransform); --- > { > if (!GDALReadWorldFile((char *)GDALGetDescription(hDS), > "wld", adfGeoTransform)) > { > rectObj rect; > if (msOWSGetLayerExtent(map, layer, &rect) == MS_SUCCESS) > { > adfGeoTransform[0] = rect.minx; > adfGeoTransform[1] = (rect.maxx - rect.minx) / > (double) src_xsize; > adfGeoTransform[2] = 0; > adfGeoTransform[3] = rect.maxy; > adfGeoTransform[4] = 0; > adfGeoTransform[5] = (rect.miny - rect.maxy) / > (double) src_ysize; > } > } > } Index: mapraster.c =================================================================== RCS file: /data2/cvsroot/mapserver/mapraster.c,v retrieving revision 1.106 diff -r1.106 mapraster.c 1436,1437c1436,1453 < GDALReadWorldFile(msBuildPath(szPath, cwd, filename), < "wld", adfGeoTransform); --- > { > if (!GDALReadWorldFile(msBuildPath(szPath, cwd, filename), > "wld", adfGeoTransform)) > { > rectObj rect; > if (msOWSGetLayerExtent(map, layer, &rect) == MS_SUCCESS) > { > adfGeoTransform[0] = rect.minx; > adfGeoTransform[1] = (rect.maxx - rect.minx) / > (double) GDALGetRasterXSize(hDS); > adfGeoTransform[2] = 0; > adfGeoTransform[3] = rect.maxy; > adfGeoTransform[4] = 0; > adfGeoTransform[5] = (rect.miny - rect.maxy) / > (double) GDALGetRasterYSize(hDS); > } > } > } Index: mapresample.c =================================================================== RCS file: /data2/cvsroot/mapserver/mapresample.c,v retrieving revision 1.42 diff -r1.42 mapresample.c 850a851,853 > nSrcXSize = GDALGetRasterXSize( hDS ); > nSrcYSize = GDALGetRasterYSize( hDS ); > 861c864,879 < GDALReadWorldFile(GDALGetDescription(hDS), "wld", adfSrcGeoTransform);--- > if (!GDALReadWorldFile(GDALGetDescription(hDS), "wld", > adfSrcGeoTransform)) > { > rectObj rect; > if (msOWSGetLayerExtent(map, layer, &rect) == MS_SUCCESS) > { > adfSrcGeoTransform[0] = rect.minx; > adfSrcGeoTransform[1] = (rect.maxx - rect.minx) / > (double) nSrcXSize; > adfSrcGeoTransform[2] = 0; > adfSrcGeoTransform[3] = rect.maxy; > adfSrcGeoTransform[4] = 0; > adfSrcGeoTransform[5] = (rect.miny - rect.maxy) / > (double) nSrcYSize; > } > } 863,864d880 < nSrcXSize = GDALGetRasterXSize( hDS ); < nSrcYSize = GDALGetRasterYSize( hDS );
Note:
See TracTickets
for help on using tickets.