How to use @turf/great-circle - 3 common examples

To help you get started, we’ve selected a few @turf/great-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 Vizzuality / trase / frontend / scripts / react-components / shared / world-map / world-map.selectors.js View on Github external
function buildGreatCircleArc(originCoords, destinationCoords, worldMapProjection) {
  if (isEqual(originCoords, destinationCoords)) {
    return null;
  }
  const arc = greatCircle(originCoords, destinationCoords, { offset: 400, npoints: 100 });
  if (arc.geometry.type === 'MultiLineString') {
    return buildCustomArc(originCoords, destinationCoords, worldMapProjection);
  }
  const pathMaker = geoPath().projection(worldMapProjection);
  return pathMaker(arc);
}
github GlobalFishingWatch / map-client / src / app / rulers / rulersSelectors.js View on Github external
type: 'Feature',
    properties: {},
    geometry: {
      type: 'LineString',
      coordinates: [[start.longitude, start.latitude], [end.longitude, end.latitude]],
    },
  }
  const lengthKm = length(rawFeature, { units: 'kilometers' })
  const lengthNmi = lengthKm / 1.852
  const lengthKmFormatted = lengthKm.toFixed(lengthKm > 100 ? 0 : 1)
  const lengthNmiFormatted = lengthNmi.toFixed(lengthNmi > 100 ? 0 : 1)

  const finalFeature =
    lengthKm < 100
      ? rawFeature
      : greatCircle([start.longitude, start.latitude], [end.longitude, end.latitude])

  finalFeature.properties.label = `${lengthKmFormatted}km - ${lengthNmiFormatted}nmi`
  finalFeature.properties.isNew = isNew
  return finalFeature
}
github geosolutions-it / MapStore2 / web / client / utils / CoordinatesUtils.js View on Github external
transformLineToArcs: (coordinates, options = {npoints: 100, offset: 10, properties: {}}) => {
        let arcs = [];
        for (let i = 0; i < coordinates.length - 1; ++i) {
            const p1 = coordinates[i];
            const p2 = coordinates[i + 1];
            const start = toPoint(p1);
            const end = toPoint(p2);
            if (!(p1[0] === p2[0] && p1[1] === p2[1])) {
                let grCircle = greatCircle(start, end, options);
                arcs = [...arcs, ...grCircle.geometry.coordinates];
            }
        }
        return arcs;
    },
    transformArcsToLine: (coordinates, npoints = 100) => {

@turf/great-circle

turf great-circle module

MIT
Latest version published 3 months ago

Package Health Score

96 / 100
Full package analysis

Popular @turf/great-circle functions