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


TypeScript helpers.point函数代码示例

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


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

示例1: point

import {point} from "@turf/helpers";
import linearc from "./";

const center = point([-75.343, 39.984]);
const bearing1 = 10;
const bearing2 = -30;
const radius = 5;
const steps = 10;
const units = "miles";

linearc(center, radius, bearing1, bearing2);
linearc(center, radius, bearing1, bearing2, {steps});
linearc(center, radius, bearing1, bearing2, {steps, units});
开发者ID:Turbo87,项目名称:turf,代码行数:13,代码来源:types.ts

示例2: featureCollection

import {point, featureCollection} from '@turf/helpers';
import tin from './';

const points = featureCollection([
  point([0, 0], {elevation: 20}),
  point([10, 10], {elevation: 10}),
  point([30, 30], {elevation: 50}),
])
tin(points)
tin(points, 'elevation')
开发者ID:OlympicsORG,项目名称:turf,代码行数:10,代码来源:types.ts

示例3: polygon

import { polygon, point } from '@turf/helpers'
import tangents from './'

const poly = polygon([[[11, 0], [22, 4], [31, 0], [31, 11], [21, 15], [11, 11], [11, 0]]])
const pt = point([61, 5])
tangents(pt, poly)
开发者ID:OlympicsORG,项目名称:turf,代码行数:6,代码来源:types.ts

示例4: switch

/**
 * Takes any {@link Feature} or a {@link FeatureCollection} and returns its [center of mass](https://en.wikipedia.org/wiki/Center_of_mass) using this formula: [Centroid of Polygon](https://en.wikipedia.org/wiki/Centroid#Centroid_of_polygon).
 *
 * @name centerOfMass
 * @param {GeoJSON} geojson GeoJSON to be centered
 * @param {Object} [options={}] Optional Parameters
 * @param {Object} [options.properties={}] Translate Properties to Feature
 * @returns {Feature<Point>} the center of mass
 * @example
 * var polygon = turf.polygon([[[-81, 41], [-88, 36], [-84, 31], [-80, 33], [-77, 39], [-81, 41]]]);
 *
 * var center = turf.centerOfMass(polygon);
 *
 * //addToMap
 * var addToMap = [polygon, center]
 */
function centerOfMass<P = Properties>(geojson: any, options: {
    properties?: P,
} = {}): Feature<Point, P> {
    switch (getType(geojson)) {
    case 'Point':
        return geojson;
    case 'Polygon':
        var coords = [];
        coordEach(geojson, function (coord) {
            coords.push(coord);
        });

        // First, we neutralize the feature (set it around coordinates [0,0]) to prevent rounding errors
        // We take any point to translate all the points around 0
        var centre = centroid(geojson, {properties: options.properties});
        var translation = centre.geometry.coordinates;
        var sx = 0;
        var sy = 0;
        var sArea = 0;
        var i, pi, pj, xi, xj, yi, yj, a;

        var neutralizedPoints = coords.map(function (point) {
            return [
                point[0] - translation[0],
                point[1] - translation[1]
            ];
        });

        for (i = 0; i < coords.length - 1; i++) {
            // pi is the current point
            pi = neutralizedPoints[i];
            xi = pi[0];
            yi = pi[1];

            // pj is the next point (pi+1)
            pj = neutralizedPoints[i + 1];
            xj = pj[0];
            yj = pj[1];

            // a is the common factor to compute the signed area and the final coordinates
            a = xi * yj - xj * yi;

            // sArea is the sum used to compute the signed area
            sArea += a;

            // sx and sy are the sums used to compute the final coordinates
            sx += (xi + xj) * a;
            sy += (yi + yj) * a;
        }

        // Shape has no area: fallback on turf.centroid
        if (sArea === 0) {
            return centre;
        } else {
            // Compute the signed area, and factorize 1/6A
            var area = sArea * 0.5;
            var areaFactor = 1 / (6 * area);

            // Compute the final coordinates, adding back the values that have been neutralized
            return point([
                translation[0] + areaFactor * sx,
                translation[1] + areaFactor * sy
            ], options.properties);
        }
    default:
        // Not a polygon: Compute the convex hull and work with that
        var hull = convex(geojson);

        if (hull) return centerOfMass(hull, {properties: options.properties});
        // Hull is empty: fallback on the centroid
        else return centroid(geojson, {properties: options.properties});
    }
}
开发者ID:antonsimola,项目名称:turf,代码行数:89,代码来源:index.ts

示例5: point

import {point, featureCollection} from '@turf/helpers'
import nearestPoint from './'

const targetPoint = point([28.965797, 41.010086], {"marker-color": "#0F0"});
const points = featureCollection([
    point([28.973865, 41.011122]),
    point([28.948459, 41.024204]),
    point([28.938674, 41.013324])
]);
const nearest = nearestPoint(targetPoint, points);
nearest.properties.distanceToPoint;
nearest.properties.featureIndex;
开发者ID:OlympicsORG,项目名称:turf,代码行数:12,代码来源:types.ts

示例6: featureCollection

import {featureCollection, point} from '@turf/helpers'
import {getCluster, clusterEach, clusterReduce} from './'

/**
 * Fixtures
 */
const geojson = featureCollection([
    point([0, 0], {cluster: 0}),
    point([2, 4], {cluster: 1}),
    point([3, 6], {cluster: 1}),
    point([3, 6], {0: 'foo'}),
    point([3, 6], {'bar': 'foo'})
]);

/**
 * Get Cluster
 */
getCluster(geojson, {cluster: 1});
getCluster(geojson, {0: 'foo'});
getCluster(geojson, {'bar': 'foo'});
getCluster(geojson, 'cluster');
getCluster(geojson, ['cluster', 'bar']);
getCluster(geojson, 0);

/**
 * ClusterEach
 */
clusterEach(geojson, 'cluster', (cluster, clusterValue, currentIndex) => {
    //= cluster
    //= clusterValue
    //= currentIndex
开发者ID:z0630,项目名称:turf,代码行数:31,代码来源:types.ts

示例7: point

import {point, polygon} from '@turf/helpers';
import * as planepoint from './';

const pt = point([1, 1]);
const triangle = polygon([[[0, 0, 0], [2, 0, 0], [1, 2, 2], [0, 0, 0]]]);

planepoint(pt, triangle);
planepoint(pt.geometry.coordinates, triangle);
planepoint(pt.geometry, triangle.geometry);
开发者ID:z0630,项目名称:turf,代码行数:9,代码来源:types.ts

示例8: polygon

import {point, polygon} from '@turf/helpers'
import * as inside from './'

const poly = polygon([[[0, 0], [0, 100], [100, 100], [100, 0], [0, 0]]]);
const pt = point([50, 50]);
inside(pt, poly);
开发者ID:z0630,项目名称:turf,代码行数:6,代码来源:types.ts


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