@turf/transform-scale 7.2.0 → 7.3.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 +2 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/package.json +21 -21
package/dist/cjs/index.cjs
CHANGED
|
@@ -101,9 +101,9 @@ function defineOrigin(geojson, origin) {
|
|
|
101
101
|
throw new Error("invalid origin");
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
-
var
|
|
104
|
+
var index_default = transformScale;
|
|
105
105
|
|
|
106
106
|
|
|
107
107
|
|
|
108
|
-
exports.default =
|
|
108
|
+
exports.default = index_default; exports.transformScale = transformScale;
|
|
109
109
|
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/turf/turf/packages/turf-transform-scale/dist/cjs/index.cjs","../../index.ts"],"names":[],"mappings":"AAAA;ACEA,oCAAsB;AACtB,sCAAuB;AACvB,0CAAyB;AACzB,kCAAiC;AACjC,mDAA6B;AAC7B,qDAA8B;AAC9B,2DAAiC;AACjC,kCAAuC;AACvC,wCAAgC;AAChC,4CAA6C;AAuB7C,SAAS,cAAA,CACP,OAAA,EACA,MAAA,EACA,OAAA,EAIG;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,MAAM,OAAA,EAAS,OAAA,CAAQ,OAAA,GAAU,UAAA;AACjC,EAAA,MAAM,OAAA,EAAS,OAAA,CAAQ,OAAA,GAAU,KAAA;AAGjC,EAAA,GAAA,CAAI,CAAC,OAAA,EAAS,MAAM,IAAI,KAAA,CAAM,kBAAkB,CAAA;AAChD,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AC5B,KAAK,IAAA;AAAA;AAAA,IAEL,KAAK,WAAA;AAAA;AAAA,IAEL,KAAK,WAAA;AAAA;AAAA,IAEL,KAAK,aAAA;AACH,MAAA,OAAO,4BAAA,CAAO,IAAA,EAAM,KAAK,CAAC,CAAA;AAAA,IAC5B,KAAK,IAAA;AAAA;AAAA,IAEL,KAAK,WAAA;AAAA;AAAA,IAEL,KAAK,WAAA;AAAA;AAAA,IAEL,KAAK,SAAA;AACH,MAAA,OAAO,4BAAA,CAAO,IAAA,EAAM,KAAK,CAAC,CAAA;AAAA,IAC5B,KAAK,IAAA;AAAA;AAAA,IAEL,KAAK,WAAA;AAAA;AAAA,IAEL,KAAK,WAAA;AAAA;AAAA,IAEL,KAAK,UAAA;AACH,MAAA,OAAO,4BAAA,CAAO,IAAA,EAAM,KAAK,CAAC,CAAA;AAAA,IAC5B,KAAK,QAAA;AACH,MAAA,OAAO,4BAAA,OAAc,CAAA;AAAA,IACvB,KAAK,KAAA,CAAA;AAAA,IACL,KAAK,IAAA;AAAA,IACL,KAAK,UAAA;AACH,MAAA,OAAO,gCAAA,OAAgB,CAAA;AAAA,IACzB,OAAA;AACE,MAAA,MAAM,IAAI,KAAA,CAAM,gBAAgB,CAAA;AAAA,EACpC;AAEF;AAGA,IAAO,6BAAA,EAAQ,cAAA;AD1Ff;AACE;AACA;AACF,wFAAC","file":"/home/runner/work/turf/turf/packages/turf-transform-scale/dist/cjs/index.cjs","sourcesContent":[null,"import { Corners, Coord } from \"@turf/helpers\";\nimport { FeatureCollection, GeoJSON, GeometryCollection } from \"geojson\";\nimport { 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 GeoJSON objects from a given point by a scaling factor e.g. factor=2\n * would make each object 200% larger.\n * If a FeatureCollection is provided, the origin point will be calculated\n * based on each individual feature _unless_ an exact\n *\n * @function\n * @param {GeoJSON|GeometryCollection} geojson objects 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 {Corners|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 improvement if true)\n * @returns {GeoJSON|GeometryCollection} scaled GeoJSON\n * @example\n * const poly = turf.polygon([[[0,29],[3.5,29],[2.5,32],[0,29]]]);\n * const scaledPoly = turf.transformScale(poly, 3);\n *\n * //addToMap\n * const addToMap = [poly, scaledPoly];\n * scaledPoly.properties = {stroke: '#F00', 'stroke-width': 4};\n */\nfunction transformScale<T extends GeoJSON | GeometryCollection>(\n geojson: T,\n factor: number,\n options?: {\n origin?: Corners | Coord;\n mutate?: boolean;\n }\n): T {\n // Optional parameters\n options = options || {};\n if (!isObject(options)) throw new Error(\"options is invalid\");\n const origin = options.origin || \"centroid\";\n const mutate = options.mutate || false;\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 const 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 if a feature collection AND the user didn't\n // pass a single explicit point to scale the whole collection from.\n if (geojson.type === \"FeatureCollection\" && !originIsPoint) {\n featureEach(geojson, function (feature, index) {\n // The type guard above is not recognised in the callback so we have to\n // cast to accept responsibility.\n (geojson as FeatureCollection).features[index] = scale(\n feature,\n factor,\n origin\n );\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 {GeoJSON|GeometryCollection} feature feature or geometry collection to scale\n * @param {number} factor of scaling, positive or negative values greater than 0\n * @param {Corners|Coord} [origin=\"centroid\"] Point from which the scaling will occur (string options: sw/se/nw/ne/center/centroid)\n * @returns {GeoJSON|GeometryCollection} scaled GeoJSON Feature/Geometry\n */\nfunction scale<T extends GeoJSON | GeometryCollection>(\n feature: T,\n factor: number,\n origin: Corners | Coord\n): T {\n // Default params\n const isPoint = getType(feature) === \"Point\";\n // Work with a Coord equivalent of the origin from here on.\n const originCoord: Coord = 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 const originalDistance = rhumbDistance(originCoord, coord);\n const bearing = rhumbBearing(originCoord, coord);\n const newDistance = originalDistance * factor;\n const newCoord = getCoords(\n rhumbDestination(originCoord, newDistance, bearing)\n );\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|GeometryCollection} geojson GeoJSON\n * @param {Corners|Coord} origin sw/se/nw/ne/center/centroid\n * @returns {Feature<Point>} Point origin\n */\nfunction defineOrigin(\n geojson: GeoJSON | GeometryCollection,\n origin: Corners | Coord\n): Coord {\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 const bbox = geojson.bbox\n ? geojson.bbox\n : turfBBox(geojson, { recompute: true });\n const west = bbox[0];\n const south = bbox[1];\n const east = bbox[2];\n const north = bbox[3];\n\n // Having to disable eslint below for lines which fail the no-fallthrough\n // rule, though only because of the ts-expect-error rules. Once we remove\n // southeast, bottomright, rightbottom, etc we should be able to remove all\n // these supressions.\n /* eslint-disable no-fallthrough */\n switch (origin) {\n case \"sw\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"southwest\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"westsouth\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"bottomleft\":\n return point([west, south]);\n case \"se\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"southeast\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"eastsouth\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"bottomright\":\n return point([east, south]);\n case \"nw\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"northwest\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"westnorth\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"topleft\":\n return point([west, north]);\n case \"ne\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"northeast\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"eastnorth\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\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 /* eslint-enable no-fallthrough */\n}\n\nexport { transformScale };\nexport default transformScale;\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/turf/turf/packages/turf-transform-scale/dist/cjs/index.cjs","../../index.ts"],"names":[],"mappings":"AAAA;ACEA,oCAAsB;AACtB,sCAAuB;AACvB,0CAAyB;AACzB,kCAAiC;AACjC,mDAA6B;AAC7B,qDAA8B;AAC9B,2DAAiC;AACjC,kCAAuC;AACvC,wCAAgC;AAChC,4CAA6C;AAuB7C,SAAS,cAAA,CACP,OAAA,EACA,MAAA,EACA,OAAA,EAIG;AAEH,EAAA,QAAA,EAAU,QAAA,GAAW,CAAC,CAAA;AACtB,EAAA,GAAA,CAAI,C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CAAA;AACnB,EAAA,MAAM,MAAA,EAAQ,IAAA,CAAK,CAAC,CAAA;AAOpB,EAAA,OAAA,CAAQ,MAAA,EAAQ;AAAA,IACd,KAAK,IAAA;AAAA;AAAA,IAEL,KAAK,WAAA;AAAA;AAAA,IAEL,KAAK,WAAA;AAAA;AAAA,IAEL,KAAK,YAAA;AACH,MAAA,OAAO,4BAAA,CAAO,IAAA,EAAM,KAAK,CAAC,CAAA;AAAA,IAC5B,KAAK,IAAA;AAAA;AAAA,IAEL,KAAK,WAAA;AAAA;AAAA,IAEL,KAAK,WAAA;AAAA;AAAA,IAEL,KAAK,aAAA;AACH,MAAA,OAAO,4BAAA,CAAO,IAAA,EAAM,KAAK,CAAC,CAAA;AAAA,IAC5B,KAAK,IAAA;AAAA;AAAA,IAEL,KAAK,WAAA;AAAA;AAAA,IAEL,KAAK,WAAA;AAAA;AAAA,IAEL,KAAK,SAAA;AACH,MAAA,OAAO,4BAAA,CAAO,IAAA,EAAM,KAAK,CAAC,CAAA;AAAA,IAC5B,KAAK,IAAA;AAAA;AAAA,IAEL,KAAK,WAAA;AAAA;AAAA,IAEL,KAAK,WAAA;AAAA;AAAA,IAEL,KAAK,UAAA;AACH,MAAA,OAAO,4BAAA,CAAO,IAAA,EAAM,KAAK,CAAC,CAAA;AAAA,IAC5B,KAAK,QAAA;AACH,MAAA,OAAO,4BAAA,OAAc,CAAA;AAAA,IACvB,KAAK,KAAA,CAAA;AAAA,IACL,KAAK,IAAA;AAAA,IACL,KAAK,UAAA;AACH,MAAA,OAAO,gCAAA,OAAgB,CAAA;AAAA,IACzB,OAAA;AACE,MAAA,MAAM,IAAI,KAAA,CAAM,gBAAgB,CAAA;AAAA,EACpC;AAEF;AAGA,IAAO,cAAA,EAAQ,cAAA;AD1Ff;AACE;AACA;AACF,yEAAC","file":"/home/runner/work/turf/turf/packages/turf-transform-scale/dist/cjs/index.cjs","sourcesContent":[null,"import { Corners, Coord } from \"@turf/helpers\";\nimport { FeatureCollection, GeoJSON, GeometryCollection } from \"geojson\";\nimport { 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 GeoJSON objects from a given point by a scaling factor e.g. factor=2\n * would make each object 200% larger.\n * If a FeatureCollection is provided, the origin point will be calculated\n * based on each individual feature _unless_ an exact\n *\n * @function\n * @param {GeoJSON|GeometryCollection} geojson objects 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 {Corners|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 improvement if true)\n * @returns {GeoJSON|GeometryCollection} scaled GeoJSON\n * @example\n * const poly = turf.polygon([[[0,29],[3.5,29],[2.5,32],[0,29]]]);\n * const scaledPoly = turf.transformScale(poly, 3);\n *\n * //addToMap\n * const addToMap = [poly, scaledPoly];\n * scaledPoly.properties = {stroke: '#F00', 'stroke-width': 4};\n */\nfunction transformScale<T extends GeoJSON | GeometryCollection>(\n geojson: T,\n factor: number,\n options?: {\n origin?: Corners | Coord;\n mutate?: boolean;\n }\n): T {\n // Optional parameters\n options = options || {};\n if (!isObject(options)) throw new Error(\"options is invalid\");\n const origin = options.origin || \"centroid\";\n const mutate = options.mutate || false;\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 const 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 if a feature collection AND the user didn't\n // pass a single explicit point to scale the whole collection from.\n if (geojson.type === \"FeatureCollection\" && !originIsPoint) {\n featureEach(geojson, function (feature, index) {\n // The type guard above is not recognised in the callback so we have to\n // cast to accept responsibility.\n (geojson as FeatureCollection).features[index] = scale(\n feature,\n factor,\n origin\n );\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 {GeoJSON|GeometryCollection} feature feature or geometry collection to scale\n * @param {number} factor of scaling, positive or negative values greater than 0\n * @param {Corners|Coord} [origin=\"centroid\"] Point from which the scaling will occur (string options: sw/se/nw/ne/center/centroid)\n * @returns {GeoJSON|GeometryCollection} scaled GeoJSON Feature/Geometry\n */\nfunction scale<T extends GeoJSON | GeometryCollection>(\n feature: T,\n factor: number,\n origin: Corners | Coord\n): T {\n // Default params\n const isPoint = getType(feature) === \"Point\";\n // Work with a Coord equivalent of the origin from here on.\n const originCoord: Coord = 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 const originalDistance = rhumbDistance(originCoord, coord);\n const bearing = rhumbBearing(originCoord, coord);\n const newDistance = originalDistance * factor;\n const newCoord = getCoords(\n rhumbDestination(originCoord, newDistance, bearing)\n );\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|GeometryCollection} geojson GeoJSON\n * @param {Corners|Coord} origin sw/se/nw/ne/center/centroid\n * @returns {Feature<Point>} Point origin\n */\nfunction defineOrigin(\n geojson: GeoJSON | GeometryCollection,\n origin: Corners | Coord\n): Coord {\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 const bbox = geojson.bbox\n ? geojson.bbox\n : turfBBox(geojson, { recompute: true });\n const west = bbox[0];\n const south = bbox[1];\n const east = bbox[2];\n const north = bbox[3];\n\n // Having to disable eslint below for lines which fail the no-fallthrough\n // rule, though only because of the ts-expect-error rules. Once we remove\n // southeast, bottomright, rightbottom, etc we should be able to remove all\n // these supressions.\n /* eslint-disable no-fallthrough */\n switch (origin) {\n case \"sw\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"southwest\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"westsouth\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"bottomleft\":\n return point([west, south]);\n case \"se\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"southeast\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"eastsouth\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"bottomright\":\n return point([east, south]);\n case \"nw\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"northwest\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"westnorth\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"topleft\":\n return point([west, north]);\n case \"ne\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"northeast\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"eastnorth\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\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 /* eslint-enable no-fallthrough */\n}\n\nexport { transformScale };\nexport default transformScale;\n"]}
|
package/dist/esm/index.js
CHANGED
|
@@ -101,9 +101,9 @@ function defineOrigin(geojson, origin) {
|
|
|
101
101
|
throw new Error("invalid origin");
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
-
var
|
|
104
|
+
var index_default = transformScale;
|
|
105
105
|
export {
|
|
106
|
-
|
|
106
|
+
index_default as default,
|
|
107
107
|
transformScale
|
|
108
108
|
};
|
|
109
109
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import { Corners, Coord } from \"@turf/helpers\";\nimport { FeatureCollection, GeoJSON, GeometryCollection } from \"geojson\";\nimport { 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 GeoJSON objects from a given point by a scaling factor e.g. factor=2\n * would make each object 200% larger.\n * If a FeatureCollection is provided, the origin point will be calculated\n * based on each individual feature _unless_ an exact\n *\n * @function\n * @param {GeoJSON|GeometryCollection} geojson objects 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 {Corners|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 improvement if true)\n * @returns {GeoJSON|GeometryCollection} scaled GeoJSON\n * @example\n * const poly = turf.polygon([[[0,29],[3.5,29],[2.5,32],[0,29]]]);\n * const scaledPoly = turf.transformScale(poly, 3);\n *\n * //addToMap\n * const addToMap = [poly, scaledPoly];\n * scaledPoly.properties = {stroke: '#F00', 'stroke-width': 4};\n */\nfunction transformScale<T extends GeoJSON | GeometryCollection>(\n geojson: T,\n factor: number,\n options?: {\n origin?: Corners | Coord;\n mutate?: boolean;\n }\n): T {\n // Optional parameters\n options = options || {};\n if (!isObject(options)) throw new Error(\"options is invalid\");\n const origin = options.origin || \"centroid\";\n const mutate = options.mutate || false;\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 const 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 if a feature collection AND the user didn't\n // pass a single explicit point to scale the whole collection from.\n if (geojson.type === \"FeatureCollection\" && !originIsPoint) {\n featureEach(geojson, function (feature, index) {\n // The type guard above is not recognised in the callback so we have to\n // cast to accept responsibility.\n (geojson as FeatureCollection).features[index] = scale(\n feature,\n factor,\n origin\n );\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 {GeoJSON|GeometryCollection} feature feature or geometry collection to scale\n * @param {number} factor of scaling, positive or negative values greater than 0\n * @param {Corners|Coord} [origin=\"centroid\"] Point from which the scaling will occur (string options: sw/se/nw/ne/center/centroid)\n * @returns {GeoJSON|GeometryCollection} scaled GeoJSON Feature/Geometry\n */\nfunction scale<T extends GeoJSON | GeometryCollection>(\n feature: T,\n factor: number,\n origin: Corners | Coord\n): T {\n // Default params\n const isPoint = getType(feature) === \"Point\";\n // Work with a Coord equivalent of the origin from here on.\n const originCoord: Coord = 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 const originalDistance = rhumbDistance(originCoord, coord);\n const bearing = rhumbBearing(originCoord, coord);\n const newDistance = originalDistance * factor;\n const newCoord = getCoords(\n rhumbDestination(originCoord, newDistance, bearing)\n );\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|GeometryCollection} geojson GeoJSON\n * @param {Corners|Coord} origin sw/se/nw/ne/center/centroid\n * @returns {Feature<Point>} Point origin\n */\nfunction defineOrigin(\n geojson: GeoJSON | GeometryCollection,\n origin: Corners | Coord\n): Coord {\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 const bbox = geojson.bbox\n ? geojson.bbox\n : turfBBox(geojson, { recompute: true });\n const west = bbox[0];\n const south = bbox[1];\n const east = bbox[2];\n const north = bbox[3];\n\n // Having to disable eslint below for lines which fail the no-fallthrough\n // rule, though only because of the ts-expect-error rules. Once we remove\n // southeast, bottomright, rightbottom, etc we should be able to remove all\n // these supressions.\n /* eslint-disable no-fallthrough */\n switch (origin) {\n case \"sw\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"southwest\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"westsouth\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"bottomleft\":\n return point([west, south]);\n case \"se\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"southeast\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"eastsouth\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"bottomright\":\n return point([east, south]);\n case \"nw\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"northwest\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"westnorth\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"topleft\":\n return point([west, north]);\n case \"ne\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"northeast\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"eastnorth\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\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 /* eslint-enable no-fallthrough */\n}\n\nexport { transformScale };\nexport default transformScale;\n"],"mappings":";AAEA,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;AAuB7C,SAAS,eACP,SACA,QACA,SAIG;AAEH,YAAU,WAAW,CAAC;AACtB,MAAI,CAAC,SAAS,OAAO,EAAG,OAAM,IAAI,MAAM,oBAAoB;AAC5D,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,SAAS,QAAQ,UAAU;AAGjC,MAAI,CAAC,QAAS,OAAM,IAAI,MAAM,kBAAkB;AAChD,MAAI,OAAO,WAAW,YAAY,UAAU;AAC1C,UAAM,IAAI,MAAM,gBAAgB;AAClC,QAAM,gBAAgB,MAAM,QAAQ,MAAM,KAAK,OAAO,WAAW;AAGjE,MAAI,WAAW,KAAM,WAAU,MAAM,OAAO;AAI5C,MAAI,QAAQ,SAAS,uBAAuB,CAAC,eAAe;AAC1D,gBAAY,SAAS,SAAU,SAAS,OAAO;AAG7C,MAAC,QAA8B,SAAS,KAAK,IAAI;AAAA,QAC/C;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF,CAAC;AACD,WAAO;AAAA,EACT;AAEA,SAAO,MAAM,SAAS,QAAQ,MAAM;AACtC;AAWA,SAAS,MACP,SACA,QACA,QACG;AAEH,QAAM,UAAU,QAAQ,OAAO,MAAM;AAErC,QAAM,cAAqB,aAAa,SAAS,MAAM;AAGvD,MAAI,WA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AAAA,IAEL,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;AAEF;AAGA,IAAO
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import { Corners, Coord } from \"@turf/helpers\";\nimport { FeatureCollection, GeoJSON, GeometryCollection } from \"geojson\";\nimport { 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 GeoJSON objects from a given point by a scaling factor e.g. factor=2\n * would make each object 200% larger.\n * If a FeatureCollection is provided, the origin point will be calculated\n * based on each individual feature _unless_ an exact\n *\n * @function\n * @param {GeoJSON|GeometryCollection} geojson objects 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 {Corners|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 improvement if true)\n * @returns {GeoJSON|GeometryCollection} scaled GeoJSON\n * @example\n * const poly = turf.polygon([[[0,29],[3.5,29],[2.5,32],[0,29]]]);\n * const scaledPoly = turf.transformScale(poly, 3);\n *\n * //addToMap\n * const addToMap = [poly, scaledPoly];\n * scaledPoly.properties = {stroke: '#F00', 'stroke-width': 4};\n */\nfunction transformScale<T extends GeoJSON | GeometryCollection>(\n geojson: T,\n factor: number,\n options?: {\n origin?: Corners | Coord;\n mutate?: boolean;\n }\n): T {\n // Optional parameters\n options = options || {};\n if (!isObject(options)) throw new Error(\"options is invalid\");\n const origin = options.origin || \"centroid\";\n const mutate = options.mutate || false;\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 const 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 if a feature collection AND the user didn't\n // pass a single explicit point to scale the whole collection from.\n if (geojson.type === \"FeatureCollection\" && !originIsPoint) {\n featureEach(geojson, function (feature, index) {\n // The type guard above is not recognised in the callback so we have to\n // cast to accept responsibility.\n (geojson as FeatureCollection).features[index] = scale(\n feature,\n factor,\n origin\n );\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 {GeoJSON|GeometryCollection} feature feature or geometry collection to scale\n * @param {number} factor of scaling, positive or negative values greater than 0\n * @param {Corners|Coord} [origin=\"centroid\"] Point from which the scaling will occur (string options: sw/se/nw/ne/center/centroid)\n * @returns {GeoJSON|GeometryCollection} scaled GeoJSON Feature/Geometry\n */\nfunction scale<T extends GeoJSON | GeometryCollection>(\n feature: T,\n factor: number,\n origin: Corners | Coord\n): T {\n // Default params\n const isPoint = getType(feature) === \"Point\";\n // Work with a Coord equivalent of the origin from here on.\n const originCoord: Coord = 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 const originalDistance = rhumbDistance(originCoord, coord);\n const bearing = rhumbBearing(originCoord, coord);\n const newDistance = originalDistance * factor;\n const newCoord = getCoords(\n rhumbDestination(originCoord, newDistance, bearing)\n );\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|GeometryCollection} geojson GeoJSON\n * @param {Corners|Coord} origin sw/se/nw/ne/center/centroid\n * @returns {Feature<Point>} Point origin\n */\nfunction defineOrigin(\n geojson: GeoJSON | GeometryCollection,\n origin: Corners | Coord\n): Coord {\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 const bbox = geojson.bbox\n ? geojson.bbox\n : turfBBox(geojson, { recompute: true });\n const west = bbox[0];\n const south = bbox[1];\n const east = bbox[2];\n const north = bbox[3];\n\n // Having to disable eslint below for lines which fail the no-fallthrough\n // rule, though only because of the ts-expect-error rules. Once we remove\n // southeast, bottomright, rightbottom, etc we should be able to remove all\n // these supressions.\n /* eslint-disable no-fallthrough */\n switch (origin) {\n case \"sw\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"southwest\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"westsouth\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"bottomleft\":\n return point([west, south]);\n case \"se\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"southeast\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"eastsouth\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"bottomright\":\n return point([east, south]);\n case \"nw\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"northwest\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"westnorth\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"topleft\":\n return point([west, north]);\n case \"ne\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"northeast\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\n case \"eastnorth\":\n // @ts-expect-error undocumented, to be removed for v8 #techdebt\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 /* eslint-enable no-fallthrough */\n}\n\nexport { transformScale };\nexport default transformScale;\n"],"mappings":";AAEA,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;AAuB7C,SAAS,eACP,SACA,QACA,SAIG;AAEH,YAAU,WAAW,CAAC;AACtB,MAAI,CAAC,SAAS,OAAO,EAAG,OAAM,IAAI,MAAM,oBAAoB;AAC5D,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,SAAS,QAAQ,UAAU;AAGjC,MAAI,CAAC,QAAS,OAAM,IAAI,MAAM,kBAAkB;AAChD,MAAI,OAAO,WAAW,YAAY,UAAU;AAC1C,UAAM,IAAI,MAAM,gBAAgB;AAClC,QAAM,gBAAgB,MAAM,QAAQ,MAAM,KAAK,OAAO,WAAW;AAGjE,MAAI,WAAW,KAAM,WAAU,MAAM,OAAO;AAI5C,MAAI,QAAQ,SAAS,uBAAuB,CAAC,eAAe;AAC1D,gBAAY,SAAS,SAAU,SAAS,OAAO;AAG7C,MAAC,QAA8B,SAAS,KAAK,IAAI;AAAA,QAC/C;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF,CAAC;AACD,WAAO;AAAA,EACT;AAEA,SAAO,MAAM,SAAS,QAAQ,MAAM;AACtC;AAWA,SAAS,MACP,SACA,QACA,QACG;AAEH,QAAM,UAAU,QAAQ,OAAO,MAAM;AAErC,QAAM,cAAqB,aAAa,SA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;AAAA,IAEL,KAAK;AAAA;AAAA,IAEL,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;AAEF;AAGA,IAAO,gBAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/transform-scale",
|
|
3
|
-
"version": "7.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "7.3.0",
|
|
4
|
+
"description": "Changes the size of a geometry by scaling it up or down.",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Stefano Borghi <@stebogit>",
|
|
@@ -60,33 +60,33 @@
|
|
|
60
60
|
"test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@turf/bbox-polygon": "
|
|
64
|
-
"@turf/hex-grid": "
|
|
65
|
-
"@turf/truncate": "
|
|
63
|
+
"@turf/bbox-polygon": "7.3.0",
|
|
64
|
+
"@turf/hex-grid": "7.3.0",
|
|
65
|
+
"@turf/truncate": "7.3.0",
|
|
66
66
|
"@types/benchmark": "^2.1.5",
|
|
67
|
-
"@types/tape": "^
|
|
67
|
+
"@types/tape": "^5.8.1",
|
|
68
68
|
"benchmark": "^2.1.4",
|
|
69
69
|
"load-json-file": "^7.0.1",
|
|
70
70
|
"npm-run-all": "^4.1.5",
|
|
71
71
|
"tape": "^5.9.0",
|
|
72
|
-
"tsup": "^8.
|
|
73
|
-
"tsx": "^4.19.
|
|
74
|
-
"typescript": "^5.
|
|
75
|
-
"write-json-file": "^
|
|
72
|
+
"tsup": "^8.4.0",
|
|
73
|
+
"tsx": "^4.19.4",
|
|
74
|
+
"typescript": "^5.8.3",
|
|
75
|
+
"write-json-file": "^6.0.0"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
|
-
"@turf/bbox": "
|
|
79
|
-
"@turf/center": "
|
|
80
|
-
"@turf/centroid": "
|
|
81
|
-
"@turf/clone": "
|
|
82
|
-
"@turf/helpers": "
|
|
83
|
-
"@turf/invariant": "
|
|
84
|
-
"@turf/meta": "
|
|
85
|
-
"@turf/rhumb-bearing": "
|
|
86
|
-
"@turf/rhumb-destination": "
|
|
87
|
-
"@turf/rhumb-distance": "
|
|
78
|
+
"@turf/bbox": "7.3.0",
|
|
79
|
+
"@turf/center": "7.3.0",
|
|
80
|
+
"@turf/centroid": "7.3.0",
|
|
81
|
+
"@turf/clone": "7.3.0",
|
|
82
|
+
"@turf/helpers": "7.3.0",
|
|
83
|
+
"@turf/invariant": "7.3.0",
|
|
84
|
+
"@turf/meta": "7.3.0",
|
|
85
|
+
"@turf/rhumb-bearing": "7.3.0",
|
|
86
|
+
"@turf/rhumb-destination": "7.3.0",
|
|
87
|
+
"@turf/rhumb-distance": "7.3.0",
|
|
88
88
|
"@types/geojson": "^7946.0.10",
|
|
89
89
|
"tslib": "^2.8.1"
|
|
90
90
|
},
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "9f58a103e8f9a587ab640307ed03ba5233913ddd"
|
|
92
92
|
}
|