本文整理汇总了TypeScript中@turf/helpers.lineString函数的典型用法代码示例。如果您正苦于以下问题:TypeScript lineString函数的具体用法?TypeScript lineString怎么用?TypeScript lineString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了lineString函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: point
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]);
示例2: lineString
import {lineString} from '@turf/helpers'
import centroid from './'
const line = lineString([[0, 0], [10, 10]]);
centroid(line)
centroid(line, {foo: 'bar'})
示例3: point
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)
示例4: lineString
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]));
示例5:
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)