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:

  • Model decoders to convert the source, such as a file, to an ILcdModel

  • Layer factories to create ILcdLayer instances for those models, allowing you to visualize the models in a view

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.

The ALcyFormat and ALcyLspFormat classes follow the Abstract Factory design pattern, and group the creation of all the related concepts for a format by defining factory methods.

ALcyFormat offers support for model handling, and also supports visualization in the GXY view. Support for the visualization of a format in a Lightspeed view is provided by the ALcyLspFormat class, though.

For example, the TLcyGeoJsonAddOn handles model support and GXY view visualization for the GeoJSON data format, but the TLcyLspGeoJsonFormatAddOn handles functionality related to the visualization of GeoJSON data in a Lightspeed view.

See Building blocks for adding new formats in GXY views for more information on this.

You can pass a concrete implementation of ALcyLspFormat to a TLcyLspFormatTool, which registers all instances created in the format with the Lucy back-end.

Implementing your own format

While it is possible to extend ALcyLspFormat directly, you have access to more specialized sub-classes that already provide some commonly required functionality:

You can access other common functionality by decorating an ALcyLspFormat with an ALcyLspFormatWrapper, as discussed in the next section.

Re-using common format functionality

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.

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

Creating an add-on for your format

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 two separate tutorials to create static and editable formats, respectively.

ALcyLspFormat has useful extensions, such as TLcyLspVectorFormat and TLcyLspRasterFormat. They both provide default implementations for most of the abstract methods of ALcyLspFormat. Consult the Styling Lightspeed Layers reference guide and the Javadoc of the ALcyLspFormat extensions to decide which format is the most appropriate to extend from when you are creating your own ALcyLspFormat.

Modifying existing data formats

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.

If the add-on does not expose its ALcyLspFormat, or if you want complete control over a certain format, you can remove the default add-on and replace it with your own version. See Creating an add-on for your format for more information.