Class TLspFusionVectorLayerBuilder

java.lang.Object
com.luciad.view.lightspeed.layer.ALspLayerBuilder
com.luciad.fusion.client.view.lightspeed.TLspFusionVectorLayerBuilder

public final class TLspFusionVectorLayerBuilder extends ALspLayerBuilder
Deprecated.
Since 2017.0 support for coverages of type VECTOR has been superseded with other mechanisms. Please refer to the Fusion migration guide for more information.

Builder class for creating ILspLayer instances for the visualization of LuciadFusion vector data in a Lightspeed view.

A layer, ready to be added to the view, can be created as follows:


   ILcdModel model = ...;
   ILspLayer layer = TLspFusionVectorLayerBuilder().newBuilder().model( model ).build();
 

The above snippet creates a layer with default visualization setting. If you want to customize this visualization, it is important to understand how the default visualization works, and what hooks are provided to customize this. This is explained in the next sections.

Default visualization

The layer created by this builder is by default configured with stylers for the body and the labels. These default stylers will ensure that:

Customize the visualization

It is perfectly possible to customize the visualization of the data on the client side by using the available API on this builder. However, if the custom visualization can be defined in SLD, it is highly recommended to fuse your vector data using an SLD file containing all the styling information. This SLD information will be picked up by the created layer automatically. Consult the javadoc of TLfnVectorCoverageMetadata for more information.

To customize the visualization, you can set your own ILspStyler for bodies and / or labels using the bodyStyler, bodyStyles, labelStyler or labelStyles methods. Consult the Writing your own ILspStyler section for more information on how to write your own styler for Fusion vector data.

Using any of the above mentioned methods will completely replace the default styling for bodies and/or labels. This means SLD styling is no longer picked up automatically and GeoSym styling is no longer automatically applied for VPF data. If you want to retain that functionality and only want to alter the default styling for other coverages, you can use the fallbackBodyStyler(com.luciad.view.lightspeed.layer.TLspPaintState, com.luciad.view.lightspeed.style.styler.ILspStyler) and/or fallbackLabelStyler(com.luciad.view.lightspeed.layer.TLspPaintState, com.luciad.view.lightspeed.style.styler.ILspStyler) methods.

Working with Fusion vector domain objects

Fusion vector domain objects implement ILcdDataObject and ILcdShapeList. While you can safely access all the ILcdDataObject methods, you should take care when using the ILcdShapeList API. Fusion vector features often have multiple geospatial representations: a same feature may for example be represented by a point at world-scale and a polygon at a more detailed zoom level. The ILcdShapeList interface of these features only provide access to the geometry of the feature at the most detailed level. This most detailed level geometry is typically not loaded yet, and must be retrieved on-demand when you access the ILcdShapeList API.

If you need access to the geometry of a LuciadFusion domain object (for example when writing an ILspLabelingAlgorithm) you must make sure you use the geometry associated with the tiles loaded for the level and bounds associated with the view. This geometry is obtained by calling the TLspFusionGeometryProvider.getGeometry(Object, com.luciad.view.lightspeed.TLspContext) method. Failing to do this will load the original untiled geometry, which will have to be retrieved at that moment and may be very costly.

Consult the javadoc of the TLspFusionGeometryProvider.getGeometry(Object, com.luciad.view.lightspeed.TLspContext) method for more information about the kind of geometries that will be returned.

This also has an effect on the ILspStyler instances which you set on this builder. See the next section for more information.

Writing your own ILspStyler

When writing your own ILspStyler for Fusion vector domain objects, you should avoid loading the most detailed geometries as this is a costly operation. To facilitate this, this builder will decorate all ILspStyler instances with an ALspStyleTargetProvider which uses the tile-specific geometry. As a result, you can simply use a regular styler as you would normally use in LuciadLightspeed:



   @Override
   void style(Collection<?> aObjects, ALspStyleCollector aStyleCollector, TLspContext aContext){
     List<Object> majorRoads = new List<Object>();
     List<Object> minorRoads = new List<Object>();
     for (Object domainObject : aObjects) {
       boolean isMajorRoad = "motorway".equals( ((ILcdDataObject)domainObject).getValue("roadType") );
       if (isMajorRoad) {
         majorRoads.add(domainObject);
       } else {
         minorRoads.add(domainObject);
       }
     }
     if (!majorRoads.isEmpty()){
       aStyleCollector.objects(majorRoads).style(fMajorRoadsStyle).submit();
     }
     if (!minorRoads.isEmpty() ){
       aStyleCollector.objects(minorRoads).style(fMajorRoadsStyle).submit();
     }
   }
 

The decorator will ensure that the correct geometry (=the tile-specific geometry) is placed on the style collector.

Note that when you place your own ALspStyleTargetProvider on the ALspStyleCollector, your own style target provider will never receive the domain objects. It will only receive the tile-specific geometries. The javadoc of TLspFusionGeometryProvider#getGeometry lists what those tile-specific geometries are.

It is important to note that in your styler you should NEVER call


   &#64;Override
   void style(Collection<?> aObjects, ALspStyleCollector aStyleCollector, TLspContext aContext) {
     for (Object domainObject : aObjects) {
       //NEVER DO THIS
       if (domainObject instanceof ILcdShapeList){
         ILcdShapeList shapeList = (ILcdShapeList) domainObject;
         ...
         //working with the ILcdShapeList API will trigger the loading of the most detailed tiles
         //this will kill the performance
       }
     }
   }
 
Since:
2012.1