當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript helpers.geometryCollection函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。