Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function createIsoLines(matrix, breaks, zProperty, commonProperties, breaksProperties) {
var results = [];
for (var i = 1; i < breaks.length; i++) {
var threshold = +breaks[i]; // make sure it's a number
var properties = objectAssign(
{},
commonProperties,
breaksProperties[i]
);
properties[zProperty] = threshold;
var isoline = multiLineString(isoContours(matrix, threshold), properties);
results.push(isoline);
}
return results;
}
featureCollection,
lineString,
multiLineString,
Polygon,
LineString,
MultiLineString,
MultiPolygon,
Feature,
FeatureCollection
} from '@turf/helpers'
import lineToPolygon from './'
// Fixtures
const coords = [[125, -30], [145, -30], [145, -20], [125, -20], [125, -30]];
const line = lineString(coords);
const multiLine = multiLineString([coords, coords]);
const fc = featureCollection([line, multiLine]);
// Assert results with types
const poly1 = lineToPolygon(line); // Feature
} 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((line) => {
return line.coordinates;
})); }
}
});
// 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
export function coordsToLine<p>(
coords: number[][][],
properties: P,
): Feature {
if (coords.length > 1) { return multiLineString(coords, properties); }
return lineString(coords[0], properties);
}
</p>
import { polygon, lineString, multiLineString, multiPolygon } from '@turf/helpers'
import rewind from './'
const coords = [[121, -29], [138, -29], [138, -18], [121, -18], [121, -29]]
const poly = polygon([coords])
const line = lineString(coords)
const multiPoly = multiPolygon([[coords], [coords]])
const multiLine = multiLineString([coords, coords])
rewind(line)
rewind(poly)
rewind(multiPoly)
rewind(multiLine)
rewind(poly, true)
rewind(poly, true, true)
import {lineString, multiLineString, polygon, multiPolygon} from '@turf/helpers'
import lineOverlap from './'
const line = lineString([[0, 0], [10, 10]]);
const multiLine = multiLineString([[[0, 0], [10, 10]], [[30, 30], [50, 50]]]);
const poly = polygon([[[0, 0], [10, 10], [15, 15], [0, 0]]]);
const multiPoly = multiPolygon([
[[[0, 0], [10, 10], [15, 15], [0, 0]]],
[[[5, 5], [30, 30], [45, 45], [5, 5]]]
])
lineOverlap(line, poly)
lineOverlap(line, line)
lineOverlap(multiPoly, line)
lineOverlap(multiPoly, multiLine)
lineOverlap(multiPoly, multiLine, 5)
import {multiPoint, multiLineString, geometryCollection} from '@turf/helpers'
import * as flatten from './'
const multiPt = multiPoint([[0, 0], [10, 10]])
const multiLine = multiLineString([[[20, 20], [30, 30]], [[0, 0], [10, 10]]])
flatten(multiPt);
flatten(multiLine);
flatten(multiPt.geometry);
flatten(multiLine.geometry);
flatten(geometryCollection([multiPt.geometry, multiLine.geometry]));