-
Notifications
You must be signed in to change notification settings - Fork 14.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add line width unit control in deckgl Polygon and Path #24755
feat: Add line width unit control in deckgl Polygon and Path #24755
Conversation
00ea75d
to
a2bb699
Compare
Codecov Report
@@ Coverage Diff @@
## master #24755 +/- ##
==========================================
+ Coverage 67.17% 68.92% +1.74%
==========================================
Files 1902 1902
Lines 73939 73939
Branches 8176 8176
==========================================
+ Hits 49672 50965 +1293
+ Misses 22154 20861 -1293
Partials 2113 2113
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 103 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Slice.viz_type == "deck_polygon", | ||
) | ||
): | ||
params = json.loads(slc.params) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not params.get("line_width_unit"): | ||
params["line_width_unit"] = "meters" | ||
slc.params = json.dumps(params) | ||
session.merge(slc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no need to do a session.merge(...)
here. Typically merge
is used when you may have more than one in-memory objects which map to the same database record with some key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for explanation!
params = json.loads(slc.params) | ||
if not params.get("line_width_unit"): | ||
params["line_width_unit"] = "meters" | ||
slc.params = json.dumps(params) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also per #24737 it's probably best to only update slc.params
if the parameters were updated. There's likely only a handful of charts which need upgrading and thus there's no need to update them all—which adds unnecessary effort on the database.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume that this will impact nearly all charts that are found by the filter clause. But I agree, adding the indentation here is more prudent and will avoid unnecessary db work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that's exactly the case, but you're right - for the sake of code quality I added the indent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One remark to complement John's review comments.
@@ -387,6 +387,7 @@ def load_deck_dash() -> None: # pylint: disable=too-many-statements | |||
"stroked": False, | |||
"extruded": True, | |||
"multiplier": 0.1, | |||
"line_width": 10, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we also add "line_width_unit": "meters"
here, as the default unit is now being changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch!
params = json.loads(slc.params) | ||
if not params.get("line_width_unit"): | ||
params["line_width_unit"] = "meters" | ||
slc.params = json.dumps(params) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume that this will impact nearly all charts that are found by the filter clause. But I agree, adding the indentation here is more prudent and will avoid unnecessary db work.
2c59e03
to
f517ac6
Compare
[extruded, multiplier], | ||
[lineWidth, null], | ||
[extruded], | ||
[multiplier], | ||
[lineWidth], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally these are split onto their own rows 👏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to do the same in the rest of deckgl plugins in upcoming PRs, no more controls squished in 1 row 😄
SUMMARY
Currently the default unit of line width in deckgl Path and Polygon charts is meter. That leads to some confusion, especially in large scale maps, because users might think that the line is not drawn at all - while in reality it's simply too thin to be visible. This PR addresses that problem by changing the default unit from meters to pixels.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Screen.Recording.2023-07-20.at.15.23.21.mov
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION
Current: 0.12 s
10+: 0.12 s
100+: 0.21 s
1000+: 0.13 s