Class TLcdVVTerrainModel

java.lang.Object
com.luciad.view.vertical.ALcdVVModel
com.luciad.earth.view.vertical.TLcdVVTerrainModel
All Implemented Interfaces:
ILcdVVModel

public class TLcdVVTerrainModel extends ALcdVVModel

ILcdVVModel to show a terrain profile in a Vertical View.

The preferred way of using this class is:

  • call setView to set the view that contains the terrain data.
  • call setObject to set the object for which the profile should be displayed, and the model to which the object belongs. Note that only models with an ILcdGeodeticReference or ILcdGridReference are supported.
  • call update to update the model.

This model treats a pointlist that is an instance of TLcdLonLatBuffer or TLcdLonLatHeightBuffer differently: the profile height in a point is the maximum height along a line perpendicular to the buffer axis in this point and with length equal to the buffer width. When going from one segment to the next (a "turn"), the outside of the turn is not covered by these perpendicular lines. Instead, the maximum inside an arc with center at the common point between the two segments and with as radius the width of the buffer is used.

Updates of this model may happen asynchronously. If the update is complete, a change event will be fired.
Since:
2012.1
  • Constructor Details

    • TLcdVVTerrainModel

      public TLcdVVTerrainModel(Object aObject, ILcdModel aModel, ILcdView aView)
      Creates a terrain profile model that immediately and asynchronously calculates the profile for the given object.
      Parameters:
      aObject - the object
      aModel - the model which the object belongs to
      aView - the view containing the terrain data
      Since:
      2023.0
    • TLcdVVTerrainModel

      public TLcdVVTerrainModel()
      Deprecated.
      call the constructor with view, model and object arguments instead to avoid partially configured models
      Creates an uninitialized terrain profile model. This model is updated asynchronously. After creation, call setView(com.luciad.view.ILcdView), setObject(Object, ILcdModel), and finally update().
    • TLcdVVTerrainModel

      public TLcdVVTerrainModel(boolean aAsynchronousUpdate)
      Deprecated.
      call the constructor with view, model and object arguments instead to avoid partially configured models
      Creates an uninitialized terrain profile model that is updated asynchronously or asynchronously. After creation, call setView(com.luciad.view.ILcdView), setObject(Object, ILcdModel), and finally update().
      Parameters:
      aAsynchronousUpdate - true to make sure the terrain profile model is updated asynchronously. false otherwise.
  • Method Details

    • addPropertyChangeListener

      public void addPropertyChangeListener(PropertyChangeListener aListener)
      Adds a PropertyChangeListener to the list of listeners that must be notified when any of the properties of this terrain profile model changes.
      Parameters:
      aListener - the listener that from now on will be notified of all changes to properties of this terrain profile model.
      See Also:
    • removePropertyChangeListener

      public void removePropertyChangeListener(PropertyChangeListener aListener)
      Removes a PropertyChangeListener from the list of listeners. This listener will no longer be notified of any changes to the properties of this terrain profile model.
      Parameters:
      aListener - the listener that no longer will be notified of any changes to properties of this terrain profile model.
      See Also:
    • setView

      public void setView(ILcdView aView)
      Sets the given view. After calling this method, the terrain profile model will be updated automatically whenever an elevation layer is added or removed.
      Parameters:
      aView - a given view. The view must implement ILcdLayered.
      Throws:
      IllegalArgumentException - if the view does not implement ILcdLayered
      See Also:
    • getView

      public ILcdView getView()
      Returns the view set in the setView method.
      Returns:
      the view set in the setView method.
      See Also:
    • setObject

      public final void setObject(Object aObject, ILcdModel aModel)
      Sets the domain object for which the profile and terrain elevation will be displayed, and the model to which the given object belongs.

      The terrain model should be able to retrieve a point list from the given object. See the retrievePointList(java.lang.Object) method for the shape types that are supported by default.

      Note: after calling this method, the update method should be called.

      Parameters:
      aObject - the object.
      aModel - the model to which the given object belongs. Note that only models with an ILcdGeodeticReference or ILcdGridReference are supported.
      Throws:
      IllegalArgumentException - when the given model is null and the given object is not null or when a model with an unsupported model reference is provider.
      See Also:
    • getObject

      public Object getObject()
      Returns the object for which the profile and terrain elevation will be displayed.

      Note that after calling setObject, this method will not immediately return the passed Object. It will only return it after the update method has been called, and has finished his execution (which may be asynchronously).

      Returns:
      the object for which the profile and terrain elevation will be displayed.
      See Also:
    • getModel

      public ILcdModel getModel()
      Returns the model to which getObject belongs.

      Note that after calling setObject, this method will not immediately return the passed ILcdModel. It will only return it after the update method has been called, and has finished his execution (which may be asynchronously).

      Returns:
      the model to which getObject belongs.
      See Also:
    • retrievePointList

      protected ILcdPointList retrievePointList(Object aObject)
      Returns a point list for the given object. This point list is used to update the terrain profile model.

      By default, this method checks if the given object is one of the following.

      Parameters:
      aObject - the object.
      Returns:
      a point list for the given point list object.
    • setTerrainProfileReference

      public void setTerrainProfileReference(ILcdModelReference aTerrainProfileReference)
      Sets the reference system in which the terrain profile should be generated. This is the reference used to retrieve the terrain height.

      By default, the terrain profile reference is null, which means that the same reference as getModel is used to discretize the point list.

      Currently, ILcdGeodeticReference and ILcdGridReference are supported.

      Parameters:
      aTerrainProfileReference - the reference system in which the terrain profile should be generated.
      See Also:
    • getTerrainProfileReference

      public ILcdModelReference getTerrainProfileReference()
      Returns the reference system in which the terrain profile is generated.
      Returns:
      the reference system in which the terrain profile is generated.
      See Also:
    • update

      public void update()
      Updates the terrain profile model.

      The terrain profile model is automatically updated

      • when the set object is modified (or removed)
      • when a layer, containing elevation data is added or removed
      In all other cases, this method should be called.

      Note that this method may update the terrain profile asynchronously.

    • calculateStepSize

      protected double calculateStepSize(int aSegmentIndex, double aSegmentDistance, ILcdPoint aSegmentPoint1, ILcdPoint aSegmentPoint2, ILcdModelReference aPointReference)
      This method calculates the step size using which the terrain is sampled. This step size (expressed in meters) is used to walk over the point list and retrieve the terrain height.

      The default implementation of this method uses a pixel density to calculate this step size.

      Parameters:
      aSegmentIndex - the index of the segment for which a step size should be calculated.
      aSegmentDistance - the length of the segment in meters
      aSegmentPoint1 - the start point of the segment
      aPointReference - the reference of the segment points.
      Returns:
      the step size using which the terrain is sampled.
      Since:
      2017.1
    • getDistance

      public double getDistance(int aPointIndex1, int aPointIndex2)
      Returns the distance between two points. In case of a geodetic reference, this distance is expressed in meters along a great circle on the globe. In case of a grid reference, the shortest (cartesian) distance is calculate.
      Specified by:
      getDistance in interface ILcdVVModel
      Overrides:
      getDistance in class ALcdVVModel
      Parameters:
      aPointIndex1 - the index of the first point on the main profile
      aPointIndex2 - the index of the second point on the main profile
      Returns:
      the distance between the 2 points along a great circle on the globe.
    • retrieveHeightProvider

      protected ILcdHeightProvider retrieveHeightProvider(Map<String,Object> aRequiredProperties, Map<String,Object> aOptionalProperties)
      Retrieves a height provider for the given required and optional height provider properties.

      By default, this method uses TLcdRasterModelHeightProviderFactory and TLcdEarthHeightProviderFactory to create a TLcdViewHeightProvider. This view height provider is based on the set view and properties. When the view is null, an IllegalArgumentException is thrown.

      Parameters:
      aRequiredProperties - the required properties used to create a height provider
      aOptionalProperties - the optional properties used to create a height provider
      Returns:
      a height provider.
    • setPixelDensity

      public void setPixelDensity(double aPixelDensity)
      Sets the pixel density to use for the terrain rendering. Pixel density is defined as the number of pixels in a raster per unit of area. The pixel density is assumed to be specified in the WGS 84 reference.

      This method is used by the default implementation of calculateStepSize.

      By default, this values is 14400.0.

      Parameters:
      aPixelDensity - The pixel density
      See Also:
    • getPixelDensity

      public double getPixelDensity()
      Returns the pixel density to use for the terrain rendering.

      This method is used by the default implementation of calculateStepSize.

      By default, this values is 14400.0.

      Returns:
      the pixel density to use for the terrain rendering.
      See Also:
    • subProfilePointCount

      public int subProfilePointCount(int aSegmentIndex, int aSubProfileIndex) throws IndexOutOfBoundsException
      Description copied from interface: ILcdVVModel
      Returns the number of points (steps) of a sub-profile for the given main profile segment.
      Parameters:
      aSegmentIndex - the index of the segment in the main profile
      aSubProfileIndex - the index of the sub-profile to use
      Returns:
      For a given segment and for one specific sub-profile, how many points are contained.
      Throws:
      IndexOutOfBoundsException
    • getPointCount

      public int getPointCount()
      Returns:
      the number of points on the main-profile.
    • getPoint

      public ILcdPoint getPoint(int aPointIndex) throws IndexOutOfBoundsException
      Parameters:
      aPointIndex - the index of the point in the main profile
      Returns:
      a point at a given index on the main-profile.
      Throws:
      IndexOutOfBoundsException
      See Also:
    • setPointZ

      public void setPointZ(int aIndex, double aZ, boolean isLastInRow) throws IndexOutOfBoundsException
      Description copied from interface: ILcdVVModel
      This method will be called whenever a point of the main-profile is being dragged so that its Z-dimension needs to be changed. If isLastInRow is false, the user should consider caching the Z-value.
      Parameters:
      aIndex - The index of the point being dragged.
      aZ - The new altitude for the point.
      isLastInRow - While the user is dragging the point, this parameter will be false, at the release of the mouse this parameter will be true.
      Throws:
      IndexOutOfBoundsException
    • getSubProfileCount

      public int getSubProfileCount()
      Returns:
      the number of sub-profiles in this ILcdVVModel.
    • isEditable

      public boolean isEditable()
      Returns:
      true if editing of the main-profile (dragging the points) is allowed.
    • minZ

      public double minZ(int aSubProfilePointIndex, int aSegmentIndex, int aSubProfileIndex) throws IndexOutOfBoundsException
      Parameters:
      aSubProfilePointIndex - the index of the sub-profile point whose altitude to retrieve
      aSegmentIndex - the main-profile segment of the sub-profile point A segment is a line-piece drawn between two main-profile points.
      aSubProfileIndex - the index of the sub-profile to use
      Returns:
      Should return the minimum altitude for one specific sub-profile-point. This minZ value will be used when the rendering mode for this sub-profile is BOTTOM_LINE, FILLED or POLYGON.
      Throws:
      IndexOutOfBoundsException
    • maxZ

      public double maxZ(int aSubProfilePointIndex, int aSegmentIndex, int aSubProfileIndex) throws IndexOutOfBoundsException
      Parameters:
      aSubProfilePointIndex - the index of the sub-profile point whose altitude to retrieve
      aSegmentIndex - the main-profile segment to retrieve the step length for. A segment is a line-piece drawn between two main-profile points.
      aSubProfileIndex - the index of the sub-profile to use
      Returns:
      Should return the maximum altitude for one specific sub-profile-point. This maxZ value will be used when rendering mode for this sub-profile is TOP_LINE, FILLED or POLYGON.
      Throws:
      IndexOutOfBoundsException
    • stepLenghtRatio

      public float stepLenghtRatio(int aSubProfilePointIndex, int aSegmentIndex, int aSubProfileIndex) throws IndexOutOfBoundsException
      Description copied from interface: ILcdVVModel
      Returns where the given sub-profile point is positioned on the X-axis. More precisely, this method returns the percentage on the X-axis the given sub-profile point represents on the given main profile segment. The sum of all the ratios for one sub-profile on the segment should be 1.
      Parameters:
      aSubProfilePointIndex - defines the step. It is the point to the right of the step, so it can never be less than 1,
      aSegmentIndex - the main-profile segment to retrieve the step length for. A segment is a line-piece drawn between two main-profile points.
      aSubProfileIndex - the sub-profile to retrieve the step length ratio for
      Returns:
      the percentage on the X-axis the given sub-profile step represents
      Throws:
      IndexOutOfBoundsException