月球大数据地理空间分析展示平台-【后端】-月球后台服务
13693261870
2023-08-25 6efe7fe203c2ccff639793c7883b61d3fc5b67cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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();
            }
        }
    }
}