Skip to content
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

Line-dasharray Impl. #39

Conversation

Lukas-Heiligenbrunner
Copy link
Contributor

Hey David,

I tried to implement a missing paint property: line-dasharray which is heavily used within country boarderlines. I'm still quite unfamiliar with your project structure but I tried my best to integrate this.

I've parsed the dasharray with jsonLayer['paint']['line-dasharray'] and didn't use your expressionparser system. Should I've used that?
The flutter inbuilt painter doesn't support line-dashing so I split the paths into subpaths with correct sizing.
I didn't really know where to place this function in your proj. structure. Do you have any suggestions?

Here you can see a before and after comparison:
image
image

I am open to criticism and hope you can find some time to review my code.
Hopefully this PR kind of leads into the right direction and helps :)

Kind regards
Lukas

@Lukas-Heiligenbrunner Lukas-Heiligenbrunner changed the title Line dasharray Line-dasharray Impl. Jun 26, 2022
Copy link
Owner

@greensopinion greensopinion left a comment

Choose a reason for hiding this comment

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

This is really cool, thanks for the contribution! I've added a few suggestions inline below.

lib/src/themes/theme_reader.dart Outdated Show resolved Hide resolved
lib/src/themes/theme_reader.dart Outdated Show resolved Hide resolved
lib/src/features/line_renderer.dart Outdated Show resolved Hide resolved
lib/src/features/line_renderer.dart Outdated Show resolved Hide resolved
lib/src/features/line_renderer.dart Outdated Show resolved Hide resolved
lib/src/features/line_renderer.dart Outdated Show resolved Hide resolved
lib/src/features/line_renderer.dart Outdated Show resolved Hide resolved
lib/src/themes/paint_factory.dart Outdated Show resolved Hide resolved
lib/src/model/path_utils.dart Outdated Show resolved Hide resolved
lib/src/features/line_renderer.dart Outdated Show resolved Hide resolved
lib/src/model/path_utils.dart Outdated Show resolved Hide resolved
lib/src/model/tile_model.dart Outdated Show resolved Hide resolved
lib/src/themes/paint_factory.dart Outdated Show resolved Hide resolved
lib/src/features/line_renderer.dart Outdated Show resolved Hide resolved
lib/src/model/tile_model.dart Outdated Show resolved Hide resolved
lib/src/model/tile_model.dart Outdated Show resolved Hide resolved
Copy link
Owner

@greensopinion greensopinion left a comment

Choose a reason for hiding this comment

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

I forgot to mention, you'll want to rebase since one of the files has been renamed.

@Lukas-Heiligenbrunner
Copy link
Contributor Author

Thanks for the fast review! I did just a draft yesterday night and wasn't fully finished, I'll look into it. :)

lib/src/model/path_utils.dart Outdated Show resolved Hide resolved
lib/src/model/path_utils.dart Outdated Show resolved Hide resolved
lib/src/model/tile_model.dart Outdated Show resolved Hide resolved
}

return _paths;
if (dashLengths.length >= 2) {
if (_dashedPaths.containsKey(dashLengths)) {
Copy link
Owner

Choose a reason for hiding this comment

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

Based on our previous discussion, would it make sense to remove _dashedPaths? The lifecycle of a tile could be quite long, and unless I'm mistaken the key (a list of doubles) could vary a lot.

Alternatively, we could limit the size of _dashedPaths (e.g. to some arbitrary size, e.g. 20)
In that case, to avoid looking up the key in the map twice, consider something like this:

var path = _dashedPaths[dashLengths];
if (path == null) {
  path = _paths?.map ...
  _dashedPaths[dashLengths] = path;
}
return path;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey, yes i think it makes sense to delete this completely. I've removed it now.

lib/src/themes/paint_factory.dart Outdated Show resolved Hide resolved
@@ -64,10 +65,16 @@ class TileFeature {
_paths = decodePolygons(geometry).toList(growable: false);
break;
}
_geometry = null;
Copy link
Owner

Choose a reason for hiding this comment

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

Leaving geometry in-place comes with a significant memory penalty. Why do we need to do this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey, wups jep, overlooked it. It makes sense to delete the geometry after decoding.

lib/src/themes/paint_factory.dart Outdated Show resolved Hide resolved
@greensopinion
Copy link
Owner

Lukas, this is looking good, we should get it in. Could you rebase over main and update this pr?

outsource path-dashing into seperate file
move property into PaintFactory
move generation of dashed paths into TileFeatures and prevent recalculations
rename some params
reformat
outsource ringnumberprovider
remove some comments
@Lukas-Heiligenbrunner
Copy link
Contributor Author

Should I squash the commits?
I couldn't manage to merge every commit correctly, the merge conflicts were a pain.
So the history isn't fully correct now...

@greensopinion
Copy link
Owner

greensopinion commented Jul 14, 2022 via email

@greensopinion
Copy link
Owner

squashed, rebased and merged on #47

@greensopinion
Copy link
Owner

Thanks for your contribution Lukas!

@Lukas-Heiligenbrunner
Copy link
Contributor Author

Thanks for your help and patience! :)

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

Successfully merging this pull request may close these issues.

None yet

2 participants