Table of Contents

Method CreateSpatialIndex

Namespace
YndigoBlue.Velocity.Engine
Assembly
YndigoBlue.Velocity.dll

CreateSpatialIndex(SpatialIndex, bool)

Creates a spatial index for geospatial queries on geometry or geography columns.

public void CreateSpatialIndex(SpatialIndex spatialIndex, bool overwrite = false)

Parameters

spatialIndex SpatialIndex

The SpatialIndex object defining the spatial index to create.

overwrite bool

If true, drops and recreates the index if it exists; if false, throws an error if it exists.

Examples

using (var m = new Manager(conn))
{
    var schema = m.LoadSchema("app");
    var table = schema["locations"];

    // Create a spatial index on a geometry column
    var spatialIndex = new SpatialIndex("sidx_location", table);
    spatialIndex.AddColumn(table["coordinates"]);
    m.CreateSpatialIndex(spatialIndex);
}

Remarks

Warning

The CreateSpatialIndex method is not available in the Community Edition of Velocity. It requires the Full Edition.

Spatial indexes improve performance for geospatial operations like distance calculations and spatial containment queries. Requires columns with Geometry or Geography data types.

Exceptions

DbException

Thrown when a database error occurs.