Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
// ----------------------------------------------------------------------
// Create GeoCircleGenerator ============================================
// simple use case
let circleGeneratorSimple: d3Geo.GeoCircleGenerator = d3Geo.geoCircle();
// complex use as part of object
class Circulator {
constructor(radius: number, precision: number) {
this.r = radius;
this.p = precision;
this.circleGenerator = d3Geo.geoCircle()
.radius(function(datum) {
const t: Circulator = this;
const d: [number, number] | undefined = datum;
return this.r;
})
.precision(function(datum) {
const t: Circulator = this;
const d: [number, number] | undefined = datum;
return this.p;
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
// ----------------------------------------------------------------------
// Create GeoCircleGenerator ============================================
// simple use case
let circleGeneratorSimple: d3Geo.GeoCircleGenerator = d3Geo.geoCircle();
// complex use as part of object
class Circulator {
constructor(radius: number, precision: number) {
this.r = radius;
this.p = precision;
this.circleGenerator = d3Geo.geoCircle()
.radius(function(datum) {
const t: Circulator = this;
const d: [number, number] | undefined = datum;
return this.r;
})
.precision(function(datum) {
const t: Circulator = this;
const d: [number, number] | undefined = datum;
return this.p;
export default function() {
var phi0 = 0,
m = projectionMutator(hammerRetroazimuthalRaw),
p = m(phi0),
rotate_ = p.rotate,
stream_ = p.stream,
circle = geoCircle();
p.parallel = function(_) {
if (!arguments.length) return phi0 * degrees;
var r = p.rotate();
return m(phi0 = _ * radians).rotate(r);
};
// Temporary hack; see hammerRetroazimuthalRotation.
p.rotate = function(_) {
if (!arguments.length) return (_ = rotate_.call(p), _[1] += phi0 * degrees, _);
rotate_.call(p, [_[0], _[1] - phi0 * degrees]);
circle.center([-_[0], -_[1]]);
return p;
};
p.stream = function(stream) {
constructor(radius: number, precision: number) {
this.r = radius;
this.p = precision;
this.circleGenerator = d3Geo.geoCircle()
.radius(function(datum) {
const t: Circulator = this;
const d: [number, number] | undefined = datum;
return this.r;
})
.precision(function(datum) {
const t: Circulator = this;
const d: [number, number] | undefined = datum;
return this.p;
})
.center(function(datum) {
const t: Circulator = this;
const d: [number, number] | undefined = datum;
return d ? d : [0, 0];
});
}
constructor(radius: number, precision: number) {
this.r = radius;
this.p = precision;
this.circleGenerator = d3Geo.geoCircle()
.radius(function(datum) {
const t: Circulator = this;
const d: [number, number] | undefined = datum;
return this.r;
})
.precision(function(datum) {
const t: Circulator = this;
const d: [number, number] | undefined = datum;
return this.p;
})
.center(function(datum) {
const t: Circulator = this;
const d: [number, number] | undefined = datum;
return d ? d : [0, 0];
});
}
export function getCircle(longitude, latitude, radius) {
return [d3geo.geoCircle().center([longitude, latitude]).radius(radius)().coordinates];
}
/**
import React from 'react';
import {geoAzimuthalEquidistant, geoPath, geoGraticule, geoCircle} from 'd3-geo';
import {utcDay} from 'd3-time';
import topojson from 'topojson';
import world from '../data/world-50m.json';
const width = 700;
const height = 700;
const pi = Math.PI;
const radians = pi / 180;
const degrees = 180 / pi;
const circle = geoCircle()
.radius(90);
const projection = geoAzimuthalEquidistant()
.scale(85)
.translate([width / 2, height / 2])
.clipAngle(180 - 1e-3)
.rotate([0, 90])
.precision(.1);
const path = geoPath()
.projection(projection);
const graticule = geoGraticule();
export default function World() {
const now = new Date();
export function getCircle(longitude: number, latitude: number, radius: number): Array>> {
return [d3geo.geoCircle().center([longitude, latitude]).radius(radius)().coordinates as Array>];
}