Commit Graph

47 Commits

Author SHA1 Message Date
Ander Conselvan de Oliveira
f210bbbb6c [core] Don't use optional unique_ptr in function coversion code
Since unique_ptr is already nullable there is no need to wrap it in an
optional<>.
2019-05-21 12:14:22 +03:00
Ander Conselvan de Oliveira
33cfd080c2 [core] Fix most identity function with default legacy expression tests
Add handling of default value to the conversion of legacy identity
functions. The color and enum tests still don't pass though.
2019-05-21 12:14:22 +03:00
Alexander Shalamov
69e11155c8 [core] Forward evaluation context directly to evaluated property
So that default value owned by the FormatSectionOverride, can be
evaluated based on required context parameters.
2019-03-15 10:37:45 +02:00
Alexander Shalamov
8be135231d [core] Add possibility of overriding paint properties inside format expression #14062
* [core] Add format override expression and formatted section to evaluation context

* [core] Add textColor to TaggedString's formatted section

* [core] Add FormatSectionOverrides and introduce overridable properties

* [core] Populate symbol layer paint properties for text sections

* [core] Add benchmark for style that uses text-color override

* [core] Add unit test for FormatOverrideExpression

* [core] Add unit test for FormatSectionOverrides
2019-03-13 17:14:53 +02:00
Konstantin Käfer
64559a255b [core] convert CompoundExpressionRegistry to constexpr hash map 2018-12-04 16:20:51 +02:00
Konstantin Käfer
2b9f3aad9a [core] use constexpr map using eternal for expression lookups 2018-12-04 16:20:51 +02:00
Chris Loer
d0cd49f516 [ios, macos] Minimal darwin wrappers of 'format' expression
Add support for `MGL_FUNCTION('format', <text>, <options dictionary>)`
2018-10-15 13:15:46 -07:00
Chris Loer
ce76bde13d [core] Initial implementation of 'format' expression 2018-10-15 13:15:46 -07:00
John Firebaugh
2e93a9ddcf [core] For string-valued properties, do coercion rather than assertion 2018-09-19 14:54:38 -07:00
John Firebaugh
89b075f592 [core] Auto-convert concat arguments to strings 2018-09-19 14:54:38 -07:00
John Firebaugh
2c48b5a292 [core] Implement array assertion fallback behavior
This was added in gl-js in #7095.
2018-09-13 15:55:34 -07:00
Chris Loer
50f9381ad3 [core] Fix cubic-bezier interpolation for zooms outside stop range.
Fixes issue #12812.
Using `util::interpolationFactor` handles the case where inputLevels.min == inputLevels.max, so it returns an interpolation factor of "0" instead of dividing by 0.
2018-09-06 11:10:10 -07:00
Konstantin Käfer
112bbc7ab2 [core] make style/conversion.hpp implementation private 2018-08-19 13:09:16 +02:00
Mikhail Pozdnyakov
0ec4a84c31 Rename EvaluationContext::heatmapDensity to colorRampParameter
More generic name as the same class member is to be used by the
linear gradient properties.
2018-08-07 18:31:59 +03:00
Anand Thakker
d25e1a1e7f Relax typing for comparison operators (#12537)
* Relax typing for comparison operators

Ports https://github.com/mapbox/mapbox-gl-js/pull/6961

* Review comments

* Lint fixes
2018-08-02 13:48:47 -04:00
John Firebaugh
bf7785618a [core] Simplify CompoundExpression implementation 2018-07-30 14:08:27 -07:00
Sudarsana Babu Nagineni
15a1c7b71f Fix compilation errors with libc++ on QNX 7
This patch fixes the compilation errors on QNX 7:
1) QNX 7 compiler (i.e qcc based GCC 5.4.0 with libc++ from LLVM) has a
limited c++11 feature support and causing the compilation
errors with the inheriting constructors. This fixes the issues by
providing the required constructors explicitly.

2) Resolves an ambiguous overload error with optional<T>
2018-07-30 12:38:24 +03:00
Bruno de Oliveira Abinader
cb714d57c5 [core] Replace expressions RTTI with enums + static cast 2018-07-24 10:06:18 +03:00
John Firebaugh
af89318b1d [core] Convert token strings to expressions 2018-07-20 12:35:00 -07:00
John Firebaugh
c8edbb0500 [core] Replace {Source,Camera,Composite}Function with PropertyExpression 2018-07-20 11:56:30 -07:00
John Firebaugh
a6727921fc [core] Convert legacy functions directly to expressions 2018-07-13 13:37:27 -07:00
John Firebaugh
f7e2fe5e38 [core] Simplify Value conversions
Use a single template function for each of {to,from}ExpressionValue, always dispatching to ValueConverter.

Remove unused ValueConverter::ExpressionType typedefs.
2018-07-12 09:42:55 -07:00
Chris Loer
9ff5d34ef2 [core] Introduce "collator" expressions
Cross platform parsing and evaluation code.
2018-07-03 10:03:05 -07:00
John Firebaugh
647959a853 [core] Add assertions to expression constructors 2018-06-29 15:38:11 -07:00
John Firebaugh
6dfe56510c [darwin] Replace use of *Stops with expressions DSL 2018-06-29 15:38:11 -07:00
John Firebaugh
542a4b4501 [core] Replace use of *Stops with expressions DSL 2018-06-29 15:38:11 -07:00
John Firebaugh
e323daf71f [core] InterpolateBase → Interpolate; Interpolate → InterpolateImpl 2018-06-28 10:00:40 -07:00
John Firebaugh
1dd35eface [core] Privatize Interpolate<T> 2018-06-28 10:00:40 -07:00
John Firebaugh
b2f6acca61 [core] Move non-polymorphic Interpolate methods to base 2018-06-28 10:00:40 -07:00
John Firebaugh
bc771ee02e [core] Split Interpolator into a separate file 2018-06-28 10:00:40 -07:00
Lucas Wojciechowski
a4e2c1af1f [core] Convert "legacy" filters directly into expressions (#11610)
Ports the specialized filter-* expressions from GL JS, adding them to src/mbgl/style/expression/compound_expression.cpp
2018-05-10 12:37:14 -07:00
Anand Thakker
352d63d2ce Don't enforce ["zoom"] constraints for filters (#11672)
* Don't enforce ["zoom"] constraints for filters

Fixes #11594

* Add a couple of comments

* Fix ambiguous constructor call

* ParsingContext(optional<Type>) => ParsingContext(Type)
2018-04-12 16:02:48 -04:00
Anand Thakker
8d26f74091 Fix style parsing bug for constant expressions (#11606)
* Fix style parsing bug for constant expressions

Closes #10849

* Ignore tests for unported GL JS change

Refs https://github.com/mapbox/mapbox-gl-js/pull/6429

* Fuller fix

* Update mapbox-gl-js
2018-04-09 17:59:18 -04:00
John Firebaugh
54f3dc961e Relax type checking for "length" 2018-03-01 17:02:26 -08:00
Chris Loer
75feda12f1 [core] Implement Expression::serialize()
Issue #10714
- Each expression stores its operator as a string, and default serialization is [operator, serialize(child1), ...]
- Custom implementations of `serialize` for Expression types that don't follow the pattern
- expression::Value -> mbgl::Value converter
- node_expression bindings to expose `serialize`
2018-02-28 16:09:09 -08:00
Anand Thakker
b16893f903 Correctly parse constant expressions in dds style properties (#11282)
* Correctly parse constant expressions in dds style properties

Closes #10849

* Clarify
2018-02-21 21:39:33 -05:00
Minh Nguyễn
fb5b8d34f2 Reimplement style values atop NSExpression (#10726)
* [ios, macos] Import headers, not implementation files

* [core] Added accessors for various expression parameters

Added missing parameter accessors to various expression operator classes, as well as a method on InterpolatorBase and Step that enumerates the stops and their values.

* [ios, macos] Silenced warning in test of error condition

* [ios, macos] Made MGLSphericalPosition boxable

* [ios, macos] Implemented array enumeration during conversion

* [ios, macos] Temporarily ignore heatmap layer type

* [ios, macos] Migrated MGLSymbolStyleLayer.text to NSExpression

MGLSymbolStyleLayer.text is now of type NSExpression instead of MGLStyleValue, as a first step toward migrating the entire layer API from style values to expressions.

Implemented conversions from NSExpression to JSON arrays and vice versa. The most common NSExpression functions are now converted into style expressions, but not all of the most common style expression operators are supported yet.

* [ios, macos] Implemented string coercion

* [ios, macos] Color literals

* [ios, macos] Null constant expressions

* [ios, macos] Convert dictionary literals

* [ios, macos] Interpolation expressions

* [ios, macos] to-boolean, to-number, get from object

* [ios, macos] Variable expressions

Implemented custom expression functions for assigning and referring to variables within the context of an expression. Variables are assigned via a “context dictionary” and applied to an subexpression that is given as another argument to the same expression. Also implemented built-in variable expressions for zoom level and heatmap density.

* [ios, macos] Convert colors, offsets, padding in expressions to JSON objects

* [ios, macos] Expression-based style property getters

Implemented a conversion from mbgl::style::PropertyValues to Objective-C JSON objects, which are then converted to NSExpressions.

* [ios, macos] Consolidated property value–expression conversion in MGLStyleValueTransformer

* [ios, macos] Predicate and expression guide

Extracted documentation about predicates from a documentation comment in MGLVectorStyleLayer.h to a new jazzy guide. Added details about NSExpression support as well. Began updating the “For Style Authors” guide to reflect the transition from style values to expressions.

* [ios, macos] Updated style authoring guide

Updated the Information for Style Authors guide to discuss expressions instead of style functions. Included a table mapping style specification expression operators to NSExpression syntaxes.

* [ios, macos] Migrated codegen templates to expressions

* [ios, macos] Applied expression changes via codegen

Ran make darwin-style-code.

* [macos] Migrated macosapp to expressions

* [ios, macos] Updated style function guide

This guide needs to be thoroughly rewritten, but for now the example code has been migrated to expressions.

* [ios, macos] Eviscerated style function tests

* [ios, macos] Updated changelogs

* [ios] Migrated iosapp to expressions

* [ios, macos] Exposed JSON conversion methods publicly

* [ios, macos] Removed MGLStyleValue, MGLStyleFunction
2018-01-24 00:04:02 -08:00
John Firebaugh
76ed5079a5 [core, ios, macos, android] Add data-driven-styling support for text-font 2018-01-10 15:31:12 -08:00
John Firebaugh
cedda5ef4f [core] Handle NaN input to interpolate and step 2018-01-10 13:45:00 -08:00
John Firebaugh
0eb4b5cc0e [core] Omit inferred type annotations for 'coalesce' arguments 2018-01-09 17:27:02 -08:00
John Firebaugh
a13027c1b6 [core] Improve typing for !=, == expressions 2018-01-09 16:10:51 -08:00
Thiago Marcos P. Santos
5b789aa4d6 [windows][core] Include what you use 2018-01-08 22:58:20 +02:00
Jason Wray
7ece4f6280 [core] Fix copy in range-based for loops
Caught by `CLANG_WARN_RANGE_LOOP_ANALYSIS = YES`.
2017-12-15 19:21:44 -05:00
Bruno de Oliveira Abinader
3bef7593a6 [build] Clang-3.8: Explicit mbgl::style::expression::Result default ctor 2017-11-14 19:01:04 +02:00
Bruno de Oliveira Abinader
2c51901400 [build] Clang-3.8: Default init of a const type requires user-provided ctor 2017-11-14 19:01:04 +02:00
Thiago Marcos P. Santos
92608f5885 [core] Fix build on Android + GCC and Android + armeabi
Sadly we don't have bots for these two setups.
2017-11-12 13:17:57 -02:00
Anand Thakker
f648cfeef6 Implement Expressions (#9439)
Ports https://github.com/mapbox/mapbox-gl-js/pull/4777 (and its several follow-ups)
2017-11-08 12:34:02 -05:00