Skip to main content

unprepare

Frees the prepared internal spatial indexes.

Call this function when you no longer need a performance boost, but need the geometry itself and want to reclaim some memory.

The prepared internal spatial indexes will be automatically freed alongside the geometry itself, either when released via free or when geometry goes out of scope.

Modifies the geometry in-place.

Type Parameters

  • G - The type of prepared geometry, for example, Geometry or more specific Polygon

Parameters

NameTypeDescription
geometryPrepared<G>Geometry to free its prepared indexes

Returns

G

Exactly the same geometry object, but without prepared internal spatial indexes

See also

Examples

lifecycle of the prepared geometry
const regularPolygon = buffer(point([ 0, 0 ]), 10, { quadrantSegments: 1000 });
const preparedPolygon = prepare(regularPolygon);
const regularPolygonAgain = unprepare(preparedPolygon);
// `regularPolygon`, `preparedPolygon` and `regularPolygonAgain` are exactly the same object
// so if you do not care about TypeScript, the above can be simplified to:
const p = buffer(point([ 0, 0 ]), 10, { quadrantSegments: 1000 });
prepare(p);
unprepare(p);