Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support supercluster#244 arrayType option within cluster sources #13253

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"quickselect": "^3.0.0",
"rw": "^1.3.3",
"serialize-to-js": "^3.1.2",
"supercluster": "^8.0.1",
"supercluster": "andrewharvey/supercluster#244",
"tinyqueue": "^3.0.0",
"tweakpane": "^4.0.4",
"vt-pbf": "^3.1.3"
Expand Down
3 changes: 2 additions & 1 deletion src/source/geojson_source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ class GeoJSONSource extends Evented<SourceEvents> implements ISource {
extent: EXTENT,
radius: (options.clusterRadius !== undefined ? options.clusterRadius : 50) * scale,
log: false,
generateId: options.generateId || false
generateId: options.generateId || false,
arrayType: options.clusterArrayType || 'Float32Array'
},
clusterProperties: options.clusterProperties,
filter: options.filter,
Expand Down
6 changes: 6 additions & 0 deletions src/source/geojson_worker_source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,12 @@ function getSuperclusterOptions({
}
};

// convert String option value into a TypedArray constructor
const arrayTypes = {
Float32Array, Float64Array
};
superclusterOptions.arrayType = arrayTypes[superclusterOptions.arrayType];

return superclusterOptions;
}

Expand Down
13 changes: 13 additions & 0 deletions src/style-spec/reference/v8.json
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,19 @@
"type": "*",
"doc": "An object defining custom properties on the generated clusters if clustering is enabled, aggregating values from clustered points. Has the form `{\"property_name\": [operator, map_expression]}`. `operator` is any expression function that accepts at least 2 operands (e.g. `\"+\"` or `\"max\"`) — it accumulates the property value from clusters/points the cluster contains; `map_expression` produces the value of a single point.\n\nExample: `{\"sum\": [\"+\", [\"get\", \"scalerank\"]]}`.\n\nFor more advanced use cases, in place of `operator`, you can use a custom reduce expression that references a special `[\"accumulated\"]` value, e.g.:\n`{\"sum\": [[\"+\", [\"accumulated\"], [\"get\", \"sum\"]], [\"get\", \"scalerank\"]]}`"
},
"clusterArrayType": {
"type": "enum",
"default": "Float32Array",
"values": {
"Float32Array": {
"doc": "A Float32Array"
},
"Float64Array": {
"doc": "A Float64Array"
}
},
"doc": "TypedArray to use for clustering, for clusterMaxZoom values and lower clusterRadius values you may need to increase this to Float64Array for more accurate clusters."
},
"lineMetrics": {
"type": "boolean",
"default": false,
Expand Down
1 change: 1 addition & 0 deletions src/style-spec/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ export type GeoJSONSourceSpecification = {
"clusterMaxZoom"?: number,
"clusterMinPoints"?: number,
"clusterProperties"?: unknown,
"clusterArrayType"?: "Float32Array" | "Float64Array",
"lineMetrics"?: boolean,
"generateId"?: boolean,
"promoteId"?: PromoteIdSpecification,
Expand Down
Loading