How to use the @turf/circle function in @turf/circle

To help you get started, we’ve selected a few @turf/circle examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github uber / nebula.gl / modules / layers / src / mode-handlers / draw-circle-from-center-handler.js View on Github external
return result;
    }

    const modeConfig = this.getModeConfig() || {};
    // Default turf value for circle is 64
    const { steps = 64 } = modeConfig;
    const options = { steps };

    if (steps < 4) {
      console.warn(`Minimum steps to draw a circle is 4 `); // eslint-disable-line no-console,no-undef
      options.steps = 4;
    }

    const centerCoordinates = clickSequence[0];
    const radius = Math.max(distance(centerCoordinates, event.groundCoords), 0.001);
    this._setTentativeFeature(circle(centerCoordinates, radius, options));

    return result;
  }
}
github uber / nebula.gl / modules / core / src / lib / editable-feature-collection.js View on Github external
_handlePointerMoveForDrawCircleByBoundingBox(groundCoords: Position) {
    if (this._clickSequence.length === 0) {
      // nothing to do yet
      return;
    }

    const firstClickedPoint = this._clickSequence[0];
    const centerCoordinates = getIntermediatePosition(firstClickedPoint, groundCoords);
    const radius = Math.max(distance(firstClickedPoint, centerCoordinates), 0.001);
    this._setTentativeFeature(circle(centerCoordinates, radius));
  }
github uber / nebula.gl / modules / core / src / lib / editable-feature-collection.js View on Github external
_handlePointerMoveForDrawCircleFromCenter(groundCoords: Position) {
    if (this._clickSequence.length === 0) {
      // nothing to do yet
      return;
    }

    const centerCoordinates = this._clickSequence[0];
    const radius = Math.max(distance(centerCoordinates, groundCoords), 0.001);
    this._setTentativeFeature(circle(centerCoordinates, radius));
  }
github terascope / teraslice / packages / xlucene-evaluator / src / document-matcher / logic-builder / geo.ts View on Github external
export function geoDistance(node: GeoDistance) {
    const {
        distance, unit, lat, lon
    } = node;
    const geoPoint = [lon, lat];
    const config = { units: unit };
    let polygon: createCircle;

    if (lat != null && lon != null) {
        polygon = createCircle(
            geoPoint,
            distance,
            config
        );
    }

    // Nothing matches so return false
    if (polygon == null) return () => false;
    return testGeoPolygon(polygon);
}
github Turfjs / turf / packages / turf-sector / index.js View on Github external
function sector(center, radius, bearing1, bearing2, options) {
    // Optional parameters
    options = options || {};
    if (!isObject(options)) throw new Error('options is invalid');

    // validation
    if (!center) throw new Error('center is required');
    if (bearing1 === undefined || bearing1 === null) throw new Error('bearing1 is required');
    if (bearing2 === undefined || bearing2 === null) throw new Error('bearing2 is required');
    if (!radius) throw new Error('radius is required');
    if (typeof options !== 'object') throw new Error('options must be an object');

    if (convertAngleTo360(bearing1) === convertAngleTo360(bearing2)) {
        return circle(center, radius, options);
    }
    var coords = getCoords(center);
    var arc = lineArc(center, radius, bearing1, bearing2, options);
    var sliceCoords = [[coords]];
    coordEach(arc, function (currentCoords) {
        sliceCoords[0].push(currentCoords);
    });
    sliceCoords[0].push(coords);

    return polygon(sliceCoords);
}
github terascope / teraslice / packages / xlucene-evaluator / src / document-matcher / type-manager / types / geo.ts View on Github external
pointTopLeft,
                        pointBottomRight,
                    ]);

                    const box = bbox(line);
                    polygon = bboxPolygon(box);
                }
            }

            if (geoPoint && geoDistance) {
                const { distance, unit } = parseGeoDistance(geoDistance);
                const config = { units: unit };

                const parsedGeoPoint = parseGeoPoint(geoPoint);
                if (parsedGeoPoint != null) {
                    polygon = createCircle(
                        parsedGeoPoint,
                        distance,
                        config
                    );
                }
            }

            // Nothing matches so return false
            if (polygon == null) return () => false;
            return (fieldData: string): boolean => {
                const point = parseGeoPoint(fieldData, false);
                if (!point) return false;
                return pointInPolygon(point, polygon);
            };
        }
github uber / nebula.gl / examples / advanced / example.js View on Github external
_loadSample = (type: string) => {
    if (type === 'mixed') {
      this.setState({
        testFeatures: sampleGeoJson,
        selectedFeatureIndexes: []
      });
    } else if (type === 'complex') {
      this.setState({
        testFeatures: {
          type: 'FeatureCollection',
          features: [
            circle([-122.45, 37.81], 4, { steps: 5000 }),
            circle([-122.33, 37.81], 4, { steps: 5000 }),
            circle([-122.45, 37.73], 4, { steps: 5000 }),
            circle([-122.33, 37.73], 4, { steps: 5000 })
          ]
        },
        selectedFeatureIndexes: []
      });
    } else if (type === 'blank') {
      this.setState({
        testFeatures: EMPTY_FEATURE_COLLECTION,
        selectedFeatureIndexes: []
      });
    } else if (type === 'file') {
      const el = document.createElement('input');
      el.type = 'file';
      el.onchange = e => {
        if (e.target.files && e.target.files[0]) {
          const reader = new FileReader();
          reader.onload = ({ target }) => {
github terascope / teraslice / packages / xlucene-evaluator / src / parser / functions / geo / helpers.ts View on Github external
export function makeCircle(point: GeoPoint, distance: number, config: any) {
    return createCircle(makeCoordinatesFromGeoPoint(point), distance, config);
}
github NYCPlanning / labs-zap-search / app / helpers / generate-circle-from-feet.js View on Github external
export function generateCircleFromFeet([point, radius]) {
  return circle(point, toMiles([radius]), { units: 'miles' });
}

@turf/circle

turf circle module

MIT
Latest version published 3 months ago

Package Health Score

96 / 100
Full package analysis