mirror of
https://github.com/Turfjs/turf.git
synced 2026-02-01 16:57:21 +00:00
Migrate to @types/geojson package (#2158)
* migrate to geojson types package * strip geojson further * migrate geojson type imports * migrate more geojson type imports * bump to geojson-rbush 3.2.0 and add line-overlap fix * few more type migrations * migrate to new internal es5 @turf/geojson-rbush * migrate buffer to geojson types * fix convertLength import
This commit is contained in:
parent
313e5264bc
commit
d72985ce1a
@ -34,7 +34,7 @@
|
||||
"**/*": "prettier --write --ignore-unknown"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/geojson": "*",
|
||||
"@types/geojson": "7946.0.8",
|
||||
"@types/node": "*",
|
||||
"@typescript-eslint/eslint-plugin": "^4.8.0",
|
||||
"@typescript-eslint/parser": "^4.8.0",
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { Feature, LineString, Point } from "geojson";
|
||||
import bearing from "@turf/bearing";
|
||||
import destination from "@turf/destination";
|
||||
import measureDistance from "@turf/distance";
|
||||
import { Feature, LineString, point, Point, Units } from "@turf/helpers";
|
||||
import { point, Units } from "@turf/helpers";
|
||||
import { getGeom } from "@turf/invariant";
|
||||
|
||||
/**
|
||||
|
||||
@ -1,9 +1,5 @@
|
||||
import {
|
||||
earthRadius,
|
||||
Feature,
|
||||
FeatureCollection,
|
||||
Geometry,
|
||||
} from "@turf/helpers";
|
||||
import { Feature, FeatureCollection, Geometry } from "geojson";
|
||||
import { earthRadius } from "@turf/helpers";
|
||||
import { geomReduce } from "@turf/meta";
|
||||
|
||||
/**
|
||||
|
||||
@ -2,14 +2,17 @@ import {
|
||||
BBox,
|
||||
Feature,
|
||||
LineString,
|
||||
MultiLineString,
|
||||
MultiPolygon,
|
||||
GeoJsonProperties,
|
||||
Polygon,
|
||||
} from "geojson";
|
||||
|
||||
import {
|
||||
lineString,
|
||||
multiLineString,
|
||||
MultiLineString,
|
||||
multiPolygon,
|
||||
MultiPolygon,
|
||||
polygon,
|
||||
Polygon,
|
||||
Properties,
|
||||
} from "@turf/helpers";
|
||||
import { getGeom } from "@turf/invariant";
|
||||
import { lineclip, polygonclip } from "./lib/lineclip";
|
||||
@ -34,7 +37,7 @@ import { lineclip, polygonclip } from "./lib/lineclip";
|
||||
*/
|
||||
export default function bboxClip<
|
||||
G extends Polygon | MultiPolygon | LineString | MultiLineString,
|
||||
P = Properties
|
||||
P = GeoJsonProperties
|
||||
>(feature: Feature<G, P> | G, bbox: BBox) {
|
||||
const geom = getGeom(feature);
|
||||
const type = geom.type;
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
// Cohen-Sutherland line clipping algorithm, adapted to efficiently
|
||||
// handle polylines rather than just segments
|
||||
|
||||
import { BBox } from "@turf/helpers";
|
||||
import { BBox } from "geojson";
|
||||
|
||||
export function lineclip(
|
||||
points: number[][],
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { BBox, Feature, Id, polygon, Polygon, Properties } from "@turf/helpers";
|
||||
import { BBox, Feature, Polygon, GeoJsonProperties } from "geojson";
|
||||
import { polygon, Id } from "@turf/helpers";
|
||||
|
||||
/**
|
||||
* Takes a bbox and returns an equivalent {@link Polygon|polygon}.
|
||||
@ -17,7 +18,7 @@ import { BBox, Feature, Id, polygon, Polygon, Properties } from "@turf/helpers";
|
||||
* //addToMap
|
||||
* var addToMap = [poly]
|
||||
*/
|
||||
export default function bboxPolygon<P = Properties>(
|
||||
export default function bboxPolygon<P = GeoJsonProperties>(
|
||||
bbox: BBox,
|
||||
options: {
|
||||
properties?: P;
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { AllGeoJSON, BBox } from "@turf/helpers";
|
||||
import { BBox } from "geojson";
|
||||
import { AllGeoJSON } from "@turf/helpers";
|
||||
import { coordEach } from "@turf/meta";
|
||||
|
||||
/**
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { Feature, lineString, LineString, Properties } from "@turf/helpers";
|
||||
import { Feature, LineString, GeoJsonProperties } from "geojson";
|
||||
import { lineString } from "@turf/helpers";
|
||||
import { getGeom } from "@turf/invariant";
|
||||
import Spline from "./lib/spline";
|
||||
|
||||
@ -32,7 +33,7 @@ import Spline from "./lib/spline";
|
||||
* var addToMap = [line, curved]
|
||||
* curved.properties = { stroke: '#0F0' };
|
||||
*/
|
||||
function bezier<P = Properties>(
|
||||
function bezier<P = GeoJsonProperties>(
|
||||
line: Feature<LineString> | LineString,
|
||||
options: {
|
||||
properties?: P;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { Feature, LineString, Position } from "@turf/helpers";
|
||||
import { Feature, LineString, Position } from "geojson";
|
||||
import { getCoords } from "@turf/invariant";
|
||||
|
||||
/**
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { Feature, Polygon } from "@turf/helpers";
|
||||
import { Feature, Polygon } from "geojson";
|
||||
import { getGeom } from "@turf/invariant";
|
||||
|
||||
/**
|
||||
|
||||
@ -1,6 +1,3 @@
|
||||
import calcBbox from "@turf/bbox";
|
||||
import booleanPointInPolygon from "@turf/boolean-point-in-polygon";
|
||||
import isPointOnLine from "@turf/boolean-point-on-line";
|
||||
import {
|
||||
BBox,
|
||||
Feature,
|
||||
@ -9,7 +6,10 @@ import {
|
||||
MultiPoint,
|
||||
Point,
|
||||
Polygon,
|
||||
} from "@turf/helpers";
|
||||
} from "geojson";
|
||||
import calcBbox from "@turf/bbox";
|
||||
import booleanPointInPolygon from "@turf/boolean-point-in-polygon";
|
||||
import isPointOnLine from "@turf/boolean-point-on-line";
|
||||
import { getGeom } from "@turf/invariant";
|
||||
|
||||
/**
|
||||
|
||||
@ -1,15 +1,9 @@
|
||||
import { Feature, Geometry, Polygon, LineString, MultiPoint } from "geojson";
|
||||
import lineIntersect from "@turf/line-intersect";
|
||||
import { polygonToLine } from "@turf/polygon-to-line";
|
||||
import booleanPointInPolygon from "@turf/boolean-point-in-polygon";
|
||||
import { getGeom } from "@turf/invariant";
|
||||
import {
|
||||
point,
|
||||
Feature,
|
||||
Geometry,
|
||||
Polygon,
|
||||
LineString,
|
||||
MultiPoint,
|
||||
} from "@turf/helpers";
|
||||
import { point } from "@turf/helpers";
|
||||
|
||||
/**
|
||||
* Boolean-Crosses returns True if the intersection results in a geometry whose dimension is one less than
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { Feature, Geometry, LineString, Point, Polygon } from "geojson";
|
||||
import booleanPointInPolygon from "@turf/boolean-point-in-polygon";
|
||||
import { Feature, Geometry, LineString, Point, Polygon } from "@turf/helpers";
|
||||
import lineIntersect from "@turf/line-intersect";
|
||||
import { flattenEach } from "@turf/meta";
|
||||
import polygonToLine from "@turf/polygon-to-line";
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { Feature, Geometry } from "geojson";
|
||||
import GeojsonEquality from "geojson-equality";
|
||||
import cleanCoords from "@turf/clean-coords";
|
||||
import { getGeom } from "@turf/invariant";
|
||||
import { Feature, Geometry } from "@turf/helpers";
|
||||
|
||||
/**
|
||||
* Determine whether two geometries of the same type have identical X,Y coordinate values.
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { Feature, Geometry } from "geojson";
|
||||
import booleanDisjoint from "@turf/boolean-disjoint";
|
||||
import { Feature, Geometry } from "@turf/helpers";
|
||||
import { flattenEach } from "@turf/meta";
|
||||
|
||||
/**
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { Feature, Geometry, MultiPoint } from "geojson";
|
||||
import { segmentEach } from "@turf/meta";
|
||||
import { getGeom } from "@turf/invariant";
|
||||
import lineOverlap from "@turf/line-overlap";
|
||||
import lineIntersect from "@turf/line-intersect";
|
||||
import GeojsonEquality from "geojson-equality";
|
||||
import { Feature, Geometry, MultiPoint } from "@turf/helpers";
|
||||
|
||||
/**
|
||||
* Compares two geometries of the same dimension and returns true if their intersection set results in a geometry
|
||||
|
||||
@ -1,13 +1,8 @@
|
||||
import { Feature, Geometry, LineString, Position } from "geojson";
|
||||
import cleanCoords from "@turf/clean-coords";
|
||||
import lineSegment from "@turf/line-segment";
|
||||
import rhumbBearing from "@turf/rhumb-bearing";
|
||||
import {
|
||||
bearingToAzimuth,
|
||||
Feature,
|
||||
Geometry,
|
||||
LineString,
|
||||
Position,
|
||||
} from "@turf/helpers";
|
||||
import { bearingToAzimuth } from "@turf/helpers";
|
||||
|
||||
/**
|
||||
* Boolean-Parallel returns True if each segment of `line1` is parallel to the correspondent segment of `line2`
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import {
|
||||
BBox,
|
||||
Coord,
|
||||
Feature,
|
||||
MultiPolygon,
|
||||
Polygon,
|
||||
Properties,
|
||||
} from "@turf/helpers";
|
||||
GeoJsonProperties,
|
||||
} from "geojson";
|
||||
import { Coord } from "@turf/helpers";
|
||||
import { getCoord, getGeom } from "@turf/invariant";
|
||||
|
||||
// http://en.wikipedia.org/wiki/Even%E2%80%93odd_rule
|
||||
@ -37,7 +37,7 @@ import { getCoord, getGeom } from "@turf/invariant";
|
||||
*/
|
||||
export default function booleanPointInPolygon<
|
||||
G extends Polygon | MultiPolygon,
|
||||
P = Properties
|
||||
P = GeoJsonProperties
|
||||
>(
|
||||
point: Coord,
|
||||
polygon: Feature<G, P> | G,
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { Coord, Feature, LineString } from "@turf/helpers";
|
||||
import { Feature, LineString } from "geojson";
|
||||
import { Coord } from "@turf/helpers";
|
||||
import { getCoord, getCoords } from "@turf/invariant";
|
||||
|
||||
/**
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { Feature, Geometry, LineString, Point } from "geojson";
|
||||
import booleanPointOnLine from "@turf/boolean-point-on-line";
|
||||
import booleanPointInPolygon from "@turf/boolean-point-in-polygon";
|
||||
import { getGeom } from "@turf/invariant";
|
||||
import { Feature, Geometry, LineString, Point } from "@turf/helpers";
|
||||
|
||||
/**
|
||||
* Boolean-touches true if none of the points common to both geometries
|
||||
|
||||
@ -1,11 +1,6 @@
|
||||
import { Feature, Geometry, Position } from "geojson";
|
||||
import { getGeom } from "@turf/invariant";
|
||||
import {
|
||||
polygon,
|
||||
lineString,
|
||||
Feature,
|
||||
Geometry,
|
||||
Position,
|
||||
} from "@turf/helpers";
|
||||
import { polygon, lineString } from "@turf/helpers";
|
||||
import booleanDisjoint from "@turf/boolean-disjoint";
|
||||
import booleanCrosses from "@turf/boolean-crosses";
|
||||
import lineIntersect from "@turf/line-intersect";
|
||||
|
||||
@ -1,7 +1,3 @@
|
||||
import calcBbox from "@turf/bbox";
|
||||
import booleanPointOnLine from "@turf/boolean-point-on-line";
|
||||
import booleanPointInPolygon from "@turf/boolean-point-in-polygon";
|
||||
import { getGeom } from "@turf/invariant";
|
||||
import {
|
||||
BBox,
|
||||
Feature,
|
||||
@ -11,7 +7,11 @@ import {
|
||||
MultiPolygon,
|
||||
Point,
|
||||
Polygon,
|
||||
} from "@turf/helpers";
|
||||
} from "geojson";
|
||||
import calcBbox from "@turf/bbox";
|
||||
import booleanPointOnLine from "@turf/boolean-point-on-line";
|
||||
import booleanPointInPolygon from "@turf/boolean-point-in-polygon";
|
||||
import { getGeom } from "@turf/invariant";
|
||||
|
||||
/**
|
||||
* Boolean-within returns true if the first geometry is completely within the second geometry.
|
||||
|
||||
4
packages/turf-buffer/index.d.ts
vendored
4
packages/turf-buffer/index.d.ts
vendored
@ -9,8 +9,8 @@ import {
|
||||
GeometryCollection,
|
||||
Feature,
|
||||
FeatureCollection,
|
||||
Units,
|
||||
} from "@turf/helpers";
|
||||
} from "geojson";
|
||||
import { Units } from "@turf/helpers";
|
||||
|
||||
interface Options {
|
||||
units?: Units;
|
||||
|
||||
@ -7,9 +7,8 @@ import {
|
||||
multiPolygon,
|
||||
featureCollection,
|
||||
geometryCollection,
|
||||
Point,
|
||||
LineString,
|
||||
} from "@turf/helpers";
|
||||
import { Point, LineString } from "geojson";
|
||||
import buffer from "./";
|
||||
|
||||
// Standard Geometry
|
||||
|
||||
@ -1,13 +1,6 @@
|
||||
import { BBox, Feature, Point, GeoJsonProperties } from "geojson";
|
||||
import { geomEach, coordEach } from "@turf/meta";
|
||||
import {
|
||||
isNumber,
|
||||
point,
|
||||
Feature,
|
||||
Point,
|
||||
Properties,
|
||||
BBox,
|
||||
Id,
|
||||
} from "@turf/helpers";
|
||||
import { isNumber, point, Id } from "@turf/helpers";
|
||||
|
||||
/**
|
||||
* Takes a {@link Feature} or {@link FeatureCollection} and returns the mean center. Can be weighted.
|
||||
@ -35,7 +28,7 @@ import {
|
||||
* mean.properties['marker-size'] = 'large';
|
||||
* mean.properties['marker-color'] = '#000';
|
||||
*/
|
||||
function centerMean<P = Properties>(
|
||||
function centerMean<P = GeoJsonProperties>(
|
||||
geojson: any, // To-Do include Typescript AllGeoJSON
|
||||
options: { properties?: P; bbox?: BBox; id?: Id; weight?: string } = {}
|
||||
): Feature<Point, P> {
|
||||
|
||||
@ -1,16 +1,8 @@
|
||||
import { FeatureCollection, Feature, Point, Position } from "geojson";
|
||||
import centerMean from "@turf/center-mean";
|
||||
import distance from "@turf/distance";
|
||||
import centroid from "@turf/centroid";
|
||||
import {
|
||||
isNumber,
|
||||
point,
|
||||
isObject,
|
||||
featureCollection,
|
||||
FeatureCollection,
|
||||
Feature,
|
||||
Point,
|
||||
Position,
|
||||
} from "@turf/helpers";
|
||||
import { isNumber, point, isObject, featureCollection } from "@turf/helpers";
|
||||
import { featureEach } from "@turf/meta";
|
||||
|
||||
/**
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { Feature, GeoJsonProperties, Point, Position } from "geojson";
|
||||
import convex from "@turf/convex";
|
||||
import centroid from "@turf/centroid";
|
||||
import { point, Properties, Feature, Point, Position } from "@turf/helpers";
|
||||
import { point } from "@turf/helpers";
|
||||
import { getType, getCoord } from "@turf/invariant";
|
||||
import { coordEach } from "@turf/meta";
|
||||
|
||||
@ -20,7 +21,7 @@ import { coordEach } from "@turf/meta";
|
||||
* //addToMap
|
||||
* var addToMap = [polygon, center]
|
||||
*/
|
||||
function centerOfMass<P = Properties>(
|
||||
function centerOfMass<P = GeoJsonProperties>(
|
||||
geojson: any,
|
||||
options: {
|
||||
properties?: P;
|
||||
|
||||
@ -1,13 +1,6 @@
|
||||
import { BBox, Feature, GeoJsonProperties, Point } from "geojson";
|
||||
import bbox from "@turf/bbox";
|
||||
import {
|
||||
point,
|
||||
BBox,
|
||||
Id,
|
||||
AllGeoJSON,
|
||||
Feature,
|
||||
Point,
|
||||
Properties,
|
||||
} from "@turf/helpers";
|
||||
import { point, Id, AllGeoJSON } from "@turf/helpers";
|
||||
|
||||
/**
|
||||
* Takes a {@link Feature} or {@link FeatureCollection} and returns the absolute center point of all features.
|
||||
@ -33,7 +26,7 @@ import {
|
||||
* center.properties['marker-size'] = 'large';
|
||||
* center.properties['marker-color'] = '#000';
|
||||
*/
|
||||
function center<P = Properties>(
|
||||
function center<P = GeoJsonProperties>(
|
||||
geojson: AllGeoJSON,
|
||||
options: { properties?: P; bbox?: BBox; id?: Id } = {}
|
||||
): Feature<Point, P> {
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { Feature, GeoJsonProperties, Point } from "geojson";
|
||||
import { point, AllGeoJSON } from "@turf/helpers";
|
||||
import { coordEach } from "@turf/meta";
|
||||
import { point, AllGeoJSON, Feature, Point, Properties } from "@turf/helpers";
|
||||
|
||||
/**
|
||||
* Takes one or more features and calculates the centroid using the mean of all vertices.
|
||||
@ -18,7 +19,7 @@ import { point, AllGeoJSON, Feature, Point, Properties } from "@turf/helpers";
|
||||
* //addToMap
|
||||
* var addToMap = [polygon, centroid]
|
||||
*/
|
||||
function centroid<P = Properties>(
|
||||
function centroid<P = GeoJsonProperties>(
|
||||
geojson: AllGeoJSON,
|
||||
options: {
|
||||
properties?: P;
|
||||
|
||||
@ -1,12 +1,6 @@
|
||||
import { GeoJsonProperties, Feature, Point, Polygon } from "geojson";
|
||||
import destination from "@turf/destination";
|
||||
import {
|
||||
polygon,
|
||||
Units,
|
||||
Point,
|
||||
Properties,
|
||||
Feature,
|
||||
Polygon,
|
||||
} from "@turf/helpers";
|
||||
import { polygon, Units } from "@turf/helpers";
|
||||
|
||||
/**
|
||||
* Takes a {@link Point} and calculates the circle polygon given a radius in degrees, radians, miles, or kilometers; and steps for precision.
|
||||
@ -28,7 +22,7 @@ import {
|
||||
* //addToMap
|
||||
* var addToMap = [turf.point(center), circle]
|
||||
*/
|
||||
function circle<P = Properties>(
|
||||
function circle<P = GeoJsonProperties>(
|
||||
center: number[] | Point | Feature<Point, P>,
|
||||
radius: number,
|
||||
options: {
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { feature, Position } from "@turf/helpers";
|
||||
import { Position } from "geojson";
|
||||
import { feature } from "@turf/helpers";
|
||||
import { getCoords, getType } from "@turf/invariant";
|
||||
|
||||
// To-Do => Improve Typescript GeoJSON handling
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { AllGeoJSON, Feature, Properties } from "@turf/helpers";
|
||||
import { Feature, GeoJsonProperties } from "geojson";
|
||||
import { AllGeoJSON } from "@turf/helpers";
|
||||
|
||||
/**
|
||||
* Returns a cloned copy of the passed GeoJSON Object, including possible 'Foreign Members'.
|
||||
@ -68,7 +69,7 @@ function cloneFeature(geojson: any) {
|
||||
* @param {Object} properties GeoJSON Properties
|
||||
* @returns {Object} cloned Properties
|
||||
*/
|
||||
function cloneProperties(properties: Properties) {
|
||||
function cloneProperties(properties: GeoJsonProperties) {
|
||||
const cloned: { [key: string]: any } = {};
|
||||
if (!properties) {
|
||||
return cloned;
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { Feature, lineString, LineString, point, Point } from "@turf/helpers";
|
||||
import { Feature, LineString, Point } from "geojson";
|
||||
import { lineString, point } from "@turf/helpers";
|
||||
import clone from "./index";
|
||||
|
||||
const pt = point([0, 20]);
|
||||
|
||||
@ -1,17 +1,12 @@
|
||||
import { GeoJsonProperties, FeatureCollection, Point } from "geojson";
|
||||
import clone from "@turf/clone";
|
||||
import distance from "@turf/distance";
|
||||
import { coordAll } from "@turf/meta";
|
||||
import {
|
||||
convertLength,
|
||||
Properties,
|
||||
Units,
|
||||
FeatureCollection,
|
||||
Point,
|
||||
} from "@turf/helpers";
|
||||
import { convertLength, Units } from "@turf/helpers";
|
||||
import clustering from "density-clustering";
|
||||
|
||||
export type Dbscan = "core" | "edge" | "noise";
|
||||
export type DbscanProps = Properties & {
|
||||
export type DbscanProps = GeoJsonProperties & {
|
||||
dbscan?: Dbscan;
|
||||
cluster?: number;
|
||||
};
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { FeatureCollection, Point, GeoJsonProperties } from "geojson";
|
||||
import clone from "@turf/clone";
|
||||
import { coordAll, featureEach } from "@turf/meta";
|
||||
import { FeatureCollection, Point, Properties } from "@turf/helpers";
|
||||
import skmeans from "skmeans";
|
||||
|
||||
export type KmeansProps = Properties & {
|
||||
export type KmeansProps = GeoJsonProperties & {
|
||||
cluster?: number;
|
||||
centroid?: [number, number];
|
||||
};
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { Feature, FeatureCollection, GeometryObject } from "geojson";
|
||||
import { featureEach } from "@turf/meta";
|
||||
import { featureCollection, Feature, FeatureCollection } from "@turf/helpers";
|
||||
import { featureCollection } from "@turf/helpers";
|
||||
|
||||
/**
|
||||
* Get Cluster
|
||||
@ -30,7 +31,7 @@ import { featureCollection, Feature, FeatureCollection } from "@turf/helpers";
|
||||
* turf.getCluster(clustered, {'marker-symbol': 'square'}).length;
|
||||
* //= 1
|
||||
*/
|
||||
export function getCluster<G extends any, P = any>(
|
||||
export function getCluster<G extends GeometryObject, P = any>(
|
||||
geojson: FeatureCollection<G, P>,
|
||||
filter: any
|
||||
): FeatureCollection<G, P> {
|
||||
@ -98,7 +99,7 @@ export function getCluster<G extends any, P = any>(
|
||||
* values.push(clusterValue);
|
||||
* });
|
||||
*/
|
||||
export function clusterEach<G = any, P = any>(
|
||||
export function clusterEach<G extends GeometryObject, P = any>(
|
||||
geojson: FeatureCollection<G, P>,
|
||||
property: number | string,
|
||||
callback: (
|
||||
@ -192,7 +193,7 @@ export function clusterEach<G = any, P = any>(
|
||||
* return previousValue.concat(clusterValue);
|
||||
* }, []);
|
||||
*/
|
||||
export function clusterReduce<G = any, P = any>(
|
||||
export function clusterReduce<G extends GeometryObject, P = any>(
|
||||
geojson: FeatureCollection<G, P>,
|
||||
property: number | string,
|
||||
callback: (
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { Point } from "geojson";
|
||||
import * as clusters from "./";
|
||||
import { featureCollection, point, Point } from "@turf/helpers";
|
||||
import { featureCollection, point } from "@turf/helpers";
|
||||
import { getCluster, clusterEach, clusterReduce } from "./index";
|
||||
|
||||
/**
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { FeatureCollection, Polygon, Point } from "geojson";
|
||||
import turfbbox from "@turf/bbox";
|
||||
import booleanPointInPolygon from "@turf/boolean-point-in-polygon";
|
||||
import rbush from "rbush";
|
||||
import { FeatureCollection, Polygon, Point } from "@turf/helpers";
|
||||
|
||||
interface Entry {
|
||||
minX: number;
|
||||
|
||||
@ -1,13 +1,15 @@
|
||||
import {
|
||||
feature,
|
||||
featureCollection,
|
||||
GeoJsonProperties,
|
||||
FeatureCollection,
|
||||
LineString,
|
||||
MultiLineString,
|
||||
MultiPoint,
|
||||
MultiPolygon,
|
||||
Properties,
|
||||
} from "@turf/helpers";
|
||||
Point,
|
||||
Polygon,
|
||||
} from "geojson";
|
||||
import { feature, featureCollection } from "@turf/helpers";
|
||||
import { featureEach } from "@turf/meta";
|
||||
import { Point, LineString, Polygon, FeatureCollection } from "@turf/helpers";
|
||||
|
||||
/**
|
||||
* Combines a {@link FeatureCollection} of {@link Point}, {@link LineString}, or {@link Polygon} features
|
||||
@ -35,15 +37,15 @@ function combine(
|
||||
var groups = {
|
||||
MultiPoint: {
|
||||
coordinates: [] as number[][],
|
||||
properties: [] as Properties[],
|
||||
properties: [] as GeoJsonProperties[],
|
||||
},
|
||||
MultiLineString: {
|
||||
coordinates: [] as number[][][],
|
||||
properties: [] as Properties[],
|
||||
properties: [] as GeoJsonProperties[],
|
||||
},
|
||||
MultiPolygon: {
|
||||
coordinates: [] as number[][][][],
|
||||
properties: [] as Properties[],
|
||||
properties: [] as GeoJsonProperties[],
|
||||
},
|
||||
};
|
||||
|
||||
@ -87,7 +89,10 @@ function combine(
|
||||
})
|
||||
.sort()
|
||||
.map(function (key) {
|
||||
var geometry = { type: key, coordinates: groups[key].coordinates };
|
||||
var geometry = { type: key, coordinates: groups[key].coordinates } as
|
||||
| MultiPoint
|
||||
| MultiLineString
|
||||
| MultiPolygon;
|
||||
var properties = { collectedProperties: groups[key].properties };
|
||||
return feature(geometry, properties);
|
||||
})
|
||||
|
||||
@ -6,8 +6,8 @@ import {
|
||||
MultiPolygon,
|
||||
Point,
|
||||
Polygon,
|
||||
Units,
|
||||
} from "@turf/helpers";
|
||||
} from "geojson";
|
||||
import { Units } from "@turf/helpers";
|
||||
import { featureEach } from "@turf/meta";
|
||||
import tin from "@turf/tin";
|
||||
import dissolve from "./lib/turf-dissolve";
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
import clone from "@turf/clone";
|
||||
import { isObject } from "@turf/helpers";
|
||||
import {
|
||||
Feature,
|
||||
FeatureCollection,
|
||||
@ -7,7 +5,9 @@ import {
|
||||
MultiLineString,
|
||||
MultiPolygon,
|
||||
Polygon,
|
||||
} from "@turf/helpers";
|
||||
} from "geojson";
|
||||
import clone from "@turf/clone";
|
||||
import { isObject } from "@turf/helpers";
|
||||
import { getType } from "@turf/invariant";
|
||||
import { flattenEach } from "@turf/meta";
|
||||
import lineDissolve from "./turf-line-dissolve";
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import clone from "@turf/clone";
|
||||
import { isObject, lineString, multiLineString } from "@turf/helpers";
|
||||
import {
|
||||
Feature,
|
||||
FeatureCollection,
|
||||
LineString,
|
||||
MultiLineString,
|
||||
} from "@turf/helpers";
|
||||
} from "geojson";
|
||||
import clone from "@turf/clone";
|
||||
import { isObject, lineString, multiLineString } from "@turf/helpers";
|
||||
import { getType } from "@turf/invariant";
|
||||
import { lineReduce } from "@turf/meta";
|
||||
|
||||
|
||||
@ -1,11 +1,6 @@
|
||||
import { Feature, FeatureCollection, MultiPolygon, Polygon } from "geojson";
|
||||
import clone from "@turf/clone";
|
||||
import { geometryCollection } from "@turf/helpers";
|
||||
import {
|
||||
Feature,
|
||||
FeatureCollection,
|
||||
MultiPolygon,
|
||||
Polygon,
|
||||
} from "@turf/helpers";
|
||||
import { getType } from "@turf/invariant";
|
||||
import { flattenEach } from "@turf/meta";
|
||||
import { merge } from "topojson-client";
|
||||
|
||||
@ -1,10 +1,5 @@
|
||||
import {
|
||||
AllGeoJSON,
|
||||
Feature,
|
||||
polygon,
|
||||
Polygon,
|
||||
Properties,
|
||||
} from "@turf/helpers";
|
||||
import { Feature, GeoJsonProperties, Polygon } from "geojson";
|
||||
import { AllGeoJSON, polygon } from "@turf/helpers";
|
||||
import { coordEach } from "@turf/meta";
|
||||
import concaveman from "concaveman";
|
||||
|
||||
@ -36,7 +31,7 @@ import concaveman from "concaveman";
|
||||
* //addToMap
|
||||
* var addToMap = [points, hull]
|
||||
*/
|
||||
export default function convex<P = Properties>(
|
||||
export default function convex<P = GeoJsonProperties>(
|
||||
geojson: AllGeoJSON,
|
||||
options: {
|
||||
concavity?: number;
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
// http://en.wikipedia.org/wiki/Haversine_formula
|
||||
// http://www.movable-type.co.uk/scripts/latlong.html
|
||||
import { Feature, Point, GeoJsonProperties } from "geojson";
|
||||
import {
|
||||
Coord,
|
||||
degreesToRadians,
|
||||
Feature,
|
||||
lengthToRadians,
|
||||
point,
|
||||
Point,
|
||||
Properties,
|
||||
radiansToDegrees,
|
||||
Units,
|
||||
} from "@turf/helpers";
|
||||
@ -39,7 +37,7 @@ import { getCoord } from "@turf/invariant";
|
||||
* destination.properties['marker-color'] = '#f00';
|
||||
* point.properties['marker-color'] = '#0f0';
|
||||
*/
|
||||
export default function destination<P = Properties>(
|
||||
export default function destination<P = GeoJsonProperties>(
|
||||
origin: Coord,
|
||||
distance: number,
|
||||
bearing: number,
|
||||
|
||||
2
packages/turf-difference/index.d.ts
vendored
2
packages/turf-difference/index.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
import { Polygon, MultiPolygon, Feature } from "@turf/helpers";
|
||||
import { Polygon, MultiPolygon, Feature } from "geojson";
|
||||
|
||||
/**
|
||||
* http://turfjs.org/docs/#difference
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { Feature, FeatureCollection, LineString, Point } from "geojson";
|
||||
import bearing from "@turf/bearing";
|
||||
import centroid from "@turf/centroid";
|
||||
import destination from "@turf/destination";
|
||||
import { featureCollection, lineString, point } from "@turf/helpers";
|
||||
import { Feature, FeatureCollection, LineString, Point } from "@turf/helpers";
|
||||
import { getCoord } from "@turf/invariant";
|
||||
import length from "@turf/length";
|
||||
import { featureEach, segmentEach, segmentReduce } from "@turf/meta";
|
||||
|
||||
2
packages/turf-dissolve/index.d.ts
vendored
2
packages/turf-dissolve/index.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
import { FeatureCollection, Polygon } from "@turf/helpers";
|
||||
import { FeatureCollection, Polygon } from "geojson";
|
||||
|
||||
/**
|
||||
* http://turfjs.org/docs.html#dissolve
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { Feature, FeatureCollection, Point } from "geojson";
|
||||
import centroid from "@turf/centroid";
|
||||
import { Feature, FeatureCollection, Point } from "@turf/helpers";
|
||||
import { getCoord } from "@turf/invariant";
|
||||
import { featureEach } from "@turf/meta";
|
||||
|
||||
|
||||
@ -1,11 +1,6 @@
|
||||
import { Point } from "geojson";
|
||||
import { getCoord } from "@turf/invariant";
|
||||
import {
|
||||
radiansToLength,
|
||||
degreesToRadians,
|
||||
Coord,
|
||||
Units,
|
||||
Point,
|
||||
} from "@turf/helpers";
|
||||
import { radiansToLength, degreesToRadians, Coord, Units } from "@turf/helpers";
|
||||
|
||||
//http://en.wikipedia.org/wiki/Haversine_formula
|
||||
//http://www.movable-type.co.uk/scripts/latlong.html
|
||||
|
||||
5
packages/turf-ellipse/index.d.ts
vendored
5
packages/turf-ellipse/index.d.ts
vendored
@ -1,4 +1,5 @@
|
||||
import { Feature, Coord, Polygon, Units, Properties } from "@turf/helpers";
|
||||
import { Feature, Polygon, GeoJsonProperties } from "geojson";
|
||||
import { Coord, Units } from "@turf/helpers";
|
||||
|
||||
/**
|
||||
* http://turfjs.org/docs/#ellipse
|
||||
@ -12,7 +13,7 @@ export default function (
|
||||
steps?: number;
|
||||
/** default kilometers */
|
||||
units?: Units;
|
||||
properties?: Properties;
|
||||
properties?: GeoJsonProperties;
|
||||
/**
|
||||
* Angle of rotation in decimal degrees, positive clockwise
|
||||
* default 0
|
||||
|
||||
3
packages/turf-envelope/index.d.ts
vendored
3
packages/turf-envelope/index.d.ts
vendored
@ -1,4 +1,5 @@
|
||||
import { Feature, AllGeoJSON, Polygon } from "@turf/helpers";
|
||||
import { Feature, Polygon } from "geojson";
|
||||
import { AllGeoJSON } from "@turf/helpers";
|
||||
|
||||
/**
|
||||
* http://turfjs.org/docs/#envelope
|
||||
|
||||
3
packages/turf-explode/index.d.ts
vendored
3
packages/turf-explode/index.d.ts
vendored
@ -1,4 +1,5 @@
|
||||
import { AllGeoJSON, FeatureCollection, Point } from "@turf/helpers";
|
||||
import { FeatureCollection, Point } from "geojson";
|
||||
import { AllGeoJSON } from "@turf/helpers";
|
||||
|
||||
/**
|
||||
* http://turfjs.org/docs/#explode
|
||||
|
||||
4
packages/turf-flatten/index.d.ts
vendored
4
packages/turf-flatten/index.d.ts
vendored
@ -7,8 +7,8 @@ import {
|
||||
MultiPolygon,
|
||||
Feature,
|
||||
FeatureCollection,
|
||||
AllGeoJSON,
|
||||
} from "@turf/helpers";
|
||||
} from "geojson";
|
||||
import { AllGeoJSON } from "@turf/helpers";
|
||||
|
||||
/**
|
||||
* http://turfjs.org/docs/#flatten
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
import { FeatureCollection, Point, LineString } from "geojson";
|
||||
import {
|
||||
multiPoint,
|
||||
multiLineString,
|
||||
geometryCollection,
|
||||
// Typescript types
|
||||
FeatureCollection,
|
||||
Point,
|
||||
LineString,
|
||||
} from "@turf/helpers";
|
||||
import flatten from "./";
|
||||
|
||||
|
||||
8
packages/turf-great-circle/index.d.ts
vendored
8
packages/turf-great-circle/index.d.ts
vendored
@ -2,9 +2,9 @@ import {
|
||||
LineString,
|
||||
MultiLineString,
|
||||
Feature,
|
||||
Coord,
|
||||
Properties,
|
||||
} from "@turf/helpers";
|
||||
GeoJsonProperties,
|
||||
} from "geojson";
|
||||
import { Coord } from "@turf/helpers";
|
||||
|
||||
/**
|
||||
* http://turfjs.org/docs/#greatcircle
|
||||
@ -13,7 +13,7 @@ export default function greatCircle(
|
||||
start: Coord,
|
||||
end: Coord,
|
||||
options?: {
|
||||
properties?: Properties;
|
||||
properties?: GeoJsonProperties;
|
||||
npoints?: number;
|
||||
offset?: number;
|
||||
}
|
||||
|
||||
@ -1,15 +1,10 @@
|
||||
import {
|
||||
BBox,
|
||||
CollectionTypes,
|
||||
Feature,
|
||||
FeatureCollection,
|
||||
GeoJSONObject,
|
||||
Geometries,
|
||||
Geometry,
|
||||
GeometryCollection,
|
||||
GeometryObject,
|
||||
GeometryTypes,
|
||||
Id,
|
||||
LineString,
|
||||
MultiLineString,
|
||||
MultiPoint,
|
||||
@ -17,31 +12,11 @@ import {
|
||||
Point,
|
||||
Polygon,
|
||||
Position,
|
||||
Properties,
|
||||
Types,
|
||||
} from "./lib/geojson";
|
||||
export {
|
||||
Id,
|
||||
Properties,
|
||||
BBox,
|
||||
Position,
|
||||
Point,
|
||||
LineString,
|
||||
Polygon,
|
||||
MultiPoint,
|
||||
MultiLineString,
|
||||
MultiPolygon,
|
||||
GeometryObject,
|
||||
GeoJSONObject,
|
||||
GeometryCollection,
|
||||
Geometry,
|
||||
GeometryTypes,
|
||||
Types,
|
||||
CollectionTypes,
|
||||
Geometries,
|
||||
Feature,
|
||||
FeatureCollection,
|
||||
};
|
||||
GeoJsonProperties,
|
||||
} from "geojson";
|
||||
|
||||
import { Id } from "./lib/geojson";
|
||||
export * from "./lib/geojson";
|
||||
|
||||
// TurfJS Combined Types
|
||||
export type Coord = Feature<Point> | Point | Position;
|
||||
@ -157,7 +132,10 @@ export const areaFactors: { [key: string]: number } = {
|
||||
*
|
||||
* //=feature
|
||||
*/
|
||||
export function feature<G = Geometry, P = Properties>(
|
||||
export function feature<
|
||||
G extends GeometryObject = Geometry,
|
||||
P = GeoJsonProperties
|
||||
>(
|
||||
geom: G,
|
||||
properties?: P,
|
||||
options: { bbox?: BBox; id?: Id } = {}
|
||||
@ -233,7 +211,7 @@ export function geometry(
|
||||
*
|
||||
* //=point
|
||||
*/
|
||||
export function point<P = Properties>(
|
||||
export function point<P = GeoJsonProperties>(
|
||||
coordinates: Position,
|
||||
properties?: P,
|
||||
options: { bbox?: BBox; id?: Id } = {}
|
||||
@ -278,7 +256,7 @@ export function point<P = Properties>(
|
||||
*
|
||||
* //=points
|
||||
*/
|
||||
export function points<P = Properties>(
|
||||
export function points<P = GeoJsonProperties>(
|
||||
coordinates: Position[],
|
||||
properties?: P,
|
||||
options: { bbox?: BBox; id?: Id } = {}
|
||||
@ -306,7 +284,7 @@ export function points<P = Properties>(
|
||||
*
|
||||
* //=polygon
|
||||
*/
|
||||
export function polygon<P = Properties>(
|
||||
export function polygon<P = GeoJsonProperties>(
|
||||
coordinates: Position[][],
|
||||
properties?: P,
|
||||
options: { bbox?: BBox; id?: Id } = {}
|
||||
@ -354,7 +332,7 @@ export function polygon<P = Properties>(
|
||||
*
|
||||
* //=polygons
|
||||
*/
|
||||
export function polygons<P = Properties>(
|
||||
export function polygons<P = GeoJsonProperties>(
|
||||
coordinates: Position[][][],
|
||||
properties?: P,
|
||||
options: { bbox?: BBox; id?: Id } = {}
|
||||
@ -384,7 +362,7 @@ export function polygons<P = Properties>(
|
||||
* //=linestring1
|
||||
* //=linestring2
|
||||
*/
|
||||
export function lineString<P = Properties>(
|
||||
export function lineString<P = GeoJsonProperties>(
|
||||
coordinates: Position[],
|
||||
properties?: P,
|
||||
options: { bbox?: BBox; id?: Id } = {}
|
||||
@ -418,7 +396,7 @@ export function lineString<P = Properties>(
|
||||
*
|
||||
* //=linestrings
|
||||
*/
|
||||
export function lineStrings<P = Properties>(
|
||||
export function lineStrings<P = GeoJsonProperties>(
|
||||
coordinates: Position[][],
|
||||
properties?: P,
|
||||
options: { bbox?: BBox; id?: Id } = {}
|
||||
@ -453,7 +431,10 @@ export function lineStrings<P = Properties>(
|
||||
*
|
||||
* //=collection
|
||||
*/
|
||||
export function featureCollection<G = Geometry, P = Properties>(
|
||||
export function featureCollection<
|
||||
G extends GeometryObject = Geometry,
|
||||
P = GeoJsonProperties
|
||||
>(
|
||||
features: Array<Feature<G, P>>,
|
||||
options: { bbox?: BBox; id?: Id } = {}
|
||||
): FeatureCollection<G, P> {
|
||||
@ -485,7 +466,7 @@ export function featureCollection<G = Geometry, P = Properties>(
|
||||
*
|
||||
* //=multiLine
|
||||
*/
|
||||
export function multiLineString<P = Properties>(
|
||||
export function multiLineString<P = GeoJsonProperties>(
|
||||
coordinates: Position[][],
|
||||
properties?: P,
|
||||
options: { bbox?: BBox; id?: Id } = {}
|
||||
@ -514,7 +495,7 @@ export function multiLineString<P = Properties>(
|
||||
*
|
||||
* //=multiPt
|
||||
*/
|
||||
export function multiPoint<P = Properties>(
|
||||
export function multiPoint<P = GeoJsonProperties>(
|
||||
coordinates: Position[],
|
||||
properties?: P,
|
||||
options: { bbox?: BBox; id?: Id } = {}
|
||||
@ -544,7 +525,7 @@ export function multiPoint<P = Properties>(
|
||||
* //=multiPoly
|
||||
*
|
||||
*/
|
||||
export function multiPolygon<P = Properties>(
|
||||
export function multiPolygon<P = GeoJsonProperties>(
|
||||
coordinates: Position[][][],
|
||||
properties?: P,
|
||||
options: { bbox?: BBox; id?: Id } = {}
|
||||
@ -574,7 +555,7 @@ export function multiPolygon<P = Properties>(
|
||||
*
|
||||
* // => collection
|
||||
*/
|
||||
export function geometryCollection<P = Properties>(
|
||||
export function geometryCollection<P = GeoJsonProperties>(
|
||||
geometries: Array<
|
||||
Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon
|
||||
>,
|
||||
|
||||
@ -1,245 +1,10 @@
|
||||
// Type definitions for geojson 7946.0
|
||||
// Project: https://geojson.org/
|
||||
// Definitions by: Jacob Bruun <https://github.com/cobster>
|
||||
// Arne Schubert <https://github.com/atd-schubert>
|
||||
// Jeff Jacobson <https://github.com/JeffJacobson>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
// Note: as of the RFC 7946 version of GeoJSON, Coordinate Reference Systems
|
||||
// are no longer supported. (See https://tools.ietf.org/html/rfc7946#appendix-B)}
|
||||
|
||||
// export as namespace GeoJSON;
|
||||
|
||||
/**
|
||||
* GeometryTypes
|
||||
*
|
||||
* https://tools.ietf.org/html/rfc7946#section-1.4
|
||||
* The valid values for the "type" property of GeoJSON geometry objects.
|
||||
*/
|
||||
export type GeometryTypes =
|
||||
| "Point"
|
||||
| "LineString"
|
||||
| "Polygon"
|
||||
| "MultiPoint"
|
||||
| "MultiLineString"
|
||||
| "MultiPolygon"
|
||||
| "GeometryCollection";
|
||||
|
||||
export type CollectionTypes = "FeatureCollection" | "GeometryCollection";
|
||||
|
||||
/**
|
||||
* Types
|
||||
*
|
||||
* https://tools.ietf.org/html/rfc7946#section-1.4
|
||||
* The value values for the "type" property of GeoJSON Objects.
|
||||
*/
|
||||
export type Types = "Feature" | GeometryTypes | CollectionTypes;
|
||||
|
||||
/**
|
||||
* Bounding box
|
||||
*
|
||||
* https://tools.ietf.org/html/rfc7946#section-5
|
||||
* A GeoJSON object MAY have a member named "bbox" to include information on the coordinate range for its Geometries, Features, or FeatureCollections.
|
||||
* The value of the bbox member MUST be an array of length 2*n where n is the number of dimensions represented in the contained geometries,
|
||||
* with all axes of the most southwesterly point followed by all axes of the more northeasterly point.
|
||||
* The axes order of a bbox follows the axes order of geometries.
|
||||
*/
|
||||
export type BBox2d = [number, number, number, number];
|
||||
export type BBox3d = [number, number, number, number, number, number];
|
||||
export type BBox = BBox2d | BBox3d;
|
||||
|
||||
/**
|
||||
* Id
|
||||
*
|
||||
* https://tools.ietf.org/html/rfc7946#section-3.2
|
||||
* If a Feature has a commonly used identifier, that identifier SHOULD be included as a member of
|
||||
* the Feature object with the name "id", and the value of this member is either a JSON string or number.
|
||||
*
|
||||
* Should be contributed to @types/geojson
|
||||
*/
|
||||
export type Id = string | number;
|
||||
|
||||
/**
|
||||
* Position
|
||||
*
|
||||
* https://tools.ietf.org/html/rfc7946#section-3.1.1
|
||||
* Array should contain between two and three elements.
|
||||
* The previous GeoJSON specification allowed more elements (e.g., which could be used to represent M values),
|
||||
* but the current specification only allows X, Y, and (optionally) Z to be defined.
|
||||
*/
|
||||
export type Position = number[]; // [number, number] | [number, number, number];
|
||||
|
||||
/**
|
||||
* Properties
|
||||
*
|
||||
* https://tools.ietf.org/html/rfc7946#section-3.2
|
||||
* A Feature object has a member with the name "properties".
|
||||
* The value of the properties member is an object (any JSON object or a JSON null value).
|
||||
*/
|
||||
export type Properties = { [name: string]: any } | null;
|
||||
|
||||
/**
|
||||
* Geometries
|
||||
*/
|
||||
export type Geometries =
|
||||
| Point
|
||||
| LineString
|
||||
| Polygon
|
||||
| MultiPoint
|
||||
| MultiLineString
|
||||
| MultiPolygon;
|
||||
|
||||
/**
|
||||
* GeoJSON Object
|
||||
*
|
||||
* https://tools.ietf.org/html/rfc7946#section-3
|
||||
* The GeoJSON specification also allows [foreign members](https://tools.ietf.org/html/rfc7946#section-6.1)
|
||||
* Developers should use "&" type in TypeScript or extend the interface to add these foreign members.
|
||||
*/
|
||||
export interface GeoJSONObject {
|
||||
// Don't include foreign members directly into this type def.
|
||||
// in order to preserve type safety.
|
||||
// [key: string]: any;
|
||||
/**
|
||||
* Specifies the type of GeoJSON object.
|
||||
*/
|
||||
type: string;
|
||||
/**
|
||||
* Bounding box of the coordinate range of the object's Geometries, Features, or Feature Collections.
|
||||
* https://tools.ietf.org/html/rfc7946#section-5
|
||||
*/
|
||||
bbox?: BBox;
|
||||
}
|
||||
|
||||
/**
|
||||
* Geometry Object
|
||||
*
|
||||
* https://tools.ietf.org/html/rfc7946#section-3
|
||||
*/
|
||||
export interface GeometryObject extends GeoJSONObject {
|
||||
type: GeometryTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Geometry
|
||||
*
|
||||
* https://tools.ietf.org/html/rfc7946#section-3
|
||||
*/
|
||||
export interface Geometry extends GeoJSONObject {
|
||||
coordinates: Position | Position[] | Position[][] | Position[][][];
|
||||
}
|
||||
|
||||
/**
|
||||
* Point Geometry Object
|
||||
*
|
||||
* https://tools.ietf.org/html/rfc7946#section-3.1.2
|
||||
*/
|
||||
export interface Point extends GeometryObject {
|
||||
type: "Point";
|
||||
coordinates: Position;
|
||||
}
|
||||
|
||||
/**
|
||||
* MultiPoint Geometry Object
|
||||
*
|
||||
* https://tools.ietf.org/html/rfc7946#section-3.1.3
|
||||
*/
|
||||
export interface MultiPoint extends GeometryObject {
|
||||
type: "MultiPoint";
|
||||
coordinates: Position[];
|
||||
}
|
||||
|
||||
/**
|
||||
* LineString Geometry Object
|
||||
*
|
||||
* https://tools.ietf.org/html/rfc7946#section-3.1.4
|
||||
*/
|
||||
export interface LineString extends GeometryObject {
|
||||
type: "LineString";
|
||||
coordinates: Position[];
|
||||
}
|
||||
|
||||
/**
|
||||
* MultiLineString Geometry Object
|
||||
*
|
||||
* https://tools.ietf.org/html/rfc7946#section-3.1.5
|
||||
*/
|
||||
export interface MultiLineString extends GeometryObject {
|
||||
type: "MultiLineString";
|
||||
coordinates: Position[][];
|
||||
}
|
||||
|
||||
/**
|
||||
* Polygon Geometry Object
|
||||
*
|
||||
* https://tools.ietf.org/html/rfc7946#section-3.1.6
|
||||
*/
|
||||
export interface Polygon extends GeometryObject {
|
||||
type: "Polygon";
|
||||
coordinates: Position[][];
|
||||
}
|
||||
|
||||
/**
|
||||
* MultiPolygon Geometry Object
|
||||
*
|
||||
* https://tools.ietf.org/html/rfc7946#section-3.1.7
|
||||
*/
|
||||
export interface MultiPolygon extends GeometryObject {
|
||||
type: "MultiPolygon";
|
||||
coordinates: Position[][][];
|
||||
}
|
||||
|
||||
/**
|
||||
* GeometryCollection
|
||||
*
|
||||
* https://tools.ietf.org/html/rfc7946#section-3.1.8
|
||||
*
|
||||
* A GeoJSON object with type "GeometryCollection" is a Geometry object.
|
||||
* A GeometryCollection has a member with the name "geometries".
|
||||
* The value of "geometries" is an array. Each element of this array is a GeoJSON Geometry object.
|
||||
* It is possible for this array to be empty.
|
||||
*/
|
||||
export interface GeometryCollection extends GeometryObject {
|
||||
type: "GeometryCollection";
|
||||
geometries: Array<
|
||||
Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygon
|
||||
>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Feature
|
||||
*
|
||||
* https://tools.ietf.org/html/rfc7946#section-3.2
|
||||
* A Feature object represents a spatially bounded thing.
|
||||
* Every Feature object is a GeoJSON object no matter where it occurs in a GeoJSON text.
|
||||
*/
|
||||
export interface Feature<G = Geometry | GeometryCollection, P = Properties>
|
||||
extends GeoJSONObject {
|
||||
type: "Feature";
|
||||
geometry: G;
|
||||
/**
|
||||
* A value that uniquely identifies this feature in a
|
||||
* https://tools.ietf.org/html/rfc7946#section-3.2.
|
||||
*/
|
||||
id?: Id;
|
||||
/**
|
||||
* Properties associated with this feature.
|
||||
*/
|
||||
properties: P;
|
||||
}
|
||||
|
||||
/**
|
||||
* Feature Collection
|
||||
*
|
||||
* https://tools.ietf.org/html/rfc7946#section-3.3
|
||||
* A GeoJSON object with the type "FeatureCollection" is a FeatureCollection object.
|
||||
* A FeatureCollection object has a member with the name "features".
|
||||
* The value of "features" is a JSON array. Each element of the array is a Feature object as defined above.
|
||||
* It is possible for this array to be empty.
|
||||
*/
|
||||
export interface FeatureCollection<
|
||||
G = Geometry | GeometryCollection,
|
||||
P = Properties
|
||||
> extends GeoJSONObject {
|
||||
type: "FeatureCollection";
|
||||
features: Array<Feature<G, P>>;
|
||||
}
|
||||
|
||||
@ -1,23 +1,19 @@
|
||||
import { BBox, GeometryCollection, LineString, Polygon, Point } from "geojson";
|
||||
import {
|
||||
BBox,
|
||||
feature,
|
||||
featureCollection,
|
||||
geometry,
|
||||
geometryCollection,
|
||||
GeometryCollection,
|
||||
isNumber,
|
||||
isObject,
|
||||
lengthToDegrees,
|
||||
lengthToRadians,
|
||||
lineString,
|
||||
LineString,
|
||||
multiLineString,
|
||||
multiPoint,
|
||||
multiPolygon,
|
||||
// Typescript types
|
||||
point,
|
||||
Point,
|
||||
Polygon,
|
||||
polygon,
|
||||
radiansToLength,
|
||||
} from "./";
|
||||
@ -38,7 +34,7 @@ const poly = polygon([
|
||||
[0, 1],
|
||||
],
|
||||
]);
|
||||
const feat = feature({ coordinates: [1, 0], type: "point" });
|
||||
const feat = feature({ coordinates: [1, 0], type: "Point" });
|
||||
const multiPt = multiPoint([
|
||||
[0, 1],
|
||||
[2, 3],
|
||||
@ -81,7 +77,8 @@ polygon([
|
||||
[0, 1],
|
||||
],
|
||||
]);
|
||||
feature({ coordinates: [1, 0], type: "point" });
|
||||
feature({ coordinates: [1, 0], type: "Point" });
|
||||
feature(null);
|
||||
multiPoint([
|
||||
[0, 1],
|
||||
[2, 3],
|
||||
|
||||
@ -1,15 +1,13 @@
|
||||
import distance from "@turf/distance";
|
||||
import intersect from "@turf/intersect";
|
||||
import {
|
||||
polygon,
|
||||
featureCollection,
|
||||
Feature,
|
||||
FeatureCollection,
|
||||
Units,
|
||||
Properties,
|
||||
GeoJsonProperties,
|
||||
Polygon,
|
||||
BBox,
|
||||
} from "@turf/helpers";
|
||||
} from "geojson";
|
||||
import { polygon, featureCollection, Units } from "@turf/helpers";
|
||||
|
||||
/**
|
||||
* Takes a bounding box and the diameter of the cell and returns a {@link FeatureCollection} of flat-topped
|
||||
@ -36,7 +34,7 @@ import {
|
||||
* //addToMap
|
||||
* var addToMap = [hexgrid];
|
||||
*/
|
||||
function hexGrid<P = Properties>(
|
||||
function hexGrid<P = GeoJsonProperties>(
|
||||
bbox: BBox,
|
||||
cellSide: number,
|
||||
options: {
|
||||
@ -165,7 +163,7 @@ function hexagon(
|
||||
center: number[],
|
||||
rx: number,
|
||||
ry: number,
|
||||
properties: Properties,
|
||||
properties: GeoJsonProperties,
|
||||
cosines: number[],
|
||||
sines: number[]
|
||||
) {
|
||||
@ -196,7 +194,7 @@ function hexTriangles(
|
||||
center: number[],
|
||||
rx: number,
|
||||
ry: number,
|
||||
properties: Properties,
|
||||
properties: GeoJsonProperties,
|
||||
cosines: number[],
|
||||
sines: number[]
|
||||
) {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { BBox } from "@turf/helpers";
|
||||
import { BBox } from "geojson";
|
||||
import hexGrid from "./index";
|
||||
|
||||
const bbox: BBox = [
|
||||
|
||||
3
packages/turf-interpolate/index.d.ts
vendored
3
packages/turf-interpolate/index.d.ts
vendored
@ -1,4 +1,5 @@
|
||||
import { Point, Polygon, Units, FeatureCollection, Grid } from "@turf/helpers";
|
||||
import { Point, Polygon, FeatureCollection } from "geojson";
|
||||
import { Units, Grid } from "@turf/helpers";
|
||||
|
||||
/**
|
||||
* http://turfjs.org/docs/#interpolate
|
||||
|
||||
@ -1,11 +1,5 @@
|
||||
import {
|
||||
Feature,
|
||||
multiPolygon,
|
||||
MultiPolygon,
|
||||
polygon,
|
||||
Polygon,
|
||||
Properties,
|
||||
} from "@turf/helpers";
|
||||
import { Feature, GeoJsonProperties, MultiPolygon, Polygon } from "geojson";
|
||||
import { multiPolygon, polygon } from "@turf/helpers";
|
||||
import { getGeom } from "@turf/invariant";
|
||||
import polygonClipping from "polygon-clipping";
|
||||
|
||||
@ -45,7 +39,7 @@ import polygonClipping from "polygon-clipping";
|
||||
* //addToMap
|
||||
* var addToMap = [poly1, poly2, intersection];
|
||||
*/
|
||||
export default function intersect<P = Properties>(
|
||||
export default function intersect<P = GeoJsonProperties>(
|
||||
poly1: Feature<Polygon | MultiPolygon> | Polygon | MultiPolygon,
|
||||
poly2: Feature<Polygon | MultiPolygon> | Polygon | MultiPolygon,
|
||||
options: {
|
||||
|
||||
@ -1,11 +1,15 @@
|
||||
import {
|
||||
Feature,
|
||||
FeatureCollection,
|
||||
Geometries,
|
||||
GeometryCollection,
|
||||
isNumber,
|
||||
Geometry,
|
||||
LineString,
|
||||
MultiPoint,
|
||||
MultiLineString,
|
||||
MultiPolygon,
|
||||
Point,
|
||||
} from "@turf/helpers";
|
||||
Polygon,
|
||||
} from "geojson";
|
||||
import { isNumber } from "@turf/helpers";
|
||||
|
||||
/**
|
||||
* Unwrap a coordinate from a Point Feature, Geometry or a single coordinate.
|
||||
@ -60,9 +64,15 @@ export function getCoord(coord: Feature<Point> | Point | number[]): number[] {
|
||||
* var coords = turf.getCoords(poly);
|
||||
* //= [[[119.32, -8.7], [119.55, -8.69], [119.51, -8.54], [119.32, -8.7]]]
|
||||
*/
|
||||
export function getCoords<G extends Geometries>(
|
||||
coords: any[] | Feature<G> | G
|
||||
): any[] {
|
||||
export function getCoords<
|
||||
G extends
|
||||
| Point
|
||||
| LineString
|
||||
| Polygon
|
||||
| MultiPoint
|
||||
| MultiLineString
|
||||
| MultiPolygon
|
||||
>(coords: any[] | Feature<G> | G): any[] {
|
||||
if (Array.isArray(coords)) {
|
||||
return coords;
|
||||
}
|
||||
@ -233,9 +243,7 @@ export function collectionOf(
|
||||
* var geom = turf.getGeom(point)
|
||||
* //={"type": "Point", "coordinates": [110, 40]}
|
||||
*/
|
||||
export function getGeom<G extends Geometries | GeometryCollection>(
|
||||
geojson: Feature<G> | G
|
||||
): G {
|
||||
export function getGeom<G extends Geometry>(geojson: Feature<G> | G): G {
|
||||
if (geojson.type === "Feature") {
|
||||
return geojson.geometry;
|
||||
}
|
||||
@ -261,11 +269,7 @@ export function getGeom<G extends Geometries | GeometryCollection>(
|
||||
* //="Point"
|
||||
*/
|
||||
export function getType(
|
||||
geojson:
|
||||
| Feature<any>
|
||||
| FeatureCollection<any>
|
||||
| Geometries
|
||||
| GeometryCollection,
|
||||
geojson: Feature<any> | FeatureCollection<any> | Geometry,
|
||||
_name?: string
|
||||
): string {
|
||||
if (geojson.type === "FeatureCollection") {
|
||||
|
||||
@ -5,7 +5,7 @@ import {
|
||||
Point,
|
||||
Polygon,
|
||||
Position,
|
||||
} from "@turf/helpers";
|
||||
} from "geojson";
|
||||
import * as invariant from "./index";
|
||||
|
||||
/**
|
||||
|
||||
8
packages/turf-isobands/index.d.ts
vendored
8
packages/turf-isobands/index.d.ts
vendored
@ -2,8 +2,8 @@ import {
|
||||
Point,
|
||||
MultiPolygon,
|
||||
FeatureCollection,
|
||||
Properties,
|
||||
} from "@turf/helpers";
|
||||
GeoJsonProperties,
|
||||
} from "geojson";
|
||||
|
||||
/**
|
||||
* http://turfjs.org/docs/#isobands
|
||||
@ -13,7 +13,7 @@ export default function isobands(
|
||||
breaks: number[],
|
||||
options?: {
|
||||
zProperty?: string;
|
||||
commonProperties?: Properties;
|
||||
breaksProperties?: Properties[];
|
||||
commonProperties?: GeoJsonProperties;
|
||||
breaksProperties?: GeoJsonProperties[];
|
||||
}
|
||||
): FeatureCollection<MultiPolygon>;
|
||||
|
||||
8
packages/turf-isolines/index.d.ts
vendored
8
packages/turf-isolines/index.d.ts
vendored
@ -2,8 +2,8 @@ import {
|
||||
Point,
|
||||
MultiLineString,
|
||||
FeatureCollection,
|
||||
Properties,
|
||||
} from "@turf/helpers";
|
||||
GeoJsonProperties,
|
||||
} from "geojson";
|
||||
|
||||
/**
|
||||
* http://turfjs.org/docs/#isolines
|
||||
@ -13,7 +13,7 @@ export default function isolines(
|
||||
breaks: number[],
|
||||
options?: {
|
||||
zProperty?: string;
|
||||
commonProperties?: Properties;
|
||||
breaksProperties?: Properties[];
|
||||
commonProperties?: GeoJsonProperties;
|
||||
breaksProperties?: GeoJsonProperties[];
|
||||
}
|
||||
): FeatureCollection<MultiLineString>;
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { point } from "@turf/helpers";
|
||||
import {
|
||||
Feature,
|
||||
FeatureCollection,
|
||||
@ -7,7 +6,8 @@ import {
|
||||
MultiPolygon,
|
||||
Point,
|
||||
Polygon,
|
||||
} from "@turf/helpers";
|
||||
} from "geojson";
|
||||
import { point } from "@turf/helpers";
|
||||
|
||||
/**
|
||||
* Takes a {@link LineString|linestring}, {@link MultiLineString|multi-linestring},
|
||||
|
||||
@ -1,10 +1,6 @@
|
||||
import { Feature, FeatureCollection, GeometryCollection } from "geojson";
|
||||
import distance from "@turf/distance";
|
||||
import {
|
||||
Feature,
|
||||
FeatureCollection,
|
||||
GeometryCollection,
|
||||
Units,
|
||||
} from "@turf/helpers";
|
||||
import { Units } from "@turf/helpers";
|
||||
import { segmentReduce } from "@turf/meta";
|
||||
|
||||
/**
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { Feature, LineString } from "geojson";
|
||||
import circle from "@turf/circle";
|
||||
import destination from "@turf/destination";
|
||||
import { Coord, Feature, lineString, LineString, Units } from "@turf/helpers";
|
||||
import { Coord, lineString, Units } from "@turf/helpers";
|
||||
|
||||
/**
|
||||
* Creates a circular arc, of a circle of the given radius and center point, between bearing1 and bearing2;
|
||||
|
||||
4
packages/turf-line-chunk/index.d.ts
vendored
4
packages/turf-line-chunk/index.d.ts
vendored
@ -2,10 +2,10 @@ import {
|
||||
LineString,
|
||||
MultiLineString,
|
||||
GeometryCollection,
|
||||
Units,
|
||||
Feature,
|
||||
FeatureCollection,
|
||||
} from "@turf/helpers";
|
||||
} from "geojson";
|
||||
import { Units } from "@turf/helpers";
|
||||
|
||||
/**
|
||||
* http://turfjs.org/docs/#lineChunk
|
||||
|
||||
@ -1,19 +1,17 @@
|
||||
import {
|
||||
feature,
|
||||
Feature,
|
||||
featureCollection,
|
||||
FeatureCollection,
|
||||
LineString,
|
||||
MultiLineString,
|
||||
MultiPolygon,
|
||||
point,
|
||||
Point,
|
||||
Polygon,
|
||||
} from "@turf/helpers";
|
||||
} from "geojson";
|
||||
import { feature, featureCollection, point } from "@turf/helpers";
|
||||
import { getCoords } from "@turf/invariant";
|
||||
import lineSegment from "@turf/line-segment";
|
||||
import { featureEach } from "@turf/meta";
|
||||
import rbush from "geojson-rbush";
|
||||
import rbush from "@turf/geojson-rbush";
|
||||
|
||||
/**
|
||||
* Takes any LineString or Polygon GeoJSON and returns the intersecting point(s).
|
||||
|
||||
@ -63,11 +63,11 @@
|
||||
"write-json-file": "*"
|
||||
},
|
||||
"dependencies": {
|
||||
"@turf/geojson-rbush": "^3.2.0",
|
||||
"@turf/helpers": "^6.5.0",
|
||||
"@turf/invariant": "^6.5.0",
|
||||
"@turf/line-segment": "^6.5.0",
|
||||
"@turf/meta": "^6.5.0",
|
||||
"geojson-rbush": "3.x",
|
||||
"tslib": "^2.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
3
packages/turf-line-offset/index.d.ts
vendored
3
packages/turf-line-offset/index.d.ts
vendored
@ -1,4 +1,5 @@
|
||||
import { Units, Feature, LineString, MultiLineString } from "@turf/helpers";
|
||||
import { Feature, LineString, MultiLineString } from "geojson";
|
||||
import { Units } from "@turf/helpers";
|
||||
|
||||
/**
|
||||
* http://turfjs.org/docs/#lineoffset
|
||||
|
||||
@ -1,20 +1,19 @@
|
||||
import rbush from "geojson-rbush";
|
||||
import rbush from "@turf/geojson-rbush";
|
||||
import lineSegment from "@turf/line-segment";
|
||||
import nearestPointOnLine from "@turf/nearest-point-on-line";
|
||||
import booleanPointOnLine from "@turf/boolean-point-on-line";
|
||||
import { getCoords } from "@turf/invariant";
|
||||
import { featureEach, segmentEach } from "@turf/meta";
|
||||
import {
|
||||
featureCollection,
|
||||
isObject,
|
||||
FeatureCollection,
|
||||
Feature,
|
||||
LineString,
|
||||
MultiLineString,
|
||||
Polygon,
|
||||
MultiPolygon,
|
||||
Properties,
|
||||
} from "@turf/helpers";
|
||||
GeoJsonProperties,
|
||||
} from "geojson";
|
||||
import { featureCollection, isObject } from "@turf/helpers";
|
||||
import equal from "deep-equal";
|
||||
|
||||
/**
|
||||
@ -49,10 +48,10 @@ function lineOverlap<
|
||||
var tolerance = options.tolerance || 0;
|
||||
|
||||
// Containers
|
||||
var features: Feature<LineString, Properties>[] = [];
|
||||
var features: Feature<LineString, GeoJsonProperties>[] = [];
|
||||
|
||||
// Create Spatial Index
|
||||
var tree = rbush();
|
||||
var tree = rbush<LineString>();
|
||||
|
||||
// To-Do -- HACK way to support typescript
|
||||
const line: any = lineSegment(line1);
|
||||
|
||||
@ -64,13 +64,13 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@turf/boolean-point-on-line": "^6.5.0",
|
||||
"@turf/geojson-rbush": "^3.2.0",
|
||||
"@turf/helpers": "^6.5.0",
|
||||
"@turf/invariant": "^6.5.0",
|
||||
"@turf/line-segment": "^6.5.0",
|
||||
"@turf/meta": "^6.5.0",
|
||||
"@turf/nearest-point-on-line": "^6.5.0",
|
||||
"deep-equal": "1.x",
|
||||
"geojson-rbush": "3.x",
|
||||
"tslib": "^2.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,14 +1,13 @@
|
||||
import {
|
||||
BBox,
|
||||
Feature,
|
||||
featureCollection,
|
||||
FeatureCollection,
|
||||
lineString,
|
||||
LineString,
|
||||
MultiLineString,
|
||||
MultiPolygon,
|
||||
Polygon,
|
||||
} from "@turf/helpers";
|
||||
} from "geojson";
|
||||
import { featureCollection, lineString } from "@turf/helpers";
|
||||
import { getCoords } from "@turf/invariant";
|
||||
import { flattenEach } from "@turf/meta";
|
||||
|
||||
|
||||
3
packages/turf-line-slice-along/index.d.ts
vendored
3
packages/turf-line-slice-along/index.d.ts
vendored
@ -1,4 +1,5 @@
|
||||
import { Units, LineString, Feature } from "@turf/helpers";
|
||||
import { LineString, Feature } from "geojson";
|
||||
import { Units } from "@turf/helpers";
|
||||
|
||||
/**
|
||||
* http://turfjs.org/docs/
|
||||
|
||||
3
packages/turf-line-slice/index.d.ts
vendored
3
packages/turf-line-slice/index.d.ts
vendored
@ -1,4 +1,5 @@
|
||||
import { Feature, LineString, Coord } from "@turf/helpers";
|
||||
import { Feature, LineString } from "geojson";
|
||||
import { Coord } from "@turf/helpers";
|
||||
|
||||
/**
|
||||
* http://turfjs.org/docs/#lineslice
|
||||
|
||||
2
packages/turf-line-split/index.d.ts
vendored
2
packages/turf-line-split/index.d.ts
vendored
@ -7,7 +7,7 @@ import {
|
||||
MultiLineString,
|
||||
Polygon,
|
||||
MultiPolygon,
|
||||
} from "@turf/helpers";
|
||||
} from "geojson";
|
||||
|
||||
export type Splitter = Feature<
|
||||
Point | MultiPoint | LineString | MultiLineString | Polygon | MultiPolygon
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import rbush from "geojson-rbush";
|
||||
import rbush from "@turf/geojson-rbush";
|
||||
import square from "@turf/square";
|
||||
import bbox from "@turf/bbox";
|
||||
import truncate from "@turf/truncate";
|
||||
|
||||
@ -58,6 +58,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@turf/bbox": "^6.5.0",
|
||||
"@turf/geojson-rbush": "^3.2.0",
|
||||
"@turf/helpers": "^6.5.0",
|
||||
"@turf/invariant": "^6.5.0",
|
||||
"@turf/line-intersect": "^6.5.0",
|
||||
@ -65,7 +66,6 @@
|
||||
"@turf/meta": "^6.5.0",
|
||||
"@turf/nearest-point-on-line": "^6.5.0",
|
||||
"@turf/square": "^6.5.0",
|
||||
"@turf/truncate": "^6.5.0",
|
||||
"geojson-rbush": "3.x"
|
||||
"@turf/truncate": "^6.5.0"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,17 +1,15 @@
|
||||
import turfBBox from "@turf/bbox";
|
||||
import { getCoords, getGeom } from "@turf/invariant";
|
||||
import {
|
||||
polygon,
|
||||
multiPolygon,
|
||||
lineString,
|
||||
Feature,
|
||||
FeatureCollection,
|
||||
MultiLineString,
|
||||
LineString,
|
||||
Properties,
|
||||
GeoJsonProperties,
|
||||
BBox,
|
||||
Position,
|
||||
} from "@turf/helpers";
|
||||
} from "geojson";
|
||||
import turfBBox from "@turf/bbox";
|
||||
import { getCoords, getGeom } from "@turf/invariant";
|
||||
import { polygon, multiPolygon, lineString } from "@turf/helpers";
|
||||
import clone from "@turf/clone";
|
||||
|
||||
/**
|
||||
@ -36,7 +34,7 @@ import clone from "@turf/clone";
|
||||
function lineToPolygon<G extends LineString | MultiLineString>(
|
||||
lines: Feature<G> | FeatureCollection<G> | G,
|
||||
options: {
|
||||
properties?: Properties;
|
||||
properties?: GeoJsonProperties;
|
||||
autoComplete?: boolean;
|
||||
orderCoords?: boolean;
|
||||
mutate?: boolean;
|
||||
@ -78,7 +76,7 @@ function lineToPolygon<G extends LineString | MultiLineString>(
|
||||
*/
|
||||
function lineStringToPolygon<G extends LineString | MultiLineString>(
|
||||
line: Feature<G> | G,
|
||||
properties: Properties | undefined,
|
||||
properties: GeoJsonProperties | undefined,
|
||||
autoComplete: boolean,
|
||||
orderCoords: boolean
|
||||
) {
|
||||
|
||||
@ -1,10 +1,5 @@
|
||||
import {
|
||||
featureCollection,
|
||||
lineString,
|
||||
multiLineString,
|
||||
LineString,
|
||||
MultiLineString,
|
||||
} from "@turf/helpers";
|
||||
import { LineString, MultiLineString } from "geojson";
|
||||
import { featureCollection, lineString, multiLineString } from "@turf/helpers";
|
||||
import lineToPolygon from "./index";
|
||||
|
||||
// Fixtures
|
||||
|
||||
7
packages/turf-mask/index.d.ts
vendored
7
packages/turf-mask/index.d.ts
vendored
@ -1,9 +1,4 @@
|
||||
import {
|
||||
Feature,
|
||||
Polygon,
|
||||
MultiPolygon,
|
||||
FeatureCollection,
|
||||
} from "@turf/helpers";
|
||||
import { Feature, Polygon, MultiPolygon, FeatureCollection } from "geojson";
|
||||
|
||||
/**
|
||||
* http://turfjs.org/docs/#mask
|
||||
|
||||
56
packages/turf-meta/index.d.ts
vendored
56
packages/turf-meta/index.d.ts
vendored
@ -6,15 +6,13 @@ import {
|
||||
MultiPolygon,
|
||||
FeatureCollection,
|
||||
Feature,
|
||||
Geometry,
|
||||
GeometryObject,
|
||||
GeometryCollection,
|
||||
AllGeoJSON,
|
||||
Properties,
|
||||
Geometries,
|
||||
Lines,
|
||||
GeoJsonProperties,
|
||||
BBox,
|
||||
Id,
|
||||
} from "@turf/helpers";
|
||||
} from "geojson";
|
||||
import { AllGeoJSON, Lines, Id } from "@turf/helpers";
|
||||
|
||||
/**
|
||||
* http://turfjs.org/docs/#coordreduce
|
||||
@ -50,7 +48,7 @@ export function coordEach(
|
||||
/**
|
||||
* http://turfjs.org/docs/#propeach
|
||||
*/
|
||||
export function propEach<Props extends Properties>(
|
||||
export function propEach<Props extends GeoJsonProperties>(
|
||||
geojson: Feature<any> | FeatureCollection<any> | Feature<GeometryCollection>,
|
||||
callback: (currentProperties: Props, featureIndex: number) => void
|
||||
): void;
|
||||
@ -58,12 +56,8 @@ export function propEach<Props extends Properties>(
|
||||
/**
|
||||
* http://turfjs.org/docs/#propreduce
|
||||
*/
|
||||
export function propReduce<Reducer extends any, P = Properties>(
|
||||
geojson:
|
||||
| Feature<any, P>
|
||||
| FeatureCollection<any, P>
|
||||
| Geometries
|
||||
| GeometryCollection,
|
||||
export function propReduce<Reducer extends any, P = GeoJsonProperties>(
|
||||
geojson: Feature<any, P> | FeatureCollection<any, P> | Geometry,
|
||||
callback: (
|
||||
previousValue: Reducer,
|
||||
currentProperties: P,
|
||||
@ -77,8 +71,8 @@ export function propReduce<Reducer extends any, P = Properties>(
|
||||
*/
|
||||
export function featureReduce<
|
||||
Reducer extends any,
|
||||
G extends Geometries,
|
||||
P = Properties
|
||||
G extends GeometryObject,
|
||||
P = GeoJsonProperties
|
||||
>(
|
||||
geojson:
|
||||
| Feature<G, P>
|
||||
@ -95,7 +89,7 @@ export function featureReduce<
|
||||
/**
|
||||
* http://turfjs.org/docs/#featureeach
|
||||
*/
|
||||
export function featureEach<G extends any, P = Properties>(
|
||||
export function featureEach<G extends GeometryObject, P = GeoJsonProperties>(
|
||||
geojson:
|
||||
| Feature<G, P>
|
||||
| FeatureCollection<G, P>
|
||||
@ -113,8 +107,8 @@ export function coordAll(geojson: AllGeoJSON): number[][];
|
||||
*/
|
||||
export function geomReduce<
|
||||
Reducer extends any,
|
||||
G extends Geometries,
|
||||
P = Properties
|
||||
G extends GeometryObject,
|
||||
P = GeoJsonProperties
|
||||
>(
|
||||
geojson:
|
||||
| Feature<G, P>
|
||||
@ -136,7 +130,10 @@ export function geomReduce<
|
||||
/**
|
||||
* http://turfjs.org/docs/#geomeach
|
||||
*/
|
||||
export function geomEach<G extends Geometries | null, P = Properties>(
|
||||
export function geomEach<
|
||||
G extends GeometryObject | null,
|
||||
P = GeoJsonProperties
|
||||
>(
|
||||
geojson:
|
||||
| Feature<G, P>
|
||||
| FeatureCollection<G, P>
|
||||
@ -157,8 +154,8 @@ export function geomEach<G extends Geometries | null, P = Properties>(
|
||||
*/
|
||||
export function flattenReduce<
|
||||
Reducer extends any,
|
||||
G extends Geometries,
|
||||
P = Properties
|
||||
G extends GeometryObject,
|
||||
P = GeoJsonProperties
|
||||
>(
|
||||
geojson:
|
||||
| Feature<G, P>
|
||||
@ -178,7 +175,10 @@ export function flattenReduce<
|
||||
/**
|
||||
* http://turfjs.org/docs/#flatteneach
|
||||
*/
|
||||
export function flattenEach<G = Geometries, P = Properties>(
|
||||
export function flattenEach<
|
||||
G extends GeometryObject = GeometryObject,
|
||||
P = GeoJsonProperties
|
||||
>(
|
||||
geojson:
|
||||
| Feature<G, P>
|
||||
| FeatureCollection<G, P>
|
||||
@ -195,7 +195,7 @@ export function flattenEach<G = Geometries, P = Properties>(
|
||||
/**
|
||||
* http://turfjs.org/docs/#segmentreduce
|
||||
*/
|
||||
export function segmentReduce<Reducer extends any, P = Properties>(
|
||||
export function segmentReduce<Reducer extends any, P = GeoJsonProperties>(
|
||||
geojson:
|
||||
| FeatureCollection<Lines, P>
|
||||
| Feature<Lines, P>
|
||||
@ -216,7 +216,7 @@ export function segmentReduce<Reducer extends any, P = Properties>(
|
||||
/**
|
||||
* http://turfjs.org/docs/#segmenteach
|
||||
*/
|
||||
export function segmentEach<P = Properties>(
|
||||
export function segmentEach<P = GeoJsonProperties>(
|
||||
geojson: AllGeoJSON,
|
||||
callback: (
|
||||
currentSegment?: Feature<LineString, P>,
|
||||
@ -230,7 +230,7 @@ export function segmentEach<P = Properties>(
|
||||
/**
|
||||
* http://turfjs.org/docs/#linereduce
|
||||
*/
|
||||
export function lineReduce<Reducer extends any, P = Properties>(
|
||||
export function lineReduce<Reducer extends any, P = GeoJsonProperties>(
|
||||
geojson:
|
||||
| FeatureCollection<Lines, P>
|
||||
| Feature<Lines, P>
|
||||
@ -250,7 +250,7 @@ export function lineReduce<Reducer extends any, P = Properties>(
|
||||
/**
|
||||
* http://turfjs.org/docs/#lineeach
|
||||
*/
|
||||
export function lineEach<P = Properties>(
|
||||
export function lineEach<P = GeoJsonProperties>(
|
||||
geojson:
|
||||
| FeatureCollection<Lines, P>
|
||||
| Feature<Lines, P>
|
||||
@ -270,7 +270,7 @@ export function lineEach<P = Properties>(
|
||||
*/
|
||||
export function findSegment<
|
||||
G extends LineString | MultiLineString | Polygon | MultiPolygon,
|
||||
P = Properties
|
||||
P = GeoJsonProperties
|
||||
>(
|
||||
geojson: Feature<G, P> | FeatureCollection<G, P> | G,
|
||||
options?: {
|
||||
@ -287,7 +287,7 @@ export function findSegment<
|
||||
/**
|
||||
* http://turfjs.org/docs/#findpoint
|
||||
*/
|
||||
export function findPoint<G extends GeometryObject, P = Properties>(
|
||||
export function findPoint<G extends GeometryObject, P = GeoJsonProperties>(
|
||||
geojson: Feature<G, P> | FeatureCollection<G, P> | G,
|
||||
options?: {
|
||||
featureIndex?: number;
|
||||
|
||||
@ -1,11 +1,6 @@
|
||||
import { Point, LineString } from "geojson";
|
||||
import * as helpers from "@turf/helpers";
|
||||
import {
|
||||
featureCollection,
|
||||
point,
|
||||
lineString,
|
||||
Point,
|
||||
LineString,
|
||||
} from "@turf/helpers";
|
||||
import { featureCollection, point, lineString } from "@turf/helpers";
|
||||
import * as meta from "./";
|
||||
import {
|
||||
coordReduce,
|
||||
|
||||
3
packages/turf-midpoint/index.d.ts
vendored
3
packages/turf-midpoint/index.d.ts
vendored
@ -1,4 +1,5 @@
|
||||
import { Feature, Point, Coord } from "@turf/helpers";
|
||||
import { Feature, Point } from "geojson";
|
||||
import { Coord } from "@turf/helpers";
|
||||
|
||||
/**
|
||||
* http://turfjs.org/docs/#midpoint
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { FeatureCollection } from "geojson";
|
||||
import spatialWeight from "@turf/distance-weight";
|
||||
import { FeatureCollection } from "@turf/helpers";
|
||||
import { featureEach } from "@turf/meta";
|
||||
|
||||
/**
|
||||
|
||||
@ -1,3 +1,10 @@
|
||||
import {
|
||||
FeatureCollection,
|
||||
Feature,
|
||||
Point,
|
||||
Polygon,
|
||||
GeoJsonProperties,
|
||||
} from "geojson";
|
||||
import area from "@turf/area";
|
||||
import bbox from "@turf/bbox";
|
||||
import bboxPolygon from "@turf/bbox-polygon";
|
||||
@ -6,14 +13,7 @@ import distance from "@turf/distance";
|
||||
import nearestPoint from "@turf/nearest-point";
|
||||
import { featureEach } from "@turf/meta";
|
||||
import { convertArea, featureCollection } from "@turf/helpers";
|
||||
import {
|
||||
FeatureCollection,
|
||||
Feature,
|
||||
Point,
|
||||
Polygon,
|
||||
Units,
|
||||
Properties,
|
||||
} from "@turf/helpers";
|
||||
import { Units } from "@turf/helpers";
|
||||
|
||||
export interface NearestNeighborStatistics {
|
||||
units: Units;
|
||||
@ -87,7 +87,7 @@ function nearestNeighborAnalysis(
|
||||
options?: {
|
||||
studyArea?: Feature<Polygon>;
|
||||
units?: Units;
|
||||
properties?: Properties;
|
||||
properties?: GeoJsonProperties;
|
||||
}
|
||||
): NearestNeighborStudyArea {
|
||||
// Optional params
|
||||
|
||||
@ -1,18 +1,10 @@
|
||||
import { Feature, Point, LineString, MultiLineString } from "geojson";
|
||||
import bearing from "@turf/bearing";
|
||||
import distance from "@turf/distance";
|
||||
import destination from "@turf/destination";
|
||||
import lineIntersects from "@turf/line-intersect";
|
||||
import { flattenEach } from "@turf/meta";
|
||||
import {
|
||||
point,
|
||||
lineString,
|
||||
Feature,
|
||||
Point,
|
||||
LineString,
|
||||
MultiLineString,
|
||||
Coord,
|
||||
Units,
|
||||
} from "@turf/helpers";
|
||||
import { point, lineString, Coord, Units } from "@turf/helpers";
|
||||
import { getCoords } from "@turf/invariant";
|
||||
|
||||
export interface NearestPointOnLine extends Feature<Point> {
|
||||
|
||||
@ -4,9 +4,9 @@ import {
|
||||
GeometryCollection,
|
||||
LineString,
|
||||
Point,
|
||||
Properties,
|
||||
Units,
|
||||
} from "@turf/helpers";
|
||||
GeoJsonProperties,
|
||||
} from "geojson";
|
||||
import { Units } from "@turf/helpers";
|
||||
import { getType } from "@turf/invariant";
|
||||
import { featureEach, geomEach } from "@turf/meta";
|
||||
import pointToLineDistance from "@turf/point-to-line-distance";
|
||||
@ -43,7 +43,7 @@ function nearestPointToLine<P = { dist: number; [key: string]: any }>(
|
||||
line: Feature<LineString> | LineString,
|
||||
options: {
|
||||
units?: Units;
|
||||
properties?: Properties;
|
||||
properties?: GeoJsonProperties;
|
||||
} = {}
|
||||
): Feature<Point, P> {
|
||||
const units = options.units;
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { Feature, FeatureCollection, Point } from "geojson";
|
||||
import { Coord } from "@turf/helpers";
|
||||
import clone from "@turf/clone";
|
||||
import distance from "@turf/distance";
|
||||
import { featureEach } from "@turf/meta";
|
||||
import { Coord, Feature, FeatureCollection, Point } from "@turf/helpers";
|
||||
|
||||
export interface NearestPoint extends Feature<Point> {
|
||||
properties: {
|
||||
|
||||
3
packages/turf-planepoint/index.d.ts
vendored
3
packages/turf-planepoint/index.d.ts
vendored
@ -1,4 +1,5 @@
|
||||
import { Feature, Coord, Polygon } from "@turf/helpers";
|
||||
import { Feature, Polygon } from "geojson";
|
||||
import { Coord } from "@turf/helpers";
|
||||
|
||||
/**
|
||||
* http://turfjs.org/docs/#planepoint
|
||||
|
||||
@ -1,17 +1,15 @@
|
||||
import within from "@turf/boolean-within";
|
||||
import distance from "@turf/distance";
|
||||
import {
|
||||
point,
|
||||
featureCollection,
|
||||
BBox,
|
||||
Feature,
|
||||
Polygon,
|
||||
MultiPolygon,
|
||||
FeatureCollection,
|
||||
Point,
|
||||
Properties,
|
||||
Units,
|
||||
} from "@turf/helpers";
|
||||
GeoJsonProperties,
|
||||
} from "geojson";
|
||||
import within from "@turf/boolean-within";
|
||||
import distance from "@turf/distance";
|
||||
import { point, featureCollection, Units } from "@turf/helpers";
|
||||
|
||||
/**
|
||||
* Creates a {@link Point} grid from a bounding box, {@link FeatureCollection} or {@link Feature}.
|
||||
@ -34,7 +32,7 @@ import {
|
||||
* //addToMap
|
||||
* var addToMap = [grid];
|
||||
*/
|
||||
function pointGrid<P = Properties>(
|
||||
function pointGrid<P = GeoJsonProperties>(
|
||||
bbox: BBox,
|
||||
cellSide: number,
|
||||
options: {
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { BBox, polygon } from "@turf/helpers";
|
||||
import { BBox } from "geojson";
|
||||
import { polygon } from "@turf/helpers";
|
||||
import pointGrid from "./dist/js/index";
|
||||
|
||||
const cellSide = 50;
|
||||
|
||||
3
packages/turf-point-on-feature/index.d.ts
vendored
3
packages/turf-point-on-feature/index.d.ts
vendored
@ -1,4 +1,5 @@
|
||||
import { Feature, Point, AllGeoJSON } from "@turf/helpers";
|
||||
import { Feature, Point } from "geojson";
|
||||
import { AllGeoJSON } from "@turf/helpers";
|
||||
|
||||
/**
|
||||
* http://turfjs.org/docs/#pointonfeature
|
||||
|
||||
@ -1,12 +1,11 @@
|
||||
// Taken from http://geomalgorithms.com/a02-_lines.html
|
||||
import { Feature, LineString } from "geojson";
|
||||
import getDistance from "@turf/distance";
|
||||
import {
|
||||
convertLength,
|
||||
Coord,
|
||||
feature,
|
||||
Feature,
|
||||
lineString,
|
||||
LineString,
|
||||
point,
|
||||
Units,
|
||||
} from "@turf/helpers";
|
||||
|
||||
@ -5,8 +5,8 @@ import {
|
||||
MultiPolygon,
|
||||
MultiPoint,
|
||||
Point,
|
||||
Properties,
|
||||
} from "@turf/helpers";
|
||||
GeoJsonProperties,
|
||||
} from "geojson";
|
||||
|
||||
/**
|
||||
* http://turfjs.org/docs/#pointswithinpolygon
|
||||
@ -14,7 +14,7 @@ import {
|
||||
export default function pointsWithinPolygon<
|
||||
F extends Point | MultiPoint,
|
||||
G extends Polygon | MultiPolygon,
|
||||
P = Properties
|
||||
P = GeoJsonProperties
|
||||
>(
|
||||
points: Feature<F, P> | FeatureCollection<F, P>,
|
||||
polygons: Feature<G> | FeatureCollection<G> | G
|
||||
|
||||
@ -1,12 +1,6 @@
|
||||
import { Point, MultiPoint } from "geojson";
|
||||
import pointsWithinPolygon from "./";
|
||||
import {
|
||||
points,
|
||||
polygon,
|
||||
multiPoint,
|
||||
featureCollection,
|
||||
Point,
|
||||
MultiPoint,
|
||||
} from "@turf/helpers";
|
||||
import { points, polygon, multiPoint, featureCollection } from "@turf/helpers";
|
||||
|
||||
const pts = points([
|
||||
[-46.6318, -23.5523],
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user