How to use the @turf/line-to-polygon function in @turf/line-to-polygon

To help you get started, we’ve selected a few @turf/line-to-polygon 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 terrestris / ol-util / src / GeometryUtil / GeometryUtil.js View on Github external
geometries.forEach(geometry => {
      // Convert the polygon to turf.js/GeoJSON geometry while
      // reprojecting them to the internal turf.js projection 'EPSG:4326'.
      const turfPolygon = geoJsonFormat.writeGeometryObject(geometry);
      const turfPolygonCoordinates = turfPolygon.coordinates;
      // outer lines of the given polygon
      const outer = lineString(turfPolygonCoordinates[0]);
      // polygonized outer polygon
      const outerPolygon = lineToPolygon(outer);
      // holes in the polygon
      const inners = [];
      turfPolygonCoordinates.slice(1, turfPolygonCoordinates.length).forEach(function (coord) {
        inners.push(lineString(coord));
      });
      // Polygonize the holes in the polygon
      const innerPolygon = polygonize(featureCollection(inners));
      // make a lineString from the spliting line and the outer of the polygon
      let unionGeom = union(outer, turfLine);
      // Polygonize the combined lines.
      const polygonizedUnionGeom = polygonize(unionGeom);
      // Array of the split polygons within the geometry
      const splitedPolygons = [];
      // Iterate over each feature in the combined feature and remove sections that are outside the initial polygon and
      // remove the parts from the cutted polygons that are in polygon holes.
      featureEach(polygonizedUnionGeom, cuttedSection => {
github terascope / teraslice / packages / xlucene-evaluator / src / parser / functions / geo / polygon.ts View on Github external
function matcher() {
            const polyPoints = points.map((obj) => [obj.lon, obj.lat]);
            const line = lineString(polyPoints);
            const matcherPolygon = lineToPolygon(line);

            // Nothing matches so return false
            if (polygon == null) return () => false;
            return geoMatcher(matcherPolygon);
        }
github terascope / teraslice / packages / xlucene-evaluator / src / parser / functions / geo / helpers.ts View on Github external
export function makePolygon(points: GeoPoint[]) {
    const polyPoints = points.map(makeCoordinatesFromGeoPoint);
    const line = lineString(polyPoints);
    return lineToPolygon(line);
}

@turf/line-to-polygon

turf line-to-polygon module

MIT
Latest version published 1 month ago

Package Health Score

98 / 100
Full package analysis

Popular @turf/line-to-polygon functions