Lucy already supports a lot of data formats out-of-the-box, but you can add support for custom formats as well. The most basic support consists of:
Most of the format support functionality in Lucy includes more than basic model decoding and layer visualization. For example, there is workspace support for both the layers and the models, there are customizer panels that allow users to modify the layer properties through the UI, there are layer style codecs, and so on. All those instances must be registered with the Lucy back-end so that Lucy can access them.
ALcyLspFormat follows the Abstract Factory design pattern, and groups the creation of all those concepts for a format in one class by defining
factory methods. You can pass a concrete implementation of
ALcyLspFormat to a
TLcyLspFormatTool, which registers all instances created in the format with the Lucy back-end.
While it is possible to extend
ALcyLspFormat directly, you have access to more specialized sub-classes that already provide some commonly required functionality:
ALcyLspGeneralFormat: this specialization works with a properties object holding the configuration of the format.
TLcyLspRasterFormat: these specializations provide support for Lightspeed layer styles. More details about these formats are available in the Styling Lightspeed Layers reference guide where the Lightspeed layer style concepts are introduced and discussed.
The Lucy framework provides some common format-related functionality in the form of
ALcyLspFormatWrapper instances. The availability of wrappers allows add-ons to re-use format-supporting functionality by wrapping their
ALcyLspFormat, following the "Decorator" design pattern.
ALcyLspFormatWrapper instances are available:
TLcyLspSafeGuardFormatWrapper: this wrapper ensures that all layer factories, encoders, type providers, and so on, only operate on layers created by the wrapped format. This means that you do not need those checks in the wrapped
ALcyLspFormat, resulting in less cluttered and more maintainable code in the wrapped format.
TLcyLspLayerTreeNodeFormatWrapper: this wrapper provides the support needed to use layer nodes in your data format.
Each of those wrappers make certain assumptions that are documented in the reference documentation of these classes. Make sure to read that documentation to verify that your format corresponds to these assumptions.
Lucy has a modular design. Therefore, it is recommended to have a dedicated add-on providing support for a new format. The
appropriate base class for such an add-on is
ALcyLspFormatAddOn. If you use it, you don’t need to write any boiler-plate code, and you can focus on implementing the
ALcyLspFormat instance. This is illustrated in the BestPractice sample. For an example, see the
Each format supported by Lucy typically has its own add-on. Most of these add-ons expose the
ALcyLspFormat by extending from
ALcyLspFormatAddOn. This add-on has protected methods that expose the creation of the
ALcyLspFormat. Overriding this method allows you to customize it.