Ejemplo n.º 1
0
 def remove_from_geotree_by_key_name(cls, key_name, coord, gt_key_name=None, max_z=None):
     """this method removes mentionings of a point from geotree
     coord is GeoPtProperty
     the points itself is not changed (it may not even exist in datastore)
     """
     #delete from native tile
     if not gt_key_name:
         gt_key_name = cls._GEO_TREE_KEY
     if not max_z:
         max_z = get_max_z(gt_key_name)
     tile_str = tile_tuple_to_str(lat_lon_to_tile(coord.lat, coord.lon, max_z))
     tile_key_name = '%s,%s' % (tile_str,gt_key_name)
     logging.debug(tile_key_name)
     t = Tile.get_by_key_name(tile_key_name)
     points = json.loads(t.points_native)
     for i in range(len(points)):
         if points[i]['key_name'] == key_name:
             del(points[i])
             break
     t.points_native = json.dumps(points)
     t.put()
     #mark this tile updated and update all tiles
     gt = cls.get_by_key_name(gt_key_name)
     tiles_updated = sorted_tiles_set(gt.tiles_updated)
     tiles_updated.insert(tile_key_name)
     gt.tiles_updated = list(tiles_updated)
     #decrease points count
     gt.number_points -= 1
     gt.put()
     gt.update_tiles()
Ejemplo n.º 2
0
 def remove_point_by_key_name(cls, key_name, gt_key_name=None, max_z=None):
     #delete from native tile
     if not gt_key_name:
         gt_key_name = cls._GEO_TREE_KEY
     if not max_z:
         max_z = get_max_z(gt_key_name)
     p = Point.get_by_key_name(key_name)
     tile_str = tile_tuple_to_str(lat_lon_to_tile(p.coord.lat, p.coord.lon, max_z))
     tile_key_name = '%s,%s' % (tile_str,gt_key_name)
     t = Tile.get_by_key_name(tile_key_name)
     points = json.loads(t.points_native)
     for i in range(len(points)):
         if points[i]['key_name'] == key_name:
             del(points[i])
             break
     t.points_native = json.dumps(points)
     t.put()
     #mark this tile updated and update all tiles
     gt = cls.get_by_key_name(gt_key_name)
     tiles_updated = sorted_tiles_set(gt.tiles_updated)
     tiles_updated.insert(tile_key_name)
     gt.tiles_updated = list(tiles_updated)
     #decrease points count
     gt.number_points -= 1
     gt.put()
     gt.update_tiles()
     #delete point
     p.delete()
Ejemplo n.º 3
0
 def test_tile_tuple_to_str(self):
     s = '2,3,4'
     t = (2,3,4)
     self.assertEqual(s,geomath.tile_tuple_to_str(t))
Ejemplo n.º 4
0
 def test_tile_tuple_to_str(self):
     s = '2,3,4'
     t = (2, 3, 4)
     self.assertEqual(s, geomath.tile_tuple_to_str(t))