All Products
Search
Document Center

PolarDB:ST_ImportOSGB

Last Updated:Mar 28, 2026

Imports an oblique photography project in OSGB format from Object Storage Service (OSS) into a PolarDB database. Returns true on success.

Syntax

boolean ST_ImportOSGB(cstring table_name, cstring url, cstring options default '{}');

Parameters

ParameterTypeDescription
table_namecstringThe name of the primary OSG table and the prefix of its tile table.
urlcstringThe OSS path to the OSGB project directory. The cluster and OSS bucket must be in the same region. Use an internal endpoint for access. See Object storage service paths.
optionscstringA JSON object of import options. Default: '{}'. See Options below.

Options

FieldTypeDefaultRequiredDescription
schemaStringpublicNoThe schema of the destination table.
parallelInteger1NoThe degree of parallelism. Set to a value less than 16. Values less than 1 are ignored. Higher values speed up import but increase memory usage. When set to any value other than 1, you must create the tables manually before importing.
batch_sizeInteger10000NoThe number of SQL statements executed per batch. Valid values: 1–2,147,483,647.
projectStringNoThe project name. Passed to the project_name field of each record.
sridIntegerNoThe spatial reference identifier (SRID) of the data. Overrides the SRID read from metadata.xml.
gatewayBooleanfalseNoSpecifies whether to import data in gateway mode. When true, records are stored as references and fetched from OSS at query time, which reduces database storage usage but may slow queries. When false, tile data is stored directly in the database.
tileset_prefixStringNoThe prefix for generated 3D Tiles addresses. Use this to configure a custom reverse proxy.

Limitations

  • Only OSGB files are supported.

  • A metadata.xml file must exist in the specified directory. It can be in the root directory or a subdirectory.

  • Import the complete OSGB project. Partial imports cause data loss.

  • For large imports through a client connection, increase the client timeout to prevent import failure.

Output tables

A successful import creates two tables in the database.

Primary table — named [table_name]

Stores metadata for the oblique photography project.

FieldData typeDescription
project_iduuidThe project ID, automatically generated.
project_nametextThe project name. Set by the project option. Empty if not specified.
sridintegerThe SRID of the project. Read from ModelMetadata/SRS in metadata.xml. The srid option takes priority if specified.
ref_pointgeometryThe 3D anchor point of the project. Read from ModelMetadata/SSRSOrigin in metadata.xml. Type: Point3DZ.
extentgeometryThe approximate spatial extent of the project. Type: PolygonZ.
auxtextThe full content of metadata.xml.
tiletablevarchar(64)The name of the tile table.

Tile table — named [table_name]_tile

Stores all tile data for the project.

FieldData typeDescription
project_iduuidThe project ID. Same as in the primary table.
project_nametextThe project name. Same as in the primary table.
uiduuidThe tile ID, automatically generated.
lodintegerThe Level of Detail (LOD) of the tile. Derived from the file name (for example, Tile_L14_0.osgb). Defaults to 0 if the LOD cannot be determined.
precisionfloat8The estimated tile precision, used when exporting to 3D Tiles.
parentuuidThe ID of the parent tile. Empty for root tiles.
childrenuuid[]The IDs of all child tiles. Empty if none exist.
auxjsonbTile metadata. Contains the file name relative to the project root directory, accessible from the file_name node.
tilesceneThe tile entity.

Usage notes

Parallel import requires manual table creation. When parallel is set to any value other than 1, automatic table creation is disabled. Create the primary table and tile table before running the import:

-- Create the primary table
CREATE TABLE IF NOT EXISTS test_osgb (
    project_id   uuid         PRIMARY KEY,
    project_name text,
    srid         integer,
    ref_point    geometry,
    extent       geometry,
    aux          text,
    tiletable    varchar(64)  NOT NULL
);

-- Create the tile table
CREATE TABLE IF NOT EXISTS test_osgb_tile (
    project_id   uuid    NOT NULL,
    project_name text,
    uid          uuid    NOT NULL,
    lod          integer,
    precision    float8,
    parent       uuid,
    children     uuid[],
    aux          jsonb,
    tile         scene   NOT NULL,
    PRIMARY KEY (project_id, uid)
);

Examples

Standard import

SELECT ST_ImportOSGB(
    'test_osgb',
    'OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/path_to_oblique_project/'
);

Returns: t

Parallel import

-- parallel: 4 enables concurrent processing.
-- Keep this value below 16 to avoid excessive memory usage.
-- When parallel != 1, create the tables manually before running this statement.
SELECT ST_ImportOSGB(
    'test_osgb',
    'OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/path_to_oblique_project/',
    '{"parallel": 4}'
);

Returns: t