public final class TLcdModelQueryConfiguration extends Object
ILcdOGCCondition
is recommended when
querying the model for a certain scale of the view.
The condition can be retrieved through the getCondition(TLcdMapScale)
method.
This information can for example be used by a layer to only query relevant data from the model when painting at
a certain scale.
Instances of this class can be created through a Builder
class.
On this builder you can add conditions
for certain scale ranges,
and specify the condition for all other scales.
The result of this is that for every scale (interval) a condition is available.
Builder
allows to specify multiple conditions for a certain scale by calling addContent
for overlapping intervals.
For example
Builder builder = TLcdModelQueryConfiguration.newBuilder();
TLcdModelQueryConfiguration configuration =
builder.addContent( 1e-5, 1e-7, majorRoadsCondition )
.addContent( FULLY_ZOOMED_OUT, FULLY_ZOOMED_IN, highWaysCondition )
.build();
defines overlapping conditions for the interval [1e-5, 1e-7[
.
In that interval, both the majorRoadsCondition
and highWaysCondition
are set.
As a result, for any scale in that interval the getCondition(TLcdMapScale) method will return a condition with an
OR
condition containing both the majorRoadsCondition
and highWaysCondition
.
More concrete, the following combinatory logic is used when determining the condition for a certain scale:
OR
condition containing each of the conditions is used.
LOAD_NOTHING_CONDITION
and other condition(s) for a scale: the LOAD_NOTHING_CONDITION
is ignored,
and an OR
combination of all other conditions is used.
null
condition (=load everything) and other condition(s) for a scale: the other conditions are ignored,
and a null
condition is used indicating that all data must be loaded.
non defined scale condition
will be returned.
Builder builder = TLcdModelQueryConfiguration.newBuilder();
TLcdModelQueryConfiguration configuration =
builder.addContent(1e-3, FULLY_ZOOMED_IN, null)
.addContent(1e-5, 1e-3, minorRoadsCondition)
.addContent(1e-11, 1e-3, majorRoadsCondition)
.addContent(1e-15, 1e-3, highWaysCondition)
.loadNothingForUndefinedScales()
.build();
would result in the following conditions:
Scale range | Condition |
---|---|
[FULLY_ZOOMED_OUT, 1e-15[ |
LOAD_NOTHING_CONDITION , meaning no data will be loaded. |
[1e-15, 1e-11[ |
highWaysCondition , meaning all highways will be loaded. |
[1e-11, 1e-5[ |
OR combination of the majorRoadsCondition and highWaysCondition ,
meaning all major roads and highways will be loaded. |
[1e-5, 1e-3[ |
OR combination of the minorRoadsCondition , majorRoadsCondition and highWaysCondition ,
meaning all minor and major roads and highways will be loaded. |
[1e-3, FULLY_ZOOMED_IN[ (zoomed in) |
null condition, meaning all data should be loaded |
TLcdModelQueryConfiguration config =
TLcdModelQueryConfiguration.newBuilder().loadEverythingForUndefinedScales().build();
TLcdModelQueryConfiguration config =
TLcdModelQueryConfiguration.newBuilder()
.addContent(1e-6, 1e-3, myDataCondition)
.loadNothingForUndefinedScales()
.build();
Modifier and Type | Class and Description |
---|---|
static class |
TLcdModelQueryConfiguration.Builder
Builder for
TLcdModelQueryConfiguration instances. |
Modifier and Type | Field and Description |
---|---|
static double |
FULLY_ZOOMED_IN
Scale value corresponding to a view which is completely zoomed in (= a scale of
Double.MAX_VALUE ). |
static double |
FULLY_ZOOMED_OUT
Scale value corresponding to a view which is completely zoomed out (= a scale of 0.0)
|
static ILcdOGCCondition |
LOAD_NOTHING_CONDITION
Condition which can be used to indicate that no data should be loaded by always evaluating to
false . |
Modifier and Type | Method and Description |
---|---|
ILcdOGCCondition |
getCondition(double aScale)
Deprecated.
use
getCondition(TLcdMapScale) to avoid any confusion about the semantic meaning of the scale parameter |
ILcdOGCCondition |
getCondition(TLcdMapScale aScale)
Returns the condition corresponding to the specified map scale ratio.
|
List<TLcdMapScale> |
getMapScales()
Returns the map scales at which point another condition becomes valid.
|
List<Double> |
getScales()
Deprecated.
use
getMapScales() to avoid any confusion about the semantic meaning of the scale parameter |
static TLcdModelQueryConfiguration.Builder |
newBuilder()
Create a new builder instance
|
public static final ILcdOGCCondition LOAD_NOTHING_CONDITION
false
.
While this is a valid condition, it is strongly recommended to avoid to perform actual conditioning
with this condition.
For performance reasons, it is better to compare a condition with this instance and use an early-out.
This avoids a potentially costly filtering operation.
For example:
ILcdOGCCondition condition = aModelQueryConfiguration.getCondition(scale);
if(condition == LOAD_NOTHING_CONDITION){
return Collections.emptySet().stream();
} else{
//only query the model when the condition indicates that data should be loaded
//this to avoid an expensive query call if we know upfront that the query will return nothing
return model.query(ILcdModel.condition(condition));
}
public static final double FULLY_ZOOMED_IN
Double.MAX_VALUE
).public static final double FULLY_ZOOMED_OUT
public ILcdOGCCondition getCondition(TLcdMapScale aScale)
aScale
- a map scalenull
(no filtering, all data should be loaded),
LOAD_NOTHING_CONDITION
(no data should be loaded) or another ILcdOGCCondition
(only data matching that condition should be loaded).
Consult the class javadoc for more information about the returned condition and how it should be interpreted.@Deprecated public ILcdOGCCondition getCondition(double aScale)
getCondition(TLcdMapScale)
to avoid any confusion about the semantic meaning of the scale parameterFULLY_ZOOMED_OUT
(=0.0) to FULLY_ZOOMED_IN
(=Double.MAX_VALUE
).
No modifications should be made to the returned condition.aScale
- The scale.null
(no filtering, all data should be loaded),
LOAD_NOTHING_CONDITION
(no data should be loaded) or another ILcdOGCCondition
(only data matching that condition should be loaded).
Consult the class javadoc for more information about the returned condition and how it should be interpreted.@Deprecated public List<Double> getScales()
getMapScales()
to avoid any confusion about the semantic meaning of the scale parameter
Builder builder = TLcdModelQueryConfiguration.newBuilder();
TLcdModelQueryConfiguration configuration =
builder.addContent(1e-5, 1e-7, majorRoadsCondition)
.addContent(FULLY_ZOOMED_OUT, FULLY_ZOOMED_IN, highWaysCondition)
.build();
would result in a scale list [1e-5, 1e-7]
because at those scales the condition instance changes.
The scales are expressed as a unitless 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 FULLY_ZOOMED_OUT
(=0.0) to FULLY_ZOOMED_IN
(=Double.MAX_VALUE
).
No modifications should be made to the returned list.getCondition(double)
would return the same condition
for each scale.public List<TLcdMapScale> getMapScales()
Builder builder = TLcdModelQueryConfiguration.newBuilder();
TLcdModelQueryConfiguration configuration =
builder.addContent(new TLcdMapScale(1d/500_000, 1d/50_000, majorRoadsCondition)
.addContent(MAX_ZOOMED_OUT, MAX_ZOOMED_IN, highWaysCondition)
.build();
would result in a scale list [1d/500_000, 1d/50_000]
because at those scales the condition instance changes.
No modifications should be made to the returned list.getCondition(TLcdMapScale)
would return the same condition for each scale.public static TLcdModelQueryConfiguration.Builder newBuilder()