supercluster icon indicating copy to clipboard operation
supercluster copied to clipboard

Add an option for using Image Coordinates x/y

Open ryanhausen opened this issue 4 years ago • 0 comments

Howdy,

I am interested in using supercluster in a project that uses x/y coordinates instead of lat/lng. I looked through the code and got it working by changing the code responsible for converting lat/lng to the [0,1] range. Specifically, the functions i had to edit were

https://github.com/mapbox/supercluster/blob/60d13df9c7d96e9ad16b43c8aca897b5aea38ac9/index.js#L69-L81 https://github.com/mapbox/supercluster/blob/60d13df9c7d96e9ad16b43c8aca897b5aea38ac9/index.js#L388-L390 https://github.com/mapbox/supercluster/blob/60d13df9c7d96e9ad16b43c8aca897b5aea38ac9/index.js#L391-L395 https://github.com/mapbox/supercluster/blob/60d13df9c7d96e9ad16b43c8aca897b5aea38ac9/index.js#L398-L400 https://github.com/mapbox/supercluster/blob/60d13df9c7d96e9ad16b43c8aca897b5aea38ac9/index.js#L401-L404

Would you be interested in incorporating this kind of functionality if I submit a PR?

My initial thoughts would be to move the [lat,lng][x,y] functions into the class so they can be overridden by the user, but the first code snippet would likely be more complex and take a flag passed to the constructor or the function call.

I don't do a lot of programming in javascript so I am not sure if any of this would be an anti pattern of some sort.

Thanks for making this!

ryanhausen avatar Aug 31 '21 16:08 ryanhausen