Skip to content
Permalink
Browse files

Merge

  • Loading branch information
DenisCarriere committed Dec 5, 2017
1 parent ba0709b commit f7f0a751137c1fe41e9956f4efc803a34080fe8c
Showing with 653 additions and 343 deletions.
  1. +27 −0 OPEN_COLLECTIVE.md
  2. +1 −2 packages/turf-buffer/index.d.ts
  3. +3 −3 packages/turf-clone/types.ts
  4. +5 −4 packages/turf-destination/index.d.ts
  5. +5 −1 packages/turf-destination/index.js
  6. +69 −86 packages/turf-helpers/index.d.ts
  7. +238 −0 packages/turf-helpers/lib/geojson.d.ts
  8. +2 −1 packages/turf-helpers/package.json
  9. +17 −0 packages/turf-helpers/test.js
  10. +66 −64 packages/turf-helpers/types.ts
  11. +3 −3 packages/turf-hex-grid/index.d.ts
  12. +5 −6 packages/turf-invariant/index.d.ts
  13. +3 −2 packages/turf-invariant/types.ts
  14. +1 −2 packages/turf-line-chunk/index.d.ts
  15. +2 −3 packages/turf-line-segment/index.d.ts
  16. +1 −2 packages/turf-line-to-polygon/index.d.ts
  17. +37 −64 packages/turf-meta/index.d.ts
  18. +4 −34 packages/turf-meta/types.ts
  19. +10 −10 packages/turf-nearest-point-to-line/index.d.ts
  20. +18 −8 packages/turf-nearest-point-to-line/index.js
  21. +3 −2 packages/turf-nearest-point-to-line/package.json
  22. +2 −1 packages/turf-nearest-point-to-line/test.js
  23. +3 −2 packages/turf-nearest-point-to-line/types.ts
  24. +90 −0 packages/turf-nearest-point-to-line/yarn.lock
  25. +3 −3 packages/turf-point-grid/index.d.ts
  26. +8 −9 packages/turf-polygon-to-line/index.d.ts
  27. +3 −3 packages/turf-rhumb-bearing/types.ts
  28. +3 −3 packages/turf-rhumb-destination/index.d.ts
  29. +1 −7 packages/turf-rhumb-destination/types.ts
  30. +2 −2 packages/turf-simplify/types.ts
  31. +3 −3 packages/turf-square-grid/index.d.ts
  32. +3 −3 packages/turf-transform-rotate/types.ts
  33. +3 −3 packages/turf-transform-scale/types.ts
  34. +3 −3 packages/turf-transform-translate/types.ts
  35. +3 −3 packages/turf-triangle-grid/index.d.ts
  36. +3 −1 packages/turf-triangle-grid/types.ts
@@ -0,0 +1,27 @@
## About Turf.js

[TurfJS](http://turfjs.org/) is a modular geospatial analysis library for designed for use in the browser as well as Node.js.
We provide almost 150 modules for people to use freely in their applications.
Our most [popular module](https://www.npmjs.com/package/@turf/helpers) is downloaded 50,000 times a week via npm.


## Why we're looking for support

TurfJS is a community-driven project maintained by a small group of core contributors who work on the project in their spare time.
Time is spent supporting users, improving documentation, fixing bugs as well as creating new modules.
Your funding will directly go to development costs, marketing campaigns, promotional events & any other financial costs to operate & maintain TurfJS.

In particular, we're looking for corporate sponsors who use TurfJS in revenue-generating ways,
either by creating applications for clients, or through use in an app used by customers.
Of course individuals are welcome to support us as well if TurfJS has helped you :)

## 2017 Achievements

- Refactoring the codebase to support ES6 modules
- Adding approx 70 new modules/functions
- All new documentation

## Development goals for Turf.js in the coming year

- Removing our largest dependency (JSTS) to significantly reduce the size of our compiled code
- Add new modules to bring us closer to feature parity with other geospatial libraries
@@ -11,7 +11,6 @@ import {
Feature,
FeatureCollection,
Units,
FeatureGeometryCollection
} from '@turf/helpers';

interface Options {
@@ -26,7 +25,7 @@ declare function buffer<Geom extends Point | LineString | Polygon>(feature: Feat
declare function buffer<Geom extends MultiPoint | MultiLineString | MultiPolygon>(feature: Feature<Geom>|Geom, radius?: number, options?: Options): Feature<MultiPolygon>;
declare function buffer<Geom extends Point | LineString | Polygon>(feature: FeatureCollection<Geom>, radius?: number, options?: Options): FeatureCollection<Polygon>;
declare function buffer<Geom extends MultiPoint | MultiLineString | MultiPolygon>(feature: FeatureCollection<Geom>, radius?: number, options?: Options): FeatureCollection<MultiPolygon>;
declare function buffer(feature: FeatureCollection<any> | FeatureGeometryCollection | GeometryCollection, radius?: number, options?: Options): FeatureCollection<Polygon | MultiPolygon>;
declare function buffer(feature: FeatureCollection<any> | Feature<GeometryCollection> | GeometryCollection, radius?: number, options?: Options): FeatureCollection<Polygon | MultiPolygon>;
declare function buffer(feature: Feature<any> | GeometryObject, radius?: number, options?: Options): Feature<Polygon | MultiPolygon>;

export default buffer;
@@ -1,8 +1,8 @@
import {point, lineString} from '@turf/helpers'
import {point, lineString, Feature, Point, LineString} from '@turf/helpers'
import clone from './'

const pt = point([0, 20])
const ptCloned: GeoJSON.Feature<GeoJSON.Point> = clone(pt)
const ptCloned: Feature<Point> = clone(pt)

const line = lineString([[0, 20], [10, 10]]).geometry
const lineCloned: GeoJSON.LineString = clone(line)
const lineCloned: LineString = clone(line)
@@ -1,13 +1,14 @@
import { Feature, Point, Units, Coord } from '@turf/helpers'
import { Feature, Point, Units, Coord, Properties } from '@turf/helpers'

/**
* http://turfjs.org/docs/#destination
*/
export default function destination(
export default function destination<P = Properties>(
origin: Coord,
distance: number,
bearing: number,
options?: {
units?: Units
units?: Units,
properties?: P
}
): Feature<Point>;
): Feature<Point, P>;
@@ -12,6 +12,7 @@ import { point, lengthToRadians, degreesToRadians, radiansToDegrees, isObject }
* @param {number} bearing ranging from -180 to 180
* @param {Object} [options={}] Optional parameters
* @param {string} [options.units='kilometers'] miles, kilometers, degrees, or radians
* @param {Object} [options.properties={}] Translate properties to Point
* @returns {Feature<Point>} destination point
* @example
* var point = turf.point([-75.343, 39.984]);
@@ -31,6 +32,7 @@ function destination(origin, distance, bearing, options) {
options = options || {};
if (!isObject(options)) throw new Error('options is invalid');
var units = options.units;
var properties = options.properties;

// Handle input
var coordinates1 = getCoord(origin);
@@ -44,8 +46,10 @@ function destination(origin, distance, bearing, options) {
Math.cos(latitude1) * Math.sin(radians) * Math.cos(bearing_rad));
var longitude2 = longitude1 + Math.atan2(Math.sin(bearing_rad) * Math.sin(radians) * Math.cos(latitude1),
Math.cos(radians) - Math.sin(latitude1) * Math.sin(latitude2));
var lng = radiansToDegrees(longitude2);
var lat = radiansToDegrees(latitude2);

return point([radiansToDegrees(longitude2), radiansToDegrees(latitude2)]);
return point([lng, lat], properties);
}

export default destination;
@@ -1,45 +1,28 @@
/// <reference types='geojson' />

// GeoJSON Foreign Members
export type Id = string | number;
export type Properties = object;
export type BBox = [number, number, number, number];
import {
Id, Properties, BBox, Position,
Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon,
GeometryObject, GeoJSONObject, GeometryCollection, Geometry,
GeometryTypes, Types, CollectionTypes, Geometries,
Feature, FeatureCollection
} from './lib/geojson'
export {
Id, Properties, BBox, Position,
Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon,
GeometryObject, GeoJSONObject, GeometryCollection, Geometry,
GeometryTypes, Types, CollectionTypes, Geometries,
Feature, FeatureCollection
}

// TurfJS Combined Types
export type Coord = Feature<Point> | Point | Position;

// TurfJS String Types
export type Units = 'miles' | 'nauticalmiles' | 'degrees' | 'radians' | 'inches' | 'yards' | 'meters' | 'metres' | 'kilometers' | 'kilometres';
export type Geometry = 'Point' | 'LineString' | 'Polygon' | 'MultiPoint' | 'MultiLineString' | 'MultiPolygon';
export type Grid = 'point' | 'square' | 'hex' | 'triangle';
export type Collection = 'FeatureCollection' | 'GeometryCollection';
export type Types = 'Feature' | Geometry | Collection;
export type Corners = 'sw' | 'se' | 'nw' | 'ne' | 'center' | 'centroid';


// GeoJSON Geometry Types
export type Position = GeoJSON.Position;
export type Point = GeoJSON.Point;
export type MultiPoint = GeoJSON.MultiPoint;
export type MultiLineString = GeoJSON.MultiLineString;
export type LineString = GeoJSON.LineString;
export type Polygon = GeoJSON.Polygon;
export type MultiPolygon = GeoJSON.MultiPolygon;
export type Geometries = Point | MultiPoint | LineString | MultiLineString | Polygon | MultiPolygon;
export type GeometryObject = GeoJSON.GeometryObject;
export type GeometryCollection = GeoJSON.GeometryCollection;

// GeoJSON Feature Objects
export type FeatureCollection<T extends GeometryObject> = GeoJSON.FeatureCollection<T>;
export type Feature<T extends GeometryObject> = GeoJSON.Feature<T>;
export interface FeatureGeometryCollection extends Feature<any> {
geometry: GeometryCollection;
}
export interface ExtendedFeatureCollection<Feat extends Feature<any>> {
type: 'FeatureCollection';
features: Feat[];
}
export type AllGeoJSON = Feature<any> | FeatureCollection<any> | FeatureGeometryCollection | GeometryObject | GeometryCollection;
export type Lines = LineString | MultiLineString | Polygon | MultiPolygon;
export type AllGeoJSON = Feature | FeatureCollection | Geometry | GeometryCollection;

interface FeatureOptions {
id?: Id;
@@ -53,12 +36,12 @@ interface GeometryOptions {
/**
* http://turfjs.org/docs/#feature
*/
export function feature<T extends GeometryObject>(geometry: T, properties?: Properties, options?: FeatureOptions): Feature<T>;
export function feature<G extends Geometry | GeometryCollection, P = Properties>(geometry: G, properties?: P, options?: FeatureOptions): Feature<G, P>;

/**
* http://turfjs.org/docs/#featurecollection
*/
export function featureCollection<Geom extends GeometryObject>(features: Feature<Geom>[], options?: FeatureOptions): FeatureCollection<Geom>;
export function featureCollection<G extends Geometry, P = Properties>(features: Feature<G, P>[], options?: FeatureOptions): FeatureCollection<G, P>;
export function featureCollection(features: Feature<any>[], options?: FeatureOptions): FeatureCollection<any>;

/**
@@ -70,113 +53,113 @@ export function geometry(type: 'Polygon', coordinates: Position[][], options?: G
export function geometry(type: 'MultiPoint', coordinates: Position[], options?: GeometryOptions): MultiPoint;
export function geometry(type: 'MultiLineString', coordinates: Position[][], options?: GeometryOptions): MultiLineString;
export function geometry(type: 'MultiPolygon', coordinates: Position[][][], options?: GeometryOptions): MultiPolygon;
export function geometry(type: Geometry | string, coordinates: any[], options?: GeometryOptions): GeometryObject;
export function geometry(type: string, coordinates: any[], options?: GeometryOptions): Geometry;

/**
* http://turfjs.org/docs/#point
*/
export function point(coordinates: Position, properties?: Properties, options?: FeatureOptions): Feature<Point>;
export function point<P = Properties>(coordinates: Position, properties?: P, options?: FeatureOptions): Feature<Point, P>;

/**
* http://turfjs.org/docs/#points
*/
export function points(coordinates: Position[], properties?: Properties, options?: FeatureOptions): FeatureCollection<Point>;
export function points<P = Properties>(coordinates: Position[], properties?: P, options?: FeatureOptions): FeatureCollection<Point, P>;

/**
* http://turfjs.org/docs/#polygon
*/
export function polygon(coordinates: Position[][], properties?: Properties, options?: FeatureOptions): Feature<Polygon>;
export function polygon<P = Properties>(coordinates: Position[][], properties?: P, options?: FeatureOptions): Feature<Polygon, P>;

/**
* http://turfjs.org/docs/#polygons
*/
export function polygons(coordinates: Position[][][], properties?: Properties, options?: FeatureOptions): FeatureCollection<Polygon>;
export function polygons<P = Properties>(coordinates: Position[][][], properties?: P, options?: FeatureOptions): FeatureCollection<Polygon, P>;

/**
* http://turfjs.org/docs/#linestring
*/
export function lineString(coordinates: Position[], properties?: Properties, options?: FeatureOptions): Feature<LineString>;
export function lineString<P = Properties>(coordinates: Position[], properties?: P, options?: FeatureOptions): Feature<LineString, P>;

/**
* http://turfjs.org/docs/#linestrings
*/
export function lineStrings(coordinates: Position[][], properties?: Properties, options?: FeatureOptions): FeatureCollection<LineString>;
export function lineStrings<P = Properties>(coordinates: Position[][], properties?: P, options?: FeatureOptions): FeatureCollection<LineString, P>;


/**
* http://turfjs.org/docs/#multilinestring
*/
export function multiLineString(coordinates: Position[][], properties?: Properties, options?: FeatureOptions): Feature<MultiLineString>;
export function multiLineString<P = Properties>(coordinates: Position[][], properties?: P, options?: FeatureOptions): Feature<MultiLineString, P>;

/**
* http://turfjs.org/docs/#multipoint
*/
export function multiPoint(coordinates: Position[], properties?: Properties, options?: FeatureOptions): Feature<MultiPoint>;
export function multiPoint<P = Properties>(coordinates: Position[], properties?: P, options?: FeatureOptions): Feature<MultiPoint, P>;

/**
* http://turfjs.org/docs/#multipolygon
*/
export function multiPolygon(coordinates: Position[][][], properties?: Properties, options?: FeatureOptions): Feature<MultiPolygon>;
export function multiPolygon<P = Properties>(coordinates: Position[][][], properties?: P, options?: FeatureOptions): Feature<MultiPolygon, P>;

/**
* http://turfjs.org/docs/#geometrycollection
*/
export function geometryCollection(geometries: GeometryObject[], properties?: Properties, options?: FeatureOptions): FeatureGeometryCollection;
export function geometryCollection<P = Properties>(geometries: Geometries[], properties?: P, options?: FeatureOptions): Feature<GeometryCollection, P>;

/**
* http://turfjs.org/docs/#radianstolength
*/
export function radiansToLength(radians: number, units?: Units): number
export function radiansToLength(radians: number, units?: Units): number;

/**
* http://turfjs.org/docs/#lengthtoradians
*/
export function lengthToRadians(distance: number, units?: Units): number
export function lengthToRadians(distance: number, units?: Units): number;

/**
* http://turfjs.org/docs/#lengthtodegrees
*/
export function lengthToDegrees(distance: number, units?: Units): number
export function lengthToDegrees(distance: number, units?: Units): number;

/**
* http://turfjs.org/docs/#bearingtoazimuth
*/
export function bearingToAzimuth(bearing: number): number
export function bearingToAzimuth(bearing: number): number;

/**
* http://turfjs.org/docs/#radianstodegrees
*/
export function radiansToDegrees(radians: number): number
export function radiansToDegrees(radians: number): number;

/**
* http://turfjs.org/docs/#degreestoradians
*/
export function degreesToRadians(degrees: number): number
export function degreesToRadians(degrees: number): number;

/**
* http://turfjs.org/docs/#round
*/
export function round(num: number, precision?: number): number
export function round(num: number, precision?: number): number;

/**
* http://turfjs.org/docs/#convertlength
*/
export function convertLength(length: number, originalUnit: Units, finalUnit?: Units): number
export function convertLength(length: number, originalUnit: Units, finalUnit?: Units): number;

/**
* http://turfjs.org/docs/#convertarea
*/
export function convertArea(area: number, originalUnit?: Units, finalUnit?: Units): number
export function convertArea(area: number, originalUnit?: Units, finalUnit?: Units): number;

/**
* http://turfjs.org/docs/#isnumber
*/
export function isNumber(num: any): boolean
export function isNumber(num: any): boolean;

/**
* http://turfjs.org/docs/#isobject
*/
export function isObject(input: any): boolean
export function isObject(input: any): boolean;

/**
* Earth Radius used with the Harvesine formula and approximates using a spherical (non-ellipsoid) Earth.
@@ -187,47 +170,47 @@ export const earthRadius: number;
* Unit of measurement factors using a spherical (non-ellipsoid) earth radius.
*/
export const factors: {
meters: number
millimeters: number
centimeters: number
kilometers: number
miles: number
nauticalmiles: number
inches: number
yards: number
feet: number
meters: number;
millimeters: number;
centimeters: number;
kilometers: number;
miles: number;
nauticalmiles: number;
inches: number;
yards: number;
feet: number;
}

/**
* Units of measurement factors based on 1 meter.
*/
export const unitsFactors: {
meters: number
millimeters: number
centimeters: number
kilometers: number
miles: number
nauticalmiles: number
inches: number
yards: number
feet: number
radians: number
degrees: number
meters: number;
millimeters: number;
centimeters: number;
kilometers: number;
miles: number;
nauticalmiles: number;
inches: number;
yards: number;
feet: number;
radians: number;
degrees: number;
};

/**
* Area of measurement factors based on 1 square meter.
*/
export const areaFactors: {
meters: number
millimeters: number
centimeters: number
kilometers: number
acres: number
miles: number
yards: number
feet: number
inches: number
meters: number;
millimeters: number;
centimeters: number;
kilometers: number;
acres: number;
miles: number;
yards: number;
feet: number;
inches: number;
};

/**

0 comments on commit f7f0a75

Please sign in to comment.
You can’t perform that action at this time.