本文整理匯總了TypeScript中@turf/turf.point函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript point函數的具體用法?TypeScript point怎麽用?TypeScript point使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了point函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1:
r.features.map(feature => {
const attributes = {
source: 'City of Ottawa'
}
const point = turf.point([feature.geometry.x, feature.geometry.y], feature.attributes)
if (!first) {
writer.write(` ${ JSON.stringify(point)}`)
first = true
} else writer.write(`,\n ${ JSON.stringify(point)}`)
})
示例2: parseFloat
data.map(items => {
const properties: any = {}
let column = 0
items.map(item => {
if (item) properties[headers[column]] = item
column ++
})
if (properties) {
// Handle OSM properties
const lat = parseFloat(properties['stop_lat'])
const lng = parseFloat(properties['stop_lon'])
const name = parseName(properties['stop_name'])
const osm: any = {
name,
operator: 'OC Transpo',
source: 'City of Ottawa',
public_transport: 'platform',
highway: 'bus_stop',
bus: 'yes',
stop_id: properties['stop_id'],
'source:stop_id': 'gtfs'
}
// Handle Ref
const ref = parseRef(properties['stop_code'])
if (ref) {
osm.ref = ref
osm['source:ref'] = 'OC Transpo'
} else {
osm.fixme = 'No reference number'
console.log('WARNING - No Reference number:', osm.name)
}
// Add Feature
const feature = turf.point([lng, lat], osm)
if (lat & lng) features.features.push(feature)
}
})
示例3:
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 --
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]);
///////////////////////////////////////////