Class LuaRuleExecutor
Product-agnostic executor for the S-100 Part 9A Lua portrayal stage. Drives
the full pass — create context, load main.lua, run provider shims,
initialise and override context parameters, call PortrayalMain,
dedup and parse the emitted instructions, and apply post-parse transforms —
entirely through injected seams, so a single implementation serves every
Lua-portrayed product (S-101, S-131, S-57-as-S-101).
public sealed class LuaRuleExecutor : ILuaVectorRuleExecutor, IVectorRuleExecutor
- Inheritance
-
LuaRuleExecutor
- Implements
- Inherited Members
Remarks
All product variation is supplied at construction:
- ILuaRuleSource — module source + declared context parameters.
- ILuaDataProviderFactory — render-scoped host-API bridge.
- LuaContextParameterBinding list — mariner→parameter mapping policy.
- IFeatureAnchorProvider — optional anchor lookup during parse.
- ISpatialReferenceResolver — optional curve lookup for
SpatialReference. - IDrawingInstructionTransform list — optional post-parse transforms.
Constructors
LuaRuleExecutor(ILuaEngine, ILuaRuleSource, ILuaDataProviderFactory, string, IReadOnlyList<LuaContextParameterBinding>, IFeatureAnchorProvider?, IReadOnlyList<IDrawingInstructionTransform>?, ISpatialReferenceResolver?)
Initialises a new generic Lua rule executor.
public LuaRuleExecutor(ILuaEngine luaEngine, ILuaRuleSource source, ILuaDataProviderFactory providerFactory, string productTag, IReadOnlyList<LuaContextParameterBinding> contextParameterBindings, IFeatureAnchorProvider? anchorProvider = null, IReadOnlyList<IDrawingInstructionTransform>? transforms = null, ISpatialReferenceResolver? spatialReferences = null)
Parameters
luaEngineILuaEngineThe sandboxed Lua engine (S-100 Part 9A).
sourceILuaRuleSourceSupplies Lua module source and declared context parameters.
providerFactoryILuaDataProviderFactoryCreates a render-scoped host-API data provider.
productTagstringTelemetry product tag (e.g.
"S-101","S-131"); S-57 reuses the S-101 Lua pipeline and therefore tags as"S-101".contextParameterBindingsIReadOnlyList<LuaContextParameterBinding>Per-product mapping from MarinerSettings to declared context parameters, including any name aliases or inversions.
anchorProviderIFeatureAnchorProviderOptional feature-anchor lookup for augmented line tessellation during parse; null for products without augmented geometry.
transformsIReadOnlyList<IDrawingInstructionTransform>Optional ordered post-parse transforms (e.g. the S-101 SAFCON label merger); null or empty when none are required.
spatialReferencesISpatialReferenceResolverOptional resolver for
SpatialReferencecommands, so lines drawn on particular edges (such as the safety contour) follow those edges only; null for products whose rules emit none.
Methods
ExecuteAsync(MarinerSettings, CancellationToken)
Runs the rule stage and returns typed drawing instructions ready for the renderer.
public Task<IReadOnlyList<DrawingInstruction>> ExecuteAsync(MarinerSettings mariner, CancellationToken cancellationToken = default)
Parameters
marinerMarinerSettingsMariner-configurable display preferences (S-100 Part 9 §4.2).
cancellationTokenCancellationTokenSignals that the render has been cancelled. Script interpreters are generally not interruptible mid-evaluation, so implementations honour the token at coarse boundaries; the asynchronous shape exists to allow implementations to await catalogue asset loads (compiled XSLT, Lua source) before driving the synchronous engine.
Returns
ExecuteRawAsync(MarinerSettings, CancellationToken)
Runs the Lua portrayal pass and returns the raw emitted drawing-instruction strings keyed by feature reference, without parsing or post-processing.
public Task<IReadOnlyList<EmittedInstruction>> ExecuteRawAsync(MarinerSettings mariner, CancellationToken cancellationToken = default)
Parameters
marinerMarinerSettingsMariner-configurable display preferences (S-100 Part 9 §4.2).
cancellationTokenCancellationTokenHonoured at coarse boundaries before Lua invocation.
Returns
OpenSessionAsync(MarinerSettings, CancellationToken)
Opens a Lua portrayal session: one Lua state, set up with the
catalogue's rules and mariner's context parameters,
that portrays chosen features on demand
(Portray(IReadOnlyCollection<string>)). Setting up the state is
most of the cost of portraying a few features, so a caller that
portrays features in batches, such as a route check leg by leg, keeps
one session.
public Task<LuaPortrayalSession> OpenSessionAsync(MarinerSettings mariner, CancellationToken cancellationToken = default)
Parameters
marinerMarinerSettingsThe mariner settings, for the context parameters.
cancellationTokenCancellationTokenCancels loading the rules.
Returns
- Task<LuaPortrayalSession>
The session; the caller disposes it.