all these changes

This commit is contained in:
Jake Kasper
2026-04-09 13:19:47 -05:00
parent e83a51a051
commit 65315f36d1
39102 changed files with 7932979 additions and 567 deletions

View File

@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2017 TurfJS
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,66 @@
# @turf/transform-translate
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
## transformTranslate
Moves any geojson Feature or Geometry of a specified distance along a Rhumb Line
on the provided direction angle.
**Parameters**
- `geojson` **[GeoJSON][1]** object to be translated
- `distance` **[number][2]** length of the motion; negative values determine motion in opposite direction
- `direction` **[number][2]** of the motion; angle from North in decimal degrees, positive clockwise
- `options` **[Object][3]** Optional parameters (optional, default `{}`)
- `options.units` **[string][4]** in which `distance` will be express; miles, kilometers, degrees, or radians (optional, default `'kilometers'`)
- `options.zTranslation` **[number][2]** length of the vertical motion, same unit of distance (optional, default `0`)
- `options.mutate` **[boolean][5]** allows GeoJSON input to be mutated (significant performance increase if true) (optional, default `false`)
**Examples**
```javascript
var poly = turf.polygon([[[0,29],[3.5,29],[2.5,32],[0,29]]]);
var translatedPoly = turf.transformTranslate(poly, 100, 35);
//addToMap
var addToMap = [poly, translatedPoly];
translatedPoly.properties = {stroke: '#F00', 'stroke-width': 4};
```
Returns **[GeoJSON][1]** the translated GeoJSON object
[1]: https://tools.ietf.org/html/rfc7946#section-3
[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
<!-- This file is automatically generated. Please don't edit it directly:
if you find an error, edit the source file (likely index.js), and re-run
./scripts/generate-readmes in the turf project. -->
---
This module is part of the [Turfjs project](http://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.
### Installation
Install this module individually:
```sh
$ npm install @turf/transform-translate
```
Or install the Turf module that includes it as a function:
```sh
$ npm install @turf/turf
```

View File

@@ -0,0 +1,72 @@
import { coordEach } from '@turf/meta';
import { isObject } from '@turf/helpers';
import { getCoords } from '@turf/invariant';
import clone from '@turf/clone';
import rhumbDestination from '@turf/rhumb-destination';
/**
* Moves any geojson Feature or Geometry of a specified distance along a Rhumb Line
* on the provided direction angle.
*
* @name transformTranslate
* @param {GeoJSON} geojson object to be translated
* @param {number} distance length of the motion; negative values determine motion in opposite direction
* @param {number} direction of the motion; angle from North in decimal degrees, positive clockwise
* @param {Object} [options={}] Optional parameters
* @param {string} [options.units='kilometers'] in which `distance` will be express; miles, kilometers, degrees, or radians
* @param {number} [options.zTranslation=0] length of the vertical motion, same unit of distance
* @param {boolean} [options.mutate=false] allows GeoJSON input to be mutated (significant performance increase if true)
* @returns {GeoJSON} the translated GeoJSON object
* @example
* var poly = turf.polygon([[[0,29],[3.5,29],[2.5,32],[0,29]]]);
* var translatedPoly = turf.transformTranslate(poly, 100, 35);
*
* //addToMap
* var addToMap = [poly, translatedPoly];
* translatedPoly.properties = {stroke: '#F00', 'stroke-width': 4};
*/
function transformTranslate(geojson, distance, direction, options) {
// Optional parameters
options = options || {};
if (!isObject(options)) throw new Error("options is invalid");
var units = options.units;
var zTranslation = options.zTranslation;
var mutate = options.mutate;
// Input validation
if (!geojson) throw new Error("geojson is required");
if (distance === undefined || distance === null || isNaN(distance))
throw new Error("distance is required");
if (zTranslation && typeof zTranslation !== "number" && isNaN(zTranslation))
throw new Error("zTranslation is not a number");
// Shortcut no-motion
zTranslation = zTranslation !== undefined ? zTranslation : 0;
if (distance === 0 && zTranslation === 0) return geojson;
if (direction === undefined || direction === null || isNaN(direction))
throw new Error("direction is required");
// Invert with negative distances
if (distance < 0) {
distance = -distance;
direction = direction + 180;
}
// Clone geojson to avoid side effects
if (mutate === false || mutate === undefined) geojson = clone(geojson);
// Translate each coordinate
coordEach(geojson, function (pointCoords) {
var newCoords = getCoords(
rhumbDestination(pointCoords, distance, direction, { units: units })
);
pointCoords[0] = newCoords[0];
pointCoords[1] = newCoords[1];
if (zTranslation && pointCoords.length === 3)
pointCoords[2] += zTranslation;
});
return geojson;
}
export default transformTranslate;

View File

@@ -0,0 +1 @@
{"type":"module"}

View File

@@ -0,0 +1,80 @@
'use strict';
var meta = require('@turf/meta');
var helpers = require('@turf/helpers');
var invariant = require('@turf/invariant');
var clone = require('@turf/clone');
var rhumbDestination = require('@turf/rhumb-destination');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var clone__default = /*#__PURE__*/_interopDefaultLegacy(clone);
var rhumbDestination__default = /*#__PURE__*/_interopDefaultLegacy(rhumbDestination);
/**
* Moves any geojson Feature or Geometry of a specified distance along a Rhumb Line
* on the provided direction angle.
*
* @name transformTranslate
* @param {GeoJSON} geojson object to be translated
* @param {number} distance length of the motion; negative values determine motion in opposite direction
* @param {number} direction of the motion; angle from North in decimal degrees, positive clockwise
* @param {Object} [options={}] Optional parameters
* @param {string} [options.units='kilometers'] in which `distance` will be express; miles, kilometers, degrees, or radians
* @param {number} [options.zTranslation=0] length of the vertical motion, same unit of distance
* @param {boolean} [options.mutate=false] allows GeoJSON input to be mutated (significant performance increase if true)
* @returns {GeoJSON} the translated GeoJSON object
* @example
* var poly = turf.polygon([[[0,29],[3.5,29],[2.5,32],[0,29]]]);
* var translatedPoly = turf.transformTranslate(poly, 100, 35);
*
* //addToMap
* var addToMap = [poly, translatedPoly];
* translatedPoly.properties = {stroke: '#F00', 'stroke-width': 4};
*/
function transformTranslate(geojson, distance, direction, options) {
// Optional parameters
options = options || {};
if (!helpers.isObject(options)) throw new Error("options is invalid");
var units = options.units;
var zTranslation = options.zTranslation;
var mutate = options.mutate;
// Input validation
if (!geojson) throw new Error("geojson is required");
if (distance === undefined || distance === null || isNaN(distance))
throw new Error("distance is required");
if (zTranslation && typeof zTranslation !== "number" && isNaN(zTranslation))
throw new Error("zTranslation is not a number");
// Shortcut no-motion
zTranslation = zTranslation !== undefined ? zTranslation : 0;
if (distance === 0 && zTranslation === 0) return geojson;
if (direction === undefined || direction === null || isNaN(direction))
throw new Error("direction is required");
// Invert with negative distances
if (distance < 0) {
distance = -distance;
direction = direction + 180;
}
// Clone geojson to avoid side effects
if (mutate === false || mutate === undefined) geojson = clone__default['default'](geojson);
// Translate each coordinate
meta.coordEach(geojson, function (pointCoords) {
var newCoords = invariant.getCoords(
rhumbDestination__default['default'](pointCoords, distance, direction, { units: units })
);
pointCoords[0] = newCoords[0];
pointCoords[1] = newCoords[1];
if (zTranslation && pointCoords.length === 3)
pointCoords[2] += zTranslation;
});
return geojson;
}
module.exports = transformTranslate;
module.exports.default = transformTranslate;

View File

@@ -0,0 +1,15 @@
import { AllGeoJSON, Units } from "@turf/helpers";
/**
* http://turfjs.org/docs/#transform-translate
*/
export default function transformTranslate<T extends AllGeoJSON>(
geojson: T,
distance: number,
direction: number,
options?: {
units?: Units;
zTranslation?: number;
mutate?: boolean;
}
): T;

View File

@@ -0,0 +1,71 @@
{
"name": "@turf/transform-translate",
"version": "6.5.0",
"description": "turf transform-translate module",
"author": "Turf Authors",
"contributors": [
"Stefano Borghi <@stebogit>",
"Denis Carriere <@DenisCarriere>"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/Turfjs/turf/issues"
},
"homepage": "https://github.com/Turfjs/turf",
"repository": {
"type": "git",
"url": "git://github.com/Turfjs/turf.git"
},
"funding": "https://opencollective.com/turf",
"publishConfig": {
"access": "public"
},
"keywords": [
"turf",
"transform",
"transformation",
"translate",
"move",
"shift"
],
"main": "dist/js/index.js",
"module": "dist/es/index.js",
"exports": {
"./package.json": "./package.json",
".": {
"import": "./dist/es/index.js",
"require": "./dist/js/index.js"
}
},
"types": "index.d.ts",
"sideEffects": false,
"files": [
"dist",
"index.d.ts"
],
"scripts": {
"bench": "node -r esm bench.js",
"build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json",
"docs": "node ../../scripts/generate-readmes",
"test": "npm-run-all test:*",
"test:tape": "node -r esm test.js",
"test:types": "tsc --esModuleInterop --noEmit types.ts"
},
"devDependencies": {
"@turf/truncate": "^6.5.0",
"benchmark": "*",
"load-json-file": "*",
"npm-run-all": "*",
"rollup": "*",
"tape": "*",
"write-json-file": "*"
},
"dependencies": {
"@turf/clone": "^6.5.0",
"@turf/helpers": "^6.5.0",
"@turf/invariant": "^6.5.0",
"@turf/meta": "^6.5.0",
"@turf/rhumb-destination": "^6.5.0"
},
"gitHead": "5375941072b90d489389db22b43bfe809d5e451e"
}