在 Objective C 中,如何使用 CATileLayer 通过分页进行聚类

In Objective C, How to do Clustering with pagination using CATileLayer

我有一种情况是在 UIView 中为最近的 CGPoint 聚类。所以我有一组 CGPoint NSArray,我试图获得最接近的值并进行聚类,但我无法获得逻辑: // 我的代码

 //total CGpointArray ex: cgPointGroupArray, i try to get each obj closest obj

   for (CGPoint firstObjOfCGPoint in cgPointGroupArray) {

     for (CGPoint nextPoint in cgPointGroupArray) {
        //ex: 30 -distance b/w two point
       if (30>[self distanceBetween: firstObjOfCGPoint and:nextPoint]){                
            [shortestClusterArr addObject:nextPoint];
        }
        else{
            [longestClusterArr addObject:nextPoint];
        }
    }
  //if array hold more than 2 value it will cluster otherwise mark single obj  

       if(shortestClusterArr.count>2){
         //clustered marker obj
           [self addClusterMarker:shortestClusterArr];
       }
       else{
          //no cluster marker obj 
       }
}

Above code, looping time getting duplicate points as well override on the same object so if anyone knows the logic comment here,.. But I want such as clustering concepts like Geo-map clustering with pagination.

           xTotalCount=pow( 2, self.mapScrollView.zoomLevel );

            for ( int i = 0; i < xTotalCount ; i++) { 
 // ex : 0 < 2,   it will execute 2 times depends on zoom level(pow(2,0),pow(2,1),pow(2,2),.. )

                xISet = [[ NSMutableArray alloc ] init];

                //set the cordination value to the a and b according to the zoom level
                ax=( i*zoomLevelTicketSpacing ) / xTotalCount; // ex : a = 0
                bx=((i + 1) *zoomLevelTicketSpacing ) / xTotalCount; // b = 256

                for (EDCTicketMarker *ticketMarker in weakSelf.activeTicketMarkers) {
                    // group with zoom scale
                    nextPointX = ticketMarker.location.x;
                    if(nextPointX > ax && nextPointX < bx){
                        [xISet addObject:ticketMarker];

                    }
                }

                [xMatrixSet setValue:xISet forKey:[@(i)stringValue]];

                // Y cordination ( 00, 01, 10, 11 )
                yTotalCount=pow ( 2, self.mapScrollView.zoomLevel );
                for (int j=0; j< yTotalCount ; j++) {
                    yISet = [[ NSMutableArray alloc ] init];

                    ay=( j*zoomLevelTicketSpacing ) / yTotalCount; // ex : a = 0
                    by=(( j+1 ) *zoomLevelTicketSpacing) / yTotalCount; // b = 256

                    for (EDCTicketMarker *ticketMarker in weakSelf.activeTicketMarkers) {
                        // group with zoom scale
                        nextPointY = ticketMarker.location.y;

                        if( nextPointY > ay && nextPointY < by ){
                            [yISet addObject:ticketMarker];
                        }
                    }

                    [yMatrixSet setValue:yISet forKey:[@(i)stringValue]];

                    // Intersect the X and Y matrix array

                    NSMutableSet *matrixSetX = [ NSMutableSet setWithArray:xISet ];
                    NSMutableSet *matrixSetY = [ NSMutableSet setWithArray:yISet ];
                    [matrixSetX intersectSet:matrixSetY];

                    NSArray *resultMatrix = [matrixSetX allObjects];
                    NSLog(resultMatrix) // it will print according to the x and y position (00,01,10,11)