管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-01-16 c4e3ccb0b53486f025a7c35694efdd2267142149
src/main/java/com/lf/server/helper/GdalHelper.java
@@ -10,6 +10,8 @@
import org.gdal.ogr.*;
import org.gdal.osr.SpatialReference;
import javax.swing.plaf.synth.SynthTextAreaUI;
import java.io.File;
import java.sql.Time;
import java.sql.Timestamp;
import java.time.LocalDate;
@@ -28,25 +30,31 @@
public class GdalHelper {
    private final static Log log = LogFactory.getLog(GdalHelper.class);
    public static void init(String driverPath) {
    public static void init(String gdalPath) {
        // 注册所有的驱动
        gdal.AllRegister();
        // 为了支持中文路径,请添加下面这句代码
        gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
        // 配置GDAL_DATA路径(gdal根目录下的bin\gdal-data)
        // gdal.SetConfigOption("GDAL_DATA", "E:\\terrait\\TianJin\\Zip\\release-1928-x64-dev\\release-1928-x64\\bin\\gdal-data");
        // gdal.SetConfigOption("PROJ_LIB", "E:\\terrait\\TianJin\\Zip\\release-1928-x64-dev\\release-1928-x64\\bin\\proj7\\share");
        if (null != driverPath) {
            gdal.SetConfigOption("GDAL_DRIVER_PATH", driverPath);
        }
        //gdal.SetConfigOption("PROJ_LIB", "E:\\terrait\\TianJin\\Zip\\release-1928-x64-dev\\release-1928-x64\\bin\\proj7\\share");
        // 为了使属性表字段支持中文,请添加下面这句:CP936
        gdal.SetConfigOption("SHAPE_ENCODING", "");
        gdal.SetConfigOption("PGEO_DRIVER_TEMPLATE", "DRIVER=Microsoft Access Driver (*.mdb, *.accdb);DBQ=%s");
        gdal.SetConfigOption("MDB_DRIVER_TEMPLATE", "DRIVER=Microsoft Access Driver (*.mdb, *.accdb);DBQ=%s");
        if (StringHelper.isEmpty(gdalPath)) {
            return;
        }
        // 配置环境变量
        gdal.SetConfigOption("GDAL_DATA", gdalPath + File.separator + "gdal-data");
        gdal.SetConfigOption("PROJ_LIB", gdalPath + File.separator + "proj7\\share");
        gdal.SetConfigOption("GDAL_DRIVER_PATH", gdalPath + File.separator + "gdalplugins");
        String path = System.getenv("PATH");
        if (!path.contains(gdalPath)) {
            System.setProperty("PATH", path + ";" + gdalPath);
        }
    }
    /**