Class TLcyLspRasterFormat


public class TLcyLspRasterFormat extends ALcyLspStyleFormat

Extension of ALcyLspStyleFormat for raster and Earth formats. It provides a custom implementation of the createLayerFactoryImpl() method, which supports the same models as documented in TLspRasterLayerBuilder. This layer factory allows to make small changes to the created layers before they leave the layer factory by calling customizeLayer for each layer it creates.

Extensions of this class can override the customizeLayer method but this only makes sense for small changes (e.g. changing the icon of the layer).

Warning: this format should be wrapped with a TLcyLspSafeGuardFormatWrapper before plugging it into the Lucy back-end.

Since:
2012.0
See Also:
  • Constructor Details

    • TLcyLspRasterFormat

      public TLcyLspRasterFormat(ILcyLucyEnv aLucyEnv, String aLongPrefix, String aShortPrefix, ALcyProperties aPreferences, ILcdFilter<ILcdModel> aModelFilter)
      Create a new raster format
      Parameters:
      aLucyEnv - The Lucy back-end
      aLongPrefix - The long prefix of this format.
      aShortPrefix - The short prefix of this format
      aPreferences - The preferences
      aModelFilter - Filter used to determine whether a model can be handled by this format. When the model can be handled by this format, it should be accepted by the filter. Filter must not be null. null models will never be passed to the filter, but always rejected.
  • Method Details

    • createLayerFactoryImpl

      protected final ILspLayerFactory createLayerFactoryImpl()
      Description copied from class: ALcyLspStyleFormat

      Creates the layer factory for this format. This method will be called from the ALcyLspStyleFileFormat.createLayerFactory() method. This factory must not return ILcdLayerTreeNode instances. In case you want to support empty nodes, consider using a TLcyLspLayerTreeNodeFormatWrapper.

      Layer requirements

      The layers returned by this layer factory should match the following requirements:

      Layer styling

      The default style of this format as defined in the default style file will be automatically applied on each layer. If a style is present next to the model source file of the layer, this style will be applied as well. It is not necessary to include this functionality in the layer factory returned by this method.

      Note however that an SLD style file can only be applied on layers which use SLD styling, and customizable styler based style files can only be applied on layers which use an ILspCustomizableStyler. This means that the layer factory decides which kind of styling is available for which layer.

      To facilitate this, this format has a utility method to check whether SLD styling can be found for a certain model. The layer factory can opt to use this method to decide between SLD based styling or customizable styler based styling.

      An example implementation of this method could be:

      
       return new ALspSingleLayerFactory() {
           @Override
           public ILspLayer createLayer(ILcdModel aModel) {
             //This example implementation assumes the data is vector data
             TLcdSLDFeatureTypeStyle featureTypeStyle = retrieveFeatureTypeStyle(aModel);
      
             if(featureTypeStyle == null){
               //create a customizable styler with default styles and set it on the layer
               TLspCustomizableStyler bodyStyler = new TLspCustomizableStyler(
                   TLspLineStyle.newBuilder().elevationMode(ILspWorldElevationStyle.ElevationMode.ON_TERRAIN)
                                             .color(Color.WHITE)
                                             .width(2)
                                             .build(),
                   TLspFillStyle.newBuilder().elevationMode(ILspWorldElevationStyle.ElevationMode.ON_TERRAIN)
                                             .color(new Color(255, 255, 0, 128))
                                             .build(),
                   TLspIconStyle.newBuilder().icon(new TLcdSymbol(TLcdSymbol.FILLED_RECT, 5)).build()
               );
      
               return TLspShapeLayerBuilder.newBuilder()
                           .model(aModel)
                           .bodyStyler(TLspPaintState.REGULAR, bodyStyler)
                           .build();
             } else {
               //Create a layer which uses SLD styling
               return TLspShapeLayerBuilder.newBuilder()
                           .model(aModel)
                           .sldStyle(featureTypeStyle)
                           .build();
             }
           }
      
           @Override
           public boolean canCreateLayers(ILcdModel aModel) {
             //the format should be wrapped with a TLcyLspSafeGuardFormatWrapper so we can just return true
             return true;
           }
        };
       
      Specified by:
      createLayerFactoryImpl in class ALcyLspStyleFormat
      Returns:
      The layer factory for this format. May be null
    • customizeLayer

      protected void customizeLayer(ILspEditableStyledLayer aRasterLayer)

      Each layer created by the layer factory of this format is passed to this method. Overriding this method allows to make changes to the created layers, for example adjusting the icon of the layer.

      If you need to make major changes to the layer (for example setting a new painter), it is recommended to extend from ALcyLspStyleFormat directly instead of using this format.

      Warning: the layers must fulfil the requirements documented in the createLayerFactoryImpl() method.

      Parameters:
      aRasterLayer - The layer created by the layer factory.
    • createLayerMeasureProviderFactory

      protected ILcdLayerMeasureProviderFactory createLayerMeasureProviderFactory()

      Creates a ILcdLayerMeasureProviderFactory that can create measure providers for a layer created by the layer factories of this format.

      These measurements could for example used by a mouse readout to display the measure value at the current location of the mouse cursor.

      Overrides:
      createLayerMeasureProviderFactory in class ALcyLspFormat
      Returns:
      an ILcdLayerMeasureProviderFactory instance. Can be null.
      See Also: