database.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:lopocs 作者: Oslandia 项目源码 文件源码
def update_metadata(cls, table, column, srid, scale_x, scale_y, scale_z,
                        offset_x, offset_y, offset_z):
        '''
        Add an entry to the lopocs metadata tables to use.
        To be used after a fresh pc table creation.
        '''
        pcid = cls.query("""
            select pcid from pointcloud_columns
            where "schema" = %s and "table" = %s and "column" = %s
            """, (table.split('.')[0], table.split('.')[1], column)
        )[0][0]

        bbox = cls.compute_boundingbox(table, column)
        # compute bbox with offset and scale applied
        bbox_scaled = [0] * 6
        bbox_scaled[0] = (bbox['xmin'] - offset_x) / scale_x
        bbox_scaled[1] = (bbox['ymin'] - offset_y) / scale_y
        bbox_scaled[2] = (bbox['zmin'] - offset_z) / scale_z
        bbox_scaled[3] = (bbox['xmax'] - offset_x) / scale_x
        bbox_scaled[4] = (bbox['ymax'] - offset_y) / scale_y
        bbox_scaled[5] = (bbox['zmax'] - offset_z) / scale_z

        res = cls.query("""
            delete from pointcloud_lopocs where schematable = %s and "column" = %s;
            insert into pointcloud_lopocs (schematable, "column", srid, bbox)
            values (%s, %s, %s, %s) returning id
            """, (table, column, table, column, srid, bbox))
        plid = res[0][0]

        scales = scale_x, scale_y, scale_z
        offsets = offset_x, offset_y, offset_z

        json_schema = cls.patch2greyhoundschema(table, column)

        cls.execute("""
            insert into pointcloud_lopocs_outputs
            (id, pcid, scales, offsets, stored, bbox, point_schema)
            values (%s, %s, %s, %s, True, %s, %s)
        """, (
            plid, pcid, iterable2pgarray(scales), iterable2pgarray(offsets),
            iterable2pgarray(bbox_scaled), Json(json_schema)))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号