@lgv/visualization-map 0.0.3 → 0.0.5

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/.gitlab-ci.yml CHANGED
@@ -6,10 +6,6 @@ stages:
6
6
  include:
7
7
  ###################################### GITLAB TEMPLATES ######################################
8
8
  - template: Security/SAST.gitlab-ci.yml
9
-
10
- # overwrites
11
- - project: "lgensinger/cicd-templates"
12
- file: "node/module/eslint-sast.yml"
13
9
 
14
10
  - project: "lgensinger/cicd-templates"
15
11
  file: "node/module/nodejs-scan-sast.yml"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lgv/visualization-map",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "type": "module",
5
5
  "description": "ES6 d3.js core visualization scaffold object and utilities for maps.",
6
6
  "main": "src/index.js",
@@ -21,10 +21,10 @@ import { configuration, configurationColor, configurationLayout } from "../confi
21
21
  */
22
22
  class Heatmap extends VisualizationMap {
23
23
 
24
- constructor(data, width=configurationLayout.width, height=configurationLayout.height, HeatLayout=null, label=configuration.branding, name=configuration.name) {
24
+ constructor(data, width=configurationLayout.width, height=configurationLayout.height, HeatLayout=null, tileServerUrl=configurationLayout.tileserver, label=configuration.branding, name=configuration.name) {
25
25
 
26
26
  // initialize inheritance
27
- super(data, width, height, HeatLayout ? HeatLayout : new HL(data), label, name);
27
+ super(data, width, height, HeatLayout ? HeatLayout : new HL(data), tileServerUrl, label, name);
28
28
 
29
29
  // initialize vega
30
30
  VegaDeckGl.use(vega, deck, layers, luma);
@@ -16,7 +16,7 @@ import { configuration, configurationLayout } from "../configuration.js";
16
16
  */
17
17
  class VisualizationMap extends LinearGrid {
18
18
 
19
- constructor(data, width=configurationLayout.width, height=configurationLayout.height, MapData=null, label=configuration.branding, name=configuration.name) {
19
+ constructor(data, width=configurationLayout.width, height=configurationLayout.height, MapData=null, tileServerUrl=configurationLayout.tileserver, label=configuration.branding, name=configuration.name) {
20
20
 
21
21
  // initialize inheritance
22
22
  super(data, width, height, MapData, label, name);
@@ -32,7 +32,7 @@ class VisualizationMap extends LinearGrid {
32
32
  // update self
33
33
  this.center = [x,y];
34
34
  this.map = null;
35
- this.tileserver = configurationLayout.tileserver;
35
+ this.tileServerUrl = tileServerUrl;
36
36
  this.zoom = 1;
37
37
 
38
38
  }
@@ -68,11 +68,32 @@ class VisualizationMap extends LinearGrid {
68
68
  * Generate main visualization, i.e. everything that sits inside the svg.
69
69
  */
70
70
  determineDataType() {
71
- this.isFeatureCollection = this.data && this.data.features;
71
+ this.isFeatureCollection = this.data && this.Data.source.features;
72
72
  this.isPoint = this.data && this.data.coordinates && this.data.type.lower() == "point";
73
73
  this.isXY = this.data && this.data.metadata && this.data.results;
74
74
  }
75
75
 
76
+ /**
77
+ * Fit map tightly to data boundary.
78
+ */
79
+ fitToData() {
80
+
81
+ // determine bounding box
82
+ let bounds = (this.isFeatureCollection || this.isPoint) ? L.geoJSON(this.Data.source).getBounds() : (this.isXY ? this.data.metadata.bounds : this.map.getBounds());
83
+
84
+ // fit to bounds
85
+ if (this.isFeatureCollection || this.isXY) {
86
+ // several data points
87
+ this.map.fitBounds(bounds);
88
+ } else if (this.isPoint) {
89
+ // zoom out if only provided single data point
90
+ this.map.setView(bounds.getCenter(), this.map.getMaxZoom() / 2);
91
+ } else {
92
+ // no geo data provided so center world
93
+ this.map.setView(bounds.getCenter());
94
+ }
95
+ }
96
+
76
97
  /**
77
98
  * Generate main visualization, i.e. everything that sits inside the svg.
78
99
  */
@@ -122,22 +143,10 @@ class VisualizationMap extends LinearGrid {
122
143
  this.attachEvents();
123
144
 
124
145
  // update tile server
125
- L.tileLayer(this.tileserver).addTo(this.map);
126
-
127
- // determine bounding box
128
- let bounds = (this.isFeatureCollection || this.isPoint) ? L.geoJSON(this.Data.source).getBounds() : (this.isXY ? this.data.metadata.bounds : this.map.getBounds());
146
+ L.tileLayer(this.tileServerUrl).addTo(this.map);
129
147
 
130
148
  // fit to bounds
131
- if (this.isFeatureCollection || this.isXY) {
132
- // several data points
133
- this.map.fitBounds(bounds);
134
- } else if (this.isPoint) {
135
- // zoom out if only provided single data point
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());
140
- }
149
+ this.fitToData();
141
150
 
142
151
  }
143
152
 
@@ -186,6 +195,9 @@ class VisualizationMap extends LinearGrid {
186
195
  // generate visualization
187
196
  this.generateChart();
188
197
 
198
+ // fit to bounds
199
+ this.fitToData();
200
+
189
201
  }
190
202
 
191
203
  }