@turf/directional-mean 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 CHANGED
@@ -4,18 +4,18 @@
4
4
 
5
5
  ## DirectionalMeanLine
6
6
 
7
- Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)
7
+ Type: [Object][1]
8
8
 
9
- **Properties**
9
+ ### Properties
10
10
 
11
- - `cartesianAngle` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** the mean angle of all lines. (measure from due earth counterclockwise).
12
- - `bearingAngle` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** the mean angle of all lines. (bearing).
13
- - `circularVariance` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** the extent to which features all point in the same direction.
14
- the value ranges 0-1, the bigger the value, the more variation in directions between lines.
15
- - `averageX` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** the centroid of all lines.
16
- - `averageY` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** the centroid of all line.
17
- - `averageLength` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** the average length of line.
18
- - `countOfLines` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** the count of features.
11
+ * `cartesianAngle` **[number][2]** the mean angle of all lines. (measure from due earth counterclockwise).
12
+ * `bearingAngle` **[number][2]** the mean angle of all lines. (bearing).
13
+ * `circularVariance` **[number][2]** the extent to which features all point in the same direction.
14
+ the value ranges 0-1, the bigger the value, the more variation in directions between lines.
15
+ * `averageX` **[number][2]** the centroid of all lines.
16
+ * `averageY` **[number][2]** the centroid of all line.
17
+ * `averageLength` **[number][2]** the average length of line.
18
+ * `countOfLines` **[number][2]** the count of features.
19
19
 
20
20
  ## directionalMean
21
21
 
@@ -23,14 +23,15 @@ This module calculate the average angle of a set of lines, measuring the trend o
23
23
  It can be used in both project coordinate system and geography coordinate system.
24
24
  It can handle segments of line or the whole line.
25
25
 
26
- **Parameters**
26
+ ### Parameters
27
27
 
28
- - `lines` **[FeatureCollection](https://tools.ietf.org/html/rfc7946#section-3.3)<[LineString](https://tools.ietf.org/html/rfc7946#section-3.1.4)>**
29
- - `options` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (optional, default `{}`)
30
- - `options.planar` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** whether the spatial reference system is projected or geographical. (optional, default `true`)
31
- - `options.segment` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** whether treat a LineString as a whole or a set of segments. (optional, default `false`)
28
+ * `lines` **[FeatureCollection][3]<[LineString][4]>**
29
+ * `options` **[object][1]** (optional, default `{}`)
32
30
 
33
- **Examples**
31
+ * `options.planar` **[boolean][5]** whether the spatial reference system is projected or geographical. (optional, default `true`)
32
+ * `options.segment` **[boolean][5]** whether treat a LineString as a whole or a set of segments. (optional, default `false`)
33
+
34
+ ### Examples
34
35
 
35
36
  ```javascript
36
37
  var lines = turf.lineStrings([
@@ -41,7 +42,19 @@ var directionalMeanLine = turf.directionalMean(lines);
41
42
  // => directionalMeanLine
42
43
  ```
43
44
 
44
- Returns **[DirectionalMeanLine](#directionalmeanline)** Directional Mean Line
45
+ Returns **[DirectionalMeanLine][6]** Directional Mean Line
46
+
47
+ [1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
48
+
49
+ [2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
50
+
51
+ [3]: https://tools.ietf.org/html/rfc7946#section-3.3
52
+
53
+ [4]: https://tools.ietf.org/html/rfc7946#section-3.1.4
54
+
55
+ [5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
56
+
57
+ [6]: #directionalmeanline
45
58
 
46
59
  <!-- This file is automatically generated. Please don't edit it directly:
47
60
  if you find an error, edit the source file (likely index.js), and re-run
package/dist/es/index.js CHANGED
@@ -35,20 +35,19 @@ import { featureEach, segmentEach, segmentReduce } from "@turf/meta";
35
35
  * var directionalMeanLine = turf.directionalMean(lines);
36
36
  * // => directionalMeanLine
37
37
  */
38
- export default function directionalMean(lines, options) {
39
- if (options === void 0) { options = {}; }
40
- var isPlanar = !!options.planar; // you can't use options.planar || true here.
41
- var isSegment = options.segment || false;
42
- var sigmaSin = 0;
43
- var sigmaCos = 0;
44
- var countOfLines = 0;
45
- var sumOfLen = 0;
46
- var centroidList = [];
38
+ export default function directionalMean(lines, options = {}) {
39
+ const isPlanar = !!options.planar; // you can't use options.planar || true here.
40
+ const isSegment = options.segment || false;
41
+ let sigmaSin = 0;
42
+ let sigmaCos = 0;
43
+ let countOfLines = 0;
44
+ let sumOfLen = 0;
45
+ const centroidList = [];
47
46
  if (isSegment) {
48
- segmentEach(lines, function (currentSegment) {
47
+ segmentEach(lines, (currentSegment) => {
49
48
  // todo fix turf-meta's declaration file
50
- var _a = getCosAndSin(currentSegment.geometry.coordinates, isPlanar), sin1 = _a[0], cos1 = _a[1];
51
- var lenOfLine = getLengthOfLineString(currentSegment, isPlanar);
49
+ const [sin1, cos1] = getCosAndSin(currentSegment.geometry.coordinates, isPlanar);
50
+ const lenOfLine = getLengthOfLineString(currentSegment, isPlanar);
52
51
  if (isNaN(sin1) || isNaN(cos1)) {
53
52
  return;
54
53
  }
@@ -64,12 +63,12 @@ export default function directionalMean(lines, options) {
64
63
  }
65
64
  else {
66
65
  // planar and non-segment
67
- featureEach(lines, function (currentFeature) {
66
+ featureEach(lines, (currentFeature) => {
68
67
  if (currentFeature.geometry.type !== "LineString") {
69
68
  throw new Error("shold to support MultiLineString?");
70
69
  }
71
- var _a = getCosAndSin(currentFeature.geometry.coordinates, isPlanar), sin1 = _a[0], cos1 = _a[1];
72
- var lenOfLine = getLengthOfLineString(currentFeature, isPlanar);
70
+ const [sin1, cos1] = getCosAndSin(currentFeature.geometry.coordinates, isPlanar);
71
+ const lenOfLine = getLengthOfLineString(currentFeature, isPlanar);
73
72
  if (isNaN(sin1) || isNaN(cos1)) {
74
73
  return;
75
74
  }
@@ -82,13 +81,13 @@ export default function directionalMean(lines, options) {
82
81
  }
83
82
  });
84
83
  }
85
- var cartesianAngle = getAngleBySinAndCos(sigmaSin, sigmaCos);
86
- var bearingAngle = bearingToCartesian(cartesianAngle);
87
- var circularVariance = getCircularVariance(sigmaSin, sigmaCos, countOfLines);
88
- var averageLength = sumOfLen / countOfLines;
89
- var centroidOfLines = centroid(featureCollection(centroidList));
90
- var _a = getCoord(centroidOfLines), averageX = _a[0], averageY = _a[1];
91
- var meanLinestring;
84
+ const cartesianAngle = getAngleBySinAndCos(sigmaSin, sigmaCos);
85
+ const bearingAngle = bearingToCartesian(cartesianAngle);
86
+ const circularVariance = getCircularVariance(sigmaSin, sigmaCos, countOfLines);
87
+ const averageLength = sumOfLen / countOfLines;
88
+ const centroidOfLines = centroid(featureCollection(centroidList));
89
+ const [averageX, averageY] = getCoord(centroidOfLines);
90
+ let meanLinestring;
92
91
  if (isPlanar) {
93
92
  meanLinestring = getMeanLineString([averageX, averageY], cartesianAngle, averageLength, isPlanar);
94
93
  }
@@ -96,13 +95,13 @@ export default function directionalMean(lines, options) {
96
95
  meanLinestring = getMeanLineString([averageX, averageY], bearingAngle, averageLength, isPlanar);
97
96
  }
98
97
  return lineString(meanLinestring, {
99
- averageLength: averageLength,
100
- averageX: averageX,
101
- averageY: averageY,
102
- bearingAngle: bearingAngle,
103
- cartesianAngle: cartesianAngle,
104
- circularVariance: circularVariance,
105
- countOfLines: countOfLines,
98
+ averageLength,
99
+ averageX,
100
+ averageY,
101
+ bearingAngle,
102
+ cartesianAngle,
103
+ circularVariance,
104
+ countOfLines,
106
105
  });
107
106
  }
108
107
  /**
@@ -112,10 +111,10 @@ export default function directionalMean(lines, options) {
112
111
  * @param coords
113
112
  */
114
113
  function euclideanDistance(coords) {
115
- var _a = coords[0], x0 = _a[0], y0 = _a[1];
116
- var _b = coords[1], x1 = _b[0], y1 = _b[1];
117
- var dx = x1 - x0;
118
- var dy = y1 - y0;
114
+ const [x0, y0] = coords[0];
115
+ const [x1, y1] = coords[1];
116
+ const dx = x1 - x0;
117
+ const dy = y1 - y0;
119
118
  return Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
120
119
  }
121
120
  /**
@@ -127,8 +126,8 @@ function euclideanDistance(coords) {
127
126
  */
128
127
  function getLengthOfLineString(line, isPlanar) {
129
128
  if (isPlanar) {
130
- return segmentReduce(line, function (previousValue, segment) {
131
- var coords = segment.geometry.coordinates; // the signatrue of segmentReduce has problem ?
129
+ return segmentReduce(line, (previousValue, segment) => {
130
+ const coords = segment.geometry.coordinates; // the signatrue of segmentReduce has problem ?
132
131
  return previousValue + euclideanDistance(coords);
133
132
  }, 0);
134
133
  }
@@ -146,7 +145,7 @@ function getLengthOfLineString(line, isPlanar) {
146
145
  * @param angle
147
146
  */
148
147
  function bearingToCartesian(angle) {
149
- var result = 90 - angle;
148
+ let result = 90 - angle;
150
149
  if (result > 180) {
151
150
  result -= 360;
152
151
  }
@@ -159,29 +158,29 @@ function bearingToCartesian(angle) {
159
158
  * @returns {Array<number>} [cos, sin]
160
159
  */
161
160
  function getCosAndSin(coordinates, isPlanar) {
162
- var beginPoint = coordinates[0];
163
- var endPoint = coordinates[coordinates.length - 1];
161
+ const beginPoint = coordinates[0];
162
+ const endPoint = coordinates[coordinates.length - 1];
164
163
  if (isPlanar) {
165
- var x0 = beginPoint[0], y0 = beginPoint[1];
166
- var x1 = endPoint[0], y1 = endPoint[1];
167
- var dx = x1 - x0;
168
- var dy = y1 - y0;
169
- var h = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
164
+ const [x0, y0] = beginPoint;
165
+ const [x1, y1] = endPoint;
166
+ const dx = x1 - x0;
167
+ const dy = y1 - y0;
168
+ const h = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
170
169
  if (h < 0.000000001) {
171
170
  return [NaN, NaN];
172
171
  }
173
- var sin1 = dy / h;
174
- var cos1 = dx / h;
172
+ const sin1 = dy / h;
173
+ const cos1 = dx / h;
175
174
  return [sin1, cos1];
176
175
  }
177
176
  else {
178
- var angle = bearingToCartesian(bearing(beginPoint, endPoint));
179
- var radian = (angle * Math.PI) / 180;
177
+ const angle = bearingToCartesian(bearing(beginPoint, endPoint));
178
+ const radian = (angle * Math.PI) / 180;
180
179
  return [Math.sin(radian), Math.cos(radian)];
181
180
  }
182
181
  }
183
182
  function getAngleBySinAndCos(sin1, cos1) {
184
- var angle = 0;
183
+ let angle = 0;
185
184
  if (Math.abs(cos1) < 0.000000001) {
186
185
  angle = 90;
187
186
  }
@@ -208,14 +207,14 @@ function getCircularVariance(sin1, cos1, len) {
208
207
  }
209
208
  function getMeanLineString(centroidOfLine, angle, lenOfLine, isPlanar) {
210
209
  if (isPlanar) {
211
- var averageX = centroidOfLine[0], averageY = centroidOfLine[1];
212
- var beginX = void 0;
213
- var beginY = void 0;
214
- var endX = void 0;
215
- var endY = void 0;
216
- var r = (angle * Math.PI) / 180;
217
- var sin = Math.sin(r);
218
- var cos = Math.cos(r);
210
+ const [averageX, averageY] = centroidOfLine;
211
+ let beginX;
212
+ let beginY;
213
+ let endX;
214
+ let endY;
215
+ const r = (angle * Math.PI) / 180;
216
+ const sin = Math.sin(r);
217
+ const cos = Math.cos(r);
219
218
  beginX = averageX - (lenOfLine / 2) * cos;
220
219
  beginY = averageY - (lenOfLine / 2) * sin;
221
220
  endX = averageX + (lenOfLine / 2) * cos;
@@ -226,10 +225,10 @@ function getMeanLineString(centroidOfLine, angle, lenOfLine, isPlanar) {
226
225
  ];
227
226
  }
228
227
  else {
229
- var end = destination(point(centroidOfLine), lenOfLine / 2, angle, {
228
+ const end = destination(point(centroidOfLine), lenOfLine / 2, angle, {
230
229
  units: "meters",
231
230
  });
232
- var begin = destination(point(centroidOfLine), -lenOfLine / 2, angle, {
231
+ const begin = destination(point(centroidOfLine), -lenOfLine / 2, angle, {
233
232
  units: "meters",
234
233
  });
235
234
  return [getCoord(begin), getCoord(end)];
@@ -1,4 +1,4 @@
1
- import { Feature, FeatureCollection, LineString } from "@turf/helpers";
1
+ import { Feature, FeatureCollection, LineString } from "geojson";
2
2
  export interface DirectionalMeanLine extends Feature<LineString> {
3
3
  properties: {
4
4
  cartesianAngle: number;
package/dist/js/index.js CHANGED
@@ -1,15 +1,13 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- var bearing_1 = __importDefault(require("@turf/bearing"));
7
- var centroid_1 = __importDefault(require("@turf/centroid"));
8
- var destination_1 = __importDefault(require("@turf/destination"));
9
- var helpers_1 = require("@turf/helpers");
10
- var invariant_1 = require("@turf/invariant");
11
- var length_1 = __importDefault(require("@turf/length"));
12
- var meta_1 = require("@turf/meta");
3
+ const tslib_1 = require("tslib");
4
+ const bearing_1 = tslib_1.__importDefault(require("@turf/bearing"));
5
+ const centroid_1 = tslib_1.__importDefault(require("@turf/centroid"));
6
+ const destination_1 = tslib_1.__importDefault(require("@turf/destination"));
7
+ const helpers_1 = require("@turf/helpers");
8
+ const invariant_1 = require("@turf/invariant");
9
+ const length_1 = tslib_1.__importDefault(require("@turf/length"));
10
+ const meta_1 = require("@turf/meta");
13
11
  /**
14
12
  * @typedef {Object} DirectionalMeanLine
15
13
  * @property {number} cartesianAngle the mean angle of all lines. (measure from due earth counterclockwise).
@@ -40,20 +38,19 @@ var meta_1 = require("@turf/meta");
40
38
  * var directionalMeanLine = turf.directionalMean(lines);
41
39
  * // => directionalMeanLine
42
40
  */
43
- function directionalMean(lines, options) {
44
- if (options === void 0) { options = {}; }
45
- var isPlanar = !!options.planar; // you can't use options.planar || true here.
46
- var isSegment = options.segment || false;
47
- var sigmaSin = 0;
48
- var sigmaCos = 0;
49
- var countOfLines = 0;
50
- var sumOfLen = 0;
51
- var centroidList = [];
41
+ function directionalMean(lines, options = {}) {
42
+ const isPlanar = !!options.planar; // you can't use options.planar || true here.
43
+ const isSegment = options.segment || false;
44
+ let sigmaSin = 0;
45
+ let sigmaCos = 0;
46
+ let countOfLines = 0;
47
+ let sumOfLen = 0;
48
+ const centroidList = [];
52
49
  if (isSegment) {
53
- meta_1.segmentEach(lines, function (currentSegment) {
50
+ meta_1.segmentEach(lines, (currentSegment) => {
54
51
  // todo fix turf-meta's declaration file
55
- var _a = getCosAndSin(currentSegment.geometry.coordinates, isPlanar), sin1 = _a[0], cos1 = _a[1];
56
- var lenOfLine = getLengthOfLineString(currentSegment, isPlanar);
52
+ const [sin1, cos1] = getCosAndSin(currentSegment.geometry.coordinates, isPlanar);
53
+ const lenOfLine = getLengthOfLineString(currentSegment, isPlanar);
57
54
  if (isNaN(sin1) || isNaN(cos1)) {
58
55
  return;
59
56
  }
@@ -69,12 +66,12 @@ function directionalMean(lines, options) {
69
66
  }
70
67
  else {
71
68
  // planar and non-segment
72
- meta_1.featureEach(lines, function (currentFeature) {
69
+ meta_1.featureEach(lines, (currentFeature) => {
73
70
  if (currentFeature.geometry.type !== "LineString") {
74
71
  throw new Error("shold to support MultiLineString?");
75
72
  }
76
- var _a = getCosAndSin(currentFeature.geometry.coordinates, isPlanar), sin1 = _a[0], cos1 = _a[1];
77
- var lenOfLine = getLengthOfLineString(currentFeature, isPlanar);
73
+ const [sin1, cos1] = getCosAndSin(currentFeature.geometry.coordinates, isPlanar);
74
+ const lenOfLine = getLengthOfLineString(currentFeature, isPlanar);
78
75
  if (isNaN(sin1) || isNaN(cos1)) {
79
76
  return;
80
77
  }
@@ -87,13 +84,13 @@ function directionalMean(lines, options) {
87
84
  }
88
85
  });
89
86
  }
90
- var cartesianAngle = getAngleBySinAndCos(sigmaSin, sigmaCos);
91
- var bearingAngle = bearingToCartesian(cartesianAngle);
92
- var circularVariance = getCircularVariance(sigmaSin, sigmaCos, countOfLines);
93
- var averageLength = sumOfLen / countOfLines;
94
- var centroidOfLines = centroid_1.default(helpers_1.featureCollection(centroidList));
95
- var _a = invariant_1.getCoord(centroidOfLines), averageX = _a[0], averageY = _a[1];
96
- var meanLinestring;
87
+ const cartesianAngle = getAngleBySinAndCos(sigmaSin, sigmaCos);
88
+ const bearingAngle = bearingToCartesian(cartesianAngle);
89
+ const circularVariance = getCircularVariance(sigmaSin, sigmaCos, countOfLines);
90
+ const averageLength = sumOfLen / countOfLines;
91
+ const centroidOfLines = centroid_1.default(helpers_1.featureCollection(centroidList));
92
+ const [averageX, averageY] = invariant_1.getCoord(centroidOfLines);
93
+ let meanLinestring;
97
94
  if (isPlanar) {
98
95
  meanLinestring = getMeanLineString([averageX, averageY], cartesianAngle, averageLength, isPlanar);
99
96
  }
@@ -101,13 +98,13 @@ function directionalMean(lines, options) {
101
98
  meanLinestring = getMeanLineString([averageX, averageY], bearingAngle, averageLength, isPlanar);
102
99
  }
103
100
  return helpers_1.lineString(meanLinestring, {
104
- averageLength: averageLength,
105
- averageX: averageX,
106
- averageY: averageY,
107
- bearingAngle: bearingAngle,
108
- cartesianAngle: cartesianAngle,
109
- circularVariance: circularVariance,
110
- countOfLines: countOfLines,
101
+ averageLength,
102
+ averageX,
103
+ averageY,
104
+ bearingAngle,
105
+ cartesianAngle,
106
+ circularVariance,
107
+ countOfLines,
111
108
  });
112
109
  }
113
110
  exports.default = directionalMean;
@@ -118,10 +115,10 @@ exports.default = directionalMean;
118
115
  * @param coords
119
116
  */
120
117
  function euclideanDistance(coords) {
121
- var _a = coords[0], x0 = _a[0], y0 = _a[1];
122
- var _b = coords[1], x1 = _b[0], y1 = _b[1];
123
- var dx = x1 - x0;
124
- var dy = y1 - y0;
118
+ const [x0, y0] = coords[0];
119
+ const [x1, y1] = coords[1];
120
+ const dx = x1 - x0;
121
+ const dy = y1 - y0;
125
122
  return Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
126
123
  }
127
124
  /**
@@ -133,8 +130,8 @@ function euclideanDistance(coords) {
133
130
  */
134
131
  function getLengthOfLineString(line, isPlanar) {
135
132
  if (isPlanar) {
136
- return meta_1.segmentReduce(line, function (previousValue, segment) {
137
- var coords = segment.geometry.coordinates; // the signatrue of segmentReduce has problem ?
133
+ return meta_1.segmentReduce(line, (previousValue, segment) => {
134
+ const coords = segment.geometry.coordinates; // the signatrue of segmentReduce has problem ?
138
135
  return previousValue + euclideanDistance(coords);
139
136
  }, 0);
140
137
  }
@@ -152,7 +149,7 @@ function getLengthOfLineString(line, isPlanar) {
152
149
  * @param angle
153
150
  */
154
151
  function bearingToCartesian(angle) {
155
- var result = 90 - angle;
152
+ let result = 90 - angle;
156
153
  if (result > 180) {
157
154
  result -= 360;
158
155
  }
@@ -165,29 +162,29 @@ function bearingToCartesian(angle) {
165
162
  * @returns {Array<number>} [cos, sin]
166
163
  */
167
164
  function getCosAndSin(coordinates, isPlanar) {
168
- var beginPoint = coordinates[0];
169
- var endPoint = coordinates[coordinates.length - 1];
165
+ const beginPoint = coordinates[0];
166
+ const endPoint = coordinates[coordinates.length - 1];
170
167
  if (isPlanar) {
171
- var x0 = beginPoint[0], y0 = beginPoint[1];
172
- var x1 = endPoint[0], y1 = endPoint[1];
173
- var dx = x1 - x0;
174
- var dy = y1 - y0;
175
- var h = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
168
+ const [x0, y0] = beginPoint;
169
+ const [x1, y1] = endPoint;
170
+ const dx = x1 - x0;
171
+ const dy = y1 - y0;
172
+ const h = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
176
173
  if (h < 0.000000001) {
177
174
  return [NaN, NaN];
178
175
  }
179
- var sin1 = dy / h;
180
- var cos1 = dx / h;
176
+ const sin1 = dy / h;
177
+ const cos1 = dx / h;
181
178
  return [sin1, cos1];
182
179
  }
183
180
  else {
184
- var angle = bearingToCartesian(bearing_1.default(beginPoint, endPoint));
185
- var radian = (angle * Math.PI) / 180;
181
+ const angle = bearingToCartesian(bearing_1.default(beginPoint, endPoint));
182
+ const radian = (angle * Math.PI) / 180;
186
183
  return [Math.sin(radian), Math.cos(radian)];
187
184
  }
188
185
  }
189
186
  function getAngleBySinAndCos(sin1, cos1) {
190
- var angle = 0;
187
+ let angle = 0;
191
188
  if (Math.abs(cos1) < 0.000000001) {
192
189
  angle = 90;
193
190
  }
@@ -214,14 +211,14 @@ function getCircularVariance(sin1, cos1, len) {
214
211
  }
215
212
  function getMeanLineString(centroidOfLine, angle, lenOfLine, isPlanar) {
216
213
  if (isPlanar) {
217
- var averageX = centroidOfLine[0], averageY = centroidOfLine[1];
218
- var beginX = void 0;
219
- var beginY = void 0;
220
- var endX = void 0;
221
- var endY = void 0;
222
- var r = (angle * Math.PI) / 180;
223
- var sin = Math.sin(r);
224
- var cos = Math.cos(r);
214
+ const [averageX, averageY] = centroidOfLine;
215
+ let beginX;
216
+ let beginY;
217
+ let endX;
218
+ let endY;
219
+ const r = (angle * Math.PI) / 180;
220
+ const sin = Math.sin(r);
221
+ const cos = Math.cos(r);
225
222
  beginX = averageX - (lenOfLine / 2) * cos;
226
223
  beginY = averageY - (lenOfLine / 2) * sin;
227
224
  endX = averageX + (lenOfLine / 2) * cos;
@@ -232,10 +229,10 @@ function getMeanLineString(centroidOfLine, angle, lenOfLine, isPlanar) {
232
229
  ];
233
230
  }
234
231
  else {
235
- var end = destination_1.default(helpers_1.point(centroidOfLine), lenOfLine / 2, angle, {
232
+ const end = destination_1.default(helpers_1.point(centroidOfLine), lenOfLine / 2, angle, {
236
233
  units: "meters",
237
234
  });
238
- var begin = destination_1.default(helpers_1.point(centroidOfLine), -lenOfLine / 2, angle, {
235
+ const begin = destination_1.default(helpers_1.point(centroidOfLine), -lenOfLine / 2, angle, {
239
236
  units: "meters",
240
237
  });
241
238
  return [invariant_1.getCoord(begin), invariant_1.getCoord(end)];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turf/directional-mean",
3
- "version": "6.4.0",
3
+ "version": "7.0.0-alpha.0",
4
4
  "description": "turf directional-mean module",
5
5
  "author": "Turf Authors",
6
6
  "contributors": [
@@ -15,6 +15,7 @@
15
15
  "type": "git",
16
16
  "url": "git://github.com/Turfjs/turf.git"
17
17
  },
18
+ "funding": "https://opencollective.com/turf",
18
19
  "publishConfig": {
19
20
  "access": "public"
20
21
  },
@@ -57,13 +58,14 @@
57
58
  "write-json-file": "*"
58
59
  },
59
60
  "dependencies": {
60
- "@turf/bearing": "^6.4.0",
61
- "@turf/centroid": "^6.4.0",
62
- "@turf/destination": "^6.4.0",
63
- "@turf/helpers": "^6.4.0",
64
- "@turf/invariant": "^6.4.0",
65
- "@turf/length": "^6.4.0",
66
- "@turf/meta": "^6.4.0"
61
+ "@turf/bearing": "^7.0.0-alpha.0",
62
+ "@turf/centroid": "^7.0.0-alpha.0",
63
+ "@turf/destination": "^7.0.0-alpha.0",
64
+ "@turf/helpers": "^7.0.0-alpha.0",
65
+ "@turf/invariant": "^7.0.0-alpha.0",
66
+ "@turf/length": "^7.0.0-alpha.0",
67
+ "@turf/meta": "^7.0.0-alpha.0",
68
+ "tslib": "^2.3.0"
67
69
  },
68
- "gitHead": "1e62773cfc88c627cca8effcb5c14cfb65a905ac"
70
+ "gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189"
69
71
  }