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

add lowerPercentile & upperPercentile back to hexagonLayer #470

Merged
merged 3 commits into from
Mar 27, 2017

Conversation

heshan0131
Copy link
Collaborator

No description provided.

Copy link

@howtimeflies0 howtimeflies0 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@ibgreen ibgreen left a comment

Choose a reason for hiding this comment

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

Need a CHANGELOG entry - if so feel free to remove the deprecation warnings (see comments).

Q: Does quantizeScale depend on an additional d3-module being imported by deck.gl? This could be the reason this was pushed out previously? I don't see a package.json change but wonder if one is required.

@@ -70,13 +70,13 @@ export default class HexagonCellLayer extends Layer {
constructor(props) {
let missingProps = false;
if (!props.hexagonVertices && (!props.radius || !Number.isFinite(props.angle))) {
log.once(0, 'HexagonLayer: Either hexagonVertices or radius and angel are ' +
log.once(0, 'HexagonCellLayer: Either hexagonVertices or radius and angel are ' +
Copy link
Collaborator

Choose a reason for hiding this comment

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

angle not angel

'needed to calculate primitive hexagon.');
missingProps = true;

} else if (props.hexagonVertices && (!Array.isArray(props.hexagonVertices) ||
props.hexagonVertices.length < 6)) {
log.once(0, 'HexagonLayer: HexagonVertices needs to be an array of 6 points');
log.once(0, 'HexagonCellLayer: HexagonVertices needs to be an array of 6 points');
Copy link
Collaborator

Choose a reason for hiding this comment

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

camelCase? hexagonVertices

Math.max.apply(null, hexagons.map(bin => bin.points.length))
];
function _percentileChanged(oldProps, props) {
return oldProps.lowerPercentile !== props.lowerPercentile ||
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a total nit, feel free to ignore: Is it just me that thinks the order of comparison reads better as props vs oldProps rather than the reverse? i.e. if (props.XYZ !== oldProps.XYZ)

}

export default class HexagonLayer extends Layer {
constructor(props) {
if (!props.radius) {
log.once(0, 'PointDensityHexagonLayer: radius in meter is needed to aggregate points into ' +
log.once(0, 'HexagonLayer: radius in meter is needed to aggregate points into ' +
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think a deprecation warning is only needed if this layer was officially supported in another release, and this is a new layer.

People using RC will have to read the release notes - which seem to be missing here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is not a deprecation warning. I simply changed the name of the layer after we changed PointDensityHexagonLayer -> HexagonLayer

'hexagonal bins, Now using 1000 meter as default');

props.radius = defaultProps.radius;
}

if (Number.isFinite(props.upperPercentile) &&
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just a thought: These checks adds a lot lines of code to the layer. Wonder if we should add and use some basic layer prop handlers like
https://github.com/uber/deck.gl/blob/master/src/lib/layer.js#L540

Also we sometimes throw errors and sometimes warn and set defaults - not sure if this is worthy of a paragraph in our API design recommendations doc?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree we should have a more formal way of checking props. At the moment, this can't be called by checkRequiredProps. because they are not required props. I only check if those props are valid when user provide them.

Maybe we should create a ticket for better prop checking?


const colorDomain = this.props.colorDomain || valueDomain;
const count = cell.points.length;
const color = quantizeScale(colorDomain, colorRange, count);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does quantizeScale depend on an additional d3-module being imported by deck.gl? This could be the reason this was pushed out previously?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

quantizeScale is implemented from scratch in utils/scale-util. We are not depend on d3 for this

@@ -77,9 +103,16 @@ export default class HexagonLayer extends Layer {
const {viewport} = this.context;

const hexagons = hexagonAggregator(this.props, viewport);
const countRange = _getCountRange(hexagons);
const sortedCounts = new SortedBins(hexagons);
Copy link
Collaborator

Choose a reason for hiding this comment

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

The name of this class doesn't feel quite right, but not sure I can't come up with anything better. BinSorter?

@@ -18,6 +18,7 @@ export default class SortedBins {
/**
* Get an array of object with sorted count and index of bins
* @param {Number} lower
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: This doesn't correctly document the params (looks like f(lower, upper)) . But probably no need to change this now. We'll probably move to something like flow type annotation comments in the future. A more correct version of JSDoc would probably look like:

@param {Number[]} range
@param {Number} range[0] - lower bound
...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm no quitter

@heshan0131 heshan0131 force-pushed the hexagon-grid-percentile branch from b84c7fe to 1baedb4 Compare March 27, 2017 22:33
@heshan0131 heshan0131 merged commit bd77f7b into master Mar 27, 2017
howtimeflies0 pushed a commit that referenced this pull request Mar 28, 2017
* add lowerPercentile & upperPercentile back to hexagonLayer

* update based on comments

* add to CHANGELOG
@ibgreen ibgreen deleted the hexagon-grid-percentile branch March 28, 2017 23:42
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