package com.moon.server.service.data; import com.moon.server.entity.data.MetaEntity; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.gdal.gdal.Dataset; import org.gdal.gdal.gdal; import org.gdal.osr.SpatialReference; import org.springframework.stereotype.Service; import java.io.File; /** * 栅格服务 * @author WWW * @date 2023-08-25 */ @Service public class RasterService { private final static Log log = LogFactory.getLog(RasterService.class); /** * 读取栅格信息 */ public void ReadRasterInfo(MetaEntity me, String file) { Dataset ds = null; try { File f = new File(file); if (!f.exists() || f.isDirectory()) { return; } ds = gdal.Open(file, 0); if (null == ds || ds.getRasterCount() == 0) { return; } SpatialReference sr = ds.GetSpatialRef(); } catch (Exception ex) { log.error(ex.getMessage(), ex); } finally { if (null != ds) { ds.delete(); } } } }