| Programming with JViews Maps > Introducing the Main Classes > Map Specific Manager Properties > Altitude Management |
Altitude Management |
INDEX
PREVIOUS
NEXT
|
The class relationship for altitude management is shown in Figure 1.2.
This section describes:
The source code for the Map Builder demonstration, which contains all of the code described in this section, can be found at <installdir>/jviews-maps81/samples/mapbuilder/index.html
Terrain analysis computations are based on the IlvAltitudeProviderProperty of the manager and its underlying IlvAltitudeProvider, which is responsible for providing altitudes for each point on a map.
You can access the altitude provider by calling:
IlvAltitudeProvider provider = IlvAltitudeProviderProperty.GetAltitudeProvider(manager);
If you do not set a specific provider to this property, this method creates or returns an instance of IlvDefaultAltitudeProvider.
This provider supports GTOPO30 and DTED data sources.
Any other Digital Elevation Model can be integrated by providing the graphic objects with an IlvAltitudeDataSource property, see Retrieving the Altitude Attached to a Graphic Object.
The IlvJMouseCoordinateViewer Bean uses altitude property information to provide altitude information whenever the mouse is over an altitude providing map object. Many other features of JViews Maps also use this information.
If you have read an image containing elevation data with an IlvRasterAbstractReader, for an example, see Writing a Raster Reader for DEM Data; you can reuse its altitude information to provide altitude data by using an IlvRasterAltitudeDataSource instance.
You first need to decide on the structure of the attribute property, for example, for a property containing only altitude data:
IlvAttributeInfoProperty info = new IlvAttributeInfoProperty(
new String[] { "myAltitudeDataSourcePropertyName" },
new Class[] { IlvRasterAltitudeDataSource.class },
new boolean[] { true });
You can then reuse this structural information with different altitude data sources, and set it as the graphic object property:
IlvFeatureAttribute value[] = { new IlvRasterAltitudeDataSource(rasterImageReader, imageIndex) };
graphic.setNamedProperty(new IlvFeatureAttributeProperty(info, value);
If you use the default altitude management described in The Altitude Provider Property, you can also retrieve the altitude attached to an object as follows:
IlvAttributeProperty property = (IlvAttributeProperty) graphic.getNamedProperty(IlvAttributeProperty.NAME);
IlvAltitudeDataSource ads = (IlvAltitudeDataSource)property.getValue("myAltitudeDataSourcePropertyName");
double, because the default data source and default provider of the manager return a Double.NaN value when there is no altitude information available.
To read a new Digital Elevation Model (DEM) file format, you should write a subclass of IlvRasterAbstractReader.
The following example shows how a reader can load a list of raster DEM files using the addMap method.
public class MyDEMReader extends IlvRasterAbstractReader {
// list of files to be read.
private ArrayList filenameList = new ArrayList();
/** default constructor */
public MyDEMReader() {
}
The addMap method has to compute the IlvRasterProperties and IlvRasterMappedBuffer attached to the file name, see Raster Image Management, and then add this information to the list managed by the reader. As this step is heavily dependant upon format, only a summary is provided here.
public void addMap(final String filename) throws IOException {
IlvRasterProperties loadingRaster = read/compute raster properties ...
IlvRasterMappedBuffer source= read/compute raster pixel values...
loadingRaster.setBaseName(filename);// to retrieve the file name when serializing data.
addRaster(loadingRaster, source);
}
If you want to take advantage of map load and save features, you have to manage the serialization of the reader, that is, provide methods that perform the following functions:
If the pixel values stored in the IlvRasterMappedBuffer are altitudes, you can use the IlvRasterAltitudeDataSource class directly as the altitude provider, and use it in the IlvFeatureAttributeProperty of every image that this reader creates:
public IlvFeatureAttributeProperty getProperties(int imageIndex) {
IlvAttributeInfoProperty info = new IlvAttributeInfoProperty(
new String[] { " myAltitudeDataSourcePropertyName" },
new Class[] { IlvRasterAltitudeDataSource.class },
new boolean[] { true });
IlvFeatureAttribute values[] = new IlvFeatureAttribute[] {
new IlvRasterAltitudeDataSource(this,imageIndex)
};
return new IlvFeatureAttributeProperty(info, values);
}
See also, Attaching an Altitude Data Source to a Graphic Object.
You need to provide JViews Maps with a way of knowing where the resulting image is placed. This is done through two methods that return the transformation and coordinate system used in the raster property boundaries. For example, assuming the bounds are given in degrees:
private static IlvCoordinateTransformation INTERNAL =
IlvCoordinateTransformation.CreateTransformation
(IlvGeographicCoordinateSystem.KERNEL,
IlvGeographicCoordinateSystem.WGS84);
public IlvCoordinateSystem getCoordinateSystem() {
return INTERNAL.getTargetCS();
}
public IlvMathTransform getInternalTransformation(int imageIndex) {
return INTERNAL.getTransform();
}
| Copyright © 1987-2007 ILOG S.A. All rights reserved. Documentation homepage. Legal terms. | PREVIOUS NEXT |