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C,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(\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"]}