Repository navigation
Collapse the renderMetatile overloads into one - #121
Merged
Merged
Conversation
- The clamping range is public as WorkQueue.concurrencyRange, so callers can validate their own input instead of discovering the clamp after the fact. - The property and the initializer share one clamp helper instead of duplicating `max(1, min(256, ...))`. - maxConcurrency's documentation now states the clamping and documents the previously undocumented mid-run behaviour: raising the limit takes effect on the next refill, lowering it does not interrupt running processWork calls, so concurrency can briefly exceed the new limit. - setMaxConcurrency stays, but its documentation explains why it exists rather than reading as a redundant duplicate: Swift only permits mutating actor state from inside the actor, so it is the supported way to change the limit from outside. Tests - Clamping is asserted against concurrencyRange instead of hard-coded numbers. - New test that raising the limit mid-run actually increases observed parallelism, which is the behaviour the docs now promise. Fixes #99
There were three overloads with overlapping semantics: one took
(origin, metaSize), one took a Metatile plus RenderOptions, and one took a
Metatile plus MetatileOptions. The last two were easy to confuse, and
MetatileOptions duplicated the block size that Metatile already carries.
Now there is a single entry point:
renderMetatile(_ metatile: Metatile, options: RenderOptions = .tile())
The block size comes from Metatile.metaSize, so there is one source of truth
and no way to pass a metaSize that disagrees with the block. RenderOptions
only controls per-tile rendering (size, scale, format, buffer).
- MetatileOptions is removed. Its pixel-dimension helpers move to
Metatile.pixelSize(for:), which returns nil instead of trapping when the
dimensions do not fit in an Int.
- The mismatched-metaSize guard is gone: the situation can no longer arise.
- renderMetatile validates the block against the tile grid and rejects a
block whose pixel buffer would not fit, both as MapnikError.invalidInput.
This is a breaking change: callers using renderMetatile(origin:metaSize:),
renderMetatile(_:options:) with MetatileOptions, or MetatileOptions itself
need to construct a Metatile and pass RenderOptions.
Tests and docs updated; a new test asserts the block size comes from the
Metatile, and that an out-of-range pixel size is reported rather than
trapping.
Fixes #86
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three
renderMetatileoverloads with overlapping semantics are now one, andMetatileOptionsis gone. The block size has a single source of truth:Metatile.metaSize.This is a breaking change (see below).
Before
MetatileOptionsbundledmetaSizeandRenderOptions, so a call that already had aMetatilecarried the block size twice — and the two could disagree. TheRenderOptionsoverload silently usedmetatile.metaSize; theMetatileOptionsoverload silently usedoptions.metaSizeand threw on a mismatch.After
Metatile.metaSize;RenderOptionsonly controls per-tile rendering.metaSizeguard is gone — the situation can no longer arise.MetatileOptions' pixel-dimension helpers moved toMetatile.pixelSize(for:), which returnsnilinstead of trapping when the dimensions do not fit in anInt.A trap I fixed on the way
The first version of
pixelSize(for:)used a plainInt(...)conversion and crashed the test suite:That is the same class of bug as #17. It now returns
nil, andrenderMetatilereports it:Testing
Metatile, not the options.pixelSize(for:)is asserted for square and non-square options, plus thenilcase.swiftformat --lintclean, DocC builds with--warnings-as-errors.Breaking changes
MetatileOptionsis removed.renderMetatile(origin:metaSize:options:)is removed — construct aMetatileinstead.renderMetatile(_:options:)no longer acceptsMetatileOptions.MetatileOptions.metatileWidth/metatileHeight/metatileSizeare replaced byMetatile.pixelSize(for:).Migration:
Closes #86