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
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!
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.luciad.model.ILcdModel
ILcdModel.Query
-
Field Summary
Fields inherited from interface com.luciad.model.ILcdModel
FIRE_LATER, FIRE_NOW, NO_EVENT
-
Method Summary
Modifier and TypeMethodDescriptionint
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.int
applyOnInteract2DBounds
(ILcdBounds aBounds, boolean aStrictInteract, ILcdFunction aFunctionToApply, double aPrecisionX, double aPrecisionY, double aMinSizeX, double aMinSizeY, boolean aIncludePoints) Applies the specified function to all the elements of which the 2D bounds overlap with the specified bounds.default <T> Stream
<T> query
(ILcdModel.Query aQuery) Provides aStream
of all elements in this model that match the given query.Methods inherited from interface com.luciad.shape.ILcdBounded
getBounds
Methods inherited from interface com.luciad.util.ILcdDisposable
close
Methods inherited from interface com.luciad.model.ILcdModel
addElement, addElements, addModelListener, canAddElement, canRemoveElement, dispose, elementChanged, elements, elementsChanged, fireCollectedModelChanges, getModelDescriptor, getModelEncoder, getModelMetadata, getModelReference, removeAllElements, removeElement, removeElements, removeModelListener
-
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 returnsfalse
.- Parameters:
aBounds
- the rectangle to test overlap with.aStrictInteract
- iffalse
, the spatial search may return more elements than the ones strictly overlapping; iftrue
, 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 returnsfalse
.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 arenull
.
-
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 returnsfalse
for an element it was applied on.- Specified by:
applyOnInteract2DBounds
in interfaceILcd2DBoundsInteractable
- Parameters:
aBounds
- the rectangle to test overlap with.aStrictInteract
- iffalse
, the spatial search may return more elements than the ones strictly overlapping; iftrue
, 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 inILcdBounds.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 inILcdBounds.getHeight()
), expressed in model units.aIncludePoints
- iftrue
, 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
Provides aStream
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
Overall documentation: Provides aminimum object size
aspect, that minimum size is passed as arguments to theapplyOnInteract2DBounds
call.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:
- The query
filter
is applied first (if any). - The query
sorting
is applied second (if any). - The query
limit
is applied last (if any).
condition
andsort-by
must never change after creation.Examples:
- model.
query
(all
()); - model.
query
(filter
(new TLcdOGCBBoxOperator(...))); - model.
query
(filter
(eq(property("name"), literal("Leuven"))); - model.
query
(all
().sorted
(comparing(property("population"), DESC)); - model.
query
(all
().limit
(150)); - model.
query
(filter
(and(bboxCondition, ogcCondition)).sorted
(sortByPopulation).limit
(120));
A
stream
iscloseable
, 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
Overriding:ILcd2DBoundsIndexedModel
, this method will invokeapplyOnInteract2DBounds()
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.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 usinginstanceof
on the various condition classes.- Specified by:
query
in interfaceILcdModel
- Parameters:
aQuery
- The query, cannot benull
. PassILcdModel.all()
if you want all elements.- Returns:
- a stream of the retained model elements
- Since:
- 2017.0
- See Also:
- The query
-