@@ -6,21 +6,22 @@ import {
66 CompositeLayer ,
77 CompositeLayerProps ,
88 DefaultProps ,
9+ GetPickingInfoParams ,
910 Layer ,
1011 LayersList ,
11- GetPickingInfoParams ,
1212 assert ,
1313} from "@deck.gl/core" ;
14- import { PolygonLayer } from "@deck.gl/layers" ;
1514import type { PolygonLayerProps } from "@deck.gl/layers" ;
16- import * as arrow from "apache-arrow " ;
15+ import { PolygonLayer } from "@deck.gl/layers " ;
1716import * as ga from "@geoarrow/geoarrow-js" ;
18- import { getGeometryData } from "../utils/utils" ;
19- import { GeoArrowExtraPickingProps , getPickingInfo } from "../utils/picking" ;
20- import { ColorAccessor , FloatAccessor , GeoArrowPickingInfo } from "../types" ;
17+ import * as arrow from "apache-arrow" ;
18+ import type { FunctionThread , Pool } from "threads" ;
2119import { EXTENSION_NAME } from "../constants" ;
22- import { GeoArrowSolidPolygonLayer } from "./solid-polygon-layer" ;
20+ import { ColorAccessor , FloatAccessor , GeoArrowPickingInfo } from "../types" ;
21+ import { GeoArrowExtraPickingProps } from "../utils/picking" ;
22+ import { getGeometryData } from "../utils/utils" ;
2323import { GeoArrowPathLayer } from "./path-layer" ;
24+ import { GeoArrowSolidPolygonLayer } from "./solid-polygon-layer" ;
2425
2526/**
2627 * Get the exterior of a PolygonVector or PolygonData as a MultiLineString
@@ -136,6 +137,34 @@ type _GeoArrowPolygonLayerProps = {
136137 */
137138 getElevation ?: FloatAccessor ;
138139
140+ /** A worker pool for earcut triangulation.
141+ *
142+ * You can use the `initEarcutPool` helper function to create a pool. This is
143+ * helpful if you're rendering many Polygon layers and want to share a pool
144+ * between them.
145+ *
146+ * If not provided, a pool will be created automatically.
147+ *
148+ * As of v0.4, layers have been refactored to take in a _RecordBatch_ as
149+ * input, instead of a table. This means that if a worker pool is created as
150+ * part of this layer, it will only be used once. To take advantage of the
151+ * pool, ideally you should create it externally and pass it in via this prop.
152+ */
153+ earcutWorkerPool ?: Pool < FunctionThread > | null ;
154+
155+ /**
156+ * URL to worker that performs earcut triangulation.
157+ *
158+ * By default this loads from the jsdelivr CDN, but end users may want to host
159+ * this on their own domain.
160+ */
161+ earcutWorkerUrl ?: string | URL | null ;
162+
163+ /**
164+ * The number of workers used for the earcut thread pool.
165+ */
166+ earcutWorkerPoolSize ?: number ;
167+
139168 /**
140169 * If `true`, validate the arrays provided (e.g. chunk lengths)
141170 * @default true
@@ -282,6 +311,9 @@ export class GeoArrowPolygonLayer<
282311 getPolygon,
283312 updateTriggers,
284313 material,
314+ earcutWorkerPool,
315+ earcutWorkerPoolSize,
316+ earcutWorkerUrl,
285317 } = this . props ;
286318
287319 const FillLayer = this . getSubLayerClass ( "fill" , GeoArrowSolidPolygonLayer ) ;
@@ -305,6 +337,10 @@ export class GeoArrowPolygonLayer<
305337
306338 material,
307339 transitions,
340+
341+ earcutWorkerPool,
342+ earcutWorkerPoolSize,
343+ earcutWorkerUrl,
308344 } ,
309345 this . getSubLayerProps ( {
310346 id : "fill" ,
0 commit comments