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

Update styles from arrays. #687

Merged
merged 5 commits into from
May 4, 2017
Merged

Update styles from arrays. #687

merged 5 commits into from
May 4, 2017

Conversation

manthey
Copy link
Contributor

@manthey manthey commented Apr 5, 2017

This allows a convenient way to animate across styles, and also provides a way where, if appropriate, rerendering can be optimized based on just what has changed.

Per-vertex styles can be set on lines and polygons by passing an array of arrays.

Some styles on points and contours were being queried via functions of the form styleFunc(data) where they should have been queried as styleFunc(data, index). These have been changed.

Speed up paths for other features will be added later.

This allows a convenient way to animate across styles, and also provides a way where, if appropriate, rerendering can be optimized based on just what has changed.

Per-vertex styles can be set on lines and polygons by passing an array of arrays.

Some styles on points and contours were being queried via functions of the form styleFunc(data) where they should have been queried as styleFunc(data, index).  These have been changed.

Speed up paths for other features will be added later.
@manthey manthey force-pushed the style-from-array branch from 117d08f to 0530e36 Compare April 5, 2017 17:19
@manthey
Copy link
Contributor Author

manthey commented Apr 5, 2017

This resolves issue #683.

Optimizations for lines and polygons can be done later. Optimizations for positions will take more work.

@codecov-io
Copy link

codecov-io commented Apr 5, 2017

Codecov Report

Merging #687 into master will increase coverage by 0.05%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #687      +/-   ##
==========================================
+ Coverage   95.22%   95.28%   +0.05%     
==========================================
  Files          84       84              
  Lines        8920     8990      +70     
==========================================
+ Hits         8494     8566      +72     
+ Misses        426      424       -2
Impacted Files Coverage Δ
src/gl/pointFeature.js 100% <100%> (ø) ⬆️
src/polygonFeature.js 99.31% <100%> (ø) ⬆️
src/feature.js 100% <100%> (ø) ⬆️
src/contourFeature.js 83.62% <100%> (ø) ⬆️
src/lineFeature.js 100% <100%> (ø) ⬆️
src/mapInteractor.js 96.11% <0%> (+0.28%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0d5d2f2...34836cf. Read the comment docs.

src/feature.js Outdated
* value per data item. The values are not converted or validated. Color
* values should be objects with r, g, b values on a scale of [0, 1]. If
* invalidate values are given the behavior is undefined.
* For features where this._subcomponentStyles is an object and a style
Copy link
Member

Choose a reason for hiding this comment

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

Since this is a public API, listing private API (from documentation point of view) could be confusing to the user.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll improve the comment.

src/feature.js Outdated
} else {
var fallback;
if (keyOrObject.toLowerCase().match(/color$/)) {
fallback = {r: 0, g: 0, b: 0};
Copy link
Member

Choose a reason for hiding this comment

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

Should be define these defaults as someplace else where it is more visible?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the only one, because colors are always coerced into the rgb object and other functions except them not to have undefined values. Moving it elsewhere will just obscure what happens, I think.

Copy link
Member

Choose a reason for hiding this comment

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

Sure I am fine with being here for now and we can revisit if needed to be in the future.

@@ -60,7 +62,7 @@ var gl_pointFeature = function (arg) {
' precision highp float;',
'#endif',
'attribute vec3 pos;',
'attribute float rad;',
'attribute float radius;',
Copy link
Member

Choose a reason for hiding this comment

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

+1

src/feature.js Outdated
@@ -44,6 +44,10 @@ var feature = function (arg) {
m_dependentFeatures = [],
m_selectedFeatures = [];

// subclasses can add keys to this for styles that apply to subcomponents of
// data items, such as individual vertices on lines or polygons.
this._subcomponentStyles = {};
Copy link
Member

Choose a reason for hiding this comment

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

should we just call it componentStyles? or perFeatureStyle? sub and component in my understanding convey very similar message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It really is intended to be part of the private API, so it should only matter to developers. This is the list of styles that are per-vertex rather than per-feature when there is a distinction between vertices and features (i.e., not on point features). There could be a feature where the sub-feature is not a vertex but something else, so this isn't strictly a list of vertex styles. I don't know what a better name would be. perFeatureStyle is definitely wrong, as these apply at a finer granularity than features. _subfeatureStyles might be better. _stylesAtFinerGranularityThanPerFeature is too long.

Copy link
Member

Choose a reason for hiding this comment

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

I like _subfeatureStyles 👍

Copy link
Member

@aashish24 aashish24 left a comment

Choose a reason for hiding this comment

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

other than the suggested name change from @manthey, it LRTM

Copy link
Member

@aashish24 aashish24 left a comment

Choose a reason for hiding this comment

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

thanks @manthey 👍

@manthey manthey merged commit aff21e4 into master May 4, 2017
@manthey manthey deleted the style-from-array branch May 4, 2017 16:16
@manthey manthey mentioned this pull request Jun 1, 2017
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.

3 participants