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

81
frontend/node_modules/@turf/concave/README.md generated vendored Normal file
View File

@@ -0,0 +1,81 @@
# @turf/concave
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
## concave
Takes a set of [points][1] and returns a concave hull Polygon or MultiPolygon.
Internally, this uses [turf-tin][2] to generate geometries.
**Parameters**
- `points` **[FeatureCollection][3]&lt;[Point][4]>** input points
- `options` **[Object][5]** Optional parameters (optional, default `{}`)
- `options.maxEdge` **[number][6]** the length (in 'units') of an edge necessary for part of the hull to become concave. (optional, default `Infinity`)
- `options.units` **[string][7]** can be degrees, radians, miles, or kilometers (optional, default `'kilometers'`)
**Examples**
```javascript
var points = turf.featureCollection([
turf.point([-63.601226, 44.642643]),
turf.point([-63.591442, 44.651436]),
turf.point([-63.580799, 44.648749]),
turf.point([-63.573589, 44.641788]),
turf.point([-63.587665, 44.64533]),
turf.point([-63.595218, 44.64765])
]);
var options = {units: 'miles', maxEdge: 1};
var hull = turf.concave(points, options);
//addToMap
var addToMap = [points, hull]
```
Returns **([Feature][8]&lt;([Polygon][9] \| [MultiPolygon][10])> | null)** a concave hull (null value is returned if unable to compute hull)
[1]: https://tools.ietf.org/html/rfc7946#section-3.1.2
[2]: https://github.com/Turfjs/turf-tin
[3]: https://tools.ietf.org/html/rfc7946#section-3.3
[4]: https://tools.ietf.org/html/rfc7946#section-3.1.2
[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
[8]: https://tools.ietf.org/html/rfc7946#section-3.2
[9]: https://tools.ietf.org/html/rfc7946#section-3.1.6
[10]: https://tools.ietf.org/html/rfc7946#section-3.1.7
<!-- 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/concave
```
Or install the Turf module that includes it as a function:
```sh
$ npm install @turf/turf
```

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

@@ -0,0 +1,83 @@
import distance from "@turf/distance";
import { feature, featureCollection } from "@turf/helpers";
import { featureEach } from "@turf/meta";
import tin from "@turf/tin";
import dissolve from "./lib/turf-dissolve.js";
/**
* Takes a set of {@link Point|points} and returns a concave hull Polygon or MultiPolygon.
* Internally, this uses [turf-tin](https://github.com/Turfjs/turf-tin) to generate geometries.
*
* @name concave
* @param {FeatureCollection<Point>} points input points
* @param {Object} [options={}] Optional parameters
* @param {number} [options.maxEdge=Infinity] the length (in 'units') of an edge necessary for part of the
* hull to become concave.
* @param {string} [options.units='kilometers'] can be degrees, radians, miles, or kilometers
* @returns {Feature<(Polygon|MultiPolygon)>|null} a concave hull (null value is returned if unable to compute hull)
* @example
* var points = turf.featureCollection([
* turf.point([-63.601226, 44.642643]),
* turf.point([-63.591442, 44.651436]),
* turf.point([-63.580799, 44.648749]),
* turf.point([-63.573589, 44.641788]),
* turf.point([-63.587665, 44.64533]),
* turf.point([-63.595218, 44.64765])
* ]);
* var options = {units: 'miles', maxEdge: 1};
*
* var hull = turf.concave(points, options);
*
* //addToMap
* var addToMap = [points, hull]
*/
function concave(points, options) {
if (options === void 0) { options = {}; }
var maxEdge = options.maxEdge || Infinity;
var cleaned = removeDuplicates(points);
var tinPolys = tin(cleaned);
// calculate length of all edges and area of all triangles
// and remove triangles that fail the max length test
tinPolys.features = tinPolys.features.filter(function (triangle) {
var pt1 = triangle.geometry.coordinates[0][0];
var pt2 = triangle.geometry.coordinates[0][1];
var pt3 = triangle.geometry.coordinates[0][2];
var dist1 = distance(pt1, pt2, options);
var dist2 = distance(pt2, pt3, options);
var dist3 = distance(pt1, pt3, options);
return dist1 <= maxEdge && dist2 <= maxEdge && dist3 <= maxEdge;
});
if (tinPolys.features.length < 1) {
return null;
}
// merge the adjacent triangles
var dissolved = dissolve(tinPolys);
// geojson-dissolve always returns a MultiPolygon
if (dissolved.coordinates.length === 1) {
dissolved.coordinates = dissolved.coordinates[0];
dissolved.type = "Polygon";
}
return feature(dissolved);
}
/**
* Removes duplicated points in a collection returning a new collection
*
* @private
* @param {FeatureCollection<Point>} points to be cleaned
* @returns {FeatureCollection<Point>} cleaned set of points
*/
function removeDuplicates(points) {
var cleaned = [];
var existing = {};
featureEach(points, function (pt) {
if (!pt.geometry) {
return;
}
var key = pt.geometry.coordinates.join("-");
if (!Object.prototype.hasOwnProperty.call(existing, key)) {
cleaned.push(pt);
existing[key] = true;
}
});
return featureCollection(cleaned);
}
export default concave;

View File

@@ -0,0 +1,71 @@
import clone from "@turf/clone";
import { isObject } from "@turf/helpers";
import { getType } from "@turf/invariant";
import { flattenEach } from "@turf/meta";
import lineDissolve from "./turf-line-dissolve.js";
import polygonDissolve from "./turf-polygon-dissolve.js";
/**
* Transform function: attempts to dissolve geojson objects where possible
* [GeoJSON] -> GeoJSON geometry
*
* @private
* @param {FeatureCollection<LineString|MultiLineString|Polygon|MultiPolygon>} geojson Features to dissolved
* @param {Object} [options={}] Optional parameters
* @param {boolean} [options.mutate=false] Prevent input mutation
* @returns {Feature<MultiLineString|MultiPolygon>} Dissolved Features
*/
function dissolve(geojson, options) {
if (options === void 0) { options = {}; }
// Optional parameters
options = options || {};
if (!isObject(options)) {
throw new Error("options is invalid");
}
var mutate = options.mutate;
// Validation
if (getType(geojson) !== "FeatureCollection") {
throw new Error("geojson must be a FeatureCollection");
}
if (!geojson.features.length) {
throw new Error("geojson is empty");
}
// Clone geojson to avoid side effects
// Topojson modifies in place, so we need to deep clone first
if (mutate === false || mutate === undefined) {
geojson = clone(geojson);
}
// Assert homogenity
var type = getHomogenousType(geojson);
if (!type) {
throw new Error("geojson must be homogenous");
}
// Data => Typescript hack
var data = geojson;
switch (type) {
case "LineString":
return lineDissolve(data, options);
case "Polygon":
return polygonDissolve(data, options);
default:
throw new Error(type + " is not supported");
}
}
/**
* Checks if GeoJSON is Homogenous
*
* @private
* @param {GeoJSON} geojson GeoJSON
* @returns {string|null} Homogenous type or null if multiple types
*/
function getHomogenousType(geojson) {
var types = {};
flattenEach(geojson, function (feature) {
types[feature.geometry.type] = true;
});
var keys = Object.keys(types);
if (keys.length === 1) {
return keys[0];
}
return null;
}
export default dissolve;

View File

@@ -0,0 +1,105 @@
import clone from "@turf/clone";
import { isObject, lineString, multiLineString } from "@turf/helpers";
import { getType } from "@turf/invariant";
import { lineReduce } from "@turf/meta";
/**
* Merges all connected (non-forking, non-junctioning) line strings into single lineStrings.
* [LineString] -> LineString|MultiLineString
*
* @param {FeatureCollection<LineString|MultiLineString>} geojson Lines to dissolve
* @param {Object} [options={}] Optional parameters
* @param {boolean} [options.mutate=false] Prevent input mutation
* @returns {Feature<LineString|MultiLineString>} Dissolved lines
*/
function lineDissolve(geojson, options) {
if (options === void 0) { options = {}; }
// Optional parameters
options = options || {};
if (!isObject(options)) {
throw new Error("options is invalid");
}
var mutate = options.mutate;
// Validation
if (getType(geojson) !== "FeatureCollection") {
throw new Error("geojson must be a FeatureCollection");
}
if (!geojson.features.length) {
throw new Error("geojson is empty");
}
// Clone geojson to avoid side effects
if (mutate === false || mutate === undefined) {
geojson = clone(geojson);
}
var result = [];
var lastLine = lineReduce(geojson, function (previousLine, currentLine) {
// Attempt to merge this LineString with the other LineStrings, updating
// the reference as it is merged with others and grows.
var merged = mergeLineStrings(previousLine, currentLine);
// Accumulate the merged LineString
if (merged) {
return merged;
// Put the unmerged LineString back into the list
}
else {
result.push(previousLine);
return currentLine;
}
});
// Append the last line
if (lastLine) {
result.push(lastLine);
}
// Return null if no lines were dissolved
if (!result.length) {
return null;
// Return LineString if only 1 line was dissolved
}
else if (result.length === 1) {
return result[0];
// Return MultiLineString if multiple lines were dissolved with gaps
}
else {
return multiLineString(result.map(function (line) {
return line.coordinates;
}));
}
}
// [Number, Number] -> String
function coordId(coord) {
return coord[0].toString() + "," + coord[1].toString();
}
/**
* LineString, LineString -> LineString
*
* @private
* @param {Feature<LineString>} a line1
* @param {Feature<LineString>} b line2
* @returns {Feature<LineString>|null} Merged LineString
*/
function mergeLineStrings(a, b) {
var coords1 = a.geometry.coordinates;
var coords2 = b.geometry.coordinates;
var s1 = coordId(coords1[0]);
var e1 = coordId(coords1[coords1.length - 1]);
var s2 = coordId(coords2[0]);
var e2 = coordId(coords2[coords2.length - 1]);
// TODO: handle case where more than one of these is true!
var coords;
if (s1 === e2) {
coords = coords2.concat(coords1.slice(1));
}
else if (s2 === e1) {
coords = coords1.concat(coords2.slice(1));
}
else if (s1 === s2) {
coords = coords1.slice(1).reverse().concat(coords2);
}
else if (e1 === e2) {
coords = coords1.concat(coords2.reverse().slice(1));
}
else {
return null;
}
return lineString(coords);
}
export default lineDissolve;

View File

@@ -0,0 +1,36 @@
import clone from "@turf/clone";
import { geometryCollection } from "@turf/helpers";
import { getType } from "@turf/invariant";
import { flattenEach } from "@turf/meta";
import { merge } from "topojson-client";
import { topology } from "topojson-server";
/**
* Dissolves all overlapping (Multi)Polygon
*
* @param {FeatureCollection<Polygon|MultiPolygon>} geojson Polygons to dissolve
* @param {Object} [options={}] Optional parameters
* @param {boolean} [options.mutate=false] Prevent input mutation
* @returns {Feature<Polygon|MultiPolygon>} Dissolved Polygons
*/
export default function polygonDissolve(geojson, options) {
if (options === void 0) { options = {}; }
// Validation
if (getType(geojson) !== "FeatureCollection") {
throw new Error("geojson must be a FeatureCollection");
}
if (!geojson.features.length) {
throw new Error("geojson is empty");
}
// Clone geojson to avoid side effects
// Topojson modifies in place, so we need to deep clone first
if (options.mutate === false || options.mutate === undefined) {
geojson = clone(geojson);
}
var geoms = [];
flattenEach(geojson, function (feature) {
geoms.push(feature.geometry);
});
var topo = topology({ geoms: geometryCollection(geoms).geometry });
var merged = merge(topo, topo.objects.geoms.geometries);
return merged;
}

View File

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

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

@@ -0,0 +1,33 @@
import { Feature, FeatureCollection, MultiPolygon, Point, Polygon, Units } from "@turf/helpers";
/**
* Takes a set of {@link Point|points} and returns a concave hull Polygon or MultiPolygon.
* Internally, this uses [turf-tin](https://github.com/Turfjs/turf-tin) to generate geometries.
*
* @name concave
* @param {FeatureCollection<Point>} points input points
* @param {Object} [options={}] Optional parameters
* @param {number} [options.maxEdge=Infinity] the length (in 'units') of an edge necessary for part of the
* hull to become concave.
* @param {string} [options.units='kilometers'] can be degrees, radians, miles, or kilometers
* @returns {Feature<(Polygon|MultiPolygon)>|null} a concave hull (null value is returned if unable to compute hull)
* @example
* var points = turf.featureCollection([
* turf.point([-63.601226, 44.642643]),
* turf.point([-63.591442, 44.651436]),
* turf.point([-63.580799, 44.648749]),
* turf.point([-63.573589, 44.641788]),
* turf.point([-63.587665, 44.64533]),
* turf.point([-63.595218, 44.64765])
* ]);
* var options = {units: 'miles', maxEdge: 1};
*
* var hull = turf.concave(points, options);
*
* //addToMap
* var addToMap = [points, hull]
*/
declare function concave(points: FeatureCollection<Point>, options?: {
maxEdge?: number;
units?: Units;
}): Feature<Polygon | MultiPolygon> | null;
export default concave;

88
frontend/node_modules/@turf/concave/dist/js/index.js generated vendored Executable file
View File

@@ -0,0 +1,88 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var distance_1 = __importDefault(require("@turf/distance"));
var helpers_1 = require("@turf/helpers");
var meta_1 = require("@turf/meta");
var tin_1 = __importDefault(require("@turf/tin"));
var turf_dissolve_1 = __importDefault(require("./lib/turf-dissolve"));
/**
* Takes a set of {@link Point|points} and returns a concave hull Polygon or MultiPolygon.
* Internally, this uses [turf-tin](https://github.com/Turfjs/turf-tin) to generate geometries.
*
* @name concave
* @param {FeatureCollection<Point>} points input points
* @param {Object} [options={}] Optional parameters
* @param {number} [options.maxEdge=Infinity] the length (in 'units') of an edge necessary for part of the
* hull to become concave.
* @param {string} [options.units='kilometers'] can be degrees, radians, miles, or kilometers
* @returns {Feature<(Polygon|MultiPolygon)>|null} a concave hull (null value is returned if unable to compute hull)
* @example
* var points = turf.featureCollection([
* turf.point([-63.601226, 44.642643]),
* turf.point([-63.591442, 44.651436]),
* turf.point([-63.580799, 44.648749]),
* turf.point([-63.573589, 44.641788]),
* turf.point([-63.587665, 44.64533]),
* turf.point([-63.595218, 44.64765])
* ]);
* var options = {units: 'miles', maxEdge: 1};
*
* var hull = turf.concave(points, options);
*
* //addToMap
* var addToMap = [points, hull]
*/
function concave(points, options) {
if (options === void 0) { options = {}; }
var maxEdge = options.maxEdge || Infinity;
var cleaned = removeDuplicates(points);
var tinPolys = tin_1.default(cleaned);
// calculate length of all edges and area of all triangles
// and remove triangles that fail the max length test
tinPolys.features = tinPolys.features.filter(function (triangle) {
var pt1 = triangle.geometry.coordinates[0][0];
var pt2 = triangle.geometry.coordinates[0][1];
var pt3 = triangle.geometry.coordinates[0][2];
var dist1 = distance_1.default(pt1, pt2, options);
var dist2 = distance_1.default(pt2, pt3, options);
var dist3 = distance_1.default(pt1, pt3, options);
return dist1 <= maxEdge && dist2 <= maxEdge && dist3 <= maxEdge;
});
if (tinPolys.features.length < 1) {
return null;
}
// merge the adjacent triangles
var dissolved = turf_dissolve_1.default(tinPolys);
// geojson-dissolve always returns a MultiPolygon
if (dissolved.coordinates.length === 1) {
dissolved.coordinates = dissolved.coordinates[0];
dissolved.type = "Polygon";
}
return helpers_1.feature(dissolved);
}
/**
* Removes duplicated points in a collection returning a new collection
*
* @private
* @param {FeatureCollection<Point>} points to be cleaned
* @returns {FeatureCollection<Point>} cleaned set of points
*/
function removeDuplicates(points) {
var cleaned = [];
var existing = {};
meta_1.featureEach(points, function (pt) {
if (!pt.geometry) {
return;
}
var key = pt.geometry.coordinates.join("-");
if (!Object.prototype.hasOwnProperty.call(existing, key)) {
cleaned.push(pt);
existing[key] = true;
}
});
return helpers_1.featureCollection(cleaned);
}
exports.default = concave;

View File

@@ -0,0 +1,15 @@
import { Feature, FeatureCollection, LineString, MultiLineString, MultiPolygon, Polygon } from "@turf/helpers";
/**
* Transform function: attempts to dissolve geojson objects where possible
* [GeoJSON] -> GeoJSON geometry
*
* @private
* @param {FeatureCollection<LineString|MultiLineString|Polygon|MultiPolygon>} geojson Features to dissolved
* @param {Object} [options={}] Optional parameters
* @param {boolean} [options.mutate=false] Prevent input mutation
* @returns {Feature<MultiLineString|MultiPolygon>} Dissolved Features
*/
declare function dissolve(geojson: FeatureCollection<LineString | MultiLineString | Polygon | MultiPolygon>, options?: {
mutate?: boolean;
}): Feature<LineString | MultiLineString | Polygon | MultiPolygon> | null;
export default dissolve;

View File

@@ -0,0 +1,76 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var clone_1 = __importDefault(require("@turf/clone"));
var helpers_1 = require("@turf/helpers");
var invariant_1 = require("@turf/invariant");
var meta_1 = require("@turf/meta");
var turf_line_dissolve_1 = __importDefault(require("./turf-line-dissolve"));
var turf_polygon_dissolve_1 = __importDefault(require("./turf-polygon-dissolve"));
/**
* Transform function: attempts to dissolve geojson objects where possible
* [GeoJSON] -> GeoJSON geometry
*
* @private
* @param {FeatureCollection<LineString|MultiLineString|Polygon|MultiPolygon>} geojson Features to dissolved
* @param {Object} [options={}] Optional parameters
* @param {boolean} [options.mutate=false] Prevent input mutation
* @returns {Feature<MultiLineString|MultiPolygon>} Dissolved Features
*/
function dissolve(geojson, options) {
if (options === void 0) { options = {}; }
// Optional parameters
options = options || {};
if (!helpers_1.isObject(options)) {
throw new Error("options is invalid");
}
var mutate = options.mutate;
// Validation
if (invariant_1.getType(geojson) !== "FeatureCollection") {
throw new Error("geojson must be a FeatureCollection");
}
if (!geojson.features.length) {
throw new Error("geojson is empty");
}
// Clone geojson to avoid side effects
// Topojson modifies in place, so we need to deep clone first
if (mutate === false || mutate === undefined) {
geojson = clone_1.default(geojson);
}
// Assert homogenity
var type = getHomogenousType(geojson);
if (!type) {
throw new Error("geojson must be homogenous");
}
// Data => Typescript hack
var data = geojson;
switch (type) {
case "LineString":
return turf_line_dissolve_1.default(data, options);
case "Polygon":
return turf_polygon_dissolve_1.default(data, options);
default:
throw new Error(type + " is not supported");
}
}
/**
* Checks if GeoJSON is Homogenous
*
* @private
* @param {GeoJSON} geojson GeoJSON
* @returns {string|null} Homogenous type or null if multiple types
*/
function getHomogenousType(geojson) {
var types = {};
meta_1.flattenEach(geojson, function (feature) {
types[feature.geometry.type] = true;
});
var keys = Object.keys(types);
if (keys.length === 1) {
return keys[0];
}
return null;
}
exports.default = dissolve;

View File

@@ -0,0 +1,14 @@
import { Feature, FeatureCollection, LineString, MultiLineString } from "@turf/helpers";
/**
* Merges all connected (non-forking, non-junctioning) line strings into single lineStrings.
* [LineString] -> LineString|MultiLineString
*
* @param {FeatureCollection<LineString|MultiLineString>} geojson Lines to dissolve
* @param {Object} [options={}] Optional parameters
* @param {boolean} [options.mutate=false] Prevent input mutation
* @returns {Feature<LineString|MultiLineString>} Dissolved lines
*/
declare function lineDissolve(geojson: FeatureCollection<LineString | MultiLineString>, options?: {
mutate?: boolean;
}): Feature<LineString | MultiLineString> | null;
export default lineDissolve;

View File

@@ -0,0 +1,110 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var clone_1 = __importDefault(require("@turf/clone"));
var helpers_1 = require("@turf/helpers");
var invariant_1 = require("@turf/invariant");
var meta_1 = require("@turf/meta");
/**
* Merges all connected (non-forking, non-junctioning) line strings into single lineStrings.
* [LineString] -> LineString|MultiLineString
*
* @param {FeatureCollection<LineString|MultiLineString>} geojson Lines to dissolve
* @param {Object} [options={}] Optional parameters
* @param {boolean} [options.mutate=false] Prevent input mutation
* @returns {Feature<LineString|MultiLineString>} Dissolved lines
*/
function lineDissolve(geojson, options) {
if (options === void 0) { options = {}; }
// Optional parameters
options = options || {};
if (!helpers_1.isObject(options)) {
throw new Error("options is invalid");
}
var mutate = options.mutate;
// Validation
if (invariant_1.getType(geojson) !== "FeatureCollection") {
throw new Error("geojson must be a FeatureCollection");
}
if (!geojson.features.length) {
throw new Error("geojson is empty");
}
// Clone geojson to avoid side effects
if (mutate === false || mutate === undefined) {
geojson = clone_1.default(geojson);
}
var result = [];
var lastLine = meta_1.lineReduce(geojson, function (previousLine, currentLine) {
// Attempt to merge this LineString with the other LineStrings, updating
// the reference as it is merged with others and grows.
var merged = mergeLineStrings(previousLine, currentLine);
// Accumulate the merged LineString
if (merged) {
return merged;
// Put the unmerged LineString back into the list
}
else {
result.push(previousLine);
return currentLine;
}
});
// Append the last line
if (lastLine) {
result.push(lastLine);
}
// Return null if no lines were dissolved
if (!result.length) {
return null;
// Return LineString if only 1 line was dissolved
}
else if (result.length === 1) {
return result[0];
// Return MultiLineString if multiple lines were dissolved with gaps
}
else {
return helpers_1.multiLineString(result.map(function (line) {
return line.coordinates;
}));
}
}
// [Number, Number] -> String
function coordId(coord) {
return coord[0].toString() + "," + coord[1].toString();
}
/**
* LineString, LineString -> LineString
*
* @private
* @param {Feature<LineString>} a line1
* @param {Feature<LineString>} b line2
* @returns {Feature<LineString>|null} Merged LineString
*/
function mergeLineStrings(a, b) {
var coords1 = a.geometry.coordinates;
var coords2 = b.geometry.coordinates;
var s1 = coordId(coords1[0]);
var e1 = coordId(coords1[coords1.length - 1]);
var s2 = coordId(coords2[0]);
var e2 = coordId(coords2[coords2.length - 1]);
// TODO: handle case where more than one of these is true!
var coords;
if (s1 === e2) {
coords = coords2.concat(coords1.slice(1));
}
else if (s2 === e1) {
coords = coords1.concat(coords2.slice(1));
}
else if (s1 === s2) {
coords = coords1.slice(1).reverse().concat(coords2);
}
else if (e1 === e2) {
coords = coords1.concat(coords2.reverse().slice(1));
}
else {
return null;
}
return helpers_1.lineString(coords);
}
exports.default = lineDissolve;

View File

@@ -0,0 +1,12 @@
import { Feature, FeatureCollection, MultiPolygon, Polygon } from "@turf/helpers";
/**
* Dissolves all overlapping (Multi)Polygon
*
* @param {FeatureCollection<Polygon|MultiPolygon>} geojson Polygons to dissolve
* @param {Object} [options={}] Optional parameters
* @param {boolean} [options.mutate=false] Prevent input mutation
* @returns {Feature<Polygon|MultiPolygon>} Dissolved Polygons
*/
export default function polygonDissolve(geojson: FeatureCollection<Polygon | MultiPolygon>, options?: {
mutate?: boolean;
}): Feature<Polygon | MultiPolygon> | null;

View File

@@ -0,0 +1,42 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var clone_1 = __importDefault(require("@turf/clone"));
var helpers_1 = require("@turf/helpers");
var invariant_1 = require("@turf/invariant");
var meta_1 = require("@turf/meta");
var topojson_client_1 = require("topojson-client");
var topojson_server_1 = require("topojson-server");
/**
* Dissolves all overlapping (Multi)Polygon
*
* @param {FeatureCollection<Polygon|MultiPolygon>} geojson Polygons to dissolve
* @param {Object} [options={}] Optional parameters
* @param {boolean} [options.mutate=false] Prevent input mutation
* @returns {Feature<Polygon|MultiPolygon>} Dissolved Polygons
*/
function polygonDissolve(geojson, options) {
if (options === void 0) { options = {}; }
// Validation
if (invariant_1.getType(geojson) !== "FeatureCollection") {
throw new Error("geojson must be a FeatureCollection");
}
if (!geojson.features.length) {
throw new Error("geojson is empty");
}
// Clone geojson to avoid side effects
// Topojson modifies in place, so we need to deep clone first
if (options.mutate === false || options.mutate === undefined) {
geojson = clone_1.default(geojson);
}
var geoms = [];
meta_1.flattenEach(geojson, function (feature) {
geoms.push(feature.geometry);
});
var topo = topojson_server_1.topology({ geoms: helpers_1.geometryCollection(geoms).geometry });
var merged = topojson_client_1.merge(topo, topo.objects.geoms.geometries);
return merged;
}
exports.default = polygonDissolve;

83
frontend/node_modules/@turf/concave/package.json generated vendored Normal file
View File

@@ -0,0 +1,83 @@
{
"name": "@turf/concave",
"version": "6.5.0",
"description": "turf concave module",
"author": "Turf Authors",
"contributors": [
"Tom MacWright <@tmcw>",
"Lyzi Diamond <@lyzidiamond>",
"Denis Carriere <@DenisCarriere>",
"Stefano Borghi <@stebogit>",
"Rowan Winsemius <@rowanwins>",
"Daniel Pulido <@dpmcmlxxvi>",
"Stephen Whitmore <@noffle>",
"Gregor MacLennan <@gmaclennan>",
"Mike Bostock <@mbostock>"
],
"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",
"gis",
"concave",
"geometry"
],
"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": "*",
"@types/topojson-client": "^3.0.0",
"@types/topojson-server": "^3.0.0",
"benchmark": "*",
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"ts-node": "*",
"tslint": "*",
"typescript": "*",
"write-json-file": "*"
},
"dependencies": {
"@turf/clone": "^6.5.0",
"@turf/distance": "^6.5.0",
"@turf/helpers": "^6.5.0",
"@turf/invariant": "^6.5.0",
"@turf/meta": "^6.5.0",
"@turf/tin": "^6.5.0",
"topojson-client": "3.x",
"topojson-server": "3.x"
},
"gitHead": "5375941072b90d489389db22b43bfe809d5e451e"
}