Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function dissolve(featureCollection, options) {
// Optional parameters
options = options || {};
if (!isObject(options)) throw new Error('options is invalid');
var propertyName = options.propertyName;
// Input validation
collectionOf(featureCollection, 'Polygon', 'dissolve');
// Main
var fc = clone(featureCollection);
var features = fc.features;
var originalIndexOfItemsRemoved = [];
features.forEach(function (f, i) {
f.properties.origIndexPosition = i;
});
var tree = rbush();
tree.load(fc);
for (var i in features) {
var polygon = features[i];
export default function gridToMatrix(grid, options) {
// Optional parameters
options = options || {};
if (!isObject(options)) throw new Error('options is invalid');
var zProperty = options.zProperty || 'elevation';
var flip = options.flip;
var flags = options.flags;
// validation
collectionOf(grid, 'Point', 'input must contain Points');
var pointsMatrix = sortPointsByLatLng(grid, flip);
var matrix = [];
// create property matrix from sorted points
// looping order matters here
for (var r = 0; r < pointsMatrix.length; r++) {
var pointRow = pointsMatrix[r];
var row = [];
for (var c = 0; c < pointRow.length; c++) {
var point = pointRow[c];
// Check if zProperty exist
if (point.properties[zProperty]) row.push(point.properties[zProperty]);
else row.push(0);
// add flags
if (flags === true) point.properties.matrixPosition = [r, c];
function isobands(pointGrid, breaks, options) {
// Optional parameters
options = options || {};
if (!isObject(options)) throw new Error('options is invalid');
var zProperty = options.zProperty || 'elevation';
var commonProperties = options.commonProperties || {};
var breaksProperties = options.breaksProperties || [];
// Validation
collectionOf(pointGrid, 'Point', 'Input must contain Points');
if (!breaks) throw new Error('breaks is required');
if (!Array.isArray(breaks)) throw new Error('breaks is not an Array');
if (!isObject(commonProperties)) throw new Error('commonProperties is not an Object');
if (!Array.isArray(breaksProperties)) throw new Error('breaksProperties is not an Array');
// Isoband methods
var matrix = gridToMatrix(pointGrid, {zProperty: zProperty, flip: true});
var contours = createContourLines(matrix, breaks, zProperty);
contours = rescaleContours(contours, matrix, pointGrid);
var multipolygons = contours.map(function (contour, index) {
if (breaksProperties[index] && !isObject(breaksProperties[index])) {
throw new Error('Each mappedProperty is required to be an Object');
}
// collect all properties
var contourProperties = objectAssign(
function isolines(pointGrid, breaks, options) {
// Optional parameters
options = options || {};
if (!isObject(options)) throw new Error('options is invalid');
var zProperty = options.zProperty || 'elevation';
var commonProperties = options.commonProperties || {};
var breaksProperties = options.breaksProperties || [];
// Input validation
collectionOf(pointGrid, 'Point', 'Input must contain Points');
if (!breaks) throw new Error('breaks is required');
if (!Array.isArray(breaks)) throw new Error('breaks must be an Array');
if (!isObject(commonProperties)) throw new Error('commonProperties must be an Object');
if (!Array.isArray(breaksProperties)) throw new Error('breaksProperties must be an Array');
// Isoline methods
var matrix = gridToMatrix(pointGrid, {zProperty: zProperty, flip: true});
var createdIsoLines = createIsoLines(matrix, breaks, zProperty, commonProperties, breaksProperties);
var scaledIsolines = rescaleIsolines(createdIsoLines, matrix, pointGrid);
return featureCollection(scaledIsolines);
}
function interpolate(points, cellSize, options) {
// Optional parameters
options = options || {};
if (typeof options !== 'object') throw new Error('options is invalid');
var gridType = options.gridType;
var property = options.property;
var units = options.units;
var weight = options.weight;
// validation
if (!points) throw new Error('points is required');
collectionOf(points, 'Point', 'input must contain Points');
if (!cellSize) throw new Error('cellSize is required');
if (weight !== undefined && typeof weight !== 'number') throw new Error('weight must be a number');
// default values
property = property || 'elevation';
gridType = gridType || 'square';
weight = weight || 1;
var box = bbox(points);
var grid;
switch (gridType) {
case 'point':
case 'points':
grid = poinGrid(box, cellSize, {units: units, bboxIsMask: true});
break;
case 'square':
function voronoi(points, options) {
// Optional params
options = options || {};
if (!isObject(options)) throw new Error('options is invalid');
var bbox = options.bbox || [-180, -85, 180, 85];
// Input Validation
if (!points) throw new Error('points is required');
if (!Array.isArray(bbox)) throw new Error('bbox is invalid');
collectionOf(points, 'Point', 'points');
// Main
return featureCollection(
d3voronoi.voronoi()
.x(function (feature) { return feature.geometry.coordinates[0]; })
.y(function (feature) { return feature.geometry.coordinates[1]; })
.extent([[bbox[0], bbox[1]], [bbox[2], bbox[3]]])
.polygons(points.features)
.map(coordsToPolygon)
);
}