-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add coalesce expression, evaluate text anchor, allow simpler expressi…
…ons for layer selector
- Loading branch information
1 parent
d2bc8ee
commit 55539d5
Showing
7 changed files
with
50 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import 'expression.dart'; | ||
|
||
class CoalesceExpression<T> extends Expression<T> { | ||
final Iterable<Expression<T>> _delegates; | ||
|
||
CoalesceExpression(this._delegates); | ||
|
||
@override | ||
T? evaluate(Map<String, dynamic> args) { | ||
for (final delegate in _delegates) { | ||
final result = delegate.evaluate(args); | ||
if (result != null) return result; | ||
} | ||
|
||
return null; | ||
} | ||
} |
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,16 @@ | ||
import 'package:vector_tile_renderer/src/expressions/coalesce_expression.dart'; | ||
import 'package:vector_tile_renderer/src/expressions/expression.dart'; | ||
|
||
import 'parser.dart'; | ||
import 'parsers.dart' as Parsers; | ||
|
||
class CoalesceParser<T> extends Parser<T> { | ||
@override | ||
Expression<T>? parseSpecial(data) { | ||
if (data is! List) return null; | ||
|
||
final delegates = | ||
data.skip(1).map((i) => Parsers.parse<T>(i)).whereType<Expression<T>>(); | ||
return CoalesceExpression(delegates); | ||
} | ||
} |
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
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