public final class TLcdClusteringTransformer extends Object
Transformer that aims to reduce map clutter caused by showing many icons. If model elements are located close to each other, they are instead replaced by a single cluster element. Whether elements are close to each other or not is defined in view space, so it depends on the current zoom level and camera position.
You use a TLcdClusteringTransformer
in combination with a
ALcdTransformingModel
. Create instances using the newBuilder()
method.
Note that it is not allowed to share a single TLcdClusteringTransformer
between different
ALcdTransformingModel
instances.
Each ALcdTransformingModel
should be constructed using its own, dedicated
TLcdClusteringTransformer
instance.
The clustering transformer will be triggered automatically by the ALcdTransformingModel
whenever
the result of the clustering operation might have changed.
Examples are view navigation (zooming, panning, ...), model changes, changes to the layer filter, ... .
Clustering has these properties, with respect to the original (=unclustered) model, and the transformed (=clustered) model:
ILcdPoint
, or ILcdPointList
or ILcdShapeList
with one point. Elements annotated with
TLcdHasGeometryAnnotation
are considered as well.TLcdCluster
.ILcdClusterShapeProvider
.
ILcdDataModelDescriptor
, the transformed model also has one. If the
original model does not have one, the transformed model doesn't either. The data
model is extended with an extra type for the clusters, see TLcdClusterDataTypes
.Modifier and Type | Class and Description |
---|---|
static class |
TLcdClusteringTransformer.Builder
Builder for
TLcdClusteringTransformer . |
Modifier and Type | Field and Description |
---|---|
static String |
CLUSTERING_MODEL_TYPE
Type name of models that use this transformer. |
Modifier and Type | Method and Description |
---|---|
static TLcdClusteringTransformer |
createMapScaleDependent(double[] aScales,
TLcdClusteringTransformer[] aClusteringTransformers)
This methods allows to create a
TLcdClusteringTransformer which uses different cluster settings for
different scales. |
static TLcdClusteringTransformer |
createScaleDependent(double[] aScaleDenominators,
TLcdClusteringTransformer[] aClusteringTransformers)
Deprecated.
|
static TLcdClusteringTransformer.Builder |
newBuilder()
Creates a new builder for
TLcdClusteringTransformer . |
public static final String CLUSTERING_MODEL_TYPE
Type name
of models that use this transformer.public static TLcdClusteringTransformer.Builder newBuilder()
TLcdClusteringTransformer
.
This builder allows you to configure default parameters and parameters for specific classifications using the forClass method.TLcdClusteringTransformer.Builder
public static TLcdClusteringTransformer createScaleDependent(double[] aScaleDenominators, TLcdClusteringTransformer[] aClusteringTransformers)
createMapScaleDependent(double[], TLcdClusteringTransformer[])
TLcdClusteringTransformer
which uses different cluster settings for
different scales.
This is achieved by providing a set of scale denominators, and for each scale a clustering transformer.
Each of the scale denominators marks the switching point between the settings of the two clustering transformer instances
at the corresponding indices in the clustering transformer array.
Note that the scale denominators need to be ordered from a low value denominator (=zoomed in scale) to a
high value denominator (=zoomed out scale).
The clustering transformers need to use the same ordering: the transformer corresponding to the most zoomed in scale
first, and the transformer corresponding to the most zoomed-out scale last.
As the scales indicate the switching point between two transformers, the number of needed transformers is equal to
the number of scales + 1.
A visual example of the relation between the scale switching points and the different transformers is given below. The example uses 3 different switching scales, hence requires 4 transformers.
Scale: 1 : 1000 1 : 10 000 1 : 100 000 (zoomed in) ---------- | ----------------- | ----------------- | ---------- (zoomed out) transformer[0] transformer[1] transformer[2] transformer[3]
aScaleDenominators
- The scale denominators, in world units/toolkit pixels.
Should be ordered from small denominators to large denominators, e.g.
new int[]{1000, 10000, 100000}
.aClusteringTransformers
- The array of clustering transformers.
Should have aScaleDenominators.length + 1
as length.TLcdClusteringTransformer
which uses different cluster settings for different scalespublic static TLcdClusteringTransformer createMapScaleDependent(double[] aScales, TLcdClusteringTransformer[] aClusteringTransformers)
This methods allows to create a TLcdClusteringTransformer
which uses different cluster settings for
different scales.
This is achieved by providing a set of unitless scales, and for each scale a clustering transformer.
For example specifying a scale of "1/5000" means that one centimetre on the map equals 5000 centimetres
in reality.
Each scale marks the switching point between the settings of the two clustering transformer instances
at the corresponding indices in the clustering transformer array.
For example, if you want to use different cluster settings when zoomed out compared to zoomed in, and the scale
on which the settings must be switched is 1 : 10 000
, you would use
TLcdClusteringTransformer zoomedOutSettings = ...;
TLcdClusteringTransformer zoomedInSettings = ...;
double scales = new double[]{1.0/10000.0};
TLcdClusteringTransformer[] transformers = new TLcdClusteringTransformer[]{
zoomedInSettings,
zoomedOutSettings
};
TLcdClusteringTransformer transformer =
TLcdClusteringTransformer.createMapScaleDependent( scales, transformers );
Note that the scales need to be ordered from a zoomed in scale to a zoomed out scale (high values to low values). The clustering transformers need to use the same ordering: the transformer corresponding to the most zoomed in scale first, and the transformer corresponding to the most zoomed-out scale last. As the scales indicate the switching point between two transformers, the number of needed transformers is equal to the number of scales + 1.
A visual example of the relation between the scale switching points and the different transformers is given below. The example uses 3 different switching scales, hence requires 4 transformers.
Scale: 1 : 1000 1 : 10 000 1 : 100 000 (zoomed in) ---------- | ----------------- | ----------------- | ---------- (zoomed out) transformer[0] transformer[1] transformer[2] transformer[3]
aScales
- The scales, which are expressed as a unitless scale.
Should be ordered from detailed scales to less detailed levels, e.g.
new int[]{1.0/1000.0, 1.0/10000.0, 1.0/100000.0}
.aClusteringTransformers
- The array of clustering transformers.
Should have aScales.length + 1
as length.TLcdClusteringTransformer
which uses different cluster settings for different scales