Socket
Socket
Sign inDemoInstall

vega-geo

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vega-geo - npm Package Compare versions

Comparing version 1.0.0-beta.2 to 1.0.0-beta.3

definitions/Contour.js

277

build/vega-geo.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vega-dataflow'), require('vega-util'), require('d3-geo')) :
typeof define === 'function' && define.amd ? define(['exports', 'vega-dataflow', 'vega-util', 'd3-geo'], factory) :
(factory((global.vega = global.vega || {}),global.vega,global.vega,global.d3));
}(this, (function (exports,vegaDataflow,vegaUtil,d3Geo) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vega-dataflow'), require('vega-util'), require('d3-contour'), require('d3-geo')) :
typeof define === 'function' && define.amd ? define(['exports', 'vega-dataflow', 'vega-util', 'd3-contour', 'd3-geo'], factory) :
(factory((global.vega = global.vega || {}),global.vega,global.vega,global.d3,global.d3));
}(this, (function (exports,vegaDataflow,vegaUtil,d3Contour,d3Geo) { 'use strict';
var CONTOUR_PARAMS = ['values', 'size', 'thresholds'];
var DENSITY_PARAMS = ['x', 'y', 'size', 'cellSize', 'bandwidth', 'thresholds'];
/**
* Generate contours based on kernel-density estimation of point data.
* @constructor
* @param {object} params - The parameters for this operator.
* @param {Array<number>} params.size - The dimensions [width, height] over which to compute contours.
* If the values parameter is provided, this must be the dimensions of the input data.
* If density estimation is performed, this is the output view dimensions in pixels.
* @param {Array<number>} [params.values] - An array of numeric values representing an
* width x height grid of values over which to compute contours. If unspecified, this
* transform will instead attempt to compute contours for the kernel density estimate
* using values drawn from data tuples in the input pulse.
* @param {function(object): number} [params.x] - The pixel x-coordinate accessor for density estimation.
* @param {function(object): number} [params.y] - The pixel y-coordinate accessor for density estimation.
* @param {number} [params.cellSize] - Contour density calculation cell size.
* @param {number} [params.bandwidth] - Kernel density estimation bandwidth.
* @param {number} [params.thresholds] - Contour threshold array or desired number of contours.
*/
function Contour(params) {
vegaDataflow.Transform.call(this, null, params);
}
var prototype = vegaUtil.inherits(Contour, vegaDataflow.Transform);
prototype.transform = function(_, pulse) {
if (this.value && !pulse.changed() && !_.modified())
return pulse.StopPropagation;
var out = pulse.fork(pulse.NO_SOURCE | pulse.NO_FIELDS),
contour, params, values;
if (_.values) {
contour = d3Contour.contours();
params = CONTOUR_PARAMS;
values = _.values;
} else {
contour = d3Contour.contourDensity();
params = DENSITY_PARAMS;
values = pulse.materialize(pulse.SOURCE).source;
}
params.forEach(function(param) {
if (_[param] != null) contour[param](_[param]);
});
if (this.value) out.rem = this.value;
this.value = out.source = out.add = contour(values).map(vegaDataflow.ingest);
return out;
};
var defaultPath = d3Geo.geoPath();
var properties = [
// standard properties in d3-geo
'clipAngle',
'clipExtent',
'scale',
'translate',
'center',
'rotate',
'parallels',
'precision',
// extended properties in d3-geo-projections
'coefficient',
'distance',
'fraction',
'lobes',
'parallel',
'radius',
'ratio',
'spacing',
'tilt'
];
/**
* Augment projections with their type and a copy method.
*/
function create(type, constructor) {
return function projection() {
var p = constructor();
p.type = type;
p.path = d3Geo.geoPath().projection(p);
p.copy = p.copy || function() {
var c = projection();
properties.forEach(function(prop) {
if (p.hasOwnProperty(prop)) c[prop](p[prop]());
});
c.path.pointRadius(p.path.pointRadius());
return c;
};
return p;
};
}
function projection(type, proj) {
return arguments.length > 1 ? (projections[type] = create(type, proj), this)
: projections.hasOwnProperty(type) ? projections[type] : null;
}
function getPath(proj) {
return (proj && proj.path) || defaultPath;
}
var projections = {
// base d3-geo projection types
albers: d3Geo.geoAlbers,
albersusa: d3Geo.geoAlbersUsa,
azimuthalequalarea: d3Geo.geoAzimuthalEqualArea,
azimuthalequidistant: d3Geo.geoAzimuthalEquidistant,
conicconformal: d3Geo.geoConicConformal,
conicequalarea: d3Geo.geoConicEqualArea,
conicequidistant: d3Geo.geoConicEquidistant,
equirectangular: d3Geo.geoEquirectangular,
gnomonic: d3Geo.geoGnomonic,
mercator: d3Geo.geoMercator,
orthographic: d3Geo.geoOrthographic,
stereographic: d3Geo.geoStereographic,
transversemercator: d3Geo.geoTransverseMercator
};
for (var key in projections) {
projection(key, projections[key]);
}
/**
* Map GeoJSON data to an SVG path string.

@@ -22,5 +154,5 @@ * @constructor

var prototype = vegaUtil.inherits(GeoPath, vegaDataflow.Transform);
var prototype$1 = vegaUtil.inherits(GeoPath, vegaDataflow.Transform);
prototype.transform = function(_, pulse) {
prototype$1.transform = function(_, pulse) {
var out = pulse.fork(pulse.ALL),

@@ -36,3 +168,3 @@ path = this.value,

// parameters updated, reset and reflow
this.value = path = _.projection.path;
this.value = path = getPath(_.projection);
out.materialize().reflow().visit(out.SOURCE, set);

@@ -62,5 +194,5 @@ } else {

var prototype$1 = vegaUtil.inherits(GeoPoint, vegaDataflow.Transform);
var prototype$2 = vegaUtil.inherits(GeoPoint, vegaDataflow.Transform);
prototype$1.transform = function(_, pulse) {
prototype$2.transform = function(_, pulse) {
var proj = _.projection,

@@ -99,4 +231,4 @@ lon = _.fields[0],

* or null if the tuple itself is a GeoJSON feature.
* @param {string} [params.as='path'] - The output field in which to store
* the generated path data (default 'path').
* @param {string} [params.as='shape'] - The output field in which to store
* the generated path data (default 'shape').
*/

@@ -107,5 +239,5 @@ function GeoShape(params) {

var prototype$2 = vegaUtil.inherits(GeoShape, vegaDataflow.Transform);
var prototype$3 = vegaUtil.inherits(GeoShape, vegaDataflow.Transform);
prototype$2.transform = function(_, pulse) {
prototype$3.transform = function(_, pulse) {
var out = pulse.fork(pulse.ALL),

@@ -119,3 +251,3 @@ shape = this.value,

// parameters updated, reset and reflow
this.value = shape = shapeGenerator(_.projection.path, datum);
this.value = shape = shapeGenerator(getPath(_.projection), datum);
out.materialize().reflow();

@@ -145,5 +277,5 @@ flag = out.SOURCE;

var prototype$3 = vegaUtil.inherits(Graticule, vegaDataflow.Transform);
var prototype$4 = vegaUtil.inherits(Graticule, vegaDataflow.Transform);
prototype$3.transform = function(_, pulse) {
prototype$4.transform = function(_, pulse) {
var out = pulse.fork(),

@@ -173,76 +305,3 @@ src = this.value,

var properties = [
// standard properties in d3-geo
'clipAngle',
'clipExtent',
'scale',
'translate',
'center',
'rotate',
'parallels',
'precision',
// extended properties in d3-geo-projections
'coefficient',
'distance',
'fraction',
'lobes',
'parallel',
'radius',
'ratio',
'spacing',
'tilt'
];
/**
* Augment projections with their type and a copy method.
*/
function create$1(type, constructor) {
return function projection() {
var p = constructor();
p.type = type;
p.path = d3Geo.geoPath().projection(p);
p.copy = p.copy || function() {
var c = projection();
properties.forEach(function(prop) {
if (p.hasOwnProperty(prop)) c[prop](p[prop]());
});
c.path.pointRadius(p.path.pointRadius());
return c;
};
return p;
};
}
function projection(type, proj) {
return arguments.length > 1 ? (projections[type] = create$1(type, proj), this)
: projections.hasOwnProperty(type) ? projections[type] : null;
}
var projections = {
// base d3-geo projection types
albers: d3Geo.geoAlbers,
albersusa: d3Geo.geoAlbersUsa,
azimuthalequalarea: d3Geo.geoAzimuthalEqualArea,
azimuthalequidistant: d3Geo.geoAzimuthalEquidistant,
conicconformal: d3Geo.geoConicConformal,
conicequalarea: d3Geo.geoConicEqualArea,
conicequidistant: d3Geo.geoConicEquidistant,
equirectangular: d3Geo.geoEquirectangular,
gnomonic: d3Geo.geoGnomonic,
mercator: d3Geo.geoMercator,
orthographic: d3Geo.geoOrthographic,
stereographic: d3Geo.geoStereographic,
transversemercator: d3Geo.geoTransverseMercator
};
for (var key in projections) {
projection(key, projections[key]);
}
/**
* Maintains a cartographic projection.

@@ -257,9 +316,9 @@ * @constructor

var prototype$4 = vegaUtil.inherits(Projection, vegaDataflow.Transform);
var prototype$5 = vegaUtil.inherits(Projection, vegaDataflow.Transform);
prototype$4.transform = function(_) {
prototype$5.transform = function(_) {
var proj = this.value;
if (!proj || _.modified('type')) {
this.value = (proj = create(_.type));
this.value = (proj = create$1(_.type));
properties.forEach(function(prop) {

@@ -275,5 +334,18 @@ if (_[prop] != null) set(proj, prop, _[prop]);

if (_.pointRadius != null) proj.path.pointRadius(_.pointRadius);
if (_.fit) fit(proj, _);
};
function create(type) {
function fit(proj, _) {
var data = geoJSON(_.fit);
_.extent ? proj.fitExtent(_.extent, data)
: _.size ? proj.fitSize(_.size, data) : 0;
}
function geoJSON(data) {
return !vegaUtil.isArray(data) ? data
: data.length > 1 ? {type: 'FeatureCollection', features: data}
: data[0];
}
function create$1(type) {
var constructor = projection((type || 'mercator').toLowerCase());

@@ -288,2 +360,16 @@ if (!constructor) vegaUtil.error('Unrecognized projection type: ' + type);

var ContourDefinition = {
"type": "Contour",
"metadata": {"generates": true, "source": true},
"params": [
{ "name": "size", "type": "number", "array": true, "length": 2, "required": true },
{ "name": "values", "type": "number", "array": true },
{ "name": "x", "type": "field" },
{ "name": "y", "type": "field" },
{ "name": "cellSize", "type": "number" },
{ "name": "bandwidth", "type": "number" },
{ "name": "thresholds", "type": "number" }
]
}
var GeoPathDefinition = {

@@ -293,3 +379,3 @@ "type": "GeoPath",

"params": [
{ "name": "projection", "type": "projection", "required": true },
{ "name": "projection", "type": "projection" },
{ "name": "field", "type": "field" },

@@ -314,3 +400,3 @@ { "name": "as", "type": "string", "default": "path" }

"params": [
{ "name": "projection", "type": "projection", "required": true },
{ "name": "projection", "type": "projection" },
{ "name": "field", "type": "field", "default": "datum" },

@@ -338,2 +424,3 @@ { "name": "as", "type": "string", "default": "shape" }

vegaDataflow.register(ContourDefinition, Contour);
vegaDataflow.register(GeoPathDefinition, GeoPath);

@@ -340,0 +427,0 @@ vegaDataflow.register(GeoPointDefinition, GeoPoint);

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vega-dataflow"),require("vega-util"),require("d3-geo")):"function"==typeof define&&define.amd?define(["exports","vega-dataflow","vega-util","d3-geo"],t):t(e.vega=e.vega||{},e.vega,e.vega,e.d3)}(this,function(e,t,r,a){"use strict";function i(e){t.Transform.call(this,null,e)}function n(e){t.Transform.call(this,null,e)}function o(e){t.Transform.call(this,null,e)}function s(e,t){var r=function(r){return e(t(r))};return r.context=function(t){return e.context(t),r},r}function u(e){t.Transform.call(this,[],e),this.generator=a.geoGraticule()}function f(e,t){return function r(){var i=t();return i.type=e,i.path=a.geoPath().projection(i),i.copy=i.copy||function(){var e=r();return v.forEach(function(t){i.hasOwnProperty(t)&&e[t](i[t]())}),e.path.pointRadius(i.path.pointRadius()),e},i}}function l(e,t){return arguments.length>1?(j[e]=f(e,t),this):j.hasOwnProperty(e)?j[e]:null}function c(e){t.Transform.call(this,null,e),this.modified(!0)}function d(e){var t=l((e||"mercator").toLowerCase());return t||r.error("Unrecognized projection type: "+e),t()}function p(e,t,a){r.isFunction(e[t])&&e[t](a)}var m=r.inherits(i,t.Transform);m.transform=function(e,t){function a(e){e[u]=o(s(e))}var i,n=t.fork(t.ALL),o=this.value,s=e.field||r.identity,u=e.as||"path";return!o||e.modified()?(this.value=o=e.projection.path,n.materialize().reflow().visit(n.SOURCE,a)):(i=s===r.identity||t.modified(s.fields),n.visit(i?n.ADD_MOD:n.ADD,a)),n.modifies(u)};var h=r.inherits(n,t.Transform);h.transform=function(e,t){function r(e){var t=i([n(e),o(e)]);t?(e[u]=t[0],e[f]=t[1]):(e[u]=void 0,e[f]=void 0)}var a,i=e.projection,n=e.fields[0],o=e.fields[1],s=e.as||["x","y"],u=s[0],f=s[1];return e.modified()?t.materialize().reflow(!0).visit(t.SOURCE,r):(a=t.modified(n.fields)||t.modified(o.fields),t.visit(a?t.ADD_MOD:t.ADD,r)),t.modifies(s)};var g=r.inherits(o,t.Transform);g.transform=function(e,t){var a=t.fork(t.ALL),i=this.value,n=e.field||r.field("datum"),o=e.as||"shape",u=a.ADD_MOD;return i&&!e.modified()||(this.value=i=s(e.projection.path,n),a.materialize().reflow(),u=a.SOURCE),a.visit(u,function(e){e[o]=i}),a.modifies(o)};var y=r.inherits(u,t.Transform);y.transform=function(e,a){var i,n=a.fork(),o=this.value,s=this.generator;if(!o.length||e.modified())for(var u in e)r.isFunction(s[u])&&s[u](e[u]);return i=s(),o.length?(i._id=o[0]._id,n.mod.push(i)):n.add.push(t.ingest(i)),o[0]=i,n.source=o,n};var v=["clipAngle","clipExtent","scale","translate","center","rotate","parallels","precision","coefficient","distance","fraction","lobes","parallel","radius","ratio","spacing","tilt"],j={albers:a.geoAlbers,albersusa:a.geoAlbersUsa,azimuthalequalarea:a.geoAzimuthalEqualArea,azimuthalequidistant:a.geoAzimuthalEquidistant,conicconformal:a.geoConicConformal,conicequalarea:a.geoConicEqualArea,conicequidistant:a.geoConicEquidistant,equirectangular:a.geoEquirectangular,gnomonic:a.geoGnomonic,mercator:a.geoMercator,orthographic:a.geoOrthographic,stereographic:a.geoStereographic,transversemercator:a.geoTransverseMercator};for(var q in j)l(q,j[q]);var b=r.inherits(c,t.Transform);b.transform=function(e){var t=this.value;!t||e.modified("type")?(this.value=t=d(e.type),v.forEach(function(r){null!=e[r]&&p(t,r,e[r])})):v.forEach(function(r){e.modified(r)&&p(t,r,e[r])}),null!=e.pointRadius&&t.path.pointRadius(e.pointRadius)};var A={type:"GeoPath",metadata:{modifies:!0},params:[{name:"projection",type:"projection",required:!0},{name:"field",type:"field"},{name:"as",type:"string",default:"path"}]},D={type:"GeoPoint",metadata:{modifies:!0},params:[{name:"projection",type:"projection",required:!0},{name:"fields",type:"field",array:!0,required:!0,length:2},{name:"as",type:"string",array:!0,length:2,default:["x","y"]}]},E={type:"GeoShape",metadata:{modifies:!0},params:[{name:"projection",type:"projection",required:!0},{name:"field",type:"field",default:"datum"},{name:"as",type:"string",default:"shape"}]},x={type:"Graticule",metadata:{source:!0,generates:!0,changes:!0},params:[{name:"extent",type:"array",array:!0,length:2,content:{type:"number",array:!0,length:2}},{name:"extentMajor",type:"array",array:!0,length:2,content:{type:"number",array:!0,length:2}},{name:"extentMinor",type:"array",array:!0,length:2,content:{type:"number",array:!0,length:2}},{name:"step",type:"number",array:!0,length:2},{name:"stepMajor",type:"number",array:!0,length:2,default:[90,360]},{name:"stepMinor",type:"number",array:!0,length:2,default:[10,10]},{name:"precision",type:"number",default:2.5}]};t.register(A,i),t.register(D,n),t.register(E,o),t.register(x,u),t.transform("Projection",c),e.transform=t.transform,e.definition=t.definition,e.projection=l,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vega-dataflow"),require("vega-util"),require("d3-contour"),require("d3-geo")):"function"==typeof define&&define.amd?define(["exports","vega-dataflow","vega-util","d3-contour","d3-geo"],t):t(e.vega=e.vega||{},e.vega,e.vega,e.d3,e.d3)}(this,function(e,t,r,a,n){"use strict";function i(e){t.Transform.call(this,null,e)}function o(e,t){return function r(){var a=t();return a.type=e,a.path=n.geoPath().projection(a),a.copy=a.copy||function(){var e=r();return E.forEach(function(t){a.hasOwnProperty(t)&&e[t](a[t]())}),e.path.pointRadius(a.path.pointRadius()),e},a}}function s(e,t){return arguments.length>1?(x[e]=o(e,t),this):x.hasOwnProperty(e)?x[e]:null}function u(e){return e&&e.path||z}function l(e){t.Transform.call(this,null,e)}function f(e){t.Transform.call(this,null,e)}function c(e){t.Transform.call(this,null,e)}function d(e,t){var r=function(r){return e(t(r))};return r.context=function(t){return e.context(t),r},r}function m(e){t.Transform.call(this,[],e),this.generator=n.geoGraticule()}function p(e){t.Transform.call(this,null,e),this.modified(!0)}function h(e,t){var r=g(t.fit);t.extent?e.fitExtent(t.extent,r):t.size?e.fitSize(t.size,r):0}function g(e){return r.isArray(e)?e.length>1?{type:"FeatureCollection",features:e}:e[0]:e}function y(e){var t=s((e||"mercator").toLowerCase());return t||r.error("Unrecognized projection type: "+e),t()}function v(e,t,a){r.isFunction(e[t])&&e[t](a)}var b=["values","size","thresholds"],j=["x","y","size","cellSize","bandwidth","thresholds"],q=r.inherits(i,t.Transform);q.transform=function(e,r){if(this.value&&!r.changed()&&!e.modified())return r.StopPropagation;var n,i,o,s=r.fork(r.NO_SOURCE|r.NO_FIELDS);return e.values?(n=a.contours(),i=b,o=e.values):(n=a.contourDensity(),i=j,o=r.materialize(r.SOURCE).source),i.forEach(function(t){null!=e[t]&&n[t](e[t])}),this.value&&(s.rem=this.value),this.value=s.source=s.add=n(o).map(t.ingest),s};var z=n.geoPath(),E=["clipAngle","clipExtent","scale","translate","center","rotate","parallels","precision","coefficient","distance","fraction","lobes","parallel","radius","ratio","spacing","tilt"],x={albers:n.geoAlbers,albersusa:n.geoAlbersUsa,azimuthalequalarea:n.geoAzimuthalEqualArea,azimuthalequidistant:n.geoAzimuthalEquidistant,conicconformal:n.geoConicConformal,conicequalarea:n.geoConicEqualArea,conicequidistant:n.geoConicEquidistant,equirectangular:n.geoEquirectangular,gnomonic:n.geoGnomonic,mercator:n.geoMercator,orthographic:n.geoOrthographic,stereographic:n.geoStereographic,transversemercator:n.geoTransverseMercator};for(var A in x)s(A,x[A]);var D=r.inherits(l,t.Transform);D.transform=function(e,t){function a(e){e[l]=o(s(e))}var n,i=t.fork(t.ALL),o=this.value,s=e.field||r.identity,l=e.as||"path";return!o||e.modified()?(this.value=o=u(e.projection),i.materialize().reflow().visit(i.SOURCE,a)):(n=s===r.identity||t.modified(s.fields),i.visit(n?i.ADD_MOD:i.ADD,a)),i.modifies(l)};var O=r.inherits(f,t.Transform);O.transform=function(e,t){function r(e){var t=n([i(e),o(e)]);t?(e[u]=t[0],e[l]=t[1]):(e[u]=void 0,e[l]=void 0)}var a,n=e.projection,i=e.fields[0],o=e.fields[1],s=e.as||["x","y"],u=s[0],l=s[1];return e.modified()?t.materialize().reflow(!0).visit(t.SOURCE,r):(a=t.modified(i.fields)||t.modified(o.fields),t.visit(a?t.ADD_MOD:t.ADD,r)),t.modifies(s)};var T=r.inherits(c,t.Transform);T.transform=function(e,t){var a=t.fork(t.ALL),n=this.value,i=e.field||r.field("datum"),o=e.as||"shape",s=a.ADD_MOD;return n&&!e.modified()||(this.value=n=d(u(e.projection),i),a.materialize().reflow(),s=a.SOURCE),a.visit(s,function(e){e[o]=n}),a.modifies(o)};var C=r.inherits(m,t.Transform);C.transform=function(e,a){var n,i=a.fork(),o=this.value,s=this.generator;if(!o.length||e.modified())for(var u in e)r.isFunction(s[u])&&s[u](e[u]);return n=s(),o.length?(n._id=o[0]._id,i.mod.push(n)):i.add.push(t.ingest(n)),o[0]=n,i.source=o,i};var S=r.inherits(p,t.Transform);S.transform=function(e){var t=this.value;!t||e.modified("type")?(this.value=t=y(e.type),E.forEach(function(r){null!=e[r]&&v(t,r,e[r])})):E.forEach(function(r){e.modified(r)&&v(t,r,e[r])}),null!=e.pointRadius&&t.path.pointRadius(e.pointRadius),e.fit&&h(t,e)};var w={type:"Contour",metadata:{generates:!0,source:!0},params:[{name:"size",type:"number",array:!0,length:2,required:!0},{name:"values",type:"number",array:!0},{name:"x",type:"field"},{name:"y",type:"field"},{name:"cellSize",type:"number"},{name:"bandwidth",type:"number"},{name:"thresholds",type:"number"}]},M={type:"GeoPath",metadata:{modifies:!0},params:[{name:"projection",type:"projection"},{name:"field",type:"field"},{name:"as",type:"string",default:"path"}]},R={type:"GeoPoint",metadata:{modifies:!0},params:[{name:"projection",type:"projection",required:!0},{name:"fields",type:"field",array:!0,required:!0,length:2},{name:"as",type:"string",array:!0,length:2,default:["x","y"]}]},P={type:"GeoShape",metadata:{modifies:!0},params:[{name:"projection",type:"projection"},{name:"field",type:"field",default:"datum"},{name:"as",type:"string",default:"shape"}]},_={type:"Graticule",metadata:{source:!0,generates:!0,changes:!0},params:[{name:"extent",type:"array",array:!0,length:2,content:{type:"number",array:!0,length:2}},{name:"extentMajor",type:"array",array:!0,length:2,content:{type:"number",array:!0,length:2}},{name:"extentMinor",type:"array",array:!0,length:2,content:{type:"number",array:!0,length:2}},{name:"step",type:"number",array:!0,length:2},{name:"stepMajor",type:"number",array:!0,length:2,default:[90,360]},{name:"stepMinor",type:"number",array:!0,length:2,default:[10,10]},{name:"precision",type:"number",default:2.5}]};t.register(w,i),t.register(M,l),t.register(R,f),t.register(P,c),t.register(_,m),t.transform("Projection",p),e.transform=t.transform,e.definition=t.definition,e.projection=s,Object.defineProperty(e,"__esModule",{value:!0})});

@@ -5,3 +5,3 @@ export default {

"params": [
{ "name": "projection", "type": "projection", "required": true },
{ "name": "projection", "type": "projection" },
{ "name": "field", "type": "field" },

@@ -8,0 +8,0 @@ { "name": "as", "type": "string", "default": "path" }

@@ -5,3 +5,3 @@ export default {

"params": [
{ "name": "projection", "type": "projection", "required": true },
{ "name": "projection", "type": "projection" },
{ "name": "field", "type": "field", "default": "datum" },

@@ -8,0 +8,0 @@ { "name": "as", "type": "string", "default": "shape" }

import {register, transform} from 'vega-dataflow';
import Contour from './src/Contour';
import GeoPath from './src/GeoPath';

@@ -9,2 +10,3 @@ import GeoPoint from './src/GeoPoint';

import ContourDefinition from './definitions/Contour';
import GeoPathDefinition from './definitions/GeoPath';

@@ -15,2 +17,3 @@ import GeoPointDefinition from './definitions/GeoPoint';

register(ContourDefinition, Contour);
register(GeoPathDefinition, GeoPath);

@@ -17,0 +20,0 @@ register(GeoPointDefinition, GeoPoint);

{
"name": "vega-geo",
"version": "1.0.0-beta.2",
"version": "1.0.0-beta.3",
"description": "Geographic data transforms for Vega dataflows.",

@@ -25,3 +25,3 @@ "keywords": [

"build": "npm run test && uglifyjs build/vega-geo.js -c -m -o build/vega-geo.min.js",
"pretest": "rm -rf build && mkdir build && rollup -g d3-geo:d3,vega-dataflow:vega,vega-util:vega -f umd -n vega -o build/vega-geo.js -- index.js",
"pretest": "rm -rf build && mkdir build && rollup -g d3-contour:d3,d3-geo:d3,vega-dataflow:vega,vega-util:vega -f umd -n vega -o build/vega-geo.js -- index.js",
"test": "tape 'test/**/*-test.js' && eslint index.js src test",

@@ -32,2 +32,3 @@ "prepublish": "npm run build",

"dependencies": {
"d3-contour": "1",
"d3-geo": "1",

@@ -34,0 +35,0 @@ "vega-dataflow": ">=2.0.0-beta.4",

@@ -0,1 +1,2 @@

import {getPath} from './projections';
import {Transform} from 'vega-dataflow';

@@ -32,3 +33,3 @@ import {inherits, identity} from 'vega-util';

// parameters updated, reset and reflow
this.value = path = _.projection.path;
this.value = path = getPath(_.projection);
out.materialize().reflow().visit(out.SOURCE, set);

@@ -35,0 +36,0 @@ } else {

@@ -0,1 +1,2 @@

import {getPath} from './projections';
import {Transform} from 'vega-dataflow';

@@ -12,4 +13,4 @@ import {inherits, field} from 'vega-util';

* or null if the tuple itself is a GeoJSON feature.
* @param {string} [params.as='path'] - The output field in which to store
* the generated path data (default 'path').
* @param {string} [params.as='shape'] - The output field in which to store
* the generated path data (default 'shape').
*/

@@ -31,3 +32,3 @@ export default function GeoShape(params) {

// parameters updated, reset and reflow
this.value = shape = shapeGenerator(_.projection.path, datum);
this.value = shape = shapeGenerator(getPath(_.projection), datum);
out.materialize().reflow();

@@ -34,0 +35,0 @@ flag = out.SOURCE;

import {Transform} from 'vega-dataflow';
import {error, inherits, isFunction} from 'vega-util';
import {error, inherits, isArray, isFunction} from 'vega-util';
import {projection, properties} from './projections';

@@ -32,4 +32,17 @@

if (_.pointRadius != null) proj.path.pointRadius(_.pointRadius);
if (_.fit) fit(proj, _);
};
function fit(proj, _) {
var data = geoJSON(_.fit);
_.extent ? proj.fitExtent(_.extent, data)
: _.size ? proj.fitSize(_.size, data) : 0;
}
function geoJSON(data) {
return !isArray(data) ? data
: data.length > 1 ? {type: 'FeatureCollection', features: data}
: data[0];
}
function create(type) {

@@ -36,0 +49,0 @@ var constructor = projection((type || 'mercator').toLowerCase());

@@ -18,2 +18,4 @@ import {

var defaultPath = geoPath();
export var properties = [

@@ -71,2 +73,6 @@ // standard properties in d3-geo

export function getPath(proj) {
return (proj && proj.path) || defaultPath;
}
var projections = {

@@ -73,0 +79,0 @@ // base d3-geo projection types

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc