Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Support getLeaves and other new clustering methods in the iOS SDK #12442

Closed
lilykaiser opened this issue Jul 19, 2018 · 4 comments
Closed

Support getLeaves and other new clustering methods in the iOS SDK #12442

lilykaiser opened this issue Jul 19, 2018 · 4 comments
Assignees
Labels
GL JS parity For feature parity with Mapbox GL JS iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS medium priority

Comments

@lilykaiser
Copy link

lilykaiser commented Jul 19, 2018

We need an iOS equivalent of mapbox/mapbox-gl-js#6829 to support features created in the most recent release of supercluster.hpp including getChildren, getLeaves, and getClusterExpansionZoom.

@lilykaiser lilykaiser added the iOS Mapbox Maps SDK for iOS label Jul 19, 2018
@1ec5 1ec5 added GL JS parity For feature parity with Mapbox GL JS macOS Mapbox Maps SDK for macOS labels Jul 19, 2018
@1ec5
Copy link
Contributor

1ec5 commented Jul 19, 2018

The Android equivalent to this issue is #12441.

The platform-specific SDK code doesn’t have direct access to Supercluster; changes will need to be made to mbgl::style::GeoJSONSource, and mbgl’s dependency on Supercluster will need to be upgraded to v0.3.0.

mason_use(supercluster VERSION 0.2.2 HEADER_ONLY)

The most literal port would add three new methods to MGLShapeSource. The method signatures that mapbox/mapbox-gl-js#6829 exposes seem somewhat ill-suited for the iOS/macOS map SDK’s public API. Normally things like this are synchronous in iOS/macOS frameworks; is there an overriding reason why it would have to be asynchronous?

Instead of separate methods on MGLShapeSource, would it be possible to automatically add this information to any feature querying result that happens to be a cluster? It seems like the developer would have to use feature querying before these methods anyways, because there’s no other way to obtain the cluster identifier. If we do add this information to feature querying results, one source of awkwardness is that the result type is an MGLFeature-conforming class. To avoid polluting the namespace for features obtained by other means, it might be necessary to further subclass each of the MGLFeature classes (which would be an argument in favor of eventually implementing #7454).

/cc @mourner

@mourner
Copy link
Member

mourner commented Jul 19, 2018

is there an overriding reason why it would have to be asynchronous?

In GL JS, it's asynchronous because the Supercluster index lives on the worker thread, and when we query the clusters from from the thread, there's no way to communicate between threads synchronously. I'm not sure what's the current threading setup in native with regards to Supercluster/GeoJSON-VT indices.

Instead of separate methods on MGLShapeSource, would it be possible to automatically add this information to any feature querying result that happens to be a cluster? It seems like the developer would have to use feature querying before these methods anyways, because there’s no other way to obtain the cluster identifier.

We can't combine queryRenderedFeatures and any cluster APIs in GL JS because the former is synchronous with render index living on the main thread, and the latter is async.

The getLeaves API also has certain arguments (e.g. for pagination — how many items to skip, and how many to return), and it would be awkward to require those without a person having an explicit intent to query leaves of a cluster.

@julianrex
Copy link
Contributor

@lilykaiser As I understand it, this requires a change on the core side.

/cc @kkaefer

@lilykaiser
Copy link
Author

The change on the core side should be in progress / done soon according to @tobrun

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
GL JS parity For feature parity with Mapbox GL JS iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS medium priority
Projects
None yet
Development

No branches or pull requests

4 participants