想实现可视域百分比的计算,想通过后台代码直接计算结果(有坐标和相关参数)
String cbd3DUrl = "D:\\Program Files\\SuperMap\\SuperMap iDesktopX 11i\\sampleData\\3D\\CBDDataset\\CBD.smwu";
Workspace workspace = new Workspace();
WorkspaceConnectionInfo workspaceConnectionInfo = new WorkspaceConnectionInfo();
workspaceConnectionInfo.setType(WorkspaceType.SMWU);
workspaceConnectionInfo.setServer(cbd3DUrl);
boolean open = workspace.open(workspaceConnectionInfo);
System.out.println(open);
String dbPath = "D:\\Program Files\\SuperMap\\SuperMap iDesktopX 11i\\sampleData\\3D\\CBDDataset\\CBD.udb";
DatasourceConnectionInfo info = new DatasourceConnectionInfo();
// 主要是这里设置数据类型
info.setEngineType(EngineType.IMAGEPLUGINS);
// 这里设置路径比如***/***/test.udbx
info.setServer(dbPath);
// 打开数据源
Datasource datasource = workspace.getDatasources().get(0);
System.out.println("打开数据源别名为:" + datasource.getAlias() + " 数据源打开的状态:" + datasource.isOpened() + " 数据源是否以只读方式打开:" + datasource.isReadOnly());//打印查询其描述信息
// workspace.getDatasources().create(info);
System.out.println("datasource open:" + datasource.isOpened());
System.out.println("数据源数量datasource:"+datasource.getDatasets().getCount());
Datasets datasets = datasource.getDatasets();
// 输出result
System.out.println("Datasets:"+datasets.getCount());
Scene sceneObject = new Scene(workspace);//返回三维地图场景(Scene)对象
sceneObject.setSceneType(SceneType.GLOBE);//设置三维场景的类型,选择球体模式(Globe)和平面模式(Flat)两种。
System.out.println("场景数量:" + workspace.getScenes().getCount() + "场景名称:" + sceneObject.getName());
//添加图层
Layer3Ds layer3Ds = sceneObject.getLayers();
System.out.println("场景中原有图层数量:" + layer3Ds.getCount());//打印数据集名称
// Viewshed3D viewshed3D = new Viewshed3D(sceneControl.getScene());
Viewshed3D viewshed3D = new Viewshed3D(sceneObject);
viewshed3D.setViewerPosition(new Point3D(116.44559728682049, 39.906862697933875, 6.914911785993112));
viewshed3D.build();
new Thread(()->{
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
viewshed3D.setVisibleAreaColor(Color.GREEN);
viewshed3D.setHiddenAreaColor(Color.RED);
viewshed3D.setQuality(AnalysisQuality.MEDIUM);
viewshed3D.setDistDirByPoint(new Point3D(116.4455483958302, 39.90637922190338, 21.990817157546257));
viewshed3D.setVerticalFov(60);
viewshed3D.setHorizontalFov(90);
// viewshed3D.setPitch(24.44518319874657);
// viewshed3D.setDirection(184.66703436851276);
// viewshed3D.setDistance(60.179869114881974);
System.out.println("相机俯仰角:"+viewshed3D.getPitch());
System.out.println("与正北方向的夹角:"+viewshed3D.getDirection());
System.out.println("可视距离:"+viewshed3D.getDistance());
List<Point3D> point3DList = viewshed3D.getBarrierPoints();
GeoModel3D total3D = viewshed3D.getFrustumBody();
GeoModel3D visible3D = viewshed3D.getVisibleBody();
double totalArea = total3D.getArea();
double visibleArea = visible3D.getArea();
System.out.println(totalArea);
System.out.println(visibleArea);
}).start();
加载smwu文件和udb文件后,打印显示已经有图层,数据也已经打开了,但是viewshed计算为空