-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[Bug] Fix hexagon layer projection #4173
Conversation
[Infinity, -Infinity] // pt[1] | ||
]; | ||
|
||
for (let i = 0; i < size * data.length; i += size) { |
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.
This will recalculate every iteration. Assign to a variable.
]; | ||
|
||
for (let i = 0; i < size * data.length; i += size) { | ||
const arrayIsFinite = Number.isFinite(positions[i]) && Number.isFinite(positions[i + 1]); |
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.
Create variables x & y
const positions = attributes.positions.value; | ||
const {size} = attributes.positions.getAccessor(); | ||
|
||
const bounds = [ |
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.
Perf: I’d just use four variables minX, minY, etc.
let angle = 90; | ||
let radius; | ||
const {viewport} = this.context; | ||
const {unitsPerMeter} = viewport.getDistanceScales(); | ||
|
||
if (Array.isArray(vertices)) { |
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.
What is the branch used for? Kepler’s h3 aggregation?
You shouldn’t have to reproject the vertices every time the viewport changes. Radius in common units is a constant.
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.
it WAS used when kepler.gl has its own aggregator and aggregate points to h3 hexagons. However, we don't need to use this anymore, since we are not aggregate points into h3. For future development, when we want to create a h3 aggregation layer, we can revisit this
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.
A H3 aggregation layer should use the H3HexagonLayer. If this is no longer used by kepler we should mark it as deprecated.
You need to rebase master and update the render test golden images. |
3666fe6
to
4a15726
Compare
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.
Why would the colors change in the golden images? I don't think color values are affected by this change.
Projection shifted, changed number of points in bin, which changes color scale |
const radius = dxy / 2 / unitsPerMeter[0]; | ||
// offset all points by centroid to meter offset | ||
const vertices = hexagonVertices.map(vt => [ | ||
(vt[0] - centroid[0]) * unitsPerMeter, |
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.
unitsPerMeter is an array
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.
LngLat coordinates must first be projected to the common space.
this.updateRadiusAngle(hexagonVertices); | ||
// if user provided custom aggregator and returns hexagonVertices, | ||
// Need to recalculate radius and angle based on vertices | ||
const {hexagonVertices} = cpuAggregator.state.layerData || {}; |
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.
const {hexagonVertices} = cpuAggregator.state.layerData || {}; | |
const {hexagonVertices, radiusCommon} = cpuAggregator.state.layerData || {}; |
} | ||
} else { | ||
// update radius angle by viewport | ||
this.updateRadiusAngle(); |
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.
this.updateRadiusAngle(); | |
this.updateRadiusAngle(radiusCommon); |
} | ||
|
||
updateState(opts) { | ||
super.updateState(opts); | ||
const {cpuAggregator} = this.state; | ||
const oldLayerData = cpuAggregator.state.layerData; | ||
const {cpuAggregator, hexagonVertices: oldVertices} = this.state; | ||
this.setState({ |
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.
Perf:
if (opts.changeFlags.propsOrDataChanged) {
// update aggregation
}
* use center of data to calculate radius in common space. for projection * save radiusCommon in aggregation result * recalculate meter radius based on saved radiusCommon when viewport updated * if hexagonVertices is provided, convert them to meter offset
* master: (82 commits) fix typo in performance.md pydeck: ArcLayer, BitmapLayer, ColumnLayer examples (#4189) [React] fix missing key error (#4193) [Bug] Fix hexagon layer projection (#4173) Remove HtmlWebpackPlugin from examples/playground (#4178) @deck.gl/json: Fix bug dropping props with falsy values (#4185) Fix buffer size check in Attribute.updateBuffer (#4190) Bump luma dependency (#4191) data-filter: support double precision (#4163) Use int type for enum uniforms (#4171) [TileLayer] fix tile indices generation in edge cases (#4170) v8.1.0-alpha.1 Voodoo fix for Mac+NVIDIA bug (#4166) Remove unnecessary code from project glsl (#4162) Fix H3HexagonLayer update when viewport jumps (#4158) Refactor render tests; use stricter pass criteria (#4157) [Extension] Add source_target to brushing mode (#4150) Add offset feature to PathStyleExtension (#4126) Project module: support pre-projected positions (#4140) Repeat maps at low zoom levels (#4105) ...
* use center of data to calculate radius in common space. for projection * save radiusCommon in aggregation result * recalculate meter radius based on saved radiusCommon when viewport updated * if hexagonVertices is provided, convert them to meter offset
#4051