Skip to content

Commit e984a66

Browse files
committed
Xcode 10.2
Swift 5 CocoaPods 1.7.3
1 parent 2568a63 commit e984a66

20 files changed

+136
-86
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: objective-c
2-
osx_image: xcode10.1
2+
osx_image: xcode10.2
33
env:
44
global:
55
- FRAMEWORK_NAME=ClusterKit
@@ -10,7 +10,7 @@ before_install:
1010

1111
install:
1212
- gem install cocoapods
13-
- gem install xcpretty --no-rdoc --no-ri --no-document --quiet
13+
- gem install xcpretty --no-document --quiet
1414

1515
script:
1616
- set -o pipefail && xcodebuild -project ClusterKit.xcodeproj -scheme $FRAMEWORK_NAME -sdk iphonesimulator12.1 -configuration Release -destination "platform=iOS Simulator,name=iPhone 8" clean build test | xcpretty -c

ClusterKit.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10-
9C2C4A0E1F94BACE00B22745 /* MGLMapView+ClusterKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 9C2C4A0C1F94BACE00B22745 /* MGLMapView+ClusterKit.h */; };
1110
9C53CD191E03F51C000AD9B8 /* CKClusterAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = 9C53CD041E03F51C000AD9B8 /* CKClusterAlgorithm.h */; settings = {ATTRIBUTES = (Public, ); }; };
1211
9C53CD1A1E03F51C000AD9B8 /* CKClusterAlgorithm.m in Sources */ = {isa = PBXBuildFile; fileRef = 9C53CD051E03F51C000AD9B8 /* CKClusterAlgorithm.m */; };
1312
9C53CD1B1E03F51C000AD9B8 /* CKNonHierarchicalDistanceBasedAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = 9C53CD061E03F51C000AD9B8 /* CKNonHierarchicalDistanceBasedAlgorithm.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -266,7 +265,6 @@
266265
9CE1F2691E069F30007E2678 /* CKGridBasedAlgorithm.h in Headers */,
267266
9C53CD1D1E03F51C000AD9B8 /* CKCluster.h in Headers */,
268267
9C53CD211E03F51C000AD9B8 /* CKMap.h in Headers */,
269-
9C2C4A0E1F94BACE00B22745 /* MGLMapView+ClusterKit.h in Headers */,
270268
9C53CD191E03F51C000AD9B8 /* CKClusterAlgorithm.h in Headers */,
271269
9CC875F31E02AE2D0019AA18 /* ClusterKit.h in Headers */,
272270
9C53CD231E03F51C000AD9B8 /* CKQuadTree.h in Headers */,
@@ -319,7 +317,7 @@
319317
isa = PBXProject;
320318
attributes = {
321319
CLASSPREFIX = CK;
322-
LastUpgradeCheck = 0930;
320+
LastUpgradeCheck = 1020;
323321
ORGANIZATIONNAME = Hulab;
324322
TargetAttributes = {
325323
9CC8756E1E0295A30019AA18 = {
@@ -334,7 +332,7 @@
334332
};
335333
buildConfigurationList = 9CC875691E0295A20019AA18 /* Build configuration list for PBXProject "ClusterKit" */;
336334
compatibilityVersion = "Xcode 3.2";
337-
developmentRegion = English;
335+
developmentRegion = en;
338336
hasScannedForEncodings = 0;
339337
knownRegions = (
340338
en,
@@ -409,6 +407,7 @@
409407
isa = XCBuildConfiguration;
410408
buildSettings = {
411409
ALWAYS_SEARCH_USER_PATHS = NO;
410+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
412411
CLANG_ANALYZER_NONNULL = YES;
413412
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
414413
CLANG_CXX_LIBRARY = "libc++";
@@ -469,6 +468,7 @@
469468
isa = XCBuildConfiguration;
470469
buildSettings = {
471470
ALWAYS_SEARCH_USER_PATHS = NO;
471+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
472472
CLANG_ANALYZER_NONNULL = YES;
473473
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
474474
CLANG_CXX_LIBRARY = "libc++";

ClusterKit.xcodeproj/xcshareddata/xcschemes/ClusterKit.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0930"
3+
LastUpgradeVersion = "1020"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

ClusterKit/Core/Algorithm/CKGridBasedAlgorithm.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,16 @@
2525
/**
2626
A simple grid-based clustering algorithm with O(n) performance.
2727
28-
The great advantage of grid-based clustering is its significant reduction of the computational complexity, especially for clustering very large data sets. The grid-based clustering approach differs from the conventional clustering algorithms in that it is concerned not with the data points but with the value space that surrounds the data points.
28+
The great advantage of grid-based clustering is its significant reduction of the computational complexity,
29+
especially for clustering very large data sets. The grid-based clustering approach differs from the conventional
30+
clustering algorithms in that it is concerned not with the data points but with the value space that surrounds
31+
the data points.
2932
3033
This grid-based implementation consists of the following the steps:
3134
3235
1. Iterate througth the annotations found in the given rect.
33-
2. Associate each annotation to a grid cell. The rect is partitioned in a finite number of cells using the cell size property at the given zoom level.
36+
2. Associate each annotation to a grid cell. The rect is partitioned in a finite number of cells using the cell
37+
size property at the given zoom level.
3438
3. Annotation are added to a centroid cluster {@see CKCentroidCluster} by default.
3539
*/
3640
@interface CKGridBasedAlgorithm : CKClusterAlgorithm

ClusterKit/Core/Algorithm/CKGridBasedAlgorithm.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ - (instancetype)init {
5050

5151
NSNumber *key = @(numCells * row + col);
5252
CKCluster *cluster = clusters[key];
53-
if (cluster == nil) {
53+
if (!cluster) {
5454
cluster = [self clusterWithCoordinate:annotation.coordinate];
5555
clusters[key] = cluster;
5656
}

ClusterKit/Core/Algorithm/CKNonHierarchicalDistanceBasedAlgorithm.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,17 @@
2525
/**
2626
A simple clustering algorithm with O(nlog n) performance.
2727
28-
Non-hierarchical distance analysis aims to find a grouping of annotations which minimises the distance between an annotation and its cluster. These algorithm will iteratively assign annotations to different groups while searching for the optimal distance.
28+
Non-hierarchical distance analysis aims to find a grouping of annotations which minimises the distance
29+
between an annotation and its cluster. These algorithm will iteratively assign annotations to different
30+
groups while searching for the optimal distance.
2931
3032
1. Iterate througth the annotations that are not yet clusterized found in the given rect.
3133
2. Create a cluster with the center of the annotation.
3234
3. Add all items that are within a certain distance to the cluster.
3335
4. Move any items out of an existing cluster if they are closer to another cluster.
3436
35-
CKNonHierarchicalDistanceBasedAlgorithm is an objective-c implementation of the non-hierarchical distance based clustering algorithm used by Google maps.
37+
CKNonHierarchicalDistanceBasedAlgorithm is an objective-c implementation of the non-hierarchical distance
38+
based clustering algorithm used by Google maps.
3639
@see https://github.com/googlemaps/android-maps-utils/blob/master/library/src/com/google/maps/android/clustering/algo/NonHierarchicalDistanceBasedAlgorithm.java
3740
*/
3841
@interface CKNonHierarchicalDistanceBasedAlgorithm : CKClusterAlgorithm

ClusterKit/Core/Algorithm/CKNonHierarchicalDistanceBasedAlgorithm.m

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ - (instancetype)init {
5454

5555
for (id<MKAnnotation> annotation in annotations) {
5656

57-
if ([visited objectForKey:annotation]) {
58-
continue;
59-
}
57+
if ([visited objectForKey:annotation]) continue;
6058

6159
CKCluster *cluster = [self clusterWithCoordinate:annotation.coordinate];
6260
[clusters addObject:cluster];
@@ -71,9 +69,7 @@ - (instancetype)init {
7169
CGFloat distance = CKDistance(neighbor.coordinate, cluster.coordinate);
7270

7371
if (candidate) {
74-
if (candidate.distance < distance) {
75-
continue;
76-
}
72+
if (candidate.distance < distance) continue;
7773
[candidate.cluster removeAnnotation:neighbor];
7874
} else {
7975
candidate = [[CKCandidate alloc] init];

ClusterKit/Core/CKCluster.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ MK_EXTERN NSComparisonResult MKMapSizeCompare(MKMapSize size1, MKMapSize size2);
6565
/**
6666
Cluster coordinate.
6767
*/
68-
@property (nonatomic) CLLocationCoordinate2D coordinate;
68+
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
6969

7070
/**
7171
Cluster annotation array.
@@ -165,20 +165,26 @@ MK_EXTERN NSComparisonResult MKMapSizeCompare(MKMapSize size1, MKMapSize size2);
165165

166166
@end
167167

168+
#pragma mark - Centroid Cluster
169+
168170
/**
169171
Cluster with centroid coordinate.
170172
*/
171173
@interface CKCentroidCluster : CKCluster
172174

173175
@end
174176

177+
#pragma mark - Nearest Centroid Cluster
178+
175179
/**
176180
Cluster with coordinate at the nearest annotation from centroid.
177181
*/
178182
@interface CKNearestCentroidCluster : CKCentroidCluster
179183

180184
@end
181185

186+
#pragma mark - Bottom Cluster
187+
182188
/**
183189
Cluster with coordinate at the bottom annotion.
184190
*/

ClusterKit/Core/CKCluster.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ - (instancetype)init{
7474
return _annotations.array;
7575
}
7676

77+
- (void)setCoordinate:(CLLocationCoordinate2D)newCoordinate {
78+
_coordinate = newCoordinate;
79+
}
80+
7781
- (MKMapRect)bounds {
7882
if (_invalidate_bounds) {
7983
_bounds = MKMapRectNull;
@@ -180,6 +184,8 @@ - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state object
180184

181185
@end
182186

187+
#pragma mark - Centroid Cluster
188+
183189
@implementation CKCentroidCluster
184190

185191
- (void)addAnnotation:(id<MKAnnotation>)annotation {
@@ -224,6 +230,8 @@ - (CLLocationCoordinate2D)coordinateByRemovingAnnotation:(id<MKAnnotation>)annot
224230

225231
@end
226232

233+
#pragma mark - Nearest Centroid Cluster
234+
227235
@implementation CKNearestCentroidCluster {
228236
CLLocationCoordinate2D _center;
229237
}
@@ -264,6 +272,8 @@ - (CLLocationCoordinate2D)coordinateByDistanceSort {
264272

265273
@end
266274

275+
#pragma mark - Bottom Cluster
276+
267277
@implementation CKBottomCluster
268278

269279
- (void)addAnnotation:(id<MKAnnotation>)annotation {

ClusterKit/Core/CKClusterManager.h

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ FOUNDATION_EXTERN const double kCKMarginFactorWorld;
3333
@class CKClusterManager;
3434

3535
/**
36-
The delegate of a CKClusterManager object may adopt the CKClusterManagerDelegate protocol. Optional methods of the protocol allow the delegate to manage clustering and animations.
36+
The delegate of a CKClusterManager object may adopt the CKClusterManagerDelegate protocol.
37+
Optional methods of the protocol allow the delegate to manage clustering and animations.
3738
*/
3839
@protocol CKClusterManagerDelegate <NSObject>
3940

@@ -43,7 +44,7 @@ FOUNDATION_EXTERN const double kCKMarginFactorWorld;
4344
Asks the delegate if the cluster manager should clusterized the given annotation.
4445
4546
@param clusterManager The cluster manager object requesting this information.
46-
@param annotation The annotation to clusterized.
47+
@param annotation The annotation to clusterized.
4748
4849
@return Yes to permit clusterization of the given annotation.
4950
*/
@@ -54,7 +55,9 @@ FOUNDATION_EXTERN const double kCKMarginFactorWorld;
5455
5556
@param clusterManager The cluster manager object requesting the animation.
5657
@param animations A block object containing the animation. This block takes no parameters and has no return value. This parameter must not be NULL.
57-
@param completion A block object to be executed when the animation sequence ends. This block has no return value and takes a single Boolean argument that indicates whether or not the animations actually finished before the completion handler was called. If the duration of the animation is 0, this block is performed at the beginning of the next run loop cycle. This parameter may be NULL.
58+
@param completion A block object to be executed when the animation sequence ends. This block has no return value and takes a single Boolean argument
59+
that indicates whether or not the animations actually finished before the completion handler was called. If the duration of the
60+
animation is 0, this block is performed at the beginning of the next run loop cycle. This parameter may be NULL.
5861
*/
5962
- (void)clusterManager:(CKClusterManager *)clusterManager performAnimations:(void (^)(void))animations completion:(void (^ __nullable)(BOOL finished))completion;
6063

@@ -65,22 +68,22 @@ FOUNDATION_EXTERN const double kCKMarginFactorWorld;
6568
/**
6669
The total duration of the clusters animations, measured in seconds. If you specify a negative value or 0, the changes are made without animating them.
6770
*/
68-
@property (assign, nonatomic) CGFloat animationDuration;
71+
@property (nonatomic, assign) CGFloat animationDuration;
6972

7073
/**
7174
A mask of options indicating how you want to perform the animations. For a list of valid constants, @see UIViewAnimationOptions.
7275
*/
73-
@property (assign, nonatomic) UIViewAnimationOptions animationOptions;
76+
@property (nonatomic, assign) UIViewAnimationOptions animationOptions;
7477

7578
/**
7679
The cluster algorithm to use. @see CKClusterAlgorithm.
7780
*/
78-
@property (nonatomic,strong) __kindof CKClusterAlgorithm *algorithm;
81+
@property (nonatomic, strong) __kindof CKClusterAlgorithm *algorithm;
7982

8083
/**
8184
A map object adopting the CKMap protocol.
8285
*/
83-
@property (nonatomic,weak) id<CKMap> map;
86+
@property (nonatomic, weak) id<CKMap> map;
8487

8588
/**
8689
Delegate instance that adopt the CKClusterManagerDelegate protocol.
@@ -90,7 +93,7 @@ FOUNDATION_EXTERN const double kCKMarginFactorWorld;
9093
/**
9194
The currently selected annotation.
9295
*/
93-
@property (nonatomic,readonly) id<MKAnnotation> selectedAnnotation;
96+
@property (nonatomic, readonly) id<MKAnnotation> selectedAnnotation;
9497

9598
/**
9699
The current cluster array.
@@ -110,7 +113,7 @@ FOUNDATION_EXTERN const double kCKMarginFactorWorld;
110113
/**
111114
The annotations to clusterize.
112115
*/
113-
@property (nonatomic,copy) NSArray<id<MKAnnotation>> *annotations;
116+
@property (nonatomic, copy) NSArray<id<MKAnnotation>> *annotations;
114117

115118
/**
116119
Adds an annotation.
@@ -190,9 +193,21 @@ FOUNDATION_EXTERN const double kCKMarginFactorWorld;
190193
Initializes an animation for the given cluster.
191194
192195
@param cluster The cluster to animate.
196+
@param from The cluster starting point.
197+
@param to The cluster ending point.
193198
@return The initialized CKClusterAnimation object.
194199
*/
195-
- (instancetype)initWithCluster:(CKCluster *)cluster NS_DESIGNATED_INITIALIZER;
200+
- (instancetype)initWithCluster:(CKCluster *)cluster from:(CLLocationCoordinate2D)from to:(CLLocationCoordinate2D)to NS_DESIGNATED_INITIALIZER;
201+
202+
/**
203+
Creates an animation for the given cluster.
204+
205+
@param cluster The cluster to animate.
206+
@param from The cluster starting point.
207+
@param to The cluster ending point.
208+
@return The initialized CKClusterAnimation object.
209+
*/
210+
+ (instancetype)animateCluster:(CKCluster *)cluster from:(CLLocationCoordinate2D)from to:(CLLocationCoordinate2D)to;
196211

197212
/// :nodoc:
198213
- (instancetype)init NS_UNAVAILABLE;

0 commit comments

Comments
 (0)