本文整理汇总了TypeScript中@turf/turf.featureCollection函数的典型用法代码示例。如果您正苦于以下问题:TypeScript featureCollection函数的具体用法?TypeScript featureCollection怎么用?TypeScript featureCollection使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了featureCollection函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: reader
import * as turf from '@turf/turf'
import {writer, reader} from 'geojson-writer'
const collection = turf.featureCollection([])
const data = reader('ottawa-address.geojson')
data.features.map(feature => {
feature.properties.source = 'City of Ottawa'
if (feature.properties['survey:date']) { delete feature.properties['survey:date'] }
collection.features.push(feature)
})
console.log('writing', collection.features.length)
writer('ottawa-address-clean.geojson', collection)
开发者ID:osmottawa,项目名称:imports,代码行数:14,代码来源:clean-address-geojson.ts
示例2:
// -- Test kinks --
turf.kinks(polygon1)
// -- Test lineSlice --
turf.lineSlice(point1, point2, lineString1)
// -- Test pointOnLine --
turf.pointOnLine(lineString1, point1)
///////////////////////////////////////////
// Tests Helper
///////////////////////////////////////////
// -- Test featurecollection --
turf.featureCollection([point1, point2])
turf.featureCollection([point1, polygon1])
turf.featureCollection([polygon1, polygon2])
turf.featureCollection([lineString1, polygon1])
turf.featureCollection([lineString1, point1])
// -- Test feature --
turf.feature(point1)
turf.feature(polygon1)
turf.feature(lineString1)
// -- Test lineString --
turf.lineString(lineString1.geometry.coordinates)
turf.lineString(lineString1.geometry.coordinates, properties)
// -- Test multiLineString --
开发者ID:ArtemZag,项目名称:DefinitelyTyped,代码行数:30,代码来源:turf-tests.ts
示例3: require
import * as fs from 'fs'
import * as changeCase from 'change-case'
import * as path from 'path'
import { isUndefined } from 'lodash'
import { featureCollection, lineString } from '@turf/turf'
const features: GeoJSON.FeatureCollection<GeoJSON.MultiLineString> = require(path.join(__dirname, 'source', 'lake-county-roads.json'))
const results: GeoJSON.FeatureCollection<GeoJSON.LineString> = featureCollection([])
const suffixLookup: any = require('./suffix.json')
const directionsLookup: any = require('./directions.json')
features.features.map(feature => {
feature.geometry.coordinates.map(coords => {
const name = changeCase.title(feature.properties['BaseStreet'])
const suffix = suffixLookup[feature.properties['SuffixType']]
const direction = directionsLookup[feature.properties['PrefixDire']]
const ref = feature.properties['SegID']
const properties: any = {
source: 'Lake County',
highway: 'residential',
maxspeed: feature.properties['SpeedLimit'] ? `${ feature.properties['SpeedLimit'] } mph` : undefined,
name: [name, suffix, direction].join(' ').trim()
}
if (ref) {
properties.ref = ref
properties['source:ref'] = 'Lake County'
}
results.features.push(lineString(coords, properties))
})
})
开发者ID:osmottawa,项目名称:imports,代码行数:30,代码来源:parse-data.ts
示例4: parseRef
import * as fs from 'fs'
import * as path from 'path'
import * as Baby from 'babyparse'
import * as turf from '@turf/turf'
import * as yml from 'js-yaml'
import { range, capitalize, keys } from 'lodash'
const parsed = Baby.parseFiles(path.join(__dirname, 'gtfs', 'stops.txt'))
const headers = parsed.data.shift()
const features: GeoJSON.FeatureCollection<GeoJSON.Point> = turf.featureCollection([])
const data: string[][] = parsed.data
function parseRef(ref: string) {
if (ref) {
if (ref.length === 4) { return ref }
else if (ref.length === 3) {
//console.log('WARNING - Padded reference number', ref)
return `0${ ref }`
}
}
}
function parseName(name: string) {
if (name) {
const words: string[] = []
name.split(/[ ]+/g).map(word => {
word = word.replace(/DR\./, 'Drive')
word = word.replace(/ST\./, 'Street')
word = word.replace(/RD\./, 'Road')
word = word.replace(/W\./, 'West')
word = word.replace(/\\/g, '/')
开发者ID:osmottawa,项目名称:imports,代码行数:31,代码来源:get-data.ts
示例5: require
import { geojson2osm } from 'geojson2osm'
import { merge } from 'lodash'
import * as fs from 'fs'
import * as path from 'path'
import * as turf from '@turf/turf'
// Load source dataset
const source: GeoJSON.FeatureCollection<GeoJSON.Point> = require(path.join(__dirname, 'oc-transpo-stops.json'))
// Load overpass data using GeoJSON & print results using `out meta`
// http://overpass-turbo.eu/s/iuT
const overpass: GeoJSON.FeatureCollection<GeoJSON.Point> = require(path.join(__dirname, 'oc-transpo-stops-overpass.json'))
// Set up index of source dataset
const index: any = {}
source.features.map(feature => index[feature.properties.ref] = feature.properties)
// Merge existing data with new data
const container: GeoJSON.FeatureCollection<GeoJSON.Point> = turf.featureCollection([])
overpass.features.map(feature => {
feature.properties = merge(feature.properties, index[feature.properties.ref])
feature.properties['@action'] = 'modify'
feature.properties['@id'] = feature.properties['@id'].replace(/node\//, '') // Remove extra ID syntax created by Overpass
delete feature.properties['@timestamp'] // Breaks geojson2osm
container.features.push(feature)
})
// Save OSM File
fs.writeFileSync(path.join(__dirname, 'oc-transpo-stops-gtfs.osm'), geojson2osm(container))
开发者ID:osmottawa,项目名称:imports,代码行数:29,代码来源:merge-gtfs.ts
示例6: 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
示例7: 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
示例8: reader
const data: GeoJSON.FeatureCollection<GeoJSON.Polygon> = reader('ottawa-parcels.geojson')
let count = 0
console.log('start')
for (let feature of data.features) {
const road: string = feature.properties['ROAD_NAME']
const suffix: string = feature.properties['SUFFIX']
const street = (road && suffix) ? road + ' ' + suffix : road
const housenumber = feature.properties['ADDRESS_NU']
feature.properties = {
'addr:housenumber': housenumber,
'addr:street': street,
ref: feature.properties['PI_PARCEL_'],
source: 'City of Ottawa'
}
const unique: any = {}
meta.coordEach(feature, coord => unique[coord.join(',')] = true)
if (Object.keys(unique).length > 2) {
feature = turf.simplify(feature, 0.000001, true)
collection.push(feature)
}
count ++
if (count % 1000 === 0) { console.log('processed', count, feature.geometry.coordinates[0].length) }
}
console.log('writting')
writer('ottawa-parcels-simplify.geojson', turf.featureCollection(collection))
开发者ID:osmottawa,项目名称:imports,代码行数:30,代码来源:clean-parcels-geojson.ts
注:本文中的@turf/turf.featureCollection函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论