Beispiel #1
0
    def step_07_fourth_clustering_by_geography_distance(self):
        for threshold in xrange(1, CLUSTERING_MIN_DISTANCE_THRESHOLD + 1):
            #print('threshold = %d' % threshold)
            prev_group_cnt = 0
            for iteration in xrange(10):
                group_cnt = 0

                for group1 in self.result:
                    img = Image()
                    img.lonLat = group1.lonLat
                    m_value = Group()
                    m_value.members = [Group()]
                    m_value.members[0].members = [img]
                    cluster = Clustering(group1, threshold,
                                         distance_geography_group, m_value,
                                         False)
                    cluster.run()
                    group1.members = [
                        Group(
                            sum([group3.members
                                 for group3 in group2.members], []))
                        for group2 in cluster.result
                    ]
                    group_cnt += len(group1.members)

                #print('step_07:group_cnt == %d' % group_cnt)
                if prev_group_cnt == group_cnt:
                    break
                else:
                    prev_group_cnt = group_cnt
        return True