-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Conversation
d36f496
to
479b788
Compare
9f6ae2c
to
aafac15
Compare
Would it be possible to keep both around in order not to break the public API (for now)? |
aafac15
to
852963f
Compare
479b788
to
e6eaabe
Compare
e6eaabe
to
4495625
Compare
fb53043
to
4bda046
Compare
1bdf9a1
to
89d094b
Compare
a2af3c3
to
2d44c1b
Compare
@zugaldia I've included the changes to the offline tool in this pr:
|
2d44c1b
to
35d6140
Compare
for (uint8_t z = clampedZoomRange.min; z <= clampedZoomRange.max; z++) { | ||
result += definition.match( | ||
[&](const OfflineTilePyramidRegionDefinition& reg){ return util::tileCount(reg.bounds, z); }, | ||
[&](const OfflineGeometryRegionDefinition& reg){ return util::tileCount(reg.geometry, z); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mbgl::util::tileCount(Geometry<>...)
method will block, especially when called in a tight loop like this. #9675 was filed in the past for this same problem with large LatLngBounds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@asheemmamoowala Correct. However, this is identical to the previous implementation.
I'm all for speeding this up. But maybe in a separate issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems fine. I profiled these changes using mbgl-offline
and don't see the tile count or tile cover operations showing up as significant blips on the main thread.
35d6140
to
ac556fe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to the comments below, please:
- Remove the note about MGLTilePyramidOfflineRegion from MGLOfflineRegion’s documentation comment, since it’s no longer an only child.
- Add a blurb to the iOS and macOS changelogs noting the new class as a more granular alternative to MGLTilePyramidOfflineRegion.
Thanks!
range of zoom levels. | ||
*/ | ||
MGL_EXPORT | ||
@interface MGLGeometryOfflineRegion : NSObject <MGLOfflineRegion, NSSecureCoding, NSCopying> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On iOS and macOS, we say “shape” instead of “geometry”.
The geometry bounds for the geographic region covered by the downloaded | ||
tiles. | ||
*/ | ||
@property (nonatomic, readonly) MGLShape *geometry; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This property would be named shape
rather than geometry
.
MGLPointAnnotation is a subclass of MGLShape that corresponds to a Point in GeoJSON. If the region needs to have dimension, we should require that the shape conform to the MGLOverlay protocol (MGLShape <MGLOverlay> *
), though that would still allow for MGLPolyline. If the region needs to be two-dimensional, then we’d need to introduce either a runtime class check or a new protocol like “MGLSpaceFilling”.
The URL may be a full HTTP or HTTPS URL or a Mapbox URL indicating the style’s | ||
map ID (`mapbox://styles/{user}/{style}`). | ||
*/ | ||
@property (nonatomic, readonly) NSURL *styleURL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let’s promote styleURL
to the MGLOfflineRegion protocol, since it’s shared in common between the two conforming classes and we don’t expect to introduce a new region class that doesn’t depend on a style URL. I could go either way about promoting minimumZoomLevel
and maximumZoomLevel
.
[NSException raise:@"Method unavailable" | ||
format: | ||
@"-[MGLGeometryOfflineRegion init] is unavailable. " | ||
@"Use -initWithStyleURL:bounds:fromZoomLevel:toZoomLevel: instead."]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace “bounds” with “shape”.
|
||
/** | ||
An offline region defined by a style URL, geographic coordinate bounds, and | ||
range of zoom levels. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace “coordinate bounds” with “shape”.
|
||
/** | ||
An offline region defined by a style URL, geographic coordinate bounds, and | ||
range of zoom levels. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there any benefits to using an MGLTilePyramidOfflineRegion instead of an MGLShapeOfflineRegion going forward, such as performance? If so, we can mention those benefits here and in MGLTilePyramidOfflineRegion’s documentation comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MGLTilePyramidOfflineRegion
would perform better at computing the number of tile resources needed, and computing their actual IDs. But that performance advantage over MGLShapeOfflineRegion
should be marginal when including the download as well.
More importantly, switching from using the bounding box to an actual shape would reduce the number of resources required, the storage and download cost. It would also help with the tile download ceiling for many customers interested in many small offline regions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, let’s mention the new class’s benefits in the documentation comments for both classes. The old class is being left in place for backwards compatibility reasons, but we don’t have to say that just yet since we aren’t deprecating it.
#12285 tracks adding a UI to macosapp for selecting a non-pyramidal offline region for download. |
Tagging @julianrex to help review the last round of iOS changes. Otherwise it seems we're in good shape to get this merged. |
By the way, most of the changes requested in #11447 (review) are renames, so that review should be straightforward to address. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good from the iOS/macOS side - we should address @1ec5's rename and protocol recommendations .
NSURL *_styleURL; | ||
} | ||
|
||
@synthesize styleURL = _styleURL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be able to replace the @synthesize
and the instance var declaration with a single @property
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't accept just the property, so left this for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
This ought to work, so I'd be interested in why it might not be for you:
@interface MGLShapeOfflineRegion () <MGLOfflineRegion_Private, MGLShapeOfflineRegion_Private>
@property (nonatomic, copy) NSURL *styleURL;
@end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It probably has to do with the fact that the property’s getter is now declared in a protocol, MGLOfflineRegion, rather than a concrete class, which would prevent autosynthesis. If that’s the case, then explicit synthesis is fine.
}]; | ||
[pack requestProgress]; | ||
[self waitForExpectationsWithTimeout:1 handler:nil]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very minor: we should probably have pack = nil;
at the end here, since it's a __block
variable.
}]; | ||
[self waitForExpectationsWithTimeout:2 handler:nil]; | ||
|
||
XCTAssertEqual([MGLOfflineStorage sharedOfflineStorage].packs.count, countOfPacks + 1, @"Added pack should have been added to the canonical collection of packs owned by the shared offline storage object. This assertion can fail if this test is run before -testAAALoadPacks."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may have to revisit this for Xcode 10 - IIRC tests can be run in a random order (though I believe this needs to be enabled)
084b3a2
to
27ce802
Compare
@@ -78,7 +87,17 @@ - (void)dealloc { | |||
|
|||
const mbgl::OfflineRegionDefinition ®ionDefinition = _mbglOfflineRegion->getDefinition(); | |||
NSAssert([MGLTilePyramidOfflineRegion conformsToProtocol:@protocol(MGLOfflineRegion_Private)], @"MGLTilePyramidOfflineRegion should conform to MGLOfflineRegion_Private."); | |||
return [(id <MGLOfflineRegion_Private>)[MGLTilePyramidOfflineRegion alloc] initWithOfflineRegionDefinition:regionDefinition]; | |||
NSAssert([MGLShapeOfflineRegion conformsToProtocol:@protocol(MGLOfflineRegion_Private)], @"MGLGeometryOfflineRegion should conform to MGLOfflineRegion_Private."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace all instances of MGLGeometryOfflineRegion
in this PR with MGLShapeOfflineRegion
.
[NSException raise:@"Method unavailable" | ||
format: | ||
@"-[MGLShapeOfflineRegion init] is unavailable. " | ||
@"Use -initWithStyleURL:bounds:fromZoomLevel:toZoomLevel: instead."]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace bounds:
with shape:
.
@@ -13,17 +13,6 @@ NS_ASSUME_NONNULL_BEGIN | |||
MGL_EXPORT | |||
@interface MGLTilePyramidOfflineRegion : NSObject <MGLOfflineRegion, NSSecureCoding, NSCopying> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To minimize the resources required by an irregularly shaped offline region, use the
MGLShapeOfflineRegion
class instead.
/ref #11447 (comment)
/** | ||
An offline region defined by a style URL, geographic shape, and | ||
range of zoom levels. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class requires fewer resources than
MGLTilePyramidOfflineRegion
for irregularly shaped regions.
/ref #11447 (comment)
27ce802
to
f0a4dcb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we just need to address @1ec5's comments, and we're good from the iOS/macOS side.
Adds the ability to specify offline regions shapes as any GeoJson geometry.
Depends on:
TODO: