From bd95f700d11867f1f18f1faaf6675906f5fa6c27 Mon Sep 17 00:00:00 2001 From: gcroteau Date: Tue, 24 Nov 2015 21:57:25 -0500 Subject: [PATCH] Completed the Misc definitions. --- turf/turf-test.ts | 17 ++++++++++++++++- turf/turf.d.ts | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/turf/turf-test.ts b/turf/turf-test.ts index 85b2c7b9a..b053e761e 100644 --- a/turf/turf-test.ts +++ b/turf/turf-test.ts @@ -222,7 +222,7 @@ var bearing = turf.bearing(point1, point2); var centerPt = turf.center(features); // -- Test centroid -- -var centroidPt = turf.centroid(poly); +var centroidPt = turf.centroid(polygon1); // -- Test destination -- var distance = 50; @@ -291,6 +291,21 @@ var union = turf.union(polygon1, polygon2); // Tests Misc ////////////////////////////////////////////////////////////////////////// +// -- Test combine -- +var combined = turf.combine(features); + +// -- Test explode -- +var points = turf.explode(polygon1); + +// -- Test flip -- +var flipedPoint = turf.flip(point1); + +// -- Test kinks -- +var kinks = turf.kinks(polygon1); + +// -- Test lineSlice -- +var sliced = turf.lineSlice(point1, point2, line); + // -- Test pointOnLine -- var snapped = turf.pointOnLine(line, point1); diff --git a/turf/turf.d.ts b/turf/turf.d.ts index 77bba0c74..fb479ae34 100644 --- a/turf/turf.d.ts +++ b/turf/turf.d.ts @@ -212,6 +212,43 @@ declare module turf { // Misc ////////////////////////////////////////////////////// + /** + * Combines a FeatureCollection of Point, LineString, or Polygon features into MultiPoint, MultiLineString, or MultiPolygon features. + * @param fc A FeatureCollection of any type + * @returns A FeatureCollection of corresponding type to input + */ + function combine(fc: GeoJSON.FeatureCollection): GeoJSON.FeatureCollection; + + /** + * Takes a feature or set of features and returns all positions as points. + * @param input Input features + * @returns Points representing the exploded input features + */ + function explode(input: GeoJSON.Feature | GeoJSON.FeatureCollection): GeoJSON.FeatureCollection; + + /** + * Takes input features and flips all of their coordinates from [x, y] to [y, x]. + * @param input Input features + * @returns A feature or set of features of the same type as input with flipped coordinates + */ + function flip(input: GeoJSON.Feature | GeoJSON.FeatureCollection): GeoJSON.Feature | GeoJSON.FeatureCollection; + + /** + * Takes a polygon and returns points at all self-intersections. + * @param polygon Input polygon + * @returns Self-intersections + */ + function kinks(polygon: GeoJSON.Feature): GeoJSON.FeatureCollection; + + /** + * Takes a line, a start Point, and a stop point and returns the line in between those points. + * @param point1 Starting point + * @param point2 Stopping point + * @param line Line to slice + * @returns Sliced line + */ + function lineSlice(point1: GeoJSON.Feature, point2: GeoJSON.Feature, line: GeoJSON.Feature): GeoJSON.Feature; + /** * Takes a Point and a LineString and calculates the closest Point on the LineString. * @param line Line to snap to