当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript turf.simplify函数代码示例

本文整理汇总了TypeScript中@turf/turf.simplify函数的典型用法代码示例。如果您正苦于以下问题:TypeScript simplify函数的具体用法?TypeScript simplify怎么用?TypeScript simplify使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了simplify函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: Number

  feature.properties = {
    building: 'yes',
    source: 'City of Ottawa',
  }
  const uniqueOuter: any = {}
  const uniqueInner: any = {}

  feature.geometry.coordinates[0].map(coord => uniqueOuter[coord.map(x => Number(x.toFixed(5))).join(',')] = true)
  if (feature.geometry.coordinates[1]) { feature.geometry.coordinates[1].map(coord => uniqueInner[coord.map(x => Number(x.toFixed(5))).join(',')] = true) }

  if (count % 1000 === 0) { console.log('processed', count, Object.keys(uniqueOuter).length, Object.keys(uniqueInner).length) }

  // Remove Inner Polygon
  if (Object.keys(uniqueInner).length === 2 || Object.keys(uniqueInner).length === 1) {
    console.log('remove inner polygon', JSON.stringify(feature, null))
    fs.writeFileSync('last-issue.geojson', JSON.stringify(feature, null, 2))
    feature.geometry.coordinates = feature.geometry.coordinates.slice(0, 1)
  }

  // Don't simplify two vertices
  if (Object.keys(uniqueOuter).length > 2) {
    feature = turf.simplify(feature, 0.000001, true)
    collection.push(feature)
  }
  count ++
}

console.log('Total:', count, collection.length)
console.log('writting')
writer('ottawa-buildings-clean.geojson', turf.featureCollection(collection))
开发者ID:osmottawa,项目名称:imports,代码行数:30,代码来源:clean-building-geojson.ts

示例2:

turf.convex(points)

// -- Test difference --
turf.difference(polygon1, polygon2)

// -- Test intersect --
turf.intersect(polygon1, polygon2)
turf.intersect(point1, polygon1)
turf.intersect(point1, point1)
turf.intersect(polygon1, point1)
turf.intersect(polygon1, lineString1)
turf.intersect(lineString1, point1)

// -- Test simplify --

turf.simplify(polygon1, 0.01, false)

// -- Test union --
turf.union(polygon1, polygon2)

///////////////////////////////////////////
// Tests Misc
///////////////////////////////////////////

// -- Test combine --
turf.combine(points)

// -- Test explode --
turf.explode(polygon1)

// -- Test flip --
开发者ID:ArtemZag,项目名称:DefinitelyTyped,代码行数:31,代码来源:turf-tests.ts

示例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]))
开发者ID:osmottawa,项目名称:imports,代码行数:18,代码来源:create-extent.ts


注:本文中的@turf/turf.simplify函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。