Lucy allows you to visualize LOS coverages on Lightspeed maps.

To find out what a LOS coverage is, see About Line-Of-Sight (LOS) Coverages.

Starting from a TLcyLOSManager instance, you can add line-of-sight visualizations to domain objects on the map, and remove them again. The TLcyLOSManager also helps you configure the properties of the line-of-sight coverage. This article shows you how to use the TLcyLOSManager.

Creating a LOS coverage

The TLcyLOSManager offers the TLcyLOSManager.addLOSCoverage method to create a LOS coverage for a given domain object. This domain object must be a point which will be the center of the line-of-sight.

TLcyLOSManager losManager = aLucyEnv.getService(TLcyLOSManager.class);
if (losManager.canAddLOSCoverageFor(aDomainObjectContext)) {
  TLcyLOSDomainObject losDomainObject = losManager.addLOSCoverage(aDomainObjectContext);
}

Before you create a line-of-sight coverage, use the canAddLOSCoverageFor method to check whether the domain object context is valid for LOS coverage creation.

Next, you must request the TLcyLOSManager through the Lucy service mechanism. For more information about the Lucy services mechanism and ILcyLucyEnv.getService, see the Lucy Services Mechanism documentation.

All calls to the TLcyLOSManager must originate from the event dispatch thread (EDT). If they do not, you will get an error stating that the EDT is required.

Removing a LOS coverage

To remove LOS coverages from the map, use TLcyLOSManager.removeLOSCoverage.

losManager.removeLOSCoverage(aDomainObjectContext);

Modifying a LOS coverage

To change the calculation settings for a LOS coverage, first lock the line-of-sight model as shown in the example below. Next, create a TLspLOSProperties object on which you can set the new properties. Once the properties are set, call TLcyLOSDomainObject.setLOSProperties.

final ILcdModel losModel = losManager.getLOSModel(losDomainObject);
try (TLcdLockUtil.Lock writeLock = TLcdLockUtil.writeLock(losModel)) {
  TLspLOSProperties losProperties = new TLspLOSProperties(losDomainObject.getLOSProperties());
  losProperties.setAngleStep(1);
  losProperties.setRadiusStep(125);
  losProperties.setMinVerticalAngle(0);
  losProperties.setMaxVerticalAngle(180);
  losProperties.setRadius(2000);
  losDomainObject.setLOSProperties(losProperties);
  losModel.elementChanged(losDomainObject, ILcdModel.FIRE_LATER);
} finally {
  losModel.fireCollectedModelChanges();
}

If you try altering the properties directly, the changes won’t be picked up.