@lgv/visualization-map 0.0.2 → 0.0.3

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": "@lgv/visualization-map",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "type": "module",
5
5
  "description": "ES6 d3.js core visualization scaffold object and utilities for maps.",
6
6
  "main": "src/index.js",
@@ -12,7 +12,7 @@
12
12
  "build": "webpack build --config webpack.prod.js",
13
13
  "coverage": "c8 --reporter=html --reporter=text ava --node-arguments='--experimental-json-modules'",
14
14
  "start": "webpack serve --config webpack.dev.js",
15
- "startdocker": "webpack serve --config webpack.dev.js --host 0.0.0.0 --public 0.0.0.0",
15
+ "startdocker": "webpack serve --config webpack.dev.js --host 0.0.0.0 --allowed-hosts all",
16
16
  "test": "npx ava --verbose --serial --timeout 1m --node-arguments='--experimental-json-modules'"
17
17
  },
18
18
  "repository": {
@@ -36,13 +36,14 @@
36
36
  "css-loader": "^6.7.2",
37
37
  "html-webpack-plugin": "^5.3.2",
38
38
  "style-loader": "^3.3.1",
39
- "webpack-cli": "^4.7.2",
40
- "webpack-dev-server": "^3.11.2"
39
+ "webpack": "^5.86.0",
40
+ "webpack-cli": "^5.1.4",
41
+ "webpack-dev-server": "^4.15.1"
41
42
  },
42
43
  "dependencies": {
43
44
  "@deck.gl/core": "^8.8.20",
44
45
  "@deck.gl/layers": "^8.8.20",
45
- "@lgv/visualization-chart": "^0.3.6",
46
+ "@lgv/visualization-chart": "^0.3.21",
46
47
  "@msrvida/vega-deck.gl": "^3.3.4",
47
48
  "leaflet": "^1.9.2",
48
49
  "vega": "^5.22.1"
@@ -6,7 +6,8 @@ const configuration = {
6
6
  };
7
7
 
8
8
  const configurationColor = {
9
- p1: ["#F7BBB5", "#F37765", "#EF4223", "#992B20", "#37150E"]
9
+ p1: ["#0a86ca", "#0a86ca"],
10
+ p2: ["#F7BBB5", "#F37765", "#EF4223", "#992B20", "#37150E"]
10
11
  };
11
12
 
12
13
  const configurationLayout = {
@@ -64,7 +64,7 @@ class Heatmap extends VisualizationMap {
64
64
  mark = base - 5;
65
65
  break;
66
66
  }
67
- console.log(mark)
67
+
68
68
  return mark;
69
69
 
70
70
  }
@@ -22,14 +22,12 @@ class VisualizationMap extends LinearGrid {
22
22
  super(data, width, height, MapData, label, name);
23
23
 
24
24
  // determine type of data object
25
- this.isFeatureCollection = this.data.features;
26
- this.isPoint = this.data.coordinates && this.data.type.lower() == "point";
27
- this.isXY = this.data.metadata && this.data.results;
25
+ this.determineDataType();
28
26
 
29
27
  // determine x/y center
30
- let x = this.isFeatureCollection ? mean(this.data.features, d => d.geometry.coordinates[1]) : (this.isPoint ? this.data.coordinates[1] : mean([this.data.metadata.bounds[0][1],this.data.metadata.bounds[1][1]]));
28
+ let x = this.isFeatureCollection ? mean(this.data.features, d => d.geometry.coordinates[1]) : (this.isPoint ? this.data.coordinates[1] : (this.isXY ? mean([this.data.metadata.bounds[0][1],this.data.metadata.bounds[1][1]]) : 0));
31
29
 
32
- let y = this.isFeatureCollection ? mean(this.data.features, d => d.geometry.coordinates[0]) : (this.isPoint ? this.data.coordinates[0] : mean([this.data.metadata.bounds[0][0],this.data.metadata.bounds[1][0]]));
30
+ let y = this.isFeatureCollection ? mean(this.data.features, d => d.geometry.coordinates[0]) : (this.isPoint ? this.data.coordinates[0] : (this.isXY ? mean([this.data.metadata.bounds[0][0],this.data.metadata.bounds[1][0]]) : 0));
33
31
 
34
32
  // update self
35
33
  this.center = [x,y];
@@ -53,14 +51,28 @@ class VisualizationMap extends LinearGrid {
53
51
  // process data
54
52
  // update data object now that map exists
55
53
  this.Data.map = this.map;
56
- this.data = this.Data.update;
54
+ if (this.Data.data) this.data = this.Data.update;
57
55
 
58
56
  // render overlay
59
57
  this.generateChart();
60
58
 
59
+ // broadcast event
60
+ this.container.dispatch("map-change", {
61
+ bubbles: true
62
+ });
63
+
61
64
  });
62
65
  }
63
66
 
67
+ /**
68
+ * Generate main visualization, i.e. everything that sits inside the svg.
69
+ */
70
+ determineDataType() {
71
+ this.isFeatureCollection = this.data && this.data.features;
72
+ this.isPoint = this.data && this.data.coordinates && this.data.type.lower() == "point";
73
+ this.isXY = this.data && this.data.metadata && this.data.results;
74
+ }
75
+
64
76
  /**
65
77
  * Generate main visualization, i.e. everything that sits inside the svg.
66
78
  */
@@ -113,15 +125,18 @@ class VisualizationMap extends LinearGrid {
113
125
  L.tileLayer(this.tileserver).addTo(this.map);
114
126
 
115
127
  // determine bounding box
116
- let bounds = (this.isFeatureCollection || this.isPoint) ? L.geoJSON(this.Data.source).getBounds() : this.data.metadata.bounds;
128
+ let bounds = (this.isFeatureCollection || this.isPoint) ? L.geoJSON(this.Data.source).getBounds() : (this.isXY ? this.data.metadata.bounds : this.map.getBounds());
117
129
 
118
130
  // fit to bounds
119
131
  if (this.isFeatureCollection || this.isXY) {
120
132
  // several data points
121
133
  this.map.fitBounds(bounds);
122
- } else {
134
+ } else if (this.isPoint) {
123
135
  // zoom out if only provided single data point
124
136
  this.map.setView(bounds.getCenter(), this.map.getMaxZoom() / 2);
137
+ } else {
138
+ // no geo data provided so center world
139
+ this.map.setView(bounds.getCenter());
125
140
  }
126
141
 
127
142
  }
@@ -165,6 +180,9 @@ class VisualizationMap extends LinearGrid {
165
180
  this.Data.data = this.Data.update;
166
181
  this.data = this.Data.data;
167
182
 
183
+ // determine type of data object
184
+ this.determineDataType();
185
+
168
186
  // generate visualization
169
187
  this.generateChart();
170
188