| 
					
				 | 
			
			
				@@ -4,10 +4,18 @@ import com.onemap.common.core.web.domain.RequestResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.supermap.analyst.spatialanalyst.OverlayAnalyst; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.supermap.analyst.spatialanalyst.OverlayAnalystParameter; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.supermap.data.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.supermap.data.conversion.DataExport; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.supermap.data.conversion.ExportSetting; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.supermap.data.conversion.ExportSettingGeoJson; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.supermap.data.conversion.FileType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.web.bind.annotation.GetMapping; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.web.bind.annotation.RequestMapping; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.web.bind.annotation.RestController; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.io.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.nio.charset.StandardCharsets; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.nio.file.Files; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.nio.file.Paths; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.Date; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 @RestController 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -31,8 +39,7 @@ public class TestData { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private static void createDatabaseSource() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         DatasourceConnectionInfo info = new DatasourceConnectionInfo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         info.setEngineType(EngineType.PGGIS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//        info.setEngineType(EngineType.POSTGRESQL); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        info.setServer("192.168.100.252:5432"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        info.setServer("192.168.100.202:5432"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         info.setDatabase("test_data1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         info.setUser("postgres"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         info.setPassword("postgres"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -73,4 +80,57 @@ public class TestData { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 释放工作空间占有的资源 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         mWorkspace.dispose(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @GetMapping("/geojson") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public RequestResult getJson() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        DatasourceConnectionInfo info = new DatasourceConnectionInfo(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        info.setEngineType(EngineType.PGGIS); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        info.setServer("192.168.60.202:5432"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        info.setDatabase("test_data1"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        info.setUser("postgres"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        info.setPassword("postgres"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Workspace mWorkspace = new Workspace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Datasource datasource = mWorkspace.getDatasources().open(info); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (datasource != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            System.out.println("创建数据源成功"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            System.out.println("创建数据源失败"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return RequestResult.error("创建数据源失败"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Datasets datasets = datasource.getDatasets(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        DatasetVector dtHebeiVertical = (DatasetVector) datasets.get("hebei_city"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ExportSettingGeoJson exportSettingGeoJson = new ExportSettingGeoJson(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        exportSettingGeoJson.setOverwrite(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        ExportSetting exportSetting = new ExportSetting(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        exportSetting.setOverwrite(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 获取当前工作目录,即项目根目录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String projectRootDir = System.getProperty("user.dir"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            File file = new File(projectRootDir, "data"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (!file.exists()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                file.mkdir(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 构建目标文件路径 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String targetFilePath = projectRootDir + File.separator + "data" + File.separator + "hebei_city.geojson"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            exportSettingGeoJson.setTargetFileType(FileType.GEOJSON); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            exportSettingGeoJson.setTargetFilePath(targetFilePath); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            exportSettingGeoJson.setSourceData(dtHebeiVertical); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            DataExport dataExport = new DataExport(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            dataExport.getExportSettings().add(exportSettingGeoJson); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            dataExport.run(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return RequestResult.success("数据创建成功", null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |