Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Readmes #670

Merged
merged 1 commit into from
Apr 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions packages/turf-along/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,14 @@ var line = {
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": [
[-77.031669, 38.878605],
[-77.029609, 38.881946],
[-77.020339, 38.884084],
[-77.025661, 38.885821],
[-77.021884, 38.889563],
[-77.019824, 38.892368]
]
"coordinates": [[-83, 30], [-84, 36], [-78, 41]]
}
};

var along = turf.along(line, 1, 'miles');
//=along
var along = turf.along(line, 200, 'miles');

//addToMap
var addToMap = [along, line]
```

Returns **[Feature](http://geojson.org/geojson-spec.html#feature-objects)<[Point](http://geojson.org/geojson-spec.html#point)>** Point `distance` `units` along the line
Expand Down
12 changes: 3 additions & 9 deletions packages/turf-along/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,12 @@ var destination = require('@turf/destination');
* "properties": {},
* "geometry": {
* "type": "LineString",
* "coordinates": [
* [-77.031669, 38.878605],
* [-77.029609, 38.881946],
* [-77.020339, 38.884084],
* [-77.025661, 38.885821],
* [-77.021884, 38.889563],
* [-77.019824, 38.892368]
* ]
* "coordinates": [[-83, 30], [-84, 36], [-78, 41]]
* }
* };
*
* var along = turf.along(line, 1, 'miles');
* var along = turf.along(line, 200, 'miles');
*
* //addToMap
* var addToMap = [along, line]
*/
Expand Down
19 changes: 5 additions & 14 deletions packages/turf-area/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,14 @@ var polygon = {
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[125, -15],
[113, -22],
[117, -37],
[130, -33],
[148, -39],
[154, -27],
[144, -15],
[125, -15]
]
]
"coordinates": [[[125, -15], [113, -22], [154, -27], [144, -15], [125, -15]]]
}
}
var area = turf.area(polygon);
//=area => square meters
//=polygon

//addToMap
polygon.properties.area = area
var addToMap = [polygon]
```

Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** area in square meters
Expand Down
14 changes: 2 additions & 12 deletions packages/turf-area/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,11 @@ var geomReduce = require('@turf/meta').geomReduce;
* "properties": {},
* "geometry": {
* "type": "Polygon",
* "coordinates": [
* [
* [125, -15],
* [113, -22],
* [117, -37],
* [130, -33],
* [148, -39],
* [154, -27],
* [144, -15],
* [125, -15]
* ]
* ]
* "coordinates": [[[125, -15], [113, -22], [154, -27], [144, -15], [125, -15]]]
* }
* }
* var area = turf.area(polygon);
*
* //addToMap
* polygon.properties.area = area
* var addToMap = [polygon]
Expand Down
5 changes: 3 additions & 2 deletions packages/turf-bbox-clip/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @turf/bbox-clip

# bbox-clip
# bboxClip

Takes a [Feature](http://geojson.org/geojson-spec.html#feature-objects) and a bbox and clips the feature to the bbox using [lineclip](https://github.com/mapbox/lineclip).
May result in degenerate edges when clipping Polygons.
Expand All @@ -25,7 +25,8 @@ var poly = {

var clipped = turf.bboxClip(poly, bbox);

//=clipped
//addToMap
var addToMap = [bbox, poly, clipped]
```

Returns **[Feature](http://geojson.org/geojson-spec.html#feature-objects)<([LineString](http://geojson.org/geojson-spec.html#linestring) \| [MultiLineString](http://geojson.org/geojson-spec.html#multilinestring) \| [Polygon](http://geojson.org/geojson-spec.html#polygon) \| [MultiPolygon](http://geojson.org/geojson-spec.html#multipolygon))>** clipped Feature
Expand Down
1 change: 1 addition & 0 deletions packages/turf-bbox-clip/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var multiPolygon = helpers.multiPolygon;
* }
*
* var clipped = turf.bboxClip(poly, bbox);
*
* //addToMap
* var addToMap = [bbox, poly, clipped]
*/
Expand Down
3 changes: 2 additions & 1 deletion packages/turf-bbox-polygon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ var bbox = [0, 0, 10, 10];

var poly = turf.bboxPolygon(bbox);

//=poly
//addToMap
var addToMap = [poly]
```

Returns **[Feature](http://geojson.org/geojson-spec.html#feature-objects)<[Polygon](http://geojson.org/geojson-spec.html#polygon)>** a Polygon representation of the bounding box
Expand Down
1 change: 1 addition & 0 deletions packages/turf-bbox-polygon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var polygon = require('@turf/helpers').polygon;
* var bbox = [0, 0, 10, 10];
*
* var poly = turf.bboxPolygon(bbox);
*
* //addToMap
* var addToMap = [poly]
*/
Expand Down
27 changes: 13 additions & 14 deletions packages/turf-bbox/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,24 @@ Takes a set of features, calculates the bbox of all input features, and returns

**Parameters**

- `geojson` **([Feature](http://geojson.org/geojson-spec.html#feature-objects) \| [FeatureCollection](http://geojson.org/geojson-spec.html#feature-collection-objects))** input features
- `geojson` **([FeatureCollection](http://geojson.org/geojson-spec.html#feature-collection-objects) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)<any>)** input features

**Examples**

```javascript
var pt1 = turf.point([114.175329, 22.2524])
var pt2 = turf.point([114.170007, 22.267969])
var pt3 = turf.point([114.200649, 22.274641])
var pt4 = turf.point([114.200649, 22.274641])
var pt5 = turf.point([114.186744, 22.265745])
var features = turf.featureCollection([pt1, pt2, pt3, pt4, pt5])

var bbox = turf.bbox(features);

var line = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": [[-74, 40], [-78, 42], [-82, 35]]
}
}
var bbox = turf.bbox(line);

//addToMap
var bboxPolygon = turf.bboxPolygon(bbox);

//=bbox

//=bboxPolygon
var addToMap = [line, bboxPolygon]
```

Returns **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>** bbox extent in [minX, minY, maxX, maxY] order
Expand Down
27 changes: 14 additions & 13 deletions packages/turf-bbox/index.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
var each = require('@turf/meta').coordEach;
var coordEach = require('@turf/meta').coordEach;

/**
* Takes a set of features, calculates the bbox of all input features, and returns a bounding box.
*
* @name bbox
* @param {(Feature|FeatureCollection)} geojson input features
* @param {FeatureCollection|Feature<any>} geojson input features
* @returns {Array<number>} bbox extent in [minX, minY, maxX, maxY] order
* @example
* var pt1 = turf.point([114.175329, 22.2524])
* var pt2 = turf.point([114.170007, 22.267969])
* var pt3 = turf.point([114.200649, 22.274641])
* var pt4 = turf.point([114.200649, 22.274641])
* var pt5 = turf.point([114.186744, 22.265745])
* var features = turf.featureCollection([pt1, pt2, pt3, pt4, pt5])
* var line = {
* "type": "Feature",
* "properties": {},
* "geometry": {
* "type": "LineString",
* "coordinates": [[-74, 40], [-78, 42], [-82, 35]]
* }
* }
* var bbox = turf.bbox(line);
*
* var bbox = turf.bbox(features);
*
* var bboxPolygon = turf.bboxPolygon(bbox);
* //addToMap
* var addToMap = [features, bboxPolygon]
* var bboxPolygon = turf.bboxPolygon(bbox);
* var addToMap = [line, bboxPolygon]
*/
module.exports = function (geojson) {
var bbox = [Infinity, Infinity, -Infinity, -Infinity];
each(geojson, function (coord) {
coordEach(geojson, function (coord) {
if (bbox[0] > coord[0]) bbox[0] = coord[0];
if (bbox[1] > coord[1]) bbox[1] = coord[1];
if (bbox[2] < coord[0]) bbox[2] = coord[0];
Expand Down
14 changes: 7 additions & 7 deletions packages/turf-bearing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,28 @@ i.e. the angle measured in degrees from the north line (0 degrees)
```javascript
var point1 = {
"type": "Feature",
"properties": {
"marker-color": '#f00'
},
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [-75.343, 39.984]
}
};
var point2 = {
"type": "Feature",
"properties": {
"marker-color": '#0f0'
},
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [-75.534, 39.123]
}
};

var bearing = turf.bearing(point1, point2);

//addToMap
var addToMap = [point1, point2]
point1.properties['marker-color'] = '#f00'
point2.properties['marker-color'] = '#0f0'
point1.properties.bearing = bearing
//=bearing
```

Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** bearing in decimal degrees, between -180 and 180 degrees (positive clockwise)
Expand Down
1 change: 1 addition & 0 deletions packages/turf-bearing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var getCoord = require('@turf/invariant').getCoord;
* };
*
* var bearing = turf.bearing(point1, point2);
*
* //addToMap
* var addToMap = [point1, point2]
* point1.properties['marker-color'] = '#f00'
Expand Down
5 changes: 3 additions & 2 deletions packages/turf-bezier/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ var line = {
};

var curved = turf.bezier(line);
curved.properties = { stroke: '#0f0' };

//=curved
//addToMap
curved.properties = { stroke: '#0f0' };
var addToMap = [line, curved]
```

Returns **[Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;[LineString](http://geojson.org/geojson-spec.html#linestring)>** curved line
Expand Down
1 change: 1 addition & 0 deletions packages/turf-bezier/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var Spline = require('./spline.js');
* };
*
* var curved = turf.bezier(line);
*
* //addToMap
* curved.properties = { stroke: '#0f0' };
* var addToMap = [line, curved]
Expand Down
14 changes: 8 additions & 6 deletions packages/turf-buffer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ Calculates a buffer for input features for a given radius. Units supported are m

**Parameters**

- `feature` **([Feature](http://geojson.org/geojson-spec.html#feature-objects) \| [FeatureCollection](http://geojson.org/geojson-spec.html#feature-collection-objects))** input to be buffered
- `feature` **([FeatureCollection](http://geojson.org/geojson-spec.html#feature-collection-objects) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;any>)** input to be buffered
- `radius` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** distance to draw the buffer
- `units` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** any of the options supported by turf units
- `units` **\[[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)]** any of the options supported by turf units (optional, default `kilometers`)
- `steps` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** number of steps (optional, default `64`)

**Examples**

```javascript
var pt = {
var point = {
"type": "Feature",
"properties": {},
"geometry": {
Expand All @@ -23,12 +24,13 @@ var pt = {
};
var unit = 'miles';

var buffered = turf.buffer(pt, 500, unit);
var buffered = turf.buffer(point, 500, unit);

//=buffered
//addToMap
var addToMap = [point, buffered]
```

Returns **([FeatureCollection](http://geojson.org/geojson-spec.html#feature-collection-objects)&lt;[Polygon](http://geojson.org/geojson-spec.html#polygon)> | [FeatureCollection](http://geojson.org/geojson-spec.html#feature-collection-objects)&lt;[MultiPolygon](http://geojson.org/geojson-spec.html#multipolygon)> | [Polygon](http://geojson.org/geojson-spec.html#polygon) \| [MultiPolygon](http://geojson.org/geojson-spec.html#multipolygon))** buffered features
Returns **([FeatureCollection](http://geojson.org/geojson-spec.html#feature-collection-objects) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;([Polygon](http://geojson.org/geojson-spec.html#polygon) \| [MultiPolygon](http://geojson.org/geojson-spec.html#multipolygon))>)** buffered features

<!-- This file is automatically generated. Please don't edit it directly:
if you find an error, edit the source file (likely index.js), and re-run
Expand Down
Loading