skip to main content
Programmer's documentation > Programming with JViews Maps for Defense > Using Terrain Analysis > Gradient, Valley and Elevated Areas, and Area of Sight computations
 
Gradient, Valley and Elevated Areas, and Area of Sight computations
Describes gradient, valley and elevated areas, and area of sight information features and how to use them.
*Overview
*Introduces the gradient, valley and elevated areas, and area out of sight information features.
*Using Gradient, Valley and Elevated Areas, and Area of Sight computations
*Explains how to create gradients or valley images in your application and provide image computation methods.
Overview
These features compute new raster images containing the gradient, valley and elevated areas, and area of sight information from raw altitude information.
The source code for the Map Builder demonstration, which contains all of the code described in this section, can be found at <installdir> /jviews-maps/samples/mapbuilder/index.html
There is also a specific demonstration that explains how to perform your own terrain analysis by implementing different algorithms in <installdir> /jviews-maps-defense/samples/3dview/index.html.
Using Gradient, Valley and Elevated Areas, and Area of Sight computations
Creating the reader
To create gradients or valley images in your application:
1. Use an IlvComputedRasterReader to create IlvRasterIcon graphic objects:
 
IlvComputedRasterReader reader = new IlvComputedRasterReader(manager);
This reader encapsulates an object to provide the image computation methods that implement the IlvImageComputation interface.
2. You can use the terrain analysis interactors for this, or provide your own computation classes:
 
reader.setImageComputation(new IlvMakeGradientInteractor());
Defining the computation parameters
To define the computation parameters:
1. To make these easy for the user to modify, set these in a map style that can be edited in the Map Layer Tree panel:
 
IlvGradientRasterStyle style = new IlvGradientRasterStyle(reader);
reader.setStyle(style);
2. You need to define at least two parameters in this style:
The bounds of the computation, that is, the bounds of the images:
 
style.setBounds(new Rectangle2D.Double(latLonMin.x, latLonMax.y, latLonMax.x
   - latLonMin.x, latLonMin.y - latLonMax.y));
The color model used to represent the values computed. The image computation object creates a table of pixel values. Each of these pixel values must be attached to a color through a color model. For example:
 
style.setColorModel(new IlvGradientIntervalColorModel());
Creating the data source and configuring the map layer
1. Create a map data source based on this reader and start it:
 
IlvTiledRasterDataSource ds =
  IlvRasterDataSourceFactory.buildTiledImageDataSource(manager, reader,
  true, true, null);
ds.start();
2. Configure the map layer to use the same style as that shown in the map layer tree:
 
IlvMapLayer mapInsertionLayer = ds.getInsertionLayer();
mapInsertionLayer.setStyle(style);
This layer and data source must then be linked with the manager properties (see Using data sources in Programming with JViews Maps).

Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.