|
@@ -0,0 +1,52 @@
|
|
|
+package com.onemap.apply.controller.data;
|
|
|
+
|
|
|
+import com.onemap.common.core.web.domain.RequestResult;
|
|
|
+import com.supermap.data.*;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("/test/data")
|
|
|
+public class TestData {
|
|
|
+
|
|
|
+ private static Workspace mWorkspace;
|
|
|
+
|
|
|
+
|
|
|
+ @GetMapping("/point")
|
|
|
+ public RequestResult list(String param) {
|
|
|
+ System.out.println(System.getProperty("java.library.path"));
|
|
|
+ createDatabaseSource();
|
|
|
+ return RequestResult.success("查询成功", null);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void createDatabaseSource() {
|
|
|
+ DatasourceConnectionInfo info = new DatasourceConnectionInfo();
|
|
|
+ info.setEngineType(EngineType.PGGIS);
|
|
|
+// info.setEngineType(EngineType.POSTGRESQL);
|
|
|
+ info.setServer("192.168.100.252:5432");
|
|
|
+ info.setDatabase("test_data");
|
|
|
+ info.setUser("postgres");
|
|
|
+ info.setPassword("postgres");
|
|
|
+ info.setAlias("PGGISSource");
|
|
|
+
|
|
|
+ mWorkspace = new Workspace();
|
|
|
+
|
|
|
+ Datasource datasource = mWorkspace.getDatasources().create(info);
|
|
|
+
|
|
|
+ if (datasource != null) {
|
|
|
+ System.out.println("创建数据源成功");
|
|
|
+ }else{
|
|
|
+ System.out.println("创建数据源失败");
|
|
|
+ }
|
|
|
+ int dbCount = datasource.getDatasets().getCount();
|
|
|
+
|
|
|
+ Datasets datasets = datasource.getDatasets();
|
|
|
+
|
|
|
+ Dataset dtHebei=datasets.get("he_bei");
|
|
|
+ Dataset dtPolygon1=datasets.get("polygon1");
|
|
|
+
|
|
|
+ //sde数据库带空间属性的表叫图层,因此图层跟表类似
|
|
|
+ String layerName = "polygon1";
|
|
|
+ }
|
|
|
+}
|