本文整理汇总了TypeScript中@turf/turf.polygon函数的典型用法代码示例。如果您正苦于以下问题:TypeScript polygon函数的具体用法?TypeScript polygon怎么用?TypeScript polygon使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了polygon函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
results.features.map(feature => {
const attributes = {
building: 'yes',
source: 'City of Ottawa'
}
const poly = turf.polygon(feature.geometry.rings, attributes)
if (!first) {
writer.write(` ${ JSON.stringify(poly)}`)
first = true
} else writer.write(`,\n ${ JSON.stringify(poly)}`)
})
示例2:
// -- Test lineString --
turf.lineString(lineString1.geometry.coordinates)
turf.lineString(lineString1.geometry.coordinates, properties)
// -- Test multiLineString --
turf.multiLineString(multiLineString1.geometry.coordinates)
// -- Test point --
turf.point(point1.geometry.coordinates)
turf.point(point1.geometry.coordinates, properties)
// -- Test multiPoint --
turf.multiPoint(multiPoint1.geometry.coordinates)
// -- Test polygon --
turf.polygon(polygon1.geometry.coordinates, properties)
// -- Test multiPolygon --
turf.multiPolygon(multiPolygon1.geometry.coordinates, properties)
// -- Test geometryCollection --
turf.geometryCollection([point1.geometry, lineString1.geometry]);
///////////////////////////////////////////
// Tests Data
///////////////////////////////////////////
// -- Test random --
turf.random('points', 100)
turf.random('points', 100, { bbox })
turf.random('polygons', 100, {
示例3: require
import * as concaveman from 'concaveman'
import * as helpers from 'geojson-helpers'
import * as turf from '@turf/turf'
const data = './halifax-buildings.json'
const geojson: GeoJSON.FeatureCollection<any> = require(data)
const points: Array<Array<number>> = []
geojson.features.map(feature => {
turf.explode(feature).features.map(point => {
points.push(point.geometry.coordinates)
})
})
const extent = turf.polygon([concaveman(points)])
const buffer = turf.buffer(extent, 500, 'meters')
const simple: any = turf.simplify(buffer, 0.001, false)
helpers.writeFileSync('./extent.geojson', turf.featureCollection([extent]))
helpers.writeFileSync('./buffer.geojson', turf.featureCollection([buffer]))
helpers.writeFileSync('./simple.geojson', turf.featureCollection([simple]))