IlvAltitudeProvider provider = IlvAltitudeProviderProperty.GetAltitudeProvider(manager);
IlvAttributeInfoProperty info = new IlvAttributeInfoProperty( new String[] { "myAltitudeDataSourcePropertyName" }, new Class[] { IlvRasterAltitudeDataSource.class }, new boolean[] { true });
IlvFeatureAttribute value[] = { new IlvRasterAltitudeDataSource(rasterImageReader, imageIndex) }; graphic.setNamedProperty(new IlvFeatureAttributeProperty(info, value);
IlvAttributeProperty property = (IlvAttributeProperty) graphic.getNamedProperty(IlvAttributeProperty.NAME);
IlvAltitudeDataSource ads = (IlvAltitudeDataSource)property.getValue("myAltitudeDataSourcePropertyName") ;
// transform the mouse point into manager coordinates IlvPoint pt=new IlvPoint(mouseLocation.x,mouseLocation.y); view.getTransformer().inverse(pt); IlvProjectionUtil.invertY(pt); try { // compute the coordinate transformation from manager coordinates to lat/ lon IlvCoordinateSystem cs = IlvCoordinateSystemProperty.GetCoordinateSystem(view.getManager()); IlvCoordinateTransformation ct = IlvCoordinateTransformation.CreateTransformation(cs, IlvGeographicCoordinateSystem.KERNEL); // transform the point into lat/lon IlvCoordinate c = new IlvCoordinate(pt.x, pt.y); ct.transform(c, c); // retrieve the altitude } catch (IlvCoordinateTransformationException e) { }
double
, because the
default data source and default provider of the manager return a Double.NaN
value
when there is no altitude information available.double alt = ads.getAltitude(c.x, c.y, 0); if(!Double.isNaN(alt)){ return alt; }
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); }
private static IlvCoordinateTransformation INTERNAL = IlvCoordinateTransformation.CreateTransformation (IlvGeographicCoordinateSystem.KERNEL, IlvGeographicCoordinateSystem.WGS84); public IlvCoordinateSystem getCoordinateSystem() { return INTERNAL.getTargetCS(); } public IlvMathTransform getInternalTransformation(int imageIndex) { return INTERNAL.getTransform(); }