-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for dashed lines using PolylineDash
- add tests; - add allowSyntheticDefaultImports to allow loading node assert and test modules.
- Loading branch information
Showing
7 changed files
with
172 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import test from 'node:test'; | ||
import assert from 'node:assert'; | ||
|
||
import {dashPattern} from './FeatureConverter'; | ||
|
||
function olPatternAsBinary(pattern: number[]): string { | ||
const pattern16 = dashPattern(pattern); | ||
return pattern16.toString(2); | ||
} | ||
|
||
test('pattern-100-100', (t) => { | ||
// Whatever the scaling, the result should be the same. | ||
// Only propoprtion matters. | ||
assert.strictEqual(olPatternAsBinary([100, 100]), '1111111100000000'); | ||
assert.strictEqual(olPatternAsBinary([1, 1]), '1111111100000000'); | ||
assert.strictEqual(olPatternAsBinary([999999, 999999]), '1111111100000000'); | ||
}); | ||
|
||
test('pattern-100-100-100-100', (t) => { | ||
// We should see 4 dashes of equal length. | ||
assert.strictEqual(olPatternAsBinary([100, 100, 100, 100]), '1111000011110000'); | ||
}); | ||
|
||
test('pattern-too-long', (t) => { | ||
// When the pattern is too long, here we have 200 segments | ||
// we should still ensure that the pattern is well formed (I guess): | ||
// - starts with a 1: | ||
// - ends with a 0. | ||
assert.strictEqual(olPatternAsBinary(Array.from({length: 200}, _ => 1)), '1000000000000000'); | ||
}); | ||
|
||
|
||
test('pattern-uneven', (t) => { | ||
// When the pattern is uneven, it is duplicated | ||
assert.strictEqual(olPatternAsBinary([6, 1, 2, 6, 1, 2]), '1111101100000100'); | ||
assert.strictEqual(olPatternAsBinary([6, 1, 2]), '1111101100000100'); | ||
assert.strictEqual(olPatternAsBinary([12, 2, 4]), '1111101100000100'); | ||
}); |
This file contains 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