How to use the d3-geo.geoInterpolate function in d3-geo

To help you get started, we’ve selected a few d3-geo 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 DefinitelyTyped / DefinitelyTyped / d3-geo / d3-geo-tests.ts View on Github external
// geoLength(...) =========================================================

let length: number = d3Geo.geoLength(samplePolygon);
length = d3Geo.geoLength(sampleSphere);
length = d3Geo.geoLength(sampleGeometryCollection);
length = d3Geo.geoLength(sampleExtendedGeometryCollection);
length = d3Geo.geoLength(sampleFeature);
length = d3Geo.geoLength(sampleExtendedFeature1);
length = d3Geo.geoLength(sampleExtendedFeature2);
length = d3Geo.geoLength(sampleFeatureCollection);
length = d3Geo.geoLength(sampleExtendedFeatureCollection);

// geoInterpolate(...) ====================================================

const interpolateFct: (t: number) => [number, number] = d3Geo.geoInterpolate([54, 2], [53, 1]);

// geoRotation(...) =======================================================

// create rotation -----------------------------------------------------

const rotation: d3Geo.GeoRotation = d3Geo.geoRotation([90, 45]);
const rotation2: d3Geo.GeoRotation = d3Geo.geoRotation([90, 45, 27.5]);

// use rotation --------------------------------------------------------

const point: [number, number] = rotation([54, 2]);
const inverted: [number, number] = rotation.invert([54, 2]);

// ----------------------------------------------------------------------
// Spherical Shapes - geoCircle
// ----------------------------------------------------------------------
github DefinitelyTyped / DefinitelyTyped / types / d3-geo / d3-geo-tests.ts View on Github external
// geoLength(...) =========================================================

let length: number = d3Geo.geoLength(samplePolygon);
length = d3Geo.geoLength(sampleSphere);
length = d3Geo.geoLength(sampleGeometryCollection);
length = d3Geo.geoLength(sampleExtendedGeometryCollection);
length = d3Geo.geoLength(sampleFeature);
length = d3Geo.geoLength(sampleExtendedFeature1);
length = d3Geo.geoLength(sampleExtendedFeature2);
length = d3Geo.geoLength(sampleFeatureCollection);
length = d3Geo.geoLength(sampleExtendedFeatureCollection);

// geoInterpolate(...) ====================================================

const interpolateFct: (t: number) => [number, number] = d3Geo.geoInterpolate([54, 2], [53, 1]);

// geoRotation(...) =======================================================

// create rotation -----------------------------------------------------

const rotation: d3Geo.GeoRotation = d3Geo.geoRotation([90, 45]);
const rotation2: d3Geo.GeoRotation = d3Geo.geoRotation([90, 45, 27.5]);

// use rotation --------------------------------------------------------

const point: [number, number] = rotation([54, 2]);
const inverted: [number, number] = rotation.invert([54, 2]);

// ----------------------------------------------------------------------
// Spherical Shapes - geoCircle
// ----------------------------------------------------------------------
github vasturiano / three-globe / src / layers / arcs.js View on Github external
const getVec = ([lng, lat, alt]) => {
        const { x, y, z } = polar2Cartesian(lat, lng, alt);
        return new THREE.Vector3(x, y, z);
      };

      //calculate curve
      const startPnt = [startLng, startLat];
      const endPnt = [endLng, endLat];

      let altitude = alt;
      (altitude === null || altitude === undefined) &&
        // by default set altitude proportional to the great-arc distance
      (altitude = geoDistance(startPnt, endPnt) / 2 * altAutoScale);

      if (altitude) {
        const interpolate = geoInterpolate(startPnt, endPnt);
        const [m1Pnt, m2Pnt] = [0.25, 0.75].map(t => [...interpolate(t), altitude * 1.5]);
        const curve = new THREE.CubicBezierCurve3(...[startPnt, m1Pnt, m2Pnt, endPnt].map(getVec));

        //const mPnt = [...interpolate(0.5), altitude * 2];
        //curve = new THREE.QuadraticBezierCurve3(...[startPnt, mPnt, endPnt].map(getVec));

        return curve;
      } else {
        // ground line
        const alt = 0.001; // slightly above the ground to prevent occlusion
        return calcSphereArc(...[[...startPnt, alt], [...endPnt, alt]].map(getVec));
      }

      //

      function calcSphereArc(startVec, endVec) {
github Nexusoft / NexusInterface / app / script / globe.js View on Github external
function getSplineFromCoords(coords) {
    const startLat = coords[0];
    const startLng = coords[1];
    const endLat = coords[2];
    const endLng = coords[3];

    const globeradius = 200;

    // spline vertices
    const start = coordinateToPosition(startLat, startLng, globeradius);
    const end = coordinateToPosition(endLat, endLng, globeradius);
    const altitude = clamp(start.distanceTo(end) * 0.75, 10, globeradius);
    const interpolate = geoInterpolate([startLng, startLat], [endLng, endLat]);
    const midCoord1 = interpolate(0.25);
    const midCoord2 = interpolate(0.75);
    const mid1 = coordinateToPosition(
      midCoord1[1],
      midCoord1[0],
      globeradius + altitude
    );
    const mid2 = coordinateToPosition(
      midCoord2[1],
      midCoord2[0],
      globeradius + altitude
    );

    return {
      start,
      end,
github d3 / d3-geo-projection / src / polyhedral / index.js View on Github external
var c = dx === 180 || dx === 360
      ? [(b[0][0] + b[1][0]) / 2, (b[0][1] + b[1][1]) / 2]
      : centroid(multiPoint);
  // First find the shared edge…
  if (parent) while (++j < n) {
    if (edges[j] === parent) break;
  }
  ++j;
  for (var i = 0; i < n; ++i) {
    edge = edges[(i + j) % n];
    if (Array.isArray(edge)) {
      if (!inside) {
        stream.point((point = interpolate(edge[0], c)(epsilon))[0], point[1]);
        inside = true;
      }
      stream.point((point = interpolate(edge[1], c)(epsilon))[0], point[1]);
    } else {
      inside = false;
      if (edge !== parent) outline(stream, edge, node);
    }
  }
}
github d3 / d3-geo-projection / src / twoPoint.js View on Github external
export default function(raw, p0, p1) {
  var i = interpolate(p0, p1),
      o = i(0.5),
      a = rotation([-o[0], -o[1]])(p0),
      b = i.distance / 2,
      y = -asin(sin(a[1] * radians) / sin(b)),
      R = [-o[0], -o[1], -(a[0] > 0 ? pi - y : y) * degrees],
      p = projection(raw(b)).rotate(R),
      r = rotation(R),
      center = p.center;

  delete p.rotate;

  p.center = function(_) {
    return arguments.length ? center(r(_)) : r.invert(center());
  };

  return p
github Nexusoft / NexusInterface / src / App / OverviewTritium / Curve.js View on Github external
function getSplineFromCoords(pointOne, pointTwo) {
  const start = coordinateToPosition(pointOne.lat, pointOne.lng, 125);
  const end = coordinateToPosition(pointTwo.lat, pointTwo.lng, 125);
  const altitude = clamp(start.distanceTo(end) * 0.35, 10, 125);
  const interpolate = geoInterpolate(
    [pointOne.lng, pointOne.lat],
    [pointTwo.lng, pointTwo.lat]
  );
  const midCoord1 = interpolate(0.25);
  const midCoord2 = interpolate(0.75);
  const mid1 = coordinateToPosition(midCoord1[1], midCoord1[0], 125 + altitude);
  const mid2 = coordinateToPosition(midCoord2[1], midCoord2[0], 125 + altitude);

  return new THREE.CubicBezierCurve3(start, mid1, mid2, end);
}
github Nexusoft / NexusInterface / src / App / Overview / Curve.js View on Github external
function getSplineFromCoords(pointOne, pointTwo) {
  const start = coordinateToPosition(pointOne.lat, pointOne.lng, 125);
  const end = coordinateToPosition(pointTwo.lat, pointTwo.lng, 125);
  const altitude = clamp(start.distanceTo(end) * 0.35, 10, 125);
  const interpolate = geoInterpolate(
    [pointOne.lng, pointOne.lat],
    [pointTwo.lng, pointTwo.lat]
  );
  const midCoord1 = interpolate(0.25);
  const midCoord2 = interpolate(0.75);
  const mid1 = coordinateToPosition(midCoord1[1], midCoord1[0], 125 + altitude);
  const mid2 = coordinateToPosition(midCoord2[1], midCoord2[0], 125 + altitude);

  return new THREE.CubicBezierCurve3(start, mid1, mid2, end);
}
github amcharts / amcharts4 / src / .internal / charts / map / projections / Projection.ts View on Github external
public intermediatePoint(pointA: IGeoPoint, pointB: IGeoPoint, position: number): IGeoPoint {
		let p = d3geo.geoInterpolate([pointA.longitude, pointA.latitude], [pointB.longitude, pointB.latitude])(position);
		return { longitude: p[0], latitude: p[1] };
	};