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

Port line-sort-key and fill-sort-key #15839

Merged
merged 4 commits into from
Dec 17, 2019
Merged

Conversation

ahk
Copy link
Contributor

@ahk ahk commented Oct 21, 2019

Adds support for line-sort-key and fill-sort-key properties, consistent with symbol-sort-key.

It took me quite a while to gain proficiency with the C++ usage in the project (I was rustier than I thought). Consider this a draft, and I would love to hear your comments and suggestions. I'm sure I may have style or design issues with my approach. For quite a while I pursued a design that modified the PatternLayout contructor only (rather than introducing my new function maybeApplySortKey). This was difficult for me to figure out because fill extrusion layer type does not support *-sort-key but there is a decent chunk of shared code among fill, line, and fill extrusion layers around Layout creation (which is most of what PatternLayout class is). Hopefully someone can point me to a better design.

I attempted to be consistent with the original PR for symbol-sort-key as much as possible.

@asheemmamoowala
Copy link
Contributor

I haven't tried to rebase this, it's obviously out of date. Is it preferred to rebase this against master or to merge master?

Rebasing is preferable. I prefer rebasing regularly so as not to fall behind too much.

@ahk
Copy link
Contributor Author

ahk commented Oct 22, 2019

I haven't tried to rebase this, it's obviously out of date. Is it preferred to rebase this against master or to merge master?

Rebasing is preferable. I prefer rebasing regularly so as not to fall behind too much.

Rebased against master now, apparently that made the darwin platform code generation a noop.

@ahk ahk requested a review from pozdnyakov October 23, 2019 20:16
src/mbgl/layermanager/fill_layer_factory.cpp Outdated Show resolved Hide resolved
src/mbgl/layout/pattern_layout.hpp Outdated Show resolved Hide resolved
src/mbgl/layout/pattern_layout.hpp Outdated Show resolved Hide resolved
@pozdnyakov
Copy link
Contributor

The new approach looks great! @ahk what is the status of this pr? is it ready for review & merge (I see it is still a draft)?

@ahk
Copy link
Contributor Author

ahk commented Nov 14, 2019

is it ready for review & merge (I see it is still a draft)?

I still need to update the sorting logic to incrementally maintain the sort in the destination as you requested earlier. I'll clean that up and move it out of draft. It looks like it I'm failing more of the circleci ARM and Linux builds than I was before ... I might need some help figuring that out.

@chloekraw chloekraw added the needs changelog Indicates PR needs a changelog entry prior to merging. label Nov 21, 2019
@ahk ahk marked this pull request as ready for review December 5, 2019 00:15
@ahk
Copy link
Contributor Author

ahk commented Dec 5, 2019

Hi @pozdnyakov I've updated this branch to maintain the sort of features during layout step and use a std::list over a std::vector. I also found an indexing numeric limits bug.

I still can't figure out how to make the sanity-check format step happy. When I apply the patch it suggests and it reruns it shows me a new patch that undoes the previous patch, can't explain that one.

Also apparently some of our linux targets use a compiler that doesn't allow fully specializing a template function in a class template. I know partial specialization isn't allowed but if you have any tips on how to resolve that I would appreciate it. Is this a funny parsing quirk I'm not familiar with?

Moved this to review because I think it does everything it's supposed to and I resolved all the comments as requested.

@ahk ahk force-pushed the port-fill-line-sort-key branch 2 times, most recently from 01e7367 to 190dafc Compare December 5, 2019 06:03
Copy link
Contributor

@pozdnyakov pozdnyakov left a comment

Choose a reason for hiding this comment

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

Looks great overall! just few nits

src/mbgl/layout/pattern_layout.hpp Outdated Show resolved Hide resolved
src/mbgl/layout/pattern_layout.hpp Outdated Show resolved Hide resolved
@alexshalamov alexshalamov force-pushed the port-fill-line-sort-key branch 2 times, most recently from c640bab to 9cf1846 Compare December 10, 2019 16:39
src/mbgl/layout/pattern_layout.hpp Outdated Show resolved Hide resolved
src/mbgl/layout/pattern_layout.hpp Outdated Show resolved Hide resolved
src/mbgl/layout/pattern_layout.hpp Outdated Show resolved Hide resolved
@alexshalamov alexshalamov force-pushed the port-fill-line-sort-key branch 2 times, most recently from d1f318a to 94730f9 Compare December 17, 2019 09:45
@alexshalamov alexshalamov removed the needs changelog Indicates PR needs a changelog entry prior to merging. label Dec 17, 2019
@alexshalamov alexshalamov force-pushed the port-fill-line-sort-key branch 2 times, most recently from 22c6fe7 to 9432744 Compare December 17, 2019 10:41
ahk and others added 3 commits December 17, 2019 13:37
…15839)

- Generate style code for 'line-sort-key' and 'symbol-sort-key'

- Add new layout properties to FillLayer::Impl, FillBucket, and FillLayerFactory

- Fix consistency of paint and layout properties type alias usage in FillBucket, LineBucket

- Add optional feature sorting to fill and line Layout creation

- Enable node render tests for fill-sort-key and line-sort-key

- Fix FillBucket test construction

- Prefer emplace_back to push_back for PatternFeature container

- Fix buggy static_cast for PatternFeature indices

- Maintain sort of features as they are created

- Switch pattern layout features container to list from vector for better insert performance

- Fix formatting expected by sanity check

- Use subclass PatternLayoutSorted to work around lack of template functions

- Fix to retain source order for features with equivalent sort keys during sorting

- [core] Fix clang-format

- [core] Address review comments

- [core] Pass inserting strategy class at compile time

- [core] Use sorted strategy only if sort key is defined in layout

- [core] Update style generator

- [core] Merge PatternLayout and PatternLayoutSorted classes

  - Use static methods for inserter strategies
  - Merge PatternLayout and PatternLayoutSorted classes
@alexshalamov alexshalamov merged commit 493d2ca into master Dec 17, 2019
alexshalamov pushed a commit that referenced this pull request Dec 17, 2019
…15839)

- Generate style code for 'line-sort-key' and 'symbol-sort-key'

- Add new layout properties to FillLayer::Impl, FillBucket, and FillLayerFactory

- Fix consistency of paint and layout properties type alias usage in FillBucket, LineBucket

- Add optional feature sorting to fill and line Layout creation

- Enable node render tests for fill-sort-key and line-sort-key

- Fix FillBucket test construction

- Prefer emplace_back to push_back for PatternFeature container

- Fix buggy static_cast for PatternFeature indices

- Maintain sort of features as they are created

- Switch pattern layout features container to list from vector for better insert performance

- Fix formatting expected by sanity check

- Use subclass PatternLayoutSorted to work around lack of template functions

- Fix to retain source order for features with equivalent sort keys during sorting

- [core] Fix clang-format

- [core] Address review comments

- [core] Pass inserting strategy class at compile time

- [core] Use sorted strategy only if sort key is defined in layout

- [core] Update style generator

- [core] Merge PatternLayout and PatternLayoutSorted classes

  - Use static methods for inserter strategies
  - Merge PatternLayout and PatternLayoutSorted classes
@chloekraw chloekraw added this to the release-unicorn milestone Dec 18, 2019
@chloekraw
Copy link
Contributor

@alexshalamov thanks for taking this over the finish line!

@@ -8,8 +8,6 @@ const colorParser = require('csscolorparser');

// FIXME: https://github.com/mapbox/mapbox-gl-native/issues/15008
delete spec.layout_circle["circle-sort-key"]
delete spec.layout_line["line-sort-key"]
delete spec.layout_fill["fill-sort-key"]
Copy link
Contributor

Choose a reason for hiding this comment

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

These lines are duplicated in the Darwin version of this script:

delete spec.layout_line["line-sort-key"]
delete spec.layout_fill["fill-sort-key"]

Copy link
Contributor

@1ec5 1ec5 Feb 25, 2020

Choose a reason for hiding this comment

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

mapbox/mapbox-gl-native-ios#179 updates the gl-native-ios repository to reflect this change. @tobrun, heads-up that the Android map SDK is missing runtime styling methods due to similar delete statements in platform/android/scripts/generate-style-code.js.

/ref #15875 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

@Chaoba could you follow up on above?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants