How to use the d3-geo-projection.geoProject function in d3-geo-projection

To help you get started, we’ve selected a few d3-geo-projection 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 antvis / data-set / test / unit / api / geo-spec.ts View on Github external
it('geoProject(feature, projection)', () => {
    expect(dv.geoProject(feature0, 'geoAiry')).to.eql(d3GeoProjection.geoProject(feature0, d3GeoProjection.geoAiry()));
  });
  it('geoProjectByName(name, projection)', () => {
github antvis / data-set / src / api / geo.ts View on Github external
geoProject(feature: ExtendedFeature, projection: string, exportRaw?: boolean) {
    projection = getGeoProjection(projection, exportRaw);
    return geoProject(feature, projection);
  },
  geoProjectByName(this: View, name: string, projection: string, exportRaw?: boolean) {
github cockroachdb / cockroach-gen / pkg / ui / scripts / topo.js View on Github external
const usOrig = require('../node_modules/us-atlas/us/10m.json');
const worldOrig = require('../node_modules/world-atlas/world/50m.json');

const projection = d3geo.geoAlbersUsa().scale(1280).translate([480, 300]);
const invert = d3geo.geoTransform({
    point: function(x, y) {
        const inverted = projection.invert([x, y]);
        this.stream.point(inverted[0], inverted[1]);
    }
});

const usFeatProjected = topojson.feature(usOrig, {
    type: "GeometryCollection",
    geometries: usOrig.objects.states.geometries,
});
const usFeat = d3geoProjection.geoProject(usFeatProjected, invert);
const worldFeat = topojson.feature(worldOrig, {
    type: "GeometryCollection",
    geometries: worldOrig.objects.countries.geometries.filter(c => c.id != "840"),
});

const combinedFeats = {
    type: "FeatureCollection",
    features: usFeat.features.concat(worldFeat.features),
};

const combinedTopo = topojson.topology({all: combinedFeats}, 1e3);

let combinedSimpl = topojson.presimplify(combinedTopo);
combinedSimpl = topojson.simplify(combinedSimpl, 0.25);

const combinedResult = topojson.feature(combinedSimpl, combinedSimpl.objects.all);
github antvis / data-set / src / api / geo.js View on Github external
geoProject(feature, projection, exportRaw) {
    projection = getGeoProjection(projection, exportRaw);
    return geoProject(feature, projection);
  },
  geoProjectByName(name, projection, exportRaw) {
github antvis / data-set / src / api / geo.js View on Github external
geoProjectByName(name, projection, exportRaw) {
    projection = getGeoProjection(projection, exportRaw);
    return geoProject(this.geoFeatureByName(name), projection);
  },
  geoProjectPosition(position, projection, exportRaw) {
github antvis / data-set / src / api / geo.ts View on Github external
geoProjectByName(this: View, name: string, projection: string, exportRaw?: boolean) {
    projection = getGeoProjection(projection, exportRaw);
    return geoProject(this.geoFeatureByName(name), projection);
  },
  geoProjectPosition(position: [number, number], projection: string, exportRaw?: boolean) {