The Real-time Engine component includes support for the visualization of radar video feeds in any format in a Lightspeed view. The following figure shows an example:

radar
Figure 1. Example of a radar video feed shown in a Lightspeed view

The package samples.realtime.lightspeed.radarvideo demonstrates the functionality discussed in this section.

Connecting to a custom radar feed

To visualize a radar feed, you need to connect to radar raw data and decode it. The radar source can be either a UDP stream or a sample-formatted file. The raw data for each radar sweep is parsed and converted to the input format that is necessary to call the addRadarSweep method of the TLcdRadar class.

Radar raw data includes at least the following fields to represent a radar sweep.

  • Start Azimuth - The azimuth at which the sweep starts, in degrees clock-wise from the up-direction.

  • End Azimuth - The azimuth at which the sweep ends, in degrees clock-wise from the up-direction.

  • Start Cell - The offset in number of cells at which the given sweep starts. You need this when the data of a single sweep line is split over multiple messages, for instance.

  • Cell Length - The radial size of the radar cells, in meters.

  • Amplitudes - The amplitudes of the cells.

radarSweep
Figure 2. Radar sweep representation

Creating a radar layer

The main API class used for radar visualization is TLspRadarVideoLayerBuilder. This builder creates an ILspLayer for models decoded from the raw radar data.

Program: Creating a radar layer using builder (from samples/realtime/lightspeed/radarvideo/RadarVideoLayerFactory)
public ILspEditableStyledLayer createLayer(ILcdModel aRadarModel) {

  ILspEditableStyledLayer radarLayer = TLspRadarVideoLayerBuilder
      .newBuilder()
      .selectable(false)
      .model(aRadarModel)
      .build();

  return radarLayer;

Radar video layers work with live data, and update automatically as new data is received. You can customize the appearance of the radar feed using TLspRadarVideoStyle. See the API reference documentation for this class for more detail about the available settings.

TLspRadarVideoLayerBuilder supports the same styling constructs as TLspShapeLayerBuilder. As such, you can paint decorations, range rings for example, on top of the radar feed without having to create an additional layer.

Creating a radar model

TLcdRadar is used to display radar data composed of radar sweeps. The position of the radar is defined by an ILcdModelReference in the model. The distance out from the center of the radar position indicates range, and the angle around the center is the azimuth to the target.

Program: Creating a radar model shows how to create a radar model by using an instance of TLcdRadar.

Program: Creating a radar model (from samples/realtime/lightspeed/radarvideo/format/SampleRadarVideoConnector)
ILcdModelReference modelReference = new TLcdGridReference(
    new TLcdGeodeticDatum(),
    new TLcdAzimuthalEquidistant(fRadarPosition.getX(), fRadarPosition.getY()),
    0, 0,
    1, 1,
    Math.toRadians(0)
);
TLcdDataType radarType = TLcdRadarVideoDataTypes.RADAR_VIDEO_DATA_TYPE;
TLcdVectorModel model = new TLcdVectorModel(
    modelReference,
    new TLcdDataModelDescriptor(fSourceName, "Radar", "Radar",
                                radarType.getDataModel(), Collections.singleton(radarType), Collections.singleton(radarType))
);

TLcdRadar radar = new TLcdRadar(radarType);
model.addElement(radar, ILcdModel.NO_EVENT);

Adding radar sweeps

You can use the addRadarSweep method to provide the radar sweeps decoded from the raw radar data to TLcdRadar. The API reference documentation for this class provides more detail about the method parameters. You must call this method within a write lock, using TLcdLockUtil.writeLock(model) and event mode ILcdModel.FIRE_LATER.

You can re-use the amplitudes array because TLcdRadar makes a copy of the data in the array. It is recommended to re-use the amplitudes array in the decoder after calling the addRadarSweep method to prevent excessive memory allocation.

Program: Adding a radar sweep shows how to add a radar sweep to the instance of TLcdRadar.

Program: Adding a radar sweep (from samples/realtime/lightspeed/radarvideo/format/SampleRadarVideoRecordDecoder)
aRadar.addRadarSweep(timeStamp,
                     startAzimuth,
                     endAzimuth,
                     startRange,
                     cellLength,
                     bitResolution,
                     fAmplitudesIntArray,
                     intArrayLength);