Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

[core] Variable label placement - #14184

Merged
pozdnyakov merged 12 commits into
masterfrom
variable_label_placement
Mar 29, 2019
Merged

pozdnyakov merged 12 commits into
masterfrom
variable_label_placement

Conversation

@pozdnyakov

Copy link
Copy Markdown
Contributor

Comment thread platform/node/test/ignores.json Resolved
Comment thread src/mbgl/layout/symbol_layout.cpp Resolved
Comment thread src/mbgl/text/placement.cpp Resolved
Comment thread src/mbgl/text/placement.cpp Resolved
Comment thread src/mbgl/text/placement.cpp Resolved
Comment thread src/mbgl/layout/symbol_layout.cpp Resolved
Comment thread src/mbgl/layout/symbol_layout.cpp Resolved
@pozdnyakov pozdnyakov added the ⚠️ DO NOT MERGE Work in progress, proof of concept, or on hold label Mar 21, 2019
@pozdnyakov
pozdnyakov force-pushed the variable_label_placement branch from 19df93a to c6f2cc7 Compare March 21, 2019 13:48
@pozdnyakov pozdnyakov removed the ⚠️ DO NOT MERGE Work in progress, proof of concept, or on hold label Mar 21, 2019
@pozdnyakov
pozdnyakov force-pushed the variable_label_placement branch from c6f2cc7 to ef803e1 Compare March 21, 2019 14:27
@pozdnyakov
pozdnyakov requested a review from kkaefer March 21, 2019 14:28
@pozdnyakov
pozdnyakov force-pushed the variable_label_placement branch from ef803e1 to 9b1def0 Compare March 21, 2019 14:43
Comment thread src/mbgl/style/conversion/constant.cpp Outdated
namespace {

} // namespace

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove unused?

Comment thread src/mbgl/text/shaping.cpp Outdated
const float spacing,
const Point<float>& translate,
const float verticalHeight,
//const float verticalHeight,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

@julianrex

Copy link
Copy Markdown
Contributor

/cc @fabian-guerra for related platform/darwin/scripts/generate-style-code.js changes.

Comment thread src/mbgl/layout/symbol_layout.cpp Resolved
Comment thread src/mbgl/layout/symbol_layout.cpp Resolved
@pozdnyakov

Copy link
Copy Markdown
Contributor Author

@alexshalamov @kkaefer Thanks for your comments! Fixed now in the latest patch set. Also, an optimization for single-line labels is added.

@chloekraw

Copy link
Copy Markdown
Contributor

@pozdnyakov - does the implementation in this PR still leave out runtime styling support?

@pozdnyakov

Copy link
Copy Markdown
Contributor Author

@pozdnyakov - does the implementation in this PR still leave out runtime styling support?

This patch contains auto-generated runtime API & tests for Android.

// but doesn't actually specify what happens if you use both. We go with the radial offset.
textOffset = evaluateRadialOffset(textAnchor, radialOffset * util::ONE_EM);
} else {
textOffset = { layout.evaluate<TextOffset>(zoom, feature)[0] * util::ONE_EM,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const auto evaluatedOffset = layout.evaluate<TextOffset>(zoom, feature);
textOffset = { evaluatedOffset[0] * util::ONE_EM, evaluatedOffset[1] * util::ONE_EM };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pozdnyakov wdyt? simple fix, avoids extra evaluation of text offset.

case 'string':
return '[' + property['default'] + "]";
case 'enum':
if (property['default'] !== undefined) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change has to be applied to darwin/scripts/generate-style-code.js and please run make darwin-style-code after. That's why the iOS and macOS tests fail in this branch.

Let me know if you have any questions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit more than this, pls see 9bc4994

@pozdnyakov
pozdnyakov requested a review from 1ec5 as a code owner March 27, 2019 12:24
@pozdnyakov
pozdnyakov requested review from a team and fabian-guerra March 27, 2019 12:24
auto str = mbgl::Enum<MBGLEnum>::toString(value);
MGLEnum mglType = *mbgl::Enum<MGLEnum>::toEnum(str);
return [NSValue value:&mglType withObjCType:@encode(MGLEnum)];
static NSString *toMGLRawStyleValue(const MBGLEnum &value) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we changing NSValue to an NSString? Is there any MGLTextAnchor conversion error?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previously existing method was never invoked - the currently removed

        template <typename MBGLEnum = MBGLType,
            class = typename std::enable_if<std::is_enum<MBGLEnum>::value>::type,
        typename MGLEnum = ObjCEnum,
            class = typename std::enable_if<std::is_enum<MGLEnum>::value>::type>
        NSExpression *operator()(const MBGLEnum &value) const {...}

was used instead. It worked fine for a single MGLTextAnchor instance, however std::vector< MGLTextAnchor> could not be handled.


You can set this property to an expression containing any of the following:

* Constant array values

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is accepts MGLTextAnchor values, the documentation should be similar to:

* Constant `MGLTextAnchor` values
* Any of the following constant string values:
* `center`: The center of the text is placed closest to the anchor.
* `left`: The left side of the text is placed closest to the anchor.
* `right`: The right side of the text is placed closest to the anchor.
* `top`: The top of the text is placed closest to the anchor.
* `bottom`: The bottom of the text is placed closest to the anchor.
* `top-left`: The top left corner of the text is placed closest to the
anchor.
* `top-right`: The top right corner of the text is placed closest to the
anchor.
* `bottom-left`: The bottom left corner of the text is placed closest to the
anchor.
* `bottom-right`: The bottom right corner of the text is placed closest to
the anchor.

@tobrun tobrun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Core The cross-platform C++ core, aka mbgl feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants