|
@@ -3,13 +3,13 @@ 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;
|
|
|
-import com.supermap.data.conversion.ImportResult;
|
|
|
-import com.supermap.data.conversion.ImportSettingSHP;
|
|
|
+// 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;
|
|
|
+// import com.supermap.data.conversion.ImportResult;
|
|
|
+// import com.supermap.data.conversion.ImportSettingSHP;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.io.File;
|
|
@@ -27,19 +27,19 @@ public class FzxzPlanSchedule {
|
|
|
* @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());
|
|
|
- }
|
|
|
+ // 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() {
|
|
@@ -64,134 +64,134 @@ public class FzxzPlanSchedule {
|
|
|
// return statusMsg;
|
|
|
//}
|
|
|
|
|
|
- //TODO:这里暂时导入不成功
|
|
|
- private static StatusMsg siteAnalysis(String filePath) {
|
|
|
- StatusMsg statusMsg = new StatusMsg();
|
|
|
-
|
|
|
- //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");
|
|
|
-
|
|
|
- Workspace mWorkspace = new Workspace();
|
|
|
- Datasource datasource = mWorkspace.getDatasources().open(info);
|
|
|
-
|
|
|
- if (datasource == null) {
|
|
|
- statusMsg.setMsg("创建数据源失败");
|
|
|
- statusMsg.setB(false);
|
|
|
- return statusMsg;
|
|
|
- }
|
|
|
-
|
|
|
- //2.导入数据
|
|
|
- // 构建目标文件路径
|
|
|
- String projectRootDir = System.getProperty("user.dir");
|
|
|
- String targetFilePath = projectRootDir + File.separator + "data" + File.separator + "shp" + File.separator + "xzqh.shp";
|
|
|
-
|
|
|
- //导入shp文件
|
|
|
- String originalRegions = "original_regions";
|
|
|
- ImportSettingSHP importSettingSHP = new ImportSettingSHP();
|
|
|
- importSettingSHP.setImportMode(ImportMode.OVERWRITE);
|
|
|
- importSettingSHP.setSourceFilePath(targetFilePath);
|
|
|
- //设置需要导入的数据编码类型,因为有中文字段,所以用ASCII编码
|
|
|
- importSettingSHP.setSourceFileCharset(Charset.ANSI);
|
|
|
- importSettingSHP.setTargetDatasetName(originalRegions);
|
|
|
-
|
|
|
- //设置要导入的目标数据源
|
|
|
- importSettingSHP.setTargetDatasource(datasource);
|
|
|
- DataImport dataImport = new DataImport();
|
|
|
- dataImport.getImportSettings().add(importSettingSHP);
|
|
|
-
|
|
|
- ImportResult result = dataImport.run();
|
|
|
- if (result.getFailedSettings().length != 0) {
|
|
|
- statusMsg.setMsg("数据导入失败");
|
|
|
- statusMsg.setB(false);
|
|
|
- return statusMsg;
|
|
|
- }
|
|
|
-
|
|
|
- //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");
|
|
|
-
|
|
|
- Workspace real3dWorkspace = new Workspace();
|
|
|
- Datasource real3dResource = real3dWorkspace.getDatasources().open(infoReal3d);
|
|
|
- DatasetVector ghdkaDataset = (DatasetVector) real3dResource.getDatasets().get("vector_GHDKA");
|
|
|
-
|
|
|
- //圈选区域
|
|
|
- Datasets datasets = datasource.getDatasets();
|
|
|
- DatasetVector originalDataset = (DatasetVector) datasets.get(originalRegions);
|
|
|
-
|
|
|
- QueryParameter parameter = new QueryParameter();
|
|
|
- parameter.setCursorType(CursorType.STATIC);
|
|
|
- parameter.setSpatialQueryMode(SpatialQueryMode.CONTAIN);
|
|
|
- parameter.setSpatialQueryObject(originalDataset);
|
|
|
- // 进行查询
|
|
|
- Recordset recordsetRes = ghdkaDataset.query(parameter);
|
|
|
- int featureCount = recordsetRes.getAllFeatures().size();
|
|
|
-
|
|
|
- //4.创建圈选后的数据集,并存储数据
|
|
|
- DatasetVector dataset_result = (DatasetVector) datasets.createFromTemplate(datasets.getAvailableDatasetName("new_GHDKA"), ghdkaDataset);
|
|
|
- // 将空间查询结果追加到新建的数据集中
|
|
|
- dataset_result.append(recordsetRes);
|
|
|
-
|
|
|
- //释放工作空间占有的资源
|
|
|
- infoReal3d.dispose();
|
|
|
- real3dWorkspace.dispose();
|
|
|
-
|
|
|
- info.dispose();
|
|
|
- mWorkspace.dispose();
|
|
|
- return statusMsg;
|
|
|
- }
|
|
|
+ // //TODO:这里暂时导入不成功
|
|
|
+ // private static StatusMsg siteAnalysis(String filePath) {
|
|
|
+ // StatusMsg statusMsg = new StatusMsg();
|
|
|
+ //
|
|
|
+ // //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");
|
|
|
+ //
|
|
|
+ // Workspace mWorkspace = new Workspace();
|
|
|
+ // Datasource datasource = mWorkspace.getDatasources().open(info);
|
|
|
+ //
|
|
|
+ // if (datasource == null) {
|
|
|
+ // statusMsg.setMsg("创建数据源失败");
|
|
|
+ // statusMsg.setB(false);
|
|
|
+ // return statusMsg;
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // //2.导入数据
|
|
|
+ // // 构建目标文件路径
|
|
|
+ // String projectRootDir = System.getProperty("user.dir");
|
|
|
+ // String targetFilePath = projectRootDir + File.separator + "data" + File.separator + "shp" + File.separator + "xzqh.shp";
|
|
|
+ //
|
|
|
+ // //导入shp文件
|
|
|
+ // String originalRegions = "original_regions";
|
|
|
+ // ImportSettingSHP importSettingSHP = new ImportSettingSHP();
|
|
|
+ // importSettingSHP.setImportMode(ImportMode.OVERWRITE);
|
|
|
+ // importSettingSHP.setSourceFilePath(targetFilePath);
|
|
|
+ // //设置需要导入的数据编码类型,因为有中文字段,所以用ASCII编码
|
|
|
+ // importSettingSHP.setSourceFileCharset(Charset.ANSI);
|
|
|
+ // importSettingSHP.setTargetDatasetName(originalRegions);
|
|
|
+ //
|
|
|
+ // //设置要导入的目标数据源
|
|
|
+ // importSettingSHP.setTargetDatasource(datasource);
|
|
|
+ // DataImport dataImport = new DataImport();
|
|
|
+ // dataImport.getImportSettings().add(importSettingSHP);
|
|
|
+ //
|
|
|
+ // ImportResult result = dataImport.run();
|
|
|
+ // if (result.getFailedSettings().length != 0) {
|
|
|
+ // statusMsg.setMsg("数据导入失败");
|
|
|
+ // statusMsg.setB(false);
|
|
|
+ // return statusMsg;
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // //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");
|
|
|
+ //
|
|
|
+ // Workspace real3dWorkspace = new Workspace();
|
|
|
+ // Datasource real3dResource = real3dWorkspace.getDatasources().open(infoReal3d);
|
|
|
+ // DatasetVector ghdkaDataset = (DatasetVector) real3dResource.getDatasets().get("vector_GHDKA");
|
|
|
+ //
|
|
|
+ // //圈选区域
|
|
|
+ // Datasets datasets = datasource.getDatasets();
|
|
|
+ // DatasetVector originalDataset = (DatasetVector) datasets.get(originalRegions);
|
|
|
+ //
|
|
|
+ // QueryParameter parameter = new QueryParameter();
|
|
|
+ // parameter.setCursorType(CursorType.STATIC);
|
|
|
+ // parameter.setSpatialQueryMode(SpatialQueryMode.CONTAIN);
|
|
|
+ // parameter.setSpatialQueryObject(originalDataset);
|
|
|
+ // // 进行查询
|
|
|
+ // Recordset recordsetRes = ghdkaDataset.query(parameter);
|
|
|
+ // int featureCount = recordsetRes.getAllFeatures().size();
|
|
|
+ //
|
|
|
+ // //4.创建圈选后的数据集,并存储数据
|
|
|
+ // DatasetVector dataset_result = (DatasetVector) datasets.createFromTemplate(datasets.getAvailableDatasetName("new_GHDKA"), ghdkaDataset);
|
|
|
+ // // 将空间查询结果追加到新建的数据集中
|
|
|
+ // dataset_result.append(recordsetRes);
|
|
|
+ //
|
|
|
+ // //释放工作空间占有的资源
|
|
|
+ // infoReal3d.dispose();
|
|
|
+ // real3dWorkspace.dispose();
|
|
|
+ //
|
|
|
+ // info.dispose();
|
|
|
+ // mWorkspace.dispose();
|
|
|
+ // return statusMsg;
|
|
|
+ // }
|
|
|
|
|
|
|
|
|
// 选址分析
|
|
|
- private static StatusMsg siteAnalysis(Geometry geometry, List<FzxzXzyzDTO> xzyzList) {
|
|
|
- StatusMsg statusMsg = new StatusMsg();
|
|
|
- //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");
|
|
|
-
|
|
|
- Workspace mWorkspace = new Workspace();
|
|
|
- Datasource datasource = mWorkspace.getDatasources().open(info);
|
|
|
-
|
|
|
- //1.打开数据源
|
|
|
- Datasets datasets = datasource.getDatasets();
|
|
|
- DatasetVector ghdkaDataset = (DatasetVector) datasets.get("vector_GHDKA");
|
|
|
- //int allSize = ghdkaDataset.getAllFeatures().size();
|
|
|
-
|
|
|
- //2.空间数据圈选
|
|
|
- QueryParameter parameter = new QueryParameter();
|
|
|
- parameter.setCursorType(CursorType.STATIC);
|
|
|
- parameter.setSpatialQueryMode(SpatialQueryMode.CONTAIN);
|
|
|
- parameter.setSpatialQueryObject(geometry);
|
|
|
- // 进行查询
|
|
|
- Recordset recordsetRes = ghdkaDataset.query(parameter);
|
|
|
- int featureCount = recordsetRes.getAllFeatures().size();
|
|
|
-
|
|
|
- //3.创建圈选后的数据集,并存储数据
|
|
|
- DatasetVector dataset_result = (DatasetVector) datasets.createFromTemplate(datasets.getAvailableDatasetName("new_GHDKA"), ghdkaDataset);
|
|
|
- // 将空间查询结果追加到新建的数据集中
|
|
|
- dataset_result.append(recordsetRes);
|
|
|
-
|
|
|
- // 释放工作空间占有的资源
|
|
|
- dataset_result.close();
|
|
|
- ghdkaDataset.close();
|
|
|
- mWorkspace.dispose();
|
|
|
-
|
|
|
- return statusMsg;
|
|
|
- }
|
|
|
+ // private static StatusMsg siteAnalysis(Geometry geometry, List<FzxzXzyzDTO> xzyzList) {
|
|
|
+ // StatusMsg statusMsg = new StatusMsg();
|
|
|
+ // //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");
|
|
|
+ //
|
|
|
+ // Workspace mWorkspace = new Workspace();
|
|
|
+ // Datasource datasource = mWorkspace.getDatasources().open(info);
|
|
|
+ //
|
|
|
+ // //1.打开数据源
|
|
|
+ // Datasets datasets = datasource.getDatasets();
|
|
|
+ // DatasetVector ghdkaDataset = (DatasetVector) datasets.get("vector_GHDKA");
|
|
|
+ // //int allSize = ghdkaDataset.getAllFeatures().size();
|
|
|
+ //
|
|
|
+ // //2.空间数据圈选
|
|
|
+ // QueryParameter parameter = new QueryParameter();
|
|
|
+ // parameter.setCursorType(CursorType.STATIC);
|
|
|
+ // parameter.setSpatialQueryMode(SpatialQueryMode.CONTAIN);
|
|
|
+ // parameter.setSpatialQueryObject(geometry);
|
|
|
+ // // 进行查询
|
|
|
+ // Recordset recordsetRes = ghdkaDataset.query(parameter);
|
|
|
+ // int featureCount = recordsetRes.getAllFeatures().size();
|
|
|
+ //
|
|
|
+ // //3.创建圈选后的数据集,并存储数据
|
|
|
+ // DatasetVector dataset_result = (DatasetVector) datasets.createFromTemplate(datasets.getAvailableDatasetName("new_GHDKA"), ghdkaDataset);
|
|
|
+ // // 将空间查询结果追加到新建的数据集中
|
|
|
+ // dataset_result.append(recordsetRes);
|
|
|
+ //
|
|
|
+ // // 释放工作空间占有的资源
|
|
|
+ // dataset_result.close();
|
|
|
+ // ghdkaDataset.close();
|
|
|
+ // mWorkspace.dispose();
|
|
|
+ //
|
|
|
+ // return statusMsg;
|
|
|
+ // }
|
|
|
}
|