@turf/directional-mean 7.0.0 → 7.1.0-alpha.7
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/dist/cjs/index.cjs +1 -12
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +0 -11
- package/dist/esm/index.js.map +1 -1
- package/package.json +9 -9
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true})
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
|
-
// index.ts
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// index.ts
|
|
5
2
|
var _bearing = require('@turf/bearing');
|
|
6
3
|
var _centroid = require('@turf/centroid');
|
|
7
4
|
var _destination = require('@turf/destination');
|
|
@@ -92,7 +89,6 @@ function directionalMean(lines, options = {}) {
|
|
|
92
89
|
countOfLines
|
|
93
90
|
});
|
|
94
91
|
}
|
|
95
|
-
__name(directionalMean, "directionalMean");
|
|
96
92
|
function euclideanDistance(coords) {
|
|
97
93
|
const [x0, y0] = coords[0];
|
|
98
94
|
const [x1, y1] = coords[1];
|
|
@@ -100,7 +96,6 @@ function euclideanDistance(coords) {
|
|
|
100
96
|
const dy = y1 - y0;
|
|
101
97
|
return Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
|
|
102
98
|
}
|
|
103
|
-
__name(euclideanDistance, "euclideanDistance");
|
|
104
99
|
function getLengthOfLineString(line, isPlanar) {
|
|
105
100
|
if (isPlanar) {
|
|
106
101
|
return _meta.segmentReduce.call(void 0,
|
|
@@ -117,7 +112,6 @@ function getLengthOfLineString(line, isPlanar) {
|
|
|
117
112
|
});
|
|
118
113
|
}
|
|
119
114
|
}
|
|
120
|
-
__name(getLengthOfLineString, "getLengthOfLineString");
|
|
121
115
|
function bearingToCartesian(angle) {
|
|
122
116
|
let result = 90 - angle;
|
|
123
117
|
if (result > 180) {
|
|
@@ -125,7 +119,6 @@ function bearingToCartesian(angle) {
|
|
|
125
119
|
}
|
|
126
120
|
return result;
|
|
127
121
|
}
|
|
128
|
-
__name(bearingToCartesian, "bearingToCartesian");
|
|
129
122
|
function getCosAndSin(coordinates, isPlanar) {
|
|
130
123
|
const beginPoint = coordinates[0];
|
|
131
124
|
const endPoint = coordinates[coordinates.length - 1];
|
|
@@ -147,7 +140,6 @@ function getCosAndSin(coordinates, isPlanar) {
|
|
|
147
140
|
return [Math.sin(radian), Math.cos(radian)];
|
|
148
141
|
}
|
|
149
142
|
}
|
|
150
|
-
__name(getCosAndSin, "getCosAndSin");
|
|
151
143
|
function getAngleBySinAndCos(sin1, cos1) {
|
|
152
144
|
let angle = 0;
|
|
153
145
|
if (Math.abs(cos1) < 1e-9) {
|
|
@@ -166,14 +158,12 @@ function getAngleBySinAndCos(sin1, cos1) {
|
|
|
166
158
|
}
|
|
167
159
|
return angle;
|
|
168
160
|
}
|
|
169
|
-
__name(getAngleBySinAndCos, "getAngleBySinAndCos");
|
|
170
161
|
function getCircularVariance(sin1, cos1, len) {
|
|
171
162
|
if (len === 0) {
|
|
172
163
|
throw new Error("the size of the features set must be greater than 0");
|
|
173
164
|
}
|
|
174
165
|
return 1 - Math.sqrt(Math.pow(sin1, 2) + Math.pow(cos1, 2)) / len;
|
|
175
166
|
}
|
|
176
|
-
__name(getCircularVariance, "getCircularVariance");
|
|
177
167
|
function getMeanLineString(centroidOfLine, angle, lenOfLine, isPlanar) {
|
|
178
168
|
if (isPlanar) {
|
|
179
169
|
const [averageX, averageY] = centroidOfLine;
|
|
@@ -202,7 +192,6 @@ function getMeanLineString(centroidOfLine, angle, lenOfLine, isPlanar) {
|
|
|
202
192
|
return [_invariant.getCoord.call(void 0, begin), _invariant.getCoord.call(void 0, end)];
|
|
203
193
|
}
|
|
204
194
|
}
|
|
205
|
-
__name(getMeanLineString, "getMeanLineString");
|
|
206
195
|
var turf_directional_mean_default = directionalMean;
|
|
207
196
|
|
|
208
197
|
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.ts"],"names":[],"mappings":";;;;AACA,SAAS,eAAe;AACxB,SAAS,gBAAgB;AACzB,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB,YAAY,aAAa;AACrD,SAAS,gBAAgB;AACzB,SAAS,cAAc;AACvB,SAAS,aAAa,aAAa,qBAAqB;AA8CxD,SAAS,gBACP,OACA,UAGI,CAAC,GACgB;AA3DvB;AA4DE,QAAM,WAAW,CAAC,CAAC,QAAQ;AAC3B,QAAM,aAAqB,aAAQ,YAAR,YAAmB;AAC9C,MAAI,WAAW;AACf,MAAI,WAAW;AACf,MAAI,eAAe;AACnB,MAAI,WAAW;AACf,QAAM,eAAsC,CAAC;AAE7C,MAAI,WAAW;AACb,gBAAY,OAAO,CAAC,mBAAwB;AAE1C,YAAM,CAAC,MAAM,IAAI,IAAsB;AAAA,QACrC,eAAe,SAAS;AAAA,QACxB;AAAA,MACF;AACA,YAAM,YAAY,sBAAsB,gBAAgB,QAAQ;AAChE,UAAI,MAAM,IAAI,KAAK,MAAM,IAAI,GAAG;AAC9B;AAAA,MACF,OAAO;AACL,oBAAY;AACZ,oBAAY;AACZ,wBAAgB;AAChB,oBAAY;AACZ,qBAAa,KAAK,SAAS,cAAc,CAAC;AAAA,MAC5C;AAAA,IACF,CAAC;AAAA,EAEH,OAAO;AAEL,gBAAY,OAAO,CAAC,mBAAwC;AAC1D,UAAI,eAAe,SAAS,SAAS,cAAc;AACjD,cAAM,IAAI,MAAM,mCAAmC;AAAA,MACrD;AACA,YAAM,CAAC,MAAM,IAAI,IAAsB;AAAA,QACrC,eAAe,SAAS;AAAA,QACxB;AAAA,MACF;AACA,YAAM,YAAY,sBAAsB,gBAAgB,QAAQ;AAChE,UAAI,MAAM,IAAI,KAAK,MAAM,IAAI,GAAG;AAC9B;AAAA,MACF,OAAO;AACL,o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F;AACA,SAAO;AACT;AAjBS;AAmBT,SAAS,oBAAoB,MAAc,MAAc,KAAa;AACpE,MAAI,QAAQ,GAAG;AACb,UAAM,IAAI,MAAM,qDAAqD;AAAA,EACvE;AACA,SAAO,IAAI,KAAK,KAAK,KAAK,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI,MAAM,CAAC,CAAC,IAAI;AAChE;AALS;AAOT,SAAS,kBACP,gBACA,OACA,WACA,UACA;AACA,MAAI,UAAU;AACZ,UAAM,CAAC,UAAU,QAAQ,IAAc;AACvC,QAAI;AACJ,QAAI;AACJ,QAAI;AACJ,QAAI;AACJ,UAAM,IAAa,QAAQ,KAAK,KAAM;AACtC,UAAM,MAAc,KAAK,IAAI,CAAC;AAC9B,UAAM,MAAc,KAAK,IAAI,CAAC;AAC9B,aAAS,WAAY,YAAY,IAAK;AACtC,aAAS,WAAY,YAAY,IAAK;AACtC,WAAO,WAAY,YAAY,IAAK;AACpC,WAAO,WAAY,YAAY,IAAK;AACpC,WAAO;AAAA,MACL,CAAC,QAAQ,MAAM;AAAA,MACf,CAAC,MAAM,IAAI;AAAA,IACb;AAAA,EACF,OAAO;AACL,UAAM,MAAM,YAAY,MAAM,cAAc,GAAG,YAAY,GAAG,OAAO;AAAA,MACnE,OAAO;AAAA,IACT,CAAC;AACD,UAAM,QAAQ,YAAY,MAAM,cAAc,GAAG,CAAC,YAAY,GAAG,OAAO;AAAA,MACtE,OAAO;AAAA,IACT,CAAC;AACD,WAAO,CAAC,SAAS,KAAK,GAAG,SAAS,GAAG,CAAC;AAAA,EACxC;AACF;AAhCS;AAmCT,IAAO,gCAAQ","sourcesContent":["import { Feature, FeatureCollection, LineString, Point } from \"geojson\";\nimport { bearing } from \"@turf/bearing\";\nimport { centroid } from \"@turf/centroid\";\nimport { destination } from \"@turf/destination\";\nimport { featureCollection, lineString, point } from \"@turf/helpers\";\nimport { getCoord } from \"@turf/invariant\";\nimport { length } from \"@turf/length\";\nimport { featureEach, segmentEach, segmentReduce } from \"@turf/meta\";\n\ninterface DirectionalMeanLine extends Feature<LineString> {\n properties: {\n cartesianAngle: number;\n bearingAngle: number;\n circularVariance: number;\n averageX: number;\n averageY: number;\n averageLength: number;\n countOfLines: number;\n [key: string]: any;\n };\n}\n\n/**\n * @typedef {Object} DirectionalMeanLine\n * @property {number} cartesianAngle the mean angle of all lines. (measure from due earth counterclockwise).\n * @property {number} bearingAngle the mean angle of all lines. (bearing).\n * @property {number} circularVariance the extent to which features all point in the same direction.\n * the value ranges 0-1, the bigger the value, the more variation in directions between lines.\n * @property {number} averageX the centroid of all lines.\n * @property {number} averageY the centroid of all line.\n * @property {number} averageLength the average length of line.\n * @property {number} countOfLines the count of features.\n */\n\n/**\n * This module calculate the average angle of a set of lines, measuring the trend of it.\n * It can be used in both project coordinate system and geography coordinate system.\n * It can handle segments of line or the whole line.\n * @name directionalMean\n * @param {FeatureCollection<LineString>} lines\n * @param {object} [options={}]\n * @param {boolean} [options.planar=true] whether the spatial reference system is projected or geographical.\n * @param {boolean} [options.segment=false] whether treat a LineString as a whole or a set of segments.\n * @returns {DirectionalMeanLine} Directional Mean Line\n * @example\n *\n * var lines = turf.lineStrings([\n * [[110, 45], [120, 50]],\n * [[100, 50], [115, 55]],\n * ])\n * var directionalMeanLine = turf.directionalMean(lines);\n * // => directionalMeanLine\n */\nfunction directionalMean(\n lines: FeatureCollection<LineString>,\n options: {\n planar?: boolean;\n segment?: boolean;\n } = {}\n): DirectionalMeanLine {\n const isPlanar = !!options.planar; // you can't use options.planar || true here.\n const isSegment: boolean = options.segment ?? false;\n let sigmaSin = 0;\n let sigmaCos = 0;\n let countOfLines = 0;\n let sumOfLen = 0;\n const centroidList: Array<Feature<Point>> = [];\n\n if (isSegment) {\n segmentEach(lines, (currentSegment: any) => {\n // todo fix turf-meta's declaration file\n const [sin1, cos1]: [number, number] = getCosAndSin(\n currentSegment.geometry.coordinates,\n isPlanar\n );\n const lenOfLine = getLengthOfLineString(currentSegment, isPlanar);\n if (isNaN(sin1) || isNaN(cos1)) {\n return;\n } else {\n sigmaSin += sin1;\n sigmaCos += cos1;\n countOfLines += 1;\n sumOfLen += lenOfLine;\n centroidList.push(centroid(currentSegment));\n }\n });\n // planar and segment\n } else {\n // planar and non-segment\n featureEach(lines, (currentFeature: Feature<LineString>) => {\n if (currentFeature.geometry.type !== \"LineString\") {\n throw new Error(\"shold to support MultiLineString?\");\n }\n const [sin1, cos1]: [number, number] = getCosAndSin(\n currentFeature.geometry.coordinates,\n isPlanar\n );\n const lenOfLine = getLengthOfLineString(currentFeature, isPlanar);\n if (isNaN(sin1) || isNaN(cos1)) {\n return;\n } else {\n sigmaSin += sin1;\n sigmaCos += cos1;\n countOfLines += 1;\n sumOfLen += lenOfLine;\n centroidList.push(centroid(currentFeature));\n }\n });\n }\n\n const cartesianAngle: number = getAngleBySinAndCos(sigmaSin, sigmaCos);\n const bearingAngle: number = bearingToCartesian(cartesianAngle);\n const circularVariance = getCircularVariance(\n sigmaSin,\n sigmaCos,\n countOfLines\n );\n const averageLength = sumOfLen / countOfLines;\n const centroidOfLines = centroid(featureCollection(centroidList));\n const [averageX, averageY]: number[] = getCoord(centroidOfLines);\n let meanLinestring;\n if (isPlanar) {\n meanLinestring = getMeanLineString(\n [averageX, averageY],\n cartesianAngle,\n averageLength,\n isPlanar\n );\n } else {\n meanLinestring = getMeanLineString(\n [averageX, averageY],\n bearingAngle,\n averageLength,\n isPlanar\n );\n }\n\n return lineString(meanLinestring, {\n averageLength,\n averageX,\n averageY,\n bearingAngle,\n cartesianAngle,\n circularVariance,\n countOfLines,\n });\n}\n\n/**\n * get euclidean distance between two points.\n * @private\n * @name euclideanDistance\n * @param coords\n */\nfunction euclideanDistance(coords: number[][]) {\n const [x0, y0]: number[] = coords[0];\n const [x1, y1]: number[] = coords[1];\n const dx: number = x1 - x0;\n const dy: number = y1 - y0;\n return Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));\n}\n\n/**\n * get the length of a LineString, both in projected or geographical coordinate system.\n * @private\n * @name getLengthOfLineString\n * @param {Feature<LineString>} line\n * @param {boolean} isPlanar\n */\nfunction getLengthOfLineString(line: Feature<LineString>, isPlanar: boolean) {\n if (isPlanar) {\n return segmentReduce<number>(\n line,\n (previousValue?: number, segment?: Feature<LineString>): number => {\n const coords = segment!.geometry.coordinates; // the signatrue of segmentReduce has problem ?\n return previousValue! + euclideanDistance(coords);\n },\n 0\n );\n } else {\n return length(line, {\n units: \"meters\",\n });\n }\n}\n\n/**\n * bearing to xy(from due earth counterclockwise 0-180)\n * convert between two forms\n * @private\n * @name bearingToCartesian\n * @param angle\n */\nfunction bearingToCartesian(angle: number): number {\n let result = 90 - angle;\n if (result > 180) {\n result -= 360;\n }\n return result;\n}\n\n/**\n * @private\n * @name getCosAndSin\n * @param {Array<Array<number>>} coordinates\n * @returns {Array<number>} [cos, sin]\n */\nfunction getCosAndSin(\n coordinates: number[][],\n isPlanar: boolean\n): [number, number] {\n const beginPoint: number[] = coordinates[0];\n const endPoint: number[] = coordinates[coordinates.length - 1];\n if (isPlanar) {\n const [x0, y0]: number[] = beginPoint;\n const [x1, y1]: number[] = endPoint;\n const dx: number = x1 - x0;\n const dy: number = y1 - y0;\n const h = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));\n if (h < 0.000000001) {\n return [NaN, NaN];\n }\n const sin1 = dy / h;\n const cos1 = dx / h;\n return [sin1, cos1];\n } else {\n const angle = bearingToCartesian(bearing(beginPoint, endPoint));\n const radian = (angle * Math.PI) / 180;\n return [Math.sin(radian), Math.cos(radian)];\n }\n}\n\nfunction getAngleBySinAndCos(sin1: number, cos1: number): number {\n let angle = 0;\n if (Math.abs(cos1) < 0.000000001) {\n angle = 90;\n } else {\n angle = (Math.atan2(sin1, cos1) * 180) / Math.PI;\n }\n if (sin1 >= 0) {\n if (cos1 < 0) {\n angle += 180;\n }\n } else {\n if (cos1 < 0) {\n angle -= 180;\n }\n }\n return angle;\n}\n\nfunction getCircularVariance(sin1: number, cos1: number, len: number) {\n if (len === 0) {\n throw new Error(\"the size of the features set must be greater than 0\");\n }\n return 1 - Math.sqrt(Math.pow(sin1, 2) + Math.pow(cos1, 2)) / len;\n}\n\nfunction getMeanLineString(\n centroidOfLine: number[],\n angle: number,\n lenOfLine: number,\n isPlanar: boolean\n) {\n if (isPlanar) {\n const [averageX, averageY]: number[] = centroidOfLine;\n let beginX: number;\n let beginY: number;\n let endX: number;\n let endY: number;\n const r: number = (angle * Math.PI) / 180;\n const sin: number = Math.sin(r);\n const cos: number = Math.cos(r);\n beginX = averageX - (lenOfLine / 2) * cos;\n beginY = averageY - (lenOfLine / 2) * sin;\n endX = averageX + (lenOfLine / 2) * cos;\n endY = averageY + (lenOfLine / 2) * sin;\n return [\n [beginX, beginY],\n [endX, endY],\n ];\n } else {\n const end = destination(point(centroidOfLine), lenOfLine / 2, angle, {\n units: \"meters\",\n });\n const begin = destination(point(centroidOfLine), -lenOfLine / 2, angle, {\n units: \"meters\",\n });\n return [getCoord(begin), getCoord(end)];\n }\n}\n\nexport { directionalMean, DirectionalMeanLine };\nexport default directionalMean;\n"]}
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"names":[],"mappings":";AACA,SAAS,eAAe;AACxB,SAAS,gBAAgB;AACzB,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB,YAAY,aAAa;AACrD,SAAS,gBAAgB;AACzB,SAAS,cAAc;AACvB,SAAS,aAAa,aAAa,qBAAqB;AA8CxD,SAAS,gBACP,OACA,UAGI,CAAC,GACgB;AA3DvB;AA4DE,QAAM,WAAW,CAAC,CAAC,QAAQ;AAC3B,QAAM,aAAqB,aAAQ,YAAR,YAAmB;AAC9C,MAAI,WAAW;AACf,MAAI,WAAW;AACf,MAAI,eAAe;AACnB,MAAI,WAAW;AACf,QAAM,eAAsC,CAAC;AAE7C,MAAI,WAAW;AACb,gBAAY,OAAO,CAAC,mBAAwB;AAE1C,YAAM,CAAC,MAAM,IAAI,IAAsB;AAAA,QACrC,eAAe,SAAS;AAA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;AAAA,EACF,OAAO;AACL,UAAM,MAAM,YAAY,MAAM,cAAc,GAAG,YAAY,GAAG,OAAO;AAAA,MACnE,OAAO;AAAA,IACT,CAAC;AACD,UAAM,QAAQ,YAAY,MAAM,cAAc,GAAG,CAAC,YAAY,GAAG,OAAO;AAAA,MACtE,OAAO;AAAA,IACT,CAAC;AACD,WAAO,CAAC,SAAS,KAAK,GAAG,SAAS,GAAG,CAAC;AAAA,EACxC;AACF;AAGA,IAAO,gCAAQ","sourcesContent":["import { Feature, FeatureCollection, LineString, Point } from \"geojson\";\nimport { bearing } from \"@turf/bearing\";\nimport { centroid } from \"@turf/centroid\";\nimport { destination } from \"@turf/destination\";\nimport { featureCollection, lineString, point } from \"@turf/helpers\";\nimport { getCoord } from \"@turf/invariant\";\nimport { length } from \"@turf/length\";\nimport { featureEach, segmentEach, segmentReduce } from \"@turf/meta\";\n\ninterface DirectionalMeanLine extends Feature<LineString> {\n properties: {\n cartesianAngle: number;\n bearingAngle: number;\n circularVariance: number;\n averageX: number;\n averageY: number;\n averageLength: number;\n countOfLines: number;\n [key: string]: any;\n };\n}\n\n/**\n * @typedef {Object} DirectionalMeanLine\n * @property {number} cartesianAngle the mean angle of all lines. (measure from due earth counterclockwise).\n * @property {number} bearingAngle the mean angle of all lines. (bearing).\n * @property {number} circularVariance the extent to which features all point in the same direction.\n * the value ranges 0-1, the bigger the value, the more variation in directions between lines.\n * @property {number} averageX the centroid of all lines.\n * @property {number} averageY the centroid of all line.\n * @property {number} averageLength the average length of line.\n * @property {number} countOfLines the count of features.\n */\n\n/**\n * This module calculate the average angle of a set of lines, measuring the trend of it.\n * It can be used in both project coordinate system and geography coordinate system.\n * It can handle segments of line or the whole line.\n * @name directionalMean\n * @param {FeatureCollection<LineString>} lines\n * @param {object} [options={}]\n * @param {boolean} [options.planar=true] whether the spatial reference system is projected or geographical.\n * @param {boolean} [options.segment=false] whether treat a LineString as a whole or a set of segments.\n * @returns {DirectionalMeanLine} Directional Mean Line\n * @example\n *\n * var lines = turf.lineStrings([\n * [[110, 45], [120, 50]],\n * [[100, 50], [115, 55]],\n * ])\n * var directionalMeanLine = turf.directionalMean(lines);\n * // => directionalMeanLine\n */\nfunction directionalMean(\n lines: FeatureCollection<LineString>,\n options: {\n planar?: boolean;\n segment?: boolean;\n } = {}\n): DirectionalMeanLine {\n const isPlanar = !!options.planar; // you can't use options.planar || true here.\n const isSegment: boolean = options.segment ?? false;\n let sigmaSin = 0;\n let sigmaCos = 0;\n let countOfLines = 0;\n let sumOfLen = 0;\n const centroidList: Array<Feature<Point>> = [];\n\n if (isSegment) {\n segmentEach(lines, (currentSegment: any) => {\n // todo fix turf-meta's declaration file\n const [sin1, cos1]: [number, number] = getCosAndSin(\n currentSegment.geometry.coordinates,\n isPlanar\n );\n const lenOfLine = getLengthOfLineString(currentSegment, isPlanar);\n if (isNaN(sin1) || isNaN(cos1)) {\n return;\n } else {\n sigmaSin += sin1;\n sigmaCos += cos1;\n countOfLines += 1;\n sumOfLen += lenOfLine;\n centroidList.push(centroid(currentSegment));\n }\n });\n // planar and segment\n } else {\n // planar and non-segment\n featureEach(lines, (currentFeature: Feature<LineString>) => {\n if (currentFeature.geometry.type !== \"LineString\") {\n throw new Error(\"shold to support MultiLineString?\");\n }\n const [sin1, cos1]: [number, number] = getCosAndSin(\n currentFeature.geometry.coordinates,\n isPlanar\n );\n const lenOfLine = getLengthOfLineString(currentFeature, isPlanar);\n if (isNaN(sin1) || isNaN(cos1)) {\n return;\n } else {\n sigmaSin += sin1;\n sigmaCos += cos1;\n countOfLines += 1;\n sumOfLen += lenOfLine;\n centroidList.push(centroid(currentFeature));\n }\n });\n }\n\n const cartesianAngle: number = getAngleBySinAndCos(sigmaSin, sigmaCos);\n const bearingAngle: number = bearingToCartesian(cartesianAngle);\n const circularVariance = getCircularVariance(\n sigmaSin,\n sigmaCos,\n countOfLines\n );\n const averageLength = sumOfLen / countOfLines;\n const centroidOfLines = centroid(featureCollection(centroidList));\n const [averageX, averageY]: number[] = getCoord(centroidOfLines);\n let meanLinestring;\n if (isPlanar) {\n meanLinestring = getMeanLineString(\n [averageX, averageY],\n cartesianAngle,\n averageLength,\n isPlanar\n );\n } else {\n meanLinestring = getMeanLineString(\n [averageX, averageY],\n bearingAngle,\n averageLength,\n isPlanar\n );\n }\n\n return lineString(meanLinestring, {\n averageLength,\n averageX,\n averageY,\n bearingAngle,\n cartesianAngle,\n circularVariance,\n countOfLines,\n });\n}\n\n/**\n * get euclidean distance between two points.\n * @private\n * @name euclideanDistance\n * @param coords\n */\nfunction euclideanDistance(coords: number[][]) {\n const [x0, y0]: number[] = coords[0];\n const [x1, y1]: number[] = coords[1];\n const dx: number = x1 - x0;\n const dy: number = y1 - y0;\n return Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));\n}\n\n/**\n * get the length of a LineString, both in projected or geographical coordinate system.\n * @private\n * @name getLengthOfLineString\n * @param {Feature<LineString>} line\n * @param {boolean} isPlanar\n */\nfunction getLengthOfLineString(line: Feature<LineString>, isPlanar: boolean) {\n if (isPlanar) {\n return segmentReduce<number>(\n line,\n (previousValue?: number, segment?: Feature<LineString>): number => {\n const coords = segment!.geometry.coordinates; // the signatrue of segmentReduce has problem ?\n return previousValue! + euclideanDistance(coords);\n },\n 0\n );\n } else {\n return length(line, {\n units: \"meters\",\n });\n }\n}\n\n/**\n * bearing to xy(from due earth counterclockwise 0-180)\n * convert between two forms\n * @private\n * @name bearingToCartesian\n * @param angle\n */\nfunction bearingToCartesian(angle: number): number {\n let result = 90 - angle;\n if (result > 180) {\n result -= 360;\n }\n return result;\n}\n\n/**\n * @private\n * @name getCosAndSin\n * @param {Array<Array<number>>} coordinates\n * @returns {Array<number>} [cos, sin]\n */\nfunction getCosAndSin(\n coordinates: number[][],\n isPlanar: boolean\n): [number, number] {\n const beginPoint: number[] = coordinates[0];\n const endPoint: number[] = coordinates[coordinates.length - 1];\n if (isPlanar) {\n const [x0, y0]: number[] = beginPoint;\n const [x1, y1]: number[] = endPoint;\n const dx: number = x1 - x0;\n const dy: number = y1 - y0;\n const h = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));\n if (h < 0.000000001) {\n return [NaN, NaN];\n }\n const sin1 = dy / h;\n const cos1 = dx / h;\n return [sin1, cos1];\n } else {\n const angle = bearingToCartesian(bearing(beginPoint, endPoint));\n const radian = (angle * Math.PI) / 180;\n return [Math.sin(radian), Math.cos(radian)];\n }\n}\n\nfunction getAngleBySinAndCos(sin1: number, cos1: number): number {\n let angle = 0;\n if (Math.abs(cos1) < 0.000000001) {\n angle = 90;\n } else {\n angle = (Math.atan2(sin1, cos1) * 180) / Math.PI;\n }\n if (sin1 >= 0) {\n if (cos1 < 0) {\n angle += 180;\n }\n } else {\n if (cos1 < 0) {\n angle -= 180;\n }\n }\n return angle;\n}\n\nfunction getCircularVariance(sin1: number, cos1: number, len: number) {\n if (len === 0) {\n throw new Error(\"the size of the features set must be greater than 0\");\n }\n return 1 - Math.sqrt(Math.pow(sin1, 2) + Math.pow(cos1, 2)) / len;\n}\n\nfunction getMeanLineString(\n centroidOfLine: number[],\n angle: number,\n lenOfLine: number,\n isPlanar: boolean\n) {\n if (isPlanar) {\n const [averageX, averageY]: number[] = centroidOfLine;\n let beginX: number;\n let beginY: number;\n let endX: number;\n let endY: number;\n const r: number = (angle * Math.PI) / 180;\n const sin: number = Math.sin(r);\n const cos: number = Math.cos(r);\n beginX = averageX - (lenOfLine / 2) * cos;\n beginY = averageY - (lenOfLine / 2) * sin;\n endX = averageX + (lenOfLine / 2) * cos;\n endY = averageY + (lenOfLine / 2) * sin;\n return [\n [beginX, beginY],\n [endX, endY],\n ];\n } else {\n const end = destination(point(centroidOfLine), lenOfLine / 2, angle, {\n units: \"meters\",\n });\n const begin = destination(point(centroidOfLine), -lenOfLine / 2, angle, {\n units: \"meters\",\n });\n return [getCoord(begin), getCoord(end)];\n }\n}\n\nexport { directionalMean, DirectionalMeanLine };\nexport default directionalMean;\n"]}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
1
|
// index.ts
|
|
5
2
|
import { bearing } from "@turf/bearing";
|
|
6
3
|
import { centroid } from "@turf/centroid";
|
|
@@ -92,7 +89,6 @@ function directionalMean(lines, options = {}) {
|
|
|
92
89
|
countOfLines
|
|
93
90
|
});
|
|
94
91
|
}
|
|
95
|
-
__name(directionalMean, "directionalMean");
|
|
96
92
|
function euclideanDistance(coords) {
|
|
97
93
|
const [x0, y0] = coords[0];
|
|
98
94
|
const [x1, y1] = coords[1];
|
|
@@ -100,7 +96,6 @@ function euclideanDistance(coords) {
|
|
|
100
96
|
const dy = y1 - y0;
|
|
101
97
|
return Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
|
|
102
98
|
}
|
|
103
|
-
__name(euclideanDistance, "euclideanDistance");
|
|
104
99
|
function getLengthOfLineString(line, isPlanar) {
|
|
105
100
|
if (isPlanar) {
|
|
106
101
|
return segmentReduce(
|
|
@@ -117,7 +112,6 @@ function getLengthOfLineString(line, isPlanar) {
|
|
|
117
112
|
});
|
|
118
113
|
}
|
|
119
114
|
}
|
|
120
|
-
__name(getLengthOfLineString, "getLengthOfLineString");
|
|
121
115
|
function bearingToCartesian(angle) {
|
|
122
116
|
let result = 90 - angle;
|
|
123
117
|
if (result > 180) {
|
|
@@ -125,7 +119,6 @@ function bearingToCartesian(angle) {
|
|
|
125
119
|
}
|
|
126
120
|
return result;
|
|
127
121
|
}
|
|
128
|
-
__name(bearingToCartesian, "bearingToCartesian");
|
|
129
122
|
function getCosAndSin(coordinates, isPlanar) {
|
|
130
123
|
const beginPoint = coordinates[0];
|
|
131
124
|
const endPoint = coordinates[coordinates.length - 1];
|
|
@@ -147,7 +140,6 @@ function getCosAndSin(coordinates, isPlanar) {
|
|
|
147
140
|
return [Math.sin(radian), Math.cos(radian)];
|
|
148
141
|
}
|
|
149
142
|
}
|
|
150
|
-
__name(getCosAndSin, "getCosAndSin");
|
|
151
143
|
function getAngleBySinAndCos(sin1, cos1) {
|
|
152
144
|
let angle = 0;
|
|
153
145
|
if (Math.abs(cos1) < 1e-9) {
|
|
@@ -166,14 +158,12 @@ function getAngleBySinAndCos(sin1, cos1) {
|
|
|
166
158
|
}
|
|
167
159
|
return angle;
|
|
168
160
|
}
|
|
169
|
-
__name(getAngleBySinAndCos, "getAngleBySinAndCos");
|
|
170
161
|
function getCircularVariance(sin1, cos1, len) {
|
|
171
162
|
if (len === 0) {
|
|
172
163
|
throw new Error("the size of the features set must be greater than 0");
|
|
173
164
|
}
|
|
174
165
|
return 1 - Math.sqrt(Math.pow(sin1, 2) + Math.pow(cos1, 2)) / len;
|
|
175
166
|
}
|
|
176
|
-
__name(getCircularVariance, "getCircularVariance");
|
|
177
167
|
function getMeanLineString(centroidOfLine, angle, lenOfLine, isPlanar) {
|
|
178
168
|
if (isPlanar) {
|
|
179
169
|
const [averageX, averageY] = centroidOfLine;
|
|
@@ -202,7 +192,6 @@ function getMeanLineString(centroidOfLine, angle, lenOfLine, isPlanar) {
|
|
|
202
192
|
return [getCoord(begin), getCoord(end)];
|
|
203
193
|
}
|
|
204
194
|
}
|
|
205
|
-
__name(getMeanLineString, "getMeanLineString");
|
|
206
195
|
var turf_directional_mean_default = directionalMean;
|
|
207
196
|
export {
|
|
208
197
|
turf_directional_mean_default as default,
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import { Feature, FeatureCollection, LineString, Point } from \"geojson\";\nimport { bearing } from \"@turf/bearing\";\nimport { centroid } from \"@turf/centroid\";\nimport { destination } from \"@turf/destination\";\nimport { featureCollection, lineString, point } from \"@turf/helpers\";\nimport { getCoord } from \"@turf/invariant\";\nimport { length } from \"@turf/length\";\nimport { featureEach, segmentEach, segmentReduce } from \"@turf/meta\";\n\ninterface DirectionalMeanLine extends Feature<LineString> {\n properties: {\n cartesianAngle: number;\n bearingAngle: number;\n circularVariance: number;\n averageX: number;\n averageY: number;\n averageLength: number;\n countOfLines: number;\n [key: string]: any;\n };\n}\n\n/**\n * @typedef {Object} DirectionalMeanLine\n * @property {number} cartesianAngle the mean angle of all lines. (measure from due earth counterclockwise).\n * @property {number} bearingAngle the mean angle of all lines. (bearing).\n * @property {number} circularVariance the extent to which features all point in the same direction.\n * the value ranges 0-1, the bigger the value, the more variation in directions between lines.\n * @property {number} averageX the centroid of all lines.\n * @property {number} averageY the centroid of all line.\n * @property {number} averageLength the average length of line.\n * @property {number} countOfLines the count of features.\n */\n\n/**\n * This module calculate the average angle of a set of lines, measuring the trend of it.\n * It can be used in both project coordinate system and geography coordinate system.\n * It can handle segments of line or the whole line.\n * @name directionalMean\n * @param {FeatureCollection<LineString>} lines\n * @param {object} [options={}]\n * @param {boolean} [options.planar=true] whether the spatial reference system is projected or geographical.\n * @param {boolean} [options.segment=false] whether treat a LineString as a whole or a set of segments.\n * @returns {DirectionalMeanLine} Directional Mean Line\n * @example\n *\n * var lines = turf.lineStrings([\n * [[110, 45], [120, 50]],\n * [[100, 50], [115, 55]],\n * ])\n * var directionalMeanLine = turf.directionalMean(lines);\n * // => directionalMeanLine\n */\nfunction directionalMean(\n lines: FeatureCollection<LineString>,\n options: {\n planar?: boolean;\n segment?: boolean;\n } = {}\n): DirectionalMeanLine {\n const isPlanar = !!options.planar; // you can't use options.planar || true here.\n const isSegment: boolean = options.segment ?? false;\n let sigmaSin = 0;\n let sigmaCos = 0;\n let countOfLines = 0;\n let sumOfLen = 0;\n const centroidList: Array<Feature<Point>> = [];\n\n if (isSegment) {\n segmentEach(lines, (currentSegment: any) => {\n // todo fix turf-meta's declaration file\n const [sin1, cos1]: [number, number] = getCosAndSin(\n currentSegment.geometry.coordinates,\n isPlanar\n );\n const lenOfLine = getLengthOfLineString(currentSegment, isPlanar);\n if (isNaN(sin1) || isNaN(cos1)) {\n return;\n } else {\n sigmaSin += sin1;\n sigmaCos += cos1;\n countOfLines += 1;\n sumOfLen += lenOfLine;\n centroidList.push(centroid(currentSegment));\n }\n });\n // planar and segment\n } else {\n // planar and non-segment\n featureEach(lines, (currentFeature: Feature<LineString>) => {\n if (currentFeature.geometry.type !== \"LineString\") {\n throw new Error(\"shold to support MultiLineString?\");\n }\n const [sin1, cos1]: [number, number] = getCosAndSin(\n currentFeature.geometry.coordinates,\n isPlanar\n );\n const lenOfLine = getLengthOfLineString(currentFeature, isPlanar);\n if (isNaN(sin1) || isNaN(cos1)) {\n return;\n } else {\n sigmaSin += sin1;\n sigmaCos += cos1;\n countOfLines += 1;\n sumOfLen += lenOfLine;\n centroidList.push(centroid(currentFeature));\n }\n });\n }\n\n const cartesianAngle: number = getAngleBySinAndCos(sigmaSin, sigmaCos);\n const bearingAngle: number = bearingToCartesian(cartesianAngle);\n const circularVariance = getCircularVariance(\n sigmaSin,\n sigmaCos,\n countOfLines\n );\n const averageLength = sumOfLen / countOfLines;\n const centroidOfLines = centroid(featureCollection(centroidList));\n const [averageX, averageY]: number[] = getCoord(centroidOfLines);\n let meanLinestring;\n if (isPlanar) {\n meanLinestring = getMeanLineString(\n [averageX, averageY],\n cartesianAngle,\n averageLength,\n isPlanar\n );\n } else {\n meanLinestring = getMeanLineString(\n [averageX, averageY],\n bearingAngle,\n averageLength,\n isPlanar\n );\n }\n\n return lineString(meanLinestring, {\n averageLength,\n averageX,\n averageY,\n bearingAngle,\n cartesianAngle,\n circularVariance,\n countOfLines,\n });\n}\n\n/**\n * get euclidean distance between two points.\n * @private\n * @name euclideanDistance\n * @param coords\n */\nfunction euclideanDistance(coords: number[][]) {\n const [x0, y0]: number[] = coords[0];\n const [x1, y1]: number[] = coords[1];\n const dx: number = x1 - x0;\n const dy: number = y1 - y0;\n return Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));\n}\n\n/**\n * get the length of a LineString, both in projected or geographical coordinate system.\n * @private\n * @name getLengthOfLineString\n * @param {Feature<LineString>} line\n * @param {boolean} isPlanar\n */\nfunction getLengthOfLineString(line: Feature<LineString>, isPlanar: boolean) {\n if (isPlanar) {\n return segmentReduce<number>(\n line,\n (previousValue?: number, segment?: Feature<LineString>): number => {\n const coords = segment!.geometry.coordinates; // the signatrue of segmentReduce has problem ?\n return previousValue! + euclideanDistance(coords);\n },\n 0\n );\n } else {\n return length(line, {\n units: \"meters\",\n });\n }\n}\n\n/**\n * bearing to xy(from due earth counterclockwise 0-180)\n * convert between two forms\n * @private\n * @name bearingToCartesian\n * @param angle\n */\nfunction bearingToCartesian(angle: number): number {\n let result = 90 - angle;\n if (result > 180) {\n result -= 360;\n }\n return result;\n}\n\n/**\n * @private\n * @name getCosAndSin\n * @param {Array<Array<number>>} coordinates\n * @returns {Array<number>} [cos, sin]\n */\nfunction getCosAndSin(\n coordinates: number[][],\n isPlanar: boolean\n): [number, number] {\n const beginPoint: number[] = coordinates[0];\n const endPoint: number[] = coordinates[coordinates.length - 1];\n if (isPlanar) {\n const [x0, y0]: number[] = beginPoint;\n const [x1, y1]: number[] = endPoint;\n const dx: number = x1 - x0;\n const dy: number = y1 - y0;\n const h = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));\n if (h < 0.000000001) {\n return [NaN, NaN];\n }\n const sin1 = dy / h;\n const cos1 = dx / h;\n return [sin1, cos1];\n } else {\n const angle = bearingToCartesian(bearing(beginPoint, endPoint));\n const radian = (angle * Math.PI) / 180;\n return [Math.sin(radian), Math.cos(radian)];\n }\n}\n\nfunction getAngleBySinAndCos(sin1: number, cos1: number): number {\n let angle = 0;\n if (Math.abs(cos1) < 0.000000001) {\n angle = 90;\n } else {\n angle = (Math.atan2(sin1, cos1) * 180) / Math.PI;\n }\n if (sin1 >= 0) {\n if (cos1 < 0) {\n angle += 180;\n }\n } else {\n if (cos1 < 0) {\n angle -= 180;\n }\n }\n return angle;\n}\n\nfunction getCircularVariance(sin1: number, cos1: number, len: number) {\n if (len === 0) {\n throw new Error(\"the size of the features set must be greater than 0\");\n }\n return 1 - Math.sqrt(Math.pow(sin1, 2) + Math.pow(cos1, 2)) / len;\n}\n\nfunction getMeanLineString(\n centroidOfLine: number[],\n angle: number,\n lenOfLine: number,\n isPlanar: boolean\n) {\n if (isPlanar) {\n const [averageX, averageY]: number[] = centroidOfLine;\n let beginX: number;\n let beginY: number;\n let endX: number;\n let endY: number;\n const r: number = (angle * Math.PI) / 180;\n const sin: number = Math.sin(r);\n const cos: number = Math.cos(r);\n beginX = averageX - (lenOfLine / 2) * cos;\n beginY = averageY - (lenOfLine / 2) * sin;\n endX = averageX + (lenOfLine / 2) * cos;\n endY = averageY + (lenOfLine / 2) * sin;\n return [\n [beginX, beginY],\n [endX, endY],\n ];\n } else {\n const end = destination(point(centroidOfLine), lenOfLine / 2, angle, {\n units: \"meters\",\n });\n const begin = destination(point(centroidOfLine), -lenOfLine / 2, angle, {\n units: \"meters\",\n });\n return [getCoord(begin), getCoord(end)];\n }\n}\n\nexport { directionalMean, DirectionalMeanLine };\nexport default directionalMean;\n"],"mappings":";;;;AACA,SAAS,eAAe;AACxB,SAAS,gBAAgB;AACzB,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB,YAAY,aAAa;AACrD,SAAS,gBAAgB;AACzB,SAAS,cAAc;AACvB,SAAS,aAAa,aAAa,qBAAqB;AA8CxD,SAAS,gBACP,OACA,UAGI,CAAC,GACgB;AA3DvB;AA4DE,QAAM,WAAW,CAAC,CAAC,QAAQ;AAC3B,QAAM,aAAqB,aAAQ,YAAR,YAAmB;AAC9C,MAAI,WAAW;AACf,MAAI,WAAW;AACf,MAAI,eAAe;AACnB,MAAI,WAAW;AACf,QAAM,eAAsC,CAAC;AAE7C,MAAI,WAAW;AACb,gBAAY,OAAO,CAAC,mBAAwB;AAE1C,YAAM,CAAC,MAAM,IAAI,IAAsB;AAAA,QACrC,eAAe,SAAS;AAAA,QACxB;AAAA,MACF;AACA,YAAM,YAAY,sBAAsB,gBAAgB,QAAQ;AAChE,UA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ACL,UAAM,MAAM,YAAY,MAAM,cAAc,GAAG,YAAY,GAAG,OAAO;AAAA,MACnE,OAAO;AAAA,IACT,CAAC;AACD,UAAM,QAAQ,YAAY,MAAM,cAAc,GAAG,CAAC,YAAY,GAAG,OAAO;AAAA,MACtE,OAAO;AAAA,IACT,CAAC;AACD,WAAO,CAAC,SAAS,KAAK,GAAG,SAAS,GAAG,CAAC;AAAA,EACxC;AACF;AAhCS;AAmCT,IAAO,gCAAQ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import { Feature, FeatureCollection, LineString, Point } from \"geojson\";\nimport { bearing } from \"@turf/bearing\";\nimport { centroid } from \"@turf/centroid\";\nimport { destination } from \"@turf/destination\";\nimport { featureCollection, lineString, point } from \"@turf/helpers\";\nimport { getCoord } from \"@turf/invariant\";\nimport { length } from \"@turf/length\";\nimport { featureEach, segmentEach, segmentReduce } from \"@turf/meta\";\n\ninterface DirectionalMeanLine extends Feature<LineString> {\n properties: {\n cartesianAngle: number;\n bearingAngle: number;\n circularVariance: number;\n averageX: number;\n averageY: number;\n averageLength: number;\n countOfLines: number;\n [key: string]: any;\n };\n}\n\n/**\n * @typedef {Object} DirectionalMeanLine\n * @property {number} cartesianAngle the mean angle of all lines. (measure from due earth counterclockwise).\n * @property {number} bearingAngle the mean angle of all lines. (bearing).\n * @property {number} circularVariance the extent to which features all point in the same direction.\n * the value ranges 0-1, the bigger the value, the more variation in directions between lines.\n * @property {number} averageX the centroid of all lines.\n * @property {number} averageY the centroid of all line.\n * @property {number} averageLength the average length of line.\n * @property {number} countOfLines the count of features.\n */\n\n/**\n * This module calculate the average angle of a set of lines, measuring the trend of it.\n * It can be used in both project coordinate system and geography coordinate system.\n * It can handle segments of line or the whole line.\n * @name directionalMean\n * @param {FeatureCollection<LineString>} lines\n * @param {object} [options={}]\n * @param {boolean} [options.planar=true] whether the spatial reference system is projected or geographical.\n * @param {boolean} [options.segment=false] whether treat a LineString as a whole or a set of segments.\n * @returns {DirectionalMeanLine} Directional Mean Line\n * @example\n *\n * var lines = turf.lineStrings([\n * [[110, 45], [120, 50]],\n * [[100, 50], [115, 55]],\n * ])\n * var directionalMeanLine = turf.directionalMean(lines);\n * // => directionalMeanLine\n */\nfunction directionalMean(\n lines: FeatureCollection<LineString>,\n options: {\n planar?: boolean;\n segment?: boolean;\n } = {}\n): DirectionalMeanLine {\n const isPlanar = !!options.planar; // you can't use options.planar || true here.\n const isSegment: boolean = options.segment ?? false;\n let sigmaSin = 0;\n let sigmaCos = 0;\n let countOfLines = 0;\n let sumOfLen = 0;\n const centroidList: Array<Feature<Point>> = [];\n\n if (isSegment) {\n segmentEach(lines, (currentSegment: any) => {\n // todo fix turf-meta's declaration file\n const [sin1, cos1]: [number, number] = getCosAndSin(\n currentSegment.geometry.coordinates,\n isPlanar\n );\n const lenOfLine = getLengthOfLineString(currentSegment, isPlanar);\n if (isNaN(sin1) || isNaN(cos1)) {\n return;\n } else {\n sigmaSin += sin1;\n sigmaCos += cos1;\n countOfLines += 1;\n sumOfLen += lenOfLine;\n centroidList.push(centroid(currentSegment));\n }\n });\n // planar and segment\n } else {\n // planar and non-segment\n featureEach(lines, (currentFeature: Feature<LineString>) => {\n if (currentFeature.geometry.type !== \"LineString\") {\n throw new Error(\"shold to support MultiLineString?\");\n }\n const [sin1, cos1]: [number, number] = getCosAndSin(\n currentFeature.geometry.coordinates,\n isPlanar\n );\n const lenOfLine = getLengthOfLineString(currentFeature, isPlanar);\n if (isNaN(sin1) || isNaN(cos1)) {\n return;\n } else {\n sigmaSin += sin1;\n sigmaCos += cos1;\n countOfLines += 1;\n sumOfLen += lenOfLine;\n centroidList.push(centroid(currentFeature));\n }\n });\n }\n\n const cartesianAngle: number = getAngleBySinAndCos(sigmaSin, sigmaCos);\n const bearingAngle: number = bearingToCartesian(cartesianAngle);\n const circularVariance = getCircularVariance(\n sigmaSin,\n sigmaCos,\n countOfLines\n );\n const averageLength = sumOfLen / countOfLines;\n const centroidOfLines = centroid(featureCollection(centroidList));\n const [averageX, averageY]: number[] = getCoord(centroidOfLines);\n let meanLinestring;\n if (isPlanar) {\n meanLinestring = getMeanLineString(\n [averageX, averageY],\n cartesianAngle,\n averageLength,\n isPlanar\n );\n } else {\n meanLinestring = getMeanLineString(\n [averageX, averageY],\n bearingAngle,\n averageLength,\n isPlanar\n );\n }\n\n return lineString(meanLinestring, {\n averageLength,\n averageX,\n averageY,\n bearingAngle,\n cartesianAngle,\n circularVariance,\n countOfLines,\n });\n}\n\n/**\n * get euclidean distance between two points.\n * @private\n * @name euclideanDistance\n * @param coords\n */\nfunction euclideanDistance(coords: number[][]) {\n const [x0, y0]: number[] = coords[0];\n const [x1, y1]: number[] = coords[1];\n const dx: number = x1 - x0;\n const dy: number = y1 - y0;\n return Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));\n}\n\n/**\n * get the length of a LineString, both in projected or geographical coordinate system.\n * @private\n * @name getLengthOfLineString\n * @param {Feature<LineString>} line\n * @param {boolean} isPlanar\n */\nfunction getLengthOfLineString(line: Feature<LineString>, isPlanar: boolean) {\n if (isPlanar) {\n return segmentReduce<number>(\n line,\n (previousValue?: number, segment?: Feature<LineString>): number => {\n const coords = segment!.geometry.coordinates; // the signatrue of segmentReduce has problem ?\n return previousValue! + euclideanDistance(coords);\n },\n 0\n );\n } else {\n return length(line, {\n units: \"meters\",\n });\n }\n}\n\n/**\n * bearing to xy(from due earth counterclockwise 0-180)\n * convert between two forms\n * @private\n * @name bearingToCartesian\n * @param angle\n */\nfunction bearingToCartesian(angle: number): number {\n let result = 90 - angle;\n if (result > 180) {\n result -= 360;\n }\n return result;\n}\n\n/**\n * @private\n * @name getCosAndSin\n * @param {Array<Array<number>>} coordinates\n * @returns {Array<number>} [cos, sin]\n */\nfunction getCosAndSin(\n coordinates: number[][],\n isPlanar: boolean\n): [number, number] {\n const beginPoint: number[] = coordinates[0];\n const endPoint: number[] = coordinates[coordinates.length - 1];\n if (isPlanar) {\n const [x0, y0]: number[] = beginPoint;\n const [x1, y1]: number[] = endPoint;\n const dx: number = x1 - x0;\n const dy: number = y1 - y0;\n const h = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));\n if (h < 0.000000001) {\n return [NaN, NaN];\n }\n const sin1 = dy / h;\n const cos1 = dx / h;\n return [sin1, cos1];\n } else {\n const angle = bearingToCartesian(bearing(beginPoint, endPoint));\n const radian = (angle * Math.PI) / 180;\n return [Math.sin(radian), Math.cos(radian)];\n }\n}\n\nfunction getAngleBySinAndCos(sin1: number, cos1: number): number {\n let angle = 0;\n if (Math.abs(cos1) < 0.000000001) {\n angle = 90;\n } else {\n angle = (Math.atan2(sin1, cos1) * 180) / Math.PI;\n }\n if (sin1 >= 0) {\n if (cos1 < 0) {\n angle += 180;\n }\n } else {\n if (cos1 < 0) {\n angle -= 180;\n }\n }\n return angle;\n}\n\nfunction getCircularVariance(sin1: number, cos1: number, len: number) {\n if (len === 0) {\n throw new Error(\"the size of the features set must be greater than 0\");\n }\n return 1 - Math.sqrt(Math.pow(sin1, 2) + Math.pow(cos1, 2)) / len;\n}\n\nfunction getMeanLineString(\n centroidOfLine: number[],\n angle: number,\n lenOfLine: number,\n isPlanar: boolean\n) {\n if (isPlanar) {\n const [averageX, averageY]: number[] = centroidOfLine;\n let beginX: number;\n let beginY: number;\n let endX: number;\n let endY: number;\n const r: number = (angle * Math.PI) / 180;\n const sin: number = Math.sin(r);\n const cos: number = Math.cos(r);\n beginX = averageX - (lenOfLine / 2) * cos;\n beginY = averageY - (lenOfLine / 2) * sin;\n endX = averageX + (lenOfLine / 2) * cos;\n endY = averageY + (lenOfLine / 2) * sin;\n return [\n [beginX, beginY],\n [endX, endY],\n ];\n } else {\n const end = destination(point(centroidOfLine), lenOfLine / 2, angle, {\n units: \"meters\",\n });\n const begin = destination(point(centroidOfLine), -lenOfLine / 2, angle, {\n units: \"meters\",\n });\n return [getCoord(begin), getCoord(end)];\n }\n}\n\nexport { directionalMean, DirectionalMeanLine };\nexport default directionalM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,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI,MAAM,CAAC,CAAC,IAAI;AAChE;AAEA,SAAS,kBACP,gBACA,OACA,WACA,UACA;AACA,MAAI,UAAU;AACZ,UAAM,CAAC,UAAU,QAAQ,IAAc;AACvC,QAAI;AACJ,QAAI;AACJ,QAAI;AACJ,QAAI;AACJ,UAAM,IAAa,QAAQ,KAAK,KAAM;AACtC,UAAM,MAAc,KAAK,IAAI,CAAC;AAC9B,UAAM,MAAc,KAAK,IAAI,CAAC;AAC9B,aAAS,WAAY,YAAY,IAAK;AACtC,aAAS,WAAY,YAAY,IAAK;AACtC,WAAO,WAAY,YAAY,IAAK;AACpC,WAAO,WAAY,YAAY,IAAK;AACpC,WAAO;AAAA,MACL,CAAC,QAAQ,MAAM;AAAA,MACf,CAAC,MAAM,IAAI;AAAA,IACb;AAAA,EACF,OAAO;AACL,UAAM,MAAM,YAAY,MAAM,cAAc,GAAG,YAAY,GAAG,OAAO;AAAA,MACnE,OAAO;AAAA,IACT,CAAC;AACD,UAAM,QAAQ,YAAY,MAAM,cAAc,GAAG,CAAC,YAAY,GAAG,OAAO;AAAA,MACtE,OAAO;AAAA,IACT,CAAC;AACD,WAAO,CAAC,SAAS,KAAK,GAAG,SAAS,GAAG,CAAC;AAAA,EACxC;AACF;AAGA,IAAO,gCAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/directional-mean",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.1.0-alpha.7+0ce6ecca0",
|
|
4
4
|
"description": "turf directional-mean module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"contributors": [
|
|
@@ -64,14 +64,14 @@
|
|
|
64
64
|
"write-json-file": "^5.0.0"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@turf/bearing": "^7.0.
|
|
68
|
-
"@turf/centroid": "^7.0.
|
|
69
|
-
"@turf/destination": "^7.0.
|
|
70
|
-
"@turf/helpers": "^7.0.
|
|
71
|
-
"@turf/invariant": "^7.0.
|
|
72
|
-
"@turf/length": "^7.0.
|
|
73
|
-
"@turf/meta": "^7.0.
|
|
67
|
+
"@turf/bearing": "^7.1.0-alpha.7+0ce6ecca0",
|
|
68
|
+
"@turf/centroid": "^7.1.0-alpha.7+0ce6ecca0",
|
|
69
|
+
"@turf/destination": "^7.1.0-alpha.7+0ce6ecca0",
|
|
70
|
+
"@turf/helpers": "^7.1.0-alpha.7+0ce6ecca0",
|
|
71
|
+
"@turf/invariant": "^7.1.0-alpha.7+0ce6ecca0",
|
|
72
|
+
"@turf/length": "^7.1.0-alpha.7+0ce6ecca0",
|
|
73
|
+
"@turf/meta": "^7.1.0-alpha.7+0ce6ecca0",
|
|
74
74
|
"tslib": "^2.6.2"
|
|
75
75
|
},
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "0ce6ecca05829690270fec6d6bed2003495fe0ea"
|
|
77
77
|
}
|