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

Locator Overlays aka 'Heatmaps'. #1437

Merged
merged 10 commits into from
Jul 30, 2024
Merged

Locator Overlays aka 'Heatmaps'. #1437

merged 10 commits into from
Jul 30, 2024

Conversation

Bonkles
Copy link
Contributor

@Bonkles Bonkles commented May 16, 2024

Locator overlays for Rapid Datasets are now a thing!

The procedure is as follows:

  1. Create a public vector data endpoint for the heatmap (an internal Meta process that I won't go into here).
  2. Hook our Rapid System code to the overlay using the code in this PR.
  3. Fire a new bit of pixi rendering code to draw very simple, highly transparent circle shapes for each point we get back from the vector heatmap endpoint.

This POC shows the resultant experience of zooming in at very high zooms over the continental US.

To test, enter poweruser mode and enable the 'meta Footways' dataset. You should then see the heatmap appear over the map if you're at low zooms (0-15). The color/checkbox for the dataset also propagates to the heatmap, so you get something like this:

overlays_color_switching_toggling.mov

The code creates a new layer above the map that styles any vector data points it gets from the heatmap endpoint. Right now, we don't do anything fancy- just draw a circle at 5% opacity at every point and make it large enough to overlap with its neighbors and the transparency stacking does a pretty good job.

@bhousel
Copy link
Contributor

bhousel commented May 16, 2024

This is going to be awesome! I can imagine this being useful for any of the data layers to be able to show users at low zoom where the data exists.

modules/core/RapidSystem.js Outdated Show resolved Hide resolved
modules/pixi/PixiFeaturePoint.js Outdated Show resolved Hide resolved
modules/pixi/PixiLayerRapidOverlay.js Outdated Show resolved Hide resolved
const vtService = this.context.services.vectortile;
const datasets = this.context.systems.rapid.datasets;

// for (const [key, dataset] in datasets) {
Copy link
Contributor Author

@Bonkles Bonkles May 16, 2024

Choose a reason for hiding this comment

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

Eventually this code should go through all the Rapid datasets and look for any overlays. For now it's hard-wired to just go looking for fbRoads.

To keep the PR minimal, I am demonstrating footways overlays wired up to fbRoads, but that's just for demo purposes. Footways impl is in a different branch.

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 have since rewired the PR to look through all the datasets, examine which ones have overlays, and conditionally display those overlays IF the dataset is enabled.

modules/pixi/PixiLayerRapidOverlay.js Outdated Show resolved Hide resolved
overlayData = vtService.getData(overlay.url).map(d => d.geojson);
}

// const polygons = overlayData.filter(d => d.geometry.type === 'Polygon' || d.geometry.type === 'MultiPolygon');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The vector data we get back seems to consist of two bits of data:

Polygon borders for awater layer (which we can safely discard)
and Points that have a single property: weight. Presumably the weight is to control how bright/vivid the heatmap should be, but in empirical testing I saw values from 100 to 300,000.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After showing this to Jonah and a few other folks, the existing implementation was fuzzy/blobby enough that they were convinced it was a raster map. I think the existing implementation is more than good enough without needing to resort to darkening/lightening the alpha with a weight value interpolation. We can revisit in the future.

modules/pixi/PixiLayerRapidOverlay.js Show resolved Hide resolved
modules/pixi/PixiLayerRapidOverlay.js Outdated Show resolved Hide resolved
…akes showing/hiding the overlays work as the checkbox is toggled.
modules/core/RapidSystem.js Show resolved Hide resolved
modules/pixi/PixiLayerRapidOverlay.js Show resolved Hide resolved
modules/pixi/PixiLayerRapidOverlay.js Show resolved Hide resolved
modules/pixi/PixiLayerRapidOverlay.js Outdated Show resolved Hide resolved
modules/pixi/PixiLayerRapidOverlay.js Show resolved Hide resolved
@Bonkles Bonkles marked this pull request as ready for review June 26, 2024 20:26
@Bonkles Bonkles changed the title [Draft] Locator Overlays aka 'Heatmaps'. Locator Overlays aka 'Heatmaps'. Jul 25, 2024
Copy link
Contributor

@bhousel bhousel left a comment

Choose a reason for hiding this comment

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

Cool! You already pointed out some ways we can optimize it later, but it looks good to me 👍 Will be great to see heatmaps of footway data at lower zooms...

@bhousel bhousel merged commit 5494666 into main Jul 30, 2024
4 checks passed
@bhousel bhousel deleted the overlays branch July 30, 2024 14:48
bhousel added a commit that referenced this pull request Aug 1, 2024
@bhousel bhousel added this to the v2.4 milestone Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: show heatmap of buildings or other layers at zoom 10-13
3 participants