Class TLcdModelQueryConfiguration

java.lang.Object
com.luciad.view.TLcdModelQueryConfiguration

public final class TLcdModelQueryConfiguration extends Object
This class defines which 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.

Condition combinations

The 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:

  • Single condition defined for a scale: the condition is used.
  • Multiple conditions defined for a scale: an OR condition containing each of the conditions is used.
  • Combination of 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.
  • Combination of a 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.
  • No condition defined for a scale: when a scale does not fall in any of the scale intervals specified on the builder, the non defined scale condition will be returned.

Example


   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

More examples

Show everything

This configuration will load all data over the whole scale range.

   TLcdModelQueryConfiguration config =
     TLcdModelQueryConfiguration.newBuilder().loadEverythingForUndefinedScales().build();
 

Setting a layer scale range

This configuration is the equivalent of setting a layer scale range: all data will be loaded in that scale range, and no data will be loaded outside that range.

   TLcdModelQueryConfiguration config =
     TLcdModelQueryConfiguration.newBuilder()
                                .addContent(1e-6, 1e-3, myDataCondition)
                                .loadNothingForUndefinedScales()
                                .build();
 
Since:
2017.0
  • Field Details

    • LOAD_NOTHING_CONDITION

      public static final ILcdOGCCondition LOAD_NOTHING_CONDITION
      Condition which can be used to indicate that no data should be loaded by always evaluating to 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));
         }
       
    • FULLY_ZOOMED_IN

      public static final double FULLY_ZOOMED_IN
      Scale value corresponding to a view which is completely zoomed in (= a scale of Double.MAX_VALUE).
      See Also:
    • FULLY_ZOOMED_OUT

      public static final double FULLY_ZOOMED_OUT
      Scale value corresponding to a view which is completely zoomed out (= a scale of 0.0)
      See Also:
  • Method Details

    • getCondition

      public ILcdOGCCondition getCondition(TLcdMapScale aScale)
      Returns the condition corresponding to the specified map scale ratio. No modifications should be made to the returned condition.
      Parameters:
      aScale - a map scale
      Returns:
      the condition for the specified scale. This can be 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.
      Since:
      2021.0
    • getCondition

      @Deprecated public ILcdOGCCondition getCondition(double aScale)
      Deprecated.
      use getCondition(TLcdMapScale) to avoid any confusion about the semantic meaning of the scale parameter
      Returns the condition corresponding to the specified scale.

      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 condition.

      Parameters:
      aScale - The scale.
      Returns:
      the condition for the specified scale. This can be 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.
    • getScales

      @Deprecated public List<Double> getScales()
      Deprecated.
      use getMapScales() to avoid any confusion about the semantic meaning of the scale parameter
      Returns the scales at which point another condition becomes valid. The scales are ordered from small to large.

      For example

      
         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.

      Returns:
      a list containing the scales at which another condition becomes valid ordered from small to large. Empty when getCondition(double) would return the same condition for each scale.
    • getMapScales

      public List<TLcdMapScale> getMapScales()
      Returns the map scales at which point another condition becomes valid. The scales are ordered from small to large.

      For example

      
         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.

      Returns:
      a list containing the scales at which another condition becomes valid ordered from small to large. Empty when getCondition(TLcdMapScale) would return the same condition for each scale.
      Since:
      2021.0
    • newBuilder

      public static TLcdModelQueryConfiguration.Builder newBuilder()
      Create a new builder instance
      Returns:
      a new builder instance