Exemplo n.º 1
0
    def test_tile_parent(self):
        x,y,z = (619,355,10)

        parent_calculated = geomath.tile_parent(x,y,z)
        parent_known = (309,177,9)

        self.assertEqual(parent_known,parent_calculated)
Exemplo n.º 2
0
    def test_tile_parent(self):
        x, y, z = (619, 355, 10)

        parent_calculated = geomath.tile_parent(x, y, z)
        parent_known = (309, 177, 9)

        self.assertEqual(parent_known, parent_calculated)
Exemplo n.º 3
0
    def test_tile_parent_str(self):
        tile = '619,355,10,a'

        parent_calculated = geomath.tile_parent(tile)
        parent_known = (309,177,9)

        self.assertEqual(parent_known,parent_calculated)
       
        # same with unicode
        tile = u'619,355,10,a'
        parent_calculated = geomath.tile_parent(tile)
        self.assertEqual(parent_known,parent_calculated)

        # test that returns string
        parent_known_str = '309,177,9,a'
        parent_calculated_str = geomath.tile_parent(tile,return_str=True)
        self.assertEqual(parent_known_str,parent_calculated_str)
Exemplo n.º 4
0
    def test_tile_parent_str_with_no_extra(self):
        tile = '619,355,10'

        parent_calculated = geomath.tile_parent(tile)
        parent_known = (309, 177, 9)

        self.assertEqual(parent_known, parent_calculated)

        # same with unicode
        tile = u'619,355,10'
        parent_calculated = geomath.tile_parent(tile)
        self.assertEqual(parent_known, parent_calculated)

        # test that returns string
        parent_known_str = '309,177,9'
        parent_calculated_str = geomath.tile_parent(tile, return_str=True)
        self.assertEqual(parent_known_str, parent_calculated_str)
Exemplo n.º 5
0
    def update_tiles(cls, count=config.COUNT_UPDATE, gt_key_name=None):
        """Update several tiles and puts them into datastore."""
        if not gt_key_name:
            gt_key_name = cls._GEO_TREE_KEY
        gt = cls.get_by_key_name(gt_key_name)
        if gt:

            # check if the first tile has larger z than min_z, if not - nothing to update
            logging.debug(gt_key_name)
            logging.debug(gt.tiles_updated)
            x,y,z = tile_str_to_tuple(gt.tiles_updated[0])
            min_z = get_min_z(gt_key_name)
            if not (z > min_z):
                r = '\n\nInfo: updated 0 tiles, nothing to update'
                return r

            needs_update = True
            count_updated = 0

            while count_updated < count and needs_update:
                # get a group of tiles with a common parent (starting with the first)
                first_tile = gt.tiles_updated[0]
                p = tile_parent(first_tile,return_str=True)
                c = tile_children(p,return_str=True)
                c_in_updated = [first_tile]
                for t in gt.tiles_updated[1:]:
                    if t in c:
                        c_in_updated.append(t)
                # update parent, use all children for update
                t = cls.update_tile(p, c, gt_key_name=gt_key_name)
                t.put()
                # remove the group of updated children tiles from tiles_updated
                tiles_updated = sorted_tiles_set(gt.tiles_updated)
                tiles_updated.remove(c_in_updated)
                # insert updated tile
                tiles_updated.insert(p)
                gt.tiles_updated = list(tiles_updated)
                gt.put()
                # check if the first tile has smaller z than min_z, if not needs_update = False
                x,y,z = tile_str_to_tuple(tiles_updated[0])
                min_z = get_min_z(gt_key_name)
                if z == min_z:
                    needs_update = False 
                # increase count_updated
                count_updated += 1
        else:
            return '\n\nError: no GeoTree exists'