Skip to content

Commit

Permalink
Added JSDoc for internal types and constants e.g. Unts and earthRadiu…
Browse files Browse the repository at this point in the history
…s. Minimal other changes to bring JSDoc types into line with code types. Added GeoJsonProperties to documentation.yml for type linking.
  • Loading branch information
smallsaucepan committed Oct 5, 2024
1 parent b49f7b7 commit 2294677
Show file tree
Hide file tree
Showing 12 changed files with 356 additions and 232 deletions.
1 change: 1 addition & 0 deletions documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ toc:
- toWgs84
paths:
GeoJSON: "https://tools.ietf.org/html/rfc7946#section-3"
GeoJsonProperties: "https://tools.ietf.org/html/rfc7946#section-3.2"
GeometryCollection: "https://tools.ietf.org/html/rfc7946#section-3.1.8"
Point: "https://tools.ietf.org/html/rfc7946#section-3.1.2"
Points: "https://tools.ietf.org/html/rfc7946#section-3.1.2"
Expand Down
7 changes: 4 additions & 3 deletions packages/turf-along/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import { getGeom } from "@turf/invariant";
/**
* Takes a {@link LineString} and returns a {@link Point} at a specified distance along the line.
*
* @name along
* @param {Feature<LineString>} line input line
* @turfcategory Measurement
* @function
* @param {Feature<LineString>|LineString} line input line
* @param {number} distance distance along the line
* @param {Object} [options] Optional parameters
* @param {string} [options.units="kilometers"] can be degrees, radians, miles, or kilometers
* @param {Units} [options.units="kilometers"] can be degrees, radians, miles, or kilometers
* @returns {Feature<Point>} Point `distance` `units` along the line
* @example
* var line = turf.lineString([[-83, 30], [-84, 36], [-78, 41]]);
Expand Down
5 changes: 3 additions & 2 deletions packages/turf-bbox-polygon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import { polygon, Id } from "@turf/helpers";
/**
* Takes a bbox and returns an equivalent {@link Polygon|polygon}.
*
* @name bboxPolygon
* @turfcategory Measurement
* @function
* @param {BBox} bbox extent in [minX, minY, maxX, maxY] order
* @param {Object} [options={}] Optional parameters
* @param {Properties} [options.properties={}] Translate properties to Polygon
* @param {GeoJsonProperties} [options.properties={}] Translate properties to Polygon
* @param {string|number} [options.id={}] Translate Id to Polygon
* @returns {Feature<Polygon>} a Polygon representation of the bounding box
* @example
Expand Down
21 changes: 18 additions & 3 deletions packages/turf-clusters-dbscan/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,21 @@ import { distance } from "@turf/distance";
import { degreesToRadians, lengthToDegrees, Units } from "@turf/helpers";
import { rbush as RBush } from "./lib/rbush-export.js";

/**
* Point classification within the cluster.
*
* @typedef {"core" | "edge" | "noise"} Dbscan
*/
type Dbscan = "core" | "edge" | "noise";

/**
* Properties assigned to each clustered point.
*
* @extends GeoJsonProperties
* @typedef {object} DbscanProps
* @property {Dbscan} [dbscan] type of point it has been classified as
* @property {number} [cluster] associated clusterId
*/
type DbscanProps = GeoJsonProperties & {
dbscan?: Dbscan;
cluster?: number;
Expand All @@ -20,17 +34,18 @@ type IndexedPoint = {
};

/**
* Takes a set of {@link Point|points} and partition them into clusters according to {@link DBSCAN's|https://en.wikipedia.org/wiki/DBSCAN} data clustering algorithm.
* Takes a set of {@link Point|points} and partition them into clusters according to {@link https://en.wikipedia.org/wiki/DBSCAN|DBSCAN's} data clustering algorithm.
*
* @name clustersDbscan
* @turfcategory Aggregation
* @function
* @param {FeatureCollection<Point>} points to be clustered
* @param {number} maxDistance Maximum Distance between any point of the cluster to generate the clusters (kilometers by default, see options)
* @param {Object} [options={}] Optional parameters
* @param {string} [options.units="kilometers"] in which `maxDistance` is expressed, can be degrees, radians, miles, or kilometers
* @param {boolean} [options.mutate=false] Allows GeoJSON input to be mutated
* @param {number} [options.minPoints=3] Minimum number of points to generate a single cluster,
* points which do not meet this requirement will be classified as an 'edge' or 'noise'.
* @returns {FeatureCollection<Point>} Clustered Points with an additional two properties associated to each Feature:
* @returns {FeatureCollection<Point, DbscanProps>} Clustered Points with an additional two properties associated to each Feature:
* - {number} cluster - the associated clusterId
* - {string} dbscan - type of point it has been classified as ('core'|'edge'|'noise')
* @example
Expand Down
7 changes: 4 additions & 3 deletions packages/turf-dissolve/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import { flatten } from "@turf/flatten";
import polygonClipping, { Geom } from "polygon-clipping";

/**
* Dissolves a FeatureCollection of {@link polygon} features, filtered by an optional property name:value.
* Note that {@link mulitpolygon} features within the collection are not supported
* Dissolves a FeatureCollection of {@link Polygon} features, filtered by an optional property name:value.
* Note that {@link MultiPolygon} features within the collection are not supported
*
* @name dissolve
* @turfcategory Transformation
* @function
* @param {FeatureCollection<Polygon>} featureCollection input feature collection to be dissolved
* @param {Object} [options={}] Optional parameters
* @param {string} [options.propertyName] features with the same `propertyName` value will be dissolved.
Expand Down
Loading

0 comments on commit 2294677

Please sign in to comment.