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

Clarify MGLGeoJSONSource option units #6236

Closed

Description

@boundsj

In #6217 (comment) we discussed some possibilities to make the documentation for VT and cluster options clearer for native mobile developers. This issue is to continue that discussion and implement improved documentation since #6217 itself is functional and has good enough documentation.

cc @1ec5 @mourner @frederoni

Activity

  1. added
    iOS
    on Sep 1, 2016
  2. added this to the ios-v3.4.0 milestone on Sep 1, 2016
  3. boundsj commented on Sep 1, 2016

    @boundsj
    ContributorAuthor
  4. 1ec5 commented on Sep 1, 2016

    @1ec5
    Contributor

    Duplicate of #5960?

  5. boundsj commented on Sep 1, 2016

    @boundsj
    ContributorAuthor

    I'm happy with #5960, just wanted to capture the specifics you brought up about MGLGeoJSONSource and absolve #5962. Closing!

  6. boundsj commented on Sep 2, 2016

    @boundsj
    ContributorAuthor

    Actually going to keep this open and block the beta with it so we can have the discussion about how to make these options mean something.

  7. reopened this on Sep 2, 2016
  8. added
    beta blocker
    on Sep 2, 2016
  9. 1ec5 commented on Sep 2, 2016

    @1ec5
    Contributor

    To recap:

    Thinking ahead to when we document these options: buffer and clusterRadius will unfortunately be difficult APIs for developers to reason about. They’re expressed in units of “⅟₅₁₂ of a tile”, which don’t correspond to any fixed real-world or screen distances, yet we don’t offer any way for the developer to find out the size of the tile at a given zoom level.

    Fortunately, I don’t think this needs to be one of those “guess-and-check” APIs that we try to avoid exposing in the SDK. Rather than the formulation used in the style specification documentation, I think we should talk about the buffer and cluster radius being expressed in screen points (which is true at integral zoom levels), with a caveat that they may be scaled up to 2× between integral zoom levels. (The offset threshold implemented in #1843 is only for raster and video sources, so it won’t affect clustering.)

    @mourner, a couple questions for you:

    1. The style specification talks about “⅟₅₁₂ of a tile” units. I assume that means a tile is 512 of these units tall and 512 of these units wide, not that there are 512 to a tile, correct? If so, that should be an easy documentation fix.
    2. On Retina displays, do these ⅟₅₁₂-of-a-tile units remain ⅟₅₁₂-of-a-tile units, or do they become ⅟₁₀₂₄-of-a-tile units?
    3. The style specification describes tolerance as a “Douglas-Peucker simplification tolerance”, but in this case that means it’s also measured in ⅟₅₁₂-of-a-tile units, right? Most descriptions of the Douglas–Peucker algorithm discuss curve simplification specifically, so it’ll be unclear to the developer how the tolerance relates to clustering. We can probably clarify the documentation a bit by talking about a minimum distance between points.

    We’re tagging this as a beta blocker because the API documentation is potentially misleading until we resolve these three issues.

  10. changed the title [-]Add better documentation for MGLGeoJSONSource options[/-] [+]Clarify MGLGeoJSONSource option units[/+] on Sep 2, 2016
  11. mourner commented on Sep 13, 2016

    @mourner
    Member

    The style specification talks about “⅟₅₁₂ of a tile” units. I assume that means a tile is 512 of these units tall and 512 of these units wide, not that there are 512 to a tile, correct? If so, that should be an easy documentation fix.

    Initially I described the units as "relative to a 512px tile", because a tile loaded on a round zoom will be displayed as 512px. Could we just say "in pixels"? I agree that the current definition is a bit confusing. cc @lucaswoj who did copy edits on this.

    On Retina displays, do these ⅟₅₁₂-of-a-tile units remain ⅟₅₁₂-of-a-tile units, or do they become ⅟₁₀₂₄-of-a-tile units?

    Nope, still relative to a tile as if it was 512px.

    The style specification describes tolerance as a “Douglas-Peucker simplification tolerance”, but in this case that means it’s also measured in ⅟₅₁₂-of-a-tile units, right? Most descriptions of the Douglas–Peucker algorithm discuss curve simplification specifically, so it’ll be unclear to the developer how the tolerance relates to clustering. We can probably clarify the documentation a bit by talking about a minimum distance between points.

    tolerance does not affect clustering at all, it's purely for lines/polygons.

  12. 1ec5 commented on Sep 13, 2016

    @1ec5
    Contributor

    Could we just say "in pixels"?

    Unfortunately, we can’t on Apple platforms, because “pixel” has a specific meaning that varies by resolution. A Mac, for example, can simultaneously have a LoDPI screen on which one pixel is one point and a HiDPI (Retina) screen on which one pixel is half a point.

    So a 512×512 tile actually has 512 of these units on each side, correct? If that’s the case, “⅟₅₁₂ of a tile” is misleading.

    tolerance does not affect clustering at all, it's purely for lines/polygons.

    I was mistaken in thinking all the options were related to clustering. Thanks for the clarification!

  13. added
    macOS
    on Sep 13, 2016
  14. lucaswoj commented on Sep 13, 2016

    @lucaswoj
    Contributor

    I pushed a PR mapbox/mapbox-gl-style-spec#492 which clarifies the meaning of the docs. It does not address the transition to defining screen points.

  15. 1ec5 commented on Sep 13, 2016

    @1ec5
    Contributor

    It does not address the transition to defining screen points.

    That’s fine; that’s a platform-specific concept anyways.

  16. self-assigned this
    on Sep 20, 2016
  17. boundsj commented on Sep 21, 2016

    @boundsj
    ContributorAuthor

    @1ec5 in #6411 I propose an update to the ios/macos API documentation to reflect the changes @lucaswoj made in mapbox/mapbox-gl-style-spec#492.

    In regards to the discussion about screen points, I'm not sure where or how to mention that concept even in the platform specific documentation. In practice, the value controls the density of cluster markers in a tile. However, I can't think of a great way to loop in the concept of points with the current interface without making the documentation less clear than it is already. For example, when I look at the same data set with cluster radius values of 512, 256, and 128 I see these results:

    screen shot 2016-09-20 at 6 53 20 pm

    My guess is that most developers won't care about fine grained control and may find an abstraction helpful (i.e. MGLClusterDensityLow, MGLClusterDensityHigh) -- something like kCLLocationAccuracyThreeKilometers -> kCLLocationAccuracyBestForNavigation that represents a double (and the developer is free to set a double if they need fine grained control) or just use the constant if they are less concerned.

    Do you have any ideas for how to proceed so we can close this blocker?

  18. nitrag commented on Sep 21, 2016

    @nitrag
    Contributor

    Hey! Newb here, just switching to mapbox SDK (ios/android) and was just looking for clustering support. Reading through all the open issues trying to get up to speed on where you guys are at.

    Honestly some of the pixel stuff you are talking about is over my head but here are my 2 cents.

    In other map SDK's I'm used to seeing a maxClusterRadius or similar property. Most likely the double you are referring to. Essentially how close points need to be (zoom dependent) to cluster together. As a developer I will test 1,000 or 10,000 markers and like the flexibility to just change a value to see how it changes on the map and to find the value that fits my needs. Perhaps you can have a default for other people that won't really care.

    Here's the example from Leaflet Marker Cluster plugin:
    maxClusterRadius: The maximum radius that a cluster will cover from the central marker (in pixels). Default 80. Decreasing will make more, smaller clusters.

    So, whatever the field is, we the users just need some value to manipulate until we get the visual granularity we are looking for.

    Thanks! Eagerly awaiting this feature!

  19. 1ec5 commented on Sep 21, 2016

    @1ec5
    Contributor

    In other map SDK's I'm used to seeing a maxClusterRadius or similar property. Most likely the double you are referring to. Essentially how close points need to be (zoom dependent) to cluster together.

    Hi @nitrag, thanks for your 2¢. One of the options in question, MGLGeoJSONClusterRadiusOption, is indeed an analogue to the maxClusterRadius field you’re asking about. So yes, there is an option developers like you can hand-tune to get the results you’re looking for.

    However, I can't think of a great way to loop in the concept of points with the current interface without making the documentation less clear than it is already.

    No platform-specific discussion about points is needed, because the final language in mapbox/mapbox-gl-style-spec#492 and #6411 ended up not mentioning pixels at all, and apparently these values have the same visual effect regardless of the screen’s pixel density.

    My guess is that most developers won't care about fine grained control and may find an abstraction helpful (i.e. MGLClusterDensityLow, MGLClusterDensityHigh) -- something like kCLLocationAccuracyThreeKilometers -> kCLLocationAccuracyBestForNavigation that represents a double (and the developer is free to set a double if they need fine grained control) or just use the constant if they are less concerned.

    Another example is MGLMapView.decelerationRate, for which we have the three constants MGLMapViewDecelerationRateNormal, MGLMapViewDecelerationRateFast, and MGLMapViewDecelerationRateImmediate but allow other values as well. I don’t have a good sense of the values developers would typically want for this option (other than the default of 50); do you?

    So, whatever the field is, we the users just need some value to manipulate until we get the visual granularity we are looking for.

    It’s true that you can often hand-tune an option until the result looks good. But we should also try to enable dynamic use cases where the right value can’t be determined until runtime. Physical units (like MGLCamera.altitude), screen units (MKRoadWidthAtZoomScale()), and “milepost” constants (MGLMapViewDecelerationRate…) help to ground the API in reality and make the results more predictable. That can be important when attempting to synchronize the map with other UI elements, UIDynamics, etc.

    But enough philosophy. 😄 Let’s go with what we have in #6411. The nice thing about an option dictionary is that we can easily add a different option in the future if we come up with a better idea.

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

Metadata

Metadata

Assignees

Labels

beta blockerdocumentationiOSmacOSneeds discussionruntime styling

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions