@turf/transform-rotate 6.4.0 → 7.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -17
- package/dist/es/index.js +0 -0
- package/dist/js/index.js +19 -12
- package/package.json +13 -12
package/README.md
CHANGED
|
@@ -4,18 +4,18 @@
|
|
|
4
4
|
|
|
5
5
|
## transformRotate
|
|
6
6
|
|
|
7
|
-
Rotates any geojson Feature or Geometry of a specified angle, around its `centroid` or a given `pivot` point
|
|
8
|
-
all rotations follow the right-hand rule: [https://en.wikipedia.org/wiki/Right-hand_rule][1]
|
|
7
|
+
Rotates any geojson Feature or Geometry of a specified angle, around its `centroid` or a given `pivot` point.
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
### Parameters
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
- `options.pivot` **[Coord][5]** point around which the rotation will be performed (optional, default `'centroid'`)
|
|
16
|
-
- `options.mutate` **[boolean][6]** allows GeoJSON input to be mutated (significant performance increase if true) (optional, default `false`)
|
|
11
|
+
* `geojson` **[GeoJSON][1]** object to be rotated
|
|
12
|
+
* `angle` **[number][2]** of rotation in decimal degrees, positive clockwise
|
|
13
|
+
* `options` **[Object][3]** Optional parameters (optional, default `{}`)
|
|
17
14
|
|
|
18
|
-
**
|
|
15
|
+
* `options.pivot` **[Coord][4]** point around which the rotation will be performed (optional, default `'centroid'`)
|
|
16
|
+
* `options.mutate` **[boolean][5]** allows GeoJSON input to be mutated (significant performance increase if true) (optional, default `false`)
|
|
17
|
+
|
|
18
|
+
### Examples
|
|
19
19
|
|
|
20
20
|
```javascript
|
|
21
21
|
var poly = turf.polygon([[[0,29],[3.5,29],[2.5,32],[0,29]]]);
|
|
@@ -27,19 +27,17 @@ var addToMap = [poly, rotatedPoly];
|
|
|
27
27
|
rotatedPoly.properties = {stroke: '#F00', 'stroke-width': 4};
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
Returns **[GeoJSON][
|
|
31
|
-
|
|
32
|
-
[1]: https://en.wikipedia.org/wiki/Right-hand_rule
|
|
30
|
+
Returns **[GeoJSON][1]** the rotated GeoJSON feature
|
|
33
31
|
|
|
34
|
-
[
|
|
32
|
+
[1]: https://tools.ietf.org/html/rfc7946#section-3
|
|
35
33
|
|
|
36
|
-
[
|
|
34
|
+
[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
|
37
35
|
|
|
38
|
-
[
|
|
36
|
+
[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
39
37
|
|
|
40
|
-
[
|
|
38
|
+
[4]: https://tools.ietf.org/html/rfc7946#section-3.1.1
|
|
41
39
|
|
|
42
|
-
[
|
|
40
|
+
[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|
|
43
41
|
|
|
44
42
|
<!-- This file is automatically generated. Please don't edit it directly:
|
|
45
43
|
if you find an error, edit the source file (likely index.js), and re-run
|
package/dist/es/index.js
CHANGED
|
File without changes
|
package/dist/js/index.js
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var rhumbDestination = _interopDefault(require('@turf/rhumb-destination'));
|
|
9
|
-
var clone = _interopDefault(require('@turf/clone'));
|
|
3
|
+
var centroid = require('@turf/centroid');
|
|
4
|
+
var rhumbBearing = require('@turf/rhumb-bearing');
|
|
5
|
+
var rhumbDistance = require('@turf/rhumb-distance');
|
|
6
|
+
var rhumbDestination = require('@turf/rhumb-destination');
|
|
7
|
+
var clone = require('@turf/clone');
|
|
10
8
|
var meta = require('@turf/meta');
|
|
11
9
|
var invariant = require('@turf/invariant');
|
|
12
10
|
var helpers = require('@turf/helpers');
|
|
13
11
|
|
|
12
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
|
+
|
|
14
|
+
var centroid__default = /*#__PURE__*/_interopDefaultLegacy(centroid);
|
|
15
|
+
var rhumbBearing__default = /*#__PURE__*/_interopDefaultLegacy(rhumbBearing);
|
|
16
|
+
var rhumbDistance__default = /*#__PURE__*/_interopDefaultLegacy(rhumbDistance);
|
|
17
|
+
var rhumbDestination__default = /*#__PURE__*/_interopDefaultLegacy(rhumbDestination);
|
|
18
|
+
var clone__default = /*#__PURE__*/_interopDefaultLegacy(clone);
|
|
19
|
+
|
|
14
20
|
/**
|
|
15
21
|
* Rotates any geojson Feature or Geometry of a specified angle, around its `centroid` or a given `pivot` point.
|
|
16
22
|
*
|
|
@@ -46,17 +52,17 @@ function transformRotate(geojson, angle, options) {
|
|
|
46
52
|
if (angle === 0) return geojson;
|
|
47
53
|
|
|
48
54
|
// Use centroid of GeoJSON if pivot is not provided
|
|
49
|
-
if (!pivot) pivot =
|
|
55
|
+
if (!pivot) pivot = centroid__default['default'](geojson);
|
|
50
56
|
|
|
51
57
|
// Clone geojson to avoid side effects
|
|
52
|
-
if (mutate === false || mutate === undefined) geojson =
|
|
58
|
+
if (mutate === false || mutate === undefined) geojson = clone__default['default'](geojson);
|
|
53
59
|
|
|
54
60
|
// Rotate each coordinate
|
|
55
61
|
meta.coordEach(geojson, function (pointCoords) {
|
|
56
|
-
var initialAngle =
|
|
62
|
+
var initialAngle = rhumbBearing__default['default'](pivot, pointCoords);
|
|
57
63
|
var finalAngle = initialAngle + angle;
|
|
58
|
-
var distance =
|
|
59
|
-
var newCoords = invariant.getCoords(
|
|
64
|
+
var distance = rhumbDistance__default['default'](pivot, pointCoords);
|
|
65
|
+
var newCoords = invariant.getCoords(rhumbDestination__default['default'](pivot, distance, finalAngle));
|
|
60
66
|
pointCoords[0] = newCoords[0];
|
|
61
67
|
pointCoords[1] = newCoords[1];
|
|
62
68
|
});
|
|
@@ -64,3 +70,4 @@ function transformRotate(geojson, angle, options) {
|
|
|
64
70
|
}
|
|
65
71
|
|
|
66
72
|
module.exports = transformRotate;
|
|
73
|
+
module.exports.default = transformRotate;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/transform-rotate",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-alpha.0",
|
|
4
4
|
"description": "turf transform-rotate module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"contributors": [
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"type": "git",
|
|
17
17
|
"url": "git://github.com/Turfjs/turf.git"
|
|
18
18
|
},
|
|
19
|
+
"funding": "https://opencollective.com/turf",
|
|
19
20
|
"publishConfig": {
|
|
20
21
|
"access": "public"
|
|
21
22
|
},
|
|
@@ -46,10 +47,10 @@
|
|
|
46
47
|
"docs": "node ../../scripts/generate-readmes",
|
|
47
48
|
"test": "npm-run-all test:*",
|
|
48
49
|
"test:tape": "node -r esm test.js",
|
|
49
|
-
"test:types": "tsc --esModuleInterop --noEmit types.ts"
|
|
50
|
+
"test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
52
|
-
"@turf/truncate": "^
|
|
53
|
+
"@turf/truncate": "^7.0.0-alpha.0",
|
|
53
54
|
"benchmark": "*",
|
|
54
55
|
"load-json-file": "*",
|
|
55
56
|
"npm-run-all": "*",
|
|
@@ -58,14 +59,14 @@
|
|
|
58
59
|
"write-json-file": "*"
|
|
59
60
|
},
|
|
60
61
|
"dependencies": {
|
|
61
|
-
"@turf/centroid": "^
|
|
62
|
-
"@turf/clone": "^
|
|
63
|
-
"@turf/helpers": "^
|
|
64
|
-
"@turf/invariant": "^
|
|
65
|
-
"@turf/meta": "^
|
|
66
|
-
"@turf/rhumb-bearing": "^
|
|
67
|
-
"@turf/rhumb-destination": "^
|
|
68
|
-
"@turf/rhumb-distance": "^
|
|
62
|
+
"@turf/centroid": "^7.0.0-alpha.0",
|
|
63
|
+
"@turf/clone": "^7.0.0-alpha.0",
|
|
64
|
+
"@turf/helpers": "^7.0.0-alpha.0",
|
|
65
|
+
"@turf/invariant": "^7.0.0-alpha.0",
|
|
66
|
+
"@turf/meta": "^7.0.0-alpha.0",
|
|
67
|
+
"@turf/rhumb-bearing": "^7.0.0-alpha.0",
|
|
68
|
+
"@turf/rhumb-destination": "^7.0.0-alpha.0",
|
|
69
|
+
"@turf/rhumb-distance": "^7.0.0-alpha.0"
|
|
69
70
|
},
|
|
70
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189"
|
|
71
72
|
}
|