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/clusters/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.

208
frontend/node_modules/@turf/clusters/README.md generated vendored Normal file
View File

@@ -0,0 +1,208 @@
# @turf/clusters
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
## getCluster
Get Cluster
**Parameters**
- `geojson` **[FeatureCollection][1]** GeoJSON Features
- `filter` **any** Filter used on GeoJSON properties to get Cluster
**Examples**
```javascript
var geojson = turf.featureCollection([
turf.point([0, 0], {'marker-symbol': 'circle'}),
turf.point([2, 4], {'marker-symbol': 'star'}),
turf.point([3, 6], {'marker-symbol': 'star'}),
turf.point([5, 1], {'marker-symbol': 'square'}),
turf.point([4, 2], {'marker-symbol': 'circle'})
]);
// Create a cluster using K-Means (adds `cluster` to GeoJSON properties)
var clustered = turf.clustersKmeans(geojson);
// Retrieve first cluster (0)
var cluster = turf.getCluster(clustered, {cluster: 0});
//= cluster
// Retrieve cluster based on custom properties
turf.getCluster(clustered, {'marker-symbol': 'circle'}).length;
//= 2
turf.getCluster(clustered, {'marker-symbol': 'square'}).length;
//= 1
```
Returns **[FeatureCollection][1]** Single Cluster filtered by GeoJSON Properties
## clusterEachCallback
Callback for clusterEach
Type: [Function][2]
**Parameters**
- `cluster` **[FeatureCollection][1]?** The current cluster being processed.
- `clusterValue` **any?** Value used to create cluster being processed.
- `currentIndex` **[number][3]?** The index of the current element being processed in the array.Starts at index 0
Returns **void**
## clusterEach
clusterEach
**Parameters**
- `geojson` **[FeatureCollection][1]** GeoJSON Features
- `property` **([string][4] \| [number][3])** GeoJSON property key/value used to create clusters
- `callback` **[Function][2]** a method that takes (cluster, clusterValue, currentIndex)
**Examples**
```javascript
var geojson = turf.featureCollection([
turf.point([0, 0]),
turf.point([2, 4]),
turf.point([3, 6]),
turf.point([5, 1]),
turf.point([4, 2])
]);
// Create a cluster using K-Means (adds `cluster` to GeoJSON properties)
var clustered = turf.clustersKmeans(geojson);
// Iterate over each cluster
turf.clusterEach(clustered, 'cluster', function (cluster, clusterValue, currentIndex) {
//= cluster
//= clusterValue
//= currentIndex
})
// Calculate the total number of clusters
var total = 0
turf.clusterEach(clustered, 'cluster', function () {
total++;
});
// Create an Array of all the values retrieved from the 'cluster' property
var values = []
turf.clusterEach(clustered, 'cluster', function (cluster, clusterValue) {
values.push(clusterValue);
});
```
Returns **void**
## clusterReduceCallback
Callback for clusterReduce
The first time the callback function is called, the values provided as arguments depend
on whether the reduce method has an initialValue argument.
If an initialValue is provided to the reduce method:
- The previousValue argument is initialValue.
- The currentValue argument is the value of the first element present in the array.
If an initialValue is not provided:
- The previousValue argument is the value of the first element present in the array.
- The currentValue argument is the value of the second element present in the array.
Type: [Function][2]
**Parameters**
- `previousValue` **any?** The accumulated value previously returned in the last invocation
of the callback, or initialValue, if supplied.
- `cluster` **[FeatureCollection][1]?** The current cluster being processed.
- `clusterValue` **any?** Value used to create cluster being processed.
- `currentIndex` **[number][3]?** The index of the current element being processed in the
array. Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
## clusterReduce
Reduce clusters in GeoJSON Features, similar to Array.reduce()
**Parameters**
- `geojson` **[FeatureCollection][1]** GeoJSON Features
- `property` **([string][4] \| [number][3])** GeoJSON property key/value used to create clusters
- `callback` **[Function][2]** a method that takes (previousValue, cluster, clusterValue, currentIndex)
- `initialValue` **any?** Value to use as the first argument to the first call of the callback.
**Examples**
```javascript
var geojson = turf.featureCollection([
turf.point([0, 0]),
turf.point([2, 4]),
turf.point([3, 6]),
turf.point([5, 1]),
turf.point([4, 2])
]);
// Create a cluster using K-Means (adds `cluster` to GeoJSON properties)
var clustered = turf.clustersKmeans(geojson);
// Iterate over each cluster and perform a calculation
var initialValue = 0
turf.clusterReduce(clustered, 'cluster', function (previousValue, cluster, clusterValue, currentIndex) {
//=previousValue
//=cluster
//=clusterValue
//=currentIndex
return previousValue++;
}, initialValue);
// Calculate the total number of clusters
var total = turf.clusterReduce(clustered, 'cluster', function (previousValue) {
return previousValue++;
}, 0);
// Create an Array of all the values retrieved from the 'cluster' property
var values = turf.clusterReduce(clustered, 'cluster', function (previousValue, cluster, clusterValue) {
return previousValue.concat(clusterValue);
}, []);
```
Returns **any** The value that results from the reduction.
[1]: https://tools.ietf.org/html/rfc7946#section-3.3
[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
<!-- 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/clusters
```
Or install the Turf module that includes it as a function:
```sh
$ npm install @turf/turf
```

294
frontend/node_modules/@turf/clusters/dist/es/index.js generated vendored Executable file
View File

@@ -0,0 +1,294 @@
import { featureEach } from "@turf/meta";
import { featureCollection } from "@turf/helpers";
/**
* Get Cluster
*
* @name getCluster
* @param {FeatureCollection} geojson GeoJSON Features
* @param {*} filter Filter used on GeoJSON properties to get Cluster
* @returns {FeatureCollection} Single Cluster filtered by GeoJSON Properties
* @example
* var geojson = turf.featureCollection([
* turf.point([0, 0], {'marker-symbol': 'circle'}),
* turf.point([2, 4], {'marker-symbol': 'star'}),
* turf.point([3, 6], {'marker-symbol': 'star'}),
* turf.point([5, 1], {'marker-symbol': 'square'}),
* turf.point([4, 2], {'marker-symbol': 'circle'})
* ]);
*
* // Create a cluster using K-Means (adds `cluster` to GeoJSON properties)
* var clustered = turf.clustersKmeans(geojson);
*
* // Retrieve first cluster (0)
* var cluster = turf.getCluster(clustered, {cluster: 0});
* //= cluster
*
* // Retrieve cluster based on custom properties
* turf.getCluster(clustered, {'marker-symbol': 'circle'}).length;
* //= 2
* turf.getCluster(clustered, {'marker-symbol': 'square'}).length;
* //= 1
*/
export function getCluster(geojson, filter) {
// Validation
if (!geojson)
throw new Error("geojson is required");
if (geojson.type !== "FeatureCollection")
throw new Error("geojson must be a FeatureCollection");
if (filter === undefined || filter === null)
throw new Error("filter is required");
// Filter Features
var features = [];
featureEach(geojson, function (feature) {
if (applyFilter(feature.properties, filter))
features.push(feature);
});
return featureCollection(features);
}
/**
* Callback for clusterEach
*
* @callback clusterEachCallback
* @param {FeatureCollection} [cluster] The current cluster being processed.
* @param {*} [clusterValue] Value used to create cluster being processed.
* @param {number} [currentIndex] The index of the current element being processed in the array.Starts at index 0
* @returns {void}
*/
/**
* clusterEach
*
* @name clusterEach
* @param {FeatureCollection} geojson GeoJSON Features
* @param {string|number} property GeoJSON property key/value used to create clusters
* @param {Function} callback a method that takes (cluster, clusterValue, currentIndex)
* @returns {void}
* @example
* var geojson = turf.featureCollection([
* turf.point([0, 0]),
* turf.point([2, 4]),
* turf.point([3, 6]),
* turf.point([5, 1]),
* turf.point([4, 2])
* ]);
*
* // Create a cluster using K-Means (adds `cluster` to GeoJSON properties)
* var clustered = turf.clustersKmeans(geojson);
*
* // Iterate over each cluster
* turf.clusterEach(clustered, 'cluster', function (cluster, clusterValue, currentIndex) {
* //= cluster
* //= clusterValue
* //= currentIndex
* })
*
* // Calculate the total number of clusters
* var total = 0
* turf.clusterEach(clustered, 'cluster', function () {
* total++;
* });
*
* // Create an Array of all the values retrieved from the 'cluster' property
* var values = []
* turf.clusterEach(clustered, 'cluster', function (cluster, clusterValue) {
* values.push(clusterValue);
* });
*/
export function clusterEach(geojson, property, callback) {
// Validation
if (!geojson)
throw new Error("geojson is required");
if (geojson.type !== "FeatureCollection")
throw new Error("geojson must be a FeatureCollection");
if (property === undefined || property === null)
throw new Error("property is required");
// Create clusters based on property values
var bins = createBins(geojson, property);
var values = Object.keys(bins);
for (var index = 0; index < values.length; index++) {
var value = values[index];
var bin = bins[value];
var features = [];
for (var i = 0; i < bin.length; i++) {
features.push(geojson.features[bin[i]]);
}
callback(featureCollection(features), value, index);
}
}
/**
* Callback for clusterReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback clusterReduceCallback
* @param {*} [previousValue] The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {FeatureCollection} [cluster] The current cluster being processed.
* @param {*} [clusterValue] Value used to create cluster being processed.
* @param {number} [currentIndex] The index of the current element being processed in the
* array. Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
*/
/**
* Reduce clusters in GeoJSON Features, similar to Array.reduce()
*
* @name clusterReduce
* @param {FeatureCollection} geojson GeoJSON Features
* @param {string|number} property GeoJSON property key/value used to create clusters
* @param {Function} callback a method that takes (previousValue, cluster, clusterValue, currentIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {*} The value that results from the reduction.
* @example
* var geojson = turf.featureCollection([
* turf.point([0, 0]),
* turf.point([2, 4]),
* turf.point([3, 6]),
* turf.point([5, 1]),
* turf.point([4, 2])
* ]);
*
* // Create a cluster using K-Means (adds `cluster` to GeoJSON properties)
* var clustered = turf.clustersKmeans(geojson);
*
* // Iterate over each cluster and perform a calculation
* var initialValue = 0
* turf.clusterReduce(clustered, 'cluster', function (previousValue, cluster, clusterValue, currentIndex) {
* //=previousValue
* //=cluster
* //=clusterValue
* //=currentIndex
* return previousValue++;
* }, initialValue);
*
* // Calculate the total number of clusters
* var total = turf.clusterReduce(clustered, 'cluster', function (previousValue) {
* return previousValue++;
* }, 0);
*
* // Create an Array of all the values retrieved from the 'cluster' property
* var values = turf.clusterReduce(clustered, 'cluster', function (previousValue, cluster, clusterValue) {
* return previousValue.concat(clusterValue);
* }, []);
*/
export function clusterReduce(geojson, property, callback, initialValue) {
var previousValue = initialValue;
clusterEach(geojson, property, function (cluster, clusterValue, currentIndex) {
if (currentIndex === 0 && initialValue === undefined)
previousValue = cluster;
else
previousValue = callback(previousValue, cluster, clusterValue, currentIndex);
});
return previousValue;
}
/**
* Create Bins
*
* @private
* @param {FeatureCollection} geojson GeoJSON Features
* @param {string|number} property Property values are used to create bins
* @returns {Object} bins with Feature IDs
* @example
* var geojson = turf.featureCollection([
* turf.point([0, 0], {cluster: 0, foo: 'null'}),
* turf.point([2, 4], {cluster: 1, foo: 'bar'}),
* turf.point([5, 1], {0: 'foo'}),
* turf.point([3, 6], {cluster: 1}),
* ]);
* createBins(geojson, 'cluster');
* //= { '0': [ 0 ], '1': [ 1, 3 ] }
*/
export function createBins(geojson, property) {
var bins = {};
featureEach(geojson, function (feature, i) {
var properties = feature.properties || {};
if (Object.prototype.hasOwnProperty.call(properties, String(property))) {
var value = properties[property];
if (Object.prototype.hasOwnProperty.call(bins, value))
bins[value].push(i);
else
bins[value] = [i];
}
});
return bins;
}
/**
* Apply Filter
*
* @private
* @param {*} properties Properties
* @param {*} filter Filter
* @returns {boolean} applied Filter to properties
*/
export function applyFilter(properties, filter) {
if (properties === undefined)
return false;
var filterType = typeof filter;
// String & Number
if (filterType === "number" || filterType === "string")
return Object.prototype.hasOwnProperty.call(properties, filter);
// Array
else if (Array.isArray(filter)) {
for (var i = 0; i < filter.length; i++) {
if (!applyFilter(properties, filter[i]))
return false;
}
return true;
// Object
}
else {
return propertiesContainsFilter(properties, filter);
}
}
/**
* Properties contains filter (does not apply deepEqual operations)
*
* @private
* @param {*} properties Properties
* @param {Object} filter Filter
* @returns {boolean} does filter equal Properties
* @example
* propertiesContainsFilter({foo: 'bar', cluster: 0}, {cluster: 0})
* //= true
* propertiesContainsFilter({foo: 'bar', cluster: 0}, {cluster: 1})
* //= false
*/
export function propertiesContainsFilter(properties, filter) {
var keys = Object.keys(filter);
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if (properties[key] !== filter[key])
return false;
}
return true;
}
/**
* Filter Properties
*
* @private
* @param {*} properties Properties
* @param {Array<string>} keys Used to filter Properties
* @returns {*} filtered Properties
* @example
* filterProperties({foo: 'bar', cluster: 0}, ['cluster'])
* //= {cluster: 0}
*/
export function filterProperties(properties, keys) {
if (!keys)
return {};
if (!keys.length)
return {};
var newProperties = {};
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if (Object.prototype.hasOwnProperty.call(properties, key))
newProperties[key] = properties[key];
}
return newProperties;
}

View File

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

197
frontend/node_modules/@turf/clusters/dist/js/index.d.ts generated vendored Executable file
View File

@@ -0,0 +1,197 @@
import { FeatureCollection } from "@turf/helpers";
/**
* Get Cluster
*
* @name getCluster
* @param {FeatureCollection} geojson GeoJSON Features
* @param {*} filter Filter used on GeoJSON properties to get Cluster
* @returns {FeatureCollection} Single Cluster filtered by GeoJSON Properties
* @example
* var geojson = turf.featureCollection([
* turf.point([0, 0], {'marker-symbol': 'circle'}),
* turf.point([2, 4], {'marker-symbol': 'star'}),
* turf.point([3, 6], {'marker-symbol': 'star'}),
* turf.point([5, 1], {'marker-symbol': 'square'}),
* turf.point([4, 2], {'marker-symbol': 'circle'})
* ]);
*
* // Create a cluster using K-Means (adds `cluster` to GeoJSON properties)
* var clustered = turf.clustersKmeans(geojson);
*
* // Retrieve first cluster (0)
* var cluster = turf.getCluster(clustered, {cluster: 0});
* //= cluster
*
* // Retrieve cluster based on custom properties
* turf.getCluster(clustered, {'marker-symbol': 'circle'}).length;
* //= 2
* turf.getCluster(clustered, {'marker-symbol': 'square'}).length;
* //= 1
*/
export declare function getCluster<G extends any, P = any>(geojson: FeatureCollection<G, P>, filter: any): FeatureCollection<G, P>;
/**
* Callback for clusterEach
*
* @callback clusterEachCallback
* @param {FeatureCollection} [cluster] The current cluster being processed.
* @param {*} [clusterValue] Value used to create cluster being processed.
* @param {number} [currentIndex] The index of the current element being processed in the array.Starts at index 0
* @returns {void}
*/
/**
* clusterEach
*
* @name clusterEach
* @param {FeatureCollection} geojson GeoJSON Features
* @param {string|number} property GeoJSON property key/value used to create clusters
* @param {Function} callback a method that takes (cluster, clusterValue, currentIndex)
* @returns {void}
* @example
* var geojson = turf.featureCollection([
* turf.point([0, 0]),
* turf.point([2, 4]),
* turf.point([3, 6]),
* turf.point([5, 1]),
* turf.point([4, 2])
* ]);
*
* // Create a cluster using K-Means (adds `cluster` to GeoJSON properties)
* var clustered = turf.clustersKmeans(geojson);
*
* // Iterate over each cluster
* turf.clusterEach(clustered, 'cluster', function (cluster, clusterValue, currentIndex) {
* //= cluster
* //= clusterValue
* //= currentIndex
* })
*
* // Calculate the total number of clusters
* var total = 0
* turf.clusterEach(clustered, 'cluster', function () {
* total++;
* });
*
* // Create an Array of all the values retrieved from the 'cluster' property
* var values = []
* turf.clusterEach(clustered, 'cluster', function (cluster, clusterValue) {
* values.push(clusterValue);
* });
*/
export declare function clusterEach<G = any, P = any>(geojson: FeatureCollection<G, P>, property: number | string, callback: (cluster?: FeatureCollection<G, P>, clusterValue?: any, currentIndex?: number) => void): void;
/**
* Callback for clusterReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback clusterReduceCallback
* @param {*} [previousValue] The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {FeatureCollection} [cluster] The current cluster being processed.
* @param {*} [clusterValue] Value used to create cluster being processed.
* @param {number} [currentIndex] The index of the current element being processed in the
* array. Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
*/
/**
* Reduce clusters in GeoJSON Features, similar to Array.reduce()
*
* @name clusterReduce
* @param {FeatureCollection} geojson GeoJSON Features
* @param {string|number} property GeoJSON property key/value used to create clusters
* @param {Function} callback a method that takes (previousValue, cluster, clusterValue, currentIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {*} The value that results from the reduction.
* @example
* var geojson = turf.featureCollection([
* turf.point([0, 0]),
* turf.point([2, 4]),
* turf.point([3, 6]),
* turf.point([5, 1]),
* turf.point([4, 2])
* ]);
*
* // Create a cluster using K-Means (adds `cluster` to GeoJSON properties)
* var clustered = turf.clustersKmeans(geojson);
*
* // Iterate over each cluster and perform a calculation
* var initialValue = 0
* turf.clusterReduce(clustered, 'cluster', function (previousValue, cluster, clusterValue, currentIndex) {
* //=previousValue
* //=cluster
* //=clusterValue
* //=currentIndex
* return previousValue++;
* }, initialValue);
*
* // Calculate the total number of clusters
* var total = turf.clusterReduce(clustered, 'cluster', function (previousValue) {
* return previousValue++;
* }, 0);
*
* // Create an Array of all the values retrieved from the 'cluster' property
* var values = turf.clusterReduce(clustered, 'cluster', function (previousValue, cluster, clusterValue) {
* return previousValue.concat(clusterValue);
* }, []);
*/
export declare function clusterReduce<G = any, P = any>(geojson: FeatureCollection<G, P>, property: number | string, callback: (previousValue?: any, cluster?: FeatureCollection<G, P>, clusterValue?: any, currentIndex?: number) => void, initialValue?: any): void;
/**
* Create Bins
*
* @private
* @param {FeatureCollection} geojson GeoJSON Features
* @param {string|number} property Property values are used to create bins
* @returns {Object} bins with Feature IDs
* @example
* var geojson = turf.featureCollection([
* turf.point([0, 0], {cluster: 0, foo: 'null'}),
* turf.point([2, 4], {cluster: 1, foo: 'bar'}),
* turf.point([5, 1], {0: 'foo'}),
* turf.point([3, 6], {cluster: 1}),
* ]);
* createBins(geojson, 'cluster');
* //= { '0': [ 0 ], '1': [ 1, 3 ] }
*/
export declare function createBins(geojson: FeatureCollection<any>, property: string | number): Record<string, number[]>;
/**
* Apply Filter
*
* @private
* @param {*} properties Properties
* @param {*} filter Filter
* @returns {boolean} applied Filter to properties
*/
export declare function applyFilter(properties: any, filter: any): boolean;
/**
* Properties contains filter (does not apply deepEqual operations)
*
* @private
* @param {*} properties Properties
* @param {Object} filter Filter
* @returns {boolean} does filter equal Properties
* @example
* propertiesContainsFilter({foo: 'bar', cluster: 0}, {cluster: 0})
* //= true
* propertiesContainsFilter({foo: 'bar', cluster: 0}, {cluster: 1})
* //= false
*/
export declare function propertiesContainsFilter(properties: any, filter: any): boolean;
/**
* Filter Properties
*
* @private
* @param {*} properties Properties
* @param {Array<string>} keys Used to filter Properties
* @returns {*} filtered Properties
* @example
* filterProperties({foo: 'bar', cluster: 0}, ['cluster'])
* //= {cluster: 0}
*/
export declare function filterProperties(properties: Record<string, any>, keys: string[]): any;

303
frontend/node_modules/@turf/clusters/dist/js/index.js generated vendored Executable file
View File

@@ -0,0 +1,303 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var meta_1 = require("@turf/meta");
var helpers_1 = require("@turf/helpers");
/**
* Get Cluster
*
* @name getCluster
* @param {FeatureCollection} geojson GeoJSON Features
* @param {*} filter Filter used on GeoJSON properties to get Cluster
* @returns {FeatureCollection} Single Cluster filtered by GeoJSON Properties
* @example
* var geojson = turf.featureCollection([
* turf.point([0, 0], {'marker-symbol': 'circle'}),
* turf.point([2, 4], {'marker-symbol': 'star'}),
* turf.point([3, 6], {'marker-symbol': 'star'}),
* turf.point([5, 1], {'marker-symbol': 'square'}),
* turf.point([4, 2], {'marker-symbol': 'circle'})
* ]);
*
* // Create a cluster using K-Means (adds `cluster` to GeoJSON properties)
* var clustered = turf.clustersKmeans(geojson);
*
* // Retrieve first cluster (0)
* var cluster = turf.getCluster(clustered, {cluster: 0});
* //= cluster
*
* // Retrieve cluster based on custom properties
* turf.getCluster(clustered, {'marker-symbol': 'circle'}).length;
* //= 2
* turf.getCluster(clustered, {'marker-symbol': 'square'}).length;
* //= 1
*/
function getCluster(geojson, filter) {
// Validation
if (!geojson)
throw new Error("geojson is required");
if (geojson.type !== "FeatureCollection")
throw new Error("geojson must be a FeatureCollection");
if (filter === undefined || filter === null)
throw new Error("filter is required");
// Filter Features
var features = [];
meta_1.featureEach(geojson, function (feature) {
if (applyFilter(feature.properties, filter))
features.push(feature);
});
return helpers_1.featureCollection(features);
}
exports.getCluster = getCluster;
/**
* Callback for clusterEach
*
* @callback clusterEachCallback
* @param {FeatureCollection} [cluster] The current cluster being processed.
* @param {*} [clusterValue] Value used to create cluster being processed.
* @param {number} [currentIndex] The index of the current element being processed in the array.Starts at index 0
* @returns {void}
*/
/**
* clusterEach
*
* @name clusterEach
* @param {FeatureCollection} geojson GeoJSON Features
* @param {string|number} property GeoJSON property key/value used to create clusters
* @param {Function} callback a method that takes (cluster, clusterValue, currentIndex)
* @returns {void}
* @example
* var geojson = turf.featureCollection([
* turf.point([0, 0]),
* turf.point([2, 4]),
* turf.point([3, 6]),
* turf.point([5, 1]),
* turf.point([4, 2])
* ]);
*
* // Create a cluster using K-Means (adds `cluster` to GeoJSON properties)
* var clustered = turf.clustersKmeans(geojson);
*
* // Iterate over each cluster
* turf.clusterEach(clustered, 'cluster', function (cluster, clusterValue, currentIndex) {
* //= cluster
* //= clusterValue
* //= currentIndex
* })
*
* // Calculate the total number of clusters
* var total = 0
* turf.clusterEach(clustered, 'cluster', function () {
* total++;
* });
*
* // Create an Array of all the values retrieved from the 'cluster' property
* var values = []
* turf.clusterEach(clustered, 'cluster', function (cluster, clusterValue) {
* values.push(clusterValue);
* });
*/
function clusterEach(geojson, property, callback) {
// Validation
if (!geojson)
throw new Error("geojson is required");
if (geojson.type !== "FeatureCollection")
throw new Error("geojson must be a FeatureCollection");
if (property === undefined || property === null)
throw new Error("property is required");
// Create clusters based on property values
var bins = createBins(geojson, property);
var values = Object.keys(bins);
for (var index = 0; index < values.length; index++) {
var value = values[index];
var bin = bins[value];
var features = [];
for (var i = 0; i < bin.length; i++) {
features.push(geojson.features[bin[i]]);
}
callback(helpers_1.featureCollection(features), value, index);
}
}
exports.clusterEach = clusterEach;
/**
* Callback for clusterReduce
*
* The first time the callback function is called, the values provided as arguments depend
* on whether the reduce method has an initialValue argument.
*
* If an initialValue is provided to the reduce method:
* - The previousValue argument is initialValue.
* - The currentValue argument is the value of the first element present in the array.
*
* If an initialValue is not provided:
* - The previousValue argument is the value of the first element present in the array.
* - The currentValue argument is the value of the second element present in the array.
*
* @callback clusterReduceCallback
* @param {*} [previousValue] The accumulated value previously returned in the last invocation
* of the callback, or initialValue, if supplied.
* @param {FeatureCollection} [cluster] The current cluster being processed.
* @param {*} [clusterValue] Value used to create cluster being processed.
* @param {number} [currentIndex] The index of the current element being processed in the
* array. Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
*/
/**
* Reduce clusters in GeoJSON Features, similar to Array.reduce()
*
* @name clusterReduce
* @param {FeatureCollection} geojson GeoJSON Features
* @param {string|number} property GeoJSON property key/value used to create clusters
* @param {Function} callback a method that takes (previousValue, cluster, clusterValue, currentIndex)
* @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
* @returns {*} The value that results from the reduction.
* @example
* var geojson = turf.featureCollection([
* turf.point([0, 0]),
* turf.point([2, 4]),
* turf.point([3, 6]),
* turf.point([5, 1]),
* turf.point([4, 2])
* ]);
*
* // Create a cluster using K-Means (adds `cluster` to GeoJSON properties)
* var clustered = turf.clustersKmeans(geojson);
*
* // Iterate over each cluster and perform a calculation
* var initialValue = 0
* turf.clusterReduce(clustered, 'cluster', function (previousValue, cluster, clusterValue, currentIndex) {
* //=previousValue
* //=cluster
* //=clusterValue
* //=currentIndex
* return previousValue++;
* }, initialValue);
*
* // Calculate the total number of clusters
* var total = turf.clusterReduce(clustered, 'cluster', function (previousValue) {
* return previousValue++;
* }, 0);
*
* // Create an Array of all the values retrieved from the 'cluster' property
* var values = turf.clusterReduce(clustered, 'cluster', function (previousValue, cluster, clusterValue) {
* return previousValue.concat(clusterValue);
* }, []);
*/
function clusterReduce(geojson, property, callback, initialValue) {
var previousValue = initialValue;
clusterEach(geojson, property, function (cluster, clusterValue, currentIndex) {
if (currentIndex === 0 && initialValue === undefined)
previousValue = cluster;
else
previousValue = callback(previousValue, cluster, clusterValue, currentIndex);
});
return previousValue;
}
exports.clusterReduce = clusterReduce;
/**
* Create Bins
*
* @private
* @param {FeatureCollection} geojson GeoJSON Features
* @param {string|number} property Property values are used to create bins
* @returns {Object} bins with Feature IDs
* @example
* var geojson = turf.featureCollection([
* turf.point([0, 0], {cluster: 0, foo: 'null'}),
* turf.point([2, 4], {cluster: 1, foo: 'bar'}),
* turf.point([5, 1], {0: 'foo'}),
* turf.point([3, 6], {cluster: 1}),
* ]);
* createBins(geojson, 'cluster');
* //= { '0': [ 0 ], '1': [ 1, 3 ] }
*/
function createBins(geojson, property) {
var bins = {};
meta_1.featureEach(geojson, function (feature, i) {
var properties = feature.properties || {};
if (Object.prototype.hasOwnProperty.call(properties, String(property))) {
var value = properties[property];
if (Object.prototype.hasOwnProperty.call(bins, value))
bins[value].push(i);
else
bins[value] = [i];
}
});
return bins;
}
exports.createBins = createBins;
/**
* Apply Filter
*
* @private
* @param {*} properties Properties
* @param {*} filter Filter
* @returns {boolean} applied Filter to properties
*/
function applyFilter(properties, filter) {
if (properties === undefined)
return false;
var filterType = typeof filter;
// String & Number
if (filterType === "number" || filterType === "string")
return Object.prototype.hasOwnProperty.call(properties, filter);
// Array
else if (Array.isArray(filter)) {
for (var i = 0; i < filter.length; i++) {
if (!applyFilter(properties, filter[i]))
return false;
}
return true;
// Object
}
else {
return propertiesContainsFilter(properties, filter);
}
}
exports.applyFilter = applyFilter;
/**
* Properties contains filter (does not apply deepEqual operations)
*
* @private
* @param {*} properties Properties
* @param {Object} filter Filter
* @returns {boolean} does filter equal Properties
* @example
* propertiesContainsFilter({foo: 'bar', cluster: 0}, {cluster: 0})
* //= true
* propertiesContainsFilter({foo: 'bar', cluster: 0}, {cluster: 1})
* //= false
*/
function propertiesContainsFilter(properties, filter) {
var keys = Object.keys(filter);
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if (properties[key] !== filter[key])
return false;
}
return true;
}
exports.propertiesContainsFilter = propertiesContainsFilter;
/**
* Filter Properties
*
* @private
* @param {*} properties Properties
* @param {Array<string>} keys Used to filter Properties
* @returns {*} filtered Properties
* @example
* filterProperties({foo: 'bar', cluster: 0}, ['cluster'])
* //= {cluster: 0}
*/
function filterProperties(properties, keys) {
if (!keys)
return {};
if (!keys.length)
return {};
var newProperties = {};
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
if (Object.prototype.hasOwnProperty.call(properties, key))
newProperties[key] = properties[key];
}
return newProperties;
}
exports.filterProperties = filterProperties;

67
frontend/node_modules/@turf/clusters/package.json generated vendored Normal file
View File

@@ -0,0 +1,67 @@
{
"name": "@turf/clusters",
"version": "6.5.0",
"description": "turf clusters module",
"author": "Turf Authors",
"contributors": [
"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",
"geojson",
"cluster",
"clusters",
"clustering"
],
"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",
"test:types": "tsc --esModuleInterop --noEmit types.ts"
},
"devDependencies": {
"@types/tape": "*",
"benchmark": "*",
"npm-run-all": "*",
"tape": "*",
"ts-node": "*",
"tslint": "*",
"typescript": "*"
},
"dependencies": {
"@turf/helpers": "^6.5.0",
"@turf/meta": "^6.5.0"
},
"gitHead": "5375941072b90d489389db22b43bfe809d5e451e"
}