一、发布png到geoserver的imagepyramid
// translate png to tif epsg:4326
File png = new File(pngPathStr);
BufferedImage sourcePng = ImageIO.read(new FileInputStream(png));
int pngWidth = sourcePng.getWidth();
int pngHeight = sourcePng.getHeight();
String outGeoTiffFormTransName = pngPathStr + "out.tif";
String comdTransPngToGTifWith4326 = "gdal_translate -a_srs EPSG:4326 -gcp 0 0 "+ west +" "+ north +" -gcp " + pngWidth + " 0 "+ east +" "+ north +" -gcp "+ pngWidth +" " + pngHeight +" " + east +" "+ south +" "+ pngPathStr +" "+ outGeoTiffFormTransName;
//gdal_translate -a_srs EPSG:4326 -gcp 0 0 -90 0 -gcp 256 0 -45 0 -gcp 256 256 -45 45 Lena.tif Lean.tiff
System.out.println(comdTransPngToGTifWith4326);
Process process1 = Runtime.getRuntime().exec(comdTransPngToGTifWith4326);
process1.waitFor();
process1.destroy();
//warp tif to geotiff epsg:4326
String warpGeotiffName = outGeoTiffFormTransName + "warp.tiff";
String comdWarpGEOtiff = "gdalwarp -s_srs EPSG:4326 -t_srs EPSG:4326 " + outGeoTiffFormTransName +" "+ warpGeotiffName;
//gdalwarp -s_srs EPSG:4326 -t_srs EPSG:4326 Lean.tiff
System.out.println(comdWarpGEOtiff);
Process process2 = Runtime.getRuntime().exec(comdWarpGEOtiff);
process2.waitFor();
process2.destroy();
//retile geoTiff in 4 level
String cutPngDirName = pngPathStr.substring(0, pngPathStr.lastIndexOf("."));
String addCutTiffDirCmd = "mkdir " +cutPngDirName;
Process process3 = Runtime.getRuntime().exec(addCutTiffDirCmd);
process3.waitFor();
process3.destroy();
String retileGeotiffCmd = "gdal_retile.py -v -r bilinear -levels 4 -ps 2048 2048 -co \"TILED=YES\" -targetDir "+ cutPngDirName +" "+warpGeotiffName;
//gdal_retile.py -v -r bilinear -levels 4 -ps 2048 2048 -co "TILED=YES" -targetDir lean LEAN.tiff
Process process4 = Runtime.getRuntime().exec(retileGeotiffCmd);
process4.waitFor();
process4.destroy();
//use geoserver restapi to