@turf/transform-translate 7.1.0 → 7.2.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/dist/cjs/index.cjs +4 -8
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +4 -8
- package/dist/esm/index.js.map +1 -1
- package/package.json +14 -14
package/dist/cjs/index.cjs
CHANGED
|
@@ -6,28 +6,24 @@ var _clone = require('@turf/clone');
|
|
|
6
6
|
var _rhumbdestination = require('@turf/rhumb-destination');
|
|
7
7
|
function transformTranslate(geojson, distance, direction, options) {
|
|
8
8
|
options = options || {};
|
|
9
|
-
if (!_helpers.isObject.call(void 0, options))
|
|
10
|
-
throw new Error("options is invalid");
|
|
9
|
+
if (!_helpers.isObject.call(void 0, options)) throw new Error("options is invalid");
|
|
11
10
|
var units = options.units;
|
|
12
11
|
var zTranslation = options.zTranslation;
|
|
13
12
|
var mutate = options.mutate;
|
|
14
|
-
if (!geojson)
|
|
15
|
-
throw new Error("geojson is required");
|
|
13
|
+
if (!geojson) throw new Error("geojson is required");
|
|
16
14
|
if (distance === void 0 || distance === null || isNaN(distance))
|
|
17
15
|
throw new Error("distance is required");
|
|
18
16
|
if (zTranslation && typeof zTranslation !== "number" && isNaN(zTranslation))
|
|
19
17
|
throw new Error("zTranslation is not a number");
|
|
20
18
|
zTranslation = zTranslation !== void 0 ? zTranslation : 0;
|
|
21
|
-
if (distance === 0 && zTranslation === 0)
|
|
22
|
-
return geojson;
|
|
19
|
+
if (distance === 0 && zTranslation === 0) return geojson;
|
|
23
20
|
if (direction === void 0 || direction === null || isNaN(direction))
|
|
24
21
|
throw new Error("direction is required");
|
|
25
22
|
if (distance < 0) {
|
|
26
23
|
distance = -distance;
|
|
27
24
|
direction = direction + 180;
|
|
28
25
|
}
|
|
29
|
-
if (mutate === false || mutate === void 0)
|
|
30
|
-
geojson = _clone.clone.call(void 0, geojson);
|
|
26
|
+
if (mutate === false || mutate === void 0) geojson = _clone.clone.call(void 0, geojson);
|
|
31
27
|
_meta.coordEach.call(void 0, geojson, function(pointCoords) {
|
|
32
28
|
var newCoords = _invariant.getCoords.call(void 0,
|
|
33
29
|
_rhumbdestination.rhumbDestination.call(void 0, pointCoords, distance, direction, { units })
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/turf/turf/packages/turf-transform-translate/dist/cjs/index.cjs","../../index.ts"],"names":[],"mappings":"AAAA;ACCA,kCAA0B;AAC1B,wCAAgC;AAChC,4CAA0B;AAC1B,oCAAsB;AACtB,2DAAiC;AAuBjC,SAAS,kBAAA,CACP,OAAA,EACA,QAAA,EACA,SAAA,EACA,OAAA,EAKG;AAEH,EAAA,QAAA,EAAU,QAAA,GAAW,CAAC,CAAA;AACtB,EAAA,GAAA,CAAI,CAAC,+BAAA,OAAgB,CAAA,EAAG,MAAM,IAAI,KAAA,CAAM,oBAAoB,CAAA;AAC5D,EAAA,IAAI,MAAA,EAAQ,OAAA,CAAQ,KAAA;AACpB,EAAA,IAAI,aAAA,EAAe,OAAA,CAAQ,YAAA;AAC3B,EAAA,IAAI,OAAA,EAAS,OAAA,CAAQ,MAAA;AAGrB,EAAA,GAAA,CAAI,CAAC,OAAA,EAAS,MAAM,IAAI,KAAA,CAAM,qBAAqB,CAAA;AACnD,EAAA,GAAA,CAAI,SAAA,IAAa,KAAA,EAAA,GAAa,SAAA,IAAa,KAAA,GAAQ,KAAA,CAAM,QAAQ,CAAA;AAC/D,IAAA,MAAM,IAAI,KAAA,CAAM,sBAAsB,CAAA;AACxC,EAAA,GAAA,CAAI,aAAA,GAAgB,OAAO,aAAA,IAAiB,SAAA,GAAY,KAAA,CAAM,YAAY,CAAA;AACxE,IAAA,MAAM,IAAI,KAAA,CAAM,8BAA8B,CAAA;AAGhD,EAAA,aAAA,EAAe,aAAA,IAAiB,KAAA,EAAA,EAAY,aAAA,EAAe,CAAA;AAC3D,EAAA,GAAA,CAAI,SAAA,IAAa,EAAA,GAAK,aAAA,IAAiB,CAAA,EAAG,OAAO,OAAA;AAEjD,EAAA,GAAA,CAAI,UAAA,IAAc,KAAA,EAAA,GAAa,UAAA,IAAc,KAAA,GAAQ,KAAA,CAAM,SAAS,CAAA;AAClE,IAAA,MAAM,IAAI,KAAA,CAAM,uBAAuB,CAAA;AAGzC,EAAA,GAAA,CAAI,SAAA,EAAW,CAAA,EAAG;AAChB,IAAA,SAAA,EAAW,CAAC,QAAA;AACZ,IAAA,UAAA,EAAY,UAAA,EAAY,GAAA;AAAA,EAC1B;AAGA,EAAA,GAAA,CAAI,OAAA,IAAW,MAAA,GAAS,OAAA,IAAW,KAAA,CAAA,EAAW,QAAA,EAAU,0BAAA,OAAa,CAAA;AAGrE,EAAA,6BAAA,OAAU,EAAS,QAAA,CAAU,WAAA,EAAa;AACxC,IAAA,IAAI,UAAA,EAAY,kCAAA;AAAA,MACd,gDAAA,WAAiB,EAAa,QAAA,EAAU,SAAA,EAAW,EAAE,MAAa,CAAC;AAAA,IACrE,CAAA;AACA,IAAA,WAAA,CAAY,CAAC,EAAA,EAAI,SAAA,CAAU,CAAC,CAAA;AAC5B,IAAA,WAAA,CAAY,CAAC,EAAA,EAAI,SAAA,CAAU,CAAC,CAAA;AAC5B,IAAA,GAAA,CAAI,aAAA,GAAgB,WAAA,CAAY,OAAA,IAAW,CAAA;AACzC,MAAA,WAAA,CAAY,CAAC,EAAA,GAAK,YAAA;AAAA,EACtB,CAAC,CAAA;AACD,EAAA,OAAO,OAAA;AACT;AAGA,IAAO,iCAAA,EAAQ,kBAAA;AD5Cf;AACE;AACA;AACF,oGAAC","file":"/home/runner/work/turf/turf/packages/turf-transform-translate/dist/cjs/index.cjs","sourcesContent":[null,"import { GeoJSON, GeometryCollection } from \"geojson\";\nimport { coordEach } from \"@turf/meta\";\nimport { isObject, Units } from \"@turf/helpers\";\nimport { getCoords } from \"@turf/invariant\";\nimport { clone } from \"@turf/clone\";\nimport { rhumbDestination } from \"@turf/rhumb-destination\";\n\n/**\n * Moves any geojson Feature or Geometry of a specified distance along a Rhumb Line\n * on the provided direction angle.\n *\n * @function\n * @param {GeoJSON|GeometryCollection} geojson object to be translated\n * @param {number} distance length of the motion; negative values determine motion in opposite direction\n * @param {number} direction of the motion; angle from North in decimal degrees, positive clockwise\n * @param {Object} [options={}] Optional parameters\n * @param {Units} [options.units='kilometers'] in which `distance` will be express; miles, kilometers, degrees, or radians\n * @param {number} [options.zTranslation=0] length of the vertical motion, same unit of distance\n * @param {boolean} [options.mutate=false] allows GeoJSON input to be mutated (significant performance increase if true)\n * @returns {GeoJSON|GeometryCollection} the translated GeoJSON object\n * @example\n * var poly = turf.polygon([[[0,29],[3.5,29],[2.5,32],[0,29]]]);\n * var translatedPoly = turf.transformTranslate(poly, 100, 35);\n *\n * //addToMap\n * var addToMap = [poly, translatedPoly];\n * translatedPoly.properties = {stroke: '#F00', 'stroke-width': 4};\n */\nfunction transformTranslate<T extends GeoJSON | GeometryCollection>(\n geojson: T,\n distance: number,\n direction: number,\n options?: {\n units?: Units;\n zTranslation?: number;\n mutate?: boolean;\n }\n): T {\n // Optional parameters\n options = options || {};\n if (!isObject(options)) throw new Error(\"options is invalid\");\n var units = options.units;\n var zTranslation = options.zTranslation;\n var mutate = options.mutate;\n\n // Input validation\n if (!geojson) throw new Error(\"geojson is required\");\n if (distance === undefined || distance === null || isNaN(distance))\n throw new Error(\"distance is required\");\n if (zTranslation && typeof zTranslation !== \"number\" && isNaN(zTranslation))\n throw new Error(\"zTranslation is not a number\");\n\n // Shortcut no-motion\n zTranslation = zTranslation !== undefined ? zTranslation : 0;\n if (distance === 0 && zTranslation === 0) return geojson;\n\n if (direction === undefined || direction === null || isNaN(direction))\n throw new Error(\"direction is required\");\n\n // Invert with negative distances\n if (distance < 0) {\n distance = -distance;\n direction = direction + 180;\n }\n\n // Clone geojson to avoid side effects\n if (mutate === false || mutate === undefined) geojson = clone(geojson);\n\n // Translate each coordinate\n coordEach(geojson, function (pointCoords) {\n var newCoords = getCoords(\n rhumbDestination(pointCoords, distance, direction, { units: units })\n );\n pointCoords[0] = newCoords[0];\n pointCoords[1] = newCoords[1];\n if (zTranslation && pointCoords.length === 3)\n pointCoords[2] += zTranslation;\n });\n return geojson;\n}\n\nexport { transformTranslate };\nexport default transformTranslate;\n"]}
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -5,7 +5,7 @@ import { Units } from '@turf/helpers';
|
|
|
5
5
|
* Moves any geojson Feature or Geometry of a specified distance along a Rhumb Line
|
|
6
6
|
* on the provided direction angle.
|
|
7
7
|
*
|
|
8
|
-
* @
|
|
8
|
+
* @function
|
|
9
9
|
* @param {GeoJSON|GeometryCollection} geojson object to be translated
|
|
10
10
|
* @param {number} distance length of the motion; negative values determine motion in opposite direction
|
|
11
11
|
* @param {number} direction of the motion; angle from North in decimal degrees, positive clockwise
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { Units } from '@turf/helpers';
|
|
|
5
5
|
* Moves any geojson Feature or Geometry of a specified distance along a Rhumb Line
|
|
6
6
|
* on the provided direction angle.
|
|
7
7
|
*
|
|
8
|
-
* @
|
|
8
|
+
* @function
|
|
9
9
|
* @param {GeoJSON|GeometryCollection} geojson object to be translated
|
|
10
10
|
* @param {number} distance length of the motion; negative values determine motion in opposite direction
|
|
11
11
|
* @param {number} direction of the motion; angle from North in decimal degrees, positive clockwise
|
package/dist/esm/index.js
CHANGED
|
@@ -6,28 +6,24 @@ import { clone } from "@turf/clone";
|
|
|
6
6
|
import { rhumbDestination } from "@turf/rhumb-destination";
|
|
7
7
|
function transformTranslate(geojson, distance, direction, options) {
|
|
8
8
|
options = options || {};
|
|
9
|
-
if (!isObject(options))
|
|
10
|
-
throw new Error("options is invalid");
|
|
9
|
+
if (!isObject(options)) throw new Error("options is invalid");
|
|
11
10
|
var units = options.units;
|
|
12
11
|
var zTranslation = options.zTranslation;
|
|
13
12
|
var mutate = options.mutate;
|
|
14
|
-
if (!geojson)
|
|
15
|
-
throw new Error("geojson is required");
|
|
13
|
+
if (!geojson) throw new Error("geojson is required");
|
|
16
14
|
if (distance === void 0 || distance === null || isNaN(distance))
|
|
17
15
|
throw new Error("distance is required");
|
|
18
16
|
if (zTranslation && typeof zTranslation !== "number" && isNaN(zTranslation))
|
|
19
17
|
throw new Error("zTranslation is not a number");
|
|
20
18
|
zTranslation = zTranslation !== void 0 ? zTranslation : 0;
|
|
21
|
-
if (distance === 0 && zTranslation === 0)
|
|
22
|
-
return geojson;
|
|
19
|
+
if (distance === 0 && zTranslation === 0) return geojson;
|
|
23
20
|
if (direction === void 0 || direction === null || isNaN(direction))
|
|
24
21
|
throw new Error("direction is required");
|
|
25
22
|
if (distance < 0) {
|
|
26
23
|
distance = -distance;
|
|
27
24
|
direction = direction + 180;
|
|
28
25
|
}
|
|
29
|
-
if (mutate === false || mutate === void 0)
|
|
30
|
-
geojson = clone(geojson);
|
|
26
|
+
if (mutate === false || mutate === void 0) geojson = clone(geojson);
|
|
31
27
|
coordEach(geojson, function(pointCoords) {
|
|
32
28
|
var newCoords = getCoords(
|
|
33
29
|
rhumbDestination(pointCoords, distance, direction, { units })
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import { GeoJSON, GeometryCollection } from \"geojson\";\nimport { coordEach } from \"@turf/meta\";\nimport { isObject, Units } from \"@turf/helpers\";\nimport { getCoords } from \"@turf/invariant\";\nimport { clone } from \"@turf/clone\";\nimport { rhumbDestination } from \"@turf/rhumb-destination\";\n\n/**\n * Moves any geojson Feature or Geometry of a specified distance along a Rhumb Line\n * on the provided direction angle.\n *\n * @
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import { GeoJSON, GeometryCollection } from \"geojson\";\nimport { coordEach } from \"@turf/meta\";\nimport { isObject, Units } from \"@turf/helpers\";\nimport { getCoords } from \"@turf/invariant\";\nimport { clone } from \"@turf/clone\";\nimport { rhumbDestination } from \"@turf/rhumb-destination\";\n\n/**\n * Moves any geojson Feature or Geometry of a specified distance along a Rhumb Line\n * on the provided direction angle.\n *\n * @function\n * @param {GeoJSON|GeometryCollection} geojson object to be translated\n * @param {number} distance length of the motion; negative values determine motion in opposite direction\n * @param {number} direction of the motion; angle from North in decimal degrees, positive clockwise\n * @param {Object} [options={}] Optional parameters\n * @param {Units} [options.units='kilometers'] in which `distance` will be express; miles, kilometers, degrees, or radians\n * @param {number} [options.zTranslation=0] length of the vertical motion, same unit of distance\n * @param {boolean} [options.mutate=false] allows GeoJSON input to be mutated (significant performance increase if true)\n * @returns {GeoJSON|GeometryCollection} the translated GeoJSON object\n * @example\n * var poly = turf.polygon([[[0,29],[3.5,29],[2.5,32],[0,29]]]);\n * var translatedPoly = turf.transformTranslate(poly, 100, 35);\n *\n * //addToMap\n * var addToMap = [poly, translatedPoly];\n * translatedPoly.properties = {stroke: '#F00', 'stroke-width': 4};\n */\nfunction transformTranslate<T extends GeoJSON | GeometryCollection>(\n geojson: T,\n distance: number,\n direction: number,\n options?: {\n units?: Units;\n zTranslation?: number;\n mutate?: boolean;\n }\n): T {\n // Optional parameters\n options = options || {};\n if (!isObject(options)) throw new Error(\"options is invalid\");\n var units = options.units;\n var zTranslation = options.zTranslation;\n var mutate = options.mutate;\n\n // Input validation\n if (!geojson) throw new Error(\"geojson is required\");\n if (distance === undefined || distance === null || isNaN(distance))\n throw new Error(\"distance is required\");\n if (zTranslation && typeof zTranslation !== \"number\" && isNaN(zTranslation))\n throw new Error(\"zTranslation is not a number\");\n\n // Shortcut no-motion\n zTranslation = zTranslation !== undefined ? zTranslation : 0;\n if (distance === 0 && zTranslation === 0) return geojson;\n\n if (direction === undefined || direction === null || isNaN(direction))\n throw new Error(\"direction is required\");\n\n // Invert with negative distances\n if (distance < 0) {\n distance = -distance;\n direction = direction + 180;\n }\n\n // Clone geojson to avoid side effects\n if (mutate === false || mutate === undefined) geojson = clone(geojson);\n\n // Translate each coordinate\n coordEach(geojson, function (pointCoords) {\n var newCoords = getCoords(\n rhumbDestination(pointCoords, distance, direction, { units: units })\n );\n pointCoords[0] = newCoords[0];\n pointCoords[1] = newCoords[1];\n if (zTranslation && pointCoords.length === 3)\n pointCoords[2] += zTranslation;\n });\n return geojson;\n}\n\nexport { transformTranslate };\nexport default transformTranslate;\n"],"mappings":";AACA,SAAS,iBAAiB;AAC1B,SAAS,gBAAuB;AAChC,SAAS,iBAAiB;AAC1B,SAAS,aAAa;AACtB,SAAS,wBAAwB;AAuBjC,SAAS,mBACP,SACA,UACA,WACA,SAKG;AAEH,YAAU,WAAW,CAAC;AACtB,MAAI,CAAC,SAAS,OAAO,EAAG,OAAM,IAAI,MAAM,oBAAoB;AAC5D,MAAI,QAAQ,QAAQ;AACpB,MAAI,eAAe,QAAQ;AAC3B,MAAI,SAAS,QAAQ;AAGrB,MAAI,CAAC,QAAS,OAAM,IAAI,MAAM,qBAAqB;AACnD,MAAI,aAAa,UAAa,aAAa,QAAQ,MAAM,QAAQ;AAC/D,UAAM,IAAI,MAAM,sBAAsB;AACxC,MAAI,gBAAgB,OAAO,iBAAiB,YAAY,MAAM,YAAY;AACxE,UAAM,IAAI,MAAM,8BAA8B;AAGhD,iBAAe,iBAAiB,SAAY,eAAe;AAC3D,MAAI,aAAa,KAAK,iBAAiB,EAAG,QAAO;AAEjD,MAAI,cAAc,UAAa,cAAc,QAAQ,MAAM,SAAS;AAClE,UAAM,IAAI,MAAM,uBAAuB;AAGzC,MAAI,WAAW,GAAG;AAChB,eAAW,CAAC;AACZ,gBAAY,YAAY;AAAA,EAC1B;AAGA,MAAI,WAAW,SAAS,WAAW,OAAW,WAAU,MAAM,OAAO;AAGrE,YAAU,SAAS,SAAU,aAAa;AACxC,QAAI,YAAY;AAAA,MACd,iBAAiB,aAAa,UAAU,WAAW,EAAE,MAAa,CAAC;AAAA,IACrE;AACA,gBAAY,CAAC,IAAI,UAAU,CAAC;AAC5B,gBAAY,CAAC,IAAI,UAAU,CAAC;AAC5B,QAAI,gBAAgB,YAAY,WAAW;AACzC,kBAAY,CAAC,KAAK;AAAA,EACtB,CAAC;AACD,SAAO;AACT;AAGA,IAAO,mCAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/transform-translate",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.2.0",
|
|
4
4
|
"description": "turf transform-translate module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"contributors": [
|
|
@@ -58,26 +58,26 @@
|
|
|
58
58
|
"test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@turf/truncate": "^7.
|
|
61
|
+
"@turf/truncate": "^7.2.0",
|
|
62
62
|
"@types/benchmark": "^2.1.5",
|
|
63
|
-
"@types/tape": "^4.
|
|
63
|
+
"@types/tape": "^4.13.4",
|
|
64
64
|
"benchmark": "^2.1.4",
|
|
65
65
|
"load-json-file": "^7.0.1",
|
|
66
66
|
"npm-run-all": "^4.1.5",
|
|
67
|
-
"tape": "^5.
|
|
68
|
-
"tsup": "^8.
|
|
69
|
-
"tsx": "^4.
|
|
70
|
-
"typescript": "^5.
|
|
67
|
+
"tape": "^5.9.0",
|
|
68
|
+
"tsup": "^8.3.5",
|
|
69
|
+
"tsx": "^4.19.2",
|
|
70
|
+
"typescript": "^5.5.4",
|
|
71
71
|
"write-json-file": "^5.0.0"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@turf/clone": "^7.
|
|
75
|
-
"@turf/helpers": "^7.
|
|
76
|
-
"@turf/invariant": "^7.
|
|
77
|
-
"@turf/meta": "^7.
|
|
78
|
-
"@turf/rhumb-destination": "^7.
|
|
74
|
+
"@turf/clone": "^7.2.0",
|
|
75
|
+
"@turf/helpers": "^7.2.0",
|
|
76
|
+
"@turf/invariant": "^7.2.0",
|
|
77
|
+
"@turf/meta": "^7.2.0",
|
|
78
|
+
"@turf/rhumb-destination": "^7.2.0",
|
|
79
79
|
"@types/geojson": "^7946.0.10",
|
|
80
|
-
"tslib": "^2.
|
|
80
|
+
"tslib": "^2.8.1"
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "7b0f0374c4668cd569f8904c71e2ae7d941be867"
|
|
83
83
|
}
|