Esempio n. 1
0
import {
  point, lineString, polygon,
  multiPoint, multiLineString, multiPolygon,
  featureCollection, geometryCollection
} from '@turf/helpers'
import buffer from './'

// Standard Geometry
const pt = point([100, 0]);
const line = lineString([[100, 0], [50, 0]]);
const poly = polygon([[[100, 0], [50, 0], [0, 50], [100, 0]]]);

buffer(pt, 5);
buffer(line, 5);
buffer(poly, 5);
buffer(pt, 5, {units: 'miles'});
buffer(pt, 10, {units: 'meters', steps: 64});

// Multi Geometry
const multiPt = multiPoint([[100, 0], [0, 100]]);
const multiLine = multiLineString([[[100, 0], [50, 0]], [[100, 0], [50, 0]]]);
const multiPoly = multiPolygon([[[[100, 0], [50, 0], [0, 50], [100, 0]]], [[[100, 0], [50, 0], [0, 50], [100, 0]]]]);

buffer(multiPt, 5);
buffer(multiLine, 5);
buffer(multiPoly, 5);

// Collections
const fc = featureCollection([pt, line]);
const gc = geometryCollection([pt.geometry, line.geometry]);
Esempio n. 2
0
import {lineString} from '@turf/helpers'
import centroid from './'

const line = lineString([[0, 0], [10, 10]]);

centroid(line)
centroid(line, {foo: 'bar'})
Esempio n. 3
0
    featureReduce,
    featureEach,
    coordAll,
    geomReduce,
    geomEach,
    flattenReduce,
    flattenEach,
    segmentReduce,
    segmentEach,
    lineReduce,
    lineEach
} from './'

// Fixtures
const pt = helpers.point([0, 0])
const line = helpers.lineString([[0, 0], [1, 1]])
const poly = helpers.polygon([[[0, 0], [1, 1], [0, 1], [0, 0]]])
const multiPoly = helpers.multiPolygon([[[[0, 0], [1, 1], [0, 1], [0, 0]]]])
const multiLine = helpers.multiLineString([[[0, 0], [1, 1], [0, 1], [0, 0]], [[2, 2], [3, 3]]])
const geomCollection = helpers.geometryCollection([pt.geometry, line.geometry])
const features = helpers.featureCollection<Point|LineString>([pt, line])

const customPoint = point([10, 20], {foo: 'abc', bar: 123})
const customPoints = featureCollection([customPoint])
const customLineString = lineString([[0, 0], [10, 20]], {foo: 'abc', bar: 123})
const customLineStrings = featureCollection([customLineString])

/**
 * meta.coordEach
 */
const coordEachValue: void = meta.coordEach(pt, coords => coords)
Esempio n. 4
0
import {featureCollection, lineString, multiLineString, Polygon, MultiPolygon} from '@turf/helpers'
import * as polygonToLineString from '../'

// Fixtures
const coords = [[125, -30], [145, -30], [145, -20], [125, -20], [125, -30]];
const line = lineString(coords);
const multiLine = multiLineString([coords, coords]);

// Assert results with types
const poly1: Polygon = polygonToLineString(line);
const poly2: Polygon = polygonToLineString(multiLine);
const multiPoly: MultiPolygon = polygonToLineString(featureCollection([line, multiLine]));
Esempio n. 5
0
import {
    Geometry,
    Types,
    GeometryCollection,
    Point,
    LineString,
    Polygon,
    GeometryTypes,
    Position
} from '@turf/helpers'

/**
 * Fixtures
 */
const pt = helpers.point([0, 0])
const line = helpers.lineString([[0, 0], [1, 1]])
const poly = helpers.polygon([[[0, 0], [1, 1], [2, 2], [0, 0]]])
const gc = helpers.geometryCollection([pt.geometry, line.geometry, poly.geometry])
const fc = helpers.featureCollection([pt, line, poly])

/**
 * invariant.getGeom
 */
// invariant.getGeom(fc) // Argument of type 'FeatureCollection<any>' is not assignable to parameter of type
invariant.getGeom(gc)
// const gcGeom: GeometryCollection  = invariant.getGeom(gc) // => NOT SUPPORTED
const pointGeom: Point = invariant.getGeom(pt)
const lineGeom: LineString = invariant.getGeom(line)
const polyGeom: Polygon = invariant.getGeom(poly)
invariant.getGeom(pt.geometry)