Skip to content

Commit

Permalink
Docs updates (Turfjs#864)
Browse files Browse the repository at this point in the history
* fixed position of documentation.js '//addToMap' tag

* Update truncate example

* Fix major `@example` errors

* fixed @examples

* improved @examples

* updated READMEs

* ran test.examples => fixed examples => updated readmes

* ran project test => fixed linting errors, updated package.json

* added  to turf/packages/turf/package.json
  • Loading branch information
stebogit authored and DenisCarriere committed Jul 26, 2017
1 parent 8b8d912 commit 3349cc9
Show file tree
Hide file tree
Showing 144 changed files with 4,186 additions and 2,484 deletions.
9 changes: 1 addition & 8 deletions packages/turf-along/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,7 @@ Takes a [line](http://geojson.org/geojson-spec.html#linestring) and returns a [p
**Examples**

```javascript
var line = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": [[-83, 30], [-84, 36], [-78, 41]]
}
};
var line = turf.lineString([[-83, 30], [-84, 36], [-78, 41]]);

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

Expand Down
9 changes: 1 addition & 8 deletions packages/turf-along/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,7 @@ var destination = require('@turf/destination');
* @param {string} [units=kilometers] can be degrees, radians, miles, or kilometers
* @returns {Feature<Point>} Point `distance` `units` along the line
* @example
* var line = {
* "type": "Feature",
* "properties": {},
* "geometry": {
* "type": "LineString",
* "coordinates": [[-83, 30], [-84, 36], [-78, 41]]
* }
* };
* var line = turf.lineString([[-83, 30], [-84, 36], [-78, 41]]);
*
* var along = turf.along(line, 200, 'miles');
*
Expand Down
12 changes: 3 additions & 9 deletions packages/turf-area/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,13 @@ Takes one or more features and returns their area in square meters.
**Examples**

```javascript
var polygon = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [[[125, -15], [113, -22], [154, -27], [144, -15], [125, -15]]]
}
}
var polygon = turf.polygon([[[125, -15], [113, -22], [154, -27], [144, -15], [125, -15]]]);

var area = turf.area(polygon);

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

Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** area in square meters
Expand Down
12 changes: 3 additions & 9 deletions packages/turf-area/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,13 @@ var geomReduce = require('@turf/meta').geomReduce;
* @param {FeatureCollection|Feature<any>} geojson input GeoJSON feature(s)
* @returns {number} area in square meters
* @example
* var polygon = {
* "type": "Feature",
* "properties": {},
* "geometry": {
* "type": "Polygon",
* "coordinates": [[[125, -15], [113, -22], [154, -27], [144, -15], [125, -15]]]
* }
* }
* var polygon = turf.polygon([[[125, -15], [113, -22], [154, -27], [144, -15], [125, -15]]]);
*
* var area = turf.area(polygon);
*
* //addToMap
* polygon.properties.area = area
* var addToMap = [polygon]
* polygon.properties.area = area
*/
module.exports = function (geojson) {
return geomReduce(geojson, function (value, geometry) {
Expand Down
9 changes: 1 addition & 8 deletions packages/turf-bbox-clip/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,7 @@ May result in degenerate edges when clipping Polygons.

```javascript
var bbox = [0, 0, 10, 10];
var poly = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [[[2, 2], [8, 4], [12, 8], [3, 7], [2, 2]]]
}
}
var poly = turf.polygon([[[2, 2], [8, 4], [12, 8], [3, 7], [2, 2]]]);

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

Expand Down
9 changes: 1 addition & 8 deletions packages/turf-bbox-clip/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,7 @@ var multiPolygon = helpers.multiPolygon;
* @returns {Feature<LineString|MultiLineString|Polygon|MultiPolygon>} clipped Feature
* @example
* var bbox = [0, 0, 10, 10];
* var poly = {
* "type": "Feature",
* "properties": {},
* "geometry": {
* "type": "Polygon",
* "coordinates": [[[2, 2], [8, 4], [12, 8], [3, 7], [2, 2]]]
* }
* }
* var poly = turf.polygon([[[2, 2], [8, 4], [12, 8], [3, 7], [2, 2]]]);
*
* var clipped = turf.bboxClip(poly, bbox);
*
Expand Down
3 changes: 1 addition & 2 deletions packages/turf-bbox-polygon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var polygon = require('@turf/helpers').polygon;
*
* @name bboxPolygon
* @param {Array<number>} bbox extent in [minX, minY, maxX, maxY] order
* @return {Feature<Polygon>} a Polygon representation of the bounding box
* @returns {Feature<Polygon>} a Polygon representation of the bounding box
* @addToMap poly
* @example
* var bbox = [0, 0, 10, 10];
Expand All @@ -15,7 +15,6 @@ var polygon = require('@turf/helpers').polygon;
* //addToMap
* var addToMap = [poly]
*/

module.exports = function (bbox) {
var lowLeft = [bbox[0], bbox[1]];
var topLeft = [bbox[0], bbox[3]];
Expand Down
11 changes: 2 additions & 9 deletions packages/turf-bbox/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,11 @@ Takes a set of features, calculates the bbox of all input features, and returns
**Examples**

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

//addToMap
var bboxPolygon = turf.bboxPolygon(bbox);
var addToMap = [line, bboxPolygon]
```

Expand Down
11 changes: 2 additions & 9 deletions packages/turf-bbox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,11 @@ var coordEach = require('@turf/meta').coordEach;
* @param {FeatureCollection|Feature<any>} geojson input features
* @returns {Array<number>} bbox extent in [minX, minY, maxX, maxY] order
* @example
* var line = {
* "type": "Feature",
* "properties": {},
* "geometry": {
* "type": "LineString",
* "coordinates": [[-74, 40], [-78, 42], [-82, 35]]
* }
* }
* var line = turf.lineString([[-74, 40], [-78, 42], [-82, 35]]);
* var bbox = turf.bbox(line);
* var bboxPolygon = turf.bboxPolygon(bbox);
*
* //addToMap
* var bboxPolygon = turf.bboxPolygon(bbox);
* var addToMap = [line, bboxPolygon]
*/
module.exports = function (geojson) {
Expand Down
18 changes: 2 additions & 16 deletions packages/turf-bearing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,8 @@ i.e. the angle measured in degrees from the north line (0 degrees)
**Examples**

```javascript
var point1 = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [-75.343, 39.984]
}
};
var point2 = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [-75.534, 39.123]
}
};
var point1 = turf.point([-75.343, 39.984]);
var point2 = turf.point([-75.534, 39.123]);

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

Expand Down
19 changes: 2 additions & 17 deletions packages/turf-bearing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,8 @@ var getCoord = require('@turf/invariant').getCoord;
* @param {boolean} [final=false] calculates the final bearing if true
* @returns {number} bearing in decimal degrees, between -180 and 180 degrees (positive clockwise)
* @example
* var point1 = {
* "type": "Feature",
* "properties": {},
* "geometry": {
* "type": "Point",
* "coordinates": [-75.343, 39.984]
* }
* };
* var point2 = {
* "type": "Feature",
* "properties": {},
* "geometry": {
* "type": "Point",
* "coordinates": [-75.534, 39.123]
* }
* };
* var point1 = turf.point([-75.343, 39.984]);
* var point2 = turf.point([-75.534, 39.123]);
*
* var bearing = turf.bearing(point1, point2);
*
Expand All @@ -37,7 +23,6 @@ var getCoord = require('@turf/invariant').getCoord;
* point2.properties['marker-color'] = '#0f0'
* point1.properties.bearing = bearing
*/

function bearing(start, end, final) {
if (final === true) return calculateFinalBearing(start, end);

Expand Down
14 changes: 7 additions & 7 deletions packages/turf-bezier/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ The bezier spline implementation is by [Leszek Rybicki](http://leszek.rybicki.cc

```javascript
var line = turf.lineString([
[-76.091308, 18.427501],
[-76.695556, 18.729501],
[-76.552734, 19.40443],
[-74.61914, 19.134789],
[-73.652343, 20.07657],
[-73.157958, 20.210656]
[-76.091308, 18.427501],
[-76.695556, 18.729501],
[-76.552734, 19.40443],
[-74.61914, 19.134789],
[-73.652343, 20.07657],
[-73.157958, 20.210656]
]);

var curved = turf.bezier(line);

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

Returns **[Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;[LineString](http://geojson.org/geojson-spec.html#linestring)>** curved line
Expand Down
14 changes: 7 additions & 7 deletions packages/turf-bezier/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ var Spline = require('./spline.js');
* @returns {Feature<LineString>} curved line
* @example
* var line = turf.lineString([
* [-76.091308, 18.427501],
* [-76.695556, 18.729501],
* [-76.552734, 19.40443],
* [-74.61914, 19.134789],
* [-73.652343, 20.07657],
* [-73.157958, 20.210656]
* [-76.091308, 18.427501],
* [-76.695556, 18.729501],
* [-76.552734, 19.40443],
* [-74.61914, 19.134789],
* [-73.652343, 20.07657],
* [-73.157958, 20.210656]
* ]);
*
* var curved = turf.bezier(line);
*
* //addToMap
* curved.properties = { stroke: '#0f0' };
* var addToMap = [line, curved]
* curved.properties = { stroke: '#0F0' };
*/
module.exports = function (line, resolution, sharpness) {
var coords = [];
Expand Down
10 changes: 5 additions & 5 deletions packages/turf-boolean-contains/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
"homepage": "https://github.com/Turfjs/turf",
"devDependencies": {
"@turf/helpers": "^4.5.2",
"benchmark": "^2.1.4",
"boolean-shapely": "^0.1.2",
"glob": "^7.1.1",
"load-json-file": "^2.0.0",
"tape": "^4.6.3"
"benchmark": "2.1.4",
"boolean-shapely": "0.1.2",
"glob": "7.1.2",
"load-json-file": "2.0.0",
"tape": "4.7.0"
},
"dependencies": {
"@turf/bbox": "^4.5.2",
Expand Down
1 change: 0 additions & 1 deletion packages/turf-boolean-crosses/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ var getGeomType = invariant.getGeomType;
* var cross = turf.booleanCrosses(line1, line2);
* //=true
*/

module.exports = function (feature1, feature2) {
var type1 = getGeomType(feature1);
var type2 = getGeomType(feature2);
Expand Down
10 changes: 5 additions & 5 deletions packages/turf-boolean-crosses/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
},
"homepage": "https://github.com/Turfjs/turf",
"devDependencies": {
"benchmark": "^2.1.4",
"boolean-shapely": "^0.1.2",
"glob": "^7.1.2",
"load-json-file": "^2.0.0",
"tape": "^4.6.3"
"benchmark": "2.1.4",
"boolean-shapely": "0.1.2",
"glob": "7.1.2",
"load-json-file": "2.0.0",
"tape": "4.7.0"
},
"dependencies": {
"@turf/helpers": "^4.5.2",
Expand Down
8 changes: 4 additions & 4 deletions packages/turf-boolean-disjoint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
"homepage": "https://github.com/Turfjs/turf",
"devDependencies": {
"@turf/helpers": "^4.5.2",
"benchmark": "^2.1.4",
"boolean-shapely": "^0.1.2",
"load-json-file": "^2.0.0",
"tape": "^4.6.3"
"benchmark": "2.1.4",
"boolean-shapely": "0.1.2",
"load-json-file": "2.0.0",
"tape": "4.7.0"
},
"dependencies": {
"@turf/inside": "^4.5.2",
Expand Down
10 changes: 5 additions & 5 deletions packages/turf-boolean-point-on-line/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
},
"homepage": "https://github.com/Turfjs/turf",
"devDependencies": {
"benchmark": "^2.1.4",
"glob": "^7.1.2",
"load-json-file": "^2.0.0",
"tape": "^4.6.3",
"write-json-file": "^2.2.0"
"benchmark": "2.1.4",
"glob": "7.1.2",
"load-json-file": "2.0.0",
"tape": "4.7.0",
"write-json-file": "2.2.0"
},
"dependencies": {
"@turf/invariant": "^4.5.2"
Expand Down
11 changes: 2 additions & 9 deletions packages/turf-buffer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,15 @@ the input, or even be empty.

**Parameters**

- `feature` **([FeatureCollection](http://geojson.org/geojson-spec.html#feature-collection-objects) \| [Geometry](http://geojson.org/geojson-spec.html#geometry) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;any>)** input to be buffered
- `geojson` **([FeatureCollection](http://geojson.org/geojson-spec.html#feature-collection-objects) \| [Geometry](http://geojson.org/geojson-spec.html#geometry) \| [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 (negative values are allowed)
- `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 point = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [-90.548630, 14.616599]
}
};
var point = turf.point([-90.548630, 14.616599]);
var buffered = turf.buffer(point, 500, 'miles');

//addToMap
Expand Down
Loading

0 comments on commit 3349cc9

Please sign in to comment.