├── QTree ├── QTreeTests │ ├── en.lproj │ │ └── InfoPlist.strings │ ├── LocationBasedMessage.h │ ├── LocationBasedMessage.m │ ├── QTreeTests-Info.plist │ └── QTreeTests.m ├── QTree │ ├── QTree-Prefix.pch │ ├── QCluster.m │ ├── QTreeInsertable.h │ ├── QTreeGeometryUtils.h │ ├── QCluster.h │ ├── QTree.h │ ├── QNode.h │ ├── QTreeGeometryUtils.m │ ├── QTree.m │ └── QNode.m └── QTree.xcodeproj │ ├── project.xcworkspace │ └── contents.xcworkspacedata │ └── project.pbxproj ├── QTreeSample ├── QTreeSample │ ├── en.lproj │ │ └── InfoPlist.strings │ ├── ViewController.h │ ├── AppDelegate.h │ ├── QCluster+Annotation.h │ ├── DummyAnnotation.m │ ├── main.m │ ├── AppDelegate.m │ ├── QTreeSample-Prefix.pch │ ├── DummyAnnotation.h │ ├── ClusterAnnotationView.h │ ├── QCluster+Annotation.m │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── LaunchImage.launchimage │ │ │ └── Contents.json │ ├── QTreeSample-Info.plist │ ├── ClusterAnnotationView.m │ ├── ViewController.m │ └── Base.lproj │ │ └── Main.storyboard └── QTreeSample.xcodeproj │ ├── project.xcworkspace │ └── contents.xcworkspacedata │ └── project.pbxproj ├── screenshot_no_clusterization.png ├── screenshot_with_clusterization.png ├── .gitignore ├── QTree-objc.podspec ├── LICENSE.md └── README.md /QTree/QTreeTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /QTreeSample/QTreeSample/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | -------------------------------------------------------------------------------- /screenshot_no_clusterization.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blackm00n/QTree-objc/HEAD/screenshot_no_clusterization.png -------------------------------------------------------------------------------- /screenshot_with_clusterization.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/blackm00n/QTree-objc/HEAD/screenshot_with_clusterization.png -------------------------------------------------------------------------------- /QTree/QTree/QTree-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #ifdef __OBJC__ 8 | @import Foundation; 9 | #endif -------------------------------------------------------------------------------- /QTree/QTree.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /QTreeSample/QTreeSample/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // This file is subject to the terms and conditions defined in 3 | // file 'LICENSE.md', which is part of this source code package. 4 | // 5 | 6 | @interface ViewController : UIViewController 7 | 8 | @end -------------------------------------------------------------------------------- /QTree/QTree/QCluster.m: -------------------------------------------------------------------------------- 1 | // 2 | // This file is subject to the terms and conditions defined in 3 | // file 'LICENSE.md', which is part of this source code package. 4 | // 5 | 6 | #import "QCluster.h" 7 | 8 | @implementation QCluster 9 | 10 | @end 11 | -------------------------------------------------------------------------------- /QTreeSample/QTreeSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /QTreeSample/QTreeSample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // This file is subject to the terms and conditions defined in 3 | // file 'LICENSE.md', which is part of this source code package. 4 | // 5 | 6 | @interface AppDelegate : UIResponder 7 | 8 | @property(strong, nonatomic) UIWindow* window; 9 | 10 | @end -------------------------------------------------------------------------------- /QTreeSample/QTreeSample/QCluster+Annotation.h: -------------------------------------------------------------------------------- 1 | // 2 | // This file is subject to the terms and conditions defined in 3 | // file 'LICENSE.md', which is part of this source code package. 4 | // 5 | 6 | #import "QCluster.h" 7 | 8 | @interface QCluster(Annotation) 9 | 10 | -(NSString*)title; 11 | -(NSString*)subtitle; 12 | 13 | @end -------------------------------------------------------------------------------- /QTreeSample/QTreeSample/DummyAnnotation.m: -------------------------------------------------------------------------------- 1 | // 2 | // This file is subject to the terms and conditions defined in 3 | // file 'LICENSE.md', which is part of this source code package. 4 | // 5 | 6 | #import "DummyAnnotation.h" 7 | 8 | @implementation DummyAnnotation 9 | 10 | -(NSString*)title 11 | { 12 | return @"Object"; 13 | } 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OS X 2 | .DS_Store 3 | 4 | # Xcode 5 | build/ 6 | *.pbxuser 7 | !default.pbxuser 8 | *.mode1v3 9 | !default.mode1v3 10 | *.mode2v3 11 | !default.mode2v3 12 | *.perspectivev3 13 | !default.perspectivev3 14 | xcuserdata 15 | *.xccheckout 16 | profile 17 | *.moved-aside 18 | DerivedData 19 | *.hmap 20 | *.ipa 21 | 22 | # CocoaPods 23 | Pods 24 | -------------------------------------------------------------------------------- /QTree/QTree/QTreeInsertable.h: -------------------------------------------------------------------------------- 1 | // 2 | // This file is subject to the terms and conditions defined in 3 | // file 'LICENSE.md', which is part of this source code package. 4 | // 5 | 6 | @import CoreLocation; 7 | 8 | @protocol QTreeInsertable 9 | 10 | @property(nonatomic, assign, readonly) CLLocationCoordinate2D coordinate; 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /QTreeSample/QTreeSample/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // This file is subject to the terms and conditions defined in 3 | // file 'LICENSE.md', which is part of this source code package. 4 | // 5 | 6 | #import "AppDelegate.h" 7 | 8 | int main(int argc, char* argv[]) 9 | { 10 | @autoreleasepool { 11 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 12 | } 13 | } -------------------------------------------------------------------------------- /QTreeSample/QTreeSample/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // This file is subject to the terms and conditions defined in 3 | // file 'LICENSE.md', which is part of this source code package. 4 | // 5 | 6 | #import "AppDelegate.h" 7 | 8 | @implementation AppDelegate 9 | 10 | -(BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions 11 | { 12 | return YES; 13 | } 14 | 15 | @end -------------------------------------------------------------------------------- /QTreeSample/QTreeSample/QTreeSample-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #include 8 | 9 | #ifndef __IPHONE_5_0 10 | #warning "This project uses features only available in iOS SDK 5.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | @import Foundation; 15 | @import UIKit; 16 | #endif -------------------------------------------------------------------------------- /QTree/QTreeTests/LocationBasedMessage.h: -------------------------------------------------------------------------------- 1 | // 2 | // This file is subject to the terms and conditions defined in 3 | // file 'LICENSE.md', which is part of this source code package. 4 | // 5 | 6 | #import "QTreeInsertable.h" 7 | 8 | @interface LocationBasedMessage : NSObject 9 | 10 | @property(nonatomic, assign) NSString* message; 11 | @property(nonatomic, assign) CLLocationCoordinate2D coordinate; 12 | 13 | @end -------------------------------------------------------------------------------- /QTreeSample/QTreeSample/DummyAnnotation.h: -------------------------------------------------------------------------------- 1 | // 2 | // This file is subject to the terms and conditions defined in 3 | // file 'LICENSE.md', which is part of this source code package. 4 | // 5 | 6 | @import MapKit; 7 | 8 | #import "QTreeInsertable.h" 9 | 10 | @interface DummyAnnotation : NSObject 11 | 12 | @property(nonatomic, assign) CLLocationCoordinate2D coordinate; 13 | 14 | -(NSString*)title; 15 | 16 | @end -------------------------------------------------------------------------------- /QTreeSample/QTreeSample/ClusterAnnotationView.h: -------------------------------------------------------------------------------- 1 | // 2 | // This file is subject to the terms and conditions defined in 3 | // file 'LICENSE.md', which is part of this source code package. 4 | // 5 | 6 | @import MapKit; 7 | @class QCluster; 8 | 9 | @interface ClusterAnnotationView : MKAnnotationView; 10 | 11 | +(NSString*)reuseId; 12 | 13 | 14 | -(instancetype)initWithCluster:(QCluster*)cluster; 15 | 16 | @property(nonatomic, strong) QCluster* cluster; 17 | 18 | @end -------------------------------------------------------------------------------- /QTreeSample/QTreeSample/QCluster+Annotation.m: -------------------------------------------------------------------------------- 1 | // 2 | // This file is subject to the terms and conditions defined in 3 | // file 'LICENSE.md', which is part of this source code package. 4 | // 5 | 6 | #import "QCluster+Annotation.h" 7 | 8 | @implementation QCluster(Annotation) 9 | 10 | -(NSString*)title 11 | { 12 | return @"Cluster"; 13 | } 14 | 15 | -(NSString*)subtitle 16 | { 17 | return [NSString stringWithFormat:@"%d objects here", self.objectsCount]; 18 | } 19 | 20 | @end -------------------------------------------------------------------------------- /QTreeSample/QTreeSample/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "40x40", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "60x60", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /QTree/QTreeTests/LocationBasedMessage.m: -------------------------------------------------------------------------------- 1 | // 2 | // This file is subject to the terms and conditions defined in 3 | // file 'LICENSE.md', which is part of this source code package. 4 | // 5 | 6 | #import "LocationBasedMessage.h" 7 | 8 | @implementation LocationBasedMessage 9 | 10 | - (NSString*)description 11 | { 12 | return [NSString stringWithFormat:@"%@ %p: {\n message: %@\n location: (%@, %@)\n}", NSStringFromClass([self class]), (__bridge void*)self, self.message, @(self.coordinate.latitude), @(self.coordinate.longitude)]; 13 | } 14 | 15 | @end -------------------------------------------------------------------------------- /QTree/QTree/QTreeGeometryUtils.h: -------------------------------------------------------------------------------- 1 | // 2 | // This file is subject to the terms and conditions defined in 3 | // file 'LICENSE.md', which is part of this source code package. 4 | // 5 | 6 | @import CoreLocation; 7 | @import MapKit; 8 | 9 | BOOL MKCoordinateRegionIntersectsRegion(MKCoordinateRegion region1, MKCoordinateRegion region2); 10 | BOOL MKCoordinateRegionContainsCoordinate(MKCoordinateRegion region, CLLocationCoordinate2D coordinate); 11 | 12 | CLLocationDistance CLMetersBetweenCoordinates(CLLocationCoordinate2D c1, CLLocationCoordinate2D c2); 13 | 14 | -------------------------------------------------------------------------------- /QTree/QTree/QCluster.h: -------------------------------------------------------------------------------- 1 | // 2 | // This file is subject to the terms and conditions defined in 3 | // file 'LICENSE.md', which is part of this source code package. 4 | // 5 | 6 | @import CoreLocation; 7 | 8 | #import "QTreeInsertable.h" 9 | 10 | @interface QCluster : NSObject 11 | 12 | @property(nonatomic, assign) CLLocationCoordinate2D coordinate; 13 | @property(nonatomic, assign) NSInteger objectsCount; 14 | @property(nonatomic, assign) CLLocationDegrees radius; 15 | // By default this property is not filled in and is nil 16 | @property(nonatomic, copy) NSArray>* objects; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /QTreeSample/QTreeSample/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "portrait", 12 | "idiom" : "iphone", 13 | "subtype" : "retina4", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "7.0", 16 | "scale" : "2x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /QTree-objc.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "QTree-objc" 3 | s.platform = :ios 4 | s.version = "0.2" 5 | s.summary = "Library for location-based clustering of data using Quadtree written in Objective-C." 6 | s.homepage = "https://github.com/blackm00n/QTree-objc" 7 | s.license = 'MIT' 8 | s.author = { "Aleksey Kozhevnikov" => "aleksey.kozhevnikov@gmail.com" } 9 | s.source = { :git => "https://github.com/blackm00n/QTree-objc.git", :tag => "0.2" } 10 | s.source_files = 'QTree/QTree' 11 | s.frameworks = 'CoreLocation', 'MapKit' 12 | s.requires_arc = true 13 | s.compiler_flags = '-fmodules' 14 | end 15 | -------------------------------------------------------------------------------- /QTree/QTreeTests/QTreeTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 0.1 17 | CFBundleVersion 18 | 0.1 19 | 20 | 21 | -------------------------------------------------------------------------------- /QTree/QTree/QTree.h: -------------------------------------------------------------------------------- 1 | // 2 | // This file is subject to the terms and conditions defined in 3 | // file 'LICENSE.md', which is part of this source code package. 4 | // 5 | 6 | @import CoreLocation; 7 | @import MapKit; 8 | 9 | #import "QTreeInsertable.h" 10 | 11 | @interface QTree : NSObject 12 | 13 | -(void)insertObject:(id)insertableObject; 14 | -(void)removeObject:(id)insertableObject; 15 | 16 | @property(nonatomic, readonly) NSUInteger count; 17 | 18 | - (void) cleanup; 19 | 20 | -(NSArray*)getObjectsInRegion:(MKCoordinateRegion)region minNonClusteredSpan:(CLLocationDegrees)span fillClusters:(BOOL)fillClusters; 21 | -(NSArray*)getObjectsInRegion:(MKCoordinateRegion)region minNonClusteredSpan:(CLLocationDegrees)span; 22 | // Returned array is sorted from the least to the most distant 23 | -(NSArray*)neighboursForLocation:(CLLocationCoordinate2D)location limitCount:(NSUInteger)limit; 24 | 25 | @end -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Aleksey Kozhevnikov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /QTree/QTree/QNode.h: -------------------------------------------------------------------------------- 1 | // 2 | // This file is subject to the terms and conditions defined in 3 | // file 'LICENSE.md', which is part of this source code package. 4 | // 5 | 6 | @import CoreLocation; 7 | @import MapKit; 8 | 9 | #import "QCluster.h" 10 | 11 | @interface QNode : NSObject 12 | 13 | +(instancetype)nodeWithRegion:(MKCoordinateRegion)region; 14 | 15 | 16 | -(instancetype)initWithRegion:(MKCoordinateRegion)region; 17 | 18 | @property(nonatomic, readonly) MKCoordinateRegion region; 19 | @property(nonatomic, readonly) NSUInteger count; 20 | // Shortcuts 21 | @property(nonatomic, readonly) CLLocationDegrees centerLatitude; 22 | @property(nonatomic, readonly) CLLocationDegrees centerLongitude; 23 | 24 | -(BOOL)insertObject:(id)insertableObject; 25 | -(BOOL)removeObject:(id)insertableObject; 26 | 27 | -(NSArray*)getObjectsInRegion:(MKCoordinateRegion)region minNonClusteredSpan:(CLLocationDegrees)span; 28 | -(NSArray*)getObjectsInRegion:(MKCoordinateRegion)region minNonClusteredSpan:(CLLocationDegrees)span fillClusters:(BOOL)fillClusters; 29 | 30 | -(QNode*)childNodeForLocation:(CLLocationCoordinate2D)location; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /QTree/QTree/QTreeGeometryUtils.m: -------------------------------------------------------------------------------- 1 | // 2 | // This file is subject to the terms and conditions defined in 3 | // file 'LICENSE.md', which is part of this source code package. 4 | // 5 | 6 | #import "QTreeGeometryUtils.h" 7 | 8 | BOOL MKCoordinateRegionIntersectsRegion(MKCoordinateRegion region1, MKCoordinateRegion region2) 9 | { 10 | const CLLocationDegrees dstLat = ABS(region1.center.latitude - region2.center.latitude); 11 | const CLLocationDegrees dstLng = ABS(region1.center.longitude - region2.center.longitude); 12 | return (dstLat < (region1.span.latitudeDelta + region2.span.latitudeDelta) / 2) 13 | && (dstLng < (region1.span.longitudeDelta + region2.span.longitudeDelta) / 2); 14 | } 15 | 16 | BOOL MKCoordinateRegionContainsCoordinate(MKCoordinateRegion region, CLLocationCoordinate2D coordinate) 17 | { 18 | CLLocationDegrees dstLat = ABS(region.center.latitude - coordinate.latitude); 19 | CLLocationDegrees dstLng = ABS(region.center.longitude - coordinate.longitude); 20 | return (dstLat < region.span.latitudeDelta / 2) && (dstLng < region.span.longitudeDelta / 2); 21 | } 22 | 23 | CLLocationDistance CLMetersBetweenCoordinates(CLLocationCoordinate2D c1, CLLocationCoordinate2D c2) 24 | { 25 | return MKMetersBetweenMapPoints(MKMapPointForCoordinate(c1), MKMapPointForCoordinate(c2)); 26 | } 27 | 28 | -------------------------------------------------------------------------------- /QTreeSample/QTreeSample/QTreeSample-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | me.akozhevnikov.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | QTree-objc 2 | ========== 3 | Library for location-based clustering of data using [Quadtree](http://en.wikipedia.org/wiki/Quadtree) written in Objective-C. 4 | 5 | Suppose you have a lot of items to display on a map. 6 | 7 | 8 | 9 | 10 | You will got a mess if you just add all of them as annotations to the map. 11 | 12 | 13 | It's better to merge items that are close to each other into clusters. 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | Clustering will help you to get a neater map and increase its performance. 27 | QuadTree will help you to get a stable (unlike k-nearest neighbor algorithm) and fast clustering. 28 | 29 | Installation 30 | ------------ 31 | The best approach is to use [CocoaPods](http://cocoapods.org/). 32 | 33 | Install CocoaPods gem if it's not installed yet and setup its enviroment: 34 | 35 | $ [sudo] gem install cocoapods 36 | $ pod setup 37 | 38 | Go to the directory containing your project's .xcodeproj file and create Podfile: 39 | 40 | $ cd ~/Projects/MyProject 41 | $ vim Podfile 42 | 43 | Add the following lines to Podfile: 44 | 45 | ```ruby 46 | platform :ios 47 | pod 'QTree-objc' 48 | ``` 49 | 50 | Finally install your pod dependencies: 51 | 52 | $ [sudo] pod install 53 | 54 | That's all, now open just created .xcworkspace file 55 | 56 | Usage 57 | ----- 58 | You can look at QTreeSample project to see `QTree-objc` in action. 59 | 60 | Contact 61 | ------- 62 | Aleksey Kozhevnikov 63 | * [blackm00n on GitHub](https://github.com/blackm00n) 64 | * aleksey.kozhevnikov@gmail.com 65 | * [@kozhevnikoff](https://twitter.com/kozhevnikoff) 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /QTreeSample/QTreeSample/ClusterAnnotationView.m: -------------------------------------------------------------------------------- 1 | // 2 | // This file is subject to the terms and conditions defined in 3 | // file 'LICENSE.md', which is part of this source code package. 4 | // 5 | 6 | #import "ClusterAnnotationView.h" 7 | #import "QCluster.h" 8 | 9 | @implementation ClusterAnnotationView 10 | 11 | +(NSString*)reuseId 12 | { 13 | return NSStringFromClass(self); 14 | } 15 | 16 | +(NSDictionary*)textAttributes 17 | { 18 | NSMutableParagraphStyle* paragraphStyle = [[NSMutableParagraphStyle alloc] init]; 19 | paragraphStyle.alignment = NSTextAlignmentCenter; 20 | return @{NSParagraphStyleAttributeName : paragraphStyle, 21 | NSForegroundColorAttributeName : [UIColor whiteColor], 22 | NSFontAttributeName : [UIFont boldSystemFontOfSize:12]}; 23 | } 24 | 25 | +(CGRect)boundsForCluster:(QCluster*)cluster 26 | { 27 | const CGSize textSize = [[@(cluster.objectsCount) stringValue] sizeWithAttributes:[self textAttributes]]; 28 | const CGFloat side = ceilf(MAX(textSize.height, textSize.width)) + 10; 29 | return CGRectMake(0, 0, side, side); 30 | } 31 | 32 | 33 | -(instancetype)initWithCluster:(QCluster*)cluster 34 | { 35 | self = [super initWithAnnotation:(id)cluster reuseIdentifier:[[self class] reuseId]]; 36 | if( !self ) { 37 | return nil; 38 | } 39 | self.opaque = NO; 40 | self.backgroundColor = [UIColor clearColor]; 41 | return self; 42 | } 43 | 44 | -(void)setCluster:(QCluster*)cluster 45 | { 46 | _cluster = cluster; 47 | self.annotation = (id)cluster; 48 | self.bounds = [[self class] boundsForCluster:cluster]; 49 | [self setNeedsDisplay]; 50 | } 51 | 52 | -(void)drawRect:(CGRect)rect 53 | { 54 | CGContextRef context = UIGraphicsGetCurrentContext(); 55 | CGContextSetAllowsAntialiasing(context, true); 56 | 57 | [[UIColor whiteColor] setFill]; 58 | const CGRect outerRect = CGRectInset(rect, 1, 1); 59 | CGContextFillEllipseInRect(context, outerRect); 60 | 61 | [[UIColor colorWithRed:0 green:122/255. blue:1 alpha:1] setFill]; 62 | const CGRect innerRect = CGRectInset(rect, 3, 3); 63 | CGContextFillEllipseInRect(context, innerRect); 64 | 65 | [[UIColor lightGrayColor] setStroke]; 66 | CGContextSetLineWidth(context, 1); 67 | CGContextStrokeEllipseInRect(context, outerRect); 68 | CGContextStrokeEllipseInRect(context, innerRect); 69 | 70 | NSString* text = [@(self.cluster.objectsCount) stringValue]; 71 | NSDictionary* attributes = [[self class] textAttributes]; 72 | const CGSize textSize = [text sizeWithAttributes:attributes]; 73 | CGRect textRect = CGRectInset(rect, 5, 5); 74 | textRect.origin.y = rect.origin.y + (rect.size.height - textSize.height) / 2; 75 | textRect.size.height = textSize.height; 76 | [text drawInRect:textRect withAttributes:attributes]; 77 | } 78 | 79 | @end -------------------------------------------------------------------------------- /QTree/QTree/QTree.m: -------------------------------------------------------------------------------- 1 | // 2 | // This file is subject to the terms and conditions defined in 3 | // file 'LICENSE.md', which is part of this source code package. 4 | // 5 | 6 | #import "QTree.h" 7 | #import "QNode.h" 8 | #import "QTreeGeometryUtils.h" 9 | 10 | @interface QTree() 11 | 12 | @property(nonatomic, strong) QNode* rootNode; 13 | 14 | @end 15 | 16 | @implementation QTree 17 | 18 | -(id)init 19 | { 20 | self = [super init]; 21 | if( !self ) { 22 | return nil; 23 | } 24 | [self cleanup]; 25 | return self; 26 | } 27 | 28 | - (void) cleanup 29 | { 30 | self.rootNode = [[QNode alloc] initWithRegion:MKCoordinateRegionForMapRect(MKMapRectWorld)]; 31 | } 32 | 33 | -(void)insertObject:(id)insertableObject 34 | { 35 | [self.rootNode insertObject:insertableObject]; 36 | } 37 | 38 | -(void)removeObject:(id)insertableObject 39 | { 40 | [self.rootNode removeObject:insertableObject]; 41 | } 42 | 43 | -(NSUInteger)count 44 | { 45 | return self.rootNode.count; 46 | } 47 | 48 | -(NSArray*)getObjectsInRegion:(MKCoordinateRegion)region minNonClusteredSpan:(CLLocationDegrees)span fillClusters:(BOOL)fillClusters 49 | { 50 | return [self.rootNode getObjectsInRegion:region minNonClusteredSpan:span fillClusters:fillClusters]; 51 | } 52 | 53 | -(NSArray*)getObjectsInRegion:(MKCoordinateRegion)region minNonClusteredSpan:(CLLocationDegrees)span 54 | { 55 | return [self.rootNode getObjectsInRegion:region minNonClusteredSpan:span fillClusters:NO]; 56 | } 57 | 58 | -(NSArray*)neighboursForLocation:(CLLocationCoordinate2D)location limitCount:(NSUInteger)limit 59 | { 60 | NSArray* nodesPath = [self nodesPathForLocation:location]; 61 | for( QNode* node in nodesPath.reverseObjectEnumerator ) { 62 | if( node.count < limit && node != [nodesPath firstObject] ) { 63 | continue; 64 | } 65 | MKCoordinateRegion region; 66 | NSPredicate* predicate = nil; 67 | if( node == self.rootNode ) { 68 | region = node.region; 69 | } else { 70 | const CLLocationDegrees latitudeDelta = 2 * (node.region.span.latitudeDelta / 2 - fabs(node.region.center.latitude - location.latitude)); 71 | const CLLocationDegrees longitudeDelta = 2 * (node.region.span.longitudeDelta / 2 - fabs(node.region.center.longitude - location.longitude)); 72 | const CLLocationDegrees delta = MIN(latitudeDelta, longitudeDelta); 73 | region = MKCoordinateRegionMake(location, MKCoordinateSpanMake(delta, delta)); 74 | predicate = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) { 75 | const CLLocationDegrees distance = sqrt(pow(evaluatedObject.coordinate.latitude - location.latitude, 2) + pow(evaluatedObject.coordinate.longitude - location.longitude, 2)); 76 | return distance <= delta; 77 | }]; 78 | } 79 | NSMutableArray* objects = [[self getObjectsInRegion:region minNonClusteredSpan:0] mutableCopy]; 80 | if( predicate != nil ) { 81 | [objects filterUsingPredicate:predicate]; 82 | } 83 | if( objects.count < limit && node != [nodesPath firstObject] ) { 84 | continue; 85 | } 86 | [objects sortUsingComparator:^NSComparisonResult(id obj1, id obj2) 87 | { 88 | CLLocationDistance m1 = CLMetersBetweenCoordinates(obj1.coordinate, location); 89 | CLLocationDistance m2 = CLMetersBetweenCoordinates(obj2.coordinate, location); 90 | if( m1 < m2 ) { 91 | return NSOrderedAscending; 92 | } else if( m1 > m2 ) { 93 | return NSOrderedDescending; 94 | } else { 95 | return NSOrderedSame; 96 | } 97 | }]; 98 | return [objects subarrayWithRange:NSMakeRange(0, MIN(limit, objects.count))]; 99 | } 100 | return @[]; 101 | } 102 | 103 | -(NSArray*)nodesPathForLocation:(CLLocationCoordinate2D)location 104 | { 105 | if( !MKCoordinateRegionContainsCoordinate(self.rootNode.region, location) ) { 106 | return @[]; 107 | } 108 | QNode* cur = self.rootNode; 109 | NSMutableArray* result = [NSMutableArray array]; 110 | while( cur ) { 111 | [result addObject:cur]; 112 | cur = [cur childNodeForLocation:location]; 113 | } 114 | return result; 115 | } 116 | 117 | @end 118 | -------------------------------------------------------------------------------- /QTreeSample/QTreeSample/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // This file is subject to the terms and conditions defined in 3 | // file 'LICENSE.md', which is part of this source code package. 4 | // 5 | 6 | #import "ViewController.h" 7 | #import "QTree.h" 8 | #import "DummyAnnotation.h" 9 | #import "QCluster.h" 10 | #import "ClusterAnnotationView.h" 11 | 12 | static NSInteger kMaxObjectsCount = 1000; 13 | 14 | inline static CLLocationCoordinate2D referenceLocation() 15 | { 16 | return CLLocationCoordinate2DMake(50, 14.42); 17 | } 18 | 19 | inline static CLLocationDegrees degreesDispersion() 20 | { 21 | return 0.5; 22 | } 23 | 24 | @interface ViewController() 25 | 26 | @property(nonatomic, weak) IBOutlet MKMapView* mapView; 27 | @property(nonatomic, weak) IBOutlet UISegmentedControl* segmentedControl; 28 | 29 | @property(nonatomic, strong) QTree* qTree; 30 | 31 | @end 32 | 33 | @implementation ViewController 34 | 35 | -(void)awakeFromNib 36 | { 37 | [super awakeFromNib]; 38 | self.qTree = [QTree new]; 39 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^ 40 | { 41 | srand48(time(0)); 42 | for( NSUInteger i = 0; i < kMaxObjectsCount; ++i ) { 43 | DummyAnnotation* object = [DummyAnnotation new]; 44 | object.coordinate = CLLocationCoordinate2DMake(referenceLocation().latitude + degreesDispersion() * (1 - 2 * drand48()), 45 | referenceLocation().longitude + degreesDispersion() * (1 - 2 * drand48())); 46 | [self.qTree insertObject:object]; 47 | dispatch_async(dispatch_get_main_queue(), ^ 48 | { 49 | [self reloadAnnotations]; 50 | }); 51 | } 52 | }); 53 | } 54 | 55 | -(void)viewDidLoad 56 | { 57 | [super viewDidLoad]; 58 | [self.mapView setCenterCoordinate:referenceLocation()]; 59 | } 60 | 61 | -(void)reloadAnnotations 62 | { 63 | if( !self.isViewLoaded ) { 64 | return; 65 | } 66 | 67 | const MKCoordinateRegion mapRegion = self.mapView.region; 68 | BOOL useClustering = (self.segmentedControl.selectedSegmentIndex == 0); 69 | const CLLocationDegrees minNonClusteredSpan = useClustering ? MIN(mapRegion.span.latitudeDelta, mapRegion.span.longitudeDelta) / 5 70 | : 0; 71 | NSArray* objects = [self.qTree getObjectsInRegion:mapRegion minNonClusteredSpan:minNonClusteredSpan]; 72 | 73 | NSMutableArray* annotationsToRemove = [self.mapView.annotations mutableCopy]; 74 | [annotationsToRemove removeObject:self.mapView.userLocation]; 75 | [annotationsToRemove removeObjectsInArray:objects]; 76 | [self.mapView removeAnnotations:annotationsToRemove]; 77 | 78 | NSMutableArray* annotationsToAdd = [objects mutableCopy]; 79 | [annotationsToAdd removeObjectsInArray:self.mapView.annotations]; 80 | 81 | [self.mapView addAnnotations:annotationsToAdd]; 82 | } 83 | 84 | -(IBAction)segmentChanged:(id)sender 85 | { 86 | [self reloadAnnotations]; 87 | } 88 | 89 | #pragma mark MKMapViewDelegate 90 | 91 | -(void)mapView:(MKMapView*)mapView regionDidChangeAnimated:(BOOL)animated 92 | { 93 | [self reloadAnnotations]; 94 | } 95 | 96 | -(MKAnnotationView*)mapView:(MKMapView*)mapView viewForAnnotation:(id)annotation 97 | { 98 | if( [annotation isKindOfClass:[QCluster class]] ) { 99 | ClusterAnnotationView* annotationView = (ClusterAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:[ClusterAnnotationView reuseId]]; 100 | if( !annotationView ) { 101 | annotationView = [[ClusterAnnotationView alloc] initWithCluster:(QCluster*)annotation]; 102 | } 103 | annotationView.cluster = (QCluster*)annotation; 104 | return annotationView; 105 | } else { 106 | return nil; 107 | } 108 | } 109 | 110 | -(void)mapView:(MKMapView*)mapView didSelectAnnotationView:(MKAnnotationView*)view 111 | { 112 | id annotation = view.annotation; 113 | if( [annotation isKindOfClass:[QCluster class]] ) { 114 | QCluster* cluster = (QCluster*)annotation; 115 | [mapView setRegion:MKCoordinateRegionMake(cluster.coordinate, MKCoordinateSpanMake(2.5 * cluster.radius, 2.5 * cluster.radius)) 116 | animated:YES]; 117 | } else { 118 | [self.qTree removeObject:(id)annotation]; 119 | [self reloadAnnotations]; 120 | } 121 | } 122 | 123 | @end -------------------------------------------------------------------------------- /QTreeSample/QTreeSample/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /QTree/QTreeTests/QTreeTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // This file is subject to the terms and conditions defined in 3 | // file 'LICENSE.md', which is part of this source code package. 4 | // 5 | 6 | @import XCTest; 7 | 8 | #import "QTree.h" 9 | #import "LocationBasedMessage.h" 10 | #import "QNode.h" 11 | 12 | @interface QTreeTests : XCTestCase 13 | 14 | @property(nonatomic, strong) QTree* tree; 15 | 16 | @end 17 | 18 | @implementation QTreeTests 19 | 20 | +(CLLocationCoordinate2D)tallinLocation 21 | { 22 | return CLLocationCoordinate2DMake(59.43, 24.75); 23 | } 24 | 25 | +(CLLocationCoordinate2D)gainesvilleLocation 26 | { 27 | return CLLocationCoordinate2DMake(29.651997, 82.324992); 28 | } 29 | 30 | +(LocationBasedMessage*)moscowBasedMessage 31 | { 32 | const CLLocationCoordinate2D moscowLocation = CLLocationCoordinate2DMake(57.75, 37.62); 33 | LocationBasedMessage* msg = [LocationBasedMessage new]; 34 | msg.message = @"Hello Moscow!"; 35 | msg.coordinate = moscowLocation; 36 | return msg; 37 | } 38 | 39 | +(LocationBasedMessage*)stPetersburgBasedMessage 40 | { 41 | const CLLocationCoordinate2D stPetersburgLocation = CLLocationCoordinate2DMake(59.95, 30.32); 42 | LocationBasedMessage* msg = [LocationBasedMessage new]; 43 | msg.message = @"Hi St. Petersburg!"; 44 | msg.coordinate = stPetersburgLocation; 45 | return msg; 46 | } 47 | 48 | 49 | -(void)setUp 50 | { 51 | [super setUp]; 52 | self.tree = [QTree new]; 53 | } 54 | 55 | -(void)tearDown 56 | { 57 | [super tearDown]; 58 | } 59 | 60 | -(void)testSameObjects 61 | { 62 | LocationBasedMessage* moscowBasedMessage = [QTreeTests moscowBasedMessage]; 63 | [self.tree insertObject:moscowBasedMessage]; 64 | 65 | LocationBasedMessage* stPetersburgBasedMessage = [QTreeTests stPetersburgBasedMessage]; 66 | [self.tree insertObject:stPetersburgBasedMessage]; 67 | 68 | [self.tree insertObject:moscowBasedMessage]; 69 | 70 | XCTAssertEqual(self.tree.count, 2, @"Tree should contain only 2 objects"); 71 | } 72 | 73 | -(void)testSatellites 74 | { 75 | [self.tree insertObject:[QTreeTests moscowBasedMessage]]; 76 | [self.tree insertObject:[QTreeTests stPetersburgBasedMessage]]; 77 | [self.tree insertObject:[QTreeTests moscowBasedMessage]]; 78 | 79 | XCTAssertEqual(self.tree.count, 3, @"Tree should contain 3 objects"); 80 | } 81 | 82 | -(void)testNeighbors 83 | { 84 | const CLLocationCoordinate2D tallinLocation = [QTreeTests tallinLocation]; 85 | 86 | LocationBasedMessage* moscowBasedMessage = [QTreeTests moscowBasedMessage]; 87 | [self.tree insertObject:moscowBasedMessage]; 88 | 89 | { 90 | NSArray* neighbors = [self.tree neighboursForLocation:tallinLocation limitCount:2]; 91 | XCTAssertEqual(neighbors.count, 1, @"Should find only 1 object nearby"); 92 | } 93 | 94 | LocationBasedMessage* stPetersburgBasedMessage = [QTreeTests stPetersburgBasedMessage]; 95 | [self.tree insertObject:stPetersburgBasedMessage]; 96 | 97 | { 98 | NSArray* neighbors = [self.tree neighboursForLocation:tallinLocation limitCount:2]; 99 | XCTAssertEqual(neighbors.count, 2, @"Should find 2 objects"); 100 | XCTAssert([neighbors firstObject] == stPetersburgBasedMessage, @"Message near St. Petersburg should be the first neighbour"); 101 | XCTAssert([neighbors lastObject] == moscowBasedMessage, @"Message near Moscow should be the second and the last neighbour"); 102 | } 103 | { 104 | NSArray* neighbors = [self.tree neighboursForLocation:tallinLocation limitCount:1]; 105 | XCTAssertEqual(neighbors.count, 1, @"Should find only one object nearby"); 106 | XCTAssertEqual([neighbors firstObject], stPetersburgBasedMessage, @"Message near St. Petersburg should be the first neighbour"); 107 | } 108 | } 109 | 110 | -(void)testFetching 111 | { 112 | [self.tree insertObject:[QTreeTests moscowBasedMessage]]; 113 | LocationBasedMessage* stPetersburgBasedMessage = [QTreeTests stPetersburgBasedMessage]; 114 | [self.tree insertObject:stPetersburgBasedMessage]; 115 | 116 | { 117 | NSArray* objectsInRegion = [self.tree getObjectsInRegion:MKCoordinateRegionMake([QTreeTests tallinLocation], MKCoordinateSpanMake(12, 12)) 118 | minNonClusteredSpan:0]; 119 | XCTAssertEqual(objectsInRegion.count, 1, @"Should fetch only one object"); 120 | XCTAssert([objectsInRegion firstObject] == stPetersburgBasedMessage, @"Message near St. Petersburg should be found"); 121 | } 122 | { 123 | NSArray* objectsInRegion = [self.tree getObjectsInRegion:MKCoordinateRegionMake([QTreeTests tallinLocation], MKCoordinateSpanMake(10, 10)) 124 | minNonClusteredSpan:0]; 125 | XCTAssertEqual(objectsInRegion.count, 0, @"Should not fetch any object"); 126 | } 127 | } 128 | 129 | -(void)testRemoval 130 | { 131 | LocationBasedMessage* moscowBasedMessage = [QTreeTests moscowBasedMessage]; 132 | [self.tree insertObject:moscowBasedMessage]; 133 | LocationBasedMessage* stPetersburgBasedMessage = [QTreeTests stPetersburgBasedMessage]; 134 | [self.tree insertObject:stPetersburgBasedMessage]; 135 | [self.tree removeObject:stPetersburgBasedMessage]; 136 | NSArray* allObjects = [self.tree getObjectsInRegion:MKCoordinateRegionForMapRect(MKMapRectWorld) minNonClusteredSpan:0]; 137 | XCTAssertEqual(allObjects.count, 1, @"Should contain only one object"); 138 | XCTAssertEqual(allObjects[0], moscowBasedMessage, @"Object should be left"); 139 | } 140 | 141 | -(void)testFarAwayFetch 142 | { 143 | LocationBasedMessage* msg = [LocationBasedMessage new]; 144 | msg.message = @"reported by andjash"; 145 | msg.coordinate = CLLocationCoordinate2DMake(34.055938, -118.248386); 146 | [self.tree insertObject:msg]; 147 | NSArray* fetchResult = [self.tree neighboursForLocation:CLLocationCoordinate2DMake(55.801854, 37.508097) limitCount:NSUIntegerMax]; 148 | XCTAssertEqual(fetchResult.count, 1, @"Number of fetched objects should be 1, but is %@", @(fetchResult.count)); 149 | } 150 | 151 | -(void)testSameLocationCluster 152 | { 153 | LocationBasedMessage* msg = [LocationBasedMessage new]; 154 | msg.message = @"pull request #6 by salagadoola"; 155 | msg.coordinate = [QTreeTests gainesvilleLocation]; 156 | 157 | LocationBasedMessage* msg2 = [LocationBasedMessage new]; 158 | msg2.message = @"Gainesville"; 159 | msg2.coordinate = [QTreeTests gainesvilleLocation]; 160 | 161 | LocationBasedMessage* msg3 = [LocationBasedMessage new]; 162 | msg3.message = @"UF"; 163 | msg3.coordinate = [QTreeTests gainesvilleLocation]; 164 | 165 | [self.tree insertObject:msg]; 166 | 167 | MKCoordinateRegion const region = MKCoordinateRegionMake([QTreeTests gainesvilleLocation], MKCoordinateSpanMake(1, 1)); 168 | 169 | NSArray* objectsInRegion = [self.tree getObjectsInRegion:region minNonClusteredSpan:0.01]; 170 | XCTAssert([[objectsInRegion firstObject] isKindOfClass:[LocationBasedMessage class]], @"When span is non-zero but only one object is in region that object should be returned, not cluster"); 171 | 172 | [self.tree insertObject:msg2]; 173 | [self.tree insertObject:msg3]; 174 | 175 | NSArray* objectsInRegionZeroSpan = [self.tree getObjectsInRegion:region minNonClusteredSpan:0]; 176 | XCTAssertEqual(objectsInRegionZeroSpan.count, 3, @"When span is 0 no clusters should be returned, but all 3 objects"); 177 | 178 | NSArray* objectsInRegionNonZeroSpan = [self.tree getObjectsInRegion:region minNonClusteredSpan:0.01]; 179 | XCTAssert(objectsInRegionNonZeroSpan.count == 1 180 | && [objectsInRegionNonZeroSpan[0] isKindOfClass:[QCluster class]], @"When span is non-zero just one cluster should be returned"); 181 | } 182 | 183 | - (void)testFetchClustersWithObjects 184 | { 185 | LocationBasedMessage* msg = [LocationBasedMessage new]; 186 | msg.message = @"issue #7"; 187 | msg.coordinate = [QTreeTests gainesvilleLocation]; 188 | 189 | LocationBasedMessage* msg2 = [LocationBasedMessage new]; 190 | msg2.message = @"near Gainesville"; 191 | msg2.coordinate = [QTreeTests gainesvilleLocation]; 192 | 193 | LocationBasedMessage* msg3 = [LocationBasedMessage new]; 194 | msg3.message = @"near Gainesville 2"; 195 | msg3.coordinate = [QTreeTests gainesvilleLocation]; 196 | 197 | [self.tree insertObject:msg]; 198 | [self.tree insertObject:msg2]; 199 | [self.tree insertObject:msg3]; 200 | 201 | MKCoordinateRegion const region = MKCoordinateRegionMake([QTreeTests gainesvilleLocation], MKCoordinateSpanMake(1, 1)); 202 | 203 | NSArray* objectsInRegion = [self.tree getObjectsInRegion:region minNonClusteredSpan:0.01 fillClusters:YES]; 204 | XCTAssert(objectsInRegion.count == 1 && [objectsInRegion[0] isKindOfClass:[QCluster class]], @"Should get only 1 cluster"); 205 | XCTAssert([objectsInRegion[0] objects].count == 3 206 | && [[objectsInRegion[0] objects] containsObject:msg] 207 | && [[objectsInRegion[0] objects] containsObject:msg2] 208 | && [[objectsInRegion[0] objects] containsObject:msg3], @"All 3 objects should be included in cluster"); 209 | 210 | } 211 | 212 | @end 213 | -------------------------------------------------------------------------------- /QTree/QTree/QNode.m: -------------------------------------------------------------------------------- 1 | // 2 | // This file is subject to the terms and conditions defined in 3 | // file 'LICENSE.md', which is part of this source code package. 4 | // 5 | 6 | #import "QNode.h" 7 | #import "QTreeGeometryUtils.h" 8 | 9 | static const CLLocationDistance MinDistinguishableMetersDistance = 0.5; 10 | 11 | static CLLocationDegrees DegreesMetric(CLLocationCoordinate2D c1, CLLocationCoordinate2D c2) 12 | { 13 | return sqrt(pow(c1.latitude - c2.latitude, 2) + pow(c1.longitude - c2.longitude, 2)); 14 | } 15 | 16 | static CLLocationCoordinate2D MeanCoordinate(NSArray* insertableObjects) 17 | { 18 | CLLocationDegrees meanLatitude = 0; 19 | CLLocationDegrees meanLongitude = 0; 20 | for( id object in insertableObjects ) { 21 | meanLongitude += object.coordinate.longitude; 22 | meanLatitude += object.coordinate.latitude; 23 | } 24 | meanLatitude /= insertableObjects.count; 25 | meanLongitude /= insertableObjects.count; 26 | return CLLocationCoordinate2DMake(meanLatitude, meanLongitude); 27 | } 28 | 29 | static CLLocationDegrees CircumscribedDegreesRadius(NSArray* insertableObjects, CLLocationCoordinate2D center) 30 | { 31 | CLLocationDegrees radius = 0; 32 | for( id object in insertableObjects ) { 33 | radius = MAX(radius, DegreesMetric(object.coordinate, center)); 34 | } 35 | return radius; 36 | } 37 | 38 | @interface QNode() 39 | 40 | @property(nonatomic, assign) MKCoordinateRegion region; 41 | 42 | @property(nonatomic, strong) id leadObject; 43 | @property(nonatomic, strong) NSMutableSet* satellites; 44 | 45 | @property(nonatomic, assign) NSUInteger count; 46 | 47 | @property(nonatomic, strong) QCluster* cachedCluster; 48 | 49 | @property(nonatomic, retain) QNode* upLeft; 50 | @property(nonatomic, retain) QNode* upRight; 51 | @property(nonatomic, retain) QNode* downLeft; 52 | @property(nonatomic, retain) QNode* downRight; 53 | 54 | @end 55 | 56 | @implementation QNode 57 | 58 | +(instancetype)nodeWithRegion:(MKCoordinateRegion)region 59 | { 60 | return [[QNode alloc] initWithRegion:region]; 61 | } 62 | 63 | 64 | -(id)initWithRegion:(MKCoordinateRegion)region 65 | { 66 | self = [super init]; 67 | if( !self ) { 68 | return nil; 69 | } 70 | self.region = region; 71 | return self; 72 | } 73 | 74 | -(CLLocationDegrees)centerLatitude 75 | { 76 | return self.region.center.latitude; 77 | } 78 | 79 | -(CLLocationDegrees)centerLongitude 80 | { 81 | return self.region.center.longitude; 82 | } 83 | 84 | -(BOOL)isLeaf 85 | { 86 | return !self.upLeft && !self.downLeft && !self.upRight && !self.downRight; 87 | } 88 | 89 | -(BOOL)insertObject:(id)insertableObject 90 | { 91 | if( self.leadObject ) { 92 | if( CLMetersBetweenCoordinates(self.leadObject.coordinate, insertableObject.coordinate) >= MinDistinguishableMetersDistance ) { 93 | // Move self objects deeper 94 | NSAssert([self isLeaf], @"Node containing objects should be a leaf"); 95 | [self insertLeadObject:self.leadObject withSatellites:self.satellites]; 96 | self.leadObject = nil; 97 | self.satellites = nil; 98 | } else { 99 | if( ![self.leadObject isEqual:insertableObject] ) { 100 | self.count += 1; 101 | self.cachedCluster = nil; 102 | if( !self.satellites ) { 103 | self.satellites = [NSMutableSet set]; 104 | } 105 | [self.satellites addObject:insertableObject]; 106 | return YES; 107 | } else { 108 | // Can't distinguish two objects 109 | return NO; 110 | } 111 | } 112 | } 113 | if( [self insertLeadObject:insertableObject withSatellites:nil] ) { 114 | self.count += 1; 115 | return YES; 116 | } else { 117 | return NO; 118 | } 119 | } 120 | 121 | -(BOOL)removeObject:(id)insertableObject 122 | { 123 | if( self.leadObject ) { 124 | if( [self.satellites containsObject:insertableObject] ) { 125 | [self.satellites removeObject:insertableObject]; 126 | self.cachedCluster = nil; 127 | self.count -= 1; 128 | return YES; 129 | } else if( [self.leadObject isEqual:insertableObject] ) { 130 | self.leadObject = [self.satellites anyObject]; 131 | if( self.leadObject ) { 132 | [self.satellites removeObject:self.leadObject]; 133 | } // else should delete this node then 134 | self.cachedCluster = nil; 135 | self.count -= 1; 136 | return YES; 137 | } else { 138 | return NO; 139 | } 140 | } 141 | 142 | QNode* __strong *pNode = [self childNodeForObject:insertableObject]; 143 | 144 | if( *pNode ) { 145 | BOOL result = [*pNode removeObject:insertableObject]; 146 | if( result ) { 147 | self.cachedCluster = nil; 148 | self.count -= 1; 149 | if( (*pNode).count == 0 ) { 150 | *pNode = nil; 151 | } 152 | QNode* __strong *pChild = [self theOnlyChildNode]; 153 | if( pChild != nil && [(*pChild) isLeaf] ) { 154 | self.leadObject = (*pChild).leadObject; 155 | self.satellites = (*pChild).satellites; 156 | NSAssert(self.count == (*pChild).count, @"Should be in sync already"); 157 | *pChild = nil; 158 | } 159 | } 160 | return result; 161 | } else { 162 | return NO; 163 | } 164 | } 165 | 166 | -(QNode* __strong *)childNodeForObject:(id)insertableObject 167 | { 168 | QNode* __strong *pNode = nil; 169 | 170 | const BOOL down = insertableObject.coordinate.latitude < self.centerLatitude; 171 | const BOOL left = insertableObject.coordinate.longitude < self.centerLongitude; 172 | 173 | if( down ) { 174 | if( left ) { 175 | pNode = &_downLeft; 176 | } else { 177 | pNode = &_downRight; 178 | } 179 | } else { 180 | if( left ) { 181 | pNode = &_upLeft; 182 | } else { 183 | pNode = &_upRight; 184 | } 185 | } 186 | 187 | return pNode; 188 | } 189 | 190 | // returns nil if there are more than one child 191 | -(QNode* __strong *)theOnlyChildNode 192 | { 193 | QNode* __strong *pChild = nil; 194 | 195 | while( YES ) { 196 | if( self.upLeft ) { 197 | pChild = &_upLeft; 198 | } 199 | if( self.downLeft ) { 200 | if( pChild ) { 201 | pChild = nil; 202 | break; 203 | } 204 | pChild = &_downLeft; 205 | } 206 | if( self.upRight ) { 207 | if( pChild ) { 208 | pChild = nil; 209 | break; 210 | } 211 | pChild = &_upRight; 212 | } 213 | if( self.downRight ) { 214 | if( pChild ) { 215 | pChild = nil; 216 | break; 217 | } 218 | pChild = &_downRight; 219 | } 220 | break; 221 | } 222 | 223 | return pChild; 224 | } 225 | 226 | -(BOOL)insertLeadObject:(id)leadObject withSatellites:(NSSet*)satellites 227 | { 228 | self.cachedCluster = nil; 229 | 230 | QNode* __strong *pNode = [self childNodeForObject:leadObject]; 231 | 232 | if( !*pNode ) { 233 | const BOOL down = leadObject.coordinate.latitude < self.centerLatitude; 234 | const BOOL left = leadObject.coordinate.longitude < self.centerLongitude; 235 | 236 | const CLLocationDegrees latDeltaBy2 = self.region.span.latitudeDelta / 2; 237 | const CLLocationDegrees newLat = self.centerLatitude + latDeltaBy2 * (down ? -1 : +1) / 2; 238 | 239 | const CLLocationDegrees lngDeltaBy2 = self.region.span.longitudeDelta / 2; 240 | const CLLocationDegrees newLng = self.centerLongitude + lngDeltaBy2 * (left ? -1 : +1) / 2; 241 | 242 | const CLLocationCoordinate2D newCenter = CLLocationCoordinate2DMake(newLat, newLng); 243 | const MKCoordinateSpan newSpan = MKCoordinateSpanMake(latDeltaBy2, lngDeltaBy2); 244 | 245 | QNode* newNode = [QNode nodeWithRegion:MKCoordinateRegionMake(newCenter, newSpan)]; 246 | newNode.leadObject = leadObject; 247 | newNode.satellites = [satellites mutableCopy]; 248 | newNode.count = 1 + satellites.count; 249 | 250 | *pNode = newNode; 251 | 252 | return YES; 253 | } else { 254 | NSAssert(!satellites, @"Satellites should be non-nil only when moving objects deeper"); 255 | return [*pNode insertObject:leadObject]; 256 | } 257 | } 258 | 259 | -(NSArray*)getObjectsInRegion:(MKCoordinateRegion)region minNonClusteredSpan:(CLLocationDegrees)span 260 | { 261 | return [self getObjectsInRegion:region minNonClusteredSpan:span fillClusters:NO]; 262 | } 263 | 264 | -(NSArray*)getObjectsInRegion:(MKCoordinateRegion)region minNonClusteredSpan:(CLLocationDegrees)span fillClusters:(BOOL)fillClusters 265 | { 266 | if( !MKCoordinateRegionIntersectsRegion(self.region, region) ) { 267 | return @[]; 268 | } 269 | NSMutableArray* result = [NSMutableArray array]; 270 | if( self.leadObject ) { 271 | if( MKCoordinateRegionContainsCoordinate(region, self.leadObject.coordinate) ) { 272 | if ( span == 0 || self.count == 1 ) { 273 | [result addObject:self.leadObject]; 274 | [result addObjectsFromArray:self.satellites.allObjects]; 275 | } else { 276 | [result addObject:[self getCluster:fillClusters]]; 277 | } 278 | } 279 | } else if( MIN(self.region.span.latitudeDelta, self.region.span.longitudeDelta) >= span ) { 280 | [result addObjectsFromArray:[self.upLeft getObjectsInRegion:region minNonClusteredSpan:span fillClusters:fillClusters]]; 281 | [result addObjectsFromArray:[self.upRight getObjectsInRegion:region minNonClusteredSpan:span fillClusters:fillClusters]]; 282 | [result addObjectsFromArray:[self.downLeft getObjectsInRegion:region minNonClusteredSpan:span fillClusters:fillClusters]]; 283 | [result addObjectsFromArray:[self.downRight getObjectsInRegion:region minNonClusteredSpan:span fillClusters:fillClusters]]; 284 | } else { 285 | [result addObject:[self getCluster:fillClusters]]; 286 | } 287 | return result; 288 | } 289 | 290 | -(QCluster*)getCluster:(BOOL)fillCluster 291 | { 292 | if( !self.cachedCluster ) { 293 | QCluster* cluster = [[QCluster alloc] init]; 294 | 295 | NSArray* allChildren = [self getObjectsInRegion:self.region minNonClusteredSpan:0]; 296 | CLLocationCoordinate2D meanCenter = MeanCoordinate(allChildren); 297 | cluster.coordinate = meanCenter; 298 | cluster.objectsCount = allChildren.count; 299 | if( fillCluster ) { 300 | cluster.objects = allChildren; 301 | } 302 | cluster.radius = CircumscribedDegreesRadius(allChildren, meanCenter); 303 | 304 | self.cachedCluster = cluster; 305 | } 306 | return self.cachedCluster; 307 | } 308 | 309 | -(QNode*)childNodeForLocation:(CLLocationCoordinate2D)location 310 | { 311 | if( self.downRight && MKCoordinateRegionContainsCoordinate(self.downRight.region, location) ) { 312 | return self.downRight; 313 | } else if( self.downLeft && MKCoordinateRegionContainsCoordinate(self.downLeft.region, location) ) { 314 | return self.downLeft; 315 | } else if( self.upRight && MKCoordinateRegionContainsCoordinate(self.upRight.region, location) ) { 316 | return self.upRight; 317 | } else if( self.upLeft && MKCoordinateRegionContainsCoordinate(self.upLeft.region, location) ) { 318 | return self.upLeft; 319 | } else { 320 | return nil; 321 | } 322 | } 323 | 324 | @end 325 | -------------------------------------------------------------------------------- /QTreeSample/QTreeSample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 539362711826EEE000A0DFEE /* libQTree.a in Frameworks */ = {isa = PBXBuildFile; fileRef = AF345C5DC9246E4A5A4A7254 /* libQTree.a */; }; 11 | 53FCAD45182917EC0041EE12 /* QCluster+Annotation.m in Sources */ = {isa = PBXBuildFile; fileRef = AF34535EED97715F1790DCB3 /* QCluster+Annotation.m */; }; 12 | AF34506EDB65C48F8DC31E92 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AF345518D6ED1CE1E957F1D0 /* Main.storyboard */; }; 13 | AF345178CE544FA9731BC757 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = AF3453A99B021F0804E08A51 /* AppDelegate.m */; }; 14 | AF3451EA3CF1A4370B32AF7C /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = AF34545043D62A00C724EC89 /* ViewController.m */; }; 15 | AF345494258EAC0139FF940C /* ClusterAnnotationView.m in Sources */ = {isa = PBXBuildFile; fileRef = AF345F860E89AB83FAACF57F /* ClusterAnnotationView.m */; }; 16 | AF3455DEC4AEADB5E72207C7 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AF3458C01D9742437F7A78F6 /* Images.xcassets */; }; 17 | AF34572F1730F2DA2D0D594C /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = AF3459617E4B9CBDD78E5A73 /* main.m */; }; 18 | AF3457D2B236A778E88A1413 /* DummyAnnotation.m in Sources */ = {isa = PBXBuildFile; fileRef = AF345C297F87A27863FB1DAD /* DummyAnnotation.m */; }; 19 | AF3459B9DEF58121C181846B /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = AF345F3CE9066F90D749F2D6 /* InfoPlist.strings */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXContainerItemProxy section */ 23 | 5393626F1826EED100A0DFEE /* PBXContainerItemProxy */ = { 24 | isa = PBXContainerItemProxy; 25 | containerPortal = AF345F11C8F9EE7A5C8BD511 /* QTree.xcodeproj */; 26 | proxyType = 1; 27 | remoteGlobalIDString = 5393622718258B2F00A0DFEE; 28 | remoteInfo = QTree; 29 | }; 30 | AF3455FC66930D5A5DECAE54 /* PBXContainerItemProxy */ = { 31 | isa = PBXContainerItemProxy; 32 | containerPortal = AF345F11C8F9EE7A5C8BD511 /* QTree.xcodeproj */; 33 | proxyType = 2; 34 | remoteGlobalIDString = AF34548C89F5FBDFA178A2B1; 35 | remoteInfo = QTree; 36 | }; 37 | AF34594C4C147D0FD3ED81CA /* PBXContainerItemProxy */ = { 38 | isa = PBXContainerItemProxy; 39 | containerPortal = AF345F11C8F9EE7A5C8BD511 /* QTree.xcodeproj */; 40 | proxyType = 2; 41 | remoteGlobalIDString = AF34540024A2FCECB93351BC; 42 | remoteInfo = QTreeTests; 43 | }; 44 | /* End PBXContainerItemProxy section */ 45 | 46 | /* Begin PBXFileReference section */ 47 | AF34502F3947E327AD5F3E66 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 48 | AF34535EED97715F1790DCB3 /* QCluster+Annotation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "QCluster+Annotation.m"; sourceTree = ""; }; 49 | AF34538D6831A79CDBAD3E85 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 50 | AF3453A99B021F0804E08A51 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 51 | AF3453F036CCC3A0B5ADF59B /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 52 | AF34545043D62A00C724EC89 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 53 | AF3455EC96B053ADB6ACD86E /* QTreeSample-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "QTreeSample-Prefix.pch"; sourceTree = ""; }; 54 | AF3456DE70A0359325160A51 /* QTreeSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = QTreeSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 55 | AF34572E2281B6B4057362A0 /* QTreeSample-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.info; path = "QTreeSample-Info.plist"; sourceTree = ""; }; 56 | AF3457350812DB204A0689FC /* ClusterAnnotationView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClusterAnnotationView.h; sourceTree = ""; }; 57 | AF3457962E672136135C215D /* DummyAnnotation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DummyAnnotation.h; sourceTree = ""; }; 58 | AF3458C01D9742437F7A78F6 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 59 | AF3459617E4B9CBDD78E5A73 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 60 | AF345A66BB92372A2FB9EC40 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 61 | AF345C297F87A27863FB1DAD /* DummyAnnotation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DummyAnnotation.m; sourceTree = ""; }; 62 | AF345F11C8F9EE7A5C8BD511 /* QTree.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = QTree.xcodeproj; path = ../QTree/QTree.xcodeproj; sourceTree = ""; }; 63 | AF345F860E89AB83FAACF57F /* ClusterAnnotationView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ClusterAnnotationView.m; sourceTree = ""; }; 64 | AF345FC9FF5F675E519EB801 /* QCluster+Annotation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "QCluster+Annotation.h"; sourceTree = ""; }; 65 | /* End PBXFileReference section */ 66 | 67 | /* Begin PBXFrameworksBuildPhase section */ 68 | AF34583BBD0F904BB7EE78B4 /* Frameworks */ = { 69 | isa = PBXFrameworksBuildPhase; 70 | buildActionMask = 2147483647; 71 | files = ( 72 | 539362711826EEE000A0DFEE /* libQTree.a in Frameworks */, 73 | ); 74 | runOnlyForDeploymentPostprocessing = 0; 75 | }; 76 | /* End PBXFrameworksBuildPhase section */ 77 | 78 | /* Begin PBXGroup section */ 79 | AF34511B090D32267E607BAE /* Products */ = { 80 | isa = PBXGroup; 81 | children = ( 82 | AF3456DE70A0359325160A51 /* QTreeSample.app */, 83 | ); 84 | name = Products; 85 | sourceTree = ""; 86 | }; 87 | AF3455953EB431A7154E9726 /* Products */ = { 88 | isa = PBXGroup; 89 | children = ( 90 | AF345C5DC9246E4A5A4A7254 /* libQTree.a */, 91 | AF345206B0CA7E4AED7C13DE /* QTreeTests.xctest */, 92 | ); 93 | name = Products; 94 | sourceTree = ""; 95 | }; 96 | AF3458026ECC3790C0003055 /* Supporting Files */ = { 97 | isa = PBXGroup; 98 | children = ( 99 | AF34572E2281B6B4057362A0 /* QTreeSample-Info.plist */, 100 | AF345F3CE9066F90D749F2D6 /* InfoPlist.strings */, 101 | AF3459617E4B9CBDD78E5A73 /* main.m */, 102 | AF3455EC96B053ADB6ACD86E /* QTreeSample-Prefix.pch */, 103 | ); 104 | name = "Supporting Files"; 105 | sourceTree = ""; 106 | }; 107 | AF34590E342BC323D3AD4A04 = { 108 | isa = PBXGroup; 109 | children = ( 110 | AF345F11C8F9EE7A5C8BD511 /* QTree.xcodeproj */, 111 | AF34511B090D32267E607BAE /* Products */, 112 | AF345EF84ACF0D2297F768B4 /* QTreeSample */, 113 | ); 114 | sourceTree = ""; 115 | }; 116 | AF345EF84ACF0D2297F768B4 /* QTreeSample */ = { 117 | isa = PBXGroup; 118 | children = ( 119 | AF3458026ECC3790C0003055 /* Supporting Files */, 120 | AF345A66BB92372A2FB9EC40 /* AppDelegate.h */, 121 | AF3453A99B021F0804E08A51 /* AppDelegate.m */, 122 | AF3457962E672136135C215D /* DummyAnnotation.h */, 123 | AF345C297F87A27863FB1DAD /* DummyAnnotation.m */, 124 | AF3458C01D9742437F7A78F6 /* Images.xcassets */, 125 | AF345518D6ED1CE1E957F1D0 /* Main.storyboard */, 126 | AF345FC9FF5F675E519EB801 /* QCluster+Annotation.h */, 127 | AF34535EED97715F1790DCB3 /* QCluster+Annotation.m */, 128 | AF3453F036CCC3A0B5ADF59B /* ViewController.h */, 129 | AF34545043D62A00C724EC89 /* ViewController.m */, 130 | AF345F860E89AB83FAACF57F /* ClusterAnnotationView.m */, 131 | AF3457350812DB204A0689FC /* ClusterAnnotationView.h */, 132 | ); 133 | path = QTreeSample; 134 | sourceTree = ""; 135 | }; 136 | /* End PBXGroup section */ 137 | 138 | /* Begin PBXNativeTarget section */ 139 | AF345F0B37D5661B4197A176 /* QTreeSample */ = { 140 | isa = PBXNativeTarget; 141 | buildConfigurationList = AF345F48D525EE19BF12A9AD /* Build configuration list for PBXNativeTarget "QTreeSample" */; 142 | buildPhases = ( 143 | AF3456849B3BE2AEA655BEF9 /* Sources */, 144 | AF34583BBD0F904BB7EE78B4 /* Frameworks */, 145 | AF345C046F891A3FD550504A /* Resources */, 146 | ); 147 | buildRules = ( 148 | ); 149 | dependencies = ( 150 | 539362701826EED100A0DFEE /* PBXTargetDependency */, 151 | ); 152 | name = QTreeSample; 153 | productName = QTreeSample; 154 | productReference = AF3456DE70A0359325160A51 /* QTreeSample.app */; 155 | productType = "com.apple.product-type.application"; 156 | }; 157 | /* End PBXNativeTarget section */ 158 | 159 | /* Begin PBXProject section */ 160 | AF345F654AEB2E5778B84AFB /* Project object */ = { 161 | isa = PBXProject; 162 | attributes = { 163 | ORGANIZATIONNAME = "Aleksey Kozhevnikov"; 164 | }; 165 | buildConfigurationList = AF3452C89C892FA0A378198C /* Build configuration list for PBXProject "QTreeSample" */; 166 | compatibilityVersion = "Xcode 3.2"; 167 | developmentRegion = English; 168 | hasScannedForEncodings = 0; 169 | knownRegions = ( 170 | en, 171 | ); 172 | mainGroup = AF34590E342BC323D3AD4A04; 173 | productRefGroup = AF34511B090D32267E607BAE /* Products */; 174 | projectDirPath = ""; 175 | projectReferences = ( 176 | { 177 | ProductGroup = AF3455953EB431A7154E9726 /* Products */; 178 | ProjectRef = AF345F11C8F9EE7A5C8BD511 /* QTree.xcodeproj */; 179 | }, 180 | ); 181 | projectRoot = ""; 182 | targets = ( 183 | AF345F0B37D5661B4197A176 /* QTreeSample */, 184 | ); 185 | }; 186 | /* End PBXProject section */ 187 | 188 | /* Begin PBXReferenceProxy section */ 189 | AF345206B0CA7E4AED7C13DE /* QTreeTests.xctest */ = { 190 | isa = PBXReferenceProxy; 191 | fileType = wrapper.cfbundle; 192 | path = QTreeTests.xctest; 193 | remoteRef = AF34594C4C147D0FD3ED81CA /* PBXContainerItemProxy */; 194 | sourceTree = BUILT_PRODUCTS_DIR; 195 | }; 196 | AF345C5DC9246E4A5A4A7254 /* libQTree.a */ = { 197 | isa = PBXReferenceProxy; 198 | fileType = archive.ar; 199 | path = libQTree.a; 200 | remoteRef = AF3455FC66930D5A5DECAE54 /* PBXContainerItemProxy */; 201 | sourceTree = BUILT_PRODUCTS_DIR; 202 | }; 203 | /* End PBXReferenceProxy section */ 204 | 205 | /* Begin PBXResourcesBuildPhase section */ 206 | AF345C046F891A3FD550504A /* Resources */ = { 207 | isa = PBXResourcesBuildPhase; 208 | buildActionMask = 2147483647; 209 | files = ( 210 | AF3459B9DEF58121C181846B /* InfoPlist.strings in Resources */, 211 | AF3455DEC4AEADB5E72207C7 /* Images.xcassets in Resources */, 212 | AF34506EDB65C48F8DC31E92 /* Main.storyboard in Resources */, 213 | ); 214 | runOnlyForDeploymentPostprocessing = 0; 215 | }; 216 | /* End PBXResourcesBuildPhase section */ 217 | 218 | /* Begin PBXSourcesBuildPhase section */ 219 | AF3456849B3BE2AEA655BEF9 /* Sources */ = { 220 | isa = PBXSourcesBuildPhase; 221 | buildActionMask = 2147483647; 222 | files = ( 223 | 53FCAD45182917EC0041EE12 /* QCluster+Annotation.m in Sources */, 224 | AF34572F1730F2DA2D0D594C /* main.m in Sources */, 225 | AF345178CE544FA9731BC757 /* AppDelegate.m in Sources */, 226 | AF3451EA3CF1A4370B32AF7C /* ViewController.m in Sources */, 227 | AF3457D2B236A778E88A1413 /* DummyAnnotation.m in Sources */, 228 | AF345494258EAC0139FF940C /* ClusterAnnotationView.m in Sources */, 229 | ); 230 | runOnlyForDeploymentPostprocessing = 0; 231 | }; 232 | /* End PBXSourcesBuildPhase section */ 233 | 234 | /* Begin PBXTargetDependency section */ 235 | 539362701826EED100A0DFEE /* PBXTargetDependency */ = { 236 | isa = PBXTargetDependency; 237 | name = QTree; 238 | targetProxy = 5393626F1826EED100A0DFEE /* PBXContainerItemProxy */; 239 | }; 240 | /* End PBXTargetDependency section */ 241 | 242 | /* Begin PBXVariantGroup section */ 243 | AF345518D6ED1CE1E957F1D0 /* Main.storyboard */ = { 244 | isa = PBXVariantGroup; 245 | children = ( 246 | AF34538D6831A79CDBAD3E85 /* Base */, 247 | ); 248 | name = Main.storyboard; 249 | sourceTree = ""; 250 | }; 251 | AF345F3CE9066F90D749F2D6 /* InfoPlist.strings */ = { 252 | isa = PBXVariantGroup; 253 | children = ( 254 | AF34502F3947E327AD5F3E66 /* en */, 255 | ); 256 | name = InfoPlist.strings; 257 | sourceTree = ""; 258 | }; 259 | /* End PBXVariantGroup section */ 260 | 261 | /* Begin XCBuildConfiguration section */ 262 | AF3451E55A31F16EA791FBB9 /* Release */ = { 263 | isa = XCBuildConfiguration; 264 | buildSettings = { 265 | ALWAYS_SEARCH_USER_PATHS = NO; 266 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 267 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 268 | CLANG_CXX_LIBRARY = "libc++"; 269 | CLANG_ENABLE_MODULES = YES; 270 | CLANG_ENABLE_OBJC_ARC = YES; 271 | CLANG_WARN_BOOL_CONVERSION = YES; 272 | CLANG_WARN_CONSTANT_CONVERSION = YES; 273 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 274 | CLANG_WARN_EMPTY_BODY = YES; 275 | CLANG_WARN_ENUM_CONVERSION = YES; 276 | CLANG_WARN_INT_CONVERSION = YES; 277 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 278 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 279 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 280 | COPY_PHASE_STRIP = YES; 281 | ENABLE_NS_ASSERTIONS = NO; 282 | GCC_C_LANGUAGE_STANDARD = gnu99; 283 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 284 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 285 | GCC_WARN_UNDECLARED_SELECTOR = YES; 286 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 287 | GCC_WARN_UNUSED_FUNCTION = YES; 288 | GCC_WARN_UNUSED_VARIABLE = YES; 289 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 290 | SDKROOT = iphoneos; 291 | VALIDATE_PRODUCT = YES; 292 | }; 293 | name = Release; 294 | }; 295 | AF34557AA3BE3B042B89890F /* Release */ = { 296 | isa = XCBuildConfiguration; 297 | buildSettings = { 298 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 299 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 300 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 301 | GCC_PREFIX_HEADER = "QTreeSample/QTreeSample-Prefix.pch"; 302 | INFOPLIST_FILE = "QTreeSample/QTreeSample-Info.plist"; 303 | OTHER_LDFLAGS = ""; 304 | PRODUCT_NAME = "$(TARGET_NAME)"; 305 | USER_HEADER_SEARCH_PATHS = "\"${PROJECT_DIR}/../QTree\"/**"; 306 | WRAPPER_EXTENSION = app; 307 | }; 308 | name = Release; 309 | }; 310 | AF345BF8B6E5177838A6C70F /* Debug */ = { 311 | isa = XCBuildConfiguration; 312 | buildSettings = { 313 | ALWAYS_SEARCH_USER_PATHS = NO; 314 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 315 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 316 | CLANG_CXX_LIBRARY = "libc++"; 317 | CLANG_ENABLE_MODULES = YES; 318 | CLANG_ENABLE_OBJC_ARC = YES; 319 | CLANG_WARN_BOOL_CONVERSION = YES; 320 | CLANG_WARN_CONSTANT_CONVERSION = YES; 321 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 322 | CLANG_WARN_EMPTY_BODY = YES; 323 | CLANG_WARN_ENUM_CONVERSION = YES; 324 | CLANG_WARN_INT_CONVERSION = YES; 325 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 326 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 327 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 328 | COPY_PHASE_STRIP = NO; 329 | GCC_C_LANGUAGE_STANDARD = gnu99; 330 | GCC_DYNAMIC_NO_PIC = NO; 331 | GCC_OPTIMIZATION_LEVEL = 0; 332 | GCC_PREPROCESSOR_DEFINITIONS = ( 333 | "DEBUG=1", 334 | "$(inherited)", 335 | ); 336 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 337 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 338 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 339 | GCC_WARN_UNDECLARED_SELECTOR = YES; 340 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 341 | GCC_WARN_UNUSED_FUNCTION = YES; 342 | GCC_WARN_UNUSED_VARIABLE = YES; 343 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 344 | ONLY_ACTIVE_ARCH = YES; 345 | SDKROOT = iphoneos; 346 | }; 347 | name = Debug; 348 | }; 349 | AF345D25C2640AF7926FD4C5 /* Debug */ = { 350 | isa = XCBuildConfiguration; 351 | buildSettings = { 352 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 353 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 354 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 355 | GCC_PREFIX_HEADER = "QTreeSample/QTreeSample-Prefix.pch"; 356 | INFOPLIST_FILE = "QTreeSample/QTreeSample-Info.plist"; 357 | OTHER_LDFLAGS = ""; 358 | PRODUCT_NAME = "$(TARGET_NAME)"; 359 | USER_HEADER_SEARCH_PATHS = "\"${PROJECT_DIR}/../QTree\"/**"; 360 | WRAPPER_EXTENSION = app; 361 | }; 362 | name = Debug; 363 | }; 364 | /* End XCBuildConfiguration section */ 365 | 366 | /* Begin XCConfigurationList section */ 367 | AF3452C89C892FA0A378198C /* Build configuration list for PBXProject "QTreeSample" */ = { 368 | isa = XCConfigurationList; 369 | buildConfigurations = ( 370 | AF3451E55A31F16EA791FBB9 /* Release */, 371 | AF345BF8B6E5177838A6C70F /* Debug */, 372 | ); 373 | defaultConfigurationIsVisible = 0; 374 | defaultConfigurationName = Release; 375 | }; 376 | AF345F48D525EE19BF12A9AD /* Build configuration list for PBXNativeTarget "QTreeSample" */ = { 377 | isa = XCConfigurationList; 378 | buildConfigurations = ( 379 | AF34557AA3BE3B042B89890F /* Release */, 380 | AF345D25C2640AF7926FD4C5 /* Debug */, 381 | ); 382 | defaultConfigurationIsVisible = 0; 383 | defaultConfigurationName = Release; 384 | }; 385 | /* End XCConfigurationList section */ 386 | }; 387 | rootObject = AF345F654AEB2E5778B84AFB /* Project object */; 388 | } 389 | -------------------------------------------------------------------------------- /QTree/QTree.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 5393624018258B2F00A0DFEE /* libQTree.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5393622818258B2F00A0DFEE /* libQTree.a */; }; 11 | 5393624618258B3000A0DFEE /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 5393624418258B3000A0DFEE /* InfoPlist.strings */; }; 12 | 5393624818258B3000A0DFEE /* QTreeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5393624718258B3000A0DFEE /* QTreeTests.m */; }; 13 | 5393625A18258B7600A0DFEE /* QCluster.m in Sources */ = {isa = PBXBuildFile; fileRef = 5393625218258B7600A0DFEE /* QCluster.m */; }; 14 | 5393625B18258B7600A0DFEE /* QNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 5393625418258B7600A0DFEE /* QNode.m */; }; 15 | 5393625C18258B7600A0DFEE /* QTree.m in Sources */ = {isa = PBXBuildFile; fileRef = 5393625618258B7600A0DFEE /* QTree.m */; }; 16 | 5393625D18258B7600A0DFEE /* QTreeGeometryUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 5393625818258B7600A0DFEE /* QTreeGeometryUtils.m */; }; 17 | AF345F496EF1617D16B090D8 /* LocationBasedMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = AF345E9ED68DE04E7AAE0D32 /* LocationBasedMessage.m */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXContainerItemProxy section */ 21 | 5393623E18258B2F00A0DFEE /* PBXContainerItemProxy */ = { 22 | isa = PBXContainerItemProxy; 23 | containerPortal = 5393622018258B2F00A0DFEE /* Project object */; 24 | proxyType = 1; 25 | remoteGlobalIDString = 5393622718258B2F00A0DFEE; 26 | remoteInfo = QTree; 27 | }; 28 | /* End PBXContainerItemProxy section */ 29 | 30 | /* Begin PBXCopyFilesBuildPhase section */ 31 | 5393622618258B2F00A0DFEE /* CopyFiles */ = { 32 | isa = PBXCopyFilesBuildPhase; 33 | buildActionMask = 2147483647; 34 | dstPath = "include/$(PRODUCT_NAME)"; 35 | dstSubfolderSpec = 16; 36 | files = ( 37 | ); 38 | runOnlyForDeploymentPostprocessing = 0; 39 | }; 40 | /* End PBXCopyFilesBuildPhase section */ 41 | 42 | /* Begin PBXFileReference section */ 43 | 5393622818258B2F00A0DFEE /* libQTree.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libQTree.a; sourceTree = BUILT_PRODUCTS_DIR; }; 44 | 5393622F18258B2F00A0DFEE /* QTree-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "QTree-Prefix.pch"; sourceTree = ""; }; 45 | 5393623818258B2F00A0DFEE /* QTreeTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = QTreeTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 46 | 5393624318258B3000A0DFEE /* QTreeTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "QTreeTests-Info.plist"; sourceTree = ""; }; 47 | 5393624518258B3000A0DFEE /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 48 | 5393624718258B3000A0DFEE /* QTreeTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = QTreeTests.m; sourceTree = ""; }; 49 | 5393625118258B7600A0DFEE /* QCluster.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QCluster.h; sourceTree = ""; }; 50 | 5393625218258B7600A0DFEE /* QCluster.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QCluster.m; sourceTree = ""; }; 51 | 5393625318258B7600A0DFEE /* QNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QNode.h; sourceTree = ""; }; 52 | 5393625418258B7600A0DFEE /* QNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QNode.m; sourceTree = ""; }; 53 | 5393625518258B7600A0DFEE /* QTree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QTree.h; sourceTree = ""; }; 54 | 5393625618258B7600A0DFEE /* QTree.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QTree.m; sourceTree = ""; }; 55 | 5393625718258B7600A0DFEE /* QTreeGeometryUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QTreeGeometryUtils.h; sourceTree = ""; }; 56 | 5393625818258B7600A0DFEE /* QTreeGeometryUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QTreeGeometryUtils.m; sourceTree = ""; }; 57 | 5393625918258B7600A0DFEE /* QTreeInsertable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QTreeInsertable.h; sourceTree = ""; }; 58 | AF3456A3F3419A54CAE5612D /* LocationBasedMessage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocationBasedMessage.h; sourceTree = ""; }; 59 | AF345E9ED68DE04E7AAE0D32 /* LocationBasedMessage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LocationBasedMessage.m; sourceTree = ""; }; 60 | /* End PBXFileReference section */ 61 | 62 | /* Begin PBXFrameworksBuildPhase section */ 63 | 5393622518258B2F00A0DFEE /* Frameworks */ = { 64 | isa = PBXFrameworksBuildPhase; 65 | buildActionMask = 2147483647; 66 | files = ( 67 | ); 68 | runOnlyForDeploymentPostprocessing = 0; 69 | }; 70 | 5393623518258B2F00A0DFEE /* Frameworks */ = { 71 | isa = PBXFrameworksBuildPhase; 72 | buildActionMask = 2147483647; 73 | files = ( 74 | 5393624018258B2F00A0DFEE /* libQTree.a in Frameworks */, 75 | ); 76 | runOnlyForDeploymentPostprocessing = 0; 77 | }; 78 | /* End PBXFrameworksBuildPhase section */ 79 | 80 | /* Begin PBXGroup section */ 81 | 5393621F18258B2F00A0DFEE = { 82 | isa = PBXGroup; 83 | children = ( 84 | 5393622D18258B2F00A0DFEE /* QTree */, 85 | 5393624118258B2F00A0DFEE /* QTreeTests */, 86 | 5393622918258B2F00A0DFEE /* Products */, 87 | ); 88 | sourceTree = ""; 89 | }; 90 | 5393622918258B2F00A0DFEE /* Products */ = { 91 | isa = PBXGroup; 92 | children = ( 93 | 5393622818258B2F00A0DFEE /* libQTree.a */, 94 | 5393623818258B2F00A0DFEE /* QTreeTests.xctest */, 95 | ); 96 | name = Products; 97 | sourceTree = ""; 98 | }; 99 | 5393622D18258B2F00A0DFEE /* QTree */ = { 100 | isa = PBXGroup; 101 | children = ( 102 | 5393625118258B7600A0DFEE /* QCluster.h */, 103 | 5393625218258B7600A0DFEE /* QCluster.m */, 104 | 5393625318258B7600A0DFEE /* QNode.h */, 105 | 5393625418258B7600A0DFEE /* QNode.m */, 106 | 5393625518258B7600A0DFEE /* QTree.h */, 107 | 5393625618258B7600A0DFEE /* QTree.m */, 108 | 5393625718258B7600A0DFEE /* QTreeGeometryUtils.h */, 109 | 5393625818258B7600A0DFEE /* QTreeGeometryUtils.m */, 110 | 5393625918258B7600A0DFEE /* QTreeInsertable.h */, 111 | 5393622E18258B2F00A0DFEE /* Supporting Files */, 112 | ); 113 | path = QTree; 114 | sourceTree = ""; 115 | }; 116 | 5393622E18258B2F00A0DFEE /* Supporting Files */ = { 117 | isa = PBXGroup; 118 | children = ( 119 | 5393622F18258B2F00A0DFEE /* QTree-Prefix.pch */, 120 | ); 121 | name = "Supporting Files"; 122 | sourceTree = ""; 123 | }; 124 | 5393624118258B2F00A0DFEE /* QTreeTests */ = { 125 | isa = PBXGroup; 126 | children = ( 127 | AF3456A3F3419A54CAE5612D /* LocationBasedMessage.h */, 128 | AF345E9ED68DE04E7AAE0D32 /* LocationBasedMessage.m */, 129 | 5393624718258B3000A0DFEE /* QTreeTests.m */, 130 | 5393624218258B3000A0DFEE /* Supporting Files */, 131 | ); 132 | path = QTreeTests; 133 | sourceTree = ""; 134 | }; 135 | 5393624218258B3000A0DFEE /* Supporting Files */ = { 136 | isa = PBXGroup; 137 | children = ( 138 | 5393624318258B3000A0DFEE /* QTreeTests-Info.plist */, 139 | 5393624418258B3000A0DFEE /* InfoPlist.strings */, 140 | ); 141 | name = "Supporting Files"; 142 | sourceTree = ""; 143 | }; 144 | /* End PBXGroup section */ 145 | 146 | /* Begin PBXNativeTarget section */ 147 | 5393622718258B2F00A0DFEE /* QTree */ = { 148 | isa = PBXNativeTarget; 149 | buildConfigurationList = 5393624B18258B3000A0DFEE /* Build configuration list for PBXNativeTarget "QTree" */; 150 | buildPhases = ( 151 | 5393622418258B2F00A0DFEE /* Sources */, 152 | 5393622518258B2F00A0DFEE /* Frameworks */, 153 | 5393622618258B2F00A0DFEE /* CopyFiles */, 154 | ); 155 | buildRules = ( 156 | ); 157 | dependencies = ( 158 | ); 159 | name = QTree; 160 | productName = QTree; 161 | productReference = 5393622818258B2F00A0DFEE /* libQTree.a */; 162 | productType = "com.apple.product-type.library.static"; 163 | }; 164 | 5393623718258B2F00A0DFEE /* QTreeTests */ = { 165 | isa = PBXNativeTarget; 166 | buildConfigurationList = 5393624E18258B3000A0DFEE /* Build configuration list for PBXNativeTarget "QTreeTests" */; 167 | buildPhases = ( 168 | 5393623418258B2F00A0DFEE /* Sources */, 169 | 5393623518258B2F00A0DFEE /* Frameworks */, 170 | 5393623618258B2F00A0DFEE /* Resources */, 171 | ); 172 | buildRules = ( 173 | ); 174 | dependencies = ( 175 | 5393623F18258B2F00A0DFEE /* PBXTargetDependency */, 176 | ); 177 | name = QTreeTests; 178 | productName = QTreeTests; 179 | productReference = 5393623818258B2F00A0DFEE /* QTreeTests.xctest */; 180 | productType = "com.apple.product-type.bundle.unit-test"; 181 | }; 182 | /* End PBXNativeTarget section */ 183 | 184 | /* Begin PBXProject section */ 185 | 5393622018258B2F00A0DFEE /* Project object */ = { 186 | isa = PBXProject; 187 | attributes = { 188 | LastUpgradeCheck = 0730; 189 | ORGANIZATIONNAME = "Aleksey Kozhevnikov"; 190 | }; 191 | buildConfigurationList = 5393622318258B2F00A0DFEE /* Build configuration list for PBXProject "QTree" */; 192 | compatibilityVersion = "Xcode 3.2"; 193 | developmentRegion = English; 194 | hasScannedForEncodings = 0; 195 | knownRegions = ( 196 | en, 197 | ); 198 | mainGroup = 5393621F18258B2F00A0DFEE; 199 | productRefGroup = 5393622918258B2F00A0DFEE /* Products */; 200 | projectDirPath = ""; 201 | projectRoot = ""; 202 | targets = ( 203 | 5393622718258B2F00A0DFEE /* QTree */, 204 | 5393623718258B2F00A0DFEE /* QTreeTests */, 205 | ); 206 | }; 207 | /* End PBXProject section */ 208 | 209 | /* Begin PBXResourcesBuildPhase section */ 210 | 5393623618258B2F00A0DFEE /* Resources */ = { 211 | isa = PBXResourcesBuildPhase; 212 | buildActionMask = 2147483647; 213 | files = ( 214 | 5393624618258B3000A0DFEE /* InfoPlist.strings in Resources */, 215 | ); 216 | runOnlyForDeploymentPostprocessing = 0; 217 | }; 218 | /* End PBXResourcesBuildPhase section */ 219 | 220 | /* Begin PBXSourcesBuildPhase section */ 221 | 5393622418258B2F00A0DFEE /* Sources */ = { 222 | isa = PBXSourcesBuildPhase; 223 | buildActionMask = 2147483647; 224 | files = ( 225 | 5393625C18258B7600A0DFEE /* QTree.m in Sources */, 226 | 5393625D18258B7600A0DFEE /* QTreeGeometryUtils.m in Sources */, 227 | 5393625A18258B7600A0DFEE /* QCluster.m in Sources */, 228 | 5393625B18258B7600A0DFEE /* QNode.m in Sources */, 229 | AF345F496EF1617D16B090D8 /* LocationBasedMessage.m in Sources */, 230 | ); 231 | runOnlyForDeploymentPostprocessing = 0; 232 | }; 233 | 5393623418258B2F00A0DFEE /* Sources */ = { 234 | isa = PBXSourcesBuildPhase; 235 | buildActionMask = 2147483647; 236 | files = ( 237 | 5393624818258B3000A0DFEE /* QTreeTests.m in Sources */, 238 | ); 239 | runOnlyForDeploymentPostprocessing = 0; 240 | }; 241 | /* End PBXSourcesBuildPhase section */ 242 | 243 | /* Begin PBXTargetDependency section */ 244 | 5393623F18258B2F00A0DFEE /* PBXTargetDependency */ = { 245 | isa = PBXTargetDependency; 246 | target = 5393622718258B2F00A0DFEE /* QTree */; 247 | targetProxy = 5393623E18258B2F00A0DFEE /* PBXContainerItemProxy */; 248 | }; 249 | /* End PBXTargetDependency section */ 250 | 251 | /* Begin PBXVariantGroup section */ 252 | 5393624418258B3000A0DFEE /* InfoPlist.strings */ = { 253 | isa = PBXVariantGroup; 254 | children = ( 255 | 5393624518258B3000A0DFEE /* en */, 256 | ); 257 | name = InfoPlist.strings; 258 | sourceTree = ""; 259 | }; 260 | /* End PBXVariantGroup section */ 261 | 262 | /* Begin XCBuildConfiguration section */ 263 | 5393624918258B3000A0DFEE /* Debug */ = { 264 | isa = XCBuildConfiguration; 265 | buildSettings = { 266 | ALWAYS_SEARCH_USER_PATHS = NO; 267 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 268 | CLANG_CXX_LIBRARY = "libc++"; 269 | CLANG_ENABLE_MODULES = YES; 270 | CLANG_ENABLE_OBJC_ARC = YES; 271 | CLANG_WARN_BOOL_CONVERSION = YES; 272 | CLANG_WARN_CONSTANT_CONVERSION = YES; 273 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 274 | CLANG_WARN_EMPTY_BODY = YES; 275 | CLANG_WARN_ENUM_CONVERSION = YES; 276 | CLANG_WARN_INT_CONVERSION = YES; 277 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 278 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 279 | COPY_PHASE_STRIP = NO; 280 | ENABLE_TESTABILITY = YES; 281 | GCC_C_LANGUAGE_STANDARD = gnu99; 282 | GCC_DYNAMIC_NO_PIC = NO; 283 | GCC_OPTIMIZATION_LEVEL = 0; 284 | GCC_PREPROCESSOR_DEFINITIONS = ( 285 | "DEBUG=1", 286 | "$(inherited)", 287 | ); 288 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 289 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 290 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 291 | GCC_WARN_UNDECLARED_SELECTOR = YES; 292 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 293 | GCC_WARN_UNUSED_FUNCTION = YES; 294 | GCC_WARN_UNUSED_VARIABLE = YES; 295 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 296 | ONLY_ACTIVE_ARCH = YES; 297 | SDKROOT = iphoneos; 298 | }; 299 | name = Debug; 300 | }; 301 | 5393624A18258B3000A0DFEE /* Release */ = { 302 | isa = XCBuildConfiguration; 303 | buildSettings = { 304 | ALWAYS_SEARCH_USER_PATHS = NO; 305 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 306 | CLANG_CXX_LIBRARY = "libc++"; 307 | CLANG_ENABLE_MODULES = YES; 308 | CLANG_ENABLE_OBJC_ARC = YES; 309 | CLANG_WARN_BOOL_CONVERSION = YES; 310 | CLANG_WARN_CONSTANT_CONVERSION = YES; 311 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 312 | CLANG_WARN_EMPTY_BODY = YES; 313 | CLANG_WARN_ENUM_CONVERSION = YES; 314 | CLANG_WARN_INT_CONVERSION = YES; 315 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 316 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 317 | COPY_PHASE_STRIP = YES; 318 | ENABLE_NS_ASSERTIONS = NO; 319 | GCC_C_LANGUAGE_STANDARD = gnu99; 320 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 321 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 322 | GCC_WARN_UNDECLARED_SELECTOR = YES; 323 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 324 | GCC_WARN_UNUSED_FUNCTION = YES; 325 | GCC_WARN_UNUSED_VARIABLE = YES; 326 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 327 | SDKROOT = iphoneos; 328 | VALIDATE_PRODUCT = YES; 329 | }; 330 | name = Release; 331 | }; 332 | 5393624C18258B3000A0DFEE /* Debug */ = { 333 | isa = XCBuildConfiguration; 334 | buildSettings = { 335 | DSTROOT = /tmp/QTree.dst; 336 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 337 | GCC_PREFIX_HEADER = "QTree/QTree-Prefix.pch"; 338 | OTHER_LDFLAGS = "-ObjC"; 339 | PRODUCT_NAME = "$(TARGET_NAME)"; 340 | SKIP_INSTALL = YES; 341 | }; 342 | name = Debug; 343 | }; 344 | 5393624D18258B3000A0DFEE /* Release */ = { 345 | isa = XCBuildConfiguration; 346 | buildSettings = { 347 | DSTROOT = /tmp/QTree.dst; 348 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 349 | GCC_PREFIX_HEADER = "QTree/QTree-Prefix.pch"; 350 | OTHER_LDFLAGS = "-ObjC"; 351 | PRODUCT_NAME = "$(TARGET_NAME)"; 352 | SKIP_INSTALL = YES; 353 | }; 354 | name = Release; 355 | }; 356 | 5393624F18258B3000A0DFEE /* Debug */ = { 357 | isa = XCBuildConfiguration; 358 | buildSettings = { 359 | FRAMEWORK_SEARCH_PATHS = ( 360 | "$(SDKROOT)/Developer/Library/Frameworks", 361 | "$(inherited)", 362 | "$(DEVELOPER_FRAMEWORKS_DIR)", 363 | ); 364 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 365 | GCC_PREFIX_HEADER = "QTree/QTree-Prefix.pch"; 366 | GCC_PREPROCESSOR_DEFINITIONS = ( 367 | "DEBUG=1", 368 | "$(inherited)", 369 | ); 370 | HEADER_SEARCH_PATHS = "$(inherited)"; 371 | INFOPLIST_FILE = "QTreeTests/QTreeTests-Info.plist"; 372 | LIBRARY_SEARCH_PATHS = ""; 373 | PRODUCT_BUNDLE_IDENTIFIER = "me.akozhevnikov.${PRODUCT_NAME:rfc1034identifier}"; 374 | PRODUCT_NAME = "$(TARGET_NAME)"; 375 | WRAPPER_EXTENSION = xctest; 376 | }; 377 | name = Debug; 378 | }; 379 | 5393625018258B3000A0DFEE /* Release */ = { 380 | isa = XCBuildConfiguration; 381 | buildSettings = { 382 | FRAMEWORK_SEARCH_PATHS = ( 383 | "$(SDKROOT)/Developer/Library/Frameworks", 384 | "$(inherited)", 385 | "$(DEVELOPER_FRAMEWORKS_DIR)", 386 | ); 387 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 388 | GCC_PREFIX_HEADER = "QTree/QTree-Prefix.pch"; 389 | HEADER_SEARCH_PATHS = "$(inherited)"; 390 | INFOPLIST_FILE = "QTreeTests/QTreeTests-Info.plist"; 391 | LIBRARY_SEARCH_PATHS = ""; 392 | PRODUCT_BUNDLE_IDENTIFIER = "me.akozhevnikov.${PRODUCT_NAME:rfc1034identifier}"; 393 | PRODUCT_NAME = "$(TARGET_NAME)"; 394 | WRAPPER_EXTENSION = xctest; 395 | }; 396 | name = Release; 397 | }; 398 | /* End XCBuildConfiguration section */ 399 | 400 | /* Begin XCConfigurationList section */ 401 | 5393622318258B2F00A0DFEE /* Build configuration list for PBXProject "QTree" */ = { 402 | isa = XCConfigurationList; 403 | buildConfigurations = ( 404 | 5393624918258B3000A0DFEE /* Debug */, 405 | 5393624A18258B3000A0DFEE /* Release */, 406 | ); 407 | defaultConfigurationIsVisible = 0; 408 | defaultConfigurationName = Release; 409 | }; 410 | 5393624B18258B3000A0DFEE /* Build configuration list for PBXNativeTarget "QTree" */ = { 411 | isa = XCConfigurationList; 412 | buildConfigurations = ( 413 | 5393624C18258B3000A0DFEE /* Debug */, 414 | 5393624D18258B3000A0DFEE /* Release */, 415 | ); 416 | defaultConfigurationIsVisible = 0; 417 | defaultConfigurationName = Release; 418 | }; 419 | 5393624E18258B3000A0DFEE /* Build configuration list for PBXNativeTarget "QTreeTests" */ = { 420 | isa = XCConfigurationList; 421 | buildConfigurations = ( 422 | 5393624F18258B3000A0DFEE /* Debug */, 423 | 5393625018258B3000A0DFEE /* Release */, 424 | ); 425 | defaultConfigurationIsVisible = 0; 426 | defaultConfigurationName = Release; 427 | }; 428 | /* End XCConfigurationList section */ 429 | }; 430 | rootObject = 5393622018258B2F00A0DFEE /* Project object */; 431 | } 432 | --------------------------------------------------------------------------------