Datasource datasource = datasources.get(i);
DatasetVector dataset = (DatasetVector)datasource.getDatasets().get(0);
String cacheName = dataset.getName();
PrjCoordSys prjCoordSys = new PrjCoordSys();
prjCoordSys.fromEPSGCode(4490);
dataset.setPrjCoordSys(prjCoordSys);
Rectangle2D bounds = dataset.getBounds();
OSGBCacheBuilder builder = new OSGBCacheBuilder();
builder.setDataset(dataset);//设置生成缓存的数据集
builder.setOutputFolder(bimPath);//设置缓存输出路径,与原始缓存一致
builder.setCacheName(cacheName);//设置缓存名称,与原始缓存一致
builder.setFileType(CacheFileType.S3MB);//设置缓存文件类型
builder.setBounds(bounds);//
builder.setTileWidth(300);
builder.setPosition(new Point3D(dataset.getBounds().getCenter().x,dataset.getBounds().getCenter().y,z));
builder.setAttributeExtentType(AttributeExtentType.S3MD);
builder.setCacheVersion(S3MVersion.VERSION_10);
String cachePath = bimPath+File.separator+cacheName+File.separator+cacheName+".scp";
boolean isSuccess = builder.toConfigAndIndexFile(cachePath);
CacheFileType fileType = builder.getFileType();
log.info(cacheName+"生成切片缓存"+isSuccess);
Scene scene = new Scene(workspace);
Layer3Ds layers = scene.getLayers();
Layer3D add = layers.add(cachePath, Layer3DType.OSGB, true);
add.setEditable(true);
add.setVisible(true);
//添加缓存
log.info("添加缓存");
Scenes scenes = workspace.getScenes();
scenes.add(dataset.getName(), scene.toXML());
帮帮孩子