How to use the @turf/turf.point function in @turf/turf

To help you get started, we’ve selected a few @turf/turf 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 Liquid-Zhangliquan / ycyfans-map / src / components / cymap / SzBuilding / index.jsx View on Github external
const segments = mapArray(item.segments, segment => {
            length += (distance(last, point(segment), { units: 'kilometers' }) * 10);
            const coord = [
              segment[0],
              segment[1],
              length,
            ];
            last = point(segment);
            return coord;
          });
          // maxLength = Math.max(maxLength, length);
github syousif94 / frugalmaps / functions / getEvents.js View on Github external
.then(results => {
        if (!results.hits.hits.length) {
          return results.hits.hits;
        }

        const points = results.hits.hits.map(doc =>
          turf.point(doc._source.coordinates)
        );

        if (lat && lng && !bounds) {
          points.push(turf.point([lng, lat]));
        }

        // create a bounding box for the results
        const envelope = turf.bbox(
          turf.buffer(turf.envelope(turf.featureCollection(points)), 0.5, {
            units: "miles"
          })
        );

        bounds = {
          southwest: {
            lat: envelope[1],
            lng: envelope[0]
          },
          northeast: {
            lat: envelope[3],
github open-apparel-registry / open-apparel-registry / src / app / src / components / Map.jsx View on Github external
findNearestPoint = (targetFeature, allFeatures) => {
        if (
            !targetFeature ||
            !targetFeature.geometry ||
            !targetFeature.geometry.coordinates
        ) {
            return;
        }
        const targetPoint = turf.point(targetFeature.geometry.coordinates);
        const uniqueFeatues = allFeatures.filter(a =>
            a.geometry.coordinates[0] !==
                    targetFeature.geometry.coordinates[0] &&
                a.geometry.coordinates[1] !==
                    targetFeature.geometry.coordinates[1]);

        const allPoints = uniqueFeatues.map(f =>
            turf.point(f.geometry.coordinates));
        const points = turf.featureCollection(allPoints);
        const nearest = turf.nearestPoint(targetPoint, points);
        if (!nearest) {
            return;
        }
        const nearestFeature = uniqueFeatues[nearest.properties.featureIndex];
        return [targetFeature, nearestFeature]; // eslint-disable-line consistent-return
    };
github osmlab / osmlint / validators / mixedLayer / map.js View on Github external
overlapHighway.properties['@id'] &&
          highwayToEvaluate.properties.layer !==
            overlapHighway.properties.layer &&
          overlapHighway.geometry.coordinates.length > 2
        ) {
          var coordOverlaphighway = overlapHighway.geometry.coordinates;
          coordOverlaphighway.splice(coordOverlaphighway.length - 1, 1);
          coordOverlaphighway.splice(0, 1);
          var coordIntersection = [];
          for (var z = 0; z < coordOverlaphighway.length; z++) {
            if (objHighwayToEvaluate[coordOverlaphighway[z].join('-')]) {
              coordIntersection = coordOverlaphighway[z];
            }
          }
          if (coordIntersection.length > 0) {
            var intersectionPoint = turf.point(coordIntersection);
            var props = {
              _fromWay: highwayToEvaluate.properties['@id'],
              _toWay: overlapHighway.properties['@id'],
              _osmlint: osmlint,
              _type: classification(
                majorRoads,
                minorRoads,
                pathRoads,
                highwayToEvaluate.properties.highway,
                overlapHighway.properties.highway
              )
            };
            //Add osmlint properties
            intersectionPoint.properties = props;
            highwayToEvaluate.properties._osmlint = osmlint;
            overlapHighway.properties._osmlint = osmlint;
github osmlab / osmlint / validators / unclosedWays / map.js View on Github external
preserveType.man_made[val.properties.man_made];

    if (
      val.geometry.type === 'LineString' &&
      valueType &&
      !(
        val.properties.source &&
        val.properties.source.indexOf(preventSource[val.properties.source]) < 0
      )
    ) {
      var coordinates = val.geometry.coordinates;
      var firstCoord = coordinates[0];
      var lastCoord = coordinates[coordinates.length - 1];
      if (
        turf.inside(turf.point(firstCoord), buffer) ||
        turf.inside(turf.point(lastCoord), buffer)
      ) {
        return false;
      }
      return true;
    }
  });
github nasa-gibs / worldview / web / js / map / measure / util.js View on Github external
transformedLine.forEachSegment((segStart, segEnd) => {
    const p1 = TurfPoint(segStart);
    const p2 = TurfPoint(segEnd);
    distance += TurfRhumbDistance(p1, p2);
  });
  return distance * metersPerKilometer;
github osmlab / osmlint / validators / impossibleOneWays / map.js View on Github external
bboxes.push(itemL);
      }
      highways[idWayL] = val;
    } else if (
      val.geometry.type === 'MultiLineString' &&
      val.properties.highway
    ) {
      //MultiLineString evaluation
      var arrayWays = flatten(val);
      for (var f = 0; f < arrayWays.length; f++) {
        if (arrayWays[f].geometry.type === 'LineString') {
          var coordsWayM = arrayWays[f].geometry.coordinates;
          var isClippedM = false;
          if (
            turf.booleanPointInPolygon(
              turf.point(coordsWayM[0]),
              bufferLayer
            ) ||
            turf.booleanPointInPolygon(
              turf.point(coordsWayM[coordsWayM.length - 1]),
              bufferLayer
            )
          ) {
            isClippedM = true;
          }
          var idWayM = id + 'M' + f;
          for (var t = 0; t < coordsWayM.length; t++) {
            var positionM;
            if (t === 0) {
              positionM = 'first';
            } else if (t === coordsWayM.length - 1) {
              positionM = 'end';