public static final class FeatureQueryConfiguration.Builder extends Object implements AutoCloseable
Builder
for the FeatureQueryConfiguration
class.Constructor and Description |
---|
Builder(FeatureQueryConfiguration.Builder other) |
Modifier and Type | Method and Description |
---|---|
FeatureQueryConfiguration.Builder |
addCondition(MapScale minScale,
MapScale maxScale,
Expression condition)
Defines an expression that is used when querying the model for a certain scale range of the map.
|
FeatureQueryConfiguration |
build()
Creates a
FeatureQueryConfiguration based on the conditions added to this builder. |
void |
close() |
protected void |
finalize() |
FeatureQueryConfiguration.Builder |
loadNothingForNonDefinedScales()
By calling this method, the layer will load nothing when no condition set by
addCondition is applicable for the current scale level. |
FeatureQueryConfiguration.Builder |
nonDefinedScales(Expression condition)
Defines the model query condition that is used when no condition set by
addCondition is applicable for the current scale level of the map. |
public Builder(@NotNull FeatureQueryConfiguration.Builder other)
public void close()
close
in interface AutoCloseable
@NotNull public FeatureQueryConfiguration build()
FeatureQueryConfiguration
based on the conditions added to this builder.
If no conditions were added to this builder, a configuration is built that accepts all features for all map scales.
@NotNull public FeatureQueryConfiguration.Builder addCondition(@NotNull MapScale minScale, @NotNull MapScale maxScale, @NotNull Expression condition) throws IllegalArgumentException
This information is used by the layer to only query relevant data from the model when painting at a certain scale level. For example, when the map is zoomed out a lot, it makes sense to filter out smaller features, thereby reducing the amount of data that is loaded and painted.
The scales are expressed in a unit-less scale. For example, specifying a scale of "1/5000" means that one centimetre on the map equals 5000 centimetres in reality. Valid scale values go from 0 (fully zoomed out) to DBL_MAX (fully zoomed in).
This method can be called multiple times, in order to define different conditions for different scale ranges. Scale ranges are allowed to overlap. If multiple conditions apply to a certain scale level, the layer will combine them in an OR
condition. When no conditions are defined for a certain scale range, the layer will by default load all data. You can change this default behaviour with nonDefinedScales
or loadNothingForNonDefinedScales
.
minScale
- the minimum scale (inclusive).maxScale
- the maximum scale (exclusive).condition
- the condition to be used for the given scale range. Use ExpressionFactory
for creating conditions.IllegalArgumentException
- if the minimum scale is larger than the maximum scale.@NotNull public FeatureQueryConfiguration.Builder nonDefinedScales(@NotNull Expression condition)
addCondition
is applicable for the current scale level of the map.
By default, this is an always-true expression, which means the layer will load everything in this case. Calling this method multiple times will simply overwrite the previously set expression.
condition
- the condition to be used for scale levels for which no other conditions were explicitly specified.@NotNull public FeatureQueryConfiguration.Builder loadNothingForNonDefinedScales()
addCondition
is applicable for the current scale level.
This is a convenience method that has the same effect as calling nonDefinedScales
with an always-false expression.