本文整理匯總了TypeScript中@turf/helpers.polygon函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript polygon函數的具體用法?TypeScript polygon怎麽用?TypeScript polygon使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了polygon函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: point
import { polygon, point, featureCollection, geometryCollection, Feature, Polygon, FeatureCollection } from '@turf/helpers';
import rotate from './'
const pt = point([15, 15]);
const poly = polygon([[[0,29],[3.5,29],[2.5,32],[0,29]]]);
// Does not mutate Geometry type
const rotatedPoly: Feature<Polygon> = rotate(poly, 100, {pivot: pt});
const rotatedFCPoly: FeatureCollection<Polygon> = rotate(featureCollection([poly]), 100, {pivot: pt});
// Different Geometry Inputs
rotate(poly, 100, {pivot: pt});
rotate(poly, 100, {pivot: pt.geometry});
rotate(poly.geometry, 100, {pivot: pt.geometry.coordinates});
rotate(featureCollection([poly]), 100, {pivot: pt.geometry});
rotate(featureCollection([poly, pt]), 100, {pivot: pt});
rotate(geometryCollection([poly.geometry]).geometry, 100, {pivot: pt.geometry});
rotate(geometryCollection([poly.geometry]), 100, {pivot: pt.geometry});
rotate(geometryCollection([poly.geometry, pt.geometry]), 100, {pivot: pt});
// Allow mutating
rotate(poly, 100, {pivot: pt, mutate: true});
示例2: polygon
import { BBox, polygon, Polygon} from '@turf/helpers';
import pointGrid from './';
const cellSide = 50;
const bbox: BBox = [-95, 30, -85, 40];
const poly = polygon([[[20, 30], [10, 10], [20, 20], [20, 30]]]);
pointGrid(bbox, cellSide);
pointGrid(bbox, cellSide, {units: 'miles'});
pointGrid(bbox, cellSide, {units: 'miles', mask: poly});
pointGrid(bbox, cellSide, {units: 'miles', mask: poly, properties: {foo: 'bar'}});
示例3: polygon
import * as tangents from '../'
import {polygon, point} from '@turf/helpers'
const poly = polygon([[[11, 0], [22, 4], [31, 0], [31, 11], [21, 15], [11, 11], [11, 0]]])
const pt = point([61, 5])
tangents(pt, poly)
示例4: points
import pointsWithinPolygon from './'
import { points, polygon } from '@turf/helpers'
const pts = points([
[-46.6318, -23.5523],
[-46.6246, -23.5325],
[-46.6062, -23.5513],
[-46.663, -23.554],
[-46.643, -23.557]
]);
const searchWithin = polygon([[
[-46.653,-23.543],
[-46.634,-23.5346],
[-46.613,-23.543],
[-46.614,-23.559],
[-46.631,-23.567],
[-46.653,-23.560],
[-46.653,-23.543]
]]);
const ptsWithin = pointsWithinPolygon(pts, searchWithin);
示例5: polygon
import {polygon, lineString, multiLineString, multiPolygon} from '@turf/helpers'
import * as 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)
示例6: point
import {
point, lineString, polygon,
multiPoint, multiLineString, multiPolygon,
featureCollection, geometryCollection} from '@turf/helpers'
import * as meta from './'
const pt = point([0, 0])
const line = lineString([[0, 0], [1, 1]])
const poly = polygon([[[0, 0], [1, 1], [0, 1], [0, 0]]])
const multiPoly = multiPolygon([[[[0, 0], [1, 1], [0, 1], [0, 0]]]])
const geomCollection = geometryCollection([pt.geometry, line.geometry])
const features = featureCollection([pt, line])
// coordEach
meta.coordEach(pt, coords => coords)
meta.coordEach(pt, (coords, index) => coords)
meta.coordEach(pt.geometry, coords => { const equal: number[] = coords })
meta.coordEach(line, coords => { const equal: number[] = coords })
meta.coordEach(poly, coords => { const equal: number[] = coords })
meta.coordEach(multiPoly, coords => { const equal: number[] = coords })
meta.coordEach(geomCollection, coords => coords)
// coordReduce
meta.coordReduce(pt, (previous, coords) => coords)
meta.coordReduce(pt, (previous, coords, index) => coords)
meta.coordReduce(pt, (previous, coords, index) => coords, 0)
meta.coordReduce(pt, (previous, coords) => { const equal: Array<number> = coords })
meta.coordReduce(geomCollection, (previous, coords) => coords)
interface CustomProps {
foo: string
示例7: polygon
import {point, polygon} from '@turf/helpers'
import * as inside from '../'
const poly = polygon([[[0, 0], [0, 100], [100, 100], [100, 0], [0, 0]]]);
const pt = point([50, 50]);
inside(pt, poly);
示例8: point
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)
coordEach(pt, (coords, index) => coords)