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

Request for Crop Functionality in ol/source/IDW #1092

Open
fabric-io-rodrigues opened this issue Aug 1, 2024 · 3 comments
Open

Request for Crop Functionality in ol/source/IDW #1092

fabric-io-rodrigues opened this issue Aug 1, 2024 · 3 comments

Comments

@fabric-io-rodrigues
Copy link

Hello @Viglino and the ol-ext Team,

First, I want to express my appreciation for the outstanding work you’ve done with the ol-ext library. Your contributions to OpenLayers are invaluable, and the library’s suite of features greatly enhances the capabilities of OpenLayers with thoughtful and well-implemented extensions.

I am currently using the ol/source/IDW functionality in my project and would like to request a new feature: a built-in crop function. At present, the heatmap generated by ol/source/IDW covers the entire map, but my use case requires limiting the heatmap rendering to a specific area.

Requested Feature:

  • Crop/Clip Function: A method to specify a particular area where the heatmap should be rendered, effectively cropping or limiting the heatmap's display area.

Current Workaround:

To achieve similar functionality, I have implemented the following steps:

  1. Create Buffers Around Points: Used Turf.js to generate buffers around the data points.
  2. Union Buffers: Combined these buffers to create a unified polygonal area.
  3. Apply Filter: Applied this polygon as a clipping mask to the heatmap layer using OpenLayers.

Visual Example:

To better illustrate the need for this feature, I have attached an image showing the heatmap with the current cropping method that I implemented. The image demonstrates how the heatmap is confined to a specific area, which is crucial for my project.

image

Adding a native crop functionality to ol/source/IDW would greatly streamline this process and enhance the flexibility of heatmap visualizations. It would be a fantastic addition to an already brilliant set of tools that ol-ext provides.

Thank you for considering this request and for your continued dedication to keeping the ol-ext project active and up-to-date.

Viglino added a commit that referenced this issue Aug 2, 2024
@Viglino
Copy link
Owner

Viglino commented Aug 2, 2024

I've added a new maxD options (in projection unit) to limit the computation at a given distance.
image

@fabric-io-rodrigues
Copy link
Author

Hello @Viglino ,

Thank you very much for the quick response, analysis, and implementation! The new maxD option to limit the computation to a specific distance is working very well.

I took the liberty of creating a setMaxD function to make adjusting the parameter easier, as shown below:

ol.source.IDW.prototype.setMaxD = function(maxD) { 
    this.set("maxD", parseFloat(maxD) || 0); 
    this.changed();
};

ezgif-6-712249bade 1

Thanks again for your dedication. Your work is helping many people!

Viglino added a commit that referenced this issue Aug 5, 2024
@Viglino
Copy link
Owner

Viglino commented Aug 5, 2024

You may also have to change the scale factor to prevent aliasing on the edge (but may lag on large datasets).
Screenity video - Aug 5, 2024

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

No branches or pull requests

2 participants