removed duplicate conditional statement and unnecessary load call, added comment
@@ -52,22 +52,20 @@ public class RasterFunctionSample extends Application {
imageServiceRaster.loadAsync();
imageServiceRaster.addDoneLoadingListener(() -> {
- if (imageServiceRaster.getLoadStatus() == LoadStatus.LOADED) {
-
if (imageServiceRaster.getLoadStatus() == LoadStatus.LOADED) {
// create raster function from local json file
File jsonFile = new File("./samples-data/raster/hillshade_simplified.json");
try (Scanner scanner = new Scanner(jsonFile)) {
+ // read in the complete file as a string
String json = scanner.useDelimiter("\\A").next();
RasterFunction rasterFunction = RasterFunction.fromJson(json);
RasterFunctionArguments arguments = rasterFunction.getArguments();
// apply the raster function
- rasterFunction.getArguments().setRaster(arguments.getRasterNames().get(0), imageServiceRaster);
+ arguments.setRaster(arguments.getRasterNames().get(0), imageServiceRaster);
// create a new raster from the function definition
Raster raster = new Raster(rasterFunction);
// create raster layer and add to map as operational layer
RasterLayer hillshadeLayer = new RasterLayer(raster);
- hillshadeLayer.loadAsync();
// add the hillshade raster layer to the map
map.getOperationalLayers().add(hillshadeLayer);
hillshadeLayer.addDoneLoadingListener(() -> {
@@ -87,7 +85,6 @@ public class RasterFunctionSample extends Application {
Alert alert = new Alert(Alert.AlertType.ERROR, "Failed to load image service raster");
alert.show();
}
- }
});
