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

20
frontend/node_modules/@turf/distance-weight/LICENSE generated vendored Normal file
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.

64
frontend/node_modules/@turf/distance-weight/README.md generated vendored Normal file
View File

@@ -0,0 +1,64 @@
# @turf/distance-weight
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
## pNormDistance
calcualte the Minkowski p-norm distance between two features.
**Parameters**
- `feature1` point feature
- `feature2` point feature
- `p` p-norm 1=&lt;p&lt;=infinity 1: Manhattan distance 2: Euclidean distance
## distanceWeight
**Parameters**
- `fc` **[FeatureCollection](https://tools.ietf.org/html/rfc7946#section-3.3)&lt;any>** FeatureCollection.
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** option object.
- `options.threshold` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** If the distance between neighbor and
target features is greater than threshold, the weight of that neighbor is 0. (optional, default `10000`)
- `options.p` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Minkowski p-norm distance parameter.
1: Manhattan distance. 2: Euclidean distance. 1=&lt;p&lt;=infinity. (optional, default `2`)
- `options.binary` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** If true, weight=1 if d &lt;= threshold otherwise weight=0.
If false, weight=Math.pow(d, alpha). (optional, default `false`)
- `options.alpha` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** distance decay parameter.
A big value means the weight decay quickly as distance increases. (optional, default `-1`)
- `options.standardization` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** row standardization. (optional, default `false`)
**Examples**
```javascript
var bbox = [-65, 40, -63, 42];
var dataset = turf.randomPoint(100, { bbox: bbox });
var result = turf.distanceWeight(dataset);
```
Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)>>** distance weight matrix.
<!-- 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/distance-weight
```
Or install the Turf module that includes it as a function:
```sh
$ npm install @turf/turf
```

105
frontend/node_modules/@turf/distance-weight/dist/es/index.js generated vendored Executable file
View File

@@ -0,0 +1,105 @@
import centroid from "@turf/centroid";
import { getCoord } from "@turf/invariant";
import { featureEach } from "@turf/meta";
/**
* calcualte the Minkowski p-norm distance between two features.
* @param feature1 point feature
* @param feature2 point feature
* @param p p-norm 1=<p<=infinity 1: Manhattan distance 2: Euclidean distance
*/
export function pNormDistance(feature1, feature2, p) {
if (p === void 0) { p = 2; }
var coordinate1 = getCoord(feature1);
var coordinate2 = getCoord(feature2);
var xDiff = coordinate1[0] - coordinate2[0];
var yDiff = coordinate1[1] - coordinate2[1];
if (p === 1) {
return Math.abs(xDiff) + Math.abs(yDiff);
}
return Math.pow(Math.pow(xDiff, p) + Math.pow(yDiff, p), 1 / p);
}
/**
*
*
* @name distanceWeight
* @param {FeatureCollection<any>} fc FeatureCollection.
* @param {Object} [options] option object.
* @param {number} [options.threshold=10000] If the distance between neighbor and
* target features is greater than threshold, the weight of that neighbor is 0.
* @param {number} [options.p=2] Minkowski p-norm distance parameter.
* 1: Manhattan distance. 2: Euclidean distance. 1=<p<=infinity.
* @param {boolean} [options.binary=false] If true, weight=1 if d <= threshold otherwise weight=0.
* If false, weight=Math.pow(d, alpha).
* @param {number} [options.alpha=-1] distance decay parameter.
* A big value means the weight decay quickly as distance increases.
* @param {boolean} [options.standardization=false] row standardization.
* @returns {Array<Array<number>>} distance weight matrix.
* @example
*
* var bbox = [-65, 40, -63, 42];
* var dataset = turf.randomPoint(100, { bbox: bbox });
* var result = turf.distanceWeight(dataset);
*/
export default function distanceWeight(fc, options) {
options = options || {};
var threshold = options.threshold || 10000;
var p = options.p || 2;
var binary = options.binary || false;
var alpha = options.alpha || -1;
var rowTransform = options.standardization || false;
var features = [];
featureEach(fc, function (feature) {
features.push(centroid(feature));
});
// computing the distance between the features
var weights = [];
for (var i = 0; i < features.length; i++) {
weights[i] = [];
}
for (var i = 0; i < features.length; i++) {
for (var j = i; j < features.length; j++) {
if (i === j) {
weights[i][j] = 0;
}
var dis = pNormDistance(features[i], features[j], p);
weights[i][j] = dis;
weights[j][i] = dis;
}
}
// binary or distance decay
for (var i = 0; i < features.length; i++) {
for (var j = 0; j < features.length; j++) {
var dis = weights[i][j];
if (dis === 0) {
continue;
}
if (binary) {
if (dis <= threshold) {
weights[i][j] = 1.0;
}
else {
weights[i][j] = 0.0;
}
}
else {
if (dis <= threshold) {
weights[i][j] = Math.pow(dis, alpha);
}
else {
weights[i][j] = 0.0;
}
}
}
}
if (rowTransform) {
for (var i = 0; i < features.length; i++) {
var rowSum = weights[i].reduce(function (sum, currentVal) {
return sum + currentVal;
}, 0);
for (var j = 0; j < features.length; j++) {
weights[i][j] = weights[i][j] / rowSum;
}
}
}
return weights;
}

View File

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

View File

@@ -0,0 +1,37 @@
import { Feature, FeatureCollection, Point } from "@turf/helpers";
/**
* calcualte the Minkowski p-norm distance between two features.
* @param feature1 point feature
* @param feature2 point feature
* @param p p-norm 1=<p<=infinity 1: Manhattan distance 2: Euclidean distance
*/
export declare function pNormDistance(feature1: Feature<Point>, feature2: Feature<Point>, p?: number): number;
/**
*
*
* @name distanceWeight
* @param {FeatureCollection<any>} fc FeatureCollection.
* @param {Object} [options] option object.
* @param {number} [options.threshold=10000] If the distance between neighbor and
* target features is greater than threshold, the weight of that neighbor is 0.
* @param {number} [options.p=2] Minkowski p-norm distance parameter.
* 1: Manhattan distance. 2: Euclidean distance. 1=<p<=infinity.
* @param {boolean} [options.binary=false] If true, weight=1 if d <= threshold otherwise weight=0.
* If false, weight=Math.pow(d, alpha).
* @param {number} [options.alpha=-1] distance decay parameter.
* A big value means the weight decay quickly as distance increases.
* @param {boolean} [options.standardization=false] row standardization.
* @returns {Array<Array<number>>} distance weight matrix.
* @example
*
* var bbox = [-65, 40, -63, 42];
* var dataset = turf.randomPoint(100, { bbox: bbox });
* var result = turf.distanceWeight(dataset);
*/
export default function distanceWeight(fc: FeatureCollection<any>, options?: {
threshold?: number;
p?: number;
binary?: boolean;
alpha?: number;
standardization?: boolean;
}): number[][];

112
frontend/node_modules/@turf/distance-weight/dist/js/index.js generated vendored Executable file
View File

@@ -0,0 +1,112 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var centroid_1 = __importDefault(require("@turf/centroid"));
var invariant_1 = require("@turf/invariant");
var meta_1 = require("@turf/meta");
/**
* calcualte the Minkowski p-norm distance between two features.
* @param feature1 point feature
* @param feature2 point feature
* @param p p-norm 1=<p<=infinity 1: Manhattan distance 2: Euclidean distance
*/
function pNormDistance(feature1, feature2, p) {
if (p === void 0) { p = 2; }
var coordinate1 = invariant_1.getCoord(feature1);
var coordinate2 = invariant_1.getCoord(feature2);
var xDiff = coordinate1[0] - coordinate2[0];
var yDiff = coordinate1[1] - coordinate2[1];
if (p === 1) {
return Math.abs(xDiff) + Math.abs(yDiff);
}
return Math.pow(Math.pow(xDiff, p) + Math.pow(yDiff, p), 1 / p);
}
exports.pNormDistance = pNormDistance;
/**
*
*
* @name distanceWeight
* @param {FeatureCollection<any>} fc FeatureCollection.
* @param {Object} [options] option object.
* @param {number} [options.threshold=10000] If the distance between neighbor and
* target features is greater than threshold, the weight of that neighbor is 0.
* @param {number} [options.p=2] Minkowski p-norm distance parameter.
* 1: Manhattan distance. 2: Euclidean distance. 1=<p<=infinity.
* @param {boolean} [options.binary=false] If true, weight=1 if d <= threshold otherwise weight=0.
* If false, weight=Math.pow(d, alpha).
* @param {number} [options.alpha=-1] distance decay parameter.
* A big value means the weight decay quickly as distance increases.
* @param {boolean} [options.standardization=false] row standardization.
* @returns {Array<Array<number>>} distance weight matrix.
* @example
*
* var bbox = [-65, 40, -63, 42];
* var dataset = turf.randomPoint(100, { bbox: bbox });
* var result = turf.distanceWeight(dataset);
*/
function distanceWeight(fc, options) {
options = options || {};
var threshold = options.threshold || 10000;
var p = options.p || 2;
var binary = options.binary || false;
var alpha = options.alpha || -1;
var rowTransform = options.standardization || false;
var features = [];
meta_1.featureEach(fc, function (feature) {
features.push(centroid_1.default(feature));
});
// computing the distance between the features
var weights = [];
for (var i = 0; i < features.length; i++) {
weights[i] = [];
}
for (var i = 0; i < features.length; i++) {
for (var j = i; j < features.length; j++) {
if (i === j) {
weights[i][j] = 0;
}
var dis = pNormDistance(features[i], features[j], p);
weights[i][j] = dis;
weights[j][i] = dis;
}
}
// binary or distance decay
for (var i = 0; i < features.length; i++) {
for (var j = 0; j < features.length; j++) {
var dis = weights[i][j];
if (dis === 0) {
continue;
}
if (binary) {
if (dis <= threshold) {
weights[i][j] = 1.0;
}
else {
weights[i][j] = 0.0;
}
}
else {
if (dis <= threshold) {
weights[i][j] = Math.pow(dis, alpha);
}
else {
weights[i][j] = 0.0;
}
}
}
}
if (rowTransform) {
for (var i = 0; i < features.length; i++) {
var rowSum = weights[i].reduce(function (sum, currentVal) {
return sum + currentVal;
}, 0);
for (var j = 0; j < features.length; j++) {
weights[i][j] = weights[i][j] / rowSum;
}
}
}
return weights;
}
exports.default = distanceWeight;

View File

@@ -0,0 +1,67 @@
{
"name": "@turf/distance-weight",
"version": "6.5.0",
"description": "turf distance-weight module",
"author": "Turf Authors",
"contributors": [
"Haoming Zhuang <@zhuang-hao-ming>"
],
"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",
"distance-weight"
],
"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": "dist/js/index.d.ts",
"sideEffects": false,
"files": [
"dist"
],
"scripts": {
"bench": "ts-node bench.js",
"build": "npm-run-all build:*",
"build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json",
"build:js": "tsc",
"docs": "node ../../scripts/generate-readmes",
"test": "npm-run-all test:*",
"test:tape": "ts-node -r esm test.js"
},
"devDependencies": {
"@types/tape": "*",
"benchmark": "*",
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"ts-node": "*",
"tslint": "*",
"typescript": "*",
"write-json-file": "*"
},
"dependencies": {
"@turf/centroid": "^6.5.0",
"@turf/helpers": "^6.5.0",
"@turf/invariant": "^6.5.0",
"@turf/meta": "^6.5.0"
},
"gitHead": "5375941072b90d489389db22b43bfe809d5e451e"
}