|
@@ -3,8 +3,6 @@ package com.onemap.analyse.task;
|
|
|
import com.onemap.analyse.domain.FzxzDTO;
|
|
|
import com.onemap.analyse.domain.FzxzXzyzDTO;
|
|
|
import com.onemap.common.core.web.domain.StatusMsg;
|
|
|
-// import com.supermap.analyst.spatialanalyst.OverlayAnalyst;
|
|
|
-// import com.supermap.analyst.spatialanalyst.OverlayAnalystParameter;
|
|
|
// import com.supermap.data.*;
|
|
|
// import com.supermap.data.conversion.DataImport;
|
|
|
// import com.supermap.data.conversion.ImportMode;
|
|
@@ -20,62 +18,65 @@ import java.util.List;
|
|
|
*/
|
|
|
@Component
|
|
|
public class FzxzPlanSchedule {
|
|
|
-
|
|
|
+ private static String dbUrl = "192.168.100.30:5432";
|
|
|
+ private static String dbName = "real";
|
|
|
+ private static String dbUser = "postgres";
|
|
|
+ private static String dbPwd = "postgis";
|
|
|
|
|
|
/**
|
|
|
* @param fzxzDTO 选址任务
|
|
|
* @param xzyzList 选址因子
|
|
|
*/
|
|
|
- public static void startPlan(FzxzDTO fzxzDTO, List<FzxzXzyzDTO> xzyzList) {
|
|
|
- // StatusMsg statusMsg = new StatusMsg();
|
|
|
- // //初始化失败返回结果
|
|
|
- // if (fzxzDTO.getFwlx() == 1) {
|
|
|
- // //statusMsg = setWorkspace();
|
|
|
- // // 绘制
|
|
|
- // String geoWkt = fzxzDTO.getXzfw();
|
|
|
- // Geometry geometry = Toolkit.WKTToGeometry(geoWkt);
|
|
|
- // statusMsg = siteAnalysis(geometry, xzyzList);
|
|
|
- // //拿到图层
|
|
|
- // } else if (fzxzDTO.getFwlx() == 2) {
|
|
|
- // // shp文件
|
|
|
- // statusMsg = siteAnalysis(fzxzDTO.getXzfw());
|
|
|
- // }
|
|
|
- }
|
|
|
-
|
|
|
- //private static StatusMsg setWorkspace() {
|
|
|
- // StatusMsg statusMsg = new StatusMsg();
|
|
|
- //
|
|
|
- // DatasourceConnectionInfo info = new DatasourceConnectionInfo();
|
|
|
- // info.setEngineType(EngineType.PGGIS);
|
|
|
- // //TODO:配置信息放到配置文件中
|
|
|
- // info.setServer("192.168.60.202:5432");
|
|
|
- // info.setDatabase("real3d");
|
|
|
- // info.setUser("postgres");
|
|
|
- // info.setPassword("postgres");
|
|
|
- //
|
|
|
- // Workspace mWorkspace = new Workspace();
|
|
|
- // Datasource datasource = mWorkspace.getDatasources().open(info);
|
|
|
- //
|
|
|
- // if (datasource == null) {
|
|
|
- // statusMsg.setMsg("创建数据源失败");
|
|
|
- // statusMsg.setB(false);
|
|
|
- // return statusMsg;
|
|
|
- // }
|
|
|
- // return statusMsg;
|
|
|
- //}
|
|
|
-
|
|
|
- // //TODO:这里暂时导入不成功
|
|
|
+ // public static void startPlan(FzxzDTO fzxzDTO, List<FzxzXzyzDTO> xzyzList) {
|
|
|
+ // StatusMsg statusMsg = new StatusMsg();
|
|
|
+ // // setWorkspace();
|
|
|
+ // // 初始化失败返回结果
|
|
|
+ // if (fzxzDTO.getFwlx() == 1) {
|
|
|
+ // // 绘制
|
|
|
+ // String geoWkt = fzxzDTO.getXzfw();
|
|
|
+ // Geometry geometry = Toolkit.WKTToGeometry(geoWkt);
|
|
|
+ // statusMsg = siteAnalysis(geometry, xzyzList);
|
|
|
+ // // 拿到图层
|
|
|
+ // } else if (fzxzDTO.getFwlx() == 2) {
|
|
|
+ // // shp文件
|
|
|
+ // statusMsg = siteAnalysis(fzxzDTO.getXzfw());
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // private static StatusMsg setWorkspace() {
|
|
|
+ // StatusMsg statusMsg = new StatusMsg();
|
|
|
+ //
|
|
|
+ // DatasourceConnectionInfo info = new DatasourceConnectionInfo();
|
|
|
+ // info.setEngineType(EngineType.PGGIS);
|
|
|
+ // // TODO:配置信息放到配置文件中
|
|
|
+ // info.setServer(dbUrl);
|
|
|
+ // info.setDatabase(dbName);
|
|
|
+ // info.setUser(dbUser);
|
|
|
+ // info.setPassword(dbPwd);
|
|
|
+ //
|
|
|
+ // Workspace mWorkspace = new Workspace();
|
|
|
+ // Datasource datasource = mWorkspace.getDatasources().create(info);
|
|
|
+ //
|
|
|
+ // if (datasource == null) {
|
|
|
+ // statusMsg.setMsg("创建数据源失败");
|
|
|
+ // statusMsg.setB(false);
|
|
|
+ // return statusMsg;
|
|
|
+ // }
|
|
|
+ // return statusMsg;
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // // TODO:这里暂时导入不成功
|
|
|
// private static StatusMsg siteAnalysis(String filePath) {
|
|
|
// StatusMsg statusMsg = new StatusMsg();
|
|
|
//
|
|
|
- // //1.创建数据源
|
|
|
+ // // 1.创建数据源
|
|
|
// DatasourceConnectionInfo info = new DatasourceConnectionInfo();
|
|
|
// info.setEngineType(EngineType.PGGIS);
|
|
|
- // //TODO:配置信息放到配置文件中
|
|
|
- // info.setServer("192.168.60.202:5432");
|
|
|
- // info.setDatabase("plan");
|
|
|
- // info.setUser("postgres");
|
|
|
- // info.setPassword("postgres");
|
|
|
+ // // TODO:配置信息放到配置文件中
|
|
|
+ // info.setServer(dbUrl);
|
|
|
+ // info.setDatabase(dbName);
|
|
|
+ // info.setUser(dbUser);
|
|
|
+ // info.setPassword(dbPwd);
|
|
|
//
|
|
|
// Workspace mWorkspace = new Workspace();
|
|
|
// Datasource datasource = mWorkspace.getDatasources().open(info);
|
|
@@ -86,21 +87,21 @@ public class FzxzPlanSchedule {
|
|
|
// return statusMsg;
|
|
|
// }
|
|
|
//
|
|
|
- // //2.导入数据
|
|
|
+ // // 2.导入数据
|
|
|
// // 构建目标文件路径
|
|
|
// String projectRootDir = System.getProperty("user.dir");
|
|
|
// String targetFilePath = projectRootDir + File.separator + "data" + File.separator + "shp" + File.separator + "xzqh.shp";
|
|
|
//
|
|
|
- // //导入shp文件
|
|
|
+ // // 导入shp文件
|
|
|
// String originalRegions = "original_regions";
|
|
|
// ImportSettingSHP importSettingSHP = new ImportSettingSHP();
|
|
|
// importSettingSHP.setImportMode(ImportMode.OVERWRITE);
|
|
|
// importSettingSHP.setSourceFilePath(targetFilePath);
|
|
|
- // //设置需要导入的数据编码类型,因为有中文字段,所以用ASCII编码
|
|
|
+ // // 设置需要导入的数据编码类型,因为有中文字段,所以用ASCII编码
|
|
|
// importSettingSHP.setSourceFileCharset(Charset.ANSI);
|
|
|
// importSettingSHP.setTargetDatasetName(originalRegions);
|
|
|
//
|
|
|
- // //设置要导入的目标数据源
|
|
|
+ // // 设置要导入的目标数据源
|
|
|
// importSettingSHP.setTargetDatasource(datasource);
|
|
|
// DataImport dataImport = new DataImport();
|
|
|
// dataImport.getImportSettings().add(importSettingSHP);
|
|
@@ -112,21 +113,22 @@ public class FzxzPlanSchedule {
|
|
|
// return statusMsg;
|
|
|
// }
|
|
|
//
|
|
|
- // //3.圈选数据
|
|
|
- // //源数据
|
|
|
+ // // 3.圈选数据
|
|
|
+ // // 源数据
|
|
|
// DatasourceConnectionInfo infoReal3d = new DatasourceConnectionInfo();
|
|
|
// infoReal3d.setEngineType(EngineType.PGGIS);
|
|
|
- // //TODO:配置信息放到配置文件中
|
|
|
- // infoReal3d.setServer("192.168.60.202:5432");
|
|
|
- // infoReal3d.setDatabase("real3d");
|
|
|
- // infoReal3d.setUser("postgres");
|
|
|
- // infoReal3d.setPassword("postgres");
|
|
|
+ // // TODO:配置信息放到配置文件中
|
|
|
+ // infoReal3d.setServer(dbUrl);
|
|
|
+ // infoReal3d.setDatabase(dbName);
|
|
|
+ // infoReal3d.setUser(dbUser);
|
|
|
+ // infoReal3d.setPassword(dbPwd);
|
|
|
//
|
|
|
// Workspace real3dWorkspace = new Workspace();
|
|
|
// Datasource real3dResource = real3dWorkspace.getDatasources().open(infoReal3d);
|
|
|
+ // String[] names = real3dResource.getDatasets().getDatasetNames();
|
|
|
// DatasetVector ghdkaDataset = (DatasetVector) real3dResource.getDatasets().get("vector_GHDKA");
|
|
|
//
|
|
|
- // //圈选区域
|
|
|
+ // // 圈选区域
|
|
|
// Datasets datasets = datasource.getDatasets();
|
|
|
// DatasetVector originalDataset = (DatasetVector) datasets.get(originalRegions);
|
|
|
//
|
|
@@ -138,12 +140,12 @@ public class FzxzPlanSchedule {
|
|
|
// Recordset recordsetRes = ghdkaDataset.query(parameter);
|
|
|
// int featureCount = recordsetRes.getAllFeatures().size();
|
|
|
//
|
|
|
- // //4.创建圈选后的数据集,并存储数据
|
|
|
+ // // 4.创建圈选后的数据集,并存储数据
|
|
|
// DatasetVector dataset_result = (DatasetVector) datasets.createFromTemplate(datasets.getAvailableDatasetName("new_GHDKA"), ghdkaDataset);
|
|
|
// // 将空间查询结果追加到新建的数据集中
|
|
|
// dataset_result.append(recordsetRes);
|
|
|
//
|
|
|
- // //释放工作空间占有的资源
|
|
|
+ // // 释放工作空间占有的资源
|
|
|
// infoReal3d.dispose();
|
|
|
// real3dWorkspace.dispose();
|
|
|
//
|
|
@@ -151,29 +153,30 @@ public class FzxzPlanSchedule {
|
|
|
// mWorkspace.dispose();
|
|
|
// return statusMsg;
|
|
|
// }
|
|
|
-
|
|
|
-
|
|
|
- // 选址分析
|
|
|
+ //
|
|
|
+ //
|
|
|
+ // // 选址分析
|
|
|
// private static StatusMsg siteAnalysis(Geometry geometry, List<FzxzXzyzDTO> xzyzList) {
|
|
|
// StatusMsg statusMsg = new StatusMsg();
|
|
|
- // //1.创建数据源
|
|
|
+ // // 1.创建数据源
|
|
|
// DatasourceConnectionInfo info = new DatasourceConnectionInfo();
|
|
|
// info.setEngineType(EngineType.PGGIS);
|
|
|
- // //TODO:配置信息放到配置文件中
|
|
|
- // info.setServer("192.168.60.202:5432");
|
|
|
- // info.setDatabase("real3d");
|
|
|
- // info.setUser("postgres");
|
|
|
- // info.setPassword("postgres");
|
|
|
+ // // info.setEngineType(EngineType);
|
|
|
+ // // TODO:配置信息放到配置文件中
|
|
|
+ // info.setServer(dbUrl);
|
|
|
+ // info.setDatabase(dbName);
|
|
|
+ // info.setUser(dbUser);
|
|
|
+ // info.setPassword(dbPwd);
|
|
|
//
|
|
|
// Workspace mWorkspace = new Workspace();
|
|
|
// Datasource datasource = mWorkspace.getDatasources().open(info);
|
|
|
//
|
|
|
- // //1.打开数据源
|
|
|
+ // // 1.打开数据源
|
|
|
// Datasets datasets = datasource.getDatasets();
|
|
|
// DatasetVector ghdkaDataset = (DatasetVector) datasets.get("vector_GHDKA");
|
|
|
- // //int allSize = ghdkaDataset.getAllFeatures().size();
|
|
|
+ // // int allSize = ghdkaDataset.getAllFeatures().size();
|
|
|
//
|
|
|
- // //2.空间数据圈选
|
|
|
+ // // 2.空间数据圈选
|
|
|
// QueryParameter parameter = new QueryParameter();
|
|
|
// parameter.setCursorType(CursorType.STATIC);
|
|
|
// parameter.setSpatialQueryMode(SpatialQueryMode.CONTAIN);
|
|
@@ -182,7 +185,7 @@ public class FzxzPlanSchedule {
|
|
|
// Recordset recordsetRes = ghdkaDataset.query(parameter);
|
|
|
// int featureCount = recordsetRes.getAllFeatures().size();
|
|
|
//
|
|
|
- // //3.创建圈选后的数据集,并存储数据
|
|
|
+ // // 3.创建圈选后的数据集,并存储数据
|
|
|
// DatasetVector dataset_result = (DatasetVector) datasets.createFromTemplate(datasets.getAvailableDatasetName("new_GHDKA"), ghdkaDataset);
|
|
|
// // 将空间查询结果追加到新建的数据集中
|
|
|
// dataset_result.append(recordsetRes);
|