Repository navigation
[core] Enable property functions for text-{field,transform} - #7944
Conversation
|
@anandthakker, thanks for your PR! By analyzing this pull request, we identified @jfirebaugh, @1ec5 and @boundsj to be potential reviewers. |
|
|
|
Okay, maybe not: I didn't trust the "Comiling parser.cpp" in the |
|
Alright, new hypothesis: the new data driven properties I'm adding here,
|
|
Took a crack at solving the issue w/ converting non-interpolatable in 941c7a8, using @jfirebaugh is there a cleaner or more idiomatic way to do this? |
| Value to use for a text label. Feature properties are specified using tokens | ||
| like {field_name}. | ||
| like {field_name}. (Token replacement is only supported for literal text-field | ||
| values--not for data-driven property functions.) |
There was a problem hiding this comment.
Did you add this note manually after running make style-code? If so, it’ll be wiped away the next time someone runs make style-code. Make sure to put any documentation overrides in platform/darwin/scripts/style-spec-overrides-v8.json.
There was a problem hiding this comment.
Nope! The note comes directly from the description of this property in v8.json
There was a problem hiding this comment.
Ah, I was confused because this page doesn’t include the new wording.
| Value to use for a text label. Feature properties are specified using tokens | ||
| like {field_name}. | ||
| like {field_name}. (Token replacement is only supported for literal text-field | ||
| values--not for data-driven property functions.) |
There was a problem hiding this comment.
Surround “text-field” in backticks. This allows generate-style-code.js to replace it with text (the overridden name of this property).
| Value to use for a text label. Feature properties are specified using tokens | ||
| like {field_name}. | ||
| like {field_name}. (Token replacement is only supported for literal text-field | ||
| values--not for data-driven property functions.) |
There was a problem hiding this comment.
What is a “data-driven property function”? An MGLSourceStyleFunction?
There was a problem hiding this comment.
Hm, yeah good point, I should have been more precise with the language here. I'll ticket this in -gl-js, along with the backtick thing.
There was a problem hiding this comment.
An override in style-spec-overrides-v8.json is probably inevitable, because the style specification doesn’t yet refer to “source functions”: mapbox/mapbox-gl-js#4154.
There was a problem hiding this comment.
Ah, okay. I suppose, in that case, that the least confusion-causing thing to do might be to just drop the parenthetical in the style-spec-overrides-v8.json, since there's no established vocabulary for these function types yet?
@1ec5 what do you think?
There was a problem hiding this comment.
It’s a good point to document. There’s no harm in using one term in the style specification and overriding it here to refer to the specific class (MGLSourceStyleFunction); that’s what style-spec-overrides-v8.json was designed for.
There was a problem hiding this comment.
Ah okay, I misunderstood: there is a publicly documented way to refer to it. It'll need to refer to both MGLSourceStyleFunction and MGLCompositeStyleFunction.
|
We should follow a similar approach for |
7f984e1 to
70c994e
Compare
70c994e to
e1e975d
Compare
|
@boundsj @1ec5 I'm seeing a compiler error in Could you point me in the right direction for the ideal way to resolve this? |
|
@anandthakker these conditionals in MGLStyleLayer.mm.ejs generate an implementation that is compatible with the static type checking by calling either the Following that convention, the existing Note that we don't have this problem with the getter implementation (going from the C++ objects back to Objective-C) since we use the cc @1ec5 @jfirebaugh |
To avoid code duplication, we could split off the MGLCompositeStyleFunction case from |
e1e975d to
b647388
Compare
|
Followup on #7944 (comment): As I started digging into resolving the compilation issues in the MGLCompositeStyleFunction => mbgl::style::CompositeFunction conversion today, it felt like I was solving the same problems that are being solved by I'm now thinking that we should accomplish the MGL => mbgl conversion — at least for property values — by having the darwin platform bindings implement the Value conversions required to leverage the existing @1ec5 notes:
I'll dig into this tomorrow AM -- hopefully the ObjC overloading thing is not a dealbreaker |
b647388 to
53b9147
Compare
Tweak the generated inline docs for text-field -- note that this was done by manually changing modifying an older version of v8.json and running `make darwin-style-code`; this is because the current version of mapbox-gl-js includes changes that enable property functions for symbol properties that are not yet implemented here, so that generating style code from the version of the submodule referenced here will NOT work.
- Do not test ExponentialStops for non-interpolatable types - Remove erroneous assertions for `piecewise-constant` function types
76c3051 to
fe1c70e
Compare
|
Couple pieces of unfinished business addressed since @jfirebaugh 's 🍏 :
@boundsj or @1ec5 could I get 👀 from one of you on these changes? |
|
Can you add tests to exercise enums, colors, and other types, which should’ve failed in #8026? |
|
|
||
| functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeInterval compositeStops:@{@18: constantStyleValue} attributeName:@"" options:nil]; | ||
| XCTAssertThrowsSpecificNamed(layer.fillAntialiased = functionStyleValue, NSException, NSInvalidArgumentException, @"MGLStyleValue should raise an exception if it is applied to a property that cannot support it"); | ||
| functionStyleValue = [MGLStyleValue<NSNumber *> valueWithInterpolationMode:MGLInterpolationModeIdentity sourceStops:nil attributeName:@"" options:nil]; |
| NSObject* toRawStyleSpecValue(NSObject *rawMGLValue, MBGLEnum &mbglValue) { | ||
| if ([rawMGLValue isKindOfClass:[NSValue class]]) { | ||
| const auto rawNSValue = (NSValue *)rawMGLValue; | ||
| if (strcmp([rawNSValue objCType], @encode(CGVector)) == 0) { |
There was a problem hiding this comment.
By the way, I see special handling for CGVector values, but not NSEdgeInsets/UIEdgeInsets values. Do we need it too? Here’s the full correspondence between JSON and Foundation types.
There was a problem hiding this comment.
This is a good catch. I've ticketed it out here as part of the completionist quest to propagate this approach to all of the MGL=>mbgl style property value conversions (or, at least the runtime-styling ones...)
I think what's missing here are the array-based types -- which, you're right, include NSEdgeInset/UIEdgeInsetValues that we still need special-case handling for. Currently, there is no unit test specific to |
|
@mapbox/android after fixing a small typo, the android bitrise build passed, but could I get quick 👀 on this before it goes in? The android-related changes are conveniently in three consecutive files in the diff, starting here: https://github.com/mapbox/mapbox-gl-native/pull/7944/files#diff-ffc041b38fb81bccaa2c261dbc6b938e |
So, I got to what I thought should at least compile here so that I could try it / iterate, but ran into this semi-mysterious compiler error:
Telling that this has something to do with style functions, and the types here are string and
TextTransformType-- precisely the ones I'm expecting to get vialayout.evaluate<TextField>(zoom, *feature)andlayout.evaluate<TextTransform>(zoom, *feature)in symbol_layout. (This seems to work fine forIconOffsetandIconRotate.)I'll keep messing w/ it, just flagging here in case it's something I'm unlikely to find on my own.
cc @jfirebaugh