From 9e19405afb6f6c68d08cbecaded752f40a7c0c02 Mon Sep 17 00:00:00 2001 From: Tobrun Date: Wed, 22 Aug 2018 15:55:37 +0200 Subject: [PATCH 01/29] [core] - expose getChildren, getLeaves, getClusterExpansionZoom on SuperclusterData --- include/mbgl/style/sources/geojson_source.hpp | 5 ++++- src/mbgl/style/sources/geojson_source.cpp | 14 ++++++++++++ .../style/sources/geojson_source_impl.cpp | 22 +++++++++---------- .../style/sources/geojson_source_impl.hpp | 11 +++++----- 4 files changed, 34 insertions(+), 18 deletions(-) diff --git a/include/mbgl/style/sources/geojson_source.hpp b/include/mbgl/style/sources/geojson_source.hpp index a03b9102795..36cc9bb4bbf 100644 --- a/include/mbgl/style/sources/geojson_source.hpp +++ b/include/mbgl/style/sources/geojson_source.hpp @@ -33,9 +33,12 @@ class GeoJSONSource : public Source { void setURL(const std::string& url); void setGeoJSON(const GeoJSON&); - optional getURL() const; + mapbox::geometry::feature_collection getChildren(const std::uint32_t) const; + mapbox::geometry::feature_collection getLeaves(const std::uint32_t, const std::uint32_t, const std::uint32_t) const; + std::uint8_t getClusterExpansionZoom(std::uint32_t) const; + class Impl; const Impl& impl() const; diff --git a/src/mbgl/style/sources/geojson_source.cpp b/src/mbgl/style/sources/geojson_source.cpp index 4e3478322de..665cc9c0dc7 100644 --- a/src/mbgl/style/sources/geojson_source.cpp +++ b/src/mbgl/style/sources/geojson_source.cpp @@ -40,6 +40,20 @@ optional GeoJSONSource::getURL() const { return url; } +mapbox::geometry::feature_collection GeoJSONSource::getChildren(const std::uint32_t cluster_id) const { + return impl().getData()->getChildren(cluster_id); +} + +mapbox::geometry::feature_collection GeoJSONSource::getLeaves(const std::uint32_t cluster_id, + const std::uint32_t limit = 10, + const std::uint32_t offset = 0) const{ + return impl().getData()->getLeaves(cluster_id, limit, offset); +} + +std::uint8_t GeoJSONSource::getClusterExpansionZoom(std::uint32_t cluster_id) const { + return impl().getData()->getClusterExpansionZoom(cluster_id); +} + void GeoJSONSource::loadDescription(FileSource& fileSource) { if (!url) { loaded = true; diff --git a/src/mbgl/style/sources/geojson_source_impl.cpp b/src/mbgl/style/sources/geojson_source_impl.cpp index 24ac1d79766..7e83588c5d7 100644 --- a/src/mbgl/style/sources/geojson_source_impl.cpp +++ b/src/mbgl/style/sources/geojson_source_impl.cpp @@ -21,11 +21,11 @@ class GeoJSONVTData : public GeoJSONData { return impl.getTile(tileID.z, tileID.x, tileID.y).features; } - mapbox::feature::feature_collection getChildren(const std::uint32_t) final { + mapbox::geometry::feature_collection getChildren(const std::uint32_t) final { return {}; } - mapbox::feature::feature_collection getLeaves(const std::uint32_t, + mapbox::geometry::feature_collection getLeaves(const std::uint32_t, const std::uint32_t, const std::uint32_t) final { return {}; @@ -49,13 +49,13 @@ class SuperclusterData : public GeoJSONData { return impl.getTile(tileID.z, tileID.x, tileID.y); } - mapbox::feature::feature_collection getChildren(const std::uint32_t cluster_id) final { + mapbox::geometry::feature_collection getChildren(const std::uint32_t cluster_id) final { return impl.getChildren(cluster_id); } - mapbox::feature::feature_collection getLeaves(const std::uint32_t cluster_id, - const std::uint32_t limit, - const std::uint32_t offset) final { + mapbox::geometry::feature_collection getLeaves(const std::uint32_t cluster_id, + const std::uint32_t limit = 10, + const std::uint32_t offset = 0) final { return impl.getLeaves(cluster_id, limit, offset); } @@ -75,7 +75,7 @@ GeoJSONSource::Impl::Impl(std::string id_, GeoJSONOptions options_) GeoJSONSource::Impl::Impl(const Impl& other, const GeoJSON& geoJSON) : Source::Impl(other), options(other.options) { - constexpr double scale = util::EXTENT / util::tileSize; + double scale = util::EXTENT / util::tileSize; if (options.cluster && geoJSON.is>() @@ -84,7 +84,7 @@ GeoJSONSource::Impl::Impl(const Impl& other, const GeoJSON& geoJSON) clusterOptions.maxZoom = options.clusterMaxZoom; clusterOptions.extent = util::EXTENT; clusterOptions.radius = ::round(scale * options.clusterRadius); - data = std::make_shared( + data = std::make_unique( geoJSON.get>(), clusterOptions); } else { mapbox::geojsonvt::Options vtOptions; @@ -93,7 +93,7 @@ GeoJSONSource::Impl::Impl(const Impl& other, const GeoJSON& geoJSON) vtOptions.buffer = ::round(scale * options.buffer); vtOptions.tolerance = scale * options.tolerance; vtOptions.lineMetrics = options.lineMetrics; - data = std::make_shared(geoJSON, vtOptions); + data = std::make_unique(geoJSON, vtOptions); } } @@ -103,8 +103,8 @@ Range GeoJSONSource::Impl::getZoomRange() const { return { options.minzoom, options.maxzoom }; } -std::weak_ptr GeoJSONSource::Impl::getData() const { - return data; +GeoJSONData* GeoJSONSource::Impl::getData() const { + return data.get(); } optional GeoJSONSource::Impl::getAttribution() const { diff --git a/src/mbgl/style/sources/geojson_source_impl.hpp b/src/mbgl/style/sources/geojson_source_impl.hpp index b88ab35ee0f..4ab529b54bd 100644 --- a/src/mbgl/style/sources/geojson_source_impl.hpp +++ b/src/mbgl/style/sources/geojson_source_impl.hpp @@ -17,10 +17,9 @@ class GeoJSONData { virtual mapbox::feature::feature_collection getTile(const CanonicalTileID&) = 0; // SuperclusterData - virtual mapbox::feature::feature_collection getChildren(const std::uint32_t) = 0; - virtual mapbox::feature::feature_collection getLeaves(const std::uint32_t, - const std::uint32_t limit = 10u, - const std::uint32_t offset = 0u) = 0; + virtual mapbox::geometry::feature_collection getChildren(const std::uint32_t) = 0; + virtual mapbox::geometry::feature_collection getLeaves(const std::uint32_t, const std::uint32_t, + const std::uint32_t) = 0; virtual std::uint8_t getClusterExpansionZoom(std::uint32_t) = 0; }; @@ -31,13 +30,13 @@ class GeoJSONSource::Impl : public Source::Impl { ~Impl() final; Range getZoomRange() const; - std::weak_ptr getData() const; + GeoJSONData* getData() const; optional getAttribution() const final; private: GeoJSONOptions options; - std::shared_ptr data; + std::unique_ptr data; }; } // namespace style From 99265a7aa26dc3a95a74afeba97da7d83eea9489 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Mon, 24 Sep 2018 11:06:53 -0400 Subject: [PATCH 02/29] [ios, macos] Expose getLeaves, getChildren, getClusterExpansionZoom. Added MGLPointCluster. --- platform/darwin/src/MGLFeature.h | 6 ++ platform/darwin/src/MGLFeature.mm | 59 +++++++++++++++++++- platform/darwin/src/MGLPointCluster.h | 15 +++++ platform/darwin/src/MGLShapeSource.h | 6 ++ platform/darwin/src/MGLShapeSource.mm | 59 ++++++++++++++++++++ platform/darwin/src/MGLShapeSource_Private.h | 4 ++ platform/ios/ios.xcodeproj/project.pbxproj | 6 ++ 7 files changed, 154 insertions(+), 1 deletion(-) create mode 100644 platform/darwin/src/MGLPointCluster.h diff --git a/platform/darwin/src/MGLFeature.h b/platform/darwin/src/MGLFeature.h index 8886c8df559..87781816f03 100644 --- a/platform/darwin/src/MGLFeature.h +++ b/platform/darwin/src/MGLFeature.h @@ -6,6 +6,7 @@ #import "MGLPointAnnotation.h" #import "MGLPointCollection.h" #import "MGLShapeCollection.h" +#import "MGLPointCluster.h" NS_ASSUME_NONNULL_BEGIN @@ -190,6 +191,9 @@ MGL_EXPORT */ MGL_EXPORT @interface MGLPointFeature : MGLPointAnnotation + +// TODO: doc +- (id)cluster; @end /** @@ -281,4 +285,6 @@ MGL_EXPORT @end + + NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MGLFeature.mm b/platform/darwin/src/MGLFeature.mm index d24c8076255..86ab2e66868 100644 --- a/platform/darwin/src/MGLFeature.mm +++ b/platform/darwin/src/MGLFeature.mm @@ -55,7 +55,14 @@ - (NSString *)description @end -@interface MGLPointFeature () +NSString * const MGLPointClusterBoolKey = @"cluster"; +NSString * const MGLPointClusterIdKey = @"cluster_id"; +NSString * const MGLPointClusterCountKey = @"point_count"; +NSString * const MGLPointClusterCountAbbreviationKey = @"cluster_abbreviated"; + +// TODO: privately conform to MGLPointCluster, so we can return the same object OR create a *new* +// object, or even have a subclass of MGLPointFeature? +@interface MGLPointFeature () @end @implementation MGLPointFeature @@ -90,6 +97,56 @@ - (NSString *)description self.attributes.count ? self.attributes : @"none"]; } +- (id)cluster { + return self.cluster ? self : nil; +} + +#pragma mark - MGLPointCluster + +- (BOOL)isCluster { + NSNumber *isCluster = MGL_OBJC_DYNAMIC_CAST(self.attributes[MGLPointClusterBoolKey], NSNumber); + return [isCluster boolValue]; +} + +- (uint32_t)clusterId { + NSNumber *clusterNumber = MGL_OBJC_DYNAMIC_CAST(self.attributes[MGLPointClusterIdKey], NSNumber); + + NSAssert(clusterNumber, @"Clusters should have a cluster_id"); + if (!clusterNumber) { + return -1; + } + + NSUInteger clusterId = [clusterNumber unsignedIntegerValue]; + + NSAssert(clusterId < (1UL << 32), @"Cluster IDs are 32bit"); + NSAssert([self.identifier isKindOfClass:[NSNumber class]], @"The identifier should be an NSNumber"); + NSAssert(clusterId == [self.identifier unsignedIntegerValue], @"The cluster id should match the feature's identifier."); + + return (uint32_t)clusterId; +} + +- (NSUInteger)pointCount { + NSNumber *pointCount = MGL_OBJC_DYNAMIC_CAST(self.attributes[MGLPointClusterCountKey], NSNumber); + + NSAssert(pointCount, @"Clusters should have a point_count"); + if (!pointCount) { + return -1; + } + + return [pointCount unsignedIntegerValue]; +} + +- (NSString*)clusterAbbreviated { + NSString *abbreviation = MGL_OBJC_DYNAMIC_CAST(self.attributes[MGLPointClusterCountAbbreviationKey], NSString); + + NSAssert(abbreviation, @"Clusters should have a cluster_abbreviated"); + if (!abbreviation) { + return @""; + } + + return abbreviation; +} + @end @interface MGLPolylineFeature () diff --git a/platform/darwin/src/MGLPointCluster.h b/platform/darwin/src/MGLPointCluster.h new file mode 100644 index 00000000000..af48203ecc1 --- /dev/null +++ b/platform/darwin/src/MGLPointCluster.h @@ -0,0 +1,15 @@ +#import +#import "MGLFoundation.h" + +NS_ASSUME_NONNULL_BEGIN + +MGL_EXPORT +// TODO: Should this be a MGLPointClusterFeature? Subclass of MGLPointFeature? +@protocol MGLPointCluster +@property (nonatomic, readonly, getter=isCluster) BOOL cluster; // Keep so we match cluster def? Always YES. +@property (nonatomic, readonly) uint32_t clusterId; +@property (nonatomic, readonly) NSUInteger pointCount; +@property (nonatomic, readonly) NSString *clusterAbbreviated; +@end + +NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MGLShapeSource.h b/platform/darwin/src/MGLShapeSource.h index edf8c0a1746..4b75e3bd163 100644 --- a/platform/darwin/src/MGLShapeSource.h +++ b/platform/darwin/src/MGLShapeSource.h @@ -5,6 +5,8 @@ NS_ASSUME_NONNULL_BEGIN @protocol MGLFeature; +@protocol MGLPointCluster; +@class MGLPointFeature; @class MGLShape; /** @@ -321,6 +323,10 @@ MGL_EXPORT */ - (NSArray> *)featuresMatchingPredicate:(nullable NSPredicate *)predicate; +// TODO: doc +- (NSArray> *)leavesOfCluster:(id)cluster offset:(uint32_t)offset limit:(uint32_t)limit; +- (NSArray> *)childrenOfCluster:(id)cluster; +- (double)zoomLevelForExpandingCluster:(id)cluster; @end NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MGLShapeSource.mm b/platform/darwin/src/MGLShapeSource.mm index c960f2a4a77..06c63183393 100644 --- a/platform/darwin/src/MGLShapeSource.mm +++ b/platform/darwin/src/MGLShapeSource.mm @@ -184,4 +184,63 @@ - (NSString *)description { return MGLFeaturesFromMBGLFeatures(features); } +#pragma mark - MGLPointCluster management + +// TODO: doc +// For clustered sources, fetches the original points that belong to the cluster (as an array of GeoJSON features). +// clusterId(number)The value of the cluster's cluster_id property. +// limit(number)The maximum number of features to return. +// offset(number)The number of features to skip (e.g. for pagination). +- (NSArray> *)leavesOfCluster:(id)cluster offset:(uint32_t)offset limit:(uint32_t)limit { + if(!self.rawSource) { + return nil; + } + + std::vector leaves = self.rawSource->getLeaves(cluster.clusterId, limit, offset); + return MGLFeaturesFromMBGLFeatures(leaves); +} + +// TODO: doc +// For clustered sources, fetches the children of the given cluster on the next zoom level (as an array of GeoJSON features). +- (NSArray> *)childrenOfCluster:(id)cluster { + if(!self.rawSource) { + return nil; + } + + std::vector children = self.rawSource->getChildren(cluster.clusterId); + return MGLFeaturesFromMBGLFeatures(children); +} + +// For clustered sources, fetches the zoom at which the given cluster expands. +- (double)zoomLevelForExpandingCluster:(id)cluster { + if(!self.rawSource) { + return -1.0; + } + + uint8_t zoom = self.rawSource->getClusterExpansionZoom(cluster.clusterId); + return static_cast(zoom); +} + +- (void)debugRecursiveLogForFeature:(id )feature indent:(NSInteger)indent { + + MGLPointFeature *pointFeature = MGL_OBJC_DYNAMIC_CAST(feature, MGLPointFeature); + id cluster = [pointFeature cluster]; + + if (cluster) { + double zoom = [self zoomLevelForExpandingCluster:cluster]; + + NSString *log = [NSString stringWithFormat:@"Cluster %d [count=%ld, zoom=%0.1g]", cluster.clusterId, cluster.pointCount, zoom]; + + printf("%*s%s\n", (int)indent, "", log.UTF8String); + + NSArray> *children = [self childrenOfCluster:cluster]; + for (id child in children) { + [self debugRecursiveLogForFeature:child indent:indent + 2]; + } + } + else { + printf("%*sLeaf\n", (int)indent, ""); + } +} + @end diff --git a/platform/darwin/src/MGLShapeSource_Private.h b/platform/darwin/src/MGLShapeSource_Private.h index fb5b3b3c0da..dfe327e46bf 100644 --- a/platform/darwin/src/MGLShapeSource_Private.h +++ b/platform/darwin/src/MGLShapeSource_Private.h @@ -12,4 +12,8 @@ namespace mbgl { MGL_EXPORT mbgl::style::GeoJSONOptions MGLGeoJSONOptionsFromDictionary(NSDictionary *options); +@interface MGLShapeSource (Private) +- (void)debugRecursiveLogForFeature:(id )feature indent:(NSInteger)indent; +@end + NS_ASSUME_NONNULL_END diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj index 45c42e65b9c..fb1598ba80f 100644 --- a/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/ios.xcodeproj/project.pbxproj @@ -474,6 +474,8 @@ CA0C27942076CA19001CE5B7 /* MGLMapViewIntegrationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CA0C27932076CA19001CE5B7 /* MGLMapViewIntegrationTest.m */; }; CA1B4A512099FB2200EDD491 /* MGLMapSnapshotterTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CA1B4A502099FB2200EDD491 /* MGLMapSnapshotterTest.m */; }; CA34C9C3207FD272005C1A06 /* MGLCameraTransitionTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = CA34C9C2207FD272005C1A06 /* MGLCameraTransitionTests.mm */; }; + CA42323B2159242400BB7C18 /* MGLPointCluster.h in Headers */ = {isa = PBXBuildFile; fileRef = CA42323A2159242400BB7C18 /* MGLPointCluster.h */; settings = {ATTRIBUTES = (Public, ); }; }; + CA42323C2159242400BB7C18 /* MGLPointCluster.h in Headers */ = {isa = PBXBuildFile; fileRef = CA42323A2159242400BB7C18 /* MGLPointCluster.h */; settings = {ATTRIBUTES = (Public, ); }; }; CA4EB8C720863487006AB465 /* MGLStyleLayerIntegrationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CA4EB8C620863487006AB465 /* MGLStyleLayerIntegrationTests.m */; }; CA55CD41202C16AA00CE7095 /* MGLCameraChangeReason.h in Headers */ = {isa = PBXBuildFile; fileRef = CA55CD3E202C16AA00CE7095 /* MGLCameraChangeReason.h */; settings = {ATTRIBUTES = (Public, ); }; }; CA55CD42202C16AA00CE7095 /* MGLCameraChangeReason.h in Headers */ = {isa = PBXBuildFile; fileRef = CA55CD3E202C16AA00CE7095 /* MGLCameraChangeReason.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -1140,6 +1142,7 @@ CA0C27952076CA50001CE5B7 /* MGLMapViewIntegrationTest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLMapViewIntegrationTest.h; sourceTree = ""; }; CA1B4A502099FB2200EDD491 /* MGLMapSnapshotterTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLMapSnapshotterTest.m; sourceTree = ""; }; CA34C9C2207FD272005C1A06 /* MGLCameraTransitionTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLCameraTransitionTests.mm; sourceTree = ""; }; + CA42323A2159242400BB7C18 /* MGLPointCluster.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLPointCluster.h; sourceTree = ""; }; CA4EB8C620863487006AB465 /* MGLStyleLayerIntegrationTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLStyleLayerIntegrationTests.m; sourceTree = ""; }; CA55CD3E202C16AA00CE7095 /* MGLCameraChangeReason.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLCameraChangeReason.h; sourceTree = ""; }; CA5E5042209BDC5F001A8A81 /* MGLTestUtility.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = MGLTestUtility.h; path = ../../darwin/test/MGLTestUtility.h; sourceTree = ""; }; @@ -2234,6 +2237,7 @@ DA88480E1CBAFA6200AB86E3 /* MGLShape.mm */, DAD165761CF4CDFF001FF4B9 /* MGLShapeCollection.h */, DAD165771CF4CDFF001FF4B9 /* MGLShapeCollection.mm */, + CA42323A2159242400BB7C18 /* MGLPointCluster.h */, ); name = Geometry; sourceTree = ""; @@ -2538,6 +2542,7 @@ 55E5666C21C2A2080008B8B5 /* MMEDispatchManager.h in Headers */, 55E5666121C2A2080008B8B5 /* MMEEventsManager.h in Headers */, 55E5666D21C2A2080008B8B5 /* NSData+MMEGZIP.h in Headers */, + CA42323B2159242400BB7C18 /* MGLPointCluster.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2655,6 +2660,7 @@ DAC25FCD200FD83F009BE98E /* NSExpression+MGLPrivateAdditions.h in Headers */, 74CB5ED2219B286400102936 /* MGLSymbolStyleLayer_Private.h in Headers */, 354B83971D2E873E005D9406 /* MGLUserLocationAnnotationView.h in Headers */, + CA42323C2159242400BB7C18 /* MGLPointCluster.h in Headers */, DAF0D8111DFE0EA000B28378 /* MGLRasterTileSource_Private.h in Headers */, 96E516FF20005A4F00A02306 /* MGLMapboxEvents.h in Headers */, 1F6A82A321360F9D00BA5B41 /* MGLLoggingConfiguration.h in Headers */, From 0e029a0f8d0e2220e9f71b18148a8ea257e12d5e Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Mon, 24 Sep 2018 23:20:01 -0400 Subject: [PATCH 03/29] [ios] Updated core files list. --- platform/ios/core-files.txt | 321 ++++++++++++++++++++++++++++++++++++ 1 file changed, 321 insertions(+) create mode 100644 platform/ios/core-files.txt diff --git a/platform/ios/core-files.txt b/platform/ios/core-files.txt new file mode 100644 index 00000000000..611245b2b30 --- /dev/null +++ b/platform/ios/core-files.txt @@ -0,0 +1,321 @@ +# This file is generated. Do not edit. Regenerate this with scripts/generate-cmake-files.js + +# SDK +platform/ios/src/Mapbox.h + +# SDK/Foundation +platform/darwin/src/MGLAccountManager.h +platform/darwin/src/MGLAccountManager.m +platform/darwin/src/MGLAccountManager_Private.h +platform/darwin/src/MGLAttributionInfo.h +platform/darwin/src/MGLAttributionInfo.mm +platform/darwin/src/MGLAttributionInfo_Private.h +platform/darwin/src/MGLFoundation.h +platform/darwin/src/MGLFoundation.mm +platform/darwin/src/MGLFoundation_Private.h +platform/darwin/src/MGLLocationManager.h +platform/darwin/src/MGLLocationManager.m +platform/darwin/src/MGLLocationManager_Private.h +platform/darwin/src/MGLLoggingConfiguration.h +platform/darwin/src/MGLLoggingConfiguration.m +platform/darwin/src/MGLLoggingConfiguration_Private.h +platform/darwin/src/MGLMapCamera.h +platform/darwin/src/MGLMapCamera.mm +platform/darwin/src/MGLMapSnapshotter.h +platform/darwin/src/MGLMapSnapshotter.mm +platform/darwin/src/MGLNetworkConfiguration.h +platform/darwin/src/MGLNetworkConfiguration.m +platform/darwin/src/MGLRendererConfiguration.h +platform/darwin/src/MGLRendererConfiguration.mm +platform/darwin/src/MGLRendererFrontend.h +platform/darwin/src/MGLStyle.h +platform/darwin/src/MGLStyle.mm +platform/darwin/src/MGLStyle_Private.h +platform/darwin/src/MGLTypes.h +platform/darwin/src/MGLTypes.m +platform/darwin/src/MGLValueEvaluator.h + +# SDK/Foundation/Categories +platform/darwin/src/NSArray+MGLAdditions.h +platform/darwin/src/NSArray+MGLAdditions.mm +platform/darwin/src/NSBundle+MGLAdditions.h +platform/darwin/src/NSBundle+MGLAdditions.m +platform/darwin/src/NSComparisonPredicate+MGLAdditions.h +platform/darwin/src/NSComparisonPredicate+MGLAdditions.mm +platform/darwin/src/NSCompoundPredicate+MGLAdditions.h +platform/darwin/src/NSCompoundPredicate+MGLAdditions.mm +platform/darwin/src/NSData+MGLAdditions.h +platform/darwin/src/NSData+MGLAdditions.mm +platform/darwin/src/NSDate+MGLAdditions.h +platform/darwin/src/NSDate+MGLAdditions.mm +platform/darwin/src/NSDictionary+MGLAdditions.h +platform/darwin/src/NSDictionary+MGLAdditions.mm +platform/darwin/src/NSException+MGLAdditions.h +platform/darwin/src/NSExpression+MGLAdditions.h +platform/darwin/src/NSExpression+MGLAdditions.mm +platform/darwin/src/NSExpression+MGLPrivateAdditions.h +platform/darwin/src/NSPredicate+MGLAdditions.h +platform/darwin/src/NSPredicate+MGLAdditions.mm +platform/darwin/src/NSPredicate+MGLPrivateAdditions.h +platform/darwin/src/NSProcessInfo+MGLAdditions.h +platform/darwin/src/NSProcessInfo+MGLAdditions.m +platform/darwin/src/NSString+MGLAdditions.h +platform/darwin/src/NSString+MGLAdditions.m +platform/darwin/src/NSURL+MGLAdditions.h +platform/darwin/src/NSURL+MGLAdditions.m +platform/darwin/src/NSValue+MGLAdditions.h +platform/darwin/src/NSValue+MGLAdditions.m + +# SDK/Foundation/Formatters +platform/darwin/src/MGLClockDirectionFormatter.h +platform/darwin/src/MGLClockDirectionFormatter.m +platform/darwin/src/MGLCompassDirectionFormatter.h +platform/darwin/src/MGLCompassDirectionFormatter.m +platform/darwin/src/MGLCoordinateFormatter.h +platform/darwin/src/MGLCoordinateFormatter.m +platform/darwin/src/MGLDistanceFormatter.h +platform/darwin/src/MGLDistanceFormatter.m + +# SDK/Foundation/Geometry +platform/darwin/src/MGLAnnotation.h +platform/darwin/src/MGLFeature.h +platform/darwin/src/MGLFeature.mm +platform/darwin/src/MGLFeature_Private.h +platform/darwin/src/MGLGeometry.h +platform/darwin/src/MGLGeometry.mm +platform/darwin/src/MGLGeometry_Private.h +platform/darwin/src/MGLMultiPoint.h +platform/darwin/src/MGLMultiPoint.mm +platform/darwin/src/MGLMultiPoint_Private.h +platform/darwin/src/MGLOverlay.h +platform/darwin/src/MGLPointAnnotation.h +platform/darwin/src/MGLPointAnnotation.mm +platform/darwin/src/MGLPointCollection.h +platform/darwin/src/MGLPointCollection.mm +platform/darwin/src/MGLPointCollection_Private.h +platform/darwin/src/MGLPointCluster.h +platform/darwin/src/MGLPolygon.h +platform/darwin/src/MGLPolygon.mm +platform/darwin/src/MGLPolygon_Private.h +platform/darwin/src/MGLPolyline.h +platform/darwin/src/MGLPolyline.mm +platform/darwin/src/MGLPolyline_Private.h +platform/darwin/src/MGLShape.h +platform/darwin/src/MGLShape.mm +platform/darwin/src/MGLShapeCollection.h +platform/darwin/src/MGLShapeCollection.mm +platform/darwin/src/MGLShape_Private.h + +# SDK/Foundation/Offline Maps +platform/darwin/src/MGLOfflinePack.h +platform/darwin/src/MGLOfflinePack.mm +platform/darwin/src/MGLOfflinePack_Private.h +platform/darwin/src/MGLOfflineRegion.h +platform/darwin/src/MGLOfflineRegion_Private.h +platform/darwin/src/MGLOfflineStorage.h +platform/darwin/src/MGLOfflineStorage.mm +platform/darwin/src/MGLOfflineStorage_Private.h +platform/darwin/src/MGLShapeOfflineRegion.h +platform/darwin/src/MGLShapeOfflineRegion.mm +platform/darwin/src/MGLShapeOfflineRegion_Private.h +platform/darwin/src/MGLTilePyramidOfflineRegion.h +platform/darwin/src/MGLTilePyramidOfflineRegion.mm +platform/darwin/src/MGLTilePyramidOfflineRegion_Private.h + +# SDK/Foundation/Styling +platform/darwin/src/MGLConversion.h +platform/darwin/src/MGLLight.h +platform/darwin/src/MGLLight.mm +platform/darwin/src/MGLLight_Private.h +platform/darwin/src/MGLStyleValue.h +platform/darwin/src/MGLStyleValue.mm +platform/darwin/src/MGLStyleValue_Private.h + +# SDK/Foundation/Styling/Categories +platform/darwin/src/NSValue+MGLStyleAttributeAdditions.h +platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm + +# SDK/Foundation/Styling/Layers +platform/darwin/src/MGLBackgroundStyleLayer.h +platform/darwin/src/MGLBackgroundStyleLayer.mm +platform/darwin/src/MGLBackgroundStyleLayer_Private.h +platform/darwin/src/MGLCircleStyleLayer.h +platform/darwin/src/MGLCircleStyleLayer.mm +platform/darwin/src/MGLCircleStyleLayer_Private.h +platform/darwin/src/MGLFillExtrusionStyleLayer.h +platform/darwin/src/MGLFillExtrusionStyleLayer.mm +platform/darwin/src/MGLFillExtrusionStyleLayer_Private.h +platform/darwin/src/MGLFillStyleLayer.h +platform/darwin/src/MGLFillStyleLayer.mm +platform/darwin/src/MGLFillStyleLayer_Private.h +platform/darwin/src/MGLForegroundStyleLayer.h +platform/darwin/src/MGLForegroundStyleLayer.mm +platform/darwin/src/MGLHeatmapStyleLayer.h +platform/darwin/src/MGLHeatmapStyleLayer.mm +platform/darwin/src/MGLHeatmapStyleLayer_Private.h +platform/darwin/src/MGLHillshadeStyleLayer.h +platform/darwin/src/MGLHillshadeStyleLayer.mm +platform/darwin/src/MGLHillshadeStyleLayer_Private.h +platform/darwin/src/MGLLineStyleLayer.h +platform/darwin/src/MGLLineStyleLayer.mm +platform/darwin/src/MGLLineStyleLayer_Private.h +platform/darwin/src/MGLOpenGLStyleLayer.h +platform/darwin/src/MGLOpenGLStyleLayer.mm +platform/darwin/src/MGLOpenGLStyleLayer_Private.h +platform/darwin/src/MGLRasterStyleLayer.h +platform/darwin/src/MGLRasterStyleLayer.mm +platform/darwin/src/MGLRasterStyleLayer_Private.h +platform/darwin/src/MGLStyleLayer.h +platform/darwin/src/MGLStyleLayer.mm +platform/darwin/src/MGLStyleLayerManager.h +platform/darwin/src/MGLStyleLayerManager.mm +platform/darwin/src/MGLStyleLayer_Private.h +platform/darwin/src/MGLSymbolStyleLayer.h +platform/darwin/src/MGLSymbolStyleLayer.mm +platform/darwin/src/MGLSymbolStyleLayer_Private.h +platform/darwin/src/MGLVectorStyleLayer.h +platform/darwin/src/MGLVectorStyleLayer.m + +# SDK/Foundation/Styling/Sources +platform/darwin/src/MGLComputedShapeSource.h +platform/darwin/src/MGLComputedShapeSource.mm +platform/darwin/src/MGLComputedShapeSource_Private.h +platform/darwin/src/MGLImageSource.h +platform/darwin/src/MGLImageSource.mm +platform/darwin/src/MGLRasterDEMSource.h +platform/darwin/src/MGLRasterDEMSource.mm +platform/darwin/src/MGLRasterTileSource.h +platform/darwin/src/MGLRasterTileSource.mm +platform/darwin/src/MGLRasterTileSource_Private.h +platform/darwin/src/MGLShapeSource.h +platform/darwin/src/MGLShapeSource.mm +platform/darwin/src/MGLShapeSource_Private.h +platform/darwin/src/MGLSource.h +platform/darwin/src/MGLSource.mm +platform/darwin/src/MGLSource_Private.h +platform/darwin/src/MGLTileSource.h +platform/darwin/src/MGLTileSource.mm +platform/darwin/src/MGLTileSource_Private.h +platform/darwin/src/MGLVectorTileSource.h +platform/darwin/src/MGLVectorTileSource.mm +platform/darwin/src/MGLVectorTileSource_Private.h + +# SDK/Kit +platform/ios/src/MGLCameraChangeReason.h +platform/ios/src/MGLMapAccessibilityElement.h +platform/ios/src/MGLMapAccessibilityElement.mm +platform/ios/src/MGLMapView+IBAdditions.h +platform/ios/src/MGLMapView.h +platform/ios/src/MGLMapView.mm +platform/ios/src/MGLMapViewDelegate.h +platform/ios/src/MGLMapView_Private.h + +# SDK/Kit/Annotations +platform/ios/src/MGLAnnotationContainerView.h +platform/ios/src/MGLAnnotationContainerView.m +platform/ios/src/MGLAnnotationContainerView_Private.h +platform/ios/src/MGLAnnotationImage.h +platform/ios/src/MGLAnnotationImage.m +platform/ios/src/MGLAnnotationImage_Private.h +platform/ios/src/MGLAnnotationView.h +platform/ios/src/MGLAnnotationView.mm +platform/ios/src/MGLAnnotationView_Private.h +platform/ios/src/MGLCalloutView.h +platform/ios/src/MGLCompactCalloutView.h +platform/ios/src/MGLCompactCalloutView.m +platform/ios/src/MGLFaux3DUserLocationAnnotationView.h +platform/ios/src/MGLFaux3DUserLocationAnnotationView.m +platform/ios/src/MGLUserLocation.h +platform/ios/src/MGLUserLocation.m +platform/ios/src/MGLUserLocationAnnotationView.h +platform/ios/src/MGLUserLocationAnnotationView.m +platform/ios/src/MGLUserLocationAnnotationView_Private.h +platform/ios/src/MGLUserLocationHeadingArrowLayer.h +platform/ios/src/MGLUserLocationHeadingArrowLayer.m +platform/ios/src/MGLUserLocationHeadingBeamLayer.h +platform/ios/src/MGLUserLocationHeadingBeamLayer.m +platform/ios/src/MGLUserLocationHeadingIndicator.h +platform/ios/src/MGLUserLocation_Private.h + +# SDK/Kit/Categories +platform/darwin/src/NSCoder+MGLAdditions.h +platform/darwin/src/NSCoder+MGLAdditions.mm +platform/ios/src/NSOrthography+MGLAdditions.h +platform/ios/src/NSOrthography+MGLAdditions.m +platform/ios/src/UIColor+MGLAdditions.h +platform/ios/src/UIColor+MGLAdditions.mm +platform/ios/src/UIDevice+MGLAdditions.h +platform/ios/src/UIDevice+MGLAdditions.m +platform/ios/src/UIImage+MGLAdditions.h +platform/ios/src/UIImage+MGLAdditions.mm +platform/ios/src/UIViewController+MGLAdditions.h +platform/ios/src/UIViewController+MGLAdditions.m + +# SDK/Kit/SMCalloutView +platform/ios/vendor/SMCalloutView/SMCalloutView.h +platform/ios/vendor/SMCalloutView/SMCalloutView.m + +# SDK/Kit/Telemetry +platform/ios/src/MGLTelemetryConfig.h +platform/ios/src/MGLTelemetryConfig.m + +# SDK/Kit/Telemetry/Development +platform/ios/src/MGLSDKUpdateChecker.h +platform/ios/src/MGLSDKUpdateChecker.mm + +# SDK/Kit/Telemetry/Runtime +platform/ios/src/MGLMapboxEvents.h +platform/ios/src/MGLMapboxEvents.m +platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/CLLocation+MMEMobileEvents.m +platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMEAPIClient.m +platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMECategoryLoader.m +platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMECommonEventData.m +platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMEConfigurator.m +platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMEConstants.m +platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMEDependencyManager.m +platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMEDispatchManager.m +platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMEEvent.m +platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMEEventLogReportViewController.m +platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMEEventLogger.m +platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMEEventsConfiguration.m +platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMEEventsManager.m +platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMEHashProvider.m +platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMELocationManager.m +platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMEMetrics.m +platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMEMetricsManager.m +platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMENSDateWrapper.m +platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMENSURLSessionWrapper.m +platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMETimerManager.m +platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMETrustKitProvider.m +platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMETypes.m +platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMEUIApplicationWrapper.m +platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMEUINavigation.m +platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMEUniqueIdentifier.m +platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/NSData+MMEGZIP.m + +# SDK/Kit/Telemetry/Runtime/Reachability +platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/Reachability/MMEReachability.m + +# SDK/Kit/Telemetry/Runtime/TrustKit +platform/ios/vendor/mapbox-events-ios/vendor/TrustKit/TSKPinningValidator.m +platform/ios/vendor/mapbox-events-ios/vendor/TrustKit/TSKPinningValidatorResult.m +platform/ios/vendor/mapbox-events-ios/vendor/TrustKit/TSKTrustKitConfig.m +platform/ios/vendor/mapbox-events-ios/vendor/TrustKit/TrustKit.m +platform/ios/vendor/mapbox-events-ios/vendor/TrustKit/configuration_utils.m +platform/ios/vendor/mapbox-events-ios/vendor/TrustKit/parse_configuration.m + +# SDK/Kit/Telemetry/Runtime/TrustKit/Pinning +platform/ios/vendor/mapbox-events-ios/vendor/TrustKit/Pinning/TSKSPKIHashCache.m +platform/ios/vendor/mapbox-events-ios/vendor/TrustKit/Pinning/ssl_pin_verifier.m + +# SDK/Kit/Telemetry/Runtime/TrustKit/Reporting +platform/ios/vendor/mapbox-events-ios/vendor/TrustKit/Reporting/TSKBackgroundReporter.m +platform/ios/vendor/mapbox-events-ios/vendor/TrustKit/Reporting/TSKPinFailureReport.m +platform/ios/vendor/mapbox-events-ios/vendor/TrustKit/Reporting/TSKReportsRateLimiter.m +platform/ios/vendor/mapbox-events-ios/vendor/TrustKit/Reporting/reporting_utils.m +platform/ios/vendor/mapbox-events-ios/vendor/TrustKit/Reporting/vendor_identifier.m + +# SDK/Kit/Views +platform/ios/src/MGLScaleBar.h +platform/ios/src/MGLScaleBar.mm + From 31b0ce62c6be4fcb8d3d4bb0e8986cc9582a9966 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Mon, 24 Sep 2018 23:27:53 -0400 Subject: [PATCH 04/29] [ios] Updated Mapbox.h --- platform/ios/core-files.txt | 2 +- platform/ios/src/Mapbox.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/ios/core-files.txt b/platform/ios/core-files.txt index 611245b2b30..70afdd08a65 100644 --- a/platform/ios/core-files.txt +++ b/platform/ios/core-files.txt @@ -90,10 +90,10 @@ platform/darwin/src/MGLMultiPoint_Private.h platform/darwin/src/MGLOverlay.h platform/darwin/src/MGLPointAnnotation.h platform/darwin/src/MGLPointAnnotation.mm +platform/darwin/src/MGLPointCluster.h platform/darwin/src/MGLPointCollection.h platform/darwin/src/MGLPointCollection.mm platform/darwin/src/MGLPointCollection_Private.h -platform/darwin/src/MGLPointCluster.h platform/darwin/src/MGLPolygon.h platform/darwin/src/MGLPolygon.mm platform/darwin/src/MGLPolygon_Private.h diff --git a/platform/ios/src/Mapbox.h b/platform/ios/src/Mapbox.h index 38da38c47fb..b4684fae03b 100644 --- a/platform/ios/src/Mapbox.h +++ b/platform/ios/src/Mapbox.h @@ -31,6 +31,7 @@ FOUNDATION_EXPORT MGL_EXPORT const unsigned char MapboxVersionString[]; #import "MGLOverlay.h" #import "MGLPointAnnotation.h" #import "MGLPointCollection.h" +#import "MGLPointCluster.h" #import "MGLPolygon.h" #import "MGLPolyline.h" #import "MGLShape.h" From fb69c1fc567a411c9099a9e8a6a0f21bef9e2504 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Tue, 25 Sep 2018 23:50:52 -0400 Subject: [PATCH 05/29] [macos] Updated macos project to reference MGLPointCluster.h --- platform/macos/macos.xcodeproj/project.pbxproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/platform/macos/macos.xcodeproj/project.pbxproj b/platform/macos/macos.xcodeproj/project.pbxproj index 3cd807be7ee..8cc526860e0 100644 --- a/platform/macos/macos.xcodeproj/project.pbxproj +++ b/platform/macos/macos.xcodeproj/project.pbxproj @@ -121,6 +121,7 @@ 96E027311E57C9A7004B8E66 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 96E027331E57C9A7004B8E66 /* Localizable.strings */; }; CA8FBC0D21A4A74300D1203C /* MGLRendererConfigurationTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = CA8FBC0C21A4A74300D1203C /* MGLRendererConfigurationTests.mm */; }; CA9461A620884CCB0015EB12 /* MGLAnnotationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CA9461A520884CCB0015EB12 /* MGLAnnotationTests.m */; }; + CAC13892215B3873009F64B4 /* MGLPointCluster.h in Headers */ = {isa = PBXBuildFile; fileRef = CAC13891215B386D009F64B4 /* MGLPointCluster.h */; settings = {ATTRIBUTES = (Public, ); }; }; DA00FC8A1D5EEAC3009AABC8 /* MGLAttributionInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = DA00FC881D5EEAC3009AABC8 /* MGLAttributionInfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; DA00FC8B1D5EEAC3009AABC8 /* MGLAttributionInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = DA00FC891D5EEAC3009AABC8 /* MGLAttributionInfo.mm */; }; DA0CD58E1CF56F5800A5F5A5 /* MGLFeatureTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = DA0CD58D1CF56F5800A5F5A5 /* MGLFeatureTests.mm */; }; @@ -446,6 +447,7 @@ 96E0273B1E57C9BC004B8E66 /* pt-BR */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "pt-BR"; path = "pt-BR.lproj/Localizable.strings"; sourceTree = ""; }; CA8FBC0C21A4A74300D1203C /* MGLRendererConfigurationTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLRendererConfigurationTests.mm; path = ../../darwin/test/MGLRendererConfigurationTests.mm; sourceTree = ""; }; CA9461A520884CCB0015EB12 /* MGLAnnotationTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MGLAnnotationTests.m; path = test/MGLAnnotationTests.m; sourceTree = SOURCE_ROOT; }; + CAC13891215B386D009F64B4 /* MGLPointCluster.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLPointCluster.h; sourceTree = ""; }; DA00FC881D5EEAC3009AABC8 /* MGLAttributionInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLAttributionInfo.h; sourceTree = ""; }; DA00FC891D5EEAC3009AABC8 /* MGLAttributionInfo.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLAttributionInfo.mm; sourceTree = ""; }; DA0CD58D1CF56F5800A5F5A5 /* MGLFeatureTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLFeatureTests.mm; path = ../../darwin/test/MGLFeatureTests.mm; sourceTree = ""; }; @@ -1024,6 +1026,7 @@ DAD1657D1CF4CECB001FF4B9 /* Geometry */ = { isa = PBXGroup; children = ( + CAC13891215B386D009F64B4 /* MGLPointCluster.h */, DAE6C34B1CC31E0400DB3429 /* MGLAnnotation.h */, DACC22121CF3D3E200D220D9 /* MGLFeature.h */, DACC22171CF3D4F700D220D9 /* MGLFeature_Private.h */, @@ -1360,6 +1363,7 @@ 3537CA741D3F93A600380318 /* MGLStyle_Private.h in Headers */, 0721493F1EE200E900085505 /* MGLImageSource.h in Headers */, DA8F259A1D51CAD00010E6B5 /* MGLSource_Private.h in Headers */, + CAC13892215B3873009F64B4 /* MGLPointCluster.h in Headers */, DA8F25931D51CA750010E6B5 /* MGLSymbolStyleLayer.h in Headers */, DAE6C3B91CC31EF300DB3429 /* MGLOpenGLLayer.h in Headers */, DAF0D80E1DFE0E5D00B28378 /* MGLPointCollection_Private.h in Headers */, From 32332ffca7f4e262716b63d14692bb51ce2bae5d Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Tue, 25 Sep 2018 23:54:49 -0400 Subject: [PATCH 06/29] [macos] Updated core files. --- platform/macos/src/Mapbox.h | 1 + 1 file changed, 1 insertion(+) diff --git a/platform/macos/src/Mapbox.h b/platform/macos/src/Mapbox.h index 88ed0acb7a3..37f8a2cc478 100644 --- a/platform/macos/src/Mapbox.h +++ b/platform/macos/src/Mapbox.h @@ -29,6 +29,7 @@ FOUNDATION_EXPORT MGL_EXPORT const unsigned char MapboxVersionString[]; #import "MGLOverlay.h" #import "MGLPointAnnotation.h" #import "MGLPointCollection.h" +#import "MGLPointCluster.h" #import "MGLPolygon.h" #import "MGLPolyline.h" #import "MGLShape.h" From 423657f9e5a69bf0b04883371248e2279ae44a69 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Wed, 3 Oct 2018 09:58:21 -0400 Subject: [PATCH 07/29] [ios, macos] Updated MGLCluster protocol, create dynamic subclass at runtime for clustered feature --- platform/darwin/src/MGLCluster.h | 18 ++ platform/darwin/src/MGLCluster.m | 132 +++++++++++ platform/darwin/src/MGLCluster_Private.h | 17 ++ platform/darwin/src/MGLFeature.h | 6 - platform/darwin/src/MGLFeature.mm | 64 +---- platform/darwin/src/MGLFeature_Private.h | 4 + platform/darwin/src/MGLPointCluster.h | 15 -- platform/darwin/src/MGLShapeSource.h | 8 +- platform/darwin/src/MGLShapeSource.mm | 24 +- platform/darwin/test/MGLCodingTests.m | 42 ++++ platform/ios/core-files.txt | 4 +- platform/ios/ios.xcodeproj/project.pbxproj | 39 ++- platform/ios/src/Mapbox.h | 2 +- platform/macos/core-files.txt | 224 ++++++++++++++++++ .../macos/macos.xcodeproj/project.pbxproj | 30 ++- platform/macos/src/Mapbox.h | 2 +- 16 files changed, 511 insertions(+), 120 deletions(-) create mode 100644 platform/darwin/src/MGLCluster.h create mode 100644 platform/darwin/src/MGLCluster.m create mode 100644 platform/darwin/src/MGLCluster_Private.h delete mode 100644 platform/darwin/src/MGLPointCluster.h create mode 100644 platform/macos/core-files.txt diff --git a/platform/darwin/src/MGLCluster.h b/platform/darwin/src/MGLCluster.h new file mode 100644 index 00000000000..77c12c000d8 --- /dev/null +++ b/platform/darwin/src/MGLCluster.h @@ -0,0 +1,18 @@ +#import +#import "MGLFoundation.h" +@protocol MGLFeature; + +NS_ASSUME_NONNULL_BEGIN + +FOUNDATION_EXTERN MGL_EXPORT const NSUInteger MGLClusterIdentifierInvalid; + +FOUNDATION_EXPORT BOOL MGLFeatureHasClusterAttribute(id feature); + +MGL_EXPORT +@protocol MGLCluster +@property (nonatomic, readonly) NSUInteger clusterIdentifier; +@property (nonatomic, readonly) NSUInteger clusterPointCount; +@property (nonatomic, readonly) NSString *clusterPointCountAbbreviation; +@end + +NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MGLCluster.m b/platform/darwin/src/MGLCluster.m new file mode 100644 index 00000000000..87c9ad4498f --- /dev/null +++ b/platform/darwin/src/MGLCluster.m @@ -0,0 +1,132 @@ +#import "MGLCluster_Private.h" +#import "MGLFeature.h" +#import + +NSString * const MGLClusterBoolKey = @"cluster"; +NSString * const MGLClusterIdentifierKey = @"cluster_id"; +NSString * const MGLClusterCountKey = @"point_count"; +NSString * const MGLClusterCountAbbreviationKey = @"point_count_abbreviated"; + +const NSUInteger MGLClusterIdentifierInvalid = NSUIntegerMax; + +BOOL MGLFeatureHasClusterAttribute(id feature) { + NSNumber *isCluster = MGL_OBJC_DYNAMIC_CAST([feature attributeForKey:MGLClusterBoolKey], NSNumber); + return [isCluster boolValue]; +} + +NSString *MGLClusterSubclassNameForFeature(id feature) { + NSString *className = NSStringFromClass([feature class]); + NSString *subclassName = [className stringByAppendingString:@"_Cluster"]; + return subclassName; +} + +static NSUInteger MGLClusterIdentifierIMP(id self, SEL _cmd) { + + id feature = MGL_OBJC_AS_PROTOCOL_OR_NIL(self, MGLFeature); + + NSNumber *clusterNumber = MGL_OBJC_DYNAMIC_CAST([feature attributeForKey:MGLClusterIdentifierKey], NSNumber); + NSAssert(clusterNumber, @"Clusters should have a cluster_id"); + + if (!clusterNumber) { + return MGLClusterIdentifierInvalid; + } + + NSUInteger identifier = [clusterNumber unsignedIntegerValue]; + NSAssert(identifier <= UINT32_MAX, @"Cluster identifiers are 32bit"); + + return identifier; +} + +static NSUInteger MGLClusterPointCountIMP(id self, SEL _cmd) { + id feature = MGL_OBJC_AS_PROTOCOL_OR_NIL(self, MGLFeature); + + NSNumber *count = MGL_OBJC_DYNAMIC_CAST([feature attributeForKey:MGLClusterCountKey], NSNumber); + NSAssert(count, @"Clusters should have a point_count"); + + return [count unsignedIntegerValue]; +} + +static NSString *MGLClusterPointCountAbbreviationIMP(id self, SEL _cmd) { + id feature = MGL_OBJC_AS_PROTOCOL_OR_NIL(self, MGLFeature); + + NSString *abbreviation = MGL_OBJC_DYNAMIC_CAST([feature attributeForKey:MGLClusterCountAbbreviationKey], NSString); + NSAssert(abbreviation, @"Clusters should have a point_count_abbreviated"); + + if (!abbreviation) { + return @"0"; + } + + return abbreviation; +} + +static IMP MGLFeatureClusterIMPFromSelector(SEL selector) { + if (selector == NSSelectorFromString(@"clusterIdentifier")) { + return (IMP)MGLClusterIdentifierIMP; + } + else if (selector == NSSelectorFromString(@"clusterPointCount")) { + return (IMP)MGLClusterPointCountIMP; + } + else if (selector == NSSelectorFromString(@"clusterPointCountAbbreviation")) { + return (IMP)MGLClusterPointCountAbbreviationIMP; + } + + assert(0); + return NULL; +} + +id MGLConvertFeatureToClusterSubclass(id feature) { + + Protocol *clusterProtocol = @protocol(MGLCluster); + + if ([feature conformsToProtocol:clusterProtocol]) { + return (id)feature; + } + + if (!MGLFeatureHasClusterAttribute(feature)) { + return nil; + } + + Class currentClass = [feature class]; + + NSString *subclassName = MGLClusterSubclassNameForFeature(feature); + + // Does this new subclass already exist? + Class clusterSubclass = NSClassFromString(subclassName); + + if (!clusterSubclass) { + clusterSubclass = objc_allocateClassPair(currentClass, subclassName.UTF8String, 0); + + // Add protocol to this new subclass + class_addProtocol(clusterSubclass, clusterProtocol); + + // Install protocol methods + unsigned int count = 0; + struct objc_method_description *methodDescriptionList = protocol_copyMethodDescriptionList(clusterProtocol, YES, YES, &count); + + for (unsigned int index = 0; index < count; index++) { + struct objc_method_description desc = methodDescriptionList[index]; + + IMP imp = MGLFeatureClusterIMPFromSelector(desc.name); + + if (imp) { + class_addMethod(clusterSubclass, desc.name, imp, desc.types); + } + } + + free(methodDescriptionList); methodDescriptionList = NULL; + + objc_registerClassPair(clusterSubclass); + } + + // Now change the class of the feature + object_setClass(feature, clusterSubclass); + assert([feature conformsToProtocol:clusterProtocol]); + + id cluster = (id)feature; + + assert([cluster respondsToSelector:@selector(clusterIdentifier)]); + assert([cluster respondsToSelector:@selector(clusterPointCount)]); + assert([cluster respondsToSelector:@selector(clusterPointCountAbbreviation)]); + + return cluster; +} diff --git a/platform/darwin/src/MGLCluster_Private.h b/platform/darwin/src/MGLCluster_Private.h new file mode 100644 index 00000000000..36dd990d135 --- /dev/null +++ b/platform/darwin/src/MGLCluster_Private.h @@ -0,0 +1,17 @@ +#import +#import "MGLFoundation.h" +#import "MGLCluster.h" + +@protocol MGLFeature; + +FOUNDATION_EXPORT NSString * const MGLClusterBoolKey; +FOUNDATION_EXPORT NSString * const MGLClusterIdentifierKey; +FOUNDATION_EXPORT NSString * const MGLClusterCountKey; +FOUNDATION_EXPORT NSString * const MGLClusterCountAbbreviationKey; + +FOUNDATION_EXPORT MGL_EXPORT +NSString *MGLClusterSubclassNameForFeature(id feature); + +FOUNDATION_EXPORT +id MGLConvertFeatureToClusterSubclass(id feature); + diff --git a/platform/darwin/src/MGLFeature.h b/platform/darwin/src/MGLFeature.h index 87781816f03..8886c8df559 100644 --- a/platform/darwin/src/MGLFeature.h +++ b/platform/darwin/src/MGLFeature.h @@ -6,7 +6,6 @@ #import "MGLPointAnnotation.h" #import "MGLPointCollection.h" #import "MGLShapeCollection.h" -#import "MGLPointCluster.h" NS_ASSUME_NONNULL_BEGIN @@ -191,9 +190,6 @@ MGL_EXPORT */ MGL_EXPORT @interface MGLPointFeature : MGLPointAnnotation - -// TODO: doc -- (id)cluster; @end /** @@ -285,6 +281,4 @@ MGL_EXPORT @end - - NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MGLFeature.mm b/platform/darwin/src/MGLFeature.mm index 86ab2e66868..e579a87eb03 100644 --- a/platform/darwin/src/MGLFeature.mm +++ b/platform/darwin/src/MGLFeature.mm @@ -5,6 +5,7 @@ #import "MGLPolygon.h" #import "MGLValueEvaluator.h" +#import "MGLCluster_Private.h" #import "MGLShape_Private.h" #import "MGLPointCollection_Private.h" #import "MGLPolyline_Private.h" @@ -55,14 +56,7 @@ - (NSString *)description @end -NSString * const MGLPointClusterBoolKey = @"cluster"; -NSString * const MGLPointClusterIdKey = @"cluster_id"; -NSString * const MGLPointClusterCountKey = @"point_count"; -NSString * const MGLPointClusterCountAbbreviationKey = @"cluster_abbreviated"; - -// TODO: privately conform to MGLPointCluster, so we can return the same object OR create a *new* -// object, or even have a subclass of MGLPointFeature? -@interface MGLPointFeature () +@interface MGLPointFeature () @end @implementation MGLPointFeature @@ -97,56 +91,6 @@ - (NSString *)description self.attributes.count ? self.attributes : @"none"]; } -- (id)cluster { - return self.cluster ? self : nil; -} - -#pragma mark - MGLPointCluster - -- (BOOL)isCluster { - NSNumber *isCluster = MGL_OBJC_DYNAMIC_CAST(self.attributes[MGLPointClusterBoolKey], NSNumber); - return [isCluster boolValue]; -} - -- (uint32_t)clusterId { - NSNumber *clusterNumber = MGL_OBJC_DYNAMIC_CAST(self.attributes[MGLPointClusterIdKey], NSNumber); - - NSAssert(clusterNumber, @"Clusters should have a cluster_id"); - if (!clusterNumber) { - return -1; - } - - NSUInteger clusterId = [clusterNumber unsignedIntegerValue]; - - NSAssert(clusterId < (1UL << 32), @"Cluster IDs are 32bit"); - NSAssert([self.identifier isKindOfClass:[NSNumber class]], @"The identifier should be an NSNumber"); - NSAssert(clusterId == [self.identifier unsignedIntegerValue], @"The cluster id should match the feature's identifier."); - - return (uint32_t)clusterId; -} - -- (NSUInteger)pointCount { - NSNumber *pointCount = MGL_OBJC_DYNAMIC_CAST(self.attributes[MGLPointClusterCountKey], NSNumber); - - NSAssert(pointCount, @"Clusters should have a point_count"); - if (!pointCount) { - return -1; - } - - return [pointCount unsignedIntegerValue]; -} - -- (NSString*)clusterAbbreviated { - NSString *abbreviation = MGL_OBJC_DYNAMIC_CAST(self.attributes[MGLPointClusterCountAbbreviationKey], NSString); - - NSAssert(abbreviation, @"Clusters should have a cluster_abbreviated"); - if (!abbreviation) { - return @""; - } - - return abbreviation; -} - @end @interface MGLPolylineFeature () @@ -507,6 +451,10 @@ static CLLocationCoordinate2D toLocationCoordinate2D(const mbgl::Point &point } shape.attributes = attributes; + if (MGLFeatureHasClusterAttribute(shape)) { + MGLConvertFeatureToClusterSubclass(shape); + } + return shape; } diff --git a/platform/darwin/src/MGLFeature_Private.h b/platform/darwin/src/MGLFeature_Private.h index 9fb1f918201..81299567dee 100644 --- a/platform/darwin/src/MGLFeature_Private.h +++ b/platform/darwin/src/MGLFeature_Private.h @@ -46,6 +46,10 @@ NS_ASSUME_NONNULL_END NSSet *identifierClasses = [NSSet setWithArray:@[[NSString class], [NSNumber class]]]; \ identifier = [decoder decodeObjectOfClasses:identifierClasses forKey:@"identifier"]; \ _attributes = [decoder decodeObjectOfClass:[NSDictionary class] forKey:@"attributes"]; \ + /* If this feature is a cluster, then change the class */ \ + if (MGLFeatureHasClusterAttribute(self)) { \ + MGLConvertFeatureToClusterSubclass(self); \ + } \ } \ return self; \ } diff --git a/platform/darwin/src/MGLPointCluster.h b/platform/darwin/src/MGLPointCluster.h deleted file mode 100644 index af48203ecc1..00000000000 --- a/platform/darwin/src/MGLPointCluster.h +++ /dev/null @@ -1,15 +0,0 @@ -#import -#import "MGLFoundation.h" - -NS_ASSUME_NONNULL_BEGIN - -MGL_EXPORT -// TODO: Should this be a MGLPointClusterFeature? Subclass of MGLPointFeature? -@protocol MGLPointCluster -@property (nonatomic, readonly, getter=isCluster) BOOL cluster; // Keep so we match cluster def? Always YES. -@property (nonatomic, readonly) uint32_t clusterId; -@property (nonatomic, readonly) NSUInteger pointCount; -@property (nonatomic, readonly) NSString *clusterAbbreviated; -@end - -NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MGLShapeSource.h b/platform/darwin/src/MGLShapeSource.h index 4b75e3bd163..3032a4b195a 100644 --- a/platform/darwin/src/MGLShapeSource.h +++ b/platform/darwin/src/MGLShapeSource.h @@ -5,7 +5,7 @@ NS_ASSUME_NONNULL_BEGIN @protocol MGLFeature; -@protocol MGLPointCluster; +@protocol MGLCluster; @class MGLPointFeature; @class MGLShape; @@ -324,9 +324,9 @@ MGL_EXPORT - (NSArray> *)featuresMatchingPredicate:(nullable NSPredicate *)predicate; // TODO: doc -- (NSArray> *)leavesOfCluster:(id)cluster offset:(uint32_t)offset limit:(uint32_t)limit; -- (NSArray> *)childrenOfCluster:(id)cluster; -- (double)zoomLevelForExpandingCluster:(id)cluster; +- (NSArray> *)leavesOfCluster:(id)cluster offset:(uint32_t)offset limit:(uint32_t)limit; +- (NSArray> *)childrenOfCluster:(id)cluster; +- (double)zoomLevelForExpandingCluster:(id)cluster; @end NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MGLShapeSource.mm b/platform/darwin/src/MGLShapeSource.mm index 06c63183393..a07435f6d45 100644 --- a/platform/darwin/src/MGLShapeSource.mm +++ b/platform/darwin/src/MGLShapeSource.mm @@ -5,6 +5,7 @@ #import "MGLSource_Private.h" #import "MGLFeature_Private.h" #import "MGLShape_Private.h" +#import "MGLCluster_Private.h" #import "NSPredicate+MGLPrivateAdditions.h" #import "NSURL+MGLAdditions.h" @@ -184,52 +185,55 @@ - (NSString *)description { return MGLFeaturesFromMBGLFeatures(features); } -#pragma mark - MGLPointCluster management +#pragma mark - MGLCluster management // TODO: doc // For clustered sources, fetches the original points that belong to the cluster (as an array of GeoJSON features). // clusterId(number)The value of the cluster's cluster_id property. // limit(number)The maximum number of features to return. // offset(number)The number of features to skip (e.g. for pagination). -- (NSArray> *)leavesOfCluster:(id)cluster offset:(uint32_t)offset limit:(uint32_t)limit { +- (NSArray> *)leavesOfCluster:(id)cluster offset:(uint32_t)offset limit:(uint32_t)limit { if(!self.rawSource) { return nil; } - std::vector leaves = self.rawSource->getLeaves(cluster.clusterId, limit, offset); + std::vector leaves = self.rawSource->getLeaves((uint32_t)cluster.clusterIdentifier, limit, offset); return MGLFeaturesFromMBGLFeatures(leaves); } // TODO: doc // For clustered sources, fetches the children of the given cluster on the next zoom level (as an array of GeoJSON features). -- (NSArray> *)childrenOfCluster:(id)cluster { +- (NSArray> *)childrenOfCluster:(id)cluster { if(!self.rawSource) { return nil; } - std::vector children = self.rawSource->getChildren(cluster.clusterId); + std::vector children = self.rawSource->getChildren((uint32_t)cluster.clusterIdentifier); return MGLFeaturesFromMBGLFeatures(children); } // For clustered sources, fetches the zoom at which the given cluster expands. -- (double)zoomLevelForExpandingCluster:(id)cluster { +- (double)zoomLevelForExpandingCluster:(id)cluster { if(!self.rawSource) { return -1.0; } - uint8_t zoom = self.rawSource->getClusterExpansionZoom(cluster.clusterId); + uint8_t zoom = self.rawSource->getClusterExpansionZoom((uint32_t)cluster.clusterIdentifier); return static_cast(zoom); } - (void)debugRecursiveLogForFeature:(id )feature indent:(NSInteger)indent { - MGLPointFeature *pointFeature = MGL_OBJC_DYNAMIC_CAST(feature, MGLPointFeature); - id cluster = [pointFeature cluster]; + id cluster = nil; + + if ([feature conformsToProtocol:@protocol(MGLCluster)]) { + cluster = (id)feature; + } if (cluster) { double zoom = [self zoomLevelForExpandingCluster:cluster]; - NSString *log = [NSString stringWithFormat:@"Cluster %d [count=%ld, zoom=%0.1g]", cluster.clusterId, cluster.pointCount, zoom]; + NSString *log = [NSString stringWithFormat:@"Cluster %ld [count=%ld, zoom=%0.1g]", cluster.clusterIdentifier, cluster.clusterPointCount, zoom]; printf("%*s%s\n", (int)indent, "", log.UTF8String); diff --git a/platform/darwin/test/MGLCodingTests.m b/platform/darwin/test/MGLCodingTests.m index ac61672b760..d1ea7f65bd9 100644 --- a/platform/darwin/test/MGLCodingTests.m +++ b/platform/darwin/test/MGLCodingTests.m @@ -1,6 +1,8 @@ #import #import +#import "MGLCluster_Private.h" + #if TARGET_OS_IPHONE #import "MGLUserLocation_Private.h" #endif @@ -41,6 +43,46 @@ - (void)testPointFeature { XCTAssertEqualObjects(pointFeature, unarchivedPointFeature); } +- (void)testPointFeatureCluster { + MGLPointFeature *pointFeature = [[MGLPointFeature alloc] init]; + pointFeature.title = @"title"; + pointFeature.subtitle = @"subtitle"; + pointFeature.identifier = @(123); + pointFeature.attributes = @{ + @"cluster" : @(YES), + @"cluster_id" : @(456), + @"point_count" : @(2), + @"point_count_abbreviated" : @"2" + }; + + XCTAssert([pointFeature isMemberOfClass:[MGLPointFeature class]], @""); + + NSString *filePath = [self temporaryFilePathForClass:MGLPointFeature.class]; + [NSKeyedArchiver archiveRootObject:pointFeature toFile:filePath]; + MGLPointFeature *unarchivedPointFeature = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath]; + + XCTAssertEqualObjects(pointFeature, unarchivedPointFeature); + + // Unarchive process should convert to a cluster + NSString *subclassName = MGLClusterSubclassNameForFeature(pointFeature); + XCTAssert([unarchivedPointFeature isMemberOfClass:NSClassFromString(subclassName)]); + + id cluster = MGL_OBJC_AS_PROTOCOL_OR_NIL(unarchivedPointFeature, MGLCluster); + + XCTAssert(cluster); + XCTAssert(cluster.clusterIdentifier == 456); + XCTAssert(cluster.clusterPointCount == 2); + XCTAssertEqualObjects(cluster.clusterPointCountAbbreviation, @"2"); + + // Archiving shouldn't affect + [NSKeyedArchiver archiveRootObject:unarchivedPointFeature toFile:filePath]; + MGLPointFeature *unarchivedPointFeature2 = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath]; + + XCTAssert([unarchivedPointFeature2 isMemberOfClass:NSClassFromString(@"MGLPointFeature_Cluster")]); + XCTAssertEqualObjects(pointFeature, unarchivedPointFeature2); +} + + - (void)testPolyline { CLLocationCoordinate2D coordinates[] = { CLLocationCoordinate2DMake(0.129631234123, 1.7812739312551), diff --git a/platform/ios/core-files.txt b/platform/ios/core-files.txt index 70afdd08a65..4a924f2fb46 100644 --- a/platform/ios/core-files.txt +++ b/platform/ios/core-files.txt @@ -78,6 +78,9 @@ platform/darwin/src/MGLDistanceFormatter.m # SDK/Foundation/Geometry platform/darwin/src/MGLAnnotation.h +platform/darwin/src/MGLCluster.h +platform/darwin/src/MGLCluster.m +platform/darwin/src/MGLCluster_Private.h platform/darwin/src/MGLFeature.h platform/darwin/src/MGLFeature.mm platform/darwin/src/MGLFeature_Private.h @@ -90,7 +93,6 @@ platform/darwin/src/MGLMultiPoint_Private.h platform/darwin/src/MGLOverlay.h platform/darwin/src/MGLPointAnnotation.h platform/darwin/src/MGLPointAnnotation.mm -platform/darwin/src/MGLPointCluster.h platform/darwin/src/MGLPointCollection.h platform/darwin/src/MGLPointCollection.mm platform/darwin/src/MGLPointCollection_Private.h diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj index fb1598ba80f..94f14ab9079 100644 --- a/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/ios.xcodeproj/project.pbxproj @@ -474,8 +474,8 @@ CA0C27942076CA19001CE5B7 /* MGLMapViewIntegrationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CA0C27932076CA19001CE5B7 /* MGLMapViewIntegrationTest.m */; }; CA1B4A512099FB2200EDD491 /* MGLMapSnapshotterTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CA1B4A502099FB2200EDD491 /* MGLMapSnapshotterTest.m */; }; CA34C9C3207FD272005C1A06 /* MGLCameraTransitionTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = CA34C9C2207FD272005C1A06 /* MGLCameraTransitionTests.mm */; }; - CA42323B2159242400BB7C18 /* MGLPointCluster.h in Headers */ = {isa = PBXBuildFile; fileRef = CA42323A2159242400BB7C18 /* MGLPointCluster.h */; settings = {ATTRIBUTES = (Public, ); }; }; - CA42323C2159242400BB7C18 /* MGLPointCluster.h in Headers */ = {isa = PBXBuildFile; fileRef = CA42323A2159242400BB7C18 /* MGLPointCluster.h */; settings = {ATTRIBUTES = (Public, ); }; }; + CA42323B2159242400BB7C18 /* MGLCluster.h in Headers */ = {isa = PBXBuildFile; fileRef = CA42323A2159242400BB7C18 /* MGLCluster.h */; settings = {ATTRIBUTES = (Public, ); }; }; + CA42323C2159242400BB7C18 /* MGLCluster.h in Headers */ = {isa = PBXBuildFile; fileRef = CA42323A2159242400BB7C18 /* MGLCluster.h */; settings = {ATTRIBUTES = (Public, ); }; }; CA4EB8C720863487006AB465 /* MGLStyleLayerIntegrationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CA4EB8C620863487006AB465 /* MGLStyleLayerIntegrationTests.m */; }; CA55CD41202C16AA00CE7095 /* MGLCameraChangeReason.h in Headers */ = {isa = PBXBuildFile; fileRef = CA55CD3E202C16AA00CE7095 /* MGLCameraChangeReason.h */; settings = {ATTRIBUTES = (Public, ); }; }; CA55CD42202C16AA00CE7095 /* MGLCameraChangeReason.h in Headers */ = {isa = PBXBuildFile; fileRef = CA55CD3E202C16AA00CE7095 /* MGLCameraChangeReason.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -485,6 +485,10 @@ CAA69DA4206DCD0E007279CD /* Mapbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA4A26961CB6E795000B7809 /* Mapbox.framework */; }; CAA69DA5206DCD0E007279CD /* Mapbox.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = DA4A26961CB6E795000B7809 /* Mapbox.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; CABE5DAD2072FAB40003AF3C /* Mapbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA8847D21CBAF91600AB86E3 /* Mapbox.framework */; }; + CAE21180216552AE00429B6F /* MGLCluster.m in Sources */ = {isa = PBXBuildFile; fileRef = CAE2117F216552AE00429B6F /* MGLCluster.m */; }; + CAE21181216552AE00429B6F /* MGLCluster.m in Sources */ = {isa = PBXBuildFile; fileRef = CAE2117F216552AE00429B6F /* MGLCluster.m */; }; + CAE211832165BD0300429B6F /* MGLCluster_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = CAE211822165BD0300429B6F /* MGLCluster_Private.h */; }; + CAE211842165BD0300429B6F /* MGLCluster_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = CAE211822165BD0300429B6F /* MGLCluster_Private.h */; }; CAE7AD5520F46EF5003B6782 /* MGLMapSnapshotterSwiftTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAE7AD5420F46EF5003B6782 /* MGLMapSnapshotterSwiftTests.swift */; }; DA00FC8E1D5EEB0D009AABC8 /* MGLAttributionInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = DA00FC8C1D5EEB0D009AABC8 /* MGLAttributionInfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; DA00FC8F1D5EEB0D009AABC8 /* MGLAttributionInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = DA00FC8C1D5EEB0D009AABC8 /* MGLAttributionInfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -1051,7 +1055,7 @@ 40FDA7691CCAAA6800442548 /* MBXAnnotationView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MBXAnnotationView.h; sourceTree = ""; }; 40FDA76A1CCAAA6800442548 /* MBXAnnotationView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MBXAnnotationView.m; sourceTree = ""; }; 554180411D2E97DE00012372 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; - 556660C91E1BF3A900E2C41B /* MGLFoundation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLFoundation.h; sourceTree = ""; }; + 556660C91E1BF3A900E2C41B /* MGLFoundation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLFoundation.h; sourceTree = ""; wrapsLines = 0; }; 556660D71E1D085500E2C41B /* MGLVersionNumber.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = MGLVersionNumber.m; path = ../../darwin/test/MGLVersionNumber.m; sourceTree = ""; }; 558DE79E1E5615E400C7916D /* MGLFoundation_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLFoundation_Private.h; sourceTree = ""; }; 558DE79F1E5615E400C7916D /* MGLFoundation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLFoundation.mm; sourceTree = ""; }; @@ -1142,13 +1146,15 @@ CA0C27952076CA50001CE5B7 /* MGLMapViewIntegrationTest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLMapViewIntegrationTest.h; sourceTree = ""; }; CA1B4A502099FB2200EDD491 /* MGLMapSnapshotterTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLMapSnapshotterTest.m; sourceTree = ""; }; CA34C9C2207FD272005C1A06 /* MGLCameraTransitionTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLCameraTransitionTests.mm; sourceTree = ""; }; - CA42323A2159242400BB7C18 /* MGLPointCluster.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLPointCluster.h; sourceTree = ""; }; + CA42323A2159242400BB7C18 /* MGLCluster.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLCluster.h; sourceTree = ""; }; CA4EB8C620863487006AB465 /* MGLStyleLayerIntegrationTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLStyleLayerIntegrationTests.m; sourceTree = ""; }; CA55CD3E202C16AA00CE7095 /* MGLCameraChangeReason.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLCameraChangeReason.h; sourceTree = ""; }; CA5E5042209BDC5F001A8A81 /* MGLTestUtility.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = MGLTestUtility.h; path = ../../darwin/test/MGLTestUtility.h; sourceTree = ""; }; CA6914B420E67F50002DB0EE /* MGLAnnotationViewIntegrationTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = MGLAnnotationViewIntegrationTests.m; path = "Annotation Tests/MGLAnnotationViewIntegrationTests.m"; sourceTree = ""; }; CA88DC2F21C85D900059ED5A /* MGLStyleURLIntegrationTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLStyleURLIntegrationTest.m; sourceTree = ""; }; CA8FBC0821A47BB100D1203C /* MGLRendererConfigurationTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLRendererConfigurationTests.mm; path = ../../darwin/test/MGLRendererConfigurationTests.mm; sourceTree = ""; }; + CAE2117F216552AE00429B6F /* MGLCluster.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLCluster.m; sourceTree = ""; wrapsLines = 0; }; + CAE211822165BD0300429B6F /* MGLCluster_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLCluster_Private.h; sourceTree = ""; }; CAE7AD5320F46EF5003B6782 /* integration-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "integration-Bridging-Header.h"; sourceTree = ""; }; CAE7AD5420F46EF5003B6782 /* MGLMapSnapshotterSwiftTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MGLMapSnapshotterSwiftTests.swift; sourceTree = ""; }; DA00FC8C1D5EEB0D009AABC8 /* MGLAttributionInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLAttributionInfo.h; sourceTree = ""; }; @@ -2211,33 +2217,35 @@ isa = PBXGroup; children = ( DA8847E01CBAFA5100AB86E3 /* MGLAnnotation.h */, - DAD165691CF41981001FF4B9 /* MGLFeature.h */, + CAE211822165BD0300429B6F /* MGLCluster_Private.h */, + CA42323A2159242400BB7C18 /* MGLCluster.h */, + CAE2117F216552AE00429B6F /* MGLCluster.m */, DAD1656A1CF41981001FF4B9 /* MGLFeature_Private.h */, + DAD165691CF41981001FF4B9 /* MGLFeature.h */, DAD1656B1CF41981001FF4B9 /* MGLFeature.mm */, - DA8847E11CBAFA5100AB86E3 /* MGLGeometry.h */, DA8848011CBAFA6200AB86E3 /* MGLGeometry_Private.h */, + DA8847E11CBAFA5100AB86E3 /* MGLGeometry.h */, DA8848021CBAFA6200AB86E3 /* MGLGeometry.mm */, - DA8847E31CBAFA5100AB86E3 /* MGLMultiPoint.h */, DA8848041CBAFA6200AB86E3 /* MGLMultiPoint_Private.h */, + DA8847E31CBAFA5100AB86E3 /* MGLMultiPoint.h */, DA8848051CBAFA6200AB86E3 /* MGLMultiPoint.mm */, DA8847E71CBAFA5100AB86E3 /* MGLOverlay.h */, DA8847E81CBAFA5100AB86E3 /* MGLPointAnnotation.h */, DA88480B1CBAFA6200AB86E3 /* MGLPointAnnotation.mm */, - 4049C29B1DB6CD6C00B3F799 /* MGLPointCollection.h */, 4049C2AB1DB6E05500B3F799 /* MGLPointCollection_Private.h */, + 4049C29B1DB6CD6C00B3F799 /* MGLPointCollection.h */, 4049C29C1DB6CD6C00B3F799 /* MGLPointCollection.mm */, - DA8847E91CBAFA5100AB86E3 /* MGLPolygon.h */, 9654C1271FFC1CC000DB6A19 /* MGLPolygon_Private.h */, + DA8847E91CBAFA5100AB86E3 /* MGLPolygon.h */, DA88480C1CBAFA6200AB86E3 /* MGLPolygon.mm */, - DA8847EA1CBAFA5100AB86E3 /* MGLPolyline.h */, 9654C1251FFC1AB900DB6A19 /* MGLPolyline_Private.h */, + DA8847EA1CBAFA5100AB86E3 /* MGLPolyline.h */, DA88480D1CBAFA6200AB86E3 /* MGLPolyline.mm */, - DA8847EB1CBAFA5100AB86E3 /* MGLShape.h */, 40CF6DBA1DAC3C1800A4D18B /* MGLShape_Private.h */, + DA8847EB1CBAFA5100AB86E3 /* MGLShape.h */, DA88480E1CBAFA6200AB86E3 /* MGLShape.mm */, DAD165761CF4CDFF001FF4B9 /* MGLShapeCollection.h */, DAD165771CF4CDFF001FF4B9 /* MGLShapeCollection.mm */, - CA42323A2159242400BB7C18 /* MGLPointCluster.h */, ); name = Geometry; sourceTree = ""; @@ -2356,6 +2364,7 @@ 74CB5EBD219B280400102936 /* MGLFillStyleLayer_Private.h in Headers */, DAF2571B201901E200367EF5 /* MGLHillshadeStyleLayer.h in Headers */, DA35A2BB1CCA9A6900E826B2 /* MGLClockDirectionFormatter.h in Headers */, + CAE211832165BD0300429B6F /* MGLCluster_Private.h in Headers */, 353933FE1D3FB7DD003F57D7 /* MGLSymbolStyleLayer.h in Headers */, DA8848201CBAFA6200AB86E3 /* MGLOfflinePack_Private.h in Headers */, DA00FC8E1D5EEB0D009AABC8 /* MGLAttributionInfo.h in Headers */, @@ -2543,6 +2552,7 @@ 55E5666121C2A2080008B8B5 /* MMEEventsManager.h in Headers */, 55E5666D21C2A2080008B8B5 /* NSData+MMEGZIP.h in Headers */, CA42323B2159242400BB7C18 /* MGLPointCluster.h in Headers */, + CA42323B2159242400BB7C18 /* MGLCluster.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2602,6 +2612,7 @@ DABFB8621CBE99E500D62B32 /* MGLOfflinePack.h in Headers */, 96E516FA20005A3D00A02306 /* MGLUserLocationHeadingArrowLayer.h in Headers */, 96E516E62000560B00A02306 /* MGLOfflineRegion_Private.h in Headers */, + CAE211842165BD0300429B6F /* MGLCluster_Private.h in Headers */, DAD1656D1CF41981001FF4B9 /* MGLFeature.h in Headers */, 96E516E72000560B00A02306 /* MGLOfflineStorage_Private.h in Headers */, DA17BE311CC4BDAA00402C41 /* MGLMapView_Private.h in Headers */, @@ -2660,7 +2671,7 @@ DAC25FCD200FD83F009BE98E /* NSExpression+MGLPrivateAdditions.h in Headers */, 74CB5ED2219B286400102936 /* MGLSymbolStyleLayer_Private.h in Headers */, 354B83971D2E873E005D9406 /* MGLUserLocationAnnotationView.h in Headers */, - CA42323C2159242400BB7C18 /* MGLPointCluster.h in Headers */, + CA42323C2159242400BB7C18 /* MGLCluster.h in Headers */, DAF0D8111DFE0EA000B28378 /* MGLRasterTileSource_Private.h in Headers */, 96E516FF20005A4F00A02306 /* MGLMapboxEvents.h in Headers */, 1F6A82A321360F9D00BA5B41 /* MGLLoggingConfiguration.h in Headers */, @@ -3201,6 +3212,7 @@ DA8848501CBAFB9800AB86E3 /* MGLAnnotationImage.m in Sources */, 40834BF01FE05E1800C1BD0D /* MMELocationManager.m in Sources */, DA8848281CBAFA6200AB86E3 /* MGLShape.mm in Sources */, + CAE21180216552AE00429B6F /* MGLCluster.m in Sources */, DA35A2B31CCA141D00E826B2 /* MGLCompassDirectionFormatter.m in Sources */, DD0902A91DB1929D00C5BDCE /* MGLNetworkConfiguration.m in Sources */, 35D13AB91D3D15E300AFB4E0 /* MGLStyleLayer.mm in Sources */, @@ -3336,6 +3348,7 @@ 40834C041FE05E1800C1BD0D /* MMELocationManager.m in Sources */, DA35A2B41CCA141D00E826B2 /* MGLCompassDirectionFormatter.m in Sources */, 35D13ABA1D3D15E300AFB4E0 /* MGLStyleLayer.mm in Sources */, + CAE21181216552AE00429B6F /* MGLCluster.m in Sources */, 071BBAFF1EE7613E001FB02A /* MGLImageSource.mm in Sources */, DA35A2CC1CCAAAD200E826B2 /* NSValue+MGLAdditions.m in Sources */, 40834C591FE05F7600C1BD0D /* TSKTrustKitConfig.m in Sources */, diff --git a/platform/ios/src/Mapbox.h b/platform/ios/src/Mapbox.h index b4684fae03b..829583be6ac 100644 --- a/platform/ios/src/Mapbox.h +++ b/platform/ios/src/Mapbox.h @@ -14,6 +14,7 @@ FOUNDATION_EXPORT MGL_EXPORT const unsigned char MapboxVersionString[]; #import "MGLAnnotationImage.h" #import "MGLCalloutView.h" #import "MGLClockDirectionFormatter.h" +#import "MGLCluster.h" #import "MGLCompassDirectionFormatter.h" #import "MGLCoordinateFormatter.h" #import "MGLDistanceFormatter.h" @@ -31,7 +32,6 @@ FOUNDATION_EXPORT MGL_EXPORT const unsigned char MapboxVersionString[]; #import "MGLOverlay.h" #import "MGLPointAnnotation.h" #import "MGLPointCollection.h" -#import "MGLPointCluster.h" #import "MGLPolygon.h" #import "MGLPolyline.h" #import "MGLShape.h" diff --git a/platform/macos/core-files.txt b/platform/macos/core-files.txt new file mode 100644 index 00000000000..f75172ae6aa --- /dev/null +++ b/platform/macos/core-files.txt @@ -0,0 +1,224 @@ +# This file is generated. Do not edit. Regenerate this with scripts/generate-cmake-files.js + +# SDK +platform/macos/src/Mapbox.h + +# SDK/Foundation +platform/darwin/src/MGLAccountManager.h +platform/darwin/src/MGLAccountManager.m +platform/darwin/src/MGLAccountManager_Private.h +platform/darwin/src/MGLAttributionInfo.h +platform/darwin/src/MGLAttributionInfo.mm +platform/darwin/src/MGLAttributionInfo_Private.h +platform/darwin/src/MGLFoundation.h +platform/darwin/src/MGLFoundation.mm +platform/darwin/src/MGLFoundation_Private.h +platform/darwin/src/MGLLoggingConfiguration.h +platform/darwin/src/MGLLoggingConfiguration.m +platform/darwin/src/MGLLoggingConfiguration_Private.h +platform/darwin/src/MGLMapCamera.h +platform/darwin/src/MGLMapCamera.mm +platform/darwin/src/MGLMapSnapshotter.h +platform/darwin/src/MGLMapSnapshotter.mm +platform/darwin/src/MGLNetworkConfiguration.h +platform/darwin/src/MGLNetworkConfiguration.m +platform/darwin/src/MGLRendererConfiguration.h +platform/darwin/src/MGLRendererConfiguration.mm +platform/darwin/src/MGLRendererFrontend.h +platform/darwin/src/MGLStyle.h +platform/darwin/src/MGLStyle.mm +platform/darwin/src/MGLStyle_Private.h +platform/darwin/src/MGLTypes.h +platform/darwin/src/MGLTypes.m +platform/darwin/src/MGLValueEvaluator.h + +# SDK/Foundation/Categories +platform/darwin/src/NSArray+MGLAdditions.h +platform/darwin/src/NSArray+MGLAdditions.mm +platform/darwin/src/NSBundle+MGLAdditions.h +platform/darwin/src/NSBundle+MGLAdditions.m +platform/darwin/src/NSCoder+MGLAdditions.h +platform/darwin/src/NSCoder+MGLAdditions.mm +platform/darwin/src/NSComparisonPredicate+MGLAdditions.h +platform/darwin/src/NSComparisonPredicate+MGLAdditions.mm +platform/darwin/src/NSCompoundPredicate+MGLAdditions.h +platform/darwin/src/NSCompoundPredicate+MGLAdditions.mm +platform/darwin/src/NSDate+MGLAdditions.h +platform/darwin/src/NSDate+MGLAdditions.mm +platform/darwin/src/NSDictionary+MGLAdditions.h +platform/darwin/src/NSDictionary+MGLAdditions.mm +platform/darwin/src/NSException+MGLAdditions.h +platform/darwin/src/NSExpression+MGLAdditions.h +platform/darwin/src/NSExpression+MGLAdditions.mm +platform/darwin/src/NSExpression+MGLPrivateAdditions.h +platform/darwin/src/NSPredicate+MGLAdditions.h +platform/darwin/src/NSPredicate+MGLAdditions.mm +platform/darwin/src/NSPredicate+MGLPrivateAdditions.h +platform/darwin/src/NSProcessInfo+MGLAdditions.h +platform/darwin/src/NSProcessInfo+MGLAdditions.m +platform/darwin/src/NSString+MGLAdditions.h +platform/darwin/src/NSString+MGLAdditions.m +platform/darwin/src/NSURL+MGLAdditions.h +platform/darwin/src/NSURL+MGLAdditions.m +platform/darwin/src/NSValue+MGLAdditions.h +platform/darwin/src/NSValue+MGLAdditions.m + +# SDK/Foundation/Formatters +platform/darwin/src/MGLClockDirectionFormatter.h +platform/darwin/src/MGLClockDirectionFormatter.m +platform/darwin/src/MGLCompassDirectionFormatter.h +platform/darwin/src/MGLCompassDirectionFormatter.m +platform/darwin/src/MGLCoordinateFormatter.h +platform/darwin/src/MGLCoordinateFormatter.m +platform/darwin/src/MGLDistanceFormatter.h +platform/darwin/src/MGLDistanceFormatter.m + +# SDK/Foundation/Geometry +platform/darwin/src/MGLAnnotation.h +platform/darwin/src/MGLCluster.h +platform/darwin/src/MGLCluster.m +platform/darwin/src/MGLCluster_Private.h +platform/darwin/src/MGLFeature.h +platform/darwin/src/MGLFeature.mm +platform/darwin/src/MGLFeature_Private.h +platform/darwin/src/MGLGeometry.h +platform/darwin/src/MGLGeometry.mm +platform/darwin/src/MGLGeometry_Private.h +platform/darwin/src/MGLMultiPoint.h +platform/darwin/src/MGLMultiPoint.mm +platform/darwin/src/MGLMultiPoint_Private.h +platform/darwin/src/MGLOverlay.h +platform/darwin/src/MGLPointAnnotation.h +platform/darwin/src/MGLPointAnnotation.mm +platform/darwin/src/MGLPointCollection.h +platform/darwin/src/MGLPointCollection.mm +platform/darwin/src/MGLPointCollection_Private.h +platform/darwin/src/MGLPolygon.h +platform/darwin/src/MGLPolygon.mm +platform/darwin/src/MGLPolygon_Private.h +platform/darwin/src/MGLPolyline.h +platform/darwin/src/MGLPolyline.mm +platform/darwin/src/MGLPolyline_Private.h +platform/darwin/src/MGLShape.h +platform/darwin/src/MGLShape.mm +platform/darwin/src/MGLShapeCollection.h +platform/darwin/src/MGLShapeCollection.mm +platform/darwin/src/MGLShape_Private.h + +# SDK/Foundation/Offline Maps +platform/darwin/src/MGLOfflinePack.h +platform/darwin/src/MGLOfflinePack.mm +platform/darwin/src/MGLOfflinePack_Private.h +platform/darwin/src/MGLOfflineRegion.h +platform/darwin/src/MGLOfflineRegion_Private.h +platform/darwin/src/MGLOfflineStorage.h +platform/darwin/src/MGLOfflineStorage.mm +platform/darwin/src/MGLOfflineStorage_Private.h +platform/darwin/src/MGLShapeOfflineRegion.h +platform/darwin/src/MGLShapeOfflineRegion.mm +platform/darwin/src/MGLShapeOfflineRegion_Private.h +platform/darwin/src/MGLTilePyramidOfflineRegion.h +platform/darwin/src/MGLTilePyramidOfflineRegion.mm +platform/darwin/src/MGLTilePyramidOfflineRegion_Private.h + +# SDK/Foundation/Styling +platform/darwin/src/MGLConversion.h +platform/darwin/src/MGLLight.h +platform/darwin/src/MGLLight.mm +platform/darwin/src/MGLLight_Private.h +platform/darwin/src/MGLStyleValue.h +platform/darwin/src/MGLStyleValue.mm +platform/darwin/src/MGLStyleValue_Private.h + +# SDK/Foundation/Styling/Categories +platform/darwin/src/NSValue+MGLStyleAttributeAdditions.h +platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm + +# SDK/Foundation/Styling/Layers +platform/darwin/src/MGLBackgroundStyleLayer.h +platform/darwin/src/MGLBackgroundStyleLayer.mm +platform/darwin/src/MGLBackgroundStyleLayer_Private.h +platform/darwin/src/MGLCircleStyleLayer.h +platform/darwin/src/MGLCircleStyleLayer.mm +platform/darwin/src/MGLCircleStyleLayer_Private.h +platform/darwin/src/MGLFillExtrusionStyleLayer.h +platform/darwin/src/MGLFillExtrusionStyleLayer.mm +platform/darwin/src/MGLFillExtrusionStyleLayer_Private.h +platform/darwin/src/MGLFillStyleLayer.h +platform/darwin/src/MGLFillStyleLayer.mm +platform/darwin/src/MGLFillStyleLayer_Private.h +platform/darwin/src/MGLForegroundStyleLayer.h +platform/darwin/src/MGLForegroundStyleLayer.mm +platform/darwin/src/MGLHeatmapStyleLayer.h +platform/darwin/src/MGLHeatmapStyleLayer.mm +platform/darwin/src/MGLHeatmapStyleLayer_Private.h +platform/darwin/src/MGLHillshadeStyleLayer.h +platform/darwin/src/MGLHillshadeStyleLayer.mm +platform/darwin/src/MGLHillshadeStyleLayer_Private.h +platform/darwin/src/MGLLineStyleLayer.h +platform/darwin/src/MGLLineStyleLayer.mm +platform/darwin/src/MGLLineStyleLayer_Private.h +platform/darwin/src/MGLOpenGLStyleLayer.h +platform/darwin/src/MGLOpenGLStyleLayer.mm +platform/darwin/src/MGLOpenGLStyleLayer_Private.h +platform/darwin/src/MGLRasterStyleLayer.h +platform/darwin/src/MGLRasterStyleLayer.mm +platform/darwin/src/MGLRasterStyleLayer_Private.h +platform/darwin/src/MGLStyleLayer.h +platform/darwin/src/MGLStyleLayer.mm +platform/darwin/src/MGLStyleLayerManager.h +platform/darwin/src/MGLStyleLayerManager.mm +platform/darwin/src/MGLStyleLayer_Private.h +platform/darwin/src/MGLSymbolStyleLayer.h +platform/darwin/src/MGLSymbolStyleLayer.mm +platform/darwin/src/MGLSymbolStyleLayer_Private.h +platform/darwin/src/MGLVectorStyleLayer.h +platform/darwin/src/MGLVectorStyleLayer.m + +# SDK/Foundation/Styling/Sources +platform/darwin/src/MGLComputedShapeSource.h +platform/darwin/src/MGLComputedShapeSource.mm +platform/darwin/src/MGLComputedShapeSource_Private.h +platform/darwin/src/MGLImageSource.h +platform/darwin/src/MGLImageSource.mm +platform/darwin/src/MGLRasterDEMSource.h +platform/darwin/src/MGLRasterDEMSource.mm +platform/darwin/src/MGLRasterTileSource.h +platform/darwin/src/MGLRasterTileSource.mm +platform/darwin/src/MGLRasterTileSource_Private.h +platform/darwin/src/MGLShapeSource.h +platform/darwin/src/MGLShapeSource.mm +platform/darwin/src/MGLShapeSource_Private.h +platform/darwin/src/MGLSource.h +platform/darwin/src/MGLSource.mm +platform/darwin/src/MGLSource_Private.h +platform/darwin/src/MGLTileSource.h +platform/darwin/src/MGLTileSource.mm +platform/darwin/src/MGLTileSource_Private.h +platform/darwin/src/MGLVectorTileSource.h +platform/darwin/src/MGLVectorTileSource.mm +platform/darwin/src/MGLVectorTileSource_Private.h + +# SDK/Kit +platform/macos/src/MGLAnnotationImage.h +platform/macos/src/MGLAnnotationImage.m +platform/macos/src/MGLAnnotationImage_Private.h +platform/macos/src/MGLAttributionButton.h +platform/macos/src/MGLAttributionButton.mm +platform/macos/src/MGLCompassCell.h +platform/macos/src/MGLCompassCell.m +platform/macos/src/MGLMapView+IBAdditions.h +platform/macos/src/MGLMapView+IBAdditions.mm +platform/macos/src/MGLMapView.h +platform/macos/src/MGLMapView.mm +platform/macos/src/MGLMapViewDelegate.h +platform/macos/src/MGLMapView_Private.h +platform/macos/src/MGLOpenGLLayer.h +platform/macos/src/MGLOpenGLLayer.mm + +# SDK/Kit/Categories +platform/macos/src/NSColor+MGLAdditions.h +platform/macos/src/NSColor+MGLAdditions.mm +platform/macos/src/NSImage+MGLAdditions.h +platform/macos/src/NSImage+MGLAdditions.mm + diff --git a/platform/macos/macos.xcodeproj/project.pbxproj b/platform/macos/macos.xcodeproj/project.pbxproj index 8cc526860e0..d11484386a0 100644 --- a/platform/macos/macos.xcodeproj/project.pbxproj +++ b/platform/macos/macos.xcodeproj/project.pbxproj @@ -120,8 +120,10 @@ 9654C12D1FFC394700DB6A19 /* MGLPolygon_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 9654C12C1FFC394700DB6A19 /* MGLPolygon_Private.h */; }; 96E027311E57C9A7004B8E66 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 96E027331E57C9A7004B8E66 /* Localizable.strings */; }; CA8FBC0D21A4A74300D1203C /* MGLRendererConfigurationTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = CA8FBC0C21A4A74300D1203C /* MGLRendererConfigurationTests.mm */; }; + CA4045C5216720D700B356E1 /* MGLCluster_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = CA4045C2216720D700B356E1 /* MGLCluster_Private.h */; }; + CA4045C6216720D700B356E1 /* MGLCluster.m in Sources */ = {isa = PBXBuildFile; fileRef = CA4045C3216720D700B356E1 /* MGLCluster.m */; }; + CA4045C7216720D700B356E1 /* MGLCluster.h in Headers */ = {isa = PBXBuildFile; fileRef = CA4045C4216720D700B356E1 /* MGLCluster.h */; settings = {ATTRIBUTES = (Public, ); }; }; CA9461A620884CCB0015EB12 /* MGLAnnotationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CA9461A520884CCB0015EB12 /* MGLAnnotationTests.m */; }; - CAC13892215B3873009F64B4 /* MGLPointCluster.h in Headers */ = {isa = PBXBuildFile; fileRef = CAC13891215B386D009F64B4 /* MGLPointCluster.h */; settings = {ATTRIBUTES = (Public, ); }; }; DA00FC8A1D5EEAC3009AABC8 /* MGLAttributionInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = DA00FC881D5EEAC3009AABC8 /* MGLAttributionInfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; DA00FC8B1D5EEAC3009AABC8 /* MGLAttributionInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = DA00FC891D5EEAC3009AABC8 /* MGLAttributionInfo.mm */; }; DA0CD58E1CF56F5800A5F5A5 /* MGLFeatureTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = DA0CD58D1CF56F5800A5F5A5 /* MGLFeatureTests.mm */; }; @@ -446,8 +448,10 @@ 96E0273A1E57C9BB004B8E66 /* vi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = vi; path = vi.lproj/Localizable.strings; sourceTree = ""; }; 96E0273B1E57C9BC004B8E66 /* pt-BR */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "pt-BR"; path = "pt-BR.lproj/Localizable.strings"; sourceTree = ""; }; CA8FBC0C21A4A74300D1203C /* MGLRendererConfigurationTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLRendererConfigurationTests.mm; path = ../../darwin/test/MGLRendererConfigurationTests.mm; sourceTree = ""; }; + CA4045C2216720D700B356E1 /* MGLCluster_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLCluster_Private.h; sourceTree = ""; }; + CA4045C3216720D700B356E1 /* MGLCluster.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLCluster.m; sourceTree = ""; }; + CA4045C4216720D700B356E1 /* MGLCluster.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLCluster.h; sourceTree = ""; }; CA9461A520884CCB0015EB12 /* MGLAnnotationTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MGLAnnotationTests.m; path = test/MGLAnnotationTests.m; sourceTree = SOURCE_ROOT; }; - CAC13891215B386D009F64B4 /* MGLPointCluster.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLPointCluster.h; sourceTree = ""; }; DA00FC881D5EEAC3009AABC8 /* MGLAttributionInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLAttributionInfo.h; sourceTree = ""; }; DA00FC891D5EEAC3009AABC8 /* MGLAttributionInfo.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLAttributionInfo.mm; sourceTree = ""; }; DA0CD58D1CF56F5800A5F5A5 /* MGLFeatureTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLFeatureTests.mm; path = ../../darwin/test/MGLFeatureTests.mm; sourceTree = ""; }; @@ -1026,31 +1030,33 @@ DAD1657D1CF4CECB001FF4B9 /* Geometry */ = { isa = PBXGroup; children = ( - CAC13891215B386D009F64B4 /* MGLPointCluster.h */, DAE6C34B1CC31E0400DB3429 /* MGLAnnotation.h */, - DACC22121CF3D3E200D220D9 /* MGLFeature.h */, + CA4045C2216720D700B356E1 /* MGLCluster_Private.h */, + CA4045C4216720D700B356E1 /* MGLCluster.h */, + CA4045C3216720D700B356E1 /* MGLCluster.m */, DACC22171CF3D4F700D220D9 /* MGLFeature_Private.h */, + DACC22121CF3D3E200D220D9 /* MGLFeature.h */, DACC22131CF3D3E200D220D9 /* MGLFeature.mm */, - DAE6C34C1CC31E0400DB3429 /* MGLGeometry.h */, DAE6C36C1CC31E2A00DB3429 /* MGLGeometry_Private.h */, + DAE6C34C1CC31E0400DB3429 /* MGLGeometry.h */, DAE6C36D1CC31E2A00DB3429 /* MGLGeometry.mm */, - DAE6C34E1CC31E0400DB3429 /* MGLMultiPoint.h */, DAE6C36F1CC31E2A00DB3429 /* MGLMultiPoint_Private.h */, + DAE6C34E1CC31E0400DB3429 /* MGLMultiPoint.h */, DAE6C3701CC31E2A00DB3429 /* MGLMultiPoint.mm */, DAE6C3521CC31E0400DB3429 /* MGLOverlay.h */, DAE6C3531CC31E0400DB3429 /* MGLPointAnnotation.h */, DAE6C3761CC31E2A00DB3429 /* MGLPointAnnotation.mm */, - 4049C2A11DB6CE7800B3F799 /* MGLPointCollection.h */, DAF0D80D1DFE0E5D00B28378 /* MGLPointCollection_Private.h */, + 4049C2A11DB6CE7800B3F799 /* MGLPointCollection.h */, 4049C2A71DB6D09B00B3F799 /* MGLPointCollection.mm */, - DAE6C3541CC31E0400DB3429 /* MGLPolygon.h */, 9654C12C1FFC394700DB6A19 /* MGLPolygon_Private.h */, + DAE6C3541CC31E0400DB3429 /* MGLPolygon.h */, DAE6C3771CC31E2A00DB3429 /* MGLPolygon.mm */, - DAE6C3551CC31E0400DB3429 /* MGLPolyline.h */, 9654C12A1FFC38E000DB6A19 /* MGLPolyline_Private.h */, + DAE6C3551CC31E0400DB3429 /* MGLPolyline.h */, DAE6C3781CC31E2A00DB3429 /* MGLPolyline.mm */, - DAE6C3561CC31E0400DB3429 /* MGLShape.h */, 408AA85A1DAEECF100022900 /* MGLShape_Private.h */, + DAE6C3561CC31E0400DB3429 /* MGLShape.h */, DAE6C3791CC31E2A00DB3429 /* MGLShape.mm */, DAD165721CF4CD7A001FF4B9 /* MGLShapeCollection.h */, DAD165731CF4CD7A001FF4B9 /* MGLShapeCollection.mm */, @@ -1317,6 +1323,7 @@ DA8F25871D51C9E10010E6B5 /* MGLBackgroundStyleLayer.h in Headers */, 4049C2A51DB6CE7F00B3F799 /* MGLPointCollection.h in Headers */, DAE6C3661CC31E0400DB3429 /* MGLShape.h in Headers */, + CA4045C5216720D700B356E1 /* MGLCluster_Private.h in Headers */, DA551B831DB496AC0009AFAF /* MGLTileSource_Private.h in Headers */, DAC25FCA200FD5E2009BE98E /* NSExpression+MGLPrivateAdditions.h in Headers */, DA7262071DEEDD460043BB89 /* MGLOpenGLStyleLayer.h in Headers */, @@ -1351,6 +1358,7 @@ DAE6C3A61CC31E9400DB3429 /* MGLMapViewDelegate.h in Headers */, DAE6C38B1CC31E2A00DB3429 /* MGLOfflinePack_Private.h in Headers */, 558DE7A61E56161C00C7916D /* MGLFoundation_Private.h in Headers */, + CA4045C7216720D700B356E1 /* MGLCluster.h in Headers */, DACC22141CF3D3E200D220D9 /* MGLFeature.h in Headers */, 3538AA231D542685008EC33D /* MGLStyleLayer.h in Headers */, DAE6C35C1CC31E0400DB3429 /* MGLGeometry.h in Headers */, @@ -1363,7 +1371,6 @@ 3537CA741D3F93A600380318 /* MGLStyle_Private.h in Headers */, 0721493F1EE200E900085505 /* MGLImageSource.h in Headers */, DA8F259A1D51CAD00010E6B5 /* MGLSource_Private.h in Headers */, - CAC13892215B3873009F64B4 /* MGLPointCluster.h in Headers */, DA8F25931D51CA750010E6B5 /* MGLSymbolStyleLayer.h in Headers */, DAE6C3B91CC31EF300DB3429 /* MGLOpenGLLayer.h in Headers */, DAF0D80E1DFE0E5D00B28378 /* MGLPointCollection_Private.h in Headers */, @@ -1649,6 +1656,7 @@ DAE6C3911CC31E2A00DB3429 /* MGLPolygon.mm in Sources */, 35C6DF851E214C0400ACA483 /* MGLDistanceFormatter.m in Sources */, DAE6C39B1CC31E2A00DB3429 /* NSProcessInfo+MGLAdditions.m in Sources */, + CA4045C6216720D700B356E1 /* MGLCluster.m in Sources */, DAA998FC1E9F545C002E6EA6 /* MGLFillExtrusionStyleLayer.mm in Sources */, DAE6C38F1CC31E2A00DB3429 /* MGLOfflineStorage.mm in Sources */, DAED38601D62CED700D7640F /* NSURL+MGLAdditions.m in Sources */, diff --git a/platform/macos/src/Mapbox.h b/platform/macos/src/Mapbox.h index 37f8a2cc478..0fd81a4df70 100644 --- a/platform/macos/src/Mapbox.h +++ b/platform/macos/src/Mapbox.h @@ -12,6 +12,7 @@ FOUNDATION_EXPORT MGL_EXPORT const unsigned char MapboxVersionString[]; #import "MGLAnnotation.h" #import "MGLAnnotationImage.h" #import "MGLClockDirectionFormatter.h" +#import "MGLCluster.h" #import "MGLCompassDirectionFormatter.h" #import "MGLCoordinateFormatter.h" #import "MGLDistanceFormatter.h" @@ -29,7 +30,6 @@ FOUNDATION_EXPORT MGL_EXPORT const unsigned char MapboxVersionString[]; #import "MGLOverlay.h" #import "MGLPointAnnotation.h" #import "MGLPointCollection.h" -#import "MGLPointCluster.h" #import "MGLPolygon.h" #import "MGLPolyline.h" #import "MGLShape.h" From 3430c3bf638a45d1fd08cc8731bcfa8e9d04c272 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Fri, 5 Oct 2018 09:08:59 -0400 Subject: [PATCH 08/29] [ios, macos] Added additional tests --- platform/darwin/src/MGLCluster.h | 2 ++ platform/darwin/src/MGLCluster.m | 6 +++--- platform/darwin/src/MGLFeature_Private.h | 1 + platform/darwin/src/MGLShapeSource.h | 2 +- platform/darwin/src/MGLShapeSource.mm | 5 +++-- platform/darwin/src/MGLShapeSource_Private.h | 2 +- platform/darwin/test/MGLCodingTests.m | 2 +- platform/darwin/test/MGLFeatureTests.mm | 20 ++++++++++++++++++++ 8 files changed, 32 insertions(+), 8 deletions(-) diff --git a/platform/darwin/src/MGLCluster.h b/platform/darwin/src/MGLCluster.h index 77c12c000d8..7cf8e0b8210 100644 --- a/platform/darwin/src/MGLCluster.h +++ b/platform/darwin/src/MGLCluster.h @@ -2,6 +2,8 @@ #import "MGLFoundation.h" @protocol MGLFeature; +// TODO: doc + NS_ASSUME_NONNULL_BEGIN FOUNDATION_EXTERN MGL_EXPORT const NSUInteger MGLClusterIdentifierInvalid; diff --git a/platform/darwin/src/MGLCluster.m b/platform/darwin/src/MGLCluster.m index 87c9ad4498f..645e0c8180d 100644 --- a/platform/darwin/src/MGLCluster.m +++ b/platform/darwin/src/MGLCluster.m @@ -22,7 +22,7 @@ BOOL MGLFeatureHasClusterAttribute(id feature) { static NSUInteger MGLClusterIdentifierIMP(id self, SEL _cmd) { - id feature = MGL_OBJC_AS_PROTOCOL_OR_NIL(self, MGLFeature); + id feature = MGL_OBJC_DYNAMIC_CAST_AS_PROTOCOL(self, MGLFeature); NSNumber *clusterNumber = MGL_OBJC_DYNAMIC_CAST([feature attributeForKey:MGLClusterIdentifierKey], NSNumber); NSAssert(clusterNumber, @"Clusters should have a cluster_id"); @@ -38,7 +38,7 @@ static NSUInteger MGLClusterIdentifierIMP(id self, SEL _cmd) { } static NSUInteger MGLClusterPointCountIMP(id self, SEL _cmd) { - id feature = MGL_OBJC_AS_PROTOCOL_OR_NIL(self, MGLFeature); + id feature = MGL_OBJC_DYNAMIC_CAST_AS_PROTOCOL(self, MGLFeature); NSNumber *count = MGL_OBJC_DYNAMIC_CAST([feature attributeForKey:MGLClusterCountKey], NSNumber); NSAssert(count, @"Clusters should have a point_count"); @@ -47,7 +47,7 @@ static NSUInteger MGLClusterPointCountIMP(id self, SEL _cmd) { } static NSString *MGLClusterPointCountAbbreviationIMP(id self, SEL _cmd) { - id feature = MGL_OBJC_AS_PROTOCOL_OR_NIL(self, MGLFeature); + id feature = MGL_OBJC_DYNAMIC_CAST_AS_PROTOCOL(self, MGLFeature); NSString *abbreviation = MGL_OBJC_DYNAMIC_CAST([feature attributeForKey:MGLClusterCountAbbreviationKey], NSString); NSAssert(abbreviation, @"Clusters should have a point_count_abbreviated"); diff --git a/platform/darwin/src/MGLFeature_Private.h b/platform/darwin/src/MGLFeature_Private.h index 81299567dee..b3406fe2b4f 100644 --- a/platform/darwin/src/MGLFeature_Private.h +++ b/platform/darwin/src/MGLFeature_Private.h @@ -18,6 +18,7 @@ NSArray *> *MGLFeaturesFromMBGLFeatures(const std::vector< /** Returns an `MGLFeature` object converted from the given mbgl::Feature */ +MGL_EXPORT id MGLFeatureFromMBGLFeature(const mbgl::Feature &feature); /** diff --git a/platform/darwin/src/MGLShapeSource.h b/platform/darwin/src/MGLShapeSource.h index 3032a4b195a..f7aeac122cf 100644 --- a/platform/darwin/src/MGLShapeSource.h +++ b/platform/darwin/src/MGLShapeSource.h @@ -324,7 +324,7 @@ MGL_EXPORT - (NSArray> *)featuresMatchingPredicate:(nullable NSPredicate *)predicate; // TODO: doc -- (NSArray> *)leavesOfCluster:(id)cluster offset:(uint32_t)offset limit:(uint32_t)limit; +- (NSArray> *)leavesOfCluster:(id)cluster offset:(UInt32)offset limit:(UInt32)limit; - (NSArray> *)childrenOfCluster:(id)cluster; - (double)zoomLevelForExpandingCluster:(id)cluster; @end diff --git a/platform/darwin/src/MGLShapeSource.mm b/platform/darwin/src/MGLShapeSource.mm index a07435f6d45..c6f87d889bd 100644 --- a/platform/darwin/src/MGLShapeSource.mm +++ b/platform/darwin/src/MGLShapeSource.mm @@ -192,7 +192,8 @@ - (NSString *)description { // clusterId(number)The value of the cluster's cluster_id property. // limit(number)The maximum number of features to return. // offset(number)The number of features to skip (e.g. for pagination). -- (NSArray> *)leavesOfCluster:(id)cluster offset:(uint32_t)offset limit:(uint32_t)limit { + +- (NSArray> *)leavesOfCluster:(id)cluster offset:(UInt32)offset limit:(UInt32)limit { if(!self.rawSource) { return nil; } @@ -222,7 +223,7 @@ - (double)zoomLevelForExpandingCluster:(id)cluster { return static_cast(zoom); } -- (void)debugRecursiveLogForFeature:(id )feature indent:(NSInteger)indent { +- (void)debugRecursiveLogForFeature:(id )feature indent:(NSUInteger)indent { id cluster = nil; diff --git a/platform/darwin/src/MGLShapeSource_Private.h b/platform/darwin/src/MGLShapeSource_Private.h index dfe327e46bf..89b2ce1d0cb 100644 --- a/platform/darwin/src/MGLShapeSource_Private.h +++ b/platform/darwin/src/MGLShapeSource_Private.h @@ -13,7 +13,7 @@ MGL_EXPORT mbgl::style::GeoJSONOptions MGLGeoJSONOptionsFromDictionary(NSDictionary *options); @interface MGLShapeSource (Private) -- (void)debugRecursiveLogForFeature:(id )feature indent:(NSInteger)indent; +- (void)debugRecursiveLogForFeature:(id )feature indent:(NSUInteger)indent; @end NS_ASSUME_NONNULL_END diff --git a/platform/darwin/test/MGLCodingTests.m b/platform/darwin/test/MGLCodingTests.m index d1ea7f65bd9..46778f51c91 100644 --- a/platform/darwin/test/MGLCodingTests.m +++ b/platform/darwin/test/MGLCodingTests.m @@ -67,7 +67,7 @@ - (void)testPointFeatureCluster { NSString *subclassName = MGLClusterSubclassNameForFeature(pointFeature); XCTAssert([unarchivedPointFeature isMemberOfClass:NSClassFromString(subclassName)]); - id cluster = MGL_OBJC_AS_PROTOCOL_OR_NIL(unarchivedPointFeature, MGLCluster); + id cluster = MGL_OBJC_DYNAMIC_CAST_AS_PROTOCOL(unarchivedPointFeature, MGLCluster); XCTAssert(cluster); XCTAssert(cluster.clusterIdentifier == 456); diff --git a/platform/darwin/test/MGLFeatureTests.mm b/platform/darwin/test/MGLFeatureTests.mm index 67f2a9a45e2..31150cb565a 100644 --- a/platform/darwin/test/MGLFeatureTests.mm +++ b/platform/darwin/test/MGLFeatureTests.mm @@ -85,6 +85,26 @@ - (void)testGeometryConversion { [NSValue valueWithMGLCoordinate:CLLocationCoordinate2DMake(3, 2)]); } +- (void)testClusterGeometryConversion { + mbgl::Point point = { -90.066667, 29.95 }; + mbgl::Feature pointFeature { point }; + pointFeature.id = { UINT64_MAX }; + pointFeature.properties["cluster"] = true; + pointFeature.properties["cluster_id"] = 1ULL; + pointFeature.properties["point_count"] = 5ULL; + pointFeature.properties["point_count_abbreviated"] = std::string("5");; + + id feature = MGLFeatureFromMBGLFeature(pointFeature); + + XCTAssert([feature conformsToProtocol:@protocol(MGLFeature)]); + + id cluster = MGL_OBJC_DYNAMIC_CAST_AS_PROTOCOL(feature, MGLCluster); + XCTAssert(cluster); + XCTAssert(cluster.clusterIdentifier == 1); + XCTAssert(cluster.clusterPointCount == 5); + XCTAssertEqualObjects(cluster.clusterPointCountAbbreviation, @"5"); +} + - (void)testPropertyConversion { std::vector features; From da5fdf642bae1fd5dc5928fc2627ed3047a8d657 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Fri, 5 Oct 2018 15:37:47 -0400 Subject: [PATCH 09/29] [ios, macos] cleaned up recursive log --- platform/darwin/src/MGLCluster.m | 7 +++---- platform/darwin/src/MGLShapeSource.mm | 29 +++++++++++---------------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/platform/darwin/src/MGLCluster.m b/platform/darwin/src/MGLCluster.m index 645e0c8180d..46c7420cd65 100644 --- a/platform/darwin/src/MGLCluster.m +++ b/platform/darwin/src/MGLCluster.m @@ -60,16 +60,15 @@ static NSUInteger MGLClusterPointCountIMP(id self, SEL _cmd) { } static IMP MGLFeatureClusterIMPFromSelector(SEL selector) { - if (selector == NSSelectorFromString(@"clusterIdentifier")) { + if (selector == @selector(clusterIdentifier)) { return (IMP)MGLClusterIdentifierIMP; } - else if (selector == NSSelectorFromString(@"clusterPointCount")) { + else if (selector == @selector(clusterPointCount)) { return (IMP)MGLClusterPointCountIMP; } - else if (selector == NSSelectorFromString(@"clusterPointCountAbbreviation")) { + else if (selector == @selector(clusterPointCountAbbreviation)) { return (IMP)MGLClusterPointCountAbbreviationIMP; } - assert(0); return NULL; } diff --git a/platform/darwin/src/MGLShapeSource.mm b/platform/darwin/src/MGLShapeSource.mm index c6f87d889bd..c9130d64814 100644 --- a/platform/darwin/src/MGLShapeSource.mm +++ b/platform/darwin/src/MGLShapeSource.mm @@ -224,28 +224,23 @@ - (double)zoomLevelForExpandingCluster:(id)cluster { } - (void)debugRecursiveLogForFeature:(id )feature indent:(NSUInteger)indent { - - id cluster = nil; + NSString *description = feature.description; - if ([feature conformsToProtocol:@protocol(MGLCluster)]) { - cluster = (id)feature; - } + // Want our recursive log on a single line + NSString *log = [description stringByReplacingOccurrencesOfString:@"\\s+" + withString:@" " + options:NSRegularExpressionSearch + range:NSMakeRange(0, description.length)]; + + printf("%*s%s\n", (int)indent, "", log.UTF8String); + + id cluster = MGL_OBJC_DYNAMIC_CAST_AS_PROTOCOL(feature, MGLCluster); if (cluster) { - double zoom = [self zoomLevelForExpandingCluster:cluster]; - - NSString *log = [NSString stringWithFormat:@"Cluster %ld [count=%ld, zoom=%0.1g]", cluster.clusterIdentifier, cluster.clusterPointCount, zoom]; - - printf("%*s%s\n", (int)indent, "", log.UTF8String); - - NSArray> *children = [self childrenOfCluster:cluster]; - for (id child in children) { - [self debugRecursiveLogForFeature:child indent:indent + 2]; + for (id child in [self childrenOfCluster:cluster]) { + [self debugRecursiveLogForFeature:child indent:indent + 4]; } } - else { - printf("%*sLeaf\n", (int)indent, ""); - } } @end From dba896ce2ded8df7c8fc4f66aa7bd7dd8f8c4aa0 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Thu, 22 Nov 2018 00:55:02 -0500 Subject: [PATCH 10/29] Compile fixes following rebase --- include/mbgl/style/sources/geojson_source.hpp | 4 ++-- .../src/{MGLCluster.m => MGLCluster.mm} | 1 + platform/darwin/src/MGLFoundation_Private.h | 6 ++++++ platform/darwin/src/MGLShapeSource.mm | 3 ++- .../{MGLCodingTests.m => MGLCodingTests.mm} | 1 + platform/darwin/test/MGLFeatureTests.mm | 1 + platform/ios/ios.xcodeproj/project.pbxproj | 20 +++++++++---------- src/mbgl/style/sources/geojson_source.cpp | 4 ++-- .../style/sources/geojson_source_impl.cpp | 8 ++++---- .../style/sources/geojson_source_impl.hpp | 4 ++-- 10 files changed, 31 insertions(+), 21 deletions(-) rename platform/darwin/src/{MGLCluster.m => MGLCluster.mm} (99%) rename platform/darwin/test/{MGLCodingTests.m => MGLCodingTests.mm} (99%) diff --git a/include/mbgl/style/sources/geojson_source.hpp b/include/mbgl/style/sources/geojson_source.hpp index 36cc9bb4bbf..a2c3c8f7d74 100644 --- a/include/mbgl/style/sources/geojson_source.hpp +++ b/include/mbgl/style/sources/geojson_source.hpp @@ -35,8 +35,8 @@ class GeoJSONSource : public Source { void setGeoJSON(const GeoJSON&); optional getURL() const; - mapbox::geometry::feature_collection getChildren(const std::uint32_t) const; - mapbox::geometry::feature_collection getLeaves(const std::uint32_t, const std::uint32_t, const std::uint32_t) const; + mapbox::feature::feature_collection getChildren(const std::uint32_t) const; + mapbox::feature::feature_collection getLeaves(const std::uint32_t, const std::uint32_t, const std::uint32_t) const; std::uint8_t getClusterExpansionZoom(std::uint32_t) const; class Impl; diff --git a/platform/darwin/src/MGLCluster.m b/platform/darwin/src/MGLCluster.mm similarity index 99% rename from platform/darwin/src/MGLCluster.m rename to platform/darwin/src/MGLCluster.mm index 46c7420cd65..5126c56af6f 100644 --- a/platform/darwin/src/MGLCluster.m +++ b/platform/darwin/src/MGLCluster.mm @@ -1,3 +1,4 @@ +#import "MGLFoundation_Private.h" #import "MGLCluster_Private.h" #import "MGLFeature.h" #import diff --git a/platform/darwin/src/MGLFoundation_Private.h b/platform/darwin/src/MGLFoundation_Private.h index 71737c2cf90..db81bde3dee 100644 --- a/platform/darwin/src/MGLFoundation_Private.h +++ b/platform/darwin/src/MGLFoundation_Private.h @@ -11,3 +11,9 @@ void MGLInitializeRunLoop(); (type *)([temp##__LINE__ isKindOfClass:[type class]] ? temp##__LINE__ : nil); \ }) +#define MGL_OBJC_DYNAMIC_CAST_AS_PROTOCOL(object, proto) \ + ({ \ + __typeof__( object ) temp##__LINE__ = (object); \ + (id< proto >)([temp##__LINE__ conformsToProtocol:@protocol( proto )] ? temp##__LINE__ : nil); \ + }) + diff --git a/platform/darwin/src/MGLShapeSource.mm b/platform/darwin/src/MGLShapeSource.mm index c9130d64814..04bd7efde73 100644 --- a/platform/darwin/src/MGLShapeSource.mm +++ b/platform/darwin/src/MGLShapeSource.mm @@ -1,3 +1,4 @@ +#import "MGLFoundation_Private.h" #import "MGLShapeSource_Private.h" #import "MGLStyle_Private.h" @@ -233,7 +234,7 @@ - (void)debugRecursiveLogForFeature:(id )feature indent:(NSUInteger) range:NSMakeRange(0, description.length)]; printf("%*s%s\n", (int)indent, "", log.UTF8String); - + id cluster = MGL_OBJC_DYNAMIC_CAST_AS_PROTOCOL(feature, MGLCluster); if (cluster) { diff --git a/platform/darwin/test/MGLCodingTests.m b/platform/darwin/test/MGLCodingTests.mm similarity index 99% rename from platform/darwin/test/MGLCodingTests.m rename to platform/darwin/test/MGLCodingTests.mm index 46778f51c91..e8fd0ddf27d 100644 --- a/platform/darwin/test/MGLCodingTests.m +++ b/platform/darwin/test/MGLCodingTests.mm @@ -1,6 +1,7 @@ #import #import +#import "MGLFoundation_Private.h" #import "MGLCluster_Private.h" #if TARGET_OS_IPHONE diff --git a/platform/darwin/test/MGLFeatureTests.mm b/platform/darwin/test/MGLFeatureTests.mm index 31150cb565a..0d6f4af29d3 100644 --- a/platform/darwin/test/MGLFeatureTests.mm +++ b/platform/darwin/test/MGLFeatureTests.mm @@ -2,6 +2,7 @@ #import #import +#import "MGLFoundation_Private.h" #import "../../darwin/src/MGLFeature_Private.h" @interface MGLFeatureTests : XCTestCase diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj index 94f14ab9079..ed803fe107a 100644 --- a/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/ios.xcodeproj/project.pbxproj @@ -170,7 +170,7 @@ 35D13AC61D3D19DD00AFB4E0 /* MGLFillStyleLayer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 35D13AC21D3D19DD00AFB4E0 /* MGLFillStyleLayer.mm */; }; 35D3A1E61E9BE7EB002B38EE /* MGLScaleBar.h in Headers */ = {isa = PBXBuildFile; fileRef = 355ADFFB1E9281DA00F3939D /* MGLScaleBar.h */; }; 35D3A1E71E9BE7EC002B38EE /* MGLScaleBar.h in Headers */ = {isa = PBXBuildFile; fileRef = 355ADFFB1E9281DA00F3939D /* MGLScaleBar.h */; }; - 35D9DDE21DA25EEC00DAAD69 /* MGLCodingTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 35D9DDE11DA25EEC00DAAD69 /* MGLCodingTests.m */; }; + 35D9DDE21DA25EEC00DAAD69 /* MGLCodingTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 35D9DDE11DA25EEC00DAAD69 /* MGLCodingTests.mm */; }; 35E0CFE61D3E501500188327 /* MGLStyle_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 35E0CFE51D3E501500188327 /* MGLStyle_Private.h */; }; 35E0CFE71D3E501500188327 /* MGLStyle_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 35E0CFE51D3E501500188327 /* MGLStyle_Private.h */; }; 35E1A4D81D74336F007AA97F /* MGLValueEvaluator.h in Headers */ = {isa = PBXBuildFile; fileRef = 35E1A4D71D74336F007AA97F /* MGLValueEvaluator.h */; }; @@ -485,8 +485,8 @@ CAA69DA4206DCD0E007279CD /* Mapbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA4A26961CB6E795000B7809 /* Mapbox.framework */; }; CAA69DA5206DCD0E007279CD /* Mapbox.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = DA4A26961CB6E795000B7809 /* Mapbox.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; CABE5DAD2072FAB40003AF3C /* Mapbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA8847D21CBAF91600AB86E3 /* Mapbox.framework */; }; - CAE21180216552AE00429B6F /* MGLCluster.m in Sources */ = {isa = PBXBuildFile; fileRef = CAE2117F216552AE00429B6F /* MGLCluster.m */; }; - CAE21181216552AE00429B6F /* MGLCluster.m in Sources */ = {isa = PBXBuildFile; fileRef = CAE2117F216552AE00429B6F /* MGLCluster.m */; }; + CAE21180216552AE00429B6F /* MGLCluster.mm in Sources */ = {isa = PBXBuildFile; fileRef = CAE2117F216552AE00429B6F /* MGLCluster.mm */; }; + CAE21181216552AE00429B6F /* MGLCluster.mm in Sources */ = {isa = PBXBuildFile; fileRef = CAE2117F216552AE00429B6F /* MGLCluster.mm */; }; CAE211832165BD0300429B6F /* MGLCluster_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = CAE211822165BD0300429B6F /* MGLCluster_Private.h */; }; CAE211842165BD0300429B6F /* MGLCluster_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = CAE211822165BD0300429B6F /* MGLCluster_Private.h */; }; CAE7AD5520F46EF5003B6782 /* MGLMapSnapshotterSwiftTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAE7AD5420F46EF5003B6782 /* MGLMapSnapshotterSwiftTests.swift */; }; @@ -941,7 +941,7 @@ 35D13AB61D3D15E300AFB4E0 /* MGLStyleLayer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLStyleLayer.mm; sourceTree = ""; }; 35D13AC11D3D19DD00AFB4E0 /* MGLFillStyleLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLFillStyleLayer.h; sourceTree = ""; }; 35D13AC21D3D19DD00AFB4E0 /* MGLFillStyleLayer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLFillStyleLayer.mm; sourceTree = ""; }; - 35D9DDE11DA25EEC00DAAD69 /* MGLCodingTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MGLCodingTests.m; path = ../../darwin/test/MGLCodingTests.m; sourceTree = ""; }; + 35D9DDE11DA25EEC00DAAD69 /* MGLCodingTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLCodingTests.mm; path = ../../darwin/test/MGLCodingTests.mm; sourceTree = ""; }; 35DE35531EB7CBA8004917C5 /* sv */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = sv; path = sv.lproj/Localizable.stringsdict; sourceTree = ""; }; 35E0CFE51D3E501500188327 /* MGLStyle_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLStyle_Private.h; sourceTree = ""; }; 35E1A4D71D74336F007AA97F /* MGLValueEvaluator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLValueEvaluator.h; sourceTree = ""; }; @@ -1153,7 +1153,7 @@ CA6914B420E67F50002DB0EE /* MGLAnnotationViewIntegrationTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = MGLAnnotationViewIntegrationTests.m; path = "Annotation Tests/MGLAnnotationViewIntegrationTests.m"; sourceTree = ""; }; CA88DC2F21C85D900059ED5A /* MGLStyleURLIntegrationTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLStyleURLIntegrationTest.m; sourceTree = ""; }; CA8FBC0821A47BB100D1203C /* MGLRendererConfigurationTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLRendererConfigurationTests.mm; path = ../../darwin/test/MGLRendererConfigurationTests.mm; sourceTree = ""; }; - CAE2117F216552AE00429B6F /* MGLCluster.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLCluster.m; sourceTree = ""; wrapsLines = 0; }; + CAE2117F216552AE00429B6F /* MGLCluster.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLCluster.mm; sourceTree = ""; wrapsLines = 0; }; CAE211822165BD0300429B6F /* MGLCluster_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLCluster_Private.h; sourceTree = ""; }; CAE7AD5320F46EF5003B6782 /* integration-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "integration-Bridging-Header.h"; sourceTree = ""; }; CAE7AD5420F46EF5003B6782 /* MGLMapSnapshotterSwiftTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MGLMapSnapshotterSwiftTests.swift; sourceTree = ""; }; @@ -1991,7 +1991,7 @@ 353D23951D0B0DFE002BE09D /* MGLAnnotationViewTests.m */, DAEDC4331D603417000224FF /* MGLAttributionInfoTests.m */, DA35A2C31CCA9F8300E826B2 /* MGLClockDirectionFormatterTests.m */, - 35D9DDE11DA25EEC00DAAD69 /* MGLCodingTests.m */, + 35D9DDE11DA25EEC00DAAD69 /* MGLCodingTests.mm */, DA35A2C41CCA9F8300E826B2 /* MGLCompassDirectionFormatterTests.m */, DA35A2A91CCA058D00E826B2 /* MGLCoordinateFormatterTests.m */, 3598544C1E1D38AA00B29F84 /* MGLDistanceFormatterTests.m */, @@ -2219,7 +2219,7 @@ DA8847E01CBAFA5100AB86E3 /* MGLAnnotation.h */, CAE211822165BD0300429B6F /* MGLCluster_Private.h */, CA42323A2159242400BB7C18 /* MGLCluster.h */, - CAE2117F216552AE00429B6F /* MGLCluster.m */, + CAE2117F216552AE00429B6F /* MGLCluster.mm */, DAD1656A1CF41981001FF4B9 /* MGLFeature_Private.h */, DAD165691CF41981001FF4B9 /* MGLFeature.h */, DAD1656B1CF41981001FF4B9 /* MGLFeature.mm */, @@ -3097,7 +3097,7 @@ 170C437D2029D97900863DF0 /* MGLHeatmapStyleLayerTests.mm in Sources */, 170C437C2029D96F00863DF0 /* MGLHeatmapColorTests.mm in Sources */, 357579801D501E09000B822E /* MGLFillStyleLayerTests.mm in Sources */, - 35D9DDE21DA25EEC00DAAD69 /* MGLCodingTests.m in Sources */, + 35D9DDE21DA25EEC00DAAD69 /* MGLCodingTests.mm in Sources */, DA1F8F3D1EBD287B00367E42 /* MGLDocumentationGuideTests.swift in Sources */, 076171C32139C70900668A35 /* MGLMapViewTests.m in Sources */, 3598544D1E1D38AA00B29F84 /* MGLDistanceFormatterTests.m in Sources */, @@ -3212,7 +3212,7 @@ DA8848501CBAFB9800AB86E3 /* MGLAnnotationImage.m in Sources */, 40834BF01FE05E1800C1BD0D /* MMELocationManager.m in Sources */, DA8848281CBAFA6200AB86E3 /* MGLShape.mm in Sources */, - CAE21180216552AE00429B6F /* MGLCluster.m in Sources */, + CAE21180216552AE00429B6F /* MGLCluster.mm in Sources */, DA35A2B31CCA141D00E826B2 /* MGLCompassDirectionFormatter.m in Sources */, DD0902A91DB1929D00C5BDCE /* MGLNetworkConfiguration.m in Sources */, 35D13AB91D3D15E300AFB4E0 /* MGLStyleLayer.mm in Sources */, @@ -3348,7 +3348,7 @@ 40834C041FE05E1800C1BD0D /* MMELocationManager.m in Sources */, DA35A2B41CCA141D00E826B2 /* MGLCompassDirectionFormatter.m in Sources */, 35D13ABA1D3D15E300AFB4E0 /* MGLStyleLayer.mm in Sources */, - CAE21181216552AE00429B6F /* MGLCluster.m in Sources */, + CAE21181216552AE00429B6F /* MGLCluster.mm in Sources */, 071BBAFF1EE7613E001FB02A /* MGLImageSource.mm in Sources */, DA35A2CC1CCAAAD200E826B2 /* NSValue+MGLAdditions.m in Sources */, 40834C591FE05F7600C1BD0D /* TSKTrustKitConfig.m in Sources */, diff --git a/src/mbgl/style/sources/geojson_source.cpp b/src/mbgl/style/sources/geojson_source.cpp index 665cc9c0dc7..0df72f1ed5f 100644 --- a/src/mbgl/style/sources/geojson_source.cpp +++ b/src/mbgl/style/sources/geojson_source.cpp @@ -40,11 +40,11 @@ optional GeoJSONSource::getURL() const { return url; } -mapbox::geometry::feature_collection GeoJSONSource::getChildren(const std::uint32_t cluster_id) const { +mapbox::feature::feature_collection GeoJSONSource::getChildren(const std::uint32_t cluster_id) const { return impl().getData()->getChildren(cluster_id); } -mapbox::geometry::feature_collection GeoJSONSource::getLeaves(const std::uint32_t cluster_id, +mapbox::feature::feature_collection GeoJSONSource::getLeaves(const std::uint32_t cluster_id, const std::uint32_t limit = 10, const std::uint32_t offset = 0) const{ return impl().getData()->getLeaves(cluster_id, limit, offset); diff --git a/src/mbgl/style/sources/geojson_source_impl.cpp b/src/mbgl/style/sources/geojson_source_impl.cpp index 7e83588c5d7..2e29317258a 100644 --- a/src/mbgl/style/sources/geojson_source_impl.cpp +++ b/src/mbgl/style/sources/geojson_source_impl.cpp @@ -21,11 +21,11 @@ class GeoJSONVTData : public GeoJSONData { return impl.getTile(tileID.z, tileID.x, tileID.y).features; } - mapbox::geometry::feature_collection getChildren(const std::uint32_t) final { + mapbox::feature::feature_collection getChildren(const std::uint32_t) final { return {}; } - mapbox::geometry::feature_collection getLeaves(const std::uint32_t, + mapbox::feature::feature_collection getLeaves(const std::uint32_t, const std::uint32_t, const std::uint32_t) final { return {}; @@ -49,11 +49,11 @@ class SuperclusterData : public GeoJSONData { return impl.getTile(tileID.z, tileID.x, tileID.y); } - mapbox::geometry::feature_collection getChildren(const std::uint32_t cluster_id) final { + mapbox::feature::feature_collection getChildren(const std::uint32_t cluster_id) final { return impl.getChildren(cluster_id); } - mapbox::geometry::feature_collection getLeaves(const std::uint32_t cluster_id, + mapbox::feature::feature_collection getLeaves(const std::uint32_t cluster_id, const std::uint32_t limit = 10, const std::uint32_t offset = 0) final { return impl.getLeaves(cluster_id, limit, offset); diff --git a/src/mbgl/style/sources/geojson_source_impl.hpp b/src/mbgl/style/sources/geojson_source_impl.hpp index 4ab529b54bd..120e7c22566 100644 --- a/src/mbgl/style/sources/geojson_source_impl.hpp +++ b/src/mbgl/style/sources/geojson_source_impl.hpp @@ -17,8 +17,8 @@ class GeoJSONData { virtual mapbox::feature::feature_collection getTile(const CanonicalTileID&) = 0; // SuperclusterData - virtual mapbox::geometry::feature_collection getChildren(const std::uint32_t) = 0; - virtual mapbox::geometry::feature_collection getLeaves(const std::uint32_t, const std::uint32_t, + virtual mapbox::feature::feature_collection getChildren(const std::uint32_t) = 0; + virtual mapbox::feature::feature_collection getLeaves(const std::uint32_t, const std::uint32_t, const std::uint32_t) = 0; virtual std::uint8_t getClusterExpansionZoom(std::uint32_t) = 0; }; From 385cd9698d20115b60b61e9fbac6f3927a6cb421 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Thu, 22 Nov 2018 01:26:58 -0500 Subject: [PATCH 11/29] Updated core-files.txt and macos project. --- platform/ios/core-files.txt | 2 +- platform/macos/core-files.txt | 2 +- .../macos/macos.xcodeproj/project.pbxproj | 20 +++++++++---------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/platform/ios/core-files.txt b/platform/ios/core-files.txt index 4a924f2fb46..bcc1a55aa81 100644 --- a/platform/ios/core-files.txt +++ b/platform/ios/core-files.txt @@ -79,7 +79,7 @@ platform/darwin/src/MGLDistanceFormatter.m # SDK/Foundation/Geometry platform/darwin/src/MGLAnnotation.h platform/darwin/src/MGLCluster.h -platform/darwin/src/MGLCluster.m +platform/darwin/src/MGLCluster.mm platform/darwin/src/MGLCluster_Private.h platform/darwin/src/MGLFeature.h platform/darwin/src/MGLFeature.mm diff --git a/platform/macos/core-files.txt b/platform/macos/core-files.txt index f75172ae6aa..25a8e869381 100644 --- a/platform/macos/core-files.txt +++ b/platform/macos/core-files.txt @@ -76,7 +76,7 @@ platform/darwin/src/MGLDistanceFormatter.m # SDK/Foundation/Geometry platform/darwin/src/MGLAnnotation.h platform/darwin/src/MGLCluster.h -platform/darwin/src/MGLCluster.m +platform/darwin/src/MGLCluster.mm platform/darwin/src/MGLCluster_Private.h platform/darwin/src/MGLFeature.h platform/darwin/src/MGLFeature.mm diff --git a/platform/macos/macos.xcodeproj/project.pbxproj b/platform/macos/macos.xcodeproj/project.pbxproj index d11484386a0..cf4d384f362 100644 --- a/platform/macos/macos.xcodeproj/project.pbxproj +++ b/platform/macos/macos.xcodeproj/project.pbxproj @@ -31,7 +31,7 @@ 1FC481852098F323000D09B4 /* NSPredicate+MGLPrivateAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 1FC481842098F323000D09B4 /* NSPredicate+MGLPrivateAdditions.h */; }; 3508EC641D749D39009B0EE4 /* NSExpression+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 3508EC621D749D39009B0EE4 /* NSExpression+MGLAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; }; 3508EC651D749D39009B0EE4 /* NSExpression+MGLAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3508EC631D749D39009B0EE4 /* NSExpression+MGLAdditions.mm */; }; - 3526EABD1DF9B19800006B43 /* MGLCodingTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3526EABC1DF9B19800006B43 /* MGLCodingTests.m */; }; + 3526EABD1DF9B19800006B43 /* MGLCodingTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3526EABC1DF9B19800006B43 /* MGLCodingTests.mm */; }; 352742781D4C220900A1ECE6 /* MGLStyleValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 352742771D4C220900A1ECE6 /* MGLStyleValue.h */; settings = {ATTRIBUTES = (Public, ); }; }; 352742811D4C243B00A1ECE6 /* MGLSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 3527427F1D4C243B00A1ECE6 /* MGLSource.h */; settings = {ATTRIBUTES = (Public, ); }; }; 352742821D4C243B00A1ECE6 /* MGLSource.mm in Sources */ = {isa = PBXBuildFile; fileRef = 352742801D4C243B00A1ECE6 /* MGLSource.mm */; }; @@ -119,10 +119,10 @@ 9654C12B1FFC38E000DB6A19 /* MGLPolyline_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 9654C12A1FFC38E000DB6A19 /* MGLPolyline_Private.h */; }; 9654C12D1FFC394700DB6A19 /* MGLPolygon_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 9654C12C1FFC394700DB6A19 /* MGLPolygon_Private.h */; }; 96E027311E57C9A7004B8E66 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 96E027331E57C9A7004B8E66 /* Localizable.strings */; }; - CA8FBC0D21A4A74300D1203C /* MGLRendererConfigurationTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = CA8FBC0C21A4A74300D1203C /* MGLRendererConfigurationTests.mm */; }; CA4045C5216720D700B356E1 /* MGLCluster_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = CA4045C2216720D700B356E1 /* MGLCluster_Private.h */; }; - CA4045C6216720D700B356E1 /* MGLCluster.m in Sources */ = {isa = PBXBuildFile; fileRef = CA4045C3216720D700B356E1 /* MGLCluster.m */; }; + CA4045C6216720D700B356E1 /* MGLCluster.mm in Sources */ = {isa = PBXBuildFile; fileRef = CA4045C3216720D700B356E1 /* MGLCluster.mm */; }; CA4045C7216720D700B356E1 /* MGLCluster.h in Headers */ = {isa = PBXBuildFile; fileRef = CA4045C4216720D700B356E1 /* MGLCluster.h */; settings = {ATTRIBUTES = (Public, ); }; }; + CA8FBC0D21A4A74300D1203C /* MGLRendererConfigurationTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = CA8FBC0C21A4A74300D1203C /* MGLRendererConfigurationTests.mm */; }; CA9461A620884CCB0015EB12 /* MGLAnnotationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CA9461A520884CCB0015EB12 /* MGLAnnotationTests.m */; }; DA00FC8A1D5EEAC3009AABC8 /* MGLAttributionInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = DA00FC881D5EEAC3009AABC8 /* MGLAttributionInfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; DA00FC8B1D5EEAC3009AABC8 /* MGLAttributionInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = DA00FC891D5EEAC3009AABC8 /* MGLAttributionInfo.mm */; }; @@ -345,7 +345,7 @@ 1FC481842098F323000D09B4 /* NSPredicate+MGLPrivateAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSPredicate+MGLPrivateAdditions.h"; sourceTree = ""; }; 3508EC621D749D39009B0EE4 /* NSExpression+MGLAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSExpression+MGLAdditions.h"; sourceTree = ""; }; 3508EC631D749D39009B0EE4 /* NSExpression+MGLAdditions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "NSExpression+MGLAdditions.mm"; sourceTree = ""; }; - 3526EABC1DF9B19800006B43 /* MGLCodingTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MGLCodingTests.m; path = ../../darwin/test/MGLCodingTests.m; sourceTree = ""; }; + 3526EABC1DF9B19800006B43 /* MGLCodingTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLCodingTests.mm; path = ../../darwin/test/MGLCodingTests.mm; sourceTree = ""; }; 352742771D4C220900A1ECE6 /* MGLStyleValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLStyleValue.h; sourceTree = ""; }; 3527427F1D4C243B00A1ECE6 /* MGLSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLSource.h; sourceTree = ""; }; 352742801D4C243B00A1ECE6 /* MGLSource.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLSource.mm; sourceTree = ""; }; @@ -447,10 +447,10 @@ 96E027391E57C9B9004B8E66 /* sv */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sv; path = sv.lproj/Localizable.strings; sourceTree = ""; }; 96E0273A1E57C9BB004B8E66 /* vi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = vi; path = vi.lproj/Localizable.strings; sourceTree = ""; }; 96E0273B1E57C9BC004B8E66 /* pt-BR */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "pt-BR"; path = "pt-BR.lproj/Localizable.strings"; sourceTree = ""; }; - CA8FBC0C21A4A74300D1203C /* MGLRendererConfigurationTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLRendererConfigurationTests.mm; path = ../../darwin/test/MGLRendererConfigurationTests.mm; sourceTree = ""; }; CA4045C2216720D700B356E1 /* MGLCluster_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLCluster_Private.h; sourceTree = ""; }; - CA4045C3216720D700B356E1 /* MGLCluster.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLCluster.m; sourceTree = ""; }; + CA4045C3216720D700B356E1 /* MGLCluster.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLCluster.mm; sourceTree = ""; }; CA4045C4216720D700B356E1 /* MGLCluster.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLCluster.h; sourceTree = ""; }; + CA8FBC0C21A4A74300D1203C /* MGLRendererConfigurationTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLRendererConfigurationTests.mm; path = ../../darwin/test/MGLRendererConfigurationTests.mm; sourceTree = ""; }; CA9461A520884CCB0015EB12 /* MGLAnnotationTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MGLAnnotationTests.m; path = test/MGLAnnotationTests.m; sourceTree = SOURCE_ROOT; }; DA00FC881D5EEAC3009AABC8 /* MGLAttributionInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLAttributionInfo.h; sourceTree = ""; }; DA00FC891D5EEAC3009AABC8 /* MGLAttributionInfo.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLAttributionInfo.mm; sourceTree = ""; }; @@ -1033,7 +1033,7 @@ DAE6C34B1CC31E0400DB3429 /* MGLAnnotation.h */, CA4045C2216720D700B356E1 /* MGLCluster_Private.h */, CA4045C4216720D700B356E1 /* MGLCluster.h */, - CA4045C3216720D700B356E1 /* MGLCluster.m */, + CA4045C3216720D700B356E1 /* MGLCluster.mm */, DACC22171CF3D4F700D220D9 /* MGLFeature_Private.h */, DACC22121CF3D3E200D220D9 /* MGLFeature.h */, DACC22131CF3D3E200D220D9 /* MGLFeature.mm */, @@ -1161,7 +1161,7 @@ DAEDC4311D6033F1000224FF /* MGLAttributionInfoTests.m */, DAEDC4361D606291000224FF /* MGLAttributionButtonTests.m */, DA35A2C11CCA9F4A00E826B2 /* MGLClockDirectionFormatterTests.m */, - 3526EABC1DF9B19800006B43 /* MGLCodingTests.m */, + 3526EABC1DF9B19800006B43 /* MGLCodingTests.mm */, DA35A2B51CCA14D700E826B2 /* MGLCompassDirectionFormatterTests.m */, DA35A2A71CC9F41600E826B2 /* MGLCoordinateFormatterTests.m */, DA2987591E1A4290002299F5 /* MGLDocumentationExampleTests.swift */, @@ -1656,7 +1656,7 @@ DAE6C3911CC31E2A00DB3429 /* MGLPolygon.mm in Sources */, 35C6DF851E214C0400ACA483 /* MGLDistanceFormatter.m in Sources */, DAE6C39B1CC31E2A00DB3429 /* NSProcessInfo+MGLAdditions.m in Sources */, - CA4045C6216720D700B356E1 /* MGLCluster.m in Sources */, + CA4045C6216720D700B356E1 /* MGLCluster.mm in Sources */, DAA998FC1E9F545C002E6EA6 /* MGLFillExtrusionStyleLayer.mm in Sources */, DAE6C38F1CC31E2A00DB3429 /* MGLOfflineStorage.mm in Sources */, DAED38601D62CED700D7640F /* NSURL+MGLAdditions.m in Sources */, @@ -1724,7 +1724,7 @@ DAE7DEC41E24549F007505A6 /* MGLNSStringAdditionsTests.m in Sources */, DA87A9981DC9D88400810D09 /* MGLShapeSourceTests.mm in Sources */, 55E2AD111E5B0A6900E8C587 /* MGLOfflineStorageTests.mm in Sources */, - 3526EABD1DF9B19800006B43 /* MGLCodingTests.m in Sources */, + 3526EABD1DF9B19800006B43 /* MGLCodingTests.mm in Sources */, DA87A9A21DC9DCF100810D09 /* MGLFillStyleLayerTests.mm in Sources */, DA57D4B11EBC699800793288 /* MGLDocumentationGuideTests.swift in Sources */, DAEDC4321D6033F1000224FF /* MGLAttributionInfoTests.m in Sources */, From 7b13def7fb28f604338f5b95064186d28cafbd9e Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Sat, 24 Nov 2018 00:49:49 -0500 Subject: [PATCH 12/29] Updated types of parameters to `leavesOfCluster:offset:limit` --- platform/darwin/src/MGLShapeSource.h | 2 +- platform/darwin/src/MGLShapeSource.mm | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/platform/darwin/src/MGLShapeSource.h b/platform/darwin/src/MGLShapeSource.h index f7aeac122cf..ed7be8d7120 100644 --- a/platform/darwin/src/MGLShapeSource.h +++ b/platform/darwin/src/MGLShapeSource.h @@ -324,7 +324,7 @@ MGL_EXPORT - (NSArray> *)featuresMatchingPredicate:(nullable NSPredicate *)predicate; // TODO: doc -- (NSArray> *)leavesOfCluster:(id)cluster offset:(UInt32)offset limit:(UInt32)limit; +- (NSArray> *)leavesOfCluster:(id)cluster offset:(NSUInteger)offset limit:(NSUInteger)limit; - (NSArray> *)childrenOfCluster:(id)cluster; - (double)zoomLevelForExpandingCluster:(id)cluster; @end diff --git a/platform/darwin/src/MGLShapeSource.mm b/platform/darwin/src/MGLShapeSource.mm index 04bd7efde73..f0a9046adb0 100644 --- a/platform/darwin/src/MGLShapeSource.mm +++ b/platform/darwin/src/MGLShapeSource.mm @@ -1,6 +1,7 @@ #import "MGLFoundation_Private.h" #import "MGLShapeSource_Private.h" +#import "MGLLoggingConfiguration_Private.h" #import "MGLStyle_Private.h" #import "MGLMapView_Private.h" #import "MGLSource_Private.h" @@ -194,12 +195,15 @@ - (NSString *)description { // limit(number)The maximum number of features to return. // offset(number)The number of features to skip (e.g. for pagination). -- (NSArray> *)leavesOfCluster:(id)cluster offset:(UInt32)offset limit:(UInt32)limit { +- (NSArray> *)leavesOfCluster:(id)cluster offset:(NSUInteger)offset limit:(NSUInteger)limit { if(!self.rawSource) { return nil; } - std::vector leaves = self.rawSource->getLeaves((uint32_t)cluster.clusterIdentifier, limit, offset); + MGLAssert(offset < UINT32_MAX, @"`offset` should be < `UINT32_MAX`"); + MGLAssert(limit < UINT32_MAX, @"`limit` should be < `UINT32_MAX`"); + + std::vector leaves = self.rawSource->getLeaves((uint32_t)cluster.clusterIdentifier, (uint32_t)limit, (uint32_t)offset); return MGLFeaturesFromMBGLFeatures(leaves); } From 9a1f4297954e992db2c85b9b3632499101d0d1ef Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Sun, 25 Nov 2018 00:41:36 -0500 Subject: [PATCH 13/29] Updated docs. Replaced `nil` return values with empty array due to nonnull. --- platform/darwin/src/MGLCluster.h | 33 ++++++++++++++-- platform/darwin/src/MGLCluster.mm | 22 +++++++++++ platform/darwin/src/MGLCluster_Private.h | 2 + platform/darwin/src/MGLShapeSource.h | 41 +++++++++++++++++++- platform/darwin/src/MGLShapeSource.mm | 13 +------ platform/darwin/src/MGLShapeSource_Private.h | 12 ++++++ 6 files changed, 107 insertions(+), 16 deletions(-) diff --git a/platform/darwin/src/MGLCluster.h b/platform/darwin/src/MGLCluster.h index 7cf8e0b8210..fcf512f1d55 100644 --- a/platform/darwin/src/MGLCluster.h +++ b/platform/darwin/src/MGLCluster.h @@ -1,19 +1,44 @@ #import #import "MGLFoundation.h" -@protocol MGLFeature; -// TODO: doc +@protocol MGLFeature; NS_ASSUME_NONNULL_BEGIN +/** + An `NSUInteger` constant used to indicate an invalid cluster identifier. + This indicates a missing cluster feature. + */ FOUNDATION_EXTERN MGL_EXPORT const NSUInteger MGLClusterIdentifierInvalid; -FOUNDATION_EXPORT BOOL MGLFeatureHasClusterAttribute(id feature); - +/** + A protocol that (private) feature subclasses (i.e. those already conforming to + the `MGLFeature` protocol) conform to if they are represent clusters. + + Currently only subclasses of `MGLPointFeature` support `MGLCluster`. + + To check if a feature is a cluster, check conformity to `MGLCluster`, for + example: + + ```swift + if let cluster = feature as? MGLCluster { + ... + } + ``` + */ MGL_EXPORT @protocol MGLCluster + +/** The identifier for the cluster. */ @property (nonatomic, readonly) NSUInteger clusterIdentifier; + +/** The number of points within this cluster */ @property (nonatomic, readonly) NSUInteger clusterPointCount; + +/** + An `NSString` abbreviation for the number of points within this cluster. For + example "1.2k". + */ @property (nonatomic, readonly) NSString *clusterPointCountAbbreviation; @end diff --git a/platform/darwin/src/MGLCluster.mm b/platform/darwin/src/MGLCluster.mm index 5126c56af6f..4e9cbe8a5f6 100644 --- a/platform/darwin/src/MGLCluster.mm +++ b/platform/darwin/src/MGLCluster.mm @@ -15,12 +15,18 @@ BOOL MGLFeatureHasClusterAttribute(id feature) { return [isCluster boolValue]; } +#pragma mark - Custom subclassing + NSString *MGLClusterSubclassNameForFeature(id feature) { NSString *className = NSStringFromClass([feature class]); NSString *subclassName = [className stringByAppendingString:@"_Cluster"]; return subclassName; } +/** + Static free function used as implementation for custom subclasses (that conform + to both `MGLFeature` and `MGLCluster`). + */ static NSUInteger MGLClusterIdentifierIMP(id self, SEL _cmd) { id feature = MGL_OBJC_DYNAMIC_CAST_AS_PROTOCOL(self, MGLFeature); @@ -38,6 +44,10 @@ static NSUInteger MGLClusterIdentifierIMP(id self, SEL _cmd) { return identifier; } +/** + Static free function used as implementation for custom subclasses (that conform + to both `MGLFeature` and `MGLCluster`). + */ static NSUInteger MGLClusterPointCountIMP(id self, SEL _cmd) { id feature = MGL_OBJC_DYNAMIC_CAST_AS_PROTOCOL(self, MGLFeature); @@ -47,6 +57,10 @@ static NSUInteger MGLClusterPointCountIMP(id self, SEL _cmd) { return [count unsignedIntegerValue]; } +/** + Static free function used as implementation for custom subclasses (that conform + to both `MGLFeature` and `MGLCluster`). + */ static NSString *MGLClusterPointCountAbbreviationIMP(id self, SEL _cmd) { id feature = MGL_OBJC_DYNAMIC_CAST_AS_PROTOCOL(self, MGLFeature); @@ -74,6 +88,11 @@ static IMP MGLFeatureClusterIMPFromSelector(SEL selector) { return NULL; } +/** + Converts a feature to a custom subclass that supports both `MGLFeature` and + `MGLCluster`, or returns `nil` if the feature doesn't have the requisite cluster + attributes. + */ id MGLConvertFeatureToClusterSubclass(id feature) { Protocol *clusterProtocol = @protocol(MGLCluster); @@ -100,6 +119,9 @@ static IMP MGLFeatureClusterIMPFromSelector(SEL selector) { class_addProtocol(clusterSubclass, clusterProtocol); // Install protocol methods + // Run through using `protocol_copyMethodDescriptionList` and the above + // `MGLFeatureClusterIMPFromSelector` method. We do this so that we avoid + // having to hand-craft the type encodings passed to `class_addMethod`. unsigned int count = 0; struct objc_method_description *methodDescriptionList = protocol_copyMethodDescriptionList(clusterProtocol, YES, YES, &count); diff --git a/platform/darwin/src/MGLCluster_Private.h b/platform/darwin/src/MGLCluster_Private.h index 36dd990d135..e3019c3dcd6 100644 --- a/platform/darwin/src/MGLCluster_Private.h +++ b/platform/darwin/src/MGLCluster_Private.h @@ -9,6 +9,8 @@ FOUNDATION_EXPORT NSString * const MGLClusterIdentifierKey; FOUNDATION_EXPORT NSString * const MGLClusterCountKey; FOUNDATION_EXPORT NSString * const MGLClusterCountAbbreviationKey; +FOUNDATION_EXPORT BOOL MGLFeatureHasClusterAttribute(id feature); + FOUNDATION_EXPORT MGL_EXPORT NSString *MGLClusterSubclassNameForFeature(id feature); diff --git a/platform/darwin/src/MGLShapeSource.h b/platform/darwin/src/MGLShapeSource.h index ed7be8d7120..0b08ddf95d0 100644 --- a/platform/darwin/src/MGLShapeSource.h +++ b/platform/darwin/src/MGLShapeSource.h @@ -323,10 +323,49 @@ MGL_EXPORT */ - (NSArray> *)featuresMatchingPredicate:(nullable NSPredicate *)predicate; -// TODO: doc +/** + Returns an array of map features that are the leaves of the specified cluster. + ("Leaves" are the original points that belong to the cluster.) + + This method supports pagination; you supply an offset (number of features to skip) + and a maximum number of features to return. + + @param cluster An object that conforms to the `MGLCluster` protocol. Currently + the only types that can conform are private subclasses of `MGLPointFeature`. + @param offset Number of features to skip. + @param limit Maximum number of features to return + + @return An array of objects that conform to the `MGLFeature` protocol. + */ - (NSArray> *)leavesOfCluster:(id)cluster offset:(NSUInteger)offset limit:(NSUInteger)limit; + +/** + Returns an array of map features that are the immediate children of the specified + cluster *on the next zoom level*. The may include features that also conform to + the `MGLCluster` protocol. + + @param cluster An object that conforms to the `MGLCluster` protocol. Currently + the only types that can conform are private subclasses of `MGLPointFeature`. + + @return An array of objects that conform to the `MGLFeature` protocol. + + @note The returned array may contain the `cluster` that was passed in, if the next + zoom level doesn't the zoom level for expanding that cluster. See + `-[MGLShapeSource zoomLevelForExpandingCluster:`. + */ - (NSArray> *)childrenOfCluster:(id)cluster; + +/** + Returns the zoom level at which the given cluster expands. + + @param cluster An object that conforms to the `MGLCluster` protocol. Currently + the only types that can conform are private subclasses of `MGLPointFeature`. + + @return Zoom level. This should be >= 0; any negative return value should be + considered an error. + */ - (double)zoomLevelForExpandingCluster:(id)cluster; + @end NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MGLShapeSource.mm b/platform/darwin/src/MGLShapeSource.mm index f0a9046adb0..35d6cf8421e 100644 --- a/platform/darwin/src/MGLShapeSource.mm +++ b/platform/darwin/src/MGLShapeSource.mm @@ -189,15 +189,9 @@ - (NSString *)description { #pragma mark - MGLCluster management -// TODO: doc -// For clustered sources, fetches the original points that belong to the cluster (as an array of GeoJSON features). -// clusterId(number)The value of the cluster's cluster_id property. -// limit(number)The maximum number of features to return. -// offset(number)The number of features to skip (e.g. for pagination). - - (NSArray> *)leavesOfCluster:(id)cluster offset:(NSUInteger)offset limit:(NSUInteger)limit { if(!self.rawSource) { - return nil; + return @[]; } MGLAssert(offset < UINT32_MAX, @"`offset` should be < `UINT32_MAX`"); @@ -207,18 +201,15 @@ - (NSString *)description { return MGLFeaturesFromMBGLFeatures(leaves); } -// TODO: doc -// For clustered sources, fetches the children of the given cluster on the next zoom level (as an array of GeoJSON features). - (NSArray> *)childrenOfCluster:(id)cluster { if(!self.rawSource) { - return nil; + return @[]; } std::vector children = self.rawSource->getChildren((uint32_t)cluster.clusterIdentifier); return MGLFeaturesFromMBGLFeatures(children); } -// For clustered sources, fetches the zoom at which the given cluster expands. - (double)zoomLevelForExpandingCluster:(id)cluster { if(!self.rawSource) { return -1.0; diff --git a/platform/darwin/src/MGLShapeSource_Private.h b/platform/darwin/src/MGLShapeSource_Private.h index 89b2ce1d0cb..4ed044c256c 100644 --- a/platform/darwin/src/MGLShapeSource_Private.h +++ b/platform/darwin/src/MGLShapeSource_Private.h @@ -13,6 +13,18 @@ MGL_EXPORT mbgl::style::GeoJSONOptions MGLGeoJSONOptionsFromDictionary(NSDictionary *options); @interface MGLShapeSource (Private) + +/** + :nodoc: + Debug log showing structure of an `MGLFeature`. This method recurses in the case + that the feature conforms to `MGLCluster`. This method is used for testing and + should be considered experimental, likely to be removed or changed in future + releases. + + @param feature An object that conforms to the `MGLFeature` protocol. + @param indent Used during recursion. Specify 0. + */ + - (void)debugRecursiveLogForFeature:(id )feature indent:(NSUInteger)indent; @end From bd32ad447c71e5754c4ed1b9c00bd8f5fb951371 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Sun, 25 Nov 2018 00:48:11 -0500 Subject: [PATCH 14/29] Updated to using MGLLogging methods. --- platform/darwin/src/MGLCluster.mm | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/platform/darwin/src/MGLCluster.mm b/platform/darwin/src/MGLCluster.mm index 4e9cbe8a5f6..7d5e72aba65 100644 --- a/platform/darwin/src/MGLCluster.mm +++ b/platform/darwin/src/MGLCluster.mm @@ -1,5 +1,6 @@ #import "MGLFoundation_Private.h" #import "MGLCluster_Private.h" +#import "MGLLoggingConfiguration_Private.h" #import "MGLFeature.h" #import @@ -32,14 +33,14 @@ static NSUInteger MGLClusterIdentifierIMP(id self, SEL _cmd) { id feature = MGL_OBJC_DYNAMIC_CAST_AS_PROTOCOL(self, MGLFeature); NSNumber *clusterNumber = MGL_OBJC_DYNAMIC_CAST([feature attributeForKey:MGLClusterIdentifierKey], NSNumber); - NSAssert(clusterNumber, @"Clusters should have a cluster_id"); + MGLAssert(clusterNumber, @"Clusters should have a cluster_id"); if (!clusterNumber) { return MGLClusterIdentifierInvalid; } NSUInteger identifier = [clusterNumber unsignedIntegerValue]; - NSAssert(identifier <= UINT32_MAX, @"Cluster identifiers are 32bit"); + MGLAssert(identifier <= UINT32_MAX, @"Cluster identifiers are 32bit"); return identifier; } @@ -52,7 +53,7 @@ static NSUInteger MGLClusterPointCountIMP(id self, SEL _cmd) { id feature = MGL_OBJC_DYNAMIC_CAST_AS_PROTOCOL(self, MGLFeature); NSNumber *count = MGL_OBJC_DYNAMIC_CAST([feature attributeForKey:MGLClusterCountKey], NSNumber); - NSAssert(count, @"Clusters should have a point_count"); + MGLAssert(count, @"Clusters should have a point_count"); return [count unsignedIntegerValue]; } @@ -65,7 +66,7 @@ Static free function used as implementation for custom subclasses (that conform id feature = MGL_OBJC_DYNAMIC_CAST_AS_PROTOCOL(self, MGLFeature); NSString *abbreviation = MGL_OBJC_DYNAMIC_CAST([feature attributeForKey:MGLClusterCountAbbreviationKey], NSString); - NSAssert(abbreviation, @"Clusters should have a point_count_abbreviated"); + MGLAssert(abbreviation, @"Clusters should have a point_count_abbreviated"); if (!abbreviation) { return @"0"; @@ -84,7 +85,7 @@ static IMP MGLFeatureClusterIMPFromSelector(SEL selector) { else if (selector == @selector(clusterPointCountAbbreviation)) { return (IMP)MGLClusterPointCountAbbreviationIMP; } - assert(0); + MGLCAssert(0, @"Unrecognized selector: %@", NSStringFromSelector(selector)); return NULL; } @@ -142,13 +143,13 @@ static IMP MGLFeatureClusterIMPFromSelector(SEL selector) { // Now change the class of the feature object_setClass(feature, clusterSubclass); - assert([feature conformsToProtocol:clusterProtocol]); + MGLCAssert([feature conformsToProtocol:clusterProtocol], @"Feature subclass %@ should conform to MGLCluster", subclassName); id cluster = (id)feature; - assert([cluster respondsToSelector:@selector(clusterIdentifier)]); - assert([cluster respondsToSelector:@selector(clusterPointCount)]); - assert([cluster respondsToSelector:@selector(clusterPointCountAbbreviation)]); + MGLCAssert([cluster respondsToSelector:@selector(clusterIdentifier)], @"Feature subclass %@ - missing selector `clusterIdentifier`", subclassName); + MGLCAssert([cluster respondsToSelector:@selector(clusterPointCount)], @"Feature subclass %@ - missing selector `clusterPointCount`", subclassName); + MGLCAssert([cluster respondsToSelector:@selector(clusterPointCountAbbreviation)], @"Feature subclass %@ - missing selector `clusterPointCountAbbreviation`", subclassName); return cluster; } From 65f0360f904033df8e46109f44830d868379ca90 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Mon, 26 Nov 2018 10:44:07 -0500 Subject: [PATCH 15/29] Updated documentation and associated test. --- platform/darwin/src/MGLCluster.h | 13 ++++- .../test/MGLDocumentationExampleTests.swift | 54 ++++++++++++++++++- 2 files changed, 64 insertions(+), 3 deletions(-) diff --git a/platform/darwin/src/MGLCluster.h b/platform/darwin/src/MGLCluster.h index fcf512f1d55..c6f9f270cd3 100644 --- a/platform/darwin/src/MGLCluster.h +++ b/platform/darwin/src/MGLCluster.h @@ -21,9 +21,18 @@ FOUNDATION_EXTERN MGL_EXPORT const NSUInteger MGLClusterIdentifierInvalid; example: ```swift - if let cluster = feature as? MGLCluster { - ... + let shape = try! MGLShape(data: clusterShapeData, encoding: String.Encoding.utf8.rawValue) + + guard let pointFeature = shape as? MGLPointFeature else { + throw ExampleError.unexpectedFeatureType + } + + // Check for cluster conformance + guard let cluster = pointFeature as? MGLCluster else { + throw ExampleError.featureIsNotACluster } + + print("Approximate number of points in cluster: \(cluster.clusterPointCountAbbreviation)") ``` */ MGL_EXPORT diff --git a/platform/darwin/test/MGLDocumentationExampleTests.swift b/platform/darwin/test/MGLDocumentationExampleTests.swift index 028ee2e8564..f29e03bde4e 100644 --- a/platform/darwin/test/MGLDocumentationExampleTests.swift +++ b/platform/darwin/test/MGLDocumentationExampleTests.swift @@ -374,7 +374,7 @@ class MGLDocumentationExampleTests: XCTestCase, MGLMapViewDelegate { return MGLDocumentationExampleTests.styleURL } } - + //#-example-code let camera = MGLMapCamera(lookingAtCenter: CLLocationCoordinate2D(latitude: 37.7184, longitude: -122.4365), altitude: 100, pitch: 20, heading: 0) @@ -394,6 +394,58 @@ class MGLDocumentationExampleTests: XCTestCase, MGLMapViewDelegate { wait(for: [expectation], timeout: 5) } + func testMGLCluster() { + + enum ExampleError: Error { + case unexpectedFeatureType + case featureIsNotACluster + } + + let geoJSON: [String: Any] = [ + "type" : "Feature", + "geometry" : [ + "coordinates" : [ + -77.00896639534831, + 38.87031006108791, + 0.0 + ], + "type" : "Point" + ], + "properties" : [ + "cluster" : true, + "cluster_id" : 123, + "point_count" : 4567, + "point_count_abbreviated" : "4.5k" + ] + ] + + let clusterShapeData = try! JSONSerialization.data(withJSONObject: geoJSON, options: []) + + do { + //#-example-code + let shape = try! MGLShape(data: clusterShapeData, encoding: String.Encoding.utf8.rawValue) + + guard let pointFeature = shape as? MGLPointFeature else { + throw ExampleError.unexpectedFeatureType + } + + // Check for cluster conformance + guard let cluster = pointFeature as? MGLCluster else { + throw ExampleError.featureIsNotACluster + } + + print("Approximate number of points in cluster: \(cluster.clusterPointCountAbbreviation)") + + //#-end-example-code + + XCTAssert(cluster.clusterIdentifier == 123) + XCTAssert(cluster.clusterPointCount == 4567) + } + catch let error { + XCTFail("Example failed with thrown error: \(error)") + } + } + // For testMGLMapView(). func myCustomFunction() {} } From 1bb7dd34d9c7eb0691df2db1fe2f004411cad814 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Mon, 26 Nov 2018 10:49:16 -0500 Subject: [PATCH 16/29] Tweaked documentation --- platform/darwin/src/MGLCluster.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/darwin/src/MGLCluster.h b/platform/darwin/src/MGLCluster.h index c6f9f270cd3..5ee32e045b8 100644 --- a/platform/darwin/src/MGLCluster.h +++ b/platform/darwin/src/MGLCluster.h @@ -24,12 +24,12 @@ FOUNDATION_EXTERN MGL_EXPORT const NSUInteger MGLClusterIdentifierInvalid; let shape = try! MGLShape(data: clusterShapeData, encoding: String.Encoding.utf8.rawValue) guard let pointFeature = shape as? MGLPointFeature else { - throw ExampleError.unexpectedFeatureType + throw ExampleError.unexpectedFeatureType } // Check for cluster conformance guard let cluster = pointFeature as? MGLCluster else { - throw ExampleError.featureIsNotACluster + throw ExampleError.featureIsNotACluster } print("Approximate number of points in cluster: \(cluster.clusterPointCountAbbreviation)") From 4596fd61c6cbe0cf9004b845bbe7d57c54367ce2 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Mon, 26 Nov 2018 11:25:36 -0500 Subject: [PATCH 17/29] Regenerated example. --- platform/darwin/src/MGLCluster.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/darwin/src/MGLCluster.h b/platform/darwin/src/MGLCluster.h index 5ee32e045b8..a3524737fc7 100644 --- a/platform/darwin/src/MGLCluster.h +++ b/platform/darwin/src/MGLCluster.h @@ -24,12 +24,12 @@ FOUNDATION_EXTERN MGL_EXPORT const NSUInteger MGLClusterIdentifierInvalid; let shape = try! MGLShape(data: clusterShapeData, encoding: String.Encoding.utf8.rawValue) guard let pointFeature = shape as? MGLPointFeature else { - throw ExampleError.unexpectedFeatureType + throw ExampleError.unexpectedFeatureType } // Check for cluster conformance guard let cluster = pointFeature as? MGLCluster else { - throw ExampleError.featureIsNotACluster + throw ExampleError.featureIsNotACluster } print("Approximate number of points in cluster: \(cluster.clusterPointCountAbbreviation)") From ddcd83f02d95a50c4a1405b661cbd32946fcc28f Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Mon, 26 Nov 2018 11:42:40 -0500 Subject: [PATCH 18/29] Updated changelogs --- platform/ios/CHANGELOG.md | 48 ++++++++----------------------------- platform/macos/CHANGELOG.md | 28 +++++----------------- 2 files changed, 16 insertions(+), 60 deletions(-) diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index eac21f7dfa1..a8099fa7293 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -2,50 +2,22 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONTRIBUTING.md](../../CONTRIBUTING.md) to get started. -## 4.8.0 +## master +* `MGLMapSnapshotter` now follows "MGLIdeographicFontFamilyName" app setting to reduce font data usage while snapshotting CJK maps [#13427](https://github.com/mapbox/mapbox-gl-native/pull/13427) -* Added an `MGLStyle.performsPlacementTransitions` property to control how long it takes for colliding labels to fade out. ([#13565](https://github.com/mapbox/mapbox-gl-native/pull/13565)) -* Fixed a crash when casting large numbers in `NSExpression`. ([#13580](https://github.com/mapbox/mapbox-gl-native/pull/13580)) -* Fixed a bug where the `animated` parameter to `-[MGLMapView selectAnnotation:animated:]` was being ignored. ([#13689](https://github.com/mapbox/mapbox-gl-native/pull/13689)) -* Reinstates version 11 as the default Mapbox Streets style (as introduced in 4.7.0). ([#13690](https://github.com/mapbox/mapbox-gl-native/pull/13690)) - -## 4.7.1 - December 21, 2018 - -### Styles and rendering - -* Reverts the ability for `MGLMapView`, `MGLShapeOfflineRegion`, and `MGLTilePyramidOfflineRegion` to use version 11 of the Mapbox Streets style. ([#13650](https://github.com/mapbox/mapbox-gl-native/pull/13650)) -* Reverts the ability for convenience methods on `MGLStyle` such as `MGLStyle.lightStyleURL`, to use version 11 of the Mapbox Streets style. ([#13650](https://github.com/mapbox/mapbox-gl-native/pull/13650)) - -## 4.7.0 - December 18, 2018 - -### Packaging - -* Added the `Mapbox-iOS-SDK-stripped` build flavor, featuring fewer debug symbols. Regular framework binaries are no longer stripped of debug symbols and the `Mapbox-iOS-SDK-symbols` build has been retired. ([#13504](https://github.com/mapbox/mapbox-gl-native/pull/13504)) -* This SDK’s dynamic framework now has a bundle identifier of `com.mapbox.Mapbox`. ([#12857](https://github.com/mapbox/mapbox-gl-native/pull/12857)) -* `MGLMapView`, `MGLShapeOfflineRegion`, and `MGLTilePyramidOfflineRegion` now default to version 11 of the Mapbox Streets style. Similarly, several class properties of `MGLStyle`, such as `MGLStyle.lightStyleURL`, have been updated to return URLs to new versions of their respective styles. ([#13585](https://github.com/mapbox/mapbox-gl-native/pull/13585)) - -### Styles and rendering +## 4.7.0 * Fixed an issue where the `{prefix}` token in tile URL templates was evaluated incorrectly when requesting a source’s tiles. ([#13429](https://github.com/mapbox/mapbox-gl-native/pull/13429)) -* Added an `-[MGLStyle removeSource:error:]` method that returns a descriptive error if the style fails to remove the source, whereas `-[MGLStyle removeSource:]` fails silently. ([#13399](https://github.com/mapbox/mapbox-gl-native/pull/13399)) -* Added the `MGLFillExtrusionStyleLayer.fillExtrusionHasVerticalGradient` property. ([#13463](https://github.com/mapbox/mapbox-gl-native/pull/13463)) -* Added support for setting `MGLCollisionBehaviorPre4_0` in `NSUserDefaults`. ([#13426](https://github.com/mapbox/mapbox-gl-native/pull/13426)) -* `-[MGLStyle localizeLabelsIntoLocale:]` and `-[NSExpression(MGLAdditions) mgl_expressionLocalizedIntoLocale:]` can automatically localize styles that use version 8 of the Mapbox Streets source. ([#13481](https://github.com/mapbox/mapbox-gl-native/pull/13481)) -* Fixed symbol flickering during instantaneous transitions. ([#13535](https://github.com/mapbox/mapbox-gl-native/pull/13535)) -* Fixed a crash when specifying `MGLShapeSourceOptionLineDistanceMetrics` when creating an `MGLShapeSource`. ([#13543](https://github.com/mapbox/mapbox-gl-native/pull/13543)) - -### Map snapshots - -* `MGLMapSnapshotter` now respects the `MGLIdeographicFontFamilyName` key in Info.plist, which reduces bandwidth consumption when snapshotting regions that contain Chinese or Japanese characters. ([#13427](https://github.com/mapbox/mapbox-gl-native/pull/13427)) -* Fixed a sporadic crash when using `MGLMapSnapshotter`. ([#13300](https://github.com/mapbox/mapbox-gl-native/pull/13300)) - -### Other changes - -* Modified the behavior of the map view so that programmatic camera transitions can no longer be interrupted by user interaction when `MGLMapView.zoomEnabled`, `MGLMapView.rotateEnabled`, `MGLMapView.scrollEnabled`, and `MGLMapView.pitchEnabled` are set to false. ([#13362](https://github.com/mapbox/mapbox-gl-native/pull/13362)) * Renamed `-[MGLOfflineStorage putResourceWithUrl:data:modified:expires:etag:mustRevalidate:]` to `-[MGLOfflineStorage preloadData:forURL:modificationDate:expirationDate:eTag:mustRevalidate:]`. ([#13318](https://github.com/mapbox/mapbox-gl-native/pull/13318)) -* Points of interest have clearer, localized VoiceOver hints in styles that use version 8 of the Mapbox Streets source. ([#13525](https://github.com/mapbox/mapbox-gl-native/pull/13525)) +* Fixed sporadic crash when using `MGLMapSnapshotter`. ([#13300](https://github.com/mapbox/mapbox-gl-native/pull/13300)) * Added `MGLLoggingConfiguration` and `MGLLoggingBlockHandler` that handle error and fault events produced by the SDK. ([#13235](https://github.com/mapbox/mapbox-gl-native/pull/13235)) +* This SDK’s dynamic framework now has a bundle identifier of `com.mapbox.Mapbox`. ([#12857](https://github.com/mapbox/mapbox-gl-native/pull/12857)) +* Modified the behavior of the map view so that programmatic camera transitions can no longer be interrupted by user interaction when `MGLMapView.zoomEnabled`, `MGLMapView.rotateEnabled`, `MGLMapView.scrollEnabled`, and `MGLMapView.pitchEnabled` are set to false. ([#13362](https://github.com/mapbox/mapbox-gl-native/pull/13362)) * Fixed random crashes during app termination. ([#13367](https://github.com/mapbox/mapbox-gl-native/pull/13367)) +* Added `-[MGLStyle removeSource:error:]` that returns a `BOOL` indicating success (and an optional `NSError` in case of failure). ([#13399](https://github.com/mapbox/mapbox-gl-native/pull/13399)) +* Added support for setting `MGLCollisionBehaviorPre4_0` in `NSUserDefaults`. ([#13426](https://github.com/mapbox/mapbox-gl-native/pull/13426)) +* Improved support for feature clusters by adding `-[MGLShapeSource leavesOfCluster:offset:limit:]`, `-[MGLShapeSource childrenOfCluster:]`, `-[MGLShapeSource zoomLevelForExpandingCluster:]` and the associated `MGLCluster` protocol. Private subclasses of `MGLPointFeature` will conform to this new protocol if the underlying feature represents a cluster. ([#12952](https://github.com/mapbox/mapbox-gl-native/pull/12952)) + ## 4.6.0 - November 7, 2018 diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md index 11908f0f18a..d47f2b30d5a 100644 --- a/platform/macos/CHANGELOG.md +++ b/platform/macos/CHANGELOG.md @@ -2,34 +2,18 @@ ## master -* Added an `MGLStyle.performsPlacementTransitions` property to control how long it takes for colliding labels to fade out. ([#13565](https://github.com/mapbox/mapbox-gl-native/pull/13565)) -* Fixed a crash when casting large numbers in `NSExpression`. ([#13580](https://github.com/mapbox/mapbox-gl-native/pull/13580)) - -## 0.13.0 - December 20, 2018 - -### Packaging - -* This SDK’s dynamic framework now has a bundle identifier of `com.mapbox.Mapbox`. ([#12857](https://github.com/mapbox/mapbox-gl-native/pull/12857)) -* `MGLMapView`, `MGLShapeOfflineRegion`, and `MGLTilePyramidOfflineRegion` now default to version 11 of the Mapbox Streets style. Similarly, several class properties of `MGLStyle`, such as `MGLStyle.lightStyleURL`, have been updated to return URLs to new versions of their respective styles. ([#13585](https://github.com/mapbox/mapbox-gl-native/pull/13585)) - -### Styles and rendering - +* `MGLMapSnapshotter` now follows "MGLIdeographicFontFamilyName" app setting to reduce font data usage while snapshotting CJK maps [#13427](https://github.com/mapbox/mapbox-gl-native/pull/13427) * Fixed an issue where the `{prefix}` token in tile URL templates was evaluated incorrectly when requesting a source’s tiles. ([#13429](https://github.com/mapbox/mapbox-gl-native/pull/13429)) -* Added an `-[MGLStyle removeSource:error:]` method that returns a descriptive error if the style fails to remove the source, whereas `-[MGLStyle removeSource:]` fails silently. ([#13399](https://github.com/mapbox/mapbox-gl-native/pull/13399)) -* Added the `MGLFillExtrusionStyleLayer.fillExtrusionHasVerticalGradient` property. ([#13463](https://github.com/mapbox/mapbox-gl-native/pull/13463)) +* Added `-[MGLStyle removeSource:error:]` that returns a `BOOL` indicating success (and an optional `NSError` in case of failure). ([#13399](https://github.com/mapbox/mapbox-gl-native/pull/13399)) * Added support for setting `MGLCollisionBehaviorPre4_0` in `NSUserDefaults`. ([#13426](https://github.com/mapbox/mapbox-gl-native/pull/13426)) -* `-[MGLStyle localizeLabelsIntoLocale:]` and `-[NSExpression(MGLAdditions) mgl_expressionLocalizedIntoLocale:]` can automatically localize styles that use version 8 of the Mapbox Streets source. ([#13481](https://github.com/mapbox/mapbox-gl-native/pull/13481)) -* Fixed symbol flickering during instantaneous transitions. ([#13535](https://github.com/mapbox/mapbox-gl-native/pull/13535)) -* Fixed a crash when specifying `MGLShapeSourceOptionLineDistanceMetrics` when creating an `MGLShapeSource`. ([#13543](https://github.com/mapbox/mapbox-gl-native/pull/13543)) - -### Other changes +* Improved support for feature clusters by adding `-[MGLShapeSource leavesOfCluster:offset:limit:]`, `-[MGLShapeSource childrenOfCluster:]`, `-[MGLShapeSource zoomLevelForExpandingCluster:]` and the associated `MGLCluster` protocol. Private subclasses of `MGLPointFeature` will conform to this new protocol if the underlying feature represents a cluster. ([#12952](https://github.com/mapbox/mapbox-gl-native/pull/12952)) -* Renamed `-[MGLOfflineStorage putResourceWithUrl:data:modified:expires:etag:mustRevalidate:]` to `-[MGLOfflineStorage preloadData:forURL:modificationDate:expirationDate:eTag:mustRevalidate:]`. ([#13318](https://github.com/mapbox/mapbox-gl-native/pull/13318)) -* `MGLMapSnapshotter` now respects the `MGLIdeographicFontFamilyName` key in Info.plist, which reduces bandwidth consumption when snapshotting regions that contain Chinese or Japanese characters. ([#13427](https://github.com/mapbox/mapbox-gl-native/pull/13427)) -* Added `MGLLoggingConfiguration` and `MGLLoggingBlockHandler` that handle error and fault events produced by the SDK. ([#13235](https://github.com/mapbox/mapbox-gl-native/pull/13235)) ## 0.12.0 - November 8, 2018 +* Renamed `-[MGLOfflineStorage putResourceWithUrl:data:modified:expires:etag:mustRevalidate:]` to `-[MGLOfflineStorage preloadData:forURL:modificationDate:expirationDate:eTag:mustRevalidate:]`. ([#13318](https://github.com/mapbox/mapbox-gl-native/pull/13318)) +* This SDK’s dynamic framework now has a bundle identifier of `com.mapbox.Mapbox`. ([#12857](https://github.com/mapbox/mapbox-gl-native/pull/12857)) + ### Styles and rendering * `MGLSymbolStyleLayer.text` can now be set to rich text with varying fonts and text sizes. ([#12624](https://github.com/mapbox/mapbox-gl-native/pull/12624)) From 08de82be39d54f6d83353ce5cb5e930caea0d7b1 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Mon, 26 Nov 2018 11:58:34 -0500 Subject: [PATCH 19/29] Documentation nits. --- platform/darwin/src/MGLShapeSource.h | 2 +- platform/darwin/test/MGLDocumentationExampleTests.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/darwin/src/MGLShapeSource.h b/platform/darwin/src/MGLShapeSource.h index 0b08ddf95d0..0263c39c583 100644 --- a/platform/darwin/src/MGLShapeSource.h +++ b/platform/darwin/src/MGLShapeSource.h @@ -351,7 +351,7 @@ MGL_EXPORT @note The returned array may contain the `cluster` that was passed in, if the next zoom level doesn't the zoom level for expanding that cluster. See - `-[MGLShapeSource zoomLevelForExpandingCluster:`. + `-[MGLShapeSource zoomLevelForExpandingCluster:]`. */ - (NSArray> *)childrenOfCluster:(id)cluster; diff --git a/platform/darwin/test/MGLDocumentationExampleTests.swift b/platform/darwin/test/MGLDocumentationExampleTests.swift index f29e03bde4e..e7420b2aa44 100644 --- a/platform/darwin/test/MGLDocumentationExampleTests.swift +++ b/platform/darwin/test/MGLDocumentationExampleTests.swift @@ -374,7 +374,7 @@ class MGLDocumentationExampleTests: XCTestCase, MGLMapViewDelegate { return MGLDocumentationExampleTests.styleURL } } - + //#-example-code let camera = MGLMapCamera(lookingAtCenter: CLLocationCoordinate2D(latitude: 37.7184, longitude: -122.4365), altitude: 100, pitch: 20, heading: 0) From 8ebce7fda579cff81d8cdacf472f5573512baf0c Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Fri, 11 Jan 2019 12:04:26 -0500 Subject: [PATCH 20/29] Reverting old core changes. --- include/mbgl/style/sources/geojson_source.hpp | 5 +---- src/mbgl/style/sources/geojson_source.cpp | 14 -------------- src/mbgl/style/sources/geojson_source_impl.cpp | 14 +++++++------- src/mbgl/style/sources/geojson_source_impl.hpp | 9 +++++---- 4 files changed, 13 insertions(+), 29 deletions(-) diff --git a/include/mbgl/style/sources/geojson_source.hpp b/include/mbgl/style/sources/geojson_source.hpp index a2c3c8f7d74..a03b9102795 100644 --- a/include/mbgl/style/sources/geojson_source.hpp +++ b/include/mbgl/style/sources/geojson_source.hpp @@ -33,11 +33,8 @@ class GeoJSONSource : public Source { void setURL(const std::string& url); void setGeoJSON(const GeoJSON&); - optional getURL() const; - mapbox::feature::feature_collection getChildren(const std::uint32_t) const; - mapbox::feature::feature_collection getLeaves(const std::uint32_t, const std::uint32_t, const std::uint32_t) const; - std::uint8_t getClusterExpansionZoom(std::uint32_t) const; + optional getURL() const; class Impl; const Impl& impl() const; diff --git a/src/mbgl/style/sources/geojson_source.cpp b/src/mbgl/style/sources/geojson_source.cpp index 0df72f1ed5f..4e3478322de 100644 --- a/src/mbgl/style/sources/geojson_source.cpp +++ b/src/mbgl/style/sources/geojson_source.cpp @@ -40,20 +40,6 @@ optional GeoJSONSource::getURL() const { return url; } -mapbox::feature::feature_collection GeoJSONSource::getChildren(const std::uint32_t cluster_id) const { - return impl().getData()->getChildren(cluster_id); -} - -mapbox::feature::feature_collection GeoJSONSource::getLeaves(const std::uint32_t cluster_id, - const std::uint32_t limit = 10, - const std::uint32_t offset = 0) const{ - return impl().getData()->getLeaves(cluster_id, limit, offset); -} - -std::uint8_t GeoJSONSource::getClusterExpansionZoom(std::uint32_t cluster_id) const { - return impl().getData()->getClusterExpansionZoom(cluster_id); -} - void GeoJSONSource::loadDescription(FileSource& fileSource) { if (!url) { loaded = true; diff --git a/src/mbgl/style/sources/geojson_source_impl.cpp b/src/mbgl/style/sources/geojson_source_impl.cpp index 2e29317258a..24ac1d79766 100644 --- a/src/mbgl/style/sources/geojson_source_impl.cpp +++ b/src/mbgl/style/sources/geojson_source_impl.cpp @@ -54,8 +54,8 @@ class SuperclusterData : public GeoJSONData { } mapbox::feature::feature_collection getLeaves(const std::uint32_t cluster_id, - const std::uint32_t limit = 10, - const std::uint32_t offset = 0) final { + const std::uint32_t limit, + const std::uint32_t offset) final { return impl.getLeaves(cluster_id, limit, offset); } @@ -75,7 +75,7 @@ GeoJSONSource::Impl::Impl(std::string id_, GeoJSONOptions options_) GeoJSONSource::Impl::Impl(const Impl& other, const GeoJSON& geoJSON) : Source::Impl(other), options(other.options) { - double scale = util::EXTENT / util::tileSize; + constexpr double scale = util::EXTENT / util::tileSize; if (options.cluster && geoJSON.is>() @@ -84,7 +84,7 @@ GeoJSONSource::Impl::Impl(const Impl& other, const GeoJSON& geoJSON) clusterOptions.maxZoom = options.clusterMaxZoom; clusterOptions.extent = util::EXTENT; clusterOptions.radius = ::round(scale * options.clusterRadius); - data = std::make_unique( + data = std::make_shared( geoJSON.get>(), clusterOptions); } else { mapbox::geojsonvt::Options vtOptions; @@ -93,7 +93,7 @@ GeoJSONSource::Impl::Impl(const Impl& other, const GeoJSON& geoJSON) vtOptions.buffer = ::round(scale * options.buffer); vtOptions.tolerance = scale * options.tolerance; vtOptions.lineMetrics = options.lineMetrics; - data = std::make_unique(geoJSON, vtOptions); + data = std::make_shared(geoJSON, vtOptions); } } @@ -103,8 +103,8 @@ Range GeoJSONSource::Impl::getZoomRange() const { return { options.minzoom, options.maxzoom }; } -GeoJSONData* GeoJSONSource::Impl::getData() const { - return data.get(); +std::weak_ptr GeoJSONSource::Impl::getData() const { + return data; } optional GeoJSONSource::Impl::getAttribution() const { diff --git a/src/mbgl/style/sources/geojson_source_impl.hpp b/src/mbgl/style/sources/geojson_source_impl.hpp index 120e7c22566..b88ab35ee0f 100644 --- a/src/mbgl/style/sources/geojson_source_impl.hpp +++ b/src/mbgl/style/sources/geojson_source_impl.hpp @@ -18,8 +18,9 @@ class GeoJSONData { // SuperclusterData virtual mapbox::feature::feature_collection getChildren(const std::uint32_t) = 0; - virtual mapbox::feature::feature_collection getLeaves(const std::uint32_t, const std::uint32_t, - const std::uint32_t) = 0; + virtual mapbox::feature::feature_collection getLeaves(const std::uint32_t, + const std::uint32_t limit = 10u, + const std::uint32_t offset = 0u) = 0; virtual std::uint8_t getClusterExpansionZoom(std::uint32_t) = 0; }; @@ -30,13 +31,13 @@ class GeoJSONSource::Impl : public Source::Impl { ~Impl() final; Range getZoomRange() const; - GeoJSONData* getData() const; + std::weak_ptr getData() const; optional getAttribution() const final; private: GeoJSONOptions options; - std::unique_ptr data; + std::shared_ptr data; }; } // namespace style From 8c4066d6a74ac6b89463c2629fa7397fe99ef818 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Fri, 11 Jan 2019 16:10:54 -0500 Subject: [PATCH 21/29] WIP updates --- platform/darwin/src/MGLCluster.h | 12 +-- platform/darwin/src/MGLCluster.mm | 42 +++++----- platform/darwin/src/MGLCluster_Private.h | 2 +- platform/darwin/src/MGLShapeSource.h | 6 +- platform/darwin/src/MGLShapeSource.mm | 82 +++++++++++++++---- platform/darwin/src/MGLShapeSource_Private.h | 2 +- platform/darwin/test/MGLCodingTests.mm | 2 - .../test/MGLDocumentationExampleTests.swift | 3 - platform/darwin/test/MGLFeatureTests.mm | 2 - 9 files changed, 99 insertions(+), 54 deletions(-) diff --git a/platform/darwin/src/MGLCluster.h b/platform/darwin/src/MGLCluster.h index a3524737fc7..2a3b5270daa 100644 --- a/platform/darwin/src/MGLCluster.h +++ b/platform/darwin/src/MGLCluster.h @@ -36,7 +36,7 @@ FOUNDATION_EXTERN MGL_EXPORT const NSUInteger MGLClusterIdentifierInvalid; ``` */ MGL_EXPORT -@protocol MGLCluster +@protocol MGLCluster /** The identifier for the cluster. */ @property (nonatomic, readonly) NSUInteger clusterIdentifier; @@ -44,11 +44,11 @@ MGL_EXPORT /** The number of points within this cluster */ @property (nonatomic, readonly) NSUInteger clusterPointCount; -/** - An `NSString` abbreviation for the number of points within this cluster. For - example "1.2k". - */ -@property (nonatomic, readonly) NSString *clusterPointCountAbbreviation; +///** +// An `NSString` abbreviation for the number of points within this cluster. For +// example "1.2k". +// */ +//@property (nonatomic, readonly) NSString *clusterPointCountAbbreviation; @end NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MGLCluster.mm b/platform/darwin/src/MGLCluster.mm index 7d5e72aba65..2cc296fa91b 100644 --- a/platform/darwin/src/MGLCluster.mm +++ b/platform/darwin/src/MGLCluster.mm @@ -7,7 +7,7 @@ NSString * const MGLClusterBoolKey = @"cluster"; NSString * const MGLClusterIdentifierKey = @"cluster_id"; NSString * const MGLClusterCountKey = @"point_count"; -NSString * const MGLClusterCountAbbreviationKey = @"point_count_abbreviated"; +//NSString * const MGLClusterCountAbbreviationKey = @"point_count_abbreviated"; const NSUInteger MGLClusterIdentifierInvalid = NSUIntegerMax; @@ -58,22 +58,22 @@ static NSUInteger MGLClusterPointCountIMP(id self, SEL _cmd) { return [count unsignedIntegerValue]; } -/** - Static free function used as implementation for custom subclasses (that conform - to both `MGLFeature` and `MGLCluster`). - */ -static NSString *MGLClusterPointCountAbbreviationIMP(id self, SEL _cmd) { - id feature = MGL_OBJC_DYNAMIC_CAST_AS_PROTOCOL(self, MGLFeature); - - NSString *abbreviation = MGL_OBJC_DYNAMIC_CAST([feature attributeForKey:MGLClusterCountAbbreviationKey], NSString); - MGLAssert(abbreviation, @"Clusters should have a point_count_abbreviated"); - - if (!abbreviation) { - return @"0"; - } - - return abbreviation; -} +///** +// Static free function used as implementation for custom subclasses (that conform +// to both `MGLFeature` and `MGLCluster`). +// */ +//static NSString *MGLClusterPointCountAbbreviationIMP(id self, SEL _cmd) { +// id feature = MGL_OBJC_DYNAMIC_CAST_AS_PROTOCOL(self, MGLFeature); +// +// NSString *abbreviation = MGL_OBJC_DYNAMIC_CAST([feature attributeForKey:MGLClusterCountAbbreviationKey], NSString); +// MGLAssert(abbreviation, @"Clusters should have a point_count_abbreviated"); +// +// if (!abbreviation) { +// return @"0"; +// } +// +// return abbreviation; +//} static IMP MGLFeatureClusterIMPFromSelector(SEL selector) { if (selector == @selector(clusterIdentifier)) { @@ -82,9 +82,9 @@ static IMP MGLFeatureClusterIMPFromSelector(SEL selector) { else if (selector == @selector(clusterPointCount)) { return (IMP)MGLClusterPointCountIMP; } - else if (selector == @selector(clusterPointCountAbbreviation)) { - return (IMP)MGLClusterPointCountAbbreviationIMP; - } +// else if (selector == @selector(clusterPointCountAbbreviation)) { +// return (IMP)MGLClusterPointCountAbbreviationIMP; +// } MGLCAssert(0, @"Unrecognized selector: %@", NSStringFromSelector(selector)); return NULL; } @@ -149,7 +149,7 @@ static IMP MGLFeatureClusterIMPFromSelector(SEL selector) { MGLCAssert([cluster respondsToSelector:@selector(clusterIdentifier)], @"Feature subclass %@ - missing selector `clusterIdentifier`", subclassName); MGLCAssert([cluster respondsToSelector:@selector(clusterPointCount)], @"Feature subclass %@ - missing selector `clusterPointCount`", subclassName); - MGLCAssert([cluster respondsToSelector:@selector(clusterPointCountAbbreviation)], @"Feature subclass %@ - missing selector `clusterPointCountAbbreviation`", subclassName); +// MGLCAssert([cluster respondsToSelector:@selector(clusterPointCountAbbreviation)], @"Feature subclass %@ - missing selector `clusterPointCountAbbreviation`", subclassName); return cluster; } diff --git a/platform/darwin/src/MGLCluster_Private.h b/platform/darwin/src/MGLCluster_Private.h index e3019c3dcd6..5117c68918e 100644 --- a/platform/darwin/src/MGLCluster_Private.h +++ b/platform/darwin/src/MGLCluster_Private.h @@ -7,7 +7,7 @@ FOUNDATION_EXPORT NSString * const MGLClusterBoolKey; FOUNDATION_EXPORT NSString * const MGLClusterIdentifierKey; FOUNDATION_EXPORT NSString * const MGLClusterCountKey; -FOUNDATION_EXPORT NSString * const MGLClusterCountAbbreviationKey; +//FOUNDATION_EXPORT NSString * const MGLClusterCountAbbreviationKey; FOUNDATION_EXPORT BOOL MGLFeatureHasClusterAttribute(id feature); diff --git a/platform/darwin/src/MGLShapeSource.h b/platform/darwin/src/MGLShapeSource.h index 0263c39c583..1c37252a3d1 100644 --- a/platform/darwin/src/MGLShapeSource.h +++ b/platform/darwin/src/MGLShapeSource.h @@ -337,7 +337,7 @@ MGL_EXPORT @return An array of objects that conform to the `MGLFeature` protocol. */ -- (NSArray> *)leavesOfCluster:(id)cluster offset:(NSUInteger)offset limit:(NSUInteger)limit; +- (NSArray> *)leavesOfCluster:(MGLShape *)cluster offset:(NSUInteger)offset limit:(NSUInteger)limit; /** Returns an array of map features that are the immediate children of the specified @@ -353,7 +353,7 @@ MGL_EXPORT zoom level doesn't the zoom level for expanding that cluster. See `-[MGLShapeSource zoomLevelForExpandingCluster:]`. */ -- (NSArray> *)childrenOfCluster:(id)cluster; +- (NSArray> *)childrenOfCluster:(MGLShape *)cluster; /** Returns the zoom level at which the given cluster expands. @@ -364,7 +364,7 @@ MGL_EXPORT @return Zoom level. This should be >= 0; any negative return value should be considered an error. */ -- (double)zoomLevelForExpandingCluster:(id)cluster; +- (double)zoomLevelForExpandingCluster:(MGLShape *)cluster; @end diff --git a/platform/darwin/src/MGLShapeSource.mm b/platform/darwin/src/MGLShapeSource.mm index 35d6cf8421e..7720f943281 100644 --- a/platform/darwin/src/MGLShapeSource.mm +++ b/platform/darwin/src/MGLShapeSource.mm @@ -189,34 +189,86 @@ - (NSString *)description { #pragma mark - MGLCluster management -- (NSArray> *)leavesOfCluster:(id)cluster offset:(NSUInteger)offset limit:(NSUInteger)limit { - if(!self.rawSource) { +- (mbgl::optional)featureExtensionValueOfCluster:(MGLShape *)cluster extension:(std::string)extension options:(const std::map)options { + mbgl::optional extensionValue; + + // Check parameters + if (!self.rawSource || !self.mapView || !cluster) { + return extensionValue; + } + + auto geoJSON = [cluster geoJSONObject]; + + if (!geoJSON.is()) { + MGLAssert(0, @"cluster geoJSON object is not a feature."); + return extensionValue; + } + + auto clusterFeature = geoJSON.get(); + + extensionValue = self.mapView.renderer->queryFeatureExtensions(self.rawSource->getID(), + clusterFeature, + "supercluster", + extension, + options); + + return extensionValue; +} + + +- (NSArray> *)leavesOfCluster:(MGLShape *)cluster offset:(NSUInteger)offset limit:(NSUInteger)limit { + const std::map options = { + { "limit", static_cast(limit) }, + { "offset", static_cast(offset) } + }; + + auto featureExtension = [self featureExtensionValueOfCluster:cluster extension:"leaves" options:options]; + + if (!featureExtension) { return @[]; } - MGLAssert(offset < UINT32_MAX, @"`offset` should be < `UINT32_MAX`"); - MGLAssert(limit < UINT32_MAX, @"`limit` should be < `UINT32_MAX`"); + if (!featureExtension->is()) { + return @[]; + } - std::vector leaves = self.rawSource->getLeaves((uint32_t)cluster.clusterIdentifier, (uint32_t)limit, (uint32_t)offset); + std::vector leaves = featureExtension->get(); return MGLFeaturesFromMBGLFeatures(leaves); } -- (NSArray> *)childrenOfCluster:(id)cluster { - if(!self.rawSource) { +- (NSArray> *)childrenOfCluster:(MGLShape *)cluster { + auto featureExtension = [self featureExtensionValueOfCluster:cluster extension:"children" options:{}]; + + if (!featureExtension) { return @[]; } - - std::vector children = self.rawSource->getChildren((uint32_t)cluster.clusterIdentifier); - return MGLFeaturesFromMBGLFeatures(children); + + if (!featureExtension->is()) { + return @[]; + } + + std::vector leaves = featureExtension->get(); + return MGLFeaturesFromMBGLFeatures(leaves); } -- (double)zoomLevelForExpandingCluster:(id)cluster { - if(!self.rawSource) { +- (double)zoomLevelForExpandingCluster:(MGLShape *)cluster { + auto featureExtension = [self featureExtensionValueOfCluster:cluster extension:"expansion-zoom" options:{}]; + + if (!featureExtension) { return -1.0; } - - uint8_t zoom = self.rawSource->getClusterExpansionZoom((uint32_t)cluster.clusterIdentifier); - return static_cast(zoom); + + if (!featureExtension->is()) { + return -1.0; + } + + auto value = featureExtension->get(); + if (value.is()) { + auto zoom = value.get(); + return static_cast(zoom); + } + + return -1.0; } - (void)debugRecursiveLogForFeature:(id )feature indent:(NSUInteger)indent { diff --git a/platform/darwin/src/MGLShapeSource_Private.h b/platform/darwin/src/MGLShapeSource_Private.h index 4ed044c256c..271aa2a9ee8 100644 --- a/platform/darwin/src/MGLShapeSource_Private.h +++ b/platform/darwin/src/MGLShapeSource_Private.h @@ -25,7 +25,7 @@ mbgl::style::GeoJSONOptions MGLGeoJSONOptionsFromDictionary(NSDictionary)feature indent:(NSUInteger)indent; +- (void)debugRecursiveLogForFeature:(MGLShape *)feature indent:(NSUInteger)indent; @end NS_ASSUME_NONNULL_END diff --git a/platform/darwin/test/MGLCodingTests.mm b/platform/darwin/test/MGLCodingTests.mm index e8fd0ddf27d..20609924576 100644 --- a/platform/darwin/test/MGLCodingTests.mm +++ b/platform/darwin/test/MGLCodingTests.mm @@ -53,7 +53,6 @@ - (void)testPointFeatureCluster { @"cluster" : @(YES), @"cluster_id" : @(456), @"point_count" : @(2), - @"point_count_abbreviated" : @"2" }; XCTAssert([pointFeature isMemberOfClass:[MGLPointFeature class]], @""); @@ -73,7 +72,6 @@ - (void)testPointFeatureCluster { XCTAssert(cluster); XCTAssert(cluster.clusterIdentifier == 456); XCTAssert(cluster.clusterPointCount == 2); - XCTAssertEqualObjects(cluster.clusterPointCountAbbreviation, @"2"); // Archiving shouldn't affect [NSKeyedArchiver archiveRootObject:unarchivedPointFeature toFile:filePath]; diff --git a/platform/darwin/test/MGLDocumentationExampleTests.swift b/platform/darwin/test/MGLDocumentationExampleTests.swift index e7420b2aa44..10308619d21 100644 --- a/platform/darwin/test/MGLDocumentationExampleTests.swift +++ b/platform/darwin/test/MGLDocumentationExampleTests.swift @@ -415,7 +415,6 @@ class MGLDocumentationExampleTests: XCTestCase, MGLMapViewDelegate { "cluster" : true, "cluster_id" : 123, "point_count" : 4567, - "point_count_abbreviated" : "4.5k" ] ] @@ -434,8 +433,6 @@ class MGLDocumentationExampleTests: XCTestCase, MGLMapViewDelegate { throw ExampleError.featureIsNotACluster } - print("Approximate number of points in cluster: \(cluster.clusterPointCountAbbreviation)") - //#-end-example-code XCTAssert(cluster.clusterIdentifier == 123) diff --git a/platform/darwin/test/MGLFeatureTests.mm b/platform/darwin/test/MGLFeatureTests.mm index 0d6f4af29d3..87f288f3ce3 100644 --- a/platform/darwin/test/MGLFeatureTests.mm +++ b/platform/darwin/test/MGLFeatureTests.mm @@ -93,7 +93,6 @@ - (void)testClusterGeometryConversion { pointFeature.properties["cluster"] = true; pointFeature.properties["cluster_id"] = 1ULL; pointFeature.properties["point_count"] = 5ULL; - pointFeature.properties["point_count_abbreviated"] = std::string("5");; id feature = MGLFeatureFromMBGLFeature(pointFeature); @@ -103,7 +102,6 @@ - (void)testClusterGeometryConversion { XCTAssert(cluster); XCTAssert(cluster.clusterIdentifier == 1); XCTAssert(cluster.clusterPointCount == 5); - XCTAssertEqualObjects(cluster.clusterPointCountAbbreviation, @"5"); } - (void)testPropertyConversion { From 360ad1c06ddb2cb8219d480908eedc3bc8a00e42 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Sat, 12 Jan 2019 01:25:18 -0500 Subject: [PATCH 22/29] Introduces MGLPointFeatureCluster subclass (since update feature extension required MGLShape) --- platform/darwin/src/MGLCluster.h | 7 - platform/darwin/src/MGLCluster.mm | 155 ------------------- platform/darwin/src/MGLCluster_Private.h | 19 --- platform/darwin/src/MGLFeature.h | 6 + platform/darwin/src/MGLFeature.mm | 74 ++++++++- platform/darwin/src/MGLFeature_Private.h | 4 - platform/darwin/src/MGLShapeSource.h | 9 +- platform/darwin/src/MGLShapeSource.mm | 10 +- platform/darwin/src/MGLShapeSource_Private.h | 2 +- platform/darwin/test/MGLCodingTests.mm | 24 +-- platform/darwin/test/MGLFeatureTests.mm | 2 + platform/ios/ios.xcodeproj/project.pbxproj | 25 +-- 12 files changed, 104 insertions(+), 233 deletions(-) delete mode 100644 platform/darwin/src/MGLCluster.mm delete mode 100644 platform/darwin/src/MGLCluster_Private.h diff --git a/platform/darwin/src/MGLCluster.h b/platform/darwin/src/MGLCluster.h index 2a3b5270daa..a7caf2ddcf8 100644 --- a/platform/darwin/src/MGLCluster.h +++ b/platform/darwin/src/MGLCluster.h @@ -1,4 +1,3 @@ -#import #import "MGLFoundation.h" @protocol MGLFeature; @@ -32,7 +31,6 @@ FOUNDATION_EXTERN MGL_EXPORT const NSUInteger MGLClusterIdentifierInvalid; throw ExampleError.featureIsNotACluster } - print("Approximate number of points in cluster: \(cluster.clusterPointCountAbbreviation)") ``` */ MGL_EXPORT @@ -44,11 +42,6 @@ MGL_EXPORT /** The number of points within this cluster */ @property (nonatomic, readonly) NSUInteger clusterPointCount; -///** -// An `NSString` abbreviation for the number of points within this cluster. For -// example "1.2k". -// */ -//@property (nonatomic, readonly) NSString *clusterPointCountAbbreviation; @end NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/MGLCluster.mm b/platform/darwin/src/MGLCluster.mm deleted file mode 100644 index 2cc296fa91b..00000000000 --- a/platform/darwin/src/MGLCluster.mm +++ /dev/null @@ -1,155 +0,0 @@ -#import "MGLFoundation_Private.h" -#import "MGLCluster_Private.h" -#import "MGLLoggingConfiguration_Private.h" -#import "MGLFeature.h" -#import - -NSString * const MGLClusterBoolKey = @"cluster"; -NSString * const MGLClusterIdentifierKey = @"cluster_id"; -NSString * const MGLClusterCountKey = @"point_count"; -//NSString * const MGLClusterCountAbbreviationKey = @"point_count_abbreviated"; - -const NSUInteger MGLClusterIdentifierInvalid = NSUIntegerMax; - -BOOL MGLFeatureHasClusterAttribute(id feature) { - NSNumber *isCluster = MGL_OBJC_DYNAMIC_CAST([feature attributeForKey:MGLClusterBoolKey], NSNumber); - return [isCluster boolValue]; -} - -#pragma mark - Custom subclassing - -NSString *MGLClusterSubclassNameForFeature(id feature) { - NSString *className = NSStringFromClass([feature class]); - NSString *subclassName = [className stringByAppendingString:@"_Cluster"]; - return subclassName; -} - -/** - Static free function used as implementation for custom subclasses (that conform - to both `MGLFeature` and `MGLCluster`). - */ -static NSUInteger MGLClusterIdentifierIMP(id self, SEL _cmd) { - - id feature = MGL_OBJC_DYNAMIC_CAST_AS_PROTOCOL(self, MGLFeature); - - NSNumber *clusterNumber = MGL_OBJC_DYNAMIC_CAST([feature attributeForKey:MGLClusterIdentifierKey], NSNumber); - MGLAssert(clusterNumber, @"Clusters should have a cluster_id"); - - if (!clusterNumber) { - return MGLClusterIdentifierInvalid; - } - - NSUInteger identifier = [clusterNumber unsignedIntegerValue]; - MGLAssert(identifier <= UINT32_MAX, @"Cluster identifiers are 32bit"); - - return identifier; -} - -/** - Static free function used as implementation for custom subclasses (that conform - to both `MGLFeature` and `MGLCluster`). - */ -static NSUInteger MGLClusterPointCountIMP(id self, SEL _cmd) { - id feature = MGL_OBJC_DYNAMIC_CAST_AS_PROTOCOL(self, MGLFeature); - - NSNumber *count = MGL_OBJC_DYNAMIC_CAST([feature attributeForKey:MGLClusterCountKey], NSNumber); - MGLAssert(count, @"Clusters should have a point_count"); - - return [count unsignedIntegerValue]; -} - -///** -// Static free function used as implementation for custom subclasses (that conform -// to both `MGLFeature` and `MGLCluster`). -// */ -//static NSString *MGLClusterPointCountAbbreviationIMP(id self, SEL _cmd) { -// id feature = MGL_OBJC_DYNAMIC_CAST_AS_PROTOCOL(self, MGLFeature); -// -// NSString *abbreviation = MGL_OBJC_DYNAMIC_CAST([feature attributeForKey:MGLClusterCountAbbreviationKey], NSString); -// MGLAssert(abbreviation, @"Clusters should have a point_count_abbreviated"); -// -// if (!abbreviation) { -// return @"0"; -// } -// -// return abbreviation; -//} - -static IMP MGLFeatureClusterIMPFromSelector(SEL selector) { - if (selector == @selector(clusterIdentifier)) { - return (IMP)MGLClusterIdentifierIMP; - } - else if (selector == @selector(clusterPointCount)) { - return (IMP)MGLClusterPointCountIMP; - } -// else if (selector == @selector(clusterPointCountAbbreviation)) { -// return (IMP)MGLClusterPointCountAbbreviationIMP; -// } - MGLCAssert(0, @"Unrecognized selector: %@", NSStringFromSelector(selector)); - return NULL; -} - -/** - Converts a feature to a custom subclass that supports both `MGLFeature` and - `MGLCluster`, or returns `nil` if the feature doesn't have the requisite cluster - attributes. - */ -id MGLConvertFeatureToClusterSubclass(id feature) { - - Protocol *clusterProtocol = @protocol(MGLCluster); - - if ([feature conformsToProtocol:clusterProtocol]) { - return (id)feature; - } - - if (!MGLFeatureHasClusterAttribute(feature)) { - return nil; - } - - Class currentClass = [feature class]; - - NSString *subclassName = MGLClusterSubclassNameForFeature(feature); - - // Does this new subclass already exist? - Class clusterSubclass = NSClassFromString(subclassName); - - if (!clusterSubclass) { - clusterSubclass = objc_allocateClassPair(currentClass, subclassName.UTF8String, 0); - - // Add protocol to this new subclass - class_addProtocol(clusterSubclass, clusterProtocol); - - // Install protocol methods - // Run through using `protocol_copyMethodDescriptionList` and the above - // `MGLFeatureClusterIMPFromSelector` method. We do this so that we avoid - // having to hand-craft the type encodings passed to `class_addMethod`. - unsigned int count = 0; - struct objc_method_description *methodDescriptionList = protocol_copyMethodDescriptionList(clusterProtocol, YES, YES, &count); - - for (unsigned int index = 0; index < count; index++) { - struct objc_method_description desc = methodDescriptionList[index]; - - IMP imp = MGLFeatureClusterIMPFromSelector(desc.name); - - if (imp) { - class_addMethod(clusterSubclass, desc.name, imp, desc.types); - } - } - - free(methodDescriptionList); methodDescriptionList = NULL; - - objc_registerClassPair(clusterSubclass); - } - - // Now change the class of the feature - object_setClass(feature, clusterSubclass); - MGLCAssert([feature conformsToProtocol:clusterProtocol], @"Feature subclass %@ should conform to MGLCluster", subclassName); - - id cluster = (id)feature; - - MGLCAssert([cluster respondsToSelector:@selector(clusterIdentifier)], @"Feature subclass %@ - missing selector `clusterIdentifier`", subclassName); - MGLCAssert([cluster respondsToSelector:@selector(clusterPointCount)], @"Feature subclass %@ - missing selector `clusterPointCount`", subclassName); -// MGLCAssert([cluster respondsToSelector:@selector(clusterPointCountAbbreviation)], @"Feature subclass %@ - missing selector `clusterPointCountAbbreviation`", subclassName); - - return cluster; -} diff --git a/platform/darwin/src/MGLCluster_Private.h b/platform/darwin/src/MGLCluster_Private.h deleted file mode 100644 index 5117c68918e..00000000000 --- a/platform/darwin/src/MGLCluster_Private.h +++ /dev/null @@ -1,19 +0,0 @@ -#import -#import "MGLFoundation.h" -#import "MGLCluster.h" - -@protocol MGLFeature; - -FOUNDATION_EXPORT NSString * const MGLClusterBoolKey; -FOUNDATION_EXPORT NSString * const MGLClusterIdentifierKey; -FOUNDATION_EXPORT NSString * const MGLClusterCountKey; -//FOUNDATION_EXPORT NSString * const MGLClusterCountAbbreviationKey; - -FOUNDATION_EXPORT BOOL MGLFeatureHasClusterAttribute(id feature); - -FOUNDATION_EXPORT MGL_EXPORT -NSString *MGLClusterSubclassNameForFeature(id feature); - -FOUNDATION_EXPORT -id MGLConvertFeatureToClusterSubclass(id feature); - diff --git a/platform/darwin/src/MGLFeature.h b/platform/darwin/src/MGLFeature.h index 8886c8df559..e17b463a7f9 100644 --- a/platform/darwin/src/MGLFeature.h +++ b/platform/darwin/src/MGLFeature.h @@ -6,6 +6,7 @@ #import "MGLPointAnnotation.h" #import "MGLPointCollection.h" #import "MGLShapeCollection.h" +#import "MGLCluster.h" NS_ASSUME_NONNULL_BEGIN @@ -192,6 +193,11 @@ MGL_EXPORT @interface MGLPointFeature : MGLPointAnnotation @end + +MGL_EXPORT +@interface MGLPointFeatureCluster : MGLPointFeature +@end + /** An `MGLPolylineFeature` object associates a polyline shape with an optional identifier and attributes. diff --git a/platform/darwin/src/MGLFeature.mm b/platform/darwin/src/MGLFeature.mm index e579a87eb03..55700b6b228 100644 --- a/platform/darwin/src/MGLFeature.mm +++ b/platform/darwin/src/MGLFeature.mm @@ -1,11 +1,13 @@ +#import "MGLFoundation_Private.h" #import "MGLFeature_Private.h" +#import "MGLCluster.h" #import "MGLPointAnnotation.h" #import "MGLPolyline.h" #import "MGLPolygon.h" #import "MGLValueEvaluator.h" -#import "MGLCluster_Private.h" +#import "MGLCluster.h" #import "MGLShape_Private.h" #import "MGLPointCollection_Private.h" #import "MGLPolyline_Private.h" @@ -20,6 +22,9 @@ #import #import +static NSString * const MGLClusterIdentifierKey = @"cluster_id"; +static NSString * const MGLClusterCountKey = @"point_count"; + @interface MGLEmptyFeature () @end @@ -93,6 +98,42 @@ - (NSString *)description @end +const NSUInteger MGLClusterIdentifierInvalid = NSUIntegerMax; + +@implementation MGLPointFeatureCluster + +// If it turns out we need to cluster other classes, then consider moving the +// following MGLCluster methods into free functions, and generate the subclasses +// at runtime +- (NSUInteger)clusterIdentifier { + id feature = MGL_OBJC_DYNAMIC_CAST_AS_PROTOCOL(self, MGLFeature); + + NSNumber *clusterNumber = MGL_OBJC_DYNAMIC_CAST([feature attributeForKey:MGLClusterIdentifierKey], NSNumber); + MGLAssert(clusterNumber, @"Clusters should have a cluster_id"); + + if (!clusterNumber) { + return MGLClusterIdentifierInvalid; + } + + NSUInteger clusterIdentifier = [clusterNumber unsignedIntegerValue]; + MGLAssert(clusterIdentifier <= UINT32_MAX, @"Cluster identifiers are 32bit"); + + return clusterIdentifier; +} + +- (NSUInteger)clusterPointCount { + id feature = MGL_OBJC_DYNAMIC_CAST_AS_PROTOCOL(self, MGLFeature); + + NSNumber *count = MGL_OBJC_DYNAMIC_CAST([feature attributeForKey:MGLClusterCountKey], NSNumber); + MGLAssert(count, @"Clusters should have a point_count"); + + return [count unsignedIntegerValue]; +} + + +@end + + @interface MGLPolylineFeature () @end @@ -319,14 +360,34 @@ - (NSDictionary *)geoJSONDictionary { */ template class GeometryEvaluator { +private: + mbgl::PropertyMap _properties; + public: + + GeometryEvaluator(mbgl::PropertyMap properties = {}): + _properties(properties) + {} + MGLShape * operator()(const mbgl::EmptyGeometry &) const { MGLEmptyFeature *feature = [[MGLEmptyFeature alloc] init]; return feature; } MGLShape * operator()(const mbgl::Point &geometry) const { - MGLPointFeature *feature = [[MGLPointFeature alloc] init]; + Class pointFeatureClass = [MGLPointFeature class]; + + auto clusterIt = _properties.find("cluster"); + if (clusterIt != _properties.end()) { + auto clusterValue = clusterIt->second; + if (clusterValue.template is()) { + if (clusterValue.template get()) { + pointFeatureClass = [MGLPointFeatureCluster class]; + } + } + } + + MGLPointFeature *feature = [[pointFeatureClass alloc] init]; feature.coordinate = toLocationCoordinate2D(geometry); return feature; } @@ -376,6 +437,9 @@ - (NSDictionary *)geoJSONDictionary { } private: + +// mbgl::PropertyMap _properties; + static CLLocationCoordinate2D toLocationCoordinate2D(const mbgl::Point &point) { return CLLocationCoordinate2DMake(point.y, point.x); } @@ -444,17 +508,13 @@ static CLLocationCoordinate2D toLocationCoordinate2D(const mbgl::Point &point ValueEvaluator evaluator; attributes[@(pair.first.c_str())] = mbgl::Value::visit(value, evaluator); } - GeometryEvaluator evaluator; + GeometryEvaluator evaluator(feature.properties); MGLShape *shape = mapbox::geometry::geometry::visit(feature.geometry, evaluator); if (!feature.id.is()) { shape.identifier = mbgl::FeatureIdentifier::visit(feature.id, ValueEvaluator()); } shape.attributes = attributes; - if (MGLFeatureHasClusterAttribute(shape)) { - MGLConvertFeatureToClusterSubclass(shape); - } - return shape; } diff --git a/platform/darwin/src/MGLFeature_Private.h b/platform/darwin/src/MGLFeature_Private.h index b3406fe2b4f..9b0e16f4b92 100644 --- a/platform/darwin/src/MGLFeature_Private.h +++ b/platform/darwin/src/MGLFeature_Private.h @@ -47,10 +47,6 @@ NS_ASSUME_NONNULL_END NSSet *identifierClasses = [NSSet setWithArray:@[[NSString class], [NSNumber class]]]; \ identifier = [decoder decodeObjectOfClasses:identifierClasses forKey:@"identifier"]; \ _attributes = [decoder decodeObjectOfClass:[NSDictionary class] forKey:@"attributes"]; \ - /* If this feature is a cluster, then change the class */ \ - if (MGLFeatureHasClusterAttribute(self)) { \ - MGLConvertFeatureToClusterSubclass(self); \ - } \ } \ return self; \ } diff --git a/platform/darwin/src/MGLShapeSource.h b/platform/darwin/src/MGLShapeSource.h index 1c37252a3d1..2982fda0685 100644 --- a/platform/darwin/src/MGLShapeSource.h +++ b/platform/darwin/src/MGLShapeSource.h @@ -5,8 +5,9 @@ NS_ASSUME_NONNULL_BEGIN @protocol MGLFeature; -@protocol MGLCluster; +//@protocol MGLCluster; @class MGLPointFeature; +@class MGLPointFeatureCluster; @class MGLShape; /** @@ -337,7 +338,7 @@ MGL_EXPORT @return An array of objects that conform to the `MGLFeature` protocol. */ -- (NSArray> *)leavesOfCluster:(MGLShape *)cluster offset:(NSUInteger)offset limit:(NSUInteger)limit; +- (NSArray> *)leavesOfCluster:(MGLPointFeatureCluster *)cluster offset:(NSUInteger)offset limit:(NSUInteger)limit; /** Returns an array of map features that are the immediate children of the specified @@ -353,7 +354,7 @@ MGL_EXPORT zoom level doesn't the zoom level for expanding that cluster. See `-[MGLShapeSource zoomLevelForExpandingCluster:]`. */ -- (NSArray> *)childrenOfCluster:(MGLShape *)cluster; +- (NSArray> *)childrenOfCluster:(MGLPointFeatureCluster *)cluster; /** Returns the zoom level at which the given cluster expands. @@ -364,7 +365,7 @@ MGL_EXPORT @return Zoom level. This should be >= 0; any negative return value should be considered an error. */ -- (double)zoomLevelForExpandingCluster:(MGLShape *)cluster; +- (double)zoomLevelForExpandingCluster:(MGLPointFeatureCluster *)cluster; @end diff --git a/platform/darwin/src/MGLShapeSource.mm b/platform/darwin/src/MGLShapeSource.mm index 7720f943281..ac0f404756c 100644 --- a/platform/darwin/src/MGLShapeSource.mm +++ b/platform/darwin/src/MGLShapeSource.mm @@ -7,7 +7,7 @@ #import "MGLSource_Private.h" #import "MGLFeature_Private.h" #import "MGLShape_Private.h" -#import "MGLCluster_Private.h" +#import "MGLCluster.h" #import "NSPredicate+MGLPrivateAdditions.h" #import "NSURL+MGLAdditions.h" @@ -216,7 +216,7 @@ - (NSString *)description { } -- (NSArray> *)leavesOfCluster:(MGLShape *)cluster offset:(NSUInteger)offset limit:(NSUInteger)limit { +- (NSArray> *)leavesOfCluster:(MGLPointFeatureCluster *)cluster offset:(NSUInteger)offset limit:(NSUInteger)limit { const std::map options = { { "limit", static_cast(limit) }, { "offset", static_cast(offset) } @@ -236,7 +236,7 @@ - (NSString *)description { return MGLFeaturesFromMBGLFeatures(leaves); } -- (NSArray> *)childrenOfCluster:(MGLShape *)cluster { +- (NSArray> *)childrenOfCluster:(MGLPointFeatureCluster *)cluster { auto featureExtension = [self featureExtensionValueOfCluster:cluster extension:"children" options:{}]; if (!featureExtension) { @@ -251,7 +251,7 @@ - (NSString *)description { return MGLFeaturesFromMBGLFeatures(leaves); } -- (double)zoomLevelForExpandingCluster:(MGLShape *)cluster { +- (double)zoomLevelForExpandingCluster:(MGLPointFeatureCluster *)cluster { auto featureExtension = [self featureExtensionValueOfCluster:cluster extension:"expansion-zoom" options:{}]; if (!featureExtension) { @@ -282,7 +282,7 @@ - (void)debugRecursiveLogForFeature:(id )feature indent:(NSUInteger) printf("%*s%s\n", (int)indent, "", log.UTF8String); - id cluster = MGL_OBJC_DYNAMIC_CAST_AS_PROTOCOL(feature, MGLCluster); + MGLPointFeatureCluster *cluster = MGL_OBJC_DYNAMIC_CAST(feature, MGLPointFeatureCluster); if (cluster) { for (id child in [self childrenOfCluster:cluster]) { diff --git a/platform/darwin/src/MGLShapeSource_Private.h b/platform/darwin/src/MGLShapeSource_Private.h index 271aa2a9ee8..c7eaf3d0a8b 100644 --- a/platform/darwin/src/MGLShapeSource_Private.h +++ b/platform/darwin/src/MGLShapeSource_Private.h @@ -25,7 +25,7 @@ mbgl::style::GeoJSONOptions MGLGeoJSONOptionsFromDictionary(NSDictionary *)feature indent:(NSUInteger)indent; +- (void)debugRecursiveLogForFeature:(id)feature indent:(NSUInteger)indent; @end NS_ASSUME_NONNULL_END diff --git a/platform/darwin/test/MGLCodingTests.mm b/platform/darwin/test/MGLCodingTests.mm index 20609924576..f4e5c8f13e7 100644 --- a/platform/darwin/test/MGLCodingTests.mm +++ b/platform/darwin/test/MGLCodingTests.mm @@ -2,7 +2,7 @@ #import #import "MGLFoundation_Private.h" -#import "MGLCluster_Private.h" +#import "MGLCluster.h" #if TARGET_OS_IPHONE #import "MGLUserLocation_Private.h" @@ -45,7 +45,7 @@ - (void)testPointFeature { } - (void)testPointFeatureCluster { - MGLPointFeature *pointFeature = [[MGLPointFeature alloc] init]; + MGLPointFeature *pointFeature = [[MGLPointFeatureCluster alloc] init]; pointFeature.title = @"title"; pointFeature.subtitle = @"subtitle"; pointFeature.identifier = @(123); @@ -55,17 +55,17 @@ - (void)testPointFeatureCluster { @"point_count" : @(2), }; - XCTAssert([pointFeature isMemberOfClass:[MGLPointFeature class]], @""); + XCTAssert([pointFeature isKindOfClass:[MGLPointFeature class]], @""); NSString *filePath = [self temporaryFilePathForClass:MGLPointFeature.class]; [NSKeyedArchiver archiveRootObject:pointFeature toFile:filePath]; MGLPointFeature *unarchivedPointFeature = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath]; XCTAssertEqualObjects(pointFeature, unarchivedPointFeature); - + // Unarchive process should convert to a cluster - NSString *subclassName = MGLClusterSubclassNameForFeature(pointFeature); - XCTAssert([unarchivedPointFeature isMemberOfClass:NSClassFromString(subclassName)]); +// NSString *subclassName = MGLClusterSubclassNameForFeature(pointFeature); + XCTAssert([unarchivedPointFeature isMemberOfClass:[MGLPointFeatureCluster class]]); id cluster = MGL_OBJC_DYNAMIC_CAST_AS_PROTOCOL(unarchivedPointFeature, MGLCluster); @@ -73,12 +73,12 @@ - (void)testPointFeatureCluster { XCTAssert(cluster.clusterIdentifier == 456); XCTAssert(cluster.clusterPointCount == 2); - // Archiving shouldn't affect - [NSKeyedArchiver archiveRootObject:unarchivedPointFeature toFile:filePath]; - MGLPointFeature *unarchivedPointFeature2 = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath]; - - XCTAssert([unarchivedPointFeature2 isMemberOfClass:NSClassFromString(@"MGLPointFeature_Cluster")]); - XCTAssertEqualObjects(pointFeature, unarchivedPointFeature2); +// // Archiving shouldn't affect +// [NSKeyedArchiver archiveRootObject:unarchivedPointFeature toFile:filePath]; +// MGLPointFeature *unarchivedPointFeature2 = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath]; +// +// XCTAssert([unarchivedPointFeature2 isMemberOfClass:[MGLPointFeatureCluster class]]); +// XCTAssertEqualObjects(pointFeature, unarchivedPointFeature2); } diff --git a/platform/darwin/test/MGLFeatureTests.mm b/platform/darwin/test/MGLFeatureTests.mm index 87f288f3ce3..edc105bca4d 100644 --- a/platform/darwin/test/MGLFeatureTests.mm +++ b/platform/darwin/test/MGLFeatureTests.mm @@ -102,6 +102,8 @@ - (void)testClusterGeometryConversion { XCTAssert(cluster); XCTAssert(cluster.clusterIdentifier == 1); XCTAssert(cluster.clusterPointCount == 5); + + XCTAssert([cluster isMemberOfClass:[MGLPointFeatureCluster class]]); } - (void)testPropertyConversion { diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj index ed803fe107a..2c4d7f2eabe 100644 --- a/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/ios.xcodeproj/project.pbxproj @@ -474,21 +474,17 @@ CA0C27942076CA19001CE5B7 /* MGLMapViewIntegrationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CA0C27932076CA19001CE5B7 /* MGLMapViewIntegrationTest.m */; }; CA1B4A512099FB2200EDD491 /* MGLMapSnapshotterTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CA1B4A502099FB2200EDD491 /* MGLMapSnapshotterTest.m */; }; CA34C9C3207FD272005C1A06 /* MGLCameraTransitionTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = CA34C9C2207FD272005C1A06 /* MGLCameraTransitionTests.mm */; }; - CA42323B2159242400BB7C18 /* MGLCluster.h in Headers */ = {isa = PBXBuildFile; fileRef = CA42323A2159242400BB7C18 /* MGLCluster.h */; settings = {ATTRIBUTES = (Public, ); }; }; - CA42323C2159242400BB7C18 /* MGLCluster.h in Headers */ = {isa = PBXBuildFile; fileRef = CA42323A2159242400BB7C18 /* MGLCluster.h */; settings = {ATTRIBUTES = (Public, ); }; }; CA4EB8C720863487006AB465 /* MGLStyleLayerIntegrationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CA4EB8C620863487006AB465 /* MGLStyleLayerIntegrationTests.m */; }; CA55CD41202C16AA00CE7095 /* MGLCameraChangeReason.h in Headers */ = {isa = PBXBuildFile; fileRef = CA55CD3E202C16AA00CE7095 /* MGLCameraChangeReason.h */; settings = {ATTRIBUTES = (Public, ); }; }; CA55CD42202C16AA00CE7095 /* MGLCameraChangeReason.h in Headers */ = {isa = PBXBuildFile; fileRef = CA55CD3E202C16AA00CE7095 /* MGLCameraChangeReason.h */; settings = {ATTRIBUTES = (Public, ); }; }; + CA65C4F821E9BB080068B0D4 /* MGLCluster.h in Headers */ = {isa = PBXBuildFile; fileRef = CA65C4F721E9BB080068B0D4 /* MGLCluster.h */; settings = {ATTRIBUTES = (Public, ); }; }; + CA65C4F921E9BB080068B0D4 /* MGLCluster.h in Headers */ = {isa = PBXBuildFile; fileRef = CA65C4F721E9BB080068B0D4 /* MGLCluster.h */; settings = {ATTRIBUTES = (Public, ); }; }; CA6914B520E67F50002DB0EE /* MGLAnnotationViewIntegrationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CA6914B420E67F50002DB0EE /* MGLAnnotationViewIntegrationTests.m */; }; CA88DC3021C85D900059ED5A /* MGLStyleURLIntegrationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CA88DC2F21C85D900059ED5A /* MGLStyleURLIntegrationTest.m */; }; CA8FBC0921A47BB100D1203C /* MGLRendererConfigurationTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = CA8FBC0821A47BB100D1203C /* MGLRendererConfigurationTests.mm */; }; CAA69DA4206DCD0E007279CD /* Mapbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA4A26961CB6E795000B7809 /* Mapbox.framework */; }; CAA69DA5206DCD0E007279CD /* Mapbox.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = DA4A26961CB6E795000B7809 /* Mapbox.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; CABE5DAD2072FAB40003AF3C /* Mapbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA8847D21CBAF91600AB86E3 /* Mapbox.framework */; }; - CAE21180216552AE00429B6F /* MGLCluster.mm in Sources */ = {isa = PBXBuildFile; fileRef = CAE2117F216552AE00429B6F /* MGLCluster.mm */; }; - CAE21181216552AE00429B6F /* MGLCluster.mm in Sources */ = {isa = PBXBuildFile; fileRef = CAE2117F216552AE00429B6F /* MGLCluster.mm */; }; - CAE211832165BD0300429B6F /* MGLCluster_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = CAE211822165BD0300429B6F /* MGLCluster_Private.h */; }; - CAE211842165BD0300429B6F /* MGLCluster_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = CAE211822165BD0300429B6F /* MGLCluster_Private.h */; }; CAE7AD5520F46EF5003B6782 /* MGLMapSnapshotterSwiftTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAE7AD5420F46EF5003B6782 /* MGLMapSnapshotterSwiftTests.swift */; }; DA00FC8E1D5EEB0D009AABC8 /* MGLAttributionInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = DA00FC8C1D5EEB0D009AABC8 /* MGLAttributionInfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; DA00FC8F1D5EEB0D009AABC8 /* MGLAttributionInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = DA00FC8C1D5EEB0D009AABC8 /* MGLAttributionInfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -1146,15 +1142,13 @@ CA0C27952076CA50001CE5B7 /* MGLMapViewIntegrationTest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLMapViewIntegrationTest.h; sourceTree = ""; }; CA1B4A502099FB2200EDD491 /* MGLMapSnapshotterTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLMapSnapshotterTest.m; sourceTree = ""; }; CA34C9C2207FD272005C1A06 /* MGLCameraTransitionTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLCameraTransitionTests.mm; sourceTree = ""; }; - CA42323A2159242400BB7C18 /* MGLCluster.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLCluster.h; sourceTree = ""; }; CA4EB8C620863487006AB465 /* MGLStyleLayerIntegrationTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLStyleLayerIntegrationTests.m; sourceTree = ""; }; CA55CD3E202C16AA00CE7095 /* MGLCameraChangeReason.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLCameraChangeReason.h; sourceTree = ""; }; CA5E5042209BDC5F001A8A81 /* MGLTestUtility.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = MGLTestUtility.h; path = ../../darwin/test/MGLTestUtility.h; sourceTree = ""; }; + CA65C4F721E9BB080068B0D4 /* MGLCluster.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLCluster.h; sourceTree = ""; }; CA6914B420E67F50002DB0EE /* MGLAnnotationViewIntegrationTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = MGLAnnotationViewIntegrationTests.m; path = "Annotation Tests/MGLAnnotationViewIntegrationTests.m"; sourceTree = ""; }; CA88DC2F21C85D900059ED5A /* MGLStyleURLIntegrationTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLStyleURLIntegrationTest.m; sourceTree = ""; }; CA8FBC0821A47BB100D1203C /* MGLRendererConfigurationTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLRendererConfigurationTests.mm; path = ../../darwin/test/MGLRendererConfigurationTests.mm; sourceTree = ""; }; - CAE2117F216552AE00429B6F /* MGLCluster.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLCluster.mm; sourceTree = ""; wrapsLines = 0; }; - CAE211822165BD0300429B6F /* MGLCluster_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLCluster_Private.h; sourceTree = ""; }; CAE7AD5320F46EF5003B6782 /* integration-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "integration-Bridging-Header.h"; sourceTree = ""; }; CAE7AD5420F46EF5003B6782 /* MGLMapSnapshotterSwiftTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MGLMapSnapshotterSwiftTests.swift; sourceTree = ""; }; DA00FC8C1D5EEB0D009AABC8 /* MGLAttributionInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLAttributionInfo.h; sourceTree = ""; }; @@ -2216,10 +2210,8 @@ DAD165811CF4CFC4001FF4B9 /* Geometry */ = { isa = PBXGroup; children = ( + CA65C4F721E9BB080068B0D4 /* MGLCluster.h */, DA8847E01CBAFA5100AB86E3 /* MGLAnnotation.h */, - CAE211822165BD0300429B6F /* MGLCluster_Private.h */, - CA42323A2159242400BB7C18 /* MGLCluster.h */, - CAE2117F216552AE00429B6F /* MGLCluster.mm */, DAD1656A1CF41981001FF4B9 /* MGLFeature_Private.h */, DAD165691CF41981001FF4B9 /* MGLFeature.h */, DAD1656B1CF41981001FF4B9 /* MGLFeature.mm */, @@ -2363,8 +2355,8 @@ DA88483A1CBAFB8500AB86E3 /* MGLAnnotationImage.h in Headers */, 74CB5EBD219B280400102936 /* MGLFillStyleLayer_Private.h in Headers */, DAF2571B201901E200367EF5 /* MGLHillshadeStyleLayer.h in Headers */, + CA65C4F821E9BB080068B0D4 /* MGLCluster.h in Headers */, DA35A2BB1CCA9A6900E826B2 /* MGLClockDirectionFormatter.h in Headers */, - CAE211832165BD0300429B6F /* MGLCluster_Private.h in Headers */, 353933FE1D3FB7DD003F57D7 /* MGLSymbolStyleLayer.h in Headers */, DA8848201CBAFA6200AB86E3 /* MGLOfflinePack_Private.h in Headers */, DA00FC8E1D5EEB0D009AABC8 /* MGLAttributionInfo.h in Headers */, @@ -2551,8 +2543,6 @@ 55E5666C21C2A2080008B8B5 /* MMEDispatchManager.h in Headers */, 55E5666121C2A2080008B8B5 /* MMEEventsManager.h in Headers */, 55E5666D21C2A2080008B8B5 /* NSData+MMEGZIP.h in Headers */, - CA42323B2159242400BB7C18 /* MGLPointCluster.h in Headers */, - CA42323B2159242400BB7C18 /* MGLCluster.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2586,6 +2576,7 @@ 071BBB041EE76147001FB02A /* MGLImageSource.h in Headers */, 74CB5EC0219B280400102936 /* MGLHeatmapStyleLayer_Private.h in Headers */, 74CB5ECB219B285000102936 /* MGLLineStyleLayer_Private.h in Headers */, + CA65C4F921E9BB080068B0D4 /* MGLCluster.h in Headers */, DABFB8611CBE99E500D62B32 /* MGLMultiPoint.h in Headers */, 74CB5ECD219B285000102936 /* MGLOpenGLStyleLayer_Private.h in Headers */, 74CB5ECF219B285000102936 /* MGLRasterStyleLayer_Private.h in Headers */, @@ -2612,7 +2603,6 @@ DABFB8621CBE99E500D62B32 /* MGLOfflinePack.h in Headers */, 96E516FA20005A3D00A02306 /* MGLUserLocationHeadingArrowLayer.h in Headers */, 96E516E62000560B00A02306 /* MGLOfflineRegion_Private.h in Headers */, - CAE211842165BD0300429B6F /* MGLCluster_Private.h in Headers */, DAD1656D1CF41981001FF4B9 /* MGLFeature.h in Headers */, 96E516E72000560B00A02306 /* MGLOfflineStorage_Private.h in Headers */, DA17BE311CC4BDAA00402C41 /* MGLMapView_Private.h in Headers */, @@ -2671,7 +2661,6 @@ DAC25FCD200FD83F009BE98E /* NSExpression+MGLPrivateAdditions.h in Headers */, 74CB5ED2219B286400102936 /* MGLSymbolStyleLayer_Private.h in Headers */, 354B83971D2E873E005D9406 /* MGLUserLocationAnnotationView.h in Headers */, - CA42323C2159242400BB7C18 /* MGLCluster.h in Headers */, DAF0D8111DFE0EA000B28378 /* MGLRasterTileSource_Private.h in Headers */, 96E516FF20005A4F00A02306 /* MGLMapboxEvents.h in Headers */, 1F6A82A321360F9D00BA5B41 /* MGLLoggingConfiguration.h in Headers */, @@ -3212,7 +3201,6 @@ DA8848501CBAFB9800AB86E3 /* MGLAnnotationImage.m in Sources */, 40834BF01FE05E1800C1BD0D /* MMELocationManager.m in Sources */, DA8848281CBAFA6200AB86E3 /* MGLShape.mm in Sources */, - CAE21180216552AE00429B6F /* MGLCluster.mm in Sources */, DA35A2B31CCA141D00E826B2 /* MGLCompassDirectionFormatter.m in Sources */, DD0902A91DB1929D00C5BDCE /* MGLNetworkConfiguration.m in Sources */, 35D13AB91D3D15E300AFB4E0 /* MGLStyleLayer.mm in Sources */, @@ -3348,7 +3336,6 @@ 40834C041FE05E1800C1BD0D /* MMELocationManager.m in Sources */, DA35A2B41CCA141D00E826B2 /* MGLCompassDirectionFormatter.m in Sources */, 35D13ABA1D3D15E300AFB4E0 /* MGLStyleLayer.mm in Sources */, - CAE21181216552AE00429B6F /* MGLCluster.mm in Sources */, 071BBAFF1EE7613E001FB02A /* MGLImageSource.mm in Sources */, DA35A2CC1CCAAAD200E826B2 /* NSValue+MGLAdditions.m in Sources */, 40834C591FE05F7600C1BD0D /* TSKTrustKitConfig.m in Sources */, From 7120a4b063a45b3d385ad6eb6ed354b871208e2b Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Sat, 12 Jan 2019 14:34:59 -0500 Subject: [PATCH 23/29] Clean up --- platform/darwin/src/MGLCluster.h | 12 +- platform/darwin/src/MGLFeature.h | 14 +- platform/darwin/src/MGLFeature.mm | 55 ++- platform/darwin/src/MGLShapeSource.h | 14 +- platform/darwin/src/MGLShapeSource.mm | 2 - platform/darwin/test/MGLCodingTests.mm | 10 +- .../test/MGLDocumentationExampleTests.swift | 6 + platform/ios/core-files.txt | 323 ------------------ platform/ios/sdk-files.json | 1 + platform/macos/core-files.txt | 224 ------------ platform/macos/sdk-files.json | 3 + 11 files changed, 60 insertions(+), 604 deletions(-) delete mode 100644 platform/ios/core-files.txt delete mode 100644 platform/macos/core-files.txt diff --git a/platform/darwin/src/MGLCluster.h b/platform/darwin/src/MGLCluster.h index a7caf2ddcf8..2b99119b262 100644 --- a/platform/darwin/src/MGLCluster.h +++ b/platform/darwin/src/MGLCluster.h @@ -11,10 +11,11 @@ NS_ASSUME_NONNULL_BEGIN FOUNDATION_EXTERN MGL_EXPORT const NSUInteger MGLClusterIdentifierInvalid; /** - A protocol that (private) feature subclasses (i.e. those already conforming to - the `MGLFeature` protocol) conform to if they are represent clusters. + A protocol that feature subclasses (i.e. those already conforming to + the `MGLFeature` protocol) conform to if they represent clusters. - Currently only subclasses of `MGLPointFeature` support `MGLCluster`. + Currently the only class that conforms to `MGLCluster` is + `MGLPointFeatureCluster` (a subclass of `MGLPointFeature`). To check if a feature is a cluster, check conformity to `MGLCluster`, for example: @@ -31,6 +32,11 @@ FOUNDATION_EXTERN MGL_EXPORT const NSUInteger MGLClusterIdentifierInvalid; throw ExampleError.featureIsNotACluster } + // Currently the only supported class that conforms to `MGLCluster` is + // `MGLPointFeatureCluster` + guard cluster is MGLPointFeatureCluster else { + throw ExampleError.unexpectedFeatureType + } ``` */ MGL_EXPORT diff --git a/platform/darwin/src/MGLFeature.h b/platform/darwin/src/MGLFeature.h index e17b463a7f9..51901d73c06 100644 --- a/platform/darwin/src/MGLFeature.h +++ b/platform/darwin/src/MGLFeature.h @@ -187,13 +187,23 @@ MGL_EXPORT #### Related examples See the Dynamically style interactive points example to learn how to initialize - `MGLPointFeature` objects and add it them your map. + `MGLPointFeature` objects and add them to your map. */ MGL_EXPORT @interface MGLPointFeature : MGLPointAnnotation @end - +/** + An `MGLPointFeatureCluster` object associates a point shape (with an optional + identifier and attributes) and represents a point cluster. + + @see `MGLCluster` + + #### Related examples + See the + Clustering point data example to learn how to initialize + clusters and add them to your map. + */ MGL_EXPORT @interface MGLPointFeatureCluster : MGLPointFeature @end diff --git a/platform/darwin/src/MGLFeature.mm b/platform/darwin/src/MGLFeature.mm index 55700b6b228..e471ea2e98c 100644 --- a/platform/darwin/src/MGLFeature.mm +++ b/platform/darwin/src/MGLFeature.mm @@ -7,7 +7,6 @@ #import "MGLPolygon.h" #import "MGLValueEvaluator.h" -#import "MGLCluster.h" #import "MGLShape_Private.h" #import "MGLPointCollection_Private.h" #import "MGLPolyline_Private.h" @@ -22,8 +21,10 @@ #import #import -static NSString * const MGLClusterIdentifierKey = @"cluster_id"; -static NSString * const MGLClusterCountKey = @"point_count"; +// Cluster constants +static NSString * const MGLClusterIdentifierKey = @"cluster_id"; +static NSString * const MGLClusterCountKey = @"point_count"; +const NSUInteger MGLClusterIdentifierInvalid = NSUIntegerMax; @interface MGLEmptyFeature () @end @@ -98,17 +99,10 @@ - (NSString *)description @end -const NSUInteger MGLClusterIdentifierInvalid = NSUIntegerMax; - @implementation MGLPointFeatureCluster -// If it turns out we need to cluster other classes, then consider moving the -// following MGLCluster methods into free functions, and generate the subclasses -// at runtime - (NSUInteger)clusterIdentifier { - id feature = MGL_OBJC_DYNAMIC_CAST_AS_PROTOCOL(self, MGLFeature); - - NSNumber *clusterNumber = MGL_OBJC_DYNAMIC_CAST([feature attributeForKey:MGLClusterIdentifierKey], NSNumber); + NSNumber *clusterNumber = MGL_OBJC_DYNAMIC_CAST([self attributeForKey:MGLClusterIdentifierKey], NSNumber); MGLAssert(clusterNumber, @"Clusters should have a cluster_id"); if (!clusterNumber) { @@ -122,15 +116,11 @@ - (NSUInteger)clusterIdentifier { } - (NSUInteger)clusterPointCount { - id feature = MGL_OBJC_DYNAMIC_CAST_AS_PROTOCOL(self, MGLFeature); - - NSNumber *count = MGL_OBJC_DYNAMIC_CAST([feature attributeForKey:MGLClusterCountKey], NSNumber); + NSNumber *count = MGL_OBJC_DYNAMIC_CAST([self attributeForKey:MGLClusterCountKey], NSNumber); MGLAssert(count, @"Clusters should have a point_count"); return [count unsignedIntegerValue]; } - - @end @@ -361,12 +351,11 @@ - (NSDictionary *)geoJSONDictionary { template class GeometryEvaluator { private: - mbgl::PropertyMap _properties; + const mbgl::PropertyMap *shared_properties; public: - - GeometryEvaluator(mbgl::PropertyMap properties = {}): - _properties(properties) + GeometryEvaluator(const mbgl::PropertyMap *properties = nullptr): + shared_properties(properties) {} MGLShape * operator()(const mbgl::EmptyGeometry &) const { @@ -377,15 +366,20 @@ - (NSDictionary *)geoJSONDictionary { MGLShape * operator()(const mbgl::Point &geometry) const { Class pointFeatureClass = [MGLPointFeature class]; - auto clusterIt = _properties.find("cluster"); - if (clusterIt != _properties.end()) { - auto clusterValue = clusterIt->second; - if (clusterValue.template is()) { - if (clusterValue.template get()) { - pointFeatureClass = [MGLPointFeatureCluster class]; + // If we're dealing with a cluster, we should change the class type. + // This could be generic and build the subclass at runtime if it turns + // out we need to support more than point clusters. + if (shared_properties) { + auto clusterIt = shared_properties->find("cluster"); + if (clusterIt != shared_properties->end()) { + auto clusterValue = clusterIt->second; + if (clusterValue.template is()) { + if (clusterValue.template get()) { + pointFeatureClass = [MGLPointFeatureCluster class]; + } } } - } + } MGLPointFeature *feature = [[pointFeatureClass alloc] init]; feature.coordinate = toLocationCoordinate2D(geometry); @@ -436,10 +430,7 @@ - (NSDictionary *)geoJSONDictionary { return [MGLShapeCollectionFeature shapeCollectionWithShapes:shapes]; } -private: - -// mbgl::PropertyMap _properties; - +private: static CLLocationCoordinate2D toLocationCoordinate2D(const mbgl::Point &point) { return CLLocationCoordinate2DMake(point.y, point.x); } @@ -508,7 +499,7 @@ static CLLocationCoordinate2D toLocationCoordinate2D(const mbgl::Point &point ValueEvaluator evaluator; attributes[@(pair.first.c_str())] = mbgl::Value::visit(value, evaluator); } - GeometryEvaluator evaluator(feature.properties); + GeometryEvaluator evaluator(&feature.properties); MGLShape *shape = mapbox::geometry::geometry::visit(feature.geometry, evaluator); if (!feature.id.is()) { shape.identifier = mbgl::FeatureIdentifier::visit(feature.id, ValueEvaluator()); diff --git a/platform/darwin/src/MGLShapeSource.h b/platform/darwin/src/MGLShapeSource.h index 2982fda0685..6676cbd02ec 100644 --- a/platform/darwin/src/MGLShapeSource.h +++ b/platform/darwin/src/MGLShapeSource.h @@ -5,7 +5,6 @@ NS_ASSUME_NONNULL_BEGIN @protocol MGLFeature; -//@protocol MGLCluster; @class MGLPointFeature; @class MGLPointFeatureCluster; @class MGLShape; @@ -331,8 +330,7 @@ MGL_EXPORT This method supports pagination; you supply an offset (number of features to skip) and a maximum number of features to return. - @param cluster An object that conforms to the `MGLCluster` protocol. Currently - the only types that can conform are private subclasses of `MGLPointFeature`. + @param cluster An object of type `MGLPointFeatureCluster` (that conforms to the `MGLCluster` protocol). @param offset Number of features to skip. @param limit Maximum number of features to return @@ -343,15 +341,14 @@ MGL_EXPORT /** Returns an array of map features that are the immediate children of the specified cluster *on the next zoom level*. The may include features that also conform to - the `MGLCluster` protocol. + the `MGLCluster` protocol (currently only objects of type `MGLPointFeatureCluster`). - @param cluster An object that conforms to the `MGLCluster` protocol. Currently - the only types that can conform are private subclasses of `MGLPointFeature`. + @param cluster An object of type `MGLPointFeatureCluster` (that conforms to the `MGLCluster` protocol). @return An array of objects that conform to the `MGLFeature` protocol. @note The returned array may contain the `cluster` that was passed in, if the next - zoom level doesn't the zoom level for expanding that cluster. See + zoom level doesn't match the zoom level for expanding that cluster. See `-[MGLShapeSource zoomLevelForExpandingCluster:]`. */ - (NSArray> *)childrenOfCluster:(MGLPointFeatureCluster *)cluster; @@ -359,8 +356,7 @@ MGL_EXPORT /** Returns the zoom level at which the given cluster expands. - @param cluster An object that conforms to the `MGLCluster` protocol. Currently - the only types that can conform are private subclasses of `MGLPointFeature`. + @param cluster An object of type `MGLPointFeatureCluster` (that conforms to the `MGLCluster` protocol). @return Zoom level. This should be >= 0; any negative return value should be considered an error. diff --git a/platform/darwin/src/MGLShapeSource.mm b/platform/darwin/src/MGLShapeSource.mm index ac0f404756c..fc526f98500 100644 --- a/platform/darwin/src/MGLShapeSource.mm +++ b/platform/darwin/src/MGLShapeSource.mm @@ -211,11 +211,9 @@ - (NSString *)description { "supercluster", extension, options); - return extensionValue; } - - (NSArray> *)leavesOfCluster:(MGLPointFeatureCluster *)cluster offset:(NSUInteger)offset limit:(NSUInteger)limit { const std::map options = { { "limit", static_cast(limit) }, diff --git a/platform/darwin/test/MGLCodingTests.mm b/platform/darwin/test/MGLCodingTests.mm index f4e5c8f13e7..c22eae81da2 100644 --- a/platform/darwin/test/MGLCodingTests.mm +++ b/platform/darwin/test/MGLCodingTests.mm @@ -63,8 +63,7 @@ - (void)testPointFeatureCluster { XCTAssertEqualObjects(pointFeature, unarchivedPointFeature); - // Unarchive process should convert to a cluster -// NSString *subclassName = MGLClusterSubclassNameForFeature(pointFeature); + // Unarchive process should ensure we still have a cluster XCTAssert([unarchivedPointFeature isMemberOfClass:[MGLPointFeatureCluster class]]); id cluster = MGL_OBJC_DYNAMIC_CAST_AS_PROTOCOL(unarchivedPointFeature, MGLCluster); @@ -72,13 +71,6 @@ - (void)testPointFeatureCluster { XCTAssert(cluster); XCTAssert(cluster.clusterIdentifier == 456); XCTAssert(cluster.clusterPointCount == 2); - -// // Archiving shouldn't affect -// [NSKeyedArchiver archiveRootObject:unarchivedPointFeature toFile:filePath]; -// MGLPointFeature *unarchivedPointFeature2 = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath]; -// -// XCTAssert([unarchivedPointFeature2 isMemberOfClass:[MGLPointFeatureCluster class]]); -// XCTAssertEqualObjects(pointFeature, unarchivedPointFeature2); } diff --git a/platform/darwin/test/MGLDocumentationExampleTests.swift b/platform/darwin/test/MGLDocumentationExampleTests.swift index 10308619d21..b59d297f978 100644 --- a/platform/darwin/test/MGLDocumentationExampleTests.swift +++ b/platform/darwin/test/MGLDocumentationExampleTests.swift @@ -433,6 +433,12 @@ class MGLDocumentationExampleTests: XCTestCase, MGLMapViewDelegate { throw ExampleError.featureIsNotACluster } + // Currently the only supported class that conforms to `MGLCluster` is + // `MGLPointFeatureCluster` + guard cluster is MGLPointFeatureCluster else { + throw ExampleError.unexpectedFeatureType + } + //#-end-example-code XCTAssert(cluster.clusterIdentifier == 123) diff --git a/platform/ios/core-files.txt b/platform/ios/core-files.txt deleted file mode 100644 index bcc1a55aa81..00000000000 --- a/platform/ios/core-files.txt +++ /dev/null @@ -1,323 +0,0 @@ -# This file is generated. Do not edit. Regenerate this with scripts/generate-cmake-files.js - -# SDK -platform/ios/src/Mapbox.h - -# SDK/Foundation -platform/darwin/src/MGLAccountManager.h -platform/darwin/src/MGLAccountManager.m -platform/darwin/src/MGLAccountManager_Private.h -platform/darwin/src/MGLAttributionInfo.h -platform/darwin/src/MGLAttributionInfo.mm -platform/darwin/src/MGLAttributionInfo_Private.h -platform/darwin/src/MGLFoundation.h -platform/darwin/src/MGLFoundation.mm -platform/darwin/src/MGLFoundation_Private.h -platform/darwin/src/MGLLocationManager.h -platform/darwin/src/MGLLocationManager.m -platform/darwin/src/MGLLocationManager_Private.h -platform/darwin/src/MGLLoggingConfiguration.h -platform/darwin/src/MGLLoggingConfiguration.m -platform/darwin/src/MGLLoggingConfiguration_Private.h -platform/darwin/src/MGLMapCamera.h -platform/darwin/src/MGLMapCamera.mm -platform/darwin/src/MGLMapSnapshotter.h -platform/darwin/src/MGLMapSnapshotter.mm -platform/darwin/src/MGLNetworkConfiguration.h -platform/darwin/src/MGLNetworkConfiguration.m -platform/darwin/src/MGLRendererConfiguration.h -platform/darwin/src/MGLRendererConfiguration.mm -platform/darwin/src/MGLRendererFrontend.h -platform/darwin/src/MGLStyle.h -platform/darwin/src/MGLStyle.mm -platform/darwin/src/MGLStyle_Private.h -platform/darwin/src/MGLTypes.h -platform/darwin/src/MGLTypes.m -platform/darwin/src/MGLValueEvaluator.h - -# SDK/Foundation/Categories -platform/darwin/src/NSArray+MGLAdditions.h -platform/darwin/src/NSArray+MGLAdditions.mm -platform/darwin/src/NSBundle+MGLAdditions.h -platform/darwin/src/NSBundle+MGLAdditions.m -platform/darwin/src/NSComparisonPredicate+MGLAdditions.h -platform/darwin/src/NSComparisonPredicate+MGLAdditions.mm -platform/darwin/src/NSCompoundPredicate+MGLAdditions.h -platform/darwin/src/NSCompoundPredicate+MGLAdditions.mm -platform/darwin/src/NSData+MGLAdditions.h -platform/darwin/src/NSData+MGLAdditions.mm -platform/darwin/src/NSDate+MGLAdditions.h -platform/darwin/src/NSDate+MGLAdditions.mm -platform/darwin/src/NSDictionary+MGLAdditions.h -platform/darwin/src/NSDictionary+MGLAdditions.mm -platform/darwin/src/NSException+MGLAdditions.h -platform/darwin/src/NSExpression+MGLAdditions.h -platform/darwin/src/NSExpression+MGLAdditions.mm -platform/darwin/src/NSExpression+MGLPrivateAdditions.h -platform/darwin/src/NSPredicate+MGLAdditions.h -platform/darwin/src/NSPredicate+MGLAdditions.mm -platform/darwin/src/NSPredicate+MGLPrivateAdditions.h -platform/darwin/src/NSProcessInfo+MGLAdditions.h -platform/darwin/src/NSProcessInfo+MGLAdditions.m -platform/darwin/src/NSString+MGLAdditions.h -platform/darwin/src/NSString+MGLAdditions.m -platform/darwin/src/NSURL+MGLAdditions.h -platform/darwin/src/NSURL+MGLAdditions.m -platform/darwin/src/NSValue+MGLAdditions.h -platform/darwin/src/NSValue+MGLAdditions.m - -# SDK/Foundation/Formatters -platform/darwin/src/MGLClockDirectionFormatter.h -platform/darwin/src/MGLClockDirectionFormatter.m -platform/darwin/src/MGLCompassDirectionFormatter.h -platform/darwin/src/MGLCompassDirectionFormatter.m -platform/darwin/src/MGLCoordinateFormatter.h -platform/darwin/src/MGLCoordinateFormatter.m -platform/darwin/src/MGLDistanceFormatter.h -platform/darwin/src/MGLDistanceFormatter.m - -# SDK/Foundation/Geometry -platform/darwin/src/MGLAnnotation.h -platform/darwin/src/MGLCluster.h -platform/darwin/src/MGLCluster.mm -platform/darwin/src/MGLCluster_Private.h -platform/darwin/src/MGLFeature.h -platform/darwin/src/MGLFeature.mm -platform/darwin/src/MGLFeature_Private.h -platform/darwin/src/MGLGeometry.h -platform/darwin/src/MGLGeometry.mm -platform/darwin/src/MGLGeometry_Private.h -platform/darwin/src/MGLMultiPoint.h -platform/darwin/src/MGLMultiPoint.mm -platform/darwin/src/MGLMultiPoint_Private.h -platform/darwin/src/MGLOverlay.h -platform/darwin/src/MGLPointAnnotation.h -platform/darwin/src/MGLPointAnnotation.mm -platform/darwin/src/MGLPointCollection.h -platform/darwin/src/MGLPointCollection.mm -platform/darwin/src/MGLPointCollection_Private.h -platform/darwin/src/MGLPolygon.h -platform/darwin/src/MGLPolygon.mm -platform/darwin/src/MGLPolygon_Private.h -platform/darwin/src/MGLPolyline.h -platform/darwin/src/MGLPolyline.mm -platform/darwin/src/MGLPolyline_Private.h -platform/darwin/src/MGLShape.h -platform/darwin/src/MGLShape.mm -platform/darwin/src/MGLShapeCollection.h -platform/darwin/src/MGLShapeCollection.mm -platform/darwin/src/MGLShape_Private.h - -# SDK/Foundation/Offline Maps -platform/darwin/src/MGLOfflinePack.h -platform/darwin/src/MGLOfflinePack.mm -platform/darwin/src/MGLOfflinePack_Private.h -platform/darwin/src/MGLOfflineRegion.h -platform/darwin/src/MGLOfflineRegion_Private.h -platform/darwin/src/MGLOfflineStorage.h -platform/darwin/src/MGLOfflineStorage.mm -platform/darwin/src/MGLOfflineStorage_Private.h -platform/darwin/src/MGLShapeOfflineRegion.h -platform/darwin/src/MGLShapeOfflineRegion.mm -platform/darwin/src/MGLShapeOfflineRegion_Private.h -platform/darwin/src/MGLTilePyramidOfflineRegion.h -platform/darwin/src/MGLTilePyramidOfflineRegion.mm -platform/darwin/src/MGLTilePyramidOfflineRegion_Private.h - -# SDK/Foundation/Styling -platform/darwin/src/MGLConversion.h -platform/darwin/src/MGLLight.h -platform/darwin/src/MGLLight.mm -platform/darwin/src/MGLLight_Private.h -platform/darwin/src/MGLStyleValue.h -platform/darwin/src/MGLStyleValue.mm -platform/darwin/src/MGLStyleValue_Private.h - -# SDK/Foundation/Styling/Categories -platform/darwin/src/NSValue+MGLStyleAttributeAdditions.h -platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm - -# SDK/Foundation/Styling/Layers -platform/darwin/src/MGLBackgroundStyleLayer.h -platform/darwin/src/MGLBackgroundStyleLayer.mm -platform/darwin/src/MGLBackgroundStyleLayer_Private.h -platform/darwin/src/MGLCircleStyleLayer.h -platform/darwin/src/MGLCircleStyleLayer.mm -platform/darwin/src/MGLCircleStyleLayer_Private.h -platform/darwin/src/MGLFillExtrusionStyleLayer.h -platform/darwin/src/MGLFillExtrusionStyleLayer.mm -platform/darwin/src/MGLFillExtrusionStyleLayer_Private.h -platform/darwin/src/MGLFillStyleLayer.h -platform/darwin/src/MGLFillStyleLayer.mm -platform/darwin/src/MGLFillStyleLayer_Private.h -platform/darwin/src/MGLForegroundStyleLayer.h -platform/darwin/src/MGLForegroundStyleLayer.mm -platform/darwin/src/MGLHeatmapStyleLayer.h -platform/darwin/src/MGLHeatmapStyleLayer.mm -platform/darwin/src/MGLHeatmapStyleLayer_Private.h -platform/darwin/src/MGLHillshadeStyleLayer.h -platform/darwin/src/MGLHillshadeStyleLayer.mm -platform/darwin/src/MGLHillshadeStyleLayer_Private.h -platform/darwin/src/MGLLineStyleLayer.h -platform/darwin/src/MGLLineStyleLayer.mm -platform/darwin/src/MGLLineStyleLayer_Private.h -platform/darwin/src/MGLOpenGLStyleLayer.h -platform/darwin/src/MGLOpenGLStyleLayer.mm -platform/darwin/src/MGLOpenGLStyleLayer_Private.h -platform/darwin/src/MGLRasterStyleLayer.h -platform/darwin/src/MGLRasterStyleLayer.mm -platform/darwin/src/MGLRasterStyleLayer_Private.h -platform/darwin/src/MGLStyleLayer.h -platform/darwin/src/MGLStyleLayer.mm -platform/darwin/src/MGLStyleLayerManager.h -platform/darwin/src/MGLStyleLayerManager.mm -platform/darwin/src/MGLStyleLayer_Private.h -platform/darwin/src/MGLSymbolStyleLayer.h -platform/darwin/src/MGLSymbolStyleLayer.mm -platform/darwin/src/MGLSymbolStyleLayer_Private.h -platform/darwin/src/MGLVectorStyleLayer.h -platform/darwin/src/MGLVectorStyleLayer.m - -# SDK/Foundation/Styling/Sources -platform/darwin/src/MGLComputedShapeSource.h -platform/darwin/src/MGLComputedShapeSource.mm -platform/darwin/src/MGLComputedShapeSource_Private.h -platform/darwin/src/MGLImageSource.h -platform/darwin/src/MGLImageSource.mm -platform/darwin/src/MGLRasterDEMSource.h -platform/darwin/src/MGLRasterDEMSource.mm -platform/darwin/src/MGLRasterTileSource.h -platform/darwin/src/MGLRasterTileSource.mm -platform/darwin/src/MGLRasterTileSource_Private.h -platform/darwin/src/MGLShapeSource.h -platform/darwin/src/MGLShapeSource.mm -platform/darwin/src/MGLShapeSource_Private.h -platform/darwin/src/MGLSource.h -platform/darwin/src/MGLSource.mm -platform/darwin/src/MGLSource_Private.h -platform/darwin/src/MGLTileSource.h -platform/darwin/src/MGLTileSource.mm -platform/darwin/src/MGLTileSource_Private.h -platform/darwin/src/MGLVectorTileSource.h -platform/darwin/src/MGLVectorTileSource.mm -platform/darwin/src/MGLVectorTileSource_Private.h - -# SDK/Kit -platform/ios/src/MGLCameraChangeReason.h -platform/ios/src/MGLMapAccessibilityElement.h -platform/ios/src/MGLMapAccessibilityElement.mm -platform/ios/src/MGLMapView+IBAdditions.h -platform/ios/src/MGLMapView.h -platform/ios/src/MGLMapView.mm -platform/ios/src/MGLMapViewDelegate.h -platform/ios/src/MGLMapView_Private.h - -# SDK/Kit/Annotations -platform/ios/src/MGLAnnotationContainerView.h -platform/ios/src/MGLAnnotationContainerView.m -platform/ios/src/MGLAnnotationContainerView_Private.h -platform/ios/src/MGLAnnotationImage.h -platform/ios/src/MGLAnnotationImage.m -platform/ios/src/MGLAnnotationImage_Private.h -platform/ios/src/MGLAnnotationView.h -platform/ios/src/MGLAnnotationView.mm -platform/ios/src/MGLAnnotationView_Private.h -platform/ios/src/MGLCalloutView.h -platform/ios/src/MGLCompactCalloutView.h -platform/ios/src/MGLCompactCalloutView.m -platform/ios/src/MGLFaux3DUserLocationAnnotationView.h -platform/ios/src/MGLFaux3DUserLocationAnnotationView.m -platform/ios/src/MGLUserLocation.h -platform/ios/src/MGLUserLocation.m -platform/ios/src/MGLUserLocationAnnotationView.h -platform/ios/src/MGLUserLocationAnnotationView.m -platform/ios/src/MGLUserLocationAnnotationView_Private.h -platform/ios/src/MGLUserLocationHeadingArrowLayer.h -platform/ios/src/MGLUserLocationHeadingArrowLayer.m -platform/ios/src/MGLUserLocationHeadingBeamLayer.h -platform/ios/src/MGLUserLocationHeadingBeamLayer.m -platform/ios/src/MGLUserLocationHeadingIndicator.h -platform/ios/src/MGLUserLocation_Private.h - -# SDK/Kit/Categories -platform/darwin/src/NSCoder+MGLAdditions.h -platform/darwin/src/NSCoder+MGLAdditions.mm -platform/ios/src/NSOrthography+MGLAdditions.h -platform/ios/src/NSOrthography+MGLAdditions.m -platform/ios/src/UIColor+MGLAdditions.h -platform/ios/src/UIColor+MGLAdditions.mm -platform/ios/src/UIDevice+MGLAdditions.h -platform/ios/src/UIDevice+MGLAdditions.m -platform/ios/src/UIImage+MGLAdditions.h -platform/ios/src/UIImage+MGLAdditions.mm -platform/ios/src/UIViewController+MGLAdditions.h -platform/ios/src/UIViewController+MGLAdditions.m - -# SDK/Kit/SMCalloutView -platform/ios/vendor/SMCalloutView/SMCalloutView.h -platform/ios/vendor/SMCalloutView/SMCalloutView.m - -# SDK/Kit/Telemetry -platform/ios/src/MGLTelemetryConfig.h -platform/ios/src/MGLTelemetryConfig.m - -# SDK/Kit/Telemetry/Development -platform/ios/src/MGLSDKUpdateChecker.h -platform/ios/src/MGLSDKUpdateChecker.mm - -# SDK/Kit/Telemetry/Runtime -platform/ios/src/MGLMapboxEvents.h -platform/ios/src/MGLMapboxEvents.m -platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/CLLocation+MMEMobileEvents.m -platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMEAPIClient.m -platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMECategoryLoader.m -platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMECommonEventData.m -platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMEConfigurator.m -platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMEConstants.m -platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMEDependencyManager.m -platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMEDispatchManager.m -platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMEEvent.m -platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMEEventLogReportViewController.m -platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMEEventLogger.m -platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMEEventsConfiguration.m -platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMEEventsManager.m -platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMEHashProvider.m -platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMELocationManager.m -platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMEMetrics.m -platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMEMetricsManager.m -platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMENSDateWrapper.m -platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMENSURLSessionWrapper.m -platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMETimerManager.m -platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMETrustKitProvider.m -platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMETypes.m -platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMEUIApplicationWrapper.m -platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMEUINavigation.m -platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/MMEUniqueIdentifier.m -platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/NSData+MMEGZIP.m - -# SDK/Kit/Telemetry/Runtime/Reachability -platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/Reachability/MMEReachability.m - -# SDK/Kit/Telemetry/Runtime/TrustKit -platform/ios/vendor/mapbox-events-ios/vendor/TrustKit/TSKPinningValidator.m -platform/ios/vendor/mapbox-events-ios/vendor/TrustKit/TSKPinningValidatorResult.m -platform/ios/vendor/mapbox-events-ios/vendor/TrustKit/TSKTrustKitConfig.m -platform/ios/vendor/mapbox-events-ios/vendor/TrustKit/TrustKit.m -platform/ios/vendor/mapbox-events-ios/vendor/TrustKit/configuration_utils.m -platform/ios/vendor/mapbox-events-ios/vendor/TrustKit/parse_configuration.m - -# SDK/Kit/Telemetry/Runtime/TrustKit/Pinning -platform/ios/vendor/mapbox-events-ios/vendor/TrustKit/Pinning/TSKSPKIHashCache.m -platform/ios/vendor/mapbox-events-ios/vendor/TrustKit/Pinning/ssl_pin_verifier.m - -# SDK/Kit/Telemetry/Runtime/TrustKit/Reporting -platform/ios/vendor/mapbox-events-ios/vendor/TrustKit/Reporting/TSKBackgroundReporter.m -platform/ios/vendor/mapbox-events-ios/vendor/TrustKit/Reporting/TSKPinFailureReport.m -platform/ios/vendor/mapbox-events-ios/vendor/TrustKit/Reporting/TSKReportsRateLimiter.m -platform/ios/vendor/mapbox-events-ios/vendor/TrustKit/Reporting/reporting_utils.m -platform/ios/vendor/mapbox-events-ios/vendor/TrustKit/Reporting/vendor_identifier.m - -# SDK/Kit/Views -platform/ios/src/MGLScaleBar.h -platform/ios/src/MGLScaleBar.mm - diff --git a/platform/ios/sdk-files.json b/platform/ios/sdk-files.json index 31eebb0980b..0bf09e48fa1 100644 --- a/platform/ios/sdk-files.json +++ b/platform/ios/sdk-files.json @@ -136,6 +136,7 @@ "MGLFillStyleLayer.h": "platform/darwin/src/MGLFillStyleLayer.h", "MGLAnnotationImage.h": "platform/ios/src/MGLAnnotationImage.h", "MGLHillshadeStyleLayer.h": "platform/darwin/src/MGLHillshadeStyleLayer.h", + "MGLCluster.h": "platform/darwin/src/MGLCluster.h", "MGLClockDirectionFormatter.h": "platform/darwin/src/MGLClockDirectionFormatter.h", "MGLSymbolStyleLayer.h": "platform/darwin/src/MGLSymbolStyleLayer.h", "MGLAttributionInfo.h": "platform/darwin/src/MGLAttributionInfo.h", diff --git a/platform/macos/core-files.txt b/platform/macos/core-files.txt deleted file mode 100644 index 25a8e869381..00000000000 --- a/platform/macos/core-files.txt +++ /dev/null @@ -1,224 +0,0 @@ -# This file is generated. Do not edit. Regenerate this with scripts/generate-cmake-files.js - -# SDK -platform/macos/src/Mapbox.h - -# SDK/Foundation -platform/darwin/src/MGLAccountManager.h -platform/darwin/src/MGLAccountManager.m -platform/darwin/src/MGLAccountManager_Private.h -platform/darwin/src/MGLAttributionInfo.h -platform/darwin/src/MGLAttributionInfo.mm -platform/darwin/src/MGLAttributionInfo_Private.h -platform/darwin/src/MGLFoundation.h -platform/darwin/src/MGLFoundation.mm -platform/darwin/src/MGLFoundation_Private.h -platform/darwin/src/MGLLoggingConfiguration.h -platform/darwin/src/MGLLoggingConfiguration.m -platform/darwin/src/MGLLoggingConfiguration_Private.h -platform/darwin/src/MGLMapCamera.h -platform/darwin/src/MGLMapCamera.mm -platform/darwin/src/MGLMapSnapshotter.h -platform/darwin/src/MGLMapSnapshotter.mm -platform/darwin/src/MGLNetworkConfiguration.h -platform/darwin/src/MGLNetworkConfiguration.m -platform/darwin/src/MGLRendererConfiguration.h -platform/darwin/src/MGLRendererConfiguration.mm -platform/darwin/src/MGLRendererFrontend.h -platform/darwin/src/MGLStyle.h -platform/darwin/src/MGLStyle.mm -platform/darwin/src/MGLStyle_Private.h -platform/darwin/src/MGLTypes.h -platform/darwin/src/MGLTypes.m -platform/darwin/src/MGLValueEvaluator.h - -# SDK/Foundation/Categories -platform/darwin/src/NSArray+MGLAdditions.h -platform/darwin/src/NSArray+MGLAdditions.mm -platform/darwin/src/NSBundle+MGLAdditions.h -platform/darwin/src/NSBundle+MGLAdditions.m -platform/darwin/src/NSCoder+MGLAdditions.h -platform/darwin/src/NSCoder+MGLAdditions.mm -platform/darwin/src/NSComparisonPredicate+MGLAdditions.h -platform/darwin/src/NSComparisonPredicate+MGLAdditions.mm -platform/darwin/src/NSCompoundPredicate+MGLAdditions.h -platform/darwin/src/NSCompoundPredicate+MGLAdditions.mm -platform/darwin/src/NSDate+MGLAdditions.h -platform/darwin/src/NSDate+MGLAdditions.mm -platform/darwin/src/NSDictionary+MGLAdditions.h -platform/darwin/src/NSDictionary+MGLAdditions.mm -platform/darwin/src/NSException+MGLAdditions.h -platform/darwin/src/NSExpression+MGLAdditions.h -platform/darwin/src/NSExpression+MGLAdditions.mm -platform/darwin/src/NSExpression+MGLPrivateAdditions.h -platform/darwin/src/NSPredicate+MGLAdditions.h -platform/darwin/src/NSPredicate+MGLAdditions.mm -platform/darwin/src/NSPredicate+MGLPrivateAdditions.h -platform/darwin/src/NSProcessInfo+MGLAdditions.h -platform/darwin/src/NSProcessInfo+MGLAdditions.m -platform/darwin/src/NSString+MGLAdditions.h -platform/darwin/src/NSString+MGLAdditions.m -platform/darwin/src/NSURL+MGLAdditions.h -platform/darwin/src/NSURL+MGLAdditions.m -platform/darwin/src/NSValue+MGLAdditions.h -platform/darwin/src/NSValue+MGLAdditions.m - -# SDK/Foundation/Formatters -platform/darwin/src/MGLClockDirectionFormatter.h -platform/darwin/src/MGLClockDirectionFormatter.m -platform/darwin/src/MGLCompassDirectionFormatter.h -platform/darwin/src/MGLCompassDirectionFormatter.m -platform/darwin/src/MGLCoordinateFormatter.h -platform/darwin/src/MGLCoordinateFormatter.m -platform/darwin/src/MGLDistanceFormatter.h -platform/darwin/src/MGLDistanceFormatter.m - -# SDK/Foundation/Geometry -platform/darwin/src/MGLAnnotation.h -platform/darwin/src/MGLCluster.h -platform/darwin/src/MGLCluster.mm -platform/darwin/src/MGLCluster_Private.h -platform/darwin/src/MGLFeature.h -platform/darwin/src/MGLFeature.mm -platform/darwin/src/MGLFeature_Private.h -platform/darwin/src/MGLGeometry.h -platform/darwin/src/MGLGeometry.mm -platform/darwin/src/MGLGeometry_Private.h -platform/darwin/src/MGLMultiPoint.h -platform/darwin/src/MGLMultiPoint.mm -platform/darwin/src/MGLMultiPoint_Private.h -platform/darwin/src/MGLOverlay.h -platform/darwin/src/MGLPointAnnotation.h -platform/darwin/src/MGLPointAnnotation.mm -platform/darwin/src/MGLPointCollection.h -platform/darwin/src/MGLPointCollection.mm -platform/darwin/src/MGLPointCollection_Private.h -platform/darwin/src/MGLPolygon.h -platform/darwin/src/MGLPolygon.mm -platform/darwin/src/MGLPolygon_Private.h -platform/darwin/src/MGLPolyline.h -platform/darwin/src/MGLPolyline.mm -platform/darwin/src/MGLPolyline_Private.h -platform/darwin/src/MGLShape.h -platform/darwin/src/MGLShape.mm -platform/darwin/src/MGLShapeCollection.h -platform/darwin/src/MGLShapeCollection.mm -platform/darwin/src/MGLShape_Private.h - -# SDK/Foundation/Offline Maps -platform/darwin/src/MGLOfflinePack.h -platform/darwin/src/MGLOfflinePack.mm -platform/darwin/src/MGLOfflinePack_Private.h -platform/darwin/src/MGLOfflineRegion.h -platform/darwin/src/MGLOfflineRegion_Private.h -platform/darwin/src/MGLOfflineStorage.h -platform/darwin/src/MGLOfflineStorage.mm -platform/darwin/src/MGLOfflineStorage_Private.h -platform/darwin/src/MGLShapeOfflineRegion.h -platform/darwin/src/MGLShapeOfflineRegion.mm -platform/darwin/src/MGLShapeOfflineRegion_Private.h -platform/darwin/src/MGLTilePyramidOfflineRegion.h -platform/darwin/src/MGLTilePyramidOfflineRegion.mm -platform/darwin/src/MGLTilePyramidOfflineRegion_Private.h - -# SDK/Foundation/Styling -platform/darwin/src/MGLConversion.h -platform/darwin/src/MGLLight.h -platform/darwin/src/MGLLight.mm -platform/darwin/src/MGLLight_Private.h -platform/darwin/src/MGLStyleValue.h -platform/darwin/src/MGLStyleValue.mm -platform/darwin/src/MGLStyleValue_Private.h - -# SDK/Foundation/Styling/Categories -platform/darwin/src/NSValue+MGLStyleAttributeAdditions.h -platform/darwin/src/NSValue+MGLStyleAttributeAdditions.mm - -# SDK/Foundation/Styling/Layers -platform/darwin/src/MGLBackgroundStyleLayer.h -platform/darwin/src/MGLBackgroundStyleLayer.mm -platform/darwin/src/MGLBackgroundStyleLayer_Private.h -platform/darwin/src/MGLCircleStyleLayer.h -platform/darwin/src/MGLCircleStyleLayer.mm -platform/darwin/src/MGLCircleStyleLayer_Private.h -platform/darwin/src/MGLFillExtrusionStyleLayer.h -platform/darwin/src/MGLFillExtrusionStyleLayer.mm -platform/darwin/src/MGLFillExtrusionStyleLayer_Private.h -platform/darwin/src/MGLFillStyleLayer.h -platform/darwin/src/MGLFillStyleLayer.mm -platform/darwin/src/MGLFillStyleLayer_Private.h -platform/darwin/src/MGLForegroundStyleLayer.h -platform/darwin/src/MGLForegroundStyleLayer.mm -platform/darwin/src/MGLHeatmapStyleLayer.h -platform/darwin/src/MGLHeatmapStyleLayer.mm -platform/darwin/src/MGLHeatmapStyleLayer_Private.h -platform/darwin/src/MGLHillshadeStyleLayer.h -platform/darwin/src/MGLHillshadeStyleLayer.mm -platform/darwin/src/MGLHillshadeStyleLayer_Private.h -platform/darwin/src/MGLLineStyleLayer.h -platform/darwin/src/MGLLineStyleLayer.mm -platform/darwin/src/MGLLineStyleLayer_Private.h -platform/darwin/src/MGLOpenGLStyleLayer.h -platform/darwin/src/MGLOpenGLStyleLayer.mm -platform/darwin/src/MGLOpenGLStyleLayer_Private.h -platform/darwin/src/MGLRasterStyleLayer.h -platform/darwin/src/MGLRasterStyleLayer.mm -platform/darwin/src/MGLRasterStyleLayer_Private.h -platform/darwin/src/MGLStyleLayer.h -platform/darwin/src/MGLStyleLayer.mm -platform/darwin/src/MGLStyleLayerManager.h -platform/darwin/src/MGLStyleLayerManager.mm -platform/darwin/src/MGLStyleLayer_Private.h -platform/darwin/src/MGLSymbolStyleLayer.h -platform/darwin/src/MGLSymbolStyleLayer.mm -platform/darwin/src/MGLSymbolStyleLayer_Private.h -platform/darwin/src/MGLVectorStyleLayer.h -platform/darwin/src/MGLVectorStyleLayer.m - -# SDK/Foundation/Styling/Sources -platform/darwin/src/MGLComputedShapeSource.h -platform/darwin/src/MGLComputedShapeSource.mm -platform/darwin/src/MGLComputedShapeSource_Private.h -platform/darwin/src/MGLImageSource.h -platform/darwin/src/MGLImageSource.mm -platform/darwin/src/MGLRasterDEMSource.h -platform/darwin/src/MGLRasterDEMSource.mm -platform/darwin/src/MGLRasterTileSource.h -platform/darwin/src/MGLRasterTileSource.mm -platform/darwin/src/MGLRasterTileSource_Private.h -platform/darwin/src/MGLShapeSource.h -platform/darwin/src/MGLShapeSource.mm -platform/darwin/src/MGLShapeSource_Private.h -platform/darwin/src/MGLSource.h -platform/darwin/src/MGLSource.mm -platform/darwin/src/MGLSource_Private.h -platform/darwin/src/MGLTileSource.h -platform/darwin/src/MGLTileSource.mm -platform/darwin/src/MGLTileSource_Private.h -platform/darwin/src/MGLVectorTileSource.h -platform/darwin/src/MGLVectorTileSource.mm -platform/darwin/src/MGLVectorTileSource_Private.h - -# SDK/Kit -platform/macos/src/MGLAnnotationImage.h -platform/macos/src/MGLAnnotationImage.m -platform/macos/src/MGLAnnotationImage_Private.h -platform/macos/src/MGLAttributionButton.h -platform/macos/src/MGLAttributionButton.mm -platform/macos/src/MGLCompassCell.h -platform/macos/src/MGLCompassCell.m -platform/macos/src/MGLMapView+IBAdditions.h -platform/macos/src/MGLMapView+IBAdditions.mm -platform/macos/src/MGLMapView.h -platform/macos/src/MGLMapView.mm -platform/macos/src/MGLMapViewDelegate.h -platform/macos/src/MGLMapView_Private.h -platform/macos/src/MGLOpenGLLayer.h -platform/macos/src/MGLOpenGLLayer.mm - -# SDK/Kit/Categories -platform/macos/src/NSColor+MGLAdditions.h -platform/macos/src/NSColor+MGLAdditions.mm -platform/macos/src/NSImage+MGLAdditions.h -platform/macos/src/NSImage+MGLAdditions.mm - diff --git a/platform/macos/sdk-files.json b/platform/macos/sdk-files.json index 884a9252171..a77e157154b 100644 --- a/platform/macos/sdk-files.json +++ b/platform/macos/sdk-files.json @@ -51,6 +51,7 @@ "platform/darwin/src/MGLPolygon.mm", "platform/darwin/src/MGLDistanceFormatter.m", "platform/darwin/src/NSProcessInfo+MGLAdditions.m", + "platform/darwin/src/MGLCluster.mm", "platform/darwin/src/MGLFillExtrusionStyleLayer.mm", "platform/darwin/src/MGLOfflineStorage.mm", "platform/darwin/src/NSURL+MGLAdditions.m", @@ -118,6 +119,7 @@ "MGLTilePyramidOfflineRegion.h": "platform/darwin/src/MGLTilePyramidOfflineRegion.h", "NSValue+MGLAdditions.h": "platform/darwin/src/NSValue+MGLAdditions.h", "MGLMapViewDelegate.h": "platform/macos/src/MGLMapViewDelegate.h", + "MGLCluster.h": "platform/darwin/src/MGLCluster.h", "MGLFeature.h": "platform/darwin/src/MGLFeature.h", "MGLStyleLayer.h": "platform/darwin/src/MGLStyleLayer.h", "MGLGeometry.h": "platform/darwin/src/MGLGeometry.h", @@ -165,6 +167,7 @@ "MGLAccountManager_Private.h": "platform/darwin/src/MGLAccountManager_Private.h", "MGLComputedShapeSource_Private.h": "platform/darwin/src/MGLComputedShapeSource_Private.h", "NSException+MGLAdditions.h": "platform/darwin/src/NSException+MGLAdditions.h", + "MGLCluster_Private.h": "platform/darwin/src/MGLCluster_Private.h", "MGLTileSource_Private.h": "platform/darwin/src/MGLTileSource_Private.h", "NSExpression+MGLPrivateAdditions.h": "platform/darwin/src/NSExpression+MGLPrivateAdditions.h", "NSCompoundPredicate+MGLAdditions.h": "platform/darwin/src/NSCompoundPredicate+MGLAdditions.h", From 172629643d3c252c75b2a13eab6612f2139f5e87 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Sat, 12 Jan 2019 14:42:35 -0500 Subject: [PATCH 24/29] Updated change logs --- platform/ios/CHANGELOG.md | 50 +++++++++++++++++++++++++++++-------- platform/macos/CHANGELOG.md | 30 +++++++++++++++++----- 2 files changed, 64 insertions(+), 16 deletions(-) diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index a8099fa7293..bcd54800c81 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -2,22 +2,52 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONTRIBUTING.md](../../CONTRIBUTING.md) to get started. -## master -* `MGLMapSnapshotter` now follows "MGLIdeographicFontFamilyName" app setting to reduce font data usage while snapshotting CJK maps [#13427](https://github.com/mapbox/mapbox-gl-native/pull/13427) +## 4.8.0 -## 4.7.0 +* Added an `MGLStyle.performsPlacementTransitions` property to control how long it takes for colliding labels to fade out. ([#13565](https://github.com/mapbox/mapbox-gl-native/pull/13565)) +* Fixed a crash when casting large numbers in `NSExpression`. ([#13580](https://github.com/mapbox/mapbox-gl-native/pull/13580)) +* Fixed a bug where the `animated` parameter to `-[MGLMapView selectAnnotation:animated:]` was being ignored. ([#13689](https://github.com/mapbox/mapbox-gl-native/pull/13689)) +* Reinstates version 11 as the default Mapbox Streets style (as introduced in 4.7.0). ([#13690](https://github.com/mapbox/mapbox-gl-native/pull/13690)) +* Added the `-[MGLShapeSource leavesOfCluster:offset:limit:]`, `-[MGLShapeSource childrenOfCluster:]`, `-[MGLShapeSource zoomLevelForExpandingCluster:]` methods for inspecting a cluster in an `MGLShapeSource`s created with the `MGLShapeSourceOptionClustered` option. Feature querying now returns clusters represented by `MGLPointFeatureCluster` objects (that conform to the `MGLCluster` protocol). ([#12952](https://github.com/mapbox/mapbox-gl-native/pull/12952) + + +## 4.7.1 - December 21, 2018 + +### Styles and rendering + +* Reverts the ability for `MGLMapView`, `MGLShapeOfflineRegion`, and `MGLTilePyramidOfflineRegion` to use version 11 of the Mapbox Streets style. ([#13650](https://github.com/mapbox/mapbox-gl-native/pull/13650)) +* Reverts the ability for convenience methods on `MGLStyle` such as `MGLStyle.lightStyleURL`, to use version 11 of the Mapbox Streets style. ([#13650](https://github.com/mapbox/mapbox-gl-native/pull/13650)) + +## 4.7.0 - December 18, 2018 + +### Packaging + +* Added the `Mapbox-iOS-SDK-stripped` build flavor, featuring fewer debug symbols. Regular framework binaries are no longer stripped of debug symbols and the `Mapbox-iOS-SDK-symbols` build has been retired. ([#13504](https://github.com/mapbox/mapbox-gl-native/pull/13504)) +* This SDK’s dynamic framework now has a bundle identifier of `com.mapbox.Mapbox`. ([#12857](https://github.com/mapbox/mapbox-gl-native/pull/12857)) +* `MGLMapView`, `MGLShapeOfflineRegion`, and `MGLTilePyramidOfflineRegion` now default to version 11 of the Mapbox Streets style. Similarly, several class properties of `MGLStyle`, such as `MGLStyle.lightStyleURL`, have been updated to return URLs to new versions of their respective styles. ([#13585](https://github.com/mapbox/mapbox-gl-native/pull/13585)) + +### Styles and rendering * Fixed an issue where the `{prefix}` token in tile URL templates was evaluated incorrectly when requesting a source’s tiles. ([#13429](https://github.com/mapbox/mapbox-gl-native/pull/13429)) +* Added an `-[MGLStyle removeSource:error:]` method that returns a descriptive error if the style fails to remove the source, whereas `-[MGLStyle removeSource:]` fails silently. ([#13399](https://github.com/mapbox/mapbox-gl-native/pull/13399)) +* Added the `MGLFillExtrusionStyleLayer.fillExtrusionHasVerticalGradient` property. ([#13463](https://github.com/mapbox/mapbox-gl-native/pull/13463)) +* Added support for setting `MGLCollisionBehaviorPre4_0` in `NSUserDefaults`. ([#13426](https://github.com/mapbox/mapbox-gl-native/pull/13426)) +* `-[MGLStyle localizeLabelsIntoLocale:]` and `-[NSExpression(MGLAdditions) mgl_expressionLocalizedIntoLocale:]` can automatically localize styles that use version 8 of the Mapbox Streets source. ([#13481](https://github.com/mapbox/mapbox-gl-native/pull/13481)) +* Fixed symbol flickering during instantaneous transitions. ([#13535](https://github.com/mapbox/mapbox-gl-native/pull/13535)) +* Fixed a crash when specifying `MGLShapeSourceOptionLineDistanceMetrics` when creating an `MGLShapeSource`. ([#13543](https://github.com/mapbox/mapbox-gl-native/pull/13543)) + +### Map snapshots + +* `MGLMapSnapshotter` now respects the `MGLIdeographicFontFamilyName` key in Info.plist, which reduces bandwidth consumption when snapshotting regions that contain Chinese or Japanese characters. ([#13427](https://github.com/mapbox/mapbox-gl-native/pull/13427)) +* Fixed a sporadic crash when using `MGLMapSnapshotter`. ([#13300](https://github.com/mapbox/mapbox-gl-native/pull/13300)) + +### Other changes + +* Modified the behavior of the map view so that programmatic camera transitions can no longer be interrupted by user interaction when `MGLMapView.zoomEnabled`, `MGLMapView.rotateEnabled`, `MGLMapView.scrollEnabled`, and `MGLMapView.pitchEnabled` are set to false. ([#13362](https://github.com/mapbox/mapbox-gl-native/pull/13362)) * Renamed `-[MGLOfflineStorage putResourceWithUrl:data:modified:expires:etag:mustRevalidate:]` to `-[MGLOfflineStorage preloadData:forURL:modificationDate:expirationDate:eTag:mustRevalidate:]`. ([#13318](https://github.com/mapbox/mapbox-gl-native/pull/13318)) -* Fixed sporadic crash when using `MGLMapSnapshotter`. ([#13300](https://github.com/mapbox/mapbox-gl-native/pull/13300)) +* Points of interest have clearer, localized VoiceOver hints in styles that use version 8 of the Mapbox Streets source. ([#13525](https://github.com/mapbox/mapbox-gl-native/pull/13525)) * Added `MGLLoggingConfiguration` and `MGLLoggingBlockHandler` that handle error and fault events produced by the SDK. ([#13235](https://github.com/mapbox/mapbox-gl-native/pull/13235)) -* This SDK’s dynamic framework now has a bundle identifier of `com.mapbox.Mapbox`. ([#12857](https://github.com/mapbox/mapbox-gl-native/pull/12857)) -* Modified the behavior of the map view so that programmatic camera transitions can no longer be interrupted by user interaction when `MGLMapView.zoomEnabled`, `MGLMapView.rotateEnabled`, `MGLMapView.scrollEnabled`, and `MGLMapView.pitchEnabled` are set to false. ([#13362](https://github.com/mapbox/mapbox-gl-native/pull/13362)) * Fixed random crashes during app termination. ([#13367](https://github.com/mapbox/mapbox-gl-native/pull/13367)) -* Added `-[MGLStyle removeSource:error:]` that returns a `BOOL` indicating success (and an optional `NSError` in case of failure). ([#13399](https://github.com/mapbox/mapbox-gl-native/pull/13399)) -* Added support for setting `MGLCollisionBehaviorPre4_0` in `NSUserDefaults`. ([#13426](https://github.com/mapbox/mapbox-gl-native/pull/13426)) -* Improved support for feature clusters by adding `-[MGLShapeSource leavesOfCluster:offset:limit:]`, `-[MGLShapeSource childrenOfCluster:]`, `-[MGLShapeSource zoomLevelForExpandingCluster:]` and the associated `MGLCluster` protocol. Private subclasses of `MGLPointFeature` will conform to this new protocol if the underlying feature represents a cluster. ([#12952](https://github.com/mapbox/mapbox-gl-native/pull/12952)) - ## 4.6.0 - November 7, 2018 diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md index d47f2b30d5a..28ff0fc453c 100644 --- a/platform/macos/CHANGELOG.md +++ b/platform/macos/CHANGELOG.md @@ -2,17 +2,35 @@ ## master -* `MGLMapSnapshotter` now follows "MGLIdeographicFontFamilyName" app setting to reduce font data usage while snapshotting CJK maps [#13427](https://github.com/mapbox/mapbox-gl-native/pull/13427) +* Added an `MGLStyle.performsPlacementTransitions` property to control how long it takes for colliding labels to fade out. ([#13565](https://github.com/mapbox/mapbox-gl-native/pull/13565)) +* Fixed a crash when casting large numbers in `NSExpression`. ([#13580](https://github.com/mapbox/mapbox-gl-native/pull/13580)) +* Added the `-[MGLShapeSource leavesOfCluster:offset:limit:]`, `-[MGLShapeSource childrenOfCluster:]`, `-[MGLShapeSource zoomLevelForExpandingCluster:]` methods for inspecting a cluster in an `MGLShapeSource`s created with the `MGLShapeSourceOptionClustered` option. Feature querying now returns clusters represented by `MGLPointFeatureCluster` objects (that conform to the `MGLCluster` protocol). ([#12952](https://github.com/mapbox/mapbox-gl-native/pull/12952) + + +## 0.13.0 - December 20, 2018 + +### Packaging + +* This SDK’s dynamic framework now has a bundle identifier of `com.mapbox.Mapbox`. ([#12857](https://github.com/mapbox/mapbox-gl-native/pull/12857)) +* `MGLMapView`, `MGLShapeOfflineRegion`, and `MGLTilePyramidOfflineRegion` now default to version 11 of the Mapbox Streets style. Similarly, several class properties of `MGLStyle`, such as `MGLStyle.lightStyleURL`, have been updated to return URLs to new versions of their respective styles. ([#13585](https://github.com/mapbox/mapbox-gl-native/pull/13585)) + +### Styles and rendering + * Fixed an issue where the `{prefix}` token in tile URL templates was evaluated incorrectly when requesting a source’s tiles. ([#13429](https://github.com/mapbox/mapbox-gl-native/pull/13429)) -* Added `-[MGLStyle removeSource:error:]` that returns a `BOOL` indicating success (and an optional `NSError` in case of failure). ([#13399](https://github.com/mapbox/mapbox-gl-native/pull/13399)) +* Added an `-[MGLStyle removeSource:error:]` method that returns a descriptive error if the style fails to remove the source, whereas `-[MGLStyle removeSource:]` fails silently. ([#13399](https://github.com/mapbox/mapbox-gl-native/pull/13399)) +* Added the `MGLFillExtrusionStyleLayer.fillExtrusionHasVerticalGradient` property. ([#13463](https://github.com/mapbox/mapbox-gl-native/pull/13463)) * Added support for setting `MGLCollisionBehaviorPre4_0` in `NSUserDefaults`. ([#13426](https://github.com/mapbox/mapbox-gl-native/pull/13426)) -* Improved support for feature clusters by adding `-[MGLShapeSource leavesOfCluster:offset:limit:]`, `-[MGLShapeSource childrenOfCluster:]`, `-[MGLShapeSource zoomLevelForExpandingCluster:]` and the associated `MGLCluster` protocol. Private subclasses of `MGLPointFeature` will conform to this new protocol if the underlying feature represents a cluster. ([#12952](https://github.com/mapbox/mapbox-gl-native/pull/12952)) - +* `-[MGLStyle localizeLabelsIntoLocale:]` and `-[NSExpression(MGLAdditions) mgl_expressionLocalizedIntoLocale:]` can automatically localize styles that use version 8 of the Mapbox Streets source. ([#13481](https://github.com/mapbox/mapbox-gl-native/pull/13481)) +* Fixed symbol flickering during instantaneous transitions. ([#13535](https://github.com/mapbox/mapbox-gl-native/pull/13535)) +* Fixed a crash when specifying `MGLShapeSourceOptionLineDistanceMetrics` when creating an `MGLShapeSource`. ([#13543](https://github.com/mapbox/mapbox-gl-native/pull/13543)) -## 0.12.0 - November 8, 2018 +### Other changes * Renamed `-[MGLOfflineStorage putResourceWithUrl:data:modified:expires:etag:mustRevalidate:]` to `-[MGLOfflineStorage preloadData:forURL:modificationDate:expirationDate:eTag:mustRevalidate:]`. ([#13318](https://github.com/mapbox/mapbox-gl-native/pull/13318)) -* This SDK’s dynamic framework now has a bundle identifier of `com.mapbox.Mapbox`. ([#12857](https://github.com/mapbox/mapbox-gl-native/pull/12857)) +* `MGLMapSnapshotter` now respects the `MGLIdeographicFontFamilyName` key in Info.plist, which reduces bandwidth consumption when snapshotting regions that contain Chinese or Japanese characters. ([#13427](https://github.com/mapbox/mapbox-gl-native/pull/13427)) +* Added `MGLLoggingConfiguration` and `MGLLoggingBlockHandler` that handle error and fault events produced by the SDK. ([#13235](https://github.com/mapbox/mapbox-gl-native/pull/13235)) + +## 0.12.0 - November 8, 2018 ### Styles and rendering From 72381bac5fdbe38be0903fac63d3f6dfb53d920c Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Sat, 12 Jan 2019 15:47:24 -0500 Subject: [PATCH 25/29] Removed deleted files from macos project --- .../macos/macos.xcodeproj/project.pbxproj | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/platform/macos/macos.xcodeproj/project.pbxproj b/platform/macos/macos.xcodeproj/project.pbxproj index cf4d384f362..4773ae8249b 100644 --- a/platform/macos/macos.xcodeproj/project.pbxproj +++ b/platform/macos/macos.xcodeproj/project.pbxproj @@ -119,8 +119,6 @@ 9654C12B1FFC38E000DB6A19 /* MGLPolyline_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 9654C12A1FFC38E000DB6A19 /* MGLPolyline_Private.h */; }; 9654C12D1FFC394700DB6A19 /* MGLPolygon_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 9654C12C1FFC394700DB6A19 /* MGLPolygon_Private.h */; }; 96E027311E57C9A7004B8E66 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 96E027331E57C9A7004B8E66 /* Localizable.strings */; }; - CA4045C5216720D700B356E1 /* MGLCluster_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = CA4045C2216720D700B356E1 /* MGLCluster_Private.h */; }; - CA4045C6216720D700B356E1 /* MGLCluster.mm in Sources */ = {isa = PBXBuildFile; fileRef = CA4045C3216720D700B356E1 /* MGLCluster.mm */; }; CA4045C7216720D700B356E1 /* MGLCluster.h in Headers */ = {isa = PBXBuildFile; fileRef = CA4045C4216720D700B356E1 /* MGLCluster.h */; settings = {ATTRIBUTES = (Public, ); }; }; CA8FBC0D21A4A74300D1203C /* MGLRendererConfigurationTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = CA8FBC0C21A4A74300D1203C /* MGLRendererConfigurationTests.mm */; }; CA9461A620884CCB0015EB12 /* MGLAnnotationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CA9461A520884CCB0015EB12 /* MGLAnnotationTests.m */; }; @@ -447,8 +445,6 @@ 96E027391E57C9B9004B8E66 /* sv */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sv; path = sv.lproj/Localizable.strings; sourceTree = ""; }; 96E0273A1E57C9BB004B8E66 /* vi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = vi; path = vi.lproj/Localizable.strings; sourceTree = ""; }; 96E0273B1E57C9BC004B8E66 /* pt-BR */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "pt-BR"; path = "pt-BR.lproj/Localizable.strings"; sourceTree = ""; }; - CA4045C2216720D700B356E1 /* MGLCluster_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLCluster_Private.h; sourceTree = ""; }; - CA4045C3216720D700B356E1 /* MGLCluster.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLCluster.mm; sourceTree = ""; }; CA4045C4216720D700B356E1 /* MGLCluster.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLCluster.h; sourceTree = ""; }; CA8FBC0C21A4A74300D1203C /* MGLRendererConfigurationTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLRendererConfigurationTests.mm; path = ../../darwin/test/MGLRendererConfigurationTests.mm; sourceTree = ""; }; CA9461A520884CCB0015EB12 /* MGLAnnotationTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MGLAnnotationTests.m; path = test/MGLAnnotationTests.m; sourceTree = SOURCE_ROOT; }; @@ -1031,9 +1027,7 @@ isa = PBXGroup; children = ( DAE6C34B1CC31E0400DB3429 /* MGLAnnotation.h */, - CA4045C2216720D700B356E1 /* MGLCluster_Private.h */, CA4045C4216720D700B356E1 /* MGLCluster.h */, - CA4045C3216720D700B356E1 /* MGLCluster.mm */, DACC22171CF3D4F700D220D9 /* MGLFeature_Private.h */, DACC22121CF3D3E200D220D9 /* MGLFeature.h */, DACC22131CF3D3E200D220D9 /* MGLFeature.mm */, @@ -1323,7 +1317,6 @@ DA8F25871D51C9E10010E6B5 /* MGLBackgroundStyleLayer.h in Headers */, 4049C2A51DB6CE7F00B3F799 /* MGLPointCollection.h in Headers */, DAE6C3661CC31E0400DB3429 /* MGLShape.h in Headers */, - CA4045C5216720D700B356E1 /* MGLCluster_Private.h in Headers */, DA551B831DB496AC0009AFAF /* MGLTileSource_Private.h in Headers */, DAC25FCA200FD5E2009BE98E /* NSExpression+MGLPrivateAdditions.h in Headers */, DA7262071DEEDD460043BB89 /* MGLOpenGLStyleLayer.h in Headers */, @@ -1656,7 +1649,6 @@ DAE6C3911CC31E2A00DB3429 /* MGLPolygon.mm in Sources */, 35C6DF851E214C0400ACA483 /* MGLDistanceFormatter.m in Sources */, DAE6C39B1CC31E2A00DB3429 /* NSProcessInfo+MGLAdditions.m in Sources */, - CA4045C6216720D700B356E1 /* MGLCluster.mm in Sources */, DAA998FC1E9F545C002E6EA6 /* MGLFillExtrusionStyleLayer.mm in Sources */, DAE6C38F1CC31E2A00DB3429 /* MGLOfflineStorage.mm in Sources */, DAED38601D62CED700D7640F /* NSURL+MGLAdditions.m in Sources */, @@ -2156,10 +2148,10 @@ "$(geometry_cflags)", "$(geojson_cflags)", ); - OTHER_LDFLAGS = ( - "$(mbgl_core_LINK_LIBRARIES)", - "$(mbgl_filesource_LINK_LIBRARIES)", - ); + OTHER_LDFLAGS = ( + "$(mbgl_core_LINK_LIBRARIES)", + "$(mbgl_filesource_LINK_LIBRARIES)", + ); OTHER_SWIFT_FLAGS = "-warnings-as-errors"; PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.test; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -2188,10 +2180,10 @@ "$(geometry_cflags)", "$(geojson_cflags)", ); - OTHER_LDFLAGS = ( - "$(mbgl_core_LINK_LIBRARIES)", - "$(mbgl_filesource_LINK_LIBRARIES)", - ); + OTHER_LDFLAGS = ( + "$(mbgl_core_LINK_LIBRARIES)", + "$(mbgl_filesource_LINK_LIBRARIES)", + ); OTHER_SWIFT_FLAGS = "-warnings-as-errors"; PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.test; PRODUCT_NAME = "$(TARGET_NAME)"; From c7baac829feddac6295b060ddb1edf00a3d36b89 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Sat, 12 Jan 2019 16:09:26 -0500 Subject: [PATCH 26/29] Updated macos file list --- platform/macos/sdk-files.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/platform/macos/sdk-files.json b/platform/macos/sdk-files.json index a77e157154b..f7d2fd34266 100644 --- a/platform/macos/sdk-files.json +++ b/platform/macos/sdk-files.json @@ -51,7 +51,6 @@ "platform/darwin/src/MGLPolygon.mm", "platform/darwin/src/MGLDistanceFormatter.m", "platform/darwin/src/NSProcessInfo+MGLAdditions.m", - "platform/darwin/src/MGLCluster.mm", "platform/darwin/src/MGLFillExtrusionStyleLayer.mm", "platform/darwin/src/MGLOfflineStorage.mm", "platform/darwin/src/NSURL+MGLAdditions.m", @@ -167,7 +166,6 @@ "MGLAccountManager_Private.h": "platform/darwin/src/MGLAccountManager_Private.h", "MGLComputedShapeSource_Private.h": "platform/darwin/src/MGLComputedShapeSource_Private.h", "NSException+MGLAdditions.h": "platform/darwin/src/NSException+MGLAdditions.h", - "MGLCluster_Private.h": "platform/darwin/src/MGLCluster_Private.h", "MGLTileSource_Private.h": "platform/darwin/src/MGLTileSource_Private.h", "NSExpression+MGLPrivateAdditions.h": "platform/darwin/src/NSExpression+MGLPrivateAdditions.h", "NSCompoundPredicate+MGLAdditions.h": "platform/darwin/src/NSCompoundPredicate+MGLAdditions.h", From 015ec9c0fed7574c574ff962da6574ba4a3dae2f Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Sat, 12 Jan 2019 18:23:52 -0500 Subject: [PATCH 27/29] Update predicates/expressions guide with the other cluster attributes. --- .../darwin/docs/guides/Predicates and Expressions.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/platform/darwin/docs/guides/Predicates and Expressions.md b/platform/darwin/docs/guides/Predicates and Expressions.md index 71c869f7fe5..0bb26b3bfdb 100644 --- a/platform/darwin/docs/guides/Predicates and Expressions.md +++ b/platform/darwin/docs/guides/Predicates and Expressions.md @@ -120,7 +120,7 @@ dictionary contains the `floorCount` key, then the key path `floorCount` refers to the value of the `floorCount` attribute when evaluating that particular polygon. -The following special attribute is also available on features that are produced +The following special attributes are also available on features that are produced as a result of clustering multiple point features together in a shape source: @@ -128,6 +128,16 @@ as a result of clustering multiple point features together in a shape source: + + + + + + + + + + From 6de3ffae8f488af6dd04e372748e774d103a5d17 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Mon, 14 Jan 2019 13:36:14 -0500 Subject: [PATCH 28/29] Documentation and whitespace tweaks. --- platform/darwin/src/MGLFeature.mm | 2 +- platform/darwin/test/MGLCodingTests.mm | 2 +- platform/ios/jazzy.yml | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/platform/darwin/src/MGLFeature.mm b/platform/darwin/src/MGLFeature.mm index e471ea2e98c..fbf262af298 100644 --- a/platform/darwin/src/MGLFeature.mm +++ b/platform/darwin/src/MGLFeature.mm @@ -430,7 +430,7 @@ - (NSDictionary *)geoJSONDictionary { return [MGLShapeCollectionFeature shapeCollectionWithShapes:shapes]; } -private: +private: static CLLocationCoordinate2D toLocationCoordinate2D(const mbgl::Point &point) { return CLLocationCoordinate2DMake(point.y, point.x); } diff --git a/platform/darwin/test/MGLCodingTests.mm b/platform/darwin/test/MGLCodingTests.mm index c22eae81da2..e6417c99f5f 100644 --- a/platform/darwin/test/MGLCodingTests.mm +++ b/platform/darwin/test/MGLCodingTests.mm @@ -53,7 +53,7 @@ - (void)testPointFeatureCluster { @"cluster" : @(YES), @"cluster_id" : @(456), @"point_count" : @(2), - }; + }; XCTAssert([pointFeature isKindOfClass:[MGLPointFeature class]], @""); diff --git a/platform/ios/jazzy.yml b/platform/ios/jazzy.yml index 184d7cbd76f..31381650da1 100644 --- a/platform/ios/jazzy.yml +++ b/platform/ios/jazzy.yml @@ -69,12 +69,14 @@ custom_categories: children: - MGLFeature - MGLPointFeature + - MGLPointFeatureCluster - MGLPolygonFeature - MGLPolylineFeature - MGLMultiPolygonFeature - MGLMultiPolylineFeature - MGLPointCollectionFeature - MGLShapeCollectionFeature + - MGLEmptyFeature - name: Style Content children: - MGLSource From 94347793847f5632bed0bed6480cbe140a264826 Mon Sep 17 00:00:00 2001 From: Julian Rex Date: Mon, 14 Jan 2019 14:14:20 -0500 Subject: [PATCH 29/29] Another minor documentation tweak. --- platform/darwin/src/MGLShapeSource.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/darwin/src/MGLShapeSource.h b/platform/darwin/src/MGLShapeSource.h index 6676cbd02ec..b910fb02cea 100644 --- a/platform/darwin/src/MGLShapeSource.h +++ b/platform/darwin/src/MGLShapeSource.h @@ -332,7 +332,7 @@ MGL_EXPORT @param cluster An object of type `MGLPointFeatureCluster` (that conforms to the `MGLCluster` protocol). @param offset Number of features to skip. - @param limit Maximum number of features to return + @param limit The maximum number of features to return @return An array of objects that conform to the `MGLFeature` protocol. */
AttributeTypeMeaning
clusterBoolTrue if the feature is a point cluster. If the attribute is false (or not present) then the feature should not be considered a cluster.
cluster_idNumberIdentifier for the point cluster.
point_count Number