Interface ILcd2DBoundsIndexedModel

All Superinterfaces:
AutoCloseable, ILcd2DBoundsInteractable, ILcdBounded, ILcdDisposable, ILcdModel, Serializable
All Known Subinterfaces:
ILcdFeatureIndexedAnd2DBoundsIndexedModel
All Known Implementing Classes:
ALfnTileStoreModel, TLcd2DBoundsIndexedModel, TLcd2DBoundsIndexedModelList, TLcd2DBoundsIndexedModelTreeNode, TLcd2DRegularTiledBoundsIndexedModel, TLcdAIXM51AbstractAIXMMessage, TLcdASTERIXFilteredModel, TLcdDatabaseModel, TLcdDatabaseReadOnlyModel, TLcdDataObjectIndexedAnd2DBoundsIndexedModel, TLcdFeatureIndexedAnd2DBoundsIndexedModel, TLcdGML2AbstractFeatureCollection, TLcdGML31AbstractFeatureCollection, TLcdGML31DynamicFeatureCollection, TLcdGML31FeatureCollection, TLcdGML31Model, TLcdGML32AbstractFeatureCollection, TLcdGML32FeatureCollection, TLcdGML32Model, TLcdKML22AbstractContainer, TLcdKML22Document, TLcdKML22DynamicModel, TLcdKML22Folder, TLcdKML22Kml, TLcdKML22RenderableModel, TLcdMagneticNorthModel, TLcdMultilevel2DBoundsIndexedModel, TLcdMultilevelGridCoordinateModel, TLcdNetCDFFilteredModel, TLcdNVG15Model, TLcdNVG20FilteredModel, TLcdNVG20Model, TLcdRegularTiled2DBoundsIndexedModel, TLcdS57DepthAreaEdgeModel, TLcdSoft2DBoundsIndexedModel, TLcdTiled2DBoundsIndexedModel, TLcdTrackModel, TLcdWCSProxyModel, TLcdWFSProxyModel

public interface ILcd2DBoundsIndexedModel extends ILcdModel, ILcdBounded, ILcd2DBoundsInteractable
An ILcdModel whose elements can be retrieved via a spatial index, using 2D rectangular bounds. A callback function is used to pass the results of the queries to the user of this interface.

The model itself is ILcdBounded; its bounds will at least contain the geometries of its elements, but may be larger.

Performance of operations that require model access may depend heavily on whether a model can be spatially queried. It is therefore advised to use model implementations that implement this interface whenever possible.

Implementations of this interface that use the ILcdBounded property of the model's elements to store and retrieve the elements in a spatial index should take care when implementing the ILcdModel.elementChanged(Object, int) method: the bounds of an element will already have changed at the moment the elementChanged method is called, and can thus not be used to retrieve the element in the index!

  • Method Details

    • applyOnInteract2DBounds

      int applyOnInteract2DBounds(ILcdBounds aBounds, boolean aStrictInteract, ILcdFunction aFunctionToApply, double aPrecisionX, double aPrecisionY)
      Applies the specified function to all the model elements of which the 2D bounds overlap with the specified bounds. By default, the order in which the function is applied on the elements is unspecified and depends on the implementation.

      The return value of the specified function is used as a stop criterion: the spatial query is interrupted if the function returns false.

      Parameters:
      aBounds - the rectangle to test overlap with.
      aStrictInteract - if false, the spatial search may return more elements than the ones strictly overlapping; if true, the search only returns the elements that are overlapping. The latter mode is more precise, but it may be slower.
      aFunctionToApply - the function to apply on each element that overlaps with the given bounds. The return value of the specified function is used as a stop criterion: the spatial query is interrupted if the function returns false.
      aPrecisionX - the precision required in the x dimension, expressed in model units. For example, for a cartesian grid system expressed in meters, the values should be expressed in meters as well, for a geodetic coordinate system the accuracy values should be expressed in degrees.

      The precision is useful in combination with multi-leveled data (multiple representations of the same object, but with varying accuracy), so that the most appropriate accuracy level can be used. 0 means best possible accuracy, but it might trigger lazy-loaded implementations to load lots of data.

      aPrecisionY - the precision required in the y dimension, expressed in model units.
      Returns:
      the number of elements to which the ILcdFunction has been applied.
      Throws:
      NullPointerException - if the specified bounds or the specified function are null.
    • applyOnInteract2DBounds

      int applyOnInteract2DBounds(ILcdBounds aBounds, boolean aStrictInteract, ILcdFunction aFunctionToApply, double aPrecisionX, double aPrecisionY, double aMinSizeX, double aMinSizeY, boolean aIncludePoints)
      Description copied from interface: ILcd2DBoundsInteractable
      Applies the specified function to all the elements of which the 2D bounds overlap with the specified bounds. The order in which the function is applied on the elements is unspecified and depends on the implementation.

      Only elements that have at least the specified minimal size in the x dimension or in the y dimension are considered. This can be useful for quickly eliminating elements that are too small to be visible in a view, for instance. If required, an exception can be made for point elements, which have a size of 0 by 0. They can be forced to be considered, even though they would always be rejected as being too small for any sizes larger than 0.

      The return value of the specified function is used as a stop criterion: the spatial query will be interrupted as soon as the function returns false for an element it was applied on.

      Specified by:
      applyOnInteract2DBounds in interface ILcd2DBoundsInteractable
      Parameters:
      aBounds - the rectangle to test overlap with.
      aStrictInteract - if false, the spatial search may return more elements than the ones strictly overlapping; if true, the search only returns the elements that are overlapping. The latter mode is more precise, but it may be slower.
      aFunctionToApply - the function to apply on each element that overlaps with the given bounds.
      aPrecisionX - the precision required in the x dimension, expressed in model units. For example, for a cartesian grid system expressed in meters, the values should be expressed in meters as well, for a geodetic coordinate system the accuracy values should be expressed in degrees.

      The precision is useful in combination with multi-leveled data (multiple representations of the same object, but with varying accuracy), so that the most appropriate accuracy level can be used. 0 means best possible accuracy, but it might trigger lazy-loaded implementations to load lots of data.

      aPrecisionY - the precision required in the y dimension, expressed in model units.
      aMinSizeX - the minimal element size in the x dimension (as in ILcdBounds.getWidth()), expressed in model units. Elements that are smaller than this size will be skipped. This may, for example, be useful when improving the efficiency of painting elements by skipping elements that are smaller than some threshold (e.g. one pixel, converted to model units).
      aMinSizeY - the minimal element size in the y dimension (as in ILcdBounds.getHeight()), expressed in model units.
      aIncludePoints - if true, zero-sized elements (points) are considered as well, even though they might be smaller than the minimum size.
      Returns:
      the number of elements to which the ILcdFunction has been applied.
    • query

      default <T> Stream<T> query(ILcdModel.Query aQuery)
      Provides a Stream of all elements in this model that match the given query.

      If the query condition contains a spatial component (either bounding-box test, or a spatial operator) applyOnInteracts2DBounds is used first to narrow down the set of relevant objects. The rest of the conditions are then evaluated on that subset.

      If the query condition contains a minimum object size aspect, that minimum size is passed as arguments to the applyOnInteract2DBounds call.

      Overall documentation:

      Provides a Stream of all elements in this model that match the given query.

      The query aspects are applied in this specific order, regardless of the order used to create the query:

      1. The query filter is applied first (if any).
      2. The query sorting is applied second (if any).
      3. The query limit is applied last (if any).
      The condition and sort-by must never change after creation.

      Examples:

      A stream is closeable, and it depends on the implementation whether the stream has to be closed or not.
      You should use this template to ensure proper model locking and stream closing:

      
         try (TLcdLockUtil.Lock autoUnlock = TLcdLockUtil.readLock(model);
              Stream elements = model.query(all())) {
           elements.forEach(System.err::println);
         }
       

      Model implementations:

      By default, this method will invoke elements(), loop over all elements and apply the filter, sorting and limit.

      For ILcd2DBoundsIndexedModel, this method will invoke applyOnInteract2DBounds() if the condition contains a spatial component (either a bounding-box operator, or a spatial operator), and apply the rest of the filter on those elements.

      Overriding:

      Model implementers can override this method to apply the query more efficiently on their back-end format.

      For example, if your back-end is a service or database that accepts certain queries, you can override this method and transform the condition into a query on that service.
      You can inspect the condition using instanceof on the various condition classes.

      Specified by:
      query in interface ILcdModel
      Parameters:
      aQuery - The query, cannot be null. Pass ILcdModel.all() if you want all elements.
      Returns:
      a stream of the retained model elements
      Since:
      2017.0
      See Also: