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

[ios, macos] fixes #5962 added geojson options to support clustering - #6217

Merged
boundsj merged 2 commits into
masterfrom
5962-geojson-clustering
Sep 2, 2016
Merged

boundsj merged 2 commits into
masterfrom
5962-geojson-clustering

Conversation

@frederoni

@frederoni frederoni commented Aug 31, 2016 •

Copy link
Copy Markdown
Contributor

wip #5962

- [ ] Reuse default values from core

  • Write documentation
  • Add unit tests

- [ ] Documentation for mobile environment (will happen in #6236)

👀 @boundsj

@frederoni frederoni added iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS beta blocker Blocks the next beta release runtime styling labels Aug 31, 2016
@frederoni frederoni added this to the ios-v3.4.0 milestone Aug 31, 2016
@frederoni
frederoni force-pushed the 5962-geojson-clustering branch from 3d97fbb to f9794ab Compare August 31, 2016 07:56
@1ec5

1ec5 commented Aug 31, 2016 •

Copy link
Copy Markdown
Contributor

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.

Comment thread platform/darwin/src/MGLGeoJSONOptions.h Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It’s ironic for me to say this in light of #5970, but I think we could get away with a simple NSDictionary and some global string constants instead of a full-blown options object. That’s the way most Cocoa APIs accept options, especially when not all of the options are required (for example, NSAttributedString). Moving to a loosely-typed dictionary also frees us from having to hard-code default values.

@boundsj

boundsj commented Aug 31, 2016

Copy link
Copy Markdown
Contributor

I actually already started this in another branch. I noticed that when I try to combine similar changes in this commit with the changes in the 6049 branch and filter on point_count (like this example from the Android demo app) no data is rendered. I'm going to investigate that more now

@boundsj
boundsj force-pushed the 5962-geojson-clustering branch from f9794ab to 2495143 Compare September 1, 2016 20:27
@boundsj

boundsj commented Sep 1, 2016

Copy link
Copy Markdown
Contributor

2495143 implements this with an NSDictionary as suggested above.

Regarding #6217 (comment) and the discussion in mapbox/mapbox-gl-js#2985; this PR has minimum viable documentation and I'd like to land it sooner for an alpha release. I'll create another ticket to capture the work to make the documentation better.

cc @frederoni @1ec5

@boundsj

boundsj commented Sep 1, 2016

Copy link
Copy Markdown
Contributor

Tail work ticket for documentation opened: #6236

Comment thread platform/darwin/src/MGLGeoJSONSource.h Outdated

@1ec5 1ec5 Sep 2, 2016 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: our convention is currently to use Objective-C Boolean values, so YES and NO (in backticks) rather than true and false.

@boundsj
boundsj force-pushed the 5962-geojson-clustering branch from bd778b5 to 4912238 Compare September 2, 2016 17:04
@boundsj

boundsj commented Sep 2, 2016

Copy link
Copy Markdown
Contributor

Great points @1ec5. Thanks for the help. I've simplified this and will land it later today if it looks ok.

@incanus

incanus commented Sep 2, 2016

Copy link
Copy Markdown
Contributor

we don’t offer any way for the developer to find out the size of the tile at a given zoom level.

AFAICT, isn't this just FractionalZoom * 512?

@1ec5

1ec5 commented Sep 2, 2016

Copy link
Copy Markdown
Contributor

we don’t offer any way for the developer to find out the size of the tile at a given zoom level.

AFAICT, isn't this just FractionalZoom * 512?

Not quite: zoom levels are logarithmic, not linear. But we don’t have an API for it anyways, so I don’t think we should hand-wave about it in documentation.

@incanus

incanus commented Sep 2, 2016 •

Copy link
Copy Markdown
Contributor

zoom levels are logarithmic, not linear

Ah, right. But then: log2(FractionalZoom) * 512?

But, true. This is a side point anyway.

@boundsj
boundsj force-pushed the 5962-geojson-clustering branch from a996245 to 46ab8aa Compare September 2, 2016 21:12
frederoni and others added 2 commits September 2, 2016 14:41
This removes a previous implementation of geojson options that used
a new type to transfer the data around. Added in its place is
an options API that takes an NSDictionary that works similarly to
NSAttributedString and many other Cocoa APIs that take options.

The options parser now expects the developer to send values of the
type noted in the documentation and it simply converts the NSNumber
to the correct type (integer, double, or bool) for mbgl. However, an
exception is raised if the value is not an NSNumber.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

beta blocker Blocks the next beta release iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS runtime styling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants