gridviz 3.0.7 → 3.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gridviz",
3
- "version": "3.0.7",
3
+ "version": "3.0.9",
4
4
  "description": "Visualization tool for gridded statistics",
5
5
  "keywords": [
6
6
  "statistics",
@@ -107,7 +107,7 @@ export class Dataset {
107
107
  if (this.mixedResolution) {
108
108
  for (const c of cells) {
109
109
  /** @type {number} */
110
- const r = this.mixedResolution(c)
110
+ const r = +this.mixedResolution(c)
111
111
  if (posGeo.x < c.x) continue
112
112
  else if (c.x + r < posGeo.x) continue
113
113
  else if (posGeo.y < c.y) continue
package/src/core/Map.js CHANGED
@@ -304,7 +304,7 @@ export class Map {
304
304
 
305
305
  //rare case for a dataset with mixed resolutions
306
306
  if (dsc.mixedResolution) {
307
- const r = dsc.mixedResolution(cell)
307
+ const r = +dsc.mixedResolution(cell)
308
308
  const html = layer.cellInfoHTML(cell, r)
309
309
  if (!html) return undefined
310
310
  return { cell: cell, html: html, resolution: r }
@@ -3,7 +3,7 @@
3
3
 
4
4
  /** @typedef {{ dims: object, crs: string, tileSizeCell: number, originPoint: {x:number,y:number}, resolutionGeo: number, tilingBounds:import("../core/GeoCanvas.js").Envelope }} GridInfo */
5
5
 
6
- import { csv } from 'd3-fetch'
6
+ import { dsv } from 'd3-fetch'
7
7
  import { Dataset } from '../core/Dataset.js'
8
8
 
9
9
  /**
@@ -17,7 +17,7 @@ export class CSVGrid extends Dataset {
17
17
  * @param {import("../core/Map.js").Map} map The map.
18
18
  * @param {string} url The URL of the dataset.
19
19
  * @param {number} resolution The dataset resolution in geographical unit.
20
- * @param {{preprocess?:(function(import("../core/Dataset.js").Cell):boolean)}} opts
20
+ * @param {{preprocess?:(function(import("../core/Dataset.js").Cell):boolean),delimiter?:string}} opts
21
21
  */
22
22
  constructor(map, url, resolution, opts = {}) {
23
23
  super(map, url, resolution, opts)
@@ -27,6 +27,11 @@ export class CSVGrid extends Dataset {
27
27
  * @type {Array.<import("../core/Dataset.js").Cell>} */
28
28
  this.cells = []
29
29
 
30
+ /**
31
+ * @private
32
+ * @type {string} */
33
+ this.delimiter = opts.delimiter || ","
34
+
30
35
  /**
31
36
  * @type {string}
32
37
  * @private */
@@ -48,7 +53,7 @@ export class CSVGrid extends Dataset {
48
53
  this.infoLoadingStatus = 'loading'
49
54
  ; (async () => {
50
55
  try {
51
- const data = await csv(this.url)
56
+ const data = await dsv(this.delimiter, this.url)
52
57
 
53
58
  //convert coordinates in numbers
54
59
  for (const c of data) {
@@ -71,7 +76,7 @@ export class CSVGrid extends Dataset {
71
76
  //TODO check if redraw is necessary
72
77
  //that is if the dataset belongs to a layer which is visible at the current zoom level
73
78
 
74
- //execute the callback, usually a draw function
79
+ //redraw map
75
80
  if (this.map) this.map.redraw()
76
81
 
77
82
  this.infoLoadingStatus = 'loaded'
package/src/index.js CHANGED
@@ -6,6 +6,7 @@ export { Map } from './core/Map.js'
6
6
  export { GeoCanvas } from './core/GeoCanvas.js'
7
7
  export { Style } from './core/Style.js'
8
8
  export { Layer } from './core/Layer.js'
9
+ export { Dataset } from './core/Dataset.js'
9
10
  export { MultiResolutionDataset } from './core/MultiResolutionDataset.js'
10
11
 
11
12
  // export dataset types