Skip to content

Commit

Permalink
Xcode 10.2
Browse files Browse the repository at this point in the history
Swift 5
CocoaPods 1.7.3
  • Loading branch information
maxep committed Jul 1, 2019
1 parent 2568a63 commit 13aa7ca
Show file tree
Hide file tree
Showing 20 changed files with 137 additions and 87 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: objective-c
osx_image: xcode10.1
osx_image: xcode10.2
env:
global:
- FRAMEWORK_NAME=ClusterKit
Expand All @@ -10,10 +10,10 @@ before_install:

install:
- gem install cocoapods
- gem install xcpretty --no-rdoc --no-ri --no-document --quiet
- gem install xcpretty --no-document --quiet

script:
- 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
- set -o pipefail && xcodebuild -project ClusterKit.xcodeproj -scheme $FRAMEWORK_NAME -sdk iphonesimulator12.2 -configuration Release -destination "platform=iOS Simulator,name=iPhone 8" clean build test | xcpretty -c
- pod lib lint --quick

before_deploy:
Expand Down
8 changes: 4 additions & 4 deletions ClusterKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
objects = {

/* Begin PBXBuildFile section */
9C2C4A0E1F94BACE00B22745 /* MGLMapView+ClusterKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 9C2C4A0C1F94BACE00B22745 /* MGLMapView+ClusterKit.h */; };
9C53CD191E03F51C000AD9B8 /* CKClusterAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = 9C53CD041E03F51C000AD9B8 /* CKClusterAlgorithm.h */; settings = {ATTRIBUTES = (Public, ); }; };
9C53CD1A1E03F51C000AD9B8 /* CKClusterAlgorithm.m in Sources */ = {isa = PBXBuildFile; fileRef = 9C53CD051E03F51C000AD9B8 /* CKClusterAlgorithm.m */; };
9C53CD1B1E03F51C000AD9B8 /* CKNonHierarchicalDistanceBasedAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = 9C53CD061E03F51C000AD9B8 /* CKNonHierarchicalDistanceBasedAlgorithm.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -266,7 +265,6 @@
9CE1F2691E069F30007E2678 /* CKGridBasedAlgorithm.h in Headers */,
9C53CD1D1E03F51C000AD9B8 /* CKCluster.h in Headers */,
9C53CD211E03F51C000AD9B8 /* CKMap.h in Headers */,
9C2C4A0E1F94BACE00B22745 /* MGLMapView+ClusterKit.h in Headers */,
9C53CD191E03F51C000AD9B8 /* CKClusterAlgorithm.h in Headers */,
9CC875F31E02AE2D0019AA18 /* ClusterKit.h in Headers */,
9C53CD231E03F51C000AD9B8 /* CKQuadTree.h in Headers */,
Expand Down Expand Up @@ -319,7 +317,7 @@
isa = PBXProject;
attributes = {
CLASSPREFIX = CK;
LastUpgradeCheck = 0930;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = Hulab;
TargetAttributes = {
9CC8756E1E0295A30019AA18 = {
Expand All @@ -334,7 +332,7 @@
};
buildConfigurationList = 9CC875691E0295A20019AA18 /* Build configuration list for PBXProject "ClusterKit" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Expand Down Expand Up @@ -409,6 +407,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
Expand Down Expand Up @@ -469,6 +468,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
8 changes: 6 additions & 2 deletions ClusterKit/Core/Algorithm/CKGridBasedAlgorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@
/**
A simple grid-based clustering algorithm with O(n) performance.
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.
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.
This grid-based implementation consists of the following the steps:
1. Iterate througth the annotations found in the given rect.
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.
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.
3. Annotation are added to a centroid cluster {@see CKCentroidCluster} by default.
*/
@interface CKGridBasedAlgorithm : CKClusterAlgorithm
Expand Down
2 changes: 1 addition & 1 deletion ClusterKit/Core/Algorithm/CKGridBasedAlgorithm.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ - (instancetype)init {

NSNumber *key = @(numCells * row + col);
CKCluster *cluster = clusters[key];
if (cluster == nil) {
if (!cluster) {
cluster = [self clusterWithCoordinate:annotation.coordinate];
clusters[key] = cluster;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@
/**
A simple clustering algorithm with O(nlog n) performance.
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.
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.
1. Iterate througth the annotations that are not yet clusterized found in the given rect.
2. Create a cluster with the center of the annotation.
3. Add all items that are within a certain distance to the cluster.
4. Move any items out of an existing cluster if they are closer to another cluster.
CKNonHierarchicalDistanceBasedAlgorithm is an objective-c implementation of the non-hierarchical distance based clustering algorithm used by Google maps.
CKNonHierarchicalDistanceBasedAlgorithm is an objective-c implementation of the non-hierarchical distance
based clustering algorithm used by Google maps.
@see https://github.com/googlemaps/android-maps-utils/blob/master/library/src/com/google/maps/android/clustering/algo/NonHierarchicalDistanceBasedAlgorithm.java
*/
@interface CKNonHierarchicalDistanceBasedAlgorithm : CKClusterAlgorithm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ - (instancetype)init {

for (id<MKAnnotation> annotation in annotations) {

if ([visited objectForKey:annotation]) {
continue;
}
if ([visited objectForKey:annotation]) continue;

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

if (candidate) {
if (candidate.distance < distance) {
continue;
}
if (candidate.distance < distance) continue;
[candidate.cluster removeAnnotation:neighbor];
} else {
candidate = [[CKCandidate alloc] init];
Expand Down
8 changes: 7 additions & 1 deletion ClusterKit/Core/CKCluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ MK_EXTERN NSComparisonResult MKMapSizeCompare(MKMapSize size1, MKMapSize size2);
/**
Cluster coordinate.
*/
@property (nonatomic) CLLocationCoordinate2D coordinate;
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;

/**
Cluster annotation array.
Expand Down Expand Up @@ -165,20 +165,26 @@ MK_EXTERN NSComparisonResult MKMapSizeCompare(MKMapSize size1, MKMapSize size2);

@end

#pragma mark - Centroid Cluster

/**
Cluster with centroid coordinate.
*/
@interface CKCentroidCluster : CKCluster

@end

#pragma mark - Nearest Centroid Cluster

/**
Cluster with coordinate at the nearest annotation from centroid.
*/
@interface CKNearestCentroidCluster : CKCentroidCluster

@end

#pragma mark - Bottom Cluster

/**
Cluster with coordinate at the bottom annotion.
*/
Expand Down
10 changes: 10 additions & 0 deletions ClusterKit/Core/CKCluster.m
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ - (instancetype)init{
return _annotations.array;
}

- (void)setCoordinate:(CLLocationCoordinate2D)newCoordinate {
_coordinate = newCoordinate;
}

- (MKMapRect)bounds {
if (_invalidate_bounds) {
_bounds = MKMapRectNull;
Expand Down Expand Up @@ -180,6 +184,8 @@ - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state object

@end

#pragma mark - Centroid Cluster

@implementation CKCentroidCluster

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

@end

#pragma mark - Nearest Centroid Cluster

@implementation CKNearestCentroidCluster {
CLLocationCoordinate2D _center;
}
Expand Down Expand Up @@ -264,6 +272,8 @@ - (CLLocationCoordinate2D)coordinateByDistanceSort {

@end

#pragma mark - Bottom Cluster

@implementation CKBottomCluster

- (void)addAnnotation:(id<MKAnnotation>)annotation {
Expand Down
35 changes: 25 additions & 10 deletions ClusterKit/Core/CKClusterManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ FOUNDATION_EXTERN const double kCKMarginFactorWorld;
@class CKClusterManager;

/**
The delegate of a CKClusterManager object may adopt the CKClusterManagerDelegate protocol. Optional methods of the protocol allow the delegate to manage clustering and animations.
The delegate of a CKClusterManager object may adopt the CKClusterManagerDelegate protocol.
Optional methods of the protocol allow the delegate to manage clustering and animations.
*/
@protocol CKClusterManagerDelegate <NSObject>

Expand All @@ -43,7 +44,7 @@ FOUNDATION_EXTERN const double kCKMarginFactorWorld;
Asks the delegate if the cluster manager should clusterized the given annotation.
@param clusterManager The cluster manager object requesting this information.
@param annotation The annotation to clusterized.
@param annotation The annotation to clusterized.
@return Yes to permit clusterization of the given annotation.
*/
Expand All @@ -54,7 +55,9 @@ FOUNDATION_EXTERN const double kCKMarginFactorWorld;
@param clusterManager The cluster manager object requesting the animation.
@param animations A block object containing the animation. This block takes no parameters and has no return value. This parameter must not be NULL.
@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.
@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.
*/
- (void)clusterManager:(CKClusterManager *)clusterManager performAnimations:(void (^)(void))animations completion:(void (^ __nullable)(BOOL finished))completion;

Expand All @@ -65,22 +68,22 @@ FOUNDATION_EXTERN const double kCKMarginFactorWorld;
/**
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.
*/
@property (assign, nonatomic) CGFloat animationDuration;
@property (nonatomic, assign) CGFloat animationDuration;

/**
A mask of options indicating how you want to perform the animations. For a list of valid constants, @see UIViewAnimationOptions.
*/
@property (assign, nonatomic) UIViewAnimationOptions animationOptions;
@property (nonatomic, assign) UIViewAnimationOptions animationOptions;

/**
The cluster algorithm to use. @see CKClusterAlgorithm.
*/
@property (nonatomic,strong) __kindof CKClusterAlgorithm *algorithm;
@property (nonatomic, strong) __kindof CKClusterAlgorithm *algorithm;

/**
A map object adopting the CKMap protocol.
*/
@property (nonatomic,weak) id<CKMap> map;
@property (nonatomic, weak) id<CKMap> map;

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

/**
The current cluster array.
Expand All @@ -110,7 +113,7 @@ FOUNDATION_EXTERN const double kCKMarginFactorWorld;
/**
The annotations to clusterize.
*/
@property (nonatomic,copy) NSArray<id<MKAnnotation>> *annotations;
@property (nonatomic, copy) NSArray<id<MKAnnotation>> *annotations;

/**
Adds an annotation.
Expand Down Expand Up @@ -190,9 +193,21 @@ FOUNDATION_EXTERN const double kCKMarginFactorWorld;
Initializes an animation for the given cluster.
@param cluster The cluster to animate.
@param from The cluster starting point.
@param to The cluster ending point.
@return The initialized CKClusterAnimation object.
*/
- (instancetype)initWithCluster:(CKCluster *)cluster NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithCluster:(CKCluster *)cluster from:(CLLocationCoordinate2D)from to:(CLLocationCoordinate2D)to NS_DESIGNATED_INITIALIZER;

/**
Creates an animation for the given cluster.
@param cluster The cluster to animate.
@param from The cluster starting point.
@param to The cluster ending point.
@return The initialized CKClusterAnimation object.
*/
+ (instancetype)animateCluster:(CKCluster *)cluster from:(CLLocationCoordinate2D)from to:(CLLocationCoordinate2D)to;

/// :nodoc:
- (instancetype)init NS_UNAVAILABLE;
Expand Down
Loading

0 comments on commit 13aa7ca

Please sign in to comment.