Skip to content

document centroid #1362

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

Merged
merged 2 commits into from
Mar 25, 2023
Merged
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
20 changes: 20 additions & 0 deletions src/transforms/centroid.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
import type {ChannelTransform, ChannelValue} from "../channel.js";
import type {Initialized} from "./basic.js";

/** Options for the centroid and geoCentroid transforms. */
export interface CentroidOptions {
/**
* A channel supplying GeoJSON geometry; defaults to the identity transform,
* assuming that the data is GeoJSON geometry.
*/
geometry?: ChannelValue;
}

/**
* Given a **geometry** input channel of GeoJSON geometry, derives **x** and
* **y** output channels representing the planar (projected) centroids of the
* geometry. The centroids are computed in screen coordinates according to the
* plot’s associated **projection** (or *x* and *y* scales), if any.
*
* For centroids of spherical geometry, see Plot.geoCentroid.
*/
export function centroid<T>(options?: T & CentroidOptions): Initialized<T>;

/**
* Given a **geometry** input channel of spherical GeoJSON geometry, derives
* **x** and **y** output channels representing the spherical centroids of the
* geometry.
*
* For planar (projected) centroids, see Plot.centroid.
*/
export function geoCentroid<T>(options?: T & CentroidOptions): T & {x: ChannelTransform; y: ChannelTransform};