本文整理汇总了TypeScript中@turf/helpers.geometryCollection函数的典型用法代码示例。如果您正苦于以下问题:TypeScript geometryCollection函数的具体用法?TypeScript geometryCollection怎么用?TypeScript geometryCollection使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了geometryCollection函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: polygonDissolve
/**
* Dissolves all overlapping (Multi)Polygon
*
* @param {FeatureCollection<Polygon|MultiPolygon>} geojson Polygons to dissolve
* @param {Object} [options={}] Optional parameters
* @param {boolean} [options.mutate=false] Prevent input mutation
* @returns {Feature<Polygon|MultiPolygon>} Dissolved Polygons
*/
export default function polygonDissolve(
geojson: FeatureCollection<Polygon|MultiPolygon>,
options: {mutate?: boolean} = {},
): Feature<Polygon|MultiPolygon> | null {
// Validation
if (getType(geojson) !== "FeatureCollection") { throw new Error("geojson must be a FeatureCollection"); }
if (!geojson.features.length) { throw new Error("geojson is empty"); }
// Clone geojson to avoid side effects
// Topojson modifies in place, so we need to deep clone first
if (options.mutate === false || options.mutate === undefined) { geojson = clone(geojson); }
const geoms: any[] = [];
flattenEach(geojson, (feature) => {
geoms.push(feature.geometry);
});
const topo: any = topology({geoms: geometryCollection(geoms).geometry});
const merged: any = merge(topo, topo.objects.geoms.geometries);
return merged;
}
开发者ID:Turbo87,项目名称:turf,代码行数:28,代码来源:turf-polygon-dissolve.ts
示例2:
GeometryTypes,
LineString,
Point,
Polygon,
Position,
Types,
} from "@turf/helpers";
import * as invariant from "./";
/**
* Fixtures
*/
const pt = helpers.point([0, 0]);
const line = helpers.lineString([[0, 0], [1, 1]]);
const poly = helpers.polygon([[[0, 0], [1, 1], [2, 2], [0, 0]]]);
const gc = helpers.geometryCollection([pt.geometry, line.geometry, poly.geometry]);
const fc = helpers.featureCollection<Point|LineString|Polygon>([pt, line, poly]);
/**
* invariant.getGeom
*/
// invariant.getGeom(fc); // Argument of type 'FeatureCollection<any>' is not assignable to parameter of type
const gcGeom: GeometryCollection = invariant.getGeom(gc);
const pointGeom: Point = invariant.getGeom(pt);
const lineGeom: LineString = invariant.getGeom(line);
const polyGeom: Polygon = invariant.getGeom(poly);
/**
* invariant.getType
*/
const type = invariant.getType(pt);
开发者ID:Turbo87,项目名称:turf,代码行数:31,代码来源:types.ts
示例3: point
import { polygon, point, 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<Polygon|Point>([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});
开发者ID:Turbo87,项目名称:turf,代码行数:22,代码来源:types.ts
示例4: point
import {polygon, point, featureCollection, geometryCollection} from '@turf/helpers';
import * as 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: GeoJSON.Feature<GeoJSON.Polygon> = rotate(poly, 100, pt);
const rotatedFCPoly: GeoJSON.FeatureCollection<GeoJSON.Polygon> = rotate(featureCollection([poly]), 100, pt);
// Different Geometry Inputs
rotate(poly, 100, pt);
rotate(poly, 100, pt.geometry);
rotate(poly.geometry, 100, pt.geometry.coordinates);
rotate(featureCollection([poly]), 100, pt.geometry);
rotate(featureCollection([poly, pt]), 100, pt);
rotate(geometryCollection([poly.geometry]).geometry, 100, pt.geometry);
rotate(geometryCollection([poly.geometry]), 100, pt.geometry);
rotate(geometryCollection([poly.geometry, pt.geometry]), 100, pt);
// Allow mutating
rotate(poly, 100, pt, true);
开发者ID:z0630,项目名称:turf,代码行数:22,代码来源:types.ts
示例5: lineString
const line = lineString([[100, 0], [50, 0]]);
const poly = polygon([[[100, 0], [50, 0], [0, 50], [100, 0]]]);
buffer(pt, 5);
buffer(line, 5);
buffer(poly, 5);
buffer(pt, 5, {units: 'miles'});
buffer(pt, 10, {units: 'meters', steps: 64});
// Multi Geometry
const multiPt = multiPoint([[100, 0], [0, 100]]);
const multiLine = multiLineString([[[100, 0], [50, 0]], [[100, 0], [50, 0]]]);
const multiPoly = multiPolygon([[[[100, 0], [50, 0], [0, 50], [100, 0]]], [[[100, 0], [50, 0], [0, 50], [100, 0]]]]);
buffer(multiPt, 5);
buffer(multiLine, 5);
buffer(multiPoly, 5);
// Collections
const fc = featureCollection<Point|LineString>([pt, line]);
const gc = geometryCollection([pt.geometry, line.geometry]);
buffer(fc, 5);
buffer(gc, 5);
// Mixed Collections
const fcMixed = featureCollection<any>([pt, line, multiPt, multiLine]);
const gcMixed = geometryCollection([pt.geometry, line.geometry, multiPt.geometry, multiLine.geometry]);
buffer(fcMixed, 5);
buffer(gcMixed, 5);
开发者ID:Turbo87,项目名称:turf,代码行数:31,代码来源:types.ts
示例6: point
import {featureCollection, point, lineString, geometryCollection} from '@turf/helpers'
import flip from './'
const pt = point([120.1234567, 40.1234567])
const ptGeom = pt.geometry
const line = lineString([[20,80], [50, 40]])
const lineGeom = line.geometry
const points = featureCollection([pt])
const lines = featureCollection([line])
const geomCollection = geometryCollection([ptGeom, lineGeom])
flip(pt)
flip(ptGeom)
flip(line)
flip(lineGeom)
flip(lines)
flip(points)
flip(geomCollection, {mutate: true})
开发者ID:OlympicsORG,项目名称:turf,代码行数:18,代码来源:types.ts
示例7: point
import {
point, lineString, polygon,
multiPoint, multiLineString, multiPolygon,
featureCollection, geometryCollection} from '@turf/helpers'
import * as meta from '../index'
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
开发者ID:dpmcmlxxvi,项目名称:turf,代码行数:31,代码来源:types.ts
示例8: featureCollection
import {
geometryCollection,
featureCollection,
point,
lineString,
Point
} from '@turf/helpers'
import nearestPointToLine from './'
const points = featureCollection([point([0, 0]), point([0.5, 0.5])]);
const line = lineString([[1,1], [-1,1]]);
const nearest = nearestPointToLine<{foo: string, dist: number}>(points, line, {properties: {foo: 'bar'}})
nearest.properties.foo
nearest.properties.dist
// nearest.properties.bar // [ts] Property 'bar' does not exist on type '{ dist?: number; foo: string; }'.
// GeometryCollection
const geomPoints = geometryCollection([point([0, 0]).geometry, point([0.5, 0.5]).geometry]);
nearestPointToLine(geomPoints, line)
开发者ID:Turbo87,项目名称:turf,代码行数:20,代码来源:types.ts
示例9: multiPoint
import {multiPoint, multiLineString, geometryCollection} from '@turf/helpers'
import * as flatten from './'
const multiPt = multiPoint([[0, 0], [10, 10]])
const multiLine = multiLineString([[[20, 20], [30, 30]], [[0, 0], [10, 10]]])
flatten(multiPt);
flatten(multiLine);
flatten(multiPt.geometry);
flatten(multiLine.geometry);
flatten(geometryCollection([multiPt.geometry, multiLine.geometry]));
开发者ID:z0630,项目名称:turf,代码行数:11,代码来源:types.ts
注:本文中的@turf/helpers.geometryCollection函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论