How to use the @turf/polygon-to-line.default function in @turf/polygon-to-line

To help you get started, we’ve selected a few @turf/polygon-to-line 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 ngageoint / geopackage-js / test / lib / features / user / testFeatureDao.js View on Github external
var distance = pointToLineDistance(centerPoint, geometry);
          if (distance < closestDistance) {
            closest = row;
            closestDistance = distance;
          } else if (distance == closestDistance && closest.type != 'Point') {
            closest = row;
            closestDistance = distance;
          }
        } else if (geometry.type == 'Polygon') {
          if (booleanPointInPolygon(centerPoint, geometry)) {
            if (closestDistance != 0) {
              closest = row;
              closestDistance = 0;
            }
          } else {
            var line = polygonToLine(geometry);
            var distance = pointToLineDistance(centerPoint, line);
            if (distance < closestDistance) {
              closest = row;
              closestDistance = distance;
            }
          }
        }
      }
      closest.values.name.should.be.equal('point');
      foundFeatures.should.be.deep.equal(['box1', 'box2', 'line', 'point']);
    });
github ngageoint / geopackage-js / test / lib / features / user / testFeatureDao.js View on Github external
var distance = pointToLineDistance(centerPoint, geometry);
          if (distance < closestDistance) {
            closest = row;
            closestDistance = distance;
          } else if (distance == closestDistance && closest.type != 'Point') {
            closest = row;
            closestDistance = distance;
          }
        } else if (geometry.type == 'Polygon') {
          if (booleanPointInPolygon(centerPoint, geometry)) {
            if (closestDistance != 0) {
              closest = row;
              closestDistance = 0;
            }
          } else {
            var line = polygonToLine(geometry);
            var distance = pointToLineDistance(centerPoint, line);
            if (distance < closestDistance) {
              closest = row;
              closestDistance = distance;
            }
          }
        }
      }
      closest.properties.Name.should.be.equal('Rio Grande');
    });
  });
github ngageoint / geopackage-js / lib / tiles / features / index.js View on Github external
FeatureTiles.prototype.drawPolygon = function(path, geoJson, context, featureStyle) {
  context.save();
  context.beginPath();
  path(PolyToLine(geoJson).geometry);
  context.closePath();
  var fillPaint = this.getPolygonFillPaint(featureStyle);
  if (fillPaint !== undefined && fillPaint !== null) {
    context.fillStyle = fillPaint.getColorRGBA();
    context.fill();
  }
  var paint = this.getPolygonPaint(featureStyle);
  context.strokeStyle = paint.getColorRGBA();
  context.lineWidth = paint.getStrokeWidth();
  context.stroke();
  context.restore();
};

@turf/polygon-to-line

turf polygon-to-line module

MIT
Latest version published 3 months ago

Package Health Score

94 / 100
Full package analysis