How to use the d3-geo.geoProjection 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 / types / d3-geo / d3-geo-tests.ts View on Github external
const azimuthalEquidistant: d3Geo.GeoProjection = d3Geo.geoAzimuthalEquidistant();
let conicConformal: d3Geo.GeoConicProjection = d3Geo.geoConicConformal();
const conicEqualArea: d3Geo.GeoConicProjection = d3Geo.geoConicEqualArea();
const conicEquidistant: d3Geo.GeoConicProjection = d3Geo.geoConicEquidistant();
const cquirectangular: d3Geo.GeoProjection = d3Geo.geoEquirectangular();
const gnomonic: d3Geo.GeoProjection = d3Geo.geoGnomonic();
const mercator: d3Geo.GeoProjection = d3Geo.geoMercator();
const orthographic: d3Geo.GeoProjection = d3Geo.geoOrthographic();
const stereographic: d3Geo.GeoProjection = d3Geo.geoStereographic();
const transverseMercator: d3Geo.GeoProjection = d3Geo.geoTransverseMercator();

// ----------------------------------------------------------------------
// Create New Projections
// ----------------------------------------------------------------------

const geoProjection: d3Geo.GeoProjection = d3Geo.geoProjection(azimuthalEqualAreaRaw);

const mutate: () => d3Geo.GeoProjection = d3Geo.geoProjectionMutator(() => azimuthalEqualAreaRaw);
let constructedProjection: d3Geo.GeoProjection = mutate();

// Use Projection ==========================================================

const projected: [number, number] = constructedProjection([54, 2]);
const inverted2: [number, number] = constructedProjection.invert([54, 2]);

// TODO ?????
// let stream: d3Geo.Stream = constructedProjection.stream([54, 2]);

const clipAngle: number = constructedProjection.clipAngle();
constructedProjection = constructedProjection.clipAngle(null);
constructedProjection = constructedProjection.clipAngle(45);
github d3 / d3-geo-polygon / src / polyhedral / index.js View on Github external
(t[3] * point[0] + t[4] * point[1] + t[5])
      ];
    }
    if (invert && node === faceDegrees(p = invert(point))) return p;
    var p,
        children = node.children;
    for (var i = 0, n = children && children.length; i < n; ++i) {
      if (p = faceInvert(children[i], coordinates)) return p;
    }
  }

  function faceDegrees(coordinates) {
    return face(coordinates[0] * radians, coordinates[1] * radians);
  }

  var proj = projection(forward);

  // run around the mesh of faces and stream all vertices to create the clipping polygon
  var polygon = [];
  outline({point: function(lambda, phi) { polygon.push([lambda, phi]); }}, tree);
  polygon.push(polygon[0]);
  proj.preclip(clipPolygon({ type: "Polygon", coordinates: [ polygon ] }));
  proj.tree = function() { return tree; };
  
  return proj;
}
github d3 / d3-geo-projection / src / winkel3.js View on Github external
export default function() {
  return projection(winkel3Raw)
      .scale(158.837);
}
github d3 / d3-geo-projection / src / interrupted / index.js View on Github external
forward.invert = inverse(forward);
  } else if (project.invert) {
    forward.invert = function(x, y) {
      var bound = bounds[+(y < 0)], lobe = lobes[+(y < 0)];
      for (var i = 0, n = bound.length; i < n; ++i) {
        var b = bound[i];
        if (b[0][0] <= x && x < b[1][0] && b[0][1] <= y && y < b[1][1]) {
          var p = project.invert(x - project(lobe[i][1][0], 0)[0], y);
          p[0] += lobe[i][1][0];
          return pointEqual(forward(p[0], p[1]), [x, y]) ? p : null;
        }
      }
    };
  }

  var p = projection(forward),
      stream_ = p.stream;

  p.stream = function(stream) {
    var rotate = p.rotate(),
        rotateStream = stream_(stream),
        sphereStream = (p.rotate([0, 0]), stream_(stream));
    p.rotate(rotate);
    rotateStream.sphere = function() { geoStream(sphere, sphereStream); };
    return rotateStream;
  };
  
  p.lobes = function(_) {
    if (!arguments.length) return lobes.map(function(lobe) {
      return lobe.map(function(l) {
        return [
          [l[0][0] * degrees, l[0][1] * degrees],
github d3 / d3-geo-projection / src / wagner6.js View on Github external
export default function() {
  return projection(wagner6Raw)
      .scale(152.63);
}
github d3 / d3-geo-projection / src / ginzburg9.js View on Github external
export default function() {
  return projection(ginzburg9Raw)
      .scale(131.087);
}
github d3 / d3-geo-projection / src / vanDerGrinten2.js View on Github external
export default function() {
  return projection(vanDerGrinten2Raw)
      .scale(79.4183);
}
github d3 / d3-geo-projection / src / eckert3.js View on Github external
export default function() {
  return projection(eckert3Raw)
      .scale(180.739);
}
github d3 / d3-geo-projection / src / mtFlatPolarSinusoidal.js View on Github external
export default function() {
  return projection(mtFlatPolarSinusoidalRaw)
      .scale(166.518);
}
github d3 / d3-geo-projection / src / kavrayskiy7.js View on Github external
export default function() {
  return projection(kavrayskiy7Raw)
      .scale(158.837);
}