@turf/transform-scale 7.0.0-alpha.0 → 7.0.0-alpha.110

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
@@ -41,26 +41,21 @@ Returns **[GeoJSON][1]** scaled GeoJSON
41
41
 
42
42
  [6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
43
43
 
44
- <!-- This file is automatically generated. Please don't edit it directly:
45
- if you find an error, edit the source file (likely index.js), and re-run
46
- ./scripts/generate-readmes in the turf project. -->
44
+ <!-- This file is automatically generated. Please don't edit it directly. If you find an error, edit the source file of the module in question (likely index.js or index.ts), and re-run "yarn docs" from the root of the turf project. -->
47
45
 
48
46
  ---
49
47
 
50
- This module is part of the [Turfjs project](http://turfjs.org/), an open source
51
- module collection dedicated to geographic algorithms. It is maintained in the
52
- [Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create
53
- PRs and issues.
48
+ This module is part of the [Turfjs project](https://turfjs.org/), an open source module collection dedicated to geographic algorithms. It is maintained in the [Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create PRs and issues.
54
49
 
55
50
  ### Installation
56
51
 
57
- Install this module individually:
52
+ Install this single module individually:
58
53
 
59
54
  ```sh
60
55
  $ npm install @turf/transform-scale
61
56
  ```
62
57
 
63
- Or install the Turf module that includes it as a function:
58
+ Or install the all-encompassing @turf/turf module that includes all modules as functions:
64
59
 
65
60
  ```sh
66
61
  $ npm install @turf/turf
@@ -0,0 +1,103 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // index.js
5
+ var _clone = require('@turf/clone');
6
+ var _center = require('@turf/center');
7
+ var _centroid = require('@turf/centroid');
8
+ var _bbox = require('@turf/bbox');
9
+ var _rhumbbearing = require('@turf/rhumb-bearing');
10
+ var _rhumbdistance = require('@turf/rhumb-distance');
11
+ var _rhumbdestination = require('@turf/rhumb-destination');
12
+ var _meta = require('@turf/meta');
13
+ var _helpers = require('@turf/helpers');
14
+ var _invariant = require('@turf/invariant');
15
+ function transformScale(geojson, factor, options) {
16
+ options = options || {};
17
+ if (!_helpers.isObject.call(void 0, options))
18
+ throw new Error("options is invalid");
19
+ var origin = options.origin;
20
+ var mutate = options.mutate;
21
+ if (!geojson)
22
+ throw new Error("geojson required");
23
+ if (typeof factor !== "number" || factor <= 0)
24
+ throw new Error("invalid factor");
25
+ var originIsPoint = Array.isArray(origin) || typeof origin === "object";
26
+ if (mutate !== true)
27
+ geojson = _clone.clone.call(void 0, geojson);
28
+ if (geojson.type === "FeatureCollection" && !originIsPoint) {
29
+ _meta.featureEach.call(void 0, geojson, function(feature, index) {
30
+ geojson.features[index] = scale(feature, factor, origin);
31
+ });
32
+ return geojson;
33
+ }
34
+ return scale(geojson, factor, origin);
35
+ }
36
+ __name(transformScale, "transformScale");
37
+ function scale(feature, factor, origin) {
38
+ var isPoint = _invariant.getType.call(void 0, feature) === "Point";
39
+ origin = defineOrigin(feature, origin);
40
+ if (factor === 1 || isPoint)
41
+ return feature;
42
+ _meta.coordEach.call(void 0, feature, function(coord) {
43
+ var originalDistance = _rhumbdistance.rhumbDistance.call(void 0, origin, coord);
44
+ var bearing = _rhumbbearing.rhumbBearing.call(void 0, origin, coord);
45
+ var newDistance = originalDistance * factor;
46
+ var newCoord = _invariant.getCoords.call(void 0, _rhumbdestination.rhumbDestination.call(void 0, origin, newDistance, bearing));
47
+ coord[0] = newCoord[0];
48
+ coord[1] = newCoord[1];
49
+ if (coord.length === 3)
50
+ coord[2] *= factor;
51
+ });
52
+ delete feature.bbox;
53
+ return feature;
54
+ }
55
+ __name(scale, "scale");
56
+ function defineOrigin(geojson, origin) {
57
+ if (origin === void 0 || origin === null)
58
+ origin = "centroid";
59
+ if (Array.isArray(origin) || typeof origin === "object")
60
+ return _invariant.getCoord.call(void 0, origin);
61
+ var bbox = geojson.bbox ? geojson.bbox : _bbox.bbox.call(void 0, geojson, { recalculate: true });
62
+ var west = bbox[0];
63
+ var south = bbox[1];
64
+ var east = bbox[2];
65
+ var north = bbox[3];
66
+ switch (origin) {
67
+ case "sw":
68
+ case "southwest":
69
+ case "westsouth":
70
+ case "bottomleft":
71
+ return _helpers.point.call(void 0, [west, south]);
72
+ case "se":
73
+ case "southeast":
74
+ case "eastsouth":
75
+ case "bottomright":
76
+ return _helpers.point.call(void 0, [east, south]);
77
+ case "nw":
78
+ case "northwest":
79
+ case "westnorth":
80
+ case "topleft":
81
+ return _helpers.point.call(void 0, [west, north]);
82
+ case "ne":
83
+ case "northeast":
84
+ case "eastnorth":
85
+ case "topright":
86
+ return _helpers.point.call(void 0, [east, north]);
87
+ case "center":
88
+ return _center.center.call(void 0, geojson);
89
+ case void 0:
90
+ case null:
91
+ case "centroid":
92
+ return _centroid.centroid.call(void 0, geojson);
93
+ default:
94
+ throw new Error("invalid origin");
95
+ }
96
+ }
97
+ __name(defineOrigin, "defineOrigin");
98
+ var turf_transform_scale_default = transformScale;
99
+
100
+
101
+
102
+ exports.default = turf_transform_scale_default; exports.transformScale = transformScale;
103
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../index.js"],"names":[],"mappings":";;;;AAAA,SAAS,aAAa;AACtB,SAAS,cAAc;AACvB,SAAS,gBAAgB;AACzB,SAAS,QAAQ,gBAAgB;AACjC,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,wBAAwB;AACjC,SAAS,WAAW,mBAAmB;AACvC,SAAS,OAAO,gBAAgB;AAChC,SAAS,UAAU,WAAW,eAAe;AAqB7C,SAAS,eAAe,SAAS,QAAQ,SAAS;AAEhD,YAAU,WAAW,CAAC;AACtB,MAAI,CAAC,SAAS,OAAO;AAAG,UAAM,IAAI,MAAM,oBAAoB;AAC5D,MAAI,SAAS,QAAQ;AACrB,MAAI,SAAS,QAAQ;AAGrB,MAAI,CAAC;A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,KAAK,CAAC;AAClB,MAAI,OAAO,KAAK,CAAC;AACjB,MAAI,QAAQ,KAAK,CAAC;AAElB,UAAQ,QAAQ;AAAA,IACd,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO,MAAM,CAAC,MAAM,KAAK,CAAC;AAAA,IAC5B,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO,MAAM,CAAC,MAAM,KAAK,CAAC;AAAA,IAC5B,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO,MAAM,CAAC,MAAM,KAAK,CAAC;AAAA,IAC5B,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO,MAAM,CAAC,MAAM,KAAK,CAAC;AAAA,IAC5B,KAAK;AACH,aAAO,OAAO,OAAO;AAAA,IACvB,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO,SAAS,OAAO;AAAA,IACzB;AACE,YAAM,IAAI,MAAM,gBAAgB;AAAA,EACpC;AACF;AA/CS;AAkDT,IAAO,+BAAQ","sourcesContent":["import { clone } from \"@turf/clone\";\nimport { center } from \"@turf/center\";\nimport { centroid } from \"@turf/centroid\";\nimport { bbox as turfBBox } from \"@turf/bbox\";\nimport { rhumbBearing } from \"@turf/rhumb-bearing\";\nimport { rhumbDistance } from \"@turf/rhumb-distance\";\nimport { rhumbDestination } from \"@turf/rhumb-destination\";\nimport { coordEach, featureEach } from \"@turf/meta\";\nimport { point, isObject } from \"@turf/helpers\";\nimport { getCoord, getCoords, getType } from \"@turf/invariant\";\n\n/**\n * Scale a GeoJSON from a given point by a factor of scaling (ex: factor=2 would make the GeoJSON 200% larger).\n * If a FeatureCollection is provided, the origin point will be calculated based on each individual Feature.\n *\n * @name transformScale\n * @param {GeoJSON} geojson GeoJSON to be scaled\n * @param {number} factor of scaling, positive values greater than 0. Numbers between 0 and 1 will shrink the geojson, numbers greater than 1 will expand it, a factor of 1 will not change the geojson.\n * @param {Object} [options={}] Optional parameters\n * @param {string|Coord} [options.origin='centroid'] Point from which the scaling will occur (string options: sw/se/nw/ne/center/centroid)\n * @param {boolean} [options.mutate=false] allows GeoJSON input to be mutated (significant performance increase if true)\n * @returns {GeoJSON} scaled GeoJSON\n * @example\n * var poly = turf.polygon([[[0,29],[3.5,29],[2.5,32],[0,29]]]);\n * var scaledPoly = turf.transformScale(poly, 3);\n *\n * //addToMap\n * var addToMap = [poly, scaledPoly];\n * scaledPoly.properties = {stroke: '#F00', 'stroke-width': 4};\n */\nfunction transformScale(geojson, factor, options) {\n // Optional parameters\n options = options || {};\n if (!isObject(options)) throw new Error(\"options is invalid\");\n var origin = options.origin;\n var mutate = options.mutate;\n\n // Input validation\n if (!geojson) throw new Error(\"geojson required\");\n if (typeof factor !== \"number\" || factor <= 0)\n throw new Error(\"invalid factor\");\n var originIsPoint = Array.isArray(origin) || typeof origin === \"object\";\n\n // Clone geojson to avoid side effects\n if (mutate !== true) geojson = clone(geojson);\n\n // Scale each Feature separately\n if (geojson.type === \"FeatureCollection\" && !originIsPoint) {\n featureEach(geojson, function (feature, index) {\n geojson.features[index] = scale(feature, factor, origin);\n });\n return geojson;\n }\n // Scale Feature/Geometry\n return scale(geojson, factor, origin);\n}\n\n/**\n * Scale Feature/Geometry\n *\n * @private\n * @param {Feature|Geometry} feature GeoJSON Feature/Geometry\n * @param {number} factor of scaling, positive or negative values greater than 0\n * @param {string|Coord} [origin=\"centroid\"] Point from which the scaling will occur (string options: sw/se/nw/ne/center/centroid)\n * @returns {Feature|Geometry} scaled GeoJSON Feature/Geometry\n */\nfunction scale(feature, factor, origin) {\n // Default params\n var isPoint = getType(feature) === \"Point\";\n origin = defineOrigin(feature, origin);\n\n // Shortcut no-scaling\n if (factor === 1 || isPoint) return feature;\n\n // Scale each coordinate\n coordEach(feature, function (coord) {\n var originalDistance = rhumbDistance(origin, coord);\n var bearing = rhumbBearing(origin, coord);\n var newDistance = originalDistance * factor;\n var newCoord = getCoords(rhumbDestination(origin, newDistance, bearing));\n coord[0] = newCoord[0];\n coord[1] = newCoord[1];\n if (coord.length === 3) coord[2] *= factor;\n });\n\n delete feature.bbox;\n\n return feature;\n}\n\n/**\n * Define Origin\n *\n * @private\n * @param {GeoJSON} geojson GeoJSON\n * @param {string|Coord} origin sw/se/nw/ne/center/centroid\n * @returns {Feature<Point>} Point origin\n */\nfunction defineOrigin(geojson, origin) {\n // Default params\n if (origin === undefined || origin === null) origin = \"centroid\";\n\n // Input Coord\n if (Array.isArray(origin) || typeof origin === \"object\")\n return getCoord(origin);\n\n // Define BBox\n var bbox = geojson.bbox\n ? geojson.bbox\n : turfBBox(geojson, { recalculate: true });\n var west = bbox[0];\n var south = bbox[1];\n var east = bbox[2];\n var north = bbox[3];\n\n switch (origin) {\n case \"sw\":\n case \"southwest\":\n case \"westsouth\":\n case \"bottomleft\":\n return point([west, south]);\n case \"se\":\n case \"southeast\":\n case \"eastsouth\":\n case \"bottomright\":\n return point([east, south]);\n case \"nw\":\n case \"northwest\":\n case \"westnorth\":\n case \"topleft\":\n return point([west, north]);\n case \"ne\":\n case \"northeast\":\n case \"eastnorth\":\n case \"topright\":\n return point([east, north]);\n case \"center\":\n return center(geojson);\n case undefined:\n case null:\n case \"centroid\":\n return centroid(geojson);\n default:\n throw new Error(\"invalid origin\");\n }\n}\n\nexport { transformScale };\nexport default transformScale;\n"]}
@@ -0,0 +1,15 @@
1
+ import { AllGeoJSON, Corners, Coord } from '@turf/helpers';
2
+
3
+ /**
4
+ * http://turfjs.org/docs/#transformscale
5
+ */
6
+ declare function transformScale<T extends AllGeoJSON>(
7
+ geojson: T,
8
+ factor: number,
9
+ options?: {
10
+ origin?: Corners | Coord;
11
+ mutate?: boolean;
12
+ }
13
+ ): T;
14
+
15
+ export { transformScale as default, transformScale };
@@ -0,0 +1,15 @@
1
+ import { AllGeoJSON, Corners, Coord } from '@turf/helpers';
2
+
3
+ /**
4
+ * http://turfjs.org/docs/#transformscale
5
+ */
6
+ declare function transformScale<T extends AllGeoJSON>(
7
+ geojson: T,
8
+ factor: number,
9
+ options?: {
10
+ origin?: Corners | Coord;
11
+ mutate?: boolean;
12
+ }
13
+ ): T;
14
+
15
+ export { transformScale as default, transformScale };
@@ -0,0 +1,103 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // index.js
5
+ import { clone } from "@turf/clone";
6
+ import { center } from "@turf/center";
7
+ import { centroid } from "@turf/centroid";
8
+ import { bbox as turfBBox } from "@turf/bbox";
9
+ import { rhumbBearing } from "@turf/rhumb-bearing";
10
+ import { rhumbDistance } from "@turf/rhumb-distance";
11
+ import { rhumbDestination } from "@turf/rhumb-destination";
12
+ import { coordEach, featureEach } from "@turf/meta";
13
+ import { point, isObject } from "@turf/helpers";
14
+ import { getCoord, getCoords, getType } from "@turf/invariant";
15
+ function transformScale(geojson, factor, options) {
16
+ options = options || {};
17
+ if (!isObject(options))
18
+ throw new Error("options is invalid");
19
+ var origin = options.origin;
20
+ var mutate = options.mutate;
21
+ if (!geojson)
22
+ throw new Error("geojson required");
23
+ if (typeof factor !== "number" || factor <= 0)
24
+ throw new Error("invalid factor");
25
+ var originIsPoint = Array.isArray(origin) || typeof origin === "object";
26
+ if (mutate !== true)
27
+ geojson = clone(geojson);
28
+ if (geojson.type === "FeatureCollection" && !originIsPoint) {
29
+ featureEach(geojson, function(feature, index) {
30
+ geojson.features[index] = scale(feature, factor, origin);
31
+ });
32
+ return geojson;
33
+ }
34
+ return scale(geojson, factor, origin);
35
+ }
36
+ __name(transformScale, "transformScale");
37
+ function scale(feature, factor, origin) {
38
+ var isPoint = getType(feature) === "Point";
39
+ origin = defineOrigin(feature, origin);
40
+ if (factor === 1 || isPoint)
41
+ return feature;
42
+ coordEach(feature, function(coord) {
43
+ var originalDistance = rhumbDistance(origin, coord);
44
+ var bearing = rhumbBearing(origin, coord);
45
+ var newDistance = originalDistance * factor;
46
+ var newCoord = getCoords(rhumbDestination(origin, newDistance, bearing));
47
+ coord[0] = newCoord[0];
48
+ coord[1] = newCoord[1];
49
+ if (coord.length === 3)
50
+ coord[2] *= factor;
51
+ });
52
+ delete feature.bbox;
53
+ return feature;
54
+ }
55
+ __name(scale, "scale");
56
+ function defineOrigin(geojson, origin) {
57
+ if (origin === void 0 || origin === null)
58
+ origin = "centroid";
59
+ if (Array.isArray(origin) || typeof origin === "object")
60
+ return getCoord(origin);
61
+ var bbox = geojson.bbox ? geojson.bbox : turfBBox(geojson, { recalculate: true });
62
+ var west = bbox[0];
63
+ var south = bbox[1];
64
+ var east = bbox[2];
65
+ var north = bbox[3];
66
+ switch (origin) {
67
+ case "sw":
68
+ case "southwest":
69
+ case "westsouth":
70
+ case "bottomleft":
71
+ return point([west, south]);
72
+ case "se":
73
+ case "southeast":
74
+ case "eastsouth":
75
+ case "bottomright":
76
+ return point([east, south]);
77
+ case "nw":
78
+ case "northwest":
79
+ case "westnorth":
80
+ case "topleft":
81
+ return point([west, north]);
82
+ case "ne":
83
+ case "northeast":
84
+ case "eastnorth":
85
+ case "topright":
86
+ return point([east, north]);
87
+ case "center":
88
+ return center(geojson);
89
+ case void 0:
90
+ case null:
91
+ case "centroid":
92
+ return centroid(geojson);
93
+ default:
94
+ throw new Error("invalid origin");
95
+ }
96
+ }
97
+ __name(defineOrigin, "defineOrigin");
98
+ var turf_transform_scale_default = transformScale;
99
+ export {
100
+ turf_transform_scale_default as default,
101
+ transformScale
102
+ };
103
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../index.js"],"sourcesContent":["import { clone } from \"@turf/clone\";\nimport { center } from \"@turf/center\";\nimport { centroid } from \"@turf/centroid\";\nimport { bbox as turfBBox } from \"@turf/bbox\";\nimport { rhumbBearing } from \"@turf/rhumb-bearing\";\nimport { rhumbDistance } from \"@turf/rhumb-distance\";\nimport { rhumbDestination } from \"@turf/rhumb-destination\";\nimport { coordEach, featureEach } from \"@turf/meta\";\nimport { point, isObject } from \"@turf/helpers\";\nimport { getCoord, getCoords, getType } from \"@turf/invariant\";\n\n/**\n * Scale a GeoJSON from a given point by a factor of scaling (ex: factor=2 would make the GeoJSON 200% larger).\n * If a FeatureCollection is provided, the origin point will be calculated based on each individual Feature.\n *\n * @name transformScale\n * @param {GeoJSON} geojson GeoJSON to be scaled\n * @param {number} factor of scaling, positive values greater than 0. Numbers between 0 and 1 will shrink the geojson, numbers greater than 1 will expand it, a factor of 1 will not change the geojson.\n * @param {Object} [options={}] Optional parameters\n * @param {string|Coord} [options.origin='centroid'] Point from which the scaling will occur (string options: sw/se/nw/ne/center/centroid)\n * @param {boolean} [options.mutate=false] allows GeoJSON input to be mutated (significant performance increase if true)\n * @returns {GeoJSON} scaled GeoJSON\n * @example\n * var poly = turf.polygon([[[0,29],[3.5,29],[2.5,32],[0,29]]]);\n * var scaledPoly = turf.transformScale(poly, 3);\n *\n * //addToMap\n * var addToMap = [poly, scaledPoly];\n * scaledPoly.properties = {stroke: '#F00', 'stroke-width': 4};\n */\nfunction transformScale(geojson, factor, options) {\n // Optional parameters\n options = options || {};\n if (!isObject(options)) throw new Error(\"options is invalid\");\n var origin = options.origin;\n var mutate = options.mutate;\n\n // Input validation\n if (!geojson) throw new Error(\"geojson required\");\n if (typeof factor !== \"number\" || factor <= 0)\n throw new Error(\"invalid factor\");\n var originIsPoint = Array.isArray(origin) || typeof origin === \"object\";\n\n // Clone geojson to avoid side effects\n if (mutate !== true) geojson = clone(geojson);\n\n // Scale each Feature separately\n if (geojson.type === \"FeatureCollection\" && !originIsPoint) {\n featureEach(geojson, function (feature, index) {\n geojson.features[index] = scale(feature, factor, origin);\n });\n return geojson;\n }\n // Scale Feature/Geometry\n return scale(geojson, factor, origin);\n}\n\n/**\n * Scale Feature/Geometry\n *\n * @private\n * @param {Feature|Geometry} feature GeoJSON Feature/Geometry\n * @param {number} factor of scaling, positive or negative values greater than 0\n * @param {string|Coord} [origin=\"centroid\"] Point from which the scaling will occur (string options: sw/se/nw/ne/center/centroid)\n * @returns {Feature|Geometry} scaled GeoJSON Feature/Geometry\n */\nfunction scale(feature, factor, origin) {\n // Default params\n var isPoint = getType(feature) === \"Point\";\n origin = defineOrigin(feature, origin);\n\n // Shortcut no-scaling\n if (factor === 1 || isPoint) return feature;\n\n // Scale each coordinate\n coordEach(feature, function (coord) {\n var originalDistance = rhumbDistance(origin, coord);\n var bearing = rhumbBearing(origin, coord);\n var newDistance = originalDistance * factor;\n var newCoord = getCoords(rhumbDestination(origin, newDistance, bearing));\n coord[0] = newCoord[0];\n coord[1] = newCoord[1];\n if (coord.length === 3) coord[2] *= factor;\n });\n\n delete feature.bbox;\n\n return feature;\n}\n\n/**\n * Define Origin\n *\n * @private\n * @param {GeoJSON} geojson GeoJSON\n * @param {string|Coord} origin sw/se/nw/ne/center/centroid\n * @returns {Feature<Point>} Point origin\n */\nfunction defineOrigin(geojson, origin) {\n // Default params\n if (origin === undefined || origin === null) origin = \"centroid\";\n\n // Input Coord\n if (Array.isArray(origin) || typeof origin === \"object\")\n return getCoord(origin);\n\n // Define BBox\n var bbox = geojson.bbox\n ? geojson.bbox\n : turfBBox(geojson, { recalculate: true });\n var west = bbox[0];\n var south = bbox[1];\n var east = bbox[2];\n var north = bbox[3];\n\n switch (origin) {\n case \"sw\":\n case \"southwest\":\n case \"westsouth\":\n case \"bottomleft\":\n return point([west, south]);\n case \"se\":\n case \"southeast\":\n case \"eastsouth\":\n case \"bottomright\":\n return point([east, south]);\n case \"nw\":\n case \"northwest\":\n case \"westnorth\":\n case \"topleft\":\n return point([west, north]);\n case \"ne\":\n case \"northeast\":\n case \"eastnorth\":\n case \"topright\":\n return point([east, north]);\n case \"center\":\n return center(geojson);\n case undefined:\n case null:\n case \"centroid\":\n return centroid(geojson);\n default:\n throw new Error(\"invalid origin\");\n }\n}\n\nexport { transformScale };\nexport default transformScale;\n"],"mappings":";;;;A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eoJSON } from "@turf/helpers";
3
3
  /**
4
4
  * http://turfjs.org/docs/#transformscale
5
5
  */
6
- export default function transformScale<T extends AllGeoJSON>(
6
+ declare function transformScale<T extends AllGeoJSON>(
7
7
  geojson: T,
8
8
  factor: number,
9
9
  options?: {
@@ -11,3 +11,6 @@ export default function transformScale<T extends AllGeoJSON>(
11
11
  mutate?: boolean;
12
12
  }
13
13
  ): T;
14
+
15
+ export { transformScale };
16
+ export default transformScale;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turf/transform-scale",
3
- "version": "7.0.0-alpha.0",
3
+ "version": "7.0.0-alpha.110+1411d63a7",
4
4
  "description": "turf transform-scale module",
5
5
  "author": "Turf Authors",
6
6
  "contributors": [
@@ -30,51 +30,59 @@
30
30
  "zoom-in",
31
31
  "zoom-out"
32
32
  ],
33
- "main": "dist/js/index.js",
34
- "module": "dist/es/index.js",
33
+ "type": "commonjs",
34
+ "main": "dist/cjs/index.cjs",
35
+ "module": "dist/esm/index.mjs",
36
+ "types": "dist/cjs/index.d.ts",
35
37
  "exports": {
36
38
  "./package.json": "./package.json",
37
39
  ".": {
38
- "import": "./dist/es/index.js",
39
- "require": "./dist/js/index.js"
40
+ "import": {
41
+ "types": "./dist/esm/index.d.mts",
42
+ "default": "./dist/esm/index.mjs"
43
+ },
44
+ "require": {
45
+ "types": "./dist/cjs/index.d.ts",
46
+ "default": "./dist/cjs/index.cjs"
47
+ }
40
48
  }
41
49
  },
42
- "types": "index.d.ts",
43
50
  "sideEffects": false,
44
51
  "files": [
45
52
  "dist",
46
53
  "index.d.ts"
47
54
  ],
48
55
  "scripts": {
49
- "bench": "node -r esm bench.js",
50
- "build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json",
51
- "docs": "node ../../scripts/generate-readmes",
52
- "test": "npm-run-all test:*",
53
- "test:tape": "node -r esm test.js",
56
+ "bench": "tsx bench.ts",
57
+ "build": "tsup --config ../../tsup.config.ts",
58
+ "docs": "tsx ../../scripts/generate-readmes.ts",
59
+ "test": "npm-run-all --npm-path npm test:*",
60
+ "test:tape": "tsx test.ts",
54
61
  "test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
55
62
  },
56
63
  "devDependencies": {
57
- "@turf/bbox-polygon": "^7.0.0-alpha.0",
58
- "@turf/hex-grid": "^7.0.0-alpha.0",
59
- "@turf/truncate": "^7.0.0-alpha.0",
60
- "benchmark": "*",
61
- "load-json-file": "*",
62
- "npm-run-all": "*",
63
- "rollup": "*",
64
- "tape": "*",
65
- "write-json-file": "*"
64
+ "@turf/bbox-polygon": "^7.0.0-alpha.110+1411d63a7",
65
+ "@turf/hex-grid": "^7.0.0-alpha.110+1411d63a7",
66
+ "@turf/truncate": "^7.0.0-alpha.110+1411d63a7",
67
+ "benchmark": "^2.1.4",
68
+ "load-json-file": "^7.0.1",
69
+ "npm-run-all": "^4.1.5",
70
+ "tape": "^5.7.2",
71
+ "tsup": "^8.0.1",
72
+ "tsx": "^4.6.2",
73
+ "write-json-file": "^5.0.0"
66
74
  },
67
75
  "dependencies": {
68
- "@turf/bbox": "^7.0.0-alpha.0",
69
- "@turf/center": "^7.0.0-alpha.0",
70
- "@turf/centroid": "^7.0.0-alpha.0",
71
- "@turf/clone": "^7.0.0-alpha.0",
72
- "@turf/helpers": "^7.0.0-alpha.0",
73
- "@turf/invariant": "^7.0.0-alpha.0",
74
- "@turf/meta": "^7.0.0-alpha.0",
75
- "@turf/rhumb-bearing": "^7.0.0-alpha.0",
76
- "@turf/rhumb-destination": "^7.0.0-alpha.0",
77
- "@turf/rhumb-distance": "^7.0.0-alpha.0"
76
+ "@turf/bbox": "^7.0.0-alpha.110+1411d63a7",
77
+ "@turf/center": "^7.0.0-alpha.110+1411d63a7",
78
+ "@turf/centroid": "^7.0.0-alpha.110+1411d63a7",
79
+ "@turf/clone": "^7.0.0-alpha.110+1411d63a7",
80
+ "@turf/helpers": "^7.0.0-alpha.110+1411d63a7",
81
+ "@turf/invariant": "^7.0.0-alpha.110+1411d63a7",
82
+ "@turf/meta": "^7.0.0-alpha.110+1411d63a7",
83
+ "@turf/rhumb-bearing": "^7.0.0-alpha.110+1411d63a7",
84
+ "@turf/rhumb-destination": "^7.0.0-alpha.110+1411d63a7",
85
+ "@turf/rhumb-distance": "^7.0.0-alpha.110+1411d63a7"
78
86
  },
79
- "gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189"
87
+ "gitHead": "1411d63a74c275c9216fe48e9d3cb2d48a359068"
80
88
  }
package/dist/es/index.js DELETED
@@ -1,148 +0,0 @@
1
- import clone from '@turf/clone';
2
- import center from '@turf/center';
3
- import centroid from '@turf/centroid';
4
- import turfBBox from '@turf/bbox';
5
- import rhumbBearing from '@turf/rhumb-bearing';
6
- import rhumbDistance from '@turf/rhumb-distance';
7
- import rhumbDestination from '@turf/rhumb-destination';
8
- import { featureEach, coordEach } from '@turf/meta';
9
- import { isObject, point } from '@turf/helpers';
10
- import { getType, getCoords, getCoord } from '@turf/invariant';
11
-
12
- /**
13
- * Scale a GeoJSON from a given point by a factor of scaling (ex: factor=2 would make the GeoJSON 200% larger).
14
- * If a FeatureCollection is provided, the origin point will be calculated based on each individual Feature.
15
- *
16
- * @name transformScale
17
- * @param {GeoJSON} geojson GeoJSON to be scaled
18
- * @param {number} factor of scaling, positive values greater than 0. Numbers between 0 and 1 will shrink the geojson, numbers greater than 1 will expand it, a factor of 1 will not change the geojson.
19
- * @param {Object} [options={}] Optional parameters
20
- * @param {string|Coord} [options.origin='centroid'] Point from which the scaling will occur (string options: sw/se/nw/ne/center/centroid)
21
- * @param {boolean} [options.mutate=false] allows GeoJSON input to be mutated (significant performance increase if true)
22
- * @returns {GeoJSON} scaled GeoJSON
23
- * @example
24
- * var poly = turf.polygon([[[0,29],[3.5,29],[2.5,32],[0,29]]]);
25
- * var scaledPoly = turf.transformScale(poly, 3);
26
- *
27
- * //addToMap
28
- * var addToMap = [poly, scaledPoly];
29
- * scaledPoly.properties = {stroke: '#F00', 'stroke-width': 4};
30
- */
31
- function transformScale(geojson, factor, options) {
32
- // Optional parameters
33
- options = options || {};
34
- if (!isObject(options)) throw new Error("options is invalid");
35
- var origin = options.origin;
36
- var mutate = options.mutate;
37
-
38
- // Input validation
39
- if (!geojson) throw new Error("geojson required");
40
- if (typeof factor !== "number" || factor <= 0)
41
- throw new Error("invalid factor");
42
- var originIsPoint = Array.isArray(origin) || typeof origin === "object";
43
-
44
- // Clone geojson to avoid side effects
45
- if (mutate !== true) geojson = clone(geojson);
46
-
47
- // Scale each Feature separately
48
- if (geojson.type === "FeatureCollection" && !originIsPoint) {
49
- featureEach(geojson, function (feature, index) {
50
- geojson.features[index] = scale(feature, factor, origin);
51
- });
52
- return geojson;
53
- }
54
- // Scale Feature/Geometry
55
- return scale(geojson, factor, origin);
56
- }
57
-
58
- /**
59
- * Scale Feature/Geometry
60
- *
61
- * @private
62
- * @param {Feature|Geometry} feature GeoJSON Feature/Geometry
63
- * @param {number} factor of scaling, positive or negative values greater than 0
64
- * @param {string|Coord} [origin="centroid"] Point from which the scaling will occur (string options: sw/se/nw/ne/center/centroid)
65
- * @returns {Feature|Geometry} scaled GeoJSON Feature/Geometry
66
- */
67
- function scale(feature, factor, origin) {
68
- // Default params
69
- var isPoint = getType(feature) === "Point";
70
- origin = defineOrigin(feature, origin);
71
-
72
- // Shortcut no-scaling
73
- if (factor === 1 || isPoint) return feature;
74
-
75
- // Scale each coordinate
76
- coordEach(feature, function (coord) {
77
- var originalDistance = rhumbDistance(origin, coord);
78
- var bearing = rhumbBearing(origin, coord);
79
- var newDistance = originalDistance * factor;
80
- var newCoord = getCoords(rhumbDestination(origin, newDistance, bearing));
81
- coord[0] = newCoord[0];
82
- coord[1] = newCoord[1];
83
- if (coord.length === 3) coord[2] *= factor;
84
- });
85
-
86
- delete feature.bbox;
87
-
88
- return feature;
89
- }
90
-
91
- /**
92
- * Define Origin
93
- *
94
- * @private
95
- * @param {GeoJSON} geojson GeoJSON
96
- * @param {string|Coord} origin sw/se/nw/ne/center/centroid
97
- * @returns {Feature<Point>} Point origin
98
- */
99
- function defineOrigin(geojson, origin) {
100
- // Default params
101
- if (origin === undefined || origin === null) origin = "centroid";
102
-
103
- // Input Coord
104
- if (Array.isArray(origin) || typeof origin === "object")
105
- return getCoord(origin);
106
-
107
- // Define BBox
108
- var bbox = geojson.bbox
109
- ? geojson.bbox
110
- : turfBBox(geojson, { recalculate: true });
111
- var west = bbox[0];
112
- var south = bbox[1];
113
- var east = bbox[2];
114
- var north = bbox[3];
115
-
116
- switch (origin) {
117
- case "sw":
118
- case "southwest":
119
- case "westsouth":
120
- case "bottomleft":
121
- return point([west, south]);
122
- case "se":
123
- case "southeast":
124
- case "eastsouth":
125
- case "bottomright":
126
- return point([east, south]);
127
- case "nw":
128
- case "northwest":
129
- case "westnorth":
130
- case "topleft":
131
- return point([west, north]);
132
- case "ne":
133
- case "northeast":
134
- case "eastnorth":
135
- case "topright":
136
- return point([east, north]);
137
- case "center":
138
- return center(geojson);
139
- case undefined:
140
- case null:
141
- case "centroid":
142
- return centroid(geojson);
143
- default:
144
- throw new Error("invalid origin");
145
- }
146
- }
147
-
148
- export default transformScale;
@@ -1 +0,0 @@
1
- {"type":"module"}
package/dist/js/index.js DELETED
@@ -1,161 +0,0 @@
1
- 'use strict';
2
-
3
- var clone = require('@turf/clone');
4
- var center = require('@turf/center');
5
- var centroid = require('@turf/centroid');
6
- var turfBBox = require('@turf/bbox');
7
- var rhumbBearing = require('@turf/rhumb-bearing');
8
- var rhumbDistance = require('@turf/rhumb-distance');
9
- var rhumbDestination = require('@turf/rhumb-destination');
10
- var meta = require('@turf/meta');
11
- var helpers = require('@turf/helpers');
12
- var invariant = require('@turf/invariant');
13
-
14
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
15
-
16
- var clone__default = /*#__PURE__*/_interopDefaultLegacy(clone);
17
- var center__default = /*#__PURE__*/_interopDefaultLegacy(center);
18
- var centroid__default = /*#__PURE__*/_interopDefaultLegacy(centroid);
19
- var turfBBox__default = /*#__PURE__*/_interopDefaultLegacy(turfBBox);
20
- var rhumbBearing__default = /*#__PURE__*/_interopDefaultLegacy(rhumbBearing);
21
- var rhumbDistance__default = /*#__PURE__*/_interopDefaultLegacy(rhumbDistance);
22
- var rhumbDestination__default = /*#__PURE__*/_interopDefaultLegacy(rhumbDestination);
23
-
24
- /**
25
- * Scale a GeoJSON from a given point by a factor of scaling (ex: factor=2 would make the GeoJSON 200% larger).
26
- * If a FeatureCollection is provided, the origin point will be calculated based on each individual Feature.
27
- *
28
- * @name transformScale
29
- * @param {GeoJSON} geojson GeoJSON to be scaled
30
- * @param {number} factor of scaling, positive values greater than 0. Numbers between 0 and 1 will shrink the geojson, numbers greater than 1 will expand it, a factor of 1 will not change the geojson.
31
- * @param {Object} [options={}] Optional parameters
32
- * @param {string|Coord} [options.origin='centroid'] Point from which the scaling will occur (string options: sw/se/nw/ne/center/centroid)
33
- * @param {boolean} [options.mutate=false] allows GeoJSON input to be mutated (significant performance increase if true)
34
- * @returns {GeoJSON} scaled GeoJSON
35
- * @example
36
- * var poly = turf.polygon([[[0,29],[3.5,29],[2.5,32],[0,29]]]);
37
- * var scaledPoly = turf.transformScale(poly, 3);
38
- *
39
- * //addToMap
40
- * var addToMap = [poly, scaledPoly];
41
- * scaledPoly.properties = {stroke: '#F00', 'stroke-width': 4};
42
- */
43
- function transformScale(geojson, factor, options) {
44
- // Optional parameters
45
- options = options || {};
46
- if (!helpers.isObject(options)) throw new Error("options is invalid");
47
- var origin = options.origin;
48
- var mutate = options.mutate;
49
-
50
- // Input validation
51
- if (!geojson) throw new Error("geojson required");
52
- if (typeof factor !== "number" || factor <= 0)
53
- throw new Error("invalid factor");
54
- var originIsPoint = Array.isArray(origin) || typeof origin === "object";
55
-
56
- // Clone geojson to avoid side effects
57
- if (mutate !== true) geojson = clone__default['default'](geojson);
58
-
59
- // Scale each Feature separately
60
- if (geojson.type === "FeatureCollection" && !originIsPoint) {
61
- meta.featureEach(geojson, function (feature, index) {
62
- geojson.features[index] = scale(feature, factor, origin);
63
- });
64
- return geojson;
65
- }
66
- // Scale Feature/Geometry
67
- return scale(geojson, factor, origin);
68
- }
69
-
70
- /**
71
- * Scale Feature/Geometry
72
- *
73
- * @private
74
- * @param {Feature|Geometry} feature GeoJSON Feature/Geometry
75
- * @param {number} factor of scaling, positive or negative values greater than 0
76
- * @param {string|Coord} [origin="centroid"] Point from which the scaling will occur (string options: sw/se/nw/ne/center/centroid)
77
- * @returns {Feature|Geometry} scaled GeoJSON Feature/Geometry
78
- */
79
- function scale(feature, factor, origin) {
80
- // Default params
81
- var isPoint = invariant.getType(feature) === "Point";
82
- origin = defineOrigin(feature, origin);
83
-
84
- // Shortcut no-scaling
85
- if (factor === 1 || isPoint) return feature;
86
-
87
- // Scale each coordinate
88
- meta.coordEach(feature, function (coord) {
89
- var originalDistance = rhumbDistance__default['default'](origin, coord);
90
- var bearing = rhumbBearing__default['default'](origin, coord);
91
- var newDistance = originalDistance * factor;
92
- var newCoord = invariant.getCoords(rhumbDestination__default['default'](origin, newDistance, bearing));
93
- coord[0] = newCoord[0];
94
- coord[1] = newCoord[1];
95
- if (coord.length === 3) coord[2] *= factor;
96
- });
97
-
98
- delete feature.bbox;
99
-
100
- return feature;
101
- }
102
-
103
- /**
104
- * Define Origin
105
- *
106
- * @private
107
- * @param {GeoJSON} geojson GeoJSON
108
- * @param {string|Coord} origin sw/se/nw/ne/center/centroid
109
- * @returns {Feature<Point>} Point origin
110
- */
111
- function defineOrigin(geojson, origin) {
112
- // Default params
113
- if (origin === undefined || origin === null) origin = "centroid";
114
-
115
- // Input Coord
116
- if (Array.isArray(origin) || typeof origin === "object")
117
- return invariant.getCoord(origin);
118
-
119
- // Define BBox
120
- var bbox = geojson.bbox
121
- ? geojson.bbox
122
- : turfBBox__default['default'](geojson, { recalculate: true });
123
- var west = bbox[0];
124
- var south = bbox[1];
125
- var east = bbox[2];
126
- var north = bbox[3];
127
-
128
- switch (origin) {
129
- case "sw":
130
- case "southwest":
131
- case "westsouth":
132
- case "bottomleft":
133
- return helpers.point([west, south]);
134
- case "se":
135
- case "southeast":
136
- case "eastsouth":
137
- case "bottomright":
138
- return helpers.point([east, south]);
139
- case "nw":
140
- case "northwest":
141
- case "westnorth":
142
- case "topleft":
143
- return helpers.point([west, north]);
144
- case "ne":
145
- case "northeast":
146
- case "eastnorth":
147
- case "topright":
148
- return helpers.point([east, north]);
149
- case "center":
150
- return center__default['default'](geojson);
151
- case undefined:
152
- case null:
153
- case "centroid":
154
- return centroid__default['default'](geojson);
155
- default:
156
- throw new Error("invalid origin");
157
- }
158
- }
159
-
160
- module.exports = transformScale;
161
- module.exports.default = transformScale;