How to use the @turf/helpers.multiLineString function in @turf/helpers

To help you get started, we’ve selected a few @turf/helpers examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Turfjs / turf / packages / turf-isolines / index.js View on Github external
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;
}
github Turfjs / turf / packages / turf-line-to-polygon / types.ts View on Github external
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
github Turfjs / turf / packages / turf-concave / lib / turf-line-dissolve.ts View on Github external
} 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;
    })); }
}
github Turfjs / turf / src / concave / lib / turf-line-dissolve.js View on Github external
});
    // 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
github Turfjs / turf / packages / turf-polygon-to-line / index.ts View on Github external
export function coordsToLine<p>(
    coords: number[][][],
    properties: P,
): Feature {
    if (coords.length &gt; 1) { return multiLineString(coords, properties); }
    return lineString(coords[0], properties);
}
</p>
github Turfjs / turf / packages / turf-rewind / types.ts View on Github external
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)
github Turfjs / turf / packages / turf-line-overlap / types.ts View on Github external
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)
github Turfjs / turf / packages / turf-flatten / types.ts View on Github external
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]));