@visactor/vdataset
Version:
data processing tool
54 lines (46 loc) • 2.37 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.createProjection = exports.projectionProperties = exports.getProjectionPath = void 0;
const d3_geo_1 = require("d3-geo"), defaultPath = (0, d3_geo_1.geoPath)();
function getProjectionPath(proj) {
return proj && proj.path || defaultPath;
}
exports.getProjectionPath = getProjectionPath;
const projections = {}, builtInProjections = {
albers: d3_geo_1.geoAlbers,
albersusa: d3_geo_1.geoAlbersUsa,
azimuthalequalarea: d3_geo_1.geoAzimuthalEqualArea,
azimuthalequidistant: d3_geo_1.geoAzimuthalEquidistant,
conicconformal: d3_geo_1.geoConicConformal,
conicequalarea: d3_geo_1.geoConicEqualArea,
conicequidistant: d3_geo_1.geoConicEquidistant,
equalearth: d3_geo_1.geoEqualEarth,
equirectangular: d3_geo_1.geoEquirectangular,
gnomonic: d3_geo_1.geoGnomonic,
identity: d3_geo_1.geoIdentity,
mercator: d3_geo_1.geoMercator,
naturalearth1: d3_geo_1.geoNaturalEarth1,
orthographic: d3_geo_1.geoOrthographic,
stereographic: d3_geo_1.geoStereographic,
transversemercator: d3_geo_1.geoTransverseMercator
};
function createProjectionInner(type, constructor) {
return function projectionGenerator() {
const p = constructor();
return p.type = type, p.path = (0, d3_geo_1.geoPath)().projection(p), p.copy = p.copy || function() {
const c = projectionGenerator();
return exports.projectionProperties.forEach((prop => {
p[prop] && c[prop](p[prop]());
})), c.path.pointRadius(p.path.pointRadius()), c;
}, p;
};
}
function createProjection(type, proj) {
const projectionType = type.toLowerCase();
return arguments.length > 1 ? createProjectionInner(projectionType, proj) : builtInProjections[projectionType] ? (projections[projectionType] || (projections[projectionType] = createProjectionInner(projectionType, builtInProjections[projectionType])),
projections[projectionType]) : null;
}
exports.projectionProperties = [ "clipAngle", "clipExtent", "scale", "translate", "center", "rotate", "precision", "reflectX", "reflectY", "parallels", "coefficient", "distance", "fraction", "lobes", "parallel", "radius", "ratio", "spacing", "tilt" ],
exports.createProjection = createProjection;
//# sourceMappingURL=projections.js.map