prepare
Prepares geometry to optimize the performance of repeated calls to specific geometric operations.
The "prepared geometry" is conceptually similar to a database "prepared statement": by doing up-front work to create an optimized object, you reap a performance benefit when executing repeated function calls on that object.
List of functions that benefit from geometry preparation:
Modifies the geometry in-place.
Type Parameters
Parameters
Name | Type | Description |
---|---|---|
geometry | G | Geometry to prepare |
Returns
Prepared<G>
Exactly the same geometry object, but with prepared internal spatial indexes
See also
unprepare
frees prepared indexesisPrepared
checks whether a geometry is prepared- https://libgeos.org/usage/c_api/#prepared-geometry
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);