@axdspub/axiom-charts 0.2.0-alpha-react19-compatible → 1.0.0-alpha-0.0.0

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.
@@ -1,4 +1,4 @@
1
- var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Selection, d3, d3Scale, d3Axis, d3Shape, reactDom, axiomUiUtilities) {
1
+ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Selection, d3, d3Scale, d3Axis, d3Shape, reactDom, axiomUiUtilities, axiomMaps) {
2
2
  'use strict';
3
3
 
4
4
  function _interopNamespaceDefault(e) {
@@ -38,7 +38,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
38
38
  /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
39
39
 
40
40
 
41
- function __awaiter$1(thisArg, _arguments, P, generator) {
41
+ function __awaiter(thisArg, _arguments, P, generator) {
42
42
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
43
43
  return new (P || (P = Promise))(function (resolve, reject) {
44
44
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
@@ -190,7 +190,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
190
190
  return undefined;
191
191
  }
192
192
  getDomain(axis) {
193
- return __awaiter$1(this, void 0, void 0, function* () {
193
+ return __awaiter(this, void 0, void 0, function* () {
194
194
  var _a;
195
195
  const data = yield this.getData();
196
196
  const parsedData = ((_a = data === null || data === void 0 ? void 0 : data.parsed) === null || _a === void 0 ? void 0 : _a.data) !== undefined ? data.parsed.data : [];
@@ -206,7 +206,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
206
206
  });
207
207
  }
208
208
  getDomainForDisplay(axis) {
209
- return __awaiter$1(this, void 0, void 0, function* () {
209
+ return __awaiter(this, void 0, void 0, function* () {
210
210
  const domain = yield this.getDomain(axis);
211
211
  return domain.map(d => {
212
212
  var _a, _b;
@@ -223,25 +223,25 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
223
223
  });
224
224
  }
225
225
  getXDomain() {
226
- return __awaiter$1(this, void 0, void 0, function* () {
226
+ return __awaiter(this, void 0, void 0, function* () {
227
227
  const domain = yield this.getDomain('x');
228
228
  return domain;
229
229
  });
230
230
  }
231
231
  getXDomainForDisplay() {
232
- return __awaiter$1(this, void 0, void 0, function* () {
232
+ return __awaiter(this, void 0, void 0, function* () {
233
233
  const domain = yield this.getDomainForDisplay('x');
234
234
  return domain;
235
235
  });
236
236
  }
237
237
  getYDomain() {
238
- return __awaiter$1(this, void 0, void 0, function* () {
238
+ return __awaiter(this, void 0, void 0, function* () {
239
239
  const domain = yield this.getDomain('y');
240
240
  return domain;
241
241
  });
242
242
  }
243
243
  getYDomainForDisplay() {
244
- return __awaiter$1(this, void 0, void 0, function* () {
244
+ return __awaiter(this, void 0, void 0, function* () {
245
245
  const domain = yield this.getDomainForDisplay('y');
246
246
  return domain;
247
247
  });
@@ -250,7 +250,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
250
250
 
251
251
  } */
252
252
  draw() {
253
- return __awaiter$1(this, void 0, void 0, function* () {
253
+ return __awaiter(this, void 0, void 0, function* () {
254
254
  this.data = yield this.getData();
255
255
  });
256
256
  }
@@ -4720,13 +4720,13 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
4720
4720
  onDraw() {
4721
4721
  }
4722
4722
  getDomainForPlotImplementations(plotImplementations, axis) {
4723
- return __awaiter$1(this, void 0, void 0, function* () {
4723
+ return __awaiter(this, void 0, void 0, function* () {
4724
4724
  var _a, _b;
4725
4725
  const overrides = (_b = (_a = this.settings) === null || _a === void 0 ? void 0 : _a.axes) === null || _b === void 0 ? void 0 : _b[String(axis)];
4726
4726
  if ((overrides === null || overrides === void 0 ? void 0 : overrides.domain) !== undefined) {
4727
4727
  return overrides.domain;
4728
4728
  }
4729
- const domains = yield Promise.all(plotImplementations.map((p) => __awaiter$1(this, void 0, void 0, function* () {
4729
+ const domains = yield Promise.all(plotImplementations.map((p) => __awaiter(this, void 0, void 0, function* () {
4730
4730
  const domain = yield p.getDomain(axis);
4731
4731
  return domain;
4732
4732
  })));
@@ -4734,13 +4734,13 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
4734
4734
  });
4735
4735
  }
4736
4736
  getDomainForDisplayFromPlotImplementations(plotImplementations, axis) {
4737
- return __awaiter$1(this, void 0, void 0, function* () {
4737
+ return __awaiter(this, void 0, void 0, function* () {
4738
4738
  var _a, _b;
4739
4739
  const overrides = (_b = (_a = this.settings) === null || _a === void 0 ? void 0 : _a.axes) === null || _b === void 0 ? void 0 : _b[String(axis)];
4740
4740
  if ((overrides === null || overrides === void 0 ? void 0 : overrides.domain) !== undefined) {
4741
4741
  return overrides.domain;
4742
4742
  }
4743
- const domains = yield Promise.all(plotImplementations.map((p) => __awaiter$1(this, void 0, void 0, function* () {
4743
+ const domains = yield Promise.all(plotImplementations.map((p) => __awaiter(this, void 0, void 0, function* () {
4744
4744
  const domain = yield p.getDomainForDisplay(axis);
4745
4745
  return domain;
4746
4746
  })));
@@ -4819,7 +4819,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
4819
4819
  this.runtime.resizeEventHandler();
4820
4820
  }
4821
4821
  init() {
4822
- return __awaiter$1(this, arguments, void 0, function* (drawImmediately = false) {
4822
+ return __awaiter(this, arguments, void 0, function* (drawImmediately = false) {
4823
4823
  var _a;
4824
4824
  this.runtime.resizeEventHandler = debounce(() => { this.onResize(this.runtime.prevWidth, this.runtime.prevHeight); }, 1000);
4825
4825
  window.addEventListener('resize', () => { this.debouncedResize(); });
@@ -4842,7 +4842,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
4842
4842
  const yGroups = this.getPlotImplementationGroups(this.plotImplementations, 'y');
4843
4843
  const yAxes = [];
4844
4844
  const yRange = this.getYRange(chartHeight);
4845
- yield Promise.all(Object.keys(yGroups).map((key, index) => __awaiter$1(this, void 0, void 0, function* () {
4845
+ yield Promise.all(Object.keys(yGroups).map((key, index) => __awaiter(this, void 0, void 0, function* () {
4846
4846
  const group = yGroups[key];
4847
4847
  const p = group.plots;
4848
4848
  // const domain = await this.getDomainForPlotImplementations(yGroups[key].plots, EChartAxes.y)
@@ -4874,7 +4874,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
4874
4874
  const chartWidth = this.getChartWidth();
4875
4875
  const xRange = this.getXRange(chartWidth);
4876
4876
  const xAxes = [];
4877
- yield Promise.all(Object.keys(xGroups).map((key, index) => __awaiter$1(this, void 0, void 0, function* () {
4877
+ yield Promise.all(Object.keys(xGroups).map((key, index) => __awaiter(this, void 0, void 0, function* () {
4878
4878
  const group = xGroups[key];
4879
4879
  const p = group.plots;
4880
4880
  const domain = yield this.getDomainForPlotImplementations(p, exports.EChartAxes.x);
@@ -4915,10 +4915,10 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
4915
4915
  adjustYAxis() {
4916
4916
  }
4917
4917
  draw() {
4918
- return __awaiter$1(this, void 0, void 0, function* () {
4918
+ return __awaiter(this, void 0, void 0, function* () {
4919
4919
  const plotImplementations = this.plotImplementations;
4920
4920
  if (plotImplementations !== undefined) {
4921
- yield Promise.all(plotImplementations.map((p) => __awaiter$1(this, void 0, void 0, function* () {
4921
+ yield Promise.all(plotImplementations.map((p) => __awaiter(this, void 0, void 0, function* () {
4922
4922
  yield p.draw();
4923
4923
  })));
4924
4924
  if (this.onChartDrew !== undefined) {
@@ -5404,7 +5404,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
5404
5404
  const _super = Object.create(null, {
5405
5405
  onLegendReady: { get: () => super.onLegendReady }
5406
5406
  });
5407
- return __awaiter$1(this, void 0, void 0, function* () {
5407
+ return __awaiter(this, void 0, void 0, function* () {
5408
5408
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
5409
5409
  const style = this.getStyle();
5410
5410
  if (this.parsedData === undefined) {
@@ -5572,7 +5572,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
5572
5572
  const _super = Object.create(null, {
5573
5573
  onLegendReady: { get: () => super.onLegendReady }
5574
5574
  });
5575
- return __awaiter$1(this, void 0, void 0, function* () {
5575
+ return __awaiter(this, void 0, void 0, function* () {
5576
5576
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
5577
5577
  const style = this.style !== undefined ? this.style : {};
5578
5578
  const data = yield this.getData();
@@ -5705,7 +5705,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
5705
5705
  const _super = Object.create(null, {
5706
5706
  onLegendReady: { get: () => super.onLegendReady }
5707
5707
  });
5708
- return __awaiter$1(this, void 0, void 0, function* () {
5708
+ return __awaiter(this, void 0, void 0, function* () {
5709
5709
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
5710
5710
  const style = this.style !== undefined ? this.style : {};
5711
5711
  const data = yield this.getData();
@@ -5823,7 +5823,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
5823
5823
  const _super = Object.create(null, {
5824
5824
  onLegendReady: { get: () => super.onLegendReady }
5825
5825
  });
5826
- return __awaiter$1(this, void 0, void 0, function* () {
5826
+ return __awaiter(this, void 0, void 0, function* () {
5827
5827
  var _a, _b, _c, _d, _e;
5828
5828
  const dataResponse = yield this.getData();
5829
5829
  const parsedData = (_a = dataResponse === null || dataResponse === void 0 ? void 0 : dataResponse.parsed) === null || _a === void 0 ? void 0 : _a.data;
@@ -6041,7 +6041,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
6041
6041
  const _super = Object.create(null, {
6042
6042
  onLegendReady: { get: () => super.onLegendReady }
6043
6043
  });
6044
- return __awaiter$1(this, void 0, void 0, function* () {
6044
+ return __awaiter(this, void 0, void 0, function* () {
6045
6045
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
6046
6046
  const style = this.style !== undefined ? this.style : {};
6047
6047
  const data = yield this.getData();
@@ -6640,7 +6640,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
6640
6640
  const _super = Object.create(null, {
6641
6641
  init: { get: () => super.init }
6642
6642
  });
6643
- return __awaiter$1(this, arguments, void 0, function* (drawImmediately = false) {
6643
+ return __awaiter(this, arguments, void 0, function* (drawImmediately = false) {
6644
6644
  yield _super.init.call(this, drawImmediately);
6645
6645
  this.attachChartElements();
6646
6646
  // this.adjustYAxis()
@@ -6658,7 +6658,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
6658
6658
  const _super = Object.create(null, {
6659
6659
  onLegendReady: { get: () => super.onLegendReady }
6660
6660
  });
6661
- return __awaiter$1(this, void 0, void 0, function* () {
6661
+ return __awaiter(this, void 0, void 0, function* () {
6662
6662
  var _a, _b, _c, _d, _e, _f, _g, _h;
6663
6663
  const style = this.style !== undefined ? this.style : {};
6664
6664
  const data = yield this.getData();
@@ -6727,7 +6727,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
6727
6727
  const _super = Object.create(null, {
6728
6728
  onLegendReady: { get: () => super.onLegendReady }
6729
6729
  });
6730
- return __awaiter$1(this, void 0, void 0, function* () {
6730
+ return __awaiter(this, void 0, void 0, function* () {
6731
6731
  var _a, _b, _c, _d, _e, _f, _g, _h;
6732
6732
  // const style = this.style !== undefined ? this.style : {}
6733
6733
  const data = yield this.getData();
@@ -6797,7 +6797,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
6797
6797
  const _super = Object.create(null, {
6798
6798
  onLegendReady: { get: () => super.onLegendReady }
6799
6799
  });
6800
- return __awaiter$1(this, void 0, void 0, function* () {
6800
+ return __awaiter(this, void 0, void 0, function* () {
6801
6801
  var _a, _b, _c, _d, _e, _f, _g, _h;
6802
6802
  const style = this.style !== undefined ? this.style : {};
6803
6803
  const data = yield this.getData();
@@ -6881,7 +6881,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
6881
6881
  this.directionMode = 'to';
6882
6882
  }
6883
6883
  setStackedData() {
6884
- return __awaiter$1(this, void 0, void 0, function* () {
6884
+ return __awaiter(this, void 0, void 0, function* () {
6885
6885
  var _a, _b, _c;
6886
6886
  let parsedData = [];
6887
6887
  if (this.data === undefined) {
@@ -6895,7 +6895,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
6895
6895
  });
6896
6896
  }
6897
6897
  getDomain(_axis) {
6898
- return __awaiter$1(this, void 0, void 0, function* () {
6898
+ return __awaiter(this, void 0, void 0, function* () {
6899
6899
  yield this.setStackedData();
6900
6900
  if (this.stacks === undefined)
6901
6901
  return [0, 10];
@@ -6935,7 +6935,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
6935
6935
  const _super = Object.create(null, {
6936
6936
  onLegendReady: { get: () => super.onLegendReady }
6937
6937
  });
6938
- return __awaiter$1(this, void 0, void 0, function* () {
6938
+ return __awaiter(this, void 0, void 0, function* () {
6939
6939
  var _a, _b, _c, _d, _e, _f, _g;
6940
6940
  const xAccessors = this.getAccessorsAtAxis('x');
6941
6941
  const xAccessor = this.getAccessorAtAxis('x');
@@ -7201,7 +7201,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
7201
7201
 
7202
7202
  class Box extends PlotRoot {
7203
7203
  draw() {
7204
- return __awaiter$1(this, void 0, void 0, function* () {
7204
+ return __awaiter(this, void 0, void 0, function* () {
7205
7205
  console.log('line: draw method not implemented');
7206
7206
  });
7207
7207
  }
@@ -7209,7 +7209,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
7209
7209
 
7210
7210
  class LineBase extends PlotRoot {
7211
7211
  draw() {
7212
- return __awaiter$1(this, void 0, void 0, function* () {
7212
+ return __awaiter(this, void 0, void 0, function* () {
7213
7213
  console.log('line: draw method not implemented');
7214
7214
  });
7215
7215
  }
@@ -10523,14 +10523,14 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
10523
10523
  }
10524
10524
  };
10525
10525
  };
10526
- const getDataContext = () => __awaiter$1(void 0, void 0, void 0, function* () {
10526
+ const getDataContext = () => __awaiter(void 0, void 0, void 0, function* () {
10527
10527
  const d = yield (yield fetch('https://oikos.axds.co/rest/context')).json();
10528
10528
  return parseOikosContext(d);
10529
10529
  });
10530
10530
  const useDataContext = () => {
10531
10531
  const queryResult = useQuery({
10532
10532
  queryKey: ['dataContext'],
10533
- queryFn: () => __awaiter$1(void 0, void 0, void 0, function* () {
10533
+ queryFn: () => __awaiter(void 0, void 0, void 0, function* () {
10534
10534
  const d = yield getDataContext();
10535
10535
  return d;
10536
10536
  }),
@@ -10545,7 +10545,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
10545
10545
  monthly: 'months'
10546
10546
  };
10547
10547
  const sensorParsers = {
10548
- timeSeries: (ob, args) => __awaiter$1(void 0, void 0, void 0, function* () {
10548
+ timeSeries: (ob, args) => __awaiter(void 0, void 0, void 0, function* () {
10549
10549
  const getNumericSensorValue = (row, metadataRow) => {
10550
10550
  if (metadataRow === undefined || metadataRow === null) {
10551
10551
  return null;
@@ -10608,7 +10608,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
10608
10608
  properties: {}
10609
10609
  };
10610
10610
  }),
10611
- climatology: (ob_1, _a) => __awaiter$1(void 0, [ob_1, _a], void 0, function* (ob, { xBin, xBounds }) {
10611
+ climatology: (ob_1, _a) => __awaiter(void 0, [ob_1, _a], void 0, function* (ob, { xBin, xBounds }) {
10612
10612
  const climatologyBin = climatologyBinToBinKey[xBin];
10613
10613
  const data = ob.climatology[climatologyBin] !== undefined ? ob.climatology[climatologyBin] : {};
10614
10614
  const def = xBinDefinitions[xBin];
@@ -11053,11 +11053,11 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
11053
11053
  },
11054
11054
  createFetchAndParse: (p) => {
11055
11055
  const xBin = getXBin(p);
11056
- return (signal) => __awaiter$1(void 0, void 0, void 0, function* () {
11056
+ return (signal) => __awaiter(void 0, void 0, void 0, function* () {
11057
11057
  var _a;
11058
11058
  const queryProps = Object.assign(Object.assign({ stationId: data.id, parameterGroupId,
11059
11059
  deviceIds }, p), { xBin });
11060
- const d = yield (yield fetch(makeSensorTimeSeriesRequest(queryProps), { signal }).then((r) => __awaiter$1(void 0, void 0, void 0, function* () { return yield r.json(); }))).data.groupedFeeds[0];
11060
+ const d = yield (yield fetch(makeSensorTimeSeriesRequest(queryProps), { signal }).then((r) => __awaiter(void 0, void 0, void 0, function* () { return yield r.json(); }))).data.groupedFeeds[0];
11061
11061
  const timeSeries = yield sensorParsers.timeSeries(d, { binSize: ((_a = xBinDefinitions[xBin]) === null || _a === void 0 ? void 0 : _a.resolution) !== undefined ? xBinDefinitions[xBin].resolution : Object.values(xBinDefinitions).map(d => d.resolution).sort((a, b) => a - b)[0] });
11062
11062
  if (onDataLoad !== undefined) {
11063
11063
  onDataLoad(timeSeries, queryProps, makeQueryKeyString(p, xBin));
@@ -11087,10 +11087,10 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
11087
11087
  },
11088
11088
  createFetchAndParse: (p) => {
11089
11089
  const xBin = getXBin(p);
11090
- return (signal) => __awaiter$1(void 0, void 0, void 0, function* () {
11090
+ return (signal) => __awaiter(void 0, void 0, void 0, function* () {
11091
11091
  const d = climatology !== undefined
11092
11092
  ? Object.assign({}, climatology) : yield (yield fetch(makeSensorSeasonalStatsRequest(Object.assign(Object.assign({ stationId: data.id, parameterGroupId,
11093
- deviceIds }, p), { xBin })), { signal }).then((r) => __awaiter$1(void 0, void 0, void 0, function* () { return yield r.json(); })));
11093
+ deviceIds }, p), { xBin })), { signal }).then((r) => __awaiter(void 0, void 0, void 0, function* () { return yield r.json(); })));
11094
11094
  if (climatology === undefined) {
11095
11095
  setClimatology(d);
11096
11096
  }
@@ -11114,7 +11114,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
11114
11114
  var _a, _b, _c, _d;
11115
11115
  const { data, isLoading, isError } = useQuery({
11116
11116
  queryKey: [stationId],
11117
- queryFn: () => __awaiter$1(void 0, void 0, void 0, function* () {
11117
+ queryFn: () => __awaiter(void 0, void 0, void 0, function* () {
11118
11118
  const d = yield (yield fetch(makeAPIStationMetadataRequest(stationId))).json();
11119
11119
  return d.data.stations[0];
11120
11120
  })
@@ -11253,7 +11253,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
11253
11253
  return {
11254
11254
  enabled: loader.getIsEnabled(),
11255
11255
  queryKey: [loader.makeQueryKey()],
11256
- queryFn: (_a) => __awaiter$1(void 0, [_a], void 0, function* ({ signal }) {
11256
+ queryFn: (_a) => __awaiter(void 0, [_a], void 0, function* ({ signal }) {
11257
11257
  const data = yield loader.fetchAndParse(signal);
11258
11258
  const newPlots = loader.makePlots({ data, xDomain: tempXBounds });
11259
11259
  console.log(`Loaded and setting:${String(loader.id)}`, newPlots);
@@ -11365,1177 +11365,6 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
11365
11365
  }));
11366
11366
  });
11367
11367
 
11368
- /******************************************************************************
11369
- Copyright (c) Microsoft Corporation.
11370
-
11371
- Permission to use, copy, modify, and/or distribute this software for any
11372
- purpose with or without fee is hereby granted.
11373
-
11374
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
11375
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11376
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11377
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11378
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
11379
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
11380
- PERFORMANCE OF THIS SOFTWARE.
11381
- ***************************************************************************** */
11382
- /* global Reflect, Promise, SuppressedError, Symbol */
11383
-
11384
- var extendStatics = function(d, b) {
11385
- extendStatics = Object.setPrototypeOf ||
11386
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11387
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
11388
- return extendStatics(d, b);
11389
- };
11390
-
11391
- function __extends(d, b) {
11392
- if (typeof b !== "function" && b !== null)
11393
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11394
- extendStatics(d, b);
11395
- function __() { this.constructor = d; }
11396
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
11397
- }
11398
-
11399
- var __assign = function() {
11400
- __assign = Object.assign || function __assign(t) {
11401
- for (var s, i = 1, n = arguments.length; i < n; i++) {
11402
- s = arguments[i];
11403
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
11404
- }
11405
- return t;
11406
- };
11407
- return __assign.apply(this, arguments);
11408
- };
11409
-
11410
- function __awaiter(thisArg, _arguments, P, generator) {
11411
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
11412
- return new (P || (P = Promise))(function (resolve, reject) {
11413
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
11414
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11415
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
11416
- step((generator = generator.apply(thisArg, _arguments || [])).next());
11417
- });
11418
- }
11419
-
11420
- function __generator(thisArg, body) {
11421
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
11422
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
11423
- function verb(n) { return function (v) { return step([n, v]); }; }
11424
- function step(op) {
11425
- if (f) throw new TypeError("Generator is already executing.");
11426
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
11427
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
11428
- if (y = 0, t) op = [op[0] & 2, t.value];
11429
- switch (op[0]) {
11430
- case 0: case 1: t = op; break;
11431
- case 4: _.label++; return { value: op[1], done: false };
11432
- case 5: _.label++; y = op[1]; op = [0]; continue;
11433
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
11434
- default:
11435
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
11436
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
11437
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
11438
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
11439
- if (t[2]) _.ops.pop();
11440
- _.trys.pop(); continue;
11441
- }
11442
- op = body.call(thisArg, _);
11443
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
11444
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
11445
- }
11446
- }
11447
-
11448
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
11449
- var e = new Error(message);
11450
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
11451
- };
11452
-
11453
- var mapBoxToken = 'pk.eyJ1Ijoic2hhbmUtYXhpb20iLCJhIjoiQTQ1U0FpTSJ9.vHiaSADEGTCnUJPZR5HZcg';
11454
- var getToken = function () { return mapBoxToken; };
11455
-
11456
- var mapBoxOptions = {
11457
- type: 'tile',
11458
- attribution: 'Base layer &copy; <a href="http://mapbox.com/">MapBox</a>',
11459
- options: {
11460
- reuseTiles: true,
11461
- subdomains: ['a', 'b'],
11462
- tileSize: 512,
11463
- zoomOffset: -1
11464
- }
11465
- };
11466
- function makeMapBoxUrl(ln) {
11467
- return "https://{s}.api.mapbox.com/styles/v1/".concat(ln, "/tiles/{z}/{x}/{y}?access_token=").concat(getToken());
11468
- }
11469
- var baseLayers = [
11470
- __assign(__assign({}, mapBoxOptions), { id: 'mb_bathymetry', type: 'tile', zIndex: 0, isBaseLayer: true, url: makeMapBoxUrl('shane-axiom/cknm3veja3cjw17o5axf7c1g2'), label: 'Bathymetry' }),
11471
- {
11472
- id: 'osm',
11473
- type: 'tile',
11474
- url: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
11475
- label: 'OpenStreetMap',
11476
- attribution: 'Map data &copy; <a href=http://openstreetmap.org>OpenStreetMap</a> contributors',
11477
- zIndex: 0,
11478
- isBaseLayer: true,
11479
- options: {
11480
- subdomains: ['a', 'b', 'c']
11481
- }
11482
- },
11483
- __assign(__assign({}, mapBoxOptions), { id: 'hybrid', type: 'tile', zIndex: 0, isBaseLayer: true, url: makeMapBoxUrl('shane-axiom/ck7mgchpc0sgk1iqk78q1wy4w'), label: 'Hybrid' }),
11484
- {
11485
- label: 'Black and White',
11486
- id: 'bw',
11487
- url: '//{s}.data.axds.co/gs/gshhg/wms?bgcolor=0xC0C0C0',
11488
- type: 'wms',
11489
- zIndex: 0,
11490
- isBaseLayer: true,
11491
- options: {
11492
- subdomains: ['30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40']
11493
- },
11494
- params: {
11495
- layers: 'gshhs_solid_bglite_full',
11496
- format: 'image/jpeg',
11497
- transparent: false
11498
- }
11499
- }
11500
- ];
11501
- baseLayers.forEach(function (l) {
11502
- var _a;
11503
- if ((l.urls == null) && (((_a = l === null || l === void 0 ? void 0 : l.options) === null || _a === void 0 ? void 0 : _a.subdomains) != null)) {
11504
- if (l.type === undefined || l.type === null) {
11505
- l.type = 'tile';
11506
- }
11507
- l.urls = l.options.subdomains.map(function (s) {
11508
- return l.url.replace('{s}', String(s));
11509
- });
11510
- }
11511
- });
11512
- var baseLayersMapped = Object.fromEntries(baseLayers.map(function (b) { return [b.id, b]; }));
11513
-
11514
- var LatLonBounds = /** @class */ (function () {
11515
- function LatLonBounds(props) {
11516
- this.sw = __assign({}, props.sw);
11517
- this.ne = __assign({}, props.ne);
11518
- }
11519
- LatLonBounds.prototype.set = function (props) {
11520
- this.sw = __assign({}, props.sw);
11521
- this.ne = __assign({}, props.ne);
11522
- };
11523
- LatLonBounds.prototype.get = function () {
11524
- return {
11525
- sw: __assign({}, this.sw),
11526
- ne: __assign({}, this.ne)
11527
- };
11528
- };
11529
- LatLonBounds.prototype.getCenter = function () {
11530
- return {
11531
- lat: (this.sw.lat + this.ne.lat) / 2,
11532
- lon: (this.sw.lon + this.ne.lon) / 2
11533
- };
11534
- };
11535
- LatLonBounds.prototype.fromArray = function (a) {
11536
- this.set({
11537
- sw: {
11538
- lon: a[0],
11539
- lat: a[1]
11540
- },
11541
- ne: {
11542
- lon: a[2],
11543
- lat: a[3]
11544
- }
11545
- });
11546
- };
11547
- LatLonBounds.prototype.toArray = function () {
11548
- // [-78, 33, -74, 35]
11549
- var _a = this, sw = _a.sw, ne = _a.ne;
11550
- return [
11551
- sw.lon,
11552
- sw.lat,
11553
- ne.lon,
11554
- ne.lat
11555
- ];
11556
- };
11557
- LatLonBounds.prototype.toStr = function () {
11558
- return this.toArray().join(',');
11559
- };
11560
- LatLonBounds.prototype.toGeoJson = function () {
11561
- var _a = this, sw = _a.sw, ne = _a.ne;
11562
- return {
11563
- type: 'FeatureCollection',
11564
- features: [
11565
- {
11566
- properties: {
11567
- soutWestLat: sw.lat,
11568
- southWestLon: sw.lon,
11569
- northEastLat: ne.lat,
11570
- northEastLon: ne.lon
11571
- },
11572
- type: 'Feature',
11573
- geometry: {
11574
- type: 'Polygon',
11575
- coordinates: [[
11576
- [sw.lon, sw.lat],
11577
- [sw.lon, ne.lat],
11578
- [ne.lon, ne.lat],
11579
- [ne.lon, sw.lat],
11580
- [sw.lon, sw.lat]
11581
- ]]
11582
- }
11583
- }
11584
- ]
11585
- };
11586
- };
11587
- LatLonBounds.prototype.toWKT = function () {
11588
- var _a = this, sw = _a.sw, ne = _a.ne;
11589
- return "POLYGON ((".concat(sw.lon, " ").concat(sw.lat, ", ").concat(ne.lon, " ").concat(sw.lat, ", ").concat(ne.lon, " ").concat(ne.lat, ", ").concat(sw.lon, " ").concat(ne.lat, ", ").concat(sw.lon, " ").concat(sw.lat, "))");
11590
- };
11591
- return LatLonBounds;
11592
- }());
11593
-
11594
- var MapStateEvent = /** @class */ (function (_super) {
11595
- __extends(MapStateEvent, _super);
11596
- function MapStateEvent() {
11597
- return _super !== null && _super.apply(this, arguments) || this;
11598
- }
11599
- return MapStateEvent;
11600
- }(axiomUiUtilities.EventWithData));
11601
- var MapLoadedEvent = /** @class */ (function (_super) {
11602
- __extends(MapLoadedEvent, _super);
11603
- function MapLoadedEvent() {
11604
- return _super !== null && _super.apply(this, arguments) || this;
11605
- }
11606
- return MapLoadedEvent;
11607
- }(axiomUiUtilities.EventWithData));
11608
- /** @class */ ((function (_super) {
11609
- __extends(MapDrawEvent, _super);
11610
- function MapDrawEvent() {
11611
- return _super !== null && _super.apply(this, arguments) || this;
11612
- }
11613
- return MapDrawEvent;
11614
- })(axiomUiUtilities.EventWithData));
11615
- /** @class */ ((function (_super) {
11616
- __extends(MapRoot, _super);
11617
- function MapRoot(props) {
11618
- var _this = _super.call(this) || this;
11619
- _this.runtime = {};
11620
- _this.mapLibraryKey = props.mapLibraryKey === undefined ? 'leaflet' : props.mapLibraryKey;
11621
- if (props.mapLibrary != null) {
11622
- _this.mapLibrary = props.mapLibrary;
11623
- }
11624
- if (props.element != null) {
11625
- _this.element = props.element;
11626
- }
11627
- if (props.center != null) {
11628
- _this.center = props.center;
11629
- }
11630
- if (props.zoom !== undefined) {
11631
- _this.zoom = props.zoom;
11632
- }
11633
- if (props.baseLayerKey !== undefined) {
11634
- _this.baseLayerKey = props.baseLayerKey;
11635
- }
11636
- if (props.baseLayer != null) {
11637
- _this.baseLayer = props.baseLayer;
11638
- }
11639
- if (props.layers !== undefined) {
11640
- _this.layers = props.layers;
11641
- }
11642
- else {
11643
- _this.layers = [];
11644
- }
11645
- if (props.tools != null) {
11646
- _this.tools = props.tools;
11647
- }
11648
- if (props.projection != null) {
11649
- _this.projection = props.projection;
11650
- }
11651
- _this.toolInstances = {};
11652
- if (props.onMapLoaded != null) {
11653
- _this.onMapLoaded(props.onMapLoaded);
11654
- }
11655
- if (props.onMapViewChange !== null) {
11656
- _this.onMapViewChangeCallBack = props.onMapViewChange;
11657
- }
11658
- if (props.onMapMoveStart !== null) {
11659
- _this.onMapMoveStartCallBack = props.onMapMoveStart;
11660
- }
11661
- if (props.onFlyToStart !== null) {
11662
- _this.onFlyToStartCallBack = props.onFlyToStart;
11663
- }
11664
- if (props.onFlyToEnd !== null) {
11665
- _this.onFlyToEndCallBack = props.onFlyToEnd;
11666
- }
11667
- if (_this.element != null) {
11668
- _this.initMap();
11669
- }
11670
- return _this;
11671
- }
11672
- MapRoot.prototype.reloadLayers = function (layers) {
11673
- if (this.layers === undefined)
11674
- return;
11675
- this.removeLayers(this.layers);
11676
- this.addLayers(layers);
11677
- };
11678
- /**
11679
- *
11680
- * (eventType: string, callback: IEventCallback): void
11681
- (eventType: 'drawstart', callback: IMapDrawCallback): void
11682
- (eventType: 'drawend', callback: IMapDrawCallback): void
11683
- (eventType: 'drawupdate', callback: IMapDrawCallback): void
11684
- (eventType: 'drawprogress', callback: IMapDrawCallback): void
11685
- (eventType: 'loaded', callback: IMapStateCallback): void
11686
- (eventType: 'moveend', callback: IMapStateCallback): void
11687
- (eventType: 'pointermove', callback: IMapPointerMoveCallback): void
11688
- (eventType: 'pointerselect', callback: IMapPointerSelectCallback): void
11689
- */
11690
- MapRoot.prototype.getDefaultLatLon = function () {
11691
- return { lat: 0, lon: 0 };
11692
- };
11693
- MapRoot.prototype.pointToLatLon = function (pt) {
11694
- console.log("pointToLatLon not yet implemented on ".concat(this.getMapLibraryName()));
11695
- return this.getDefaultLatLon();
11696
- };
11697
- MapRoot.prototype.latLonToPoint = function (ll) {
11698
- console.log("latLonToPoint not yet implemented on ".concat(this.getMapLibraryName()));
11699
- return { x: 0, y: 0 };
11700
- };
11701
- MapRoot.prototype.mapPointToWindowPoint = function (point) {
11702
- var rect = this.element !== undefined ? this.element.getBoundingClientRect() : { left: 0, top: 0 };
11703
- return {
11704
- x: point.x + rect.left,
11705
- y: point.y + rect.top
11706
- };
11707
- };
11708
- MapRoot.prototype.dispatchMapLoadedEvent = function () {
11709
- this.dispatchEventWithData('loaded');
11710
- };
11711
- MapRoot.prototype.dispatchMapMoveStartEvent = function (e) {
11712
- this.dispatchEventWithData('movestart', { mapState: this.getMapState() }, e);
11713
- };
11714
- MapRoot.prototype.dispatchMapMoveEvent = function (e) {
11715
- this.dispatchEventWithData('moveend', { mapState: this.getMapState() }, e);
11716
- };
11717
- MapRoot.prototype.dispatchMapClickEvent = function (e) {
11718
- this.dispatchEventWithData('mapclick');
11719
- };
11720
- MapRoot.prototype.dispatchFlyToStartEvent = function (e) {
11721
- this.dispatchEventWithData('flytostart', { mapState: this.getMapState() }, e);
11722
- };
11723
- MapRoot.prototype.dispatchFlyToEndEvent = function (e) {
11724
- this.dispatchEventWithData('flytoend', { mapState: this.getMapState() }, e);
11725
- };
11726
- MapRoot.prototype.dispatchPointerMove = function (point, latlon, extraData, nativeEvent) {
11727
- var data = point !== undefined
11728
- ? __assign({ windowPoint: this.mapPointToWindowPoint(point), point: point, latlon: this.pointToLatLon(point) }, extraData) : undefined;
11729
- this.dispatchEventWithData('pointermove', data, nativeEvent);
11730
- };
11731
- MapRoot.prototype.dispatchPointerSelect = function (point, latlon, nativeEvent) {
11732
- var windowPoint = this.mapPointToWindowPoint(point);
11733
- this.dispatchEventWithData('pointerselect', { windowPoint: windowPoint, point: point, latlon: this.pointToLatLon(point) }, nativeEvent);
11734
- };
11735
- MapRoot.prototype.onMapLoaded = function (callback) {
11736
- this.addEventListener('loaded', callback);
11737
- if (this.map !== undefined) {
11738
- callback(new MapStateEvent('loaded', {
11739
- data: {
11740
- mapState: this.getMapState()
11741
- }
11742
- }));
11743
- }
11744
- };
11745
- MapRoot.prototype.onMapMoveStart = function (callback) {
11746
- console.log('onmap');
11747
- this.addEventListener('movestart', callback);
11748
- };
11749
- MapRoot.prototype.onMapViewChange = function (callback) {
11750
- this.addEventListener('moveend', callback);
11751
- };
11752
- MapRoot.prototype.onFlyToStart = function (callback) {
11753
- this.addEventListener('flytostart', callback);
11754
- };
11755
- MapRoot.prototype.onFlyToEnd = function (callback) {
11756
- this.addEventListener('flytoend', callback);
11757
- };
11758
- MapRoot.prototype.onPointerMove = function (callback) {
11759
- this.addEventListener('pointermove', callback);
11760
- };
11761
- MapRoot.prototype.onPointerSelect = function (callback) {
11762
- this.addEventListener('pointerselect', callback);
11763
- };
11764
- MapRoot.prototype.on = function (eventType, callback) {
11765
- this.addEventListener(eventType, callback);
11766
- };
11767
- MapRoot.prototype.getDefaultMapState = function () {
11768
- return {
11769
- center: {
11770
- lat: 0,
11771
- lon: 0
11772
- },
11773
- zoom: 0,
11774
- bounds: new LatLonBounds({
11775
- ne: {
11776
- lat: 90,
11777
- lon: -180
11778
- },
11779
- sw: {
11780
- lat: -90,
11781
- lon: 180
11782
- }
11783
- })
11784
- };
11785
- };
11786
- MapRoot.prototype.getMapState = function () {
11787
- var bounds = this.getMapBounds();
11788
- var center = this.getMapCenter();
11789
- var zoom = this.getMapZoom();
11790
- if (bounds !== undefined && center !== undefined && zoom !== undefined) {
11791
- return {
11792
- zoom: zoom,
11793
- center: center,
11794
- bounds: bounds
11795
- };
11796
- }
11797
- else {
11798
- return this.getDefaultMapState();
11799
- }
11800
- };
11801
- MapRoot.prototype.setBaseLayerKey = function (baseLayerKey) {
11802
- if (baseLayersMapped[baseLayerKey] !== undefined) {
11803
- this.baseLayerKey = baseLayerKey;
11804
- this.setBaseLayer(__assign({}, baseLayersMapped[baseLayerKey]));
11805
- }
11806
- };
11807
- MapRoot.prototype.getBaseLayerKey = function () {
11808
- return this.baseLayerKey;
11809
- };
11810
- MapRoot.prototype.setBaseLayer = function (layer) {
11811
- if ((this.baseLayer != null) && this.map !== undefined) {
11812
- this.removeLayerFromMap(this.baseLayer);
11813
- }
11814
- this.baseLayer = layer;
11815
- if (this.map !== undefined) {
11816
- this.setMapBaseLayer(layer);
11817
- }
11818
- };
11819
- // TODO: Handle case where there are multiple layers of the same type.
11820
- // Here we are finding the layer by ILayerProps. We should be finding it by a unique id.
11821
- MapRoot.prototype.getLayer = function (layerIdentifier) {
11822
- var _a, _b;
11823
- if (typeof layerIdentifier === 'string') {
11824
- return (_a = this.layers) === null || _a === void 0 ? void 0 : _a.find(function (l) { return l.id === layerIdentifier; });
11825
- }
11826
- return (_b = this.layers) === null || _b === void 0 ? void 0 : _b.find(function (l) { return l.id === layerIdentifier.id; });
11827
- };
11828
- MapRoot.prototype.hasLayer = function (layer) {
11829
- var _a, _b;
11830
- if (typeof layer === 'string') {
11831
- return ((_a = this.layers) === null || _a === void 0 ? void 0 : _a.find(function (l) { return l.id === layer; })) !== undefined;
11832
- }
11833
- return (((_b = this.layers) === null || _b === void 0 ? void 0 : _b.find(function (l) { return l.id === layer.id; })) !== undefined);
11834
- };
11835
- MapRoot.prototype.addLayer = function (layer) {
11836
- var _a;
11837
- if (this.map !== undefined && (layer.layer === undefined || layer.layer === null)) {
11838
- this.addLayerToMap(layer);
11839
- }
11840
- if (!this.hasLayer(layer)) {
11841
- (_a = this.layers) === null || _a === void 0 ? void 0 : _a.push(layer);
11842
- }
11843
- };
11844
- MapRoot.prototype.addLayers = function (layers) {
11845
- var _this = this;
11846
- layers.forEach(function (l) {
11847
- _this.addLayer(l);
11848
- });
11849
- };
11850
- MapRoot.prototype.removeLayer = function (layerIdentifier) {
11851
- var _a, _b;
11852
- console.log('removeLayer');
11853
- var layer = this.getLayer(layerIdentifier);
11854
- if (layer !== undefined) {
11855
- (_a = layer === null || layer === void 0 ? void 0 : layer.implementation) === null || _a === void 0 ? void 0 : _a.onBeforeRemoveFromMap();
11856
- if (this.layers != null) {
11857
- if (this.map !== undefined && (layer.layer !== undefined && layer.layer !== null)) {
11858
- console.log('removing from map');
11859
- this.removeLayerFromMap(layer);
11860
- }
11861
- else {
11862
- console.log(this.map);
11863
- console.log(layer);
11864
- }
11865
- if (this.layers.includes(layer)) {
11866
- console.log('removing from array');
11867
- this.layers.splice(this.layers.indexOf(layer), 1);
11868
- }
11869
- (_b = layer === null || layer === void 0 ? void 0 : layer.implementation) === null || _b === void 0 ? void 0 : _b.onRemovedFromMap();
11870
- }
11871
- }
11872
- };
11873
- MapRoot.prototype.removeAllLayers = function () {
11874
- if (this.layers !== undefined) {
11875
- this.removeLayers(this.layers);
11876
- }
11877
- };
11878
- MapRoot.prototype.removeLayers = function (layers) {
11879
- var _this = this;
11880
- // gotta slice it since removeLayer splices it
11881
- layers.slice().forEach(function (layer) {
11882
- _this.removeLayer(layer);
11883
- });
11884
- };
11885
- MapRoot.prototype.setZoom = function (zoom) {
11886
- this.zoom = zoom;
11887
- if (this.map !== undefined) {
11888
- this.setMapZoom(zoom);
11889
- }
11890
- };
11891
- MapRoot.prototype.getZoom = function () {
11892
- return this.zoom;
11893
- };
11894
- MapRoot.prototype.setCenter = function (center) {
11895
- this.center = center;
11896
- if (this.map !== undefined) {
11897
- this.setMapCenter(center);
11898
- }
11899
- };
11900
- MapRoot.prototype.getCenter = function () {
11901
- return this.center;
11902
- };
11903
- MapRoot.prototype.setPosition = function (_a) {
11904
- var center = _a.center, zoom = _a.zoom;
11905
- this.center = center;
11906
- this.zoom = zoom;
11907
- if (this.map !== undefined) {
11908
- this.setMapCenter(center);
11909
- this.setMapZoom(zoom);
11910
- }
11911
- };
11912
- MapRoot.prototype.setState = function (state) {
11913
- if (state.bounds !== undefined) {
11914
- this.setBounds(state.bounds);
11915
- }
11916
- else {
11917
- this.setPosition(state);
11918
- }
11919
- };
11920
- MapRoot.prototype.setBounds = function (bounds, options) {
11921
- if (this.map !== undefined) {
11922
- this.setMapBounds(bounds, options);
11923
- }
11924
- };
11925
- MapRoot.prototype.getBounds = function () {
11926
- if (this.map !== undefined) {
11927
- return this.getMapBounds();
11928
- }
11929
- return null;
11930
- };
11931
- MapRoot.prototype.setProjection = function (projection) {
11932
- this.projection = projection;
11933
- if (this.map !== undefined) {
11934
- this.setMapProjection(projection);
11935
- }
11936
- };
11937
- MapRoot.prototype.getProjection = function () {
11938
- return this.projection;
11939
- };
11940
- MapRoot.prototype.setElement = function (element) {
11941
- this.element = element;
11942
- if (this.map !== undefined) {
11943
- this.setMapElement(element);
11944
- }
11945
- };
11946
- MapRoot.prototype.getElement = function () {
11947
- return this.element;
11948
- };
11949
- MapRoot.prototype.setMapBaseLayer = function (layer) {
11950
- this.addLayerToMap(layer);
11951
- // console.log(`setMapBaseLayer no implemented for ${this.getMapLibraryName()}`)
11952
- };
11953
- MapRoot.prototype.getMapLibraryName = function () {
11954
- if (this.mapLibraryKey !== undefined) {
11955
- return this.mapLibraryKey;
11956
- }
11957
- return '(no library key)';
11958
- };
11959
- MapRoot.prototype.createGeojsonLayer = function (layer) {
11960
- console.log("createGeojsonLayer not yet implemented on ".concat(this.getMapLibraryName()));
11961
- return undefined;
11962
- };
11963
- MapRoot.prototype.createLayer = function (layer) {
11964
- return __awaiter(this, void 0, void 0, function () {
11965
- var layerTypeMap;
11966
- var _a;
11967
- return __generator(this, function (_b) {
11968
- layerTypeMap = ((_a = this.mapLibrary) === null || _a === void 0 ? void 0 : _a.LayerTypes) !== undefined ? Object.fromEntries(this.mapLibrary.LayerTypes.map(function (l) { return [l.type, l]; })) : {};
11969
- if (layer.libraryPath !== undefined) {
11970
- console.log('LOAD IT');
11971
- }
11972
- else if (layerTypeMap[layer.type] !== undefined) {
11973
- return [2 /*return*/, layerTypeMap[layer.type]];
11974
- }
11975
- return [2 /*return*/, undefined];
11976
- });
11977
- });
11978
- };
11979
- MapRoot.prototype.addLayerImplementationToMap = function (layerImplementation) {
11980
- console.log("addLayerImplementationToMap not yet implemented on ".concat(this.getMapLibraryName(), ". Layers will not be added to your map until you do"));
11981
- };
11982
- MapRoot.prototype.addLayerToMap = function (layer) {
11983
- var _this = this;
11984
- this.createLayer(layer).then(function (layerLibrary) {
11985
- if (layerLibrary !== undefined) {
11986
- var Implementation = layerLibrary.Implementation;
11987
- var layerImplementation = new Implementation(layer, _this);
11988
- _this.addLayerImplementationToMap(layerImplementation);
11989
- layer.implementation = layerImplementation;
11990
- if (layer.opacity !== undefined) {
11991
- layer.implementation.setOpacity(layer.opacity);
11992
- }
11993
- if (layer.visible !== undefined) {
11994
- layer.implementation.setVisible(layer.visible);
11995
- }
11996
- }
11997
- else {
11998
- /* const type = layer.type
11999
- if (type === 'tile') {
12000
- this.addTileLayerToMap(layer as ITileLayerProps)
12001
- } else if (type === 'wms') {
12002
- this.addWMSLayerToMap(layer as IWMSLayerProps)
12003
- } else if (type === 'geoJson') {
12004
- this.addGeoJsonLayerToMap(layer as IGeoJSONLayerProps)
12005
- } else {
12006
- console.log(`layer type not supported by ${this.getMapLibraryName()}`)
12007
- } */
12008
- console.log("layer type ".concat(layer.type, " not supported by ").concat(_this.getMapLibraryName()));
12009
- }
12010
- }).catch(function (e) {
12011
- console.log('Error loading map implementation');
12012
- console.log(e);
12013
- });
12014
- };
12015
- MapRoot.prototype.addTileLayerToMap = function (layer) {
12016
- console.log("addTileLayerToMap no implemented for ".concat(this.getMapLibraryName()));
12017
- };
12018
- MapRoot.prototype.addWMSLayerToMap = function (layer) {
12019
- console.log("addWMSLayerToMap no implemented for ".concat(this.getMapLibraryName()));
12020
- };
12021
- MapRoot.prototype.addGeoJsonLayerToMap = function (layer) {
12022
- console.log("addGeoJsonLayerToMap no implemented for ".concat(this.getMapLibraryName()));
12023
- };
12024
- MapRoot.prototype.removeLayerFromMap = function (layer) {
12025
- console.log("removeLayerFromMap not implemented for ".concat(this.getMapLibraryName()));
12026
- };
12027
- MapRoot.prototype.setMapZoom = function (zoom) {
12028
- console.log("setMapZoom not implemented for ".concat(this.getMapLibraryName()));
12029
- };
12030
- MapRoot.prototype.getMapZoom = function () {
12031
- console.log("getMapZoom not implemented for ".concat(this.getMapLibraryName()));
12032
- return 0;
12033
- };
12034
- MapRoot.prototype.setMapCenter = function (center) {
12035
- console.log("setMapCenter not implemented for ".concat(this.getMapLibraryName()));
12036
- };
12037
- MapRoot.prototype.getMapCenter = function () {
12038
- console.log("getMapCenter not implemented for ".concat(this.getMapLibraryName()));
12039
- return undefined;
12040
- };
12041
- MapRoot.prototype.setMapBounds = function (bounds, options) {
12042
- console.log("setMapBounds not implemented for ".concat(this.getMapLibraryName()));
12043
- };
12044
- MapRoot.prototype.getMapBounds = function () {
12045
- console.log("getMapBounds not implemented for ".concat(this.getMapLibraryName()));
12046
- return undefined;
12047
- };
12048
- MapRoot.prototype.setMapProjection = function (projection) {
12049
- console.log("setMapProjection not implemented for ".concat(this.getMapLibraryName()));
12050
- };
12051
- MapRoot.prototype.setMapElement = function (element) {
12052
- console.log("setMapProjection not implemented for ".concat(this.getMapLibraryName()));
12053
- };
12054
- MapRoot.prototype.getIDrawToolInstance = function () {
12055
- if (this.toolInstances.draw !== undefined) {
12056
- return this.toolInstances.draw;
12057
- }
12058
- return undefined;
12059
- };
12060
- MapRoot.prototype.getDrawGeojson = function () {
12061
- var drawToolInstance = this.getIDrawToolInstance();
12062
- if (drawToolInstance !== undefined) {
12063
- return drawToolInstance.getGeojson();
12064
- }
12065
- return undefined;
12066
- };
12067
- MapRoot.prototype.setDrawGeojson = function (geoJSON) {
12068
- var drawToolInstance = this.getIDrawToolInstance();
12069
- if (drawToolInstance !== undefined) {
12070
- drawToolInstance.setGeojson(geoJSON);
12071
- }
12072
- };
12073
- MapRoot.prototype.onDrawStart = function (onDrawStartCallback) {
12074
- this.on('drawstart', onDrawStartCallback);
12075
- /* if (this.toolInstances.draw !== undefined) {
12076
- this.toolInstances.draw.onStart(this.onDrawStartCallback)
12077
- } */
12078
- };
12079
- MapRoot.prototype.dispatchDrawStartEvent = function (shape) {
12080
- this.dispatchEventWithData('drawstart', { shape: shape });
12081
- };
12082
- MapRoot.prototype.onDrawComplete = function (onDrawCompleteCallback) {
12083
- this.on('drawcomplete', onDrawCompleteCallback);
12084
- /* if (this.toolInstances.draw !== undefined) {
12085
- this.toolInstances.draw.onComplete(this.onDrawCompleteCallback)
12086
- } */
12087
- };
12088
- MapRoot.prototype.dispatchDrawCompleteEvent = function (geojson) {
12089
- this.dispatchEventWithData('drawcomplete', { geojson: geojson });
12090
- };
12091
- MapRoot.prototype.onDrawUpdate = function (onDrawUpdateCallback) {
12092
- this.addEventListener('drawupdate', onDrawUpdateCallback);
12093
- /* if (this.toolInstances.draw !== undefined) {
12094
- this.toolInstances.draw.onUpdate()
12095
- } */
12096
- };
12097
- MapRoot.prototype.dispatchDrawUpdateEvent = function (geojson) {
12098
- this.dispatchEventWithData('drawupdate', { geojson: geojson });
12099
- };
12100
- MapRoot.prototype.onDrawProgress = function (onDrawProgressCallback) {
12101
- this.addEventListener('drawprogress', onDrawProgressCallback);
12102
- /* if (this.toolInstances.draw !== undefined) {
12103
- this.toolInstances.draw.onUpdateProgress(this.onDrawProgressCallback)
12104
- } */
12105
- };
12106
- MapRoot.prototype.dispatchDrawProgressEvent = function (geojson) {
12107
- this.dispatchEventWithData('drawprogress', { geojson: geojson });
12108
- };
12109
- MapRoot.prototype.enableDraw = function (shape) {
12110
- if (this.toolInstances.draw === undefined) {
12111
- this.initIDrawTool({ enabled: false });
12112
- }
12113
- if (this.toolInstances.draw !== undefined) {
12114
- this.toolInstances.draw.enableMapShape(shape);
12115
- }
12116
- };
12117
- MapRoot.prototype.disableDraw = function (shape) {
12118
- if (this.toolInstances.draw !== undefined) {
12119
- this.toolInstances.draw.disableMapShape(shape);
12120
- }
12121
- };
12122
- MapRoot.prototype.clearDrawings = function () {
12123
- if (this.toolInstances.draw !== undefined) {
12124
- this.toolInstances.draw.clearDrawings();
12125
- }
12126
- };
12127
- MapRoot.prototype.initIDrawTool = function (ops) {
12128
- var _a, _b;
12129
- if (ops === void 0) { ops = { enabled: true }; }
12130
- if (((_b = (_a = this === null || this === void 0 ? void 0 : this.mapLibrary) === null || _a === void 0 ? void 0 : _a.Tools) === null || _b === void 0 ? void 0 : _b.Draw) !== undefined) {
12131
- var drawProps = __assign(__assign({}, ops), { map: this });
12132
- var DrawClass = this.mapLibrary.Tools.Draw;
12133
- var newIDrawTool = new DrawClass(drawProps);
12134
- this.toolInstances.draw = newIDrawTool;
12135
- }
12136
- };
12137
- MapRoot.prototype.initIScaleLineTool = function (ops) {
12138
- var _a, _b;
12139
- if (ops === void 0) { ops = { enabled: true, targetElementId: 'scale-line-container' }; }
12140
- if (((_b = (_a = this === null || this === void 0 ? void 0 : this.mapLibrary) === null || _a === void 0 ? void 0 : _a.Tools) === null || _b === void 0 ? void 0 : _b.ScaleLine) !== undefined) {
12141
- var scaleLineProps = __assign(__assign({}, ops), { map: this });
12142
- var ScaleLineClass = this.mapLibrary.Tools.ScaleLine;
12143
- var newIScaleLineTool = new ScaleLineClass(scaleLineProps);
12144
- this.toolInstances.scaleLine = newIScaleLineTool;
12145
- }
12146
- };
12147
- MapRoot.prototype.initTools = function () {
12148
- var _a, _b;
12149
- if (((_a = this === null || this === void 0 ? void 0 : this.tools) === null || _a === void 0 ? void 0 : _a.draw) !== undefined) {
12150
- this.initIDrawTool(this.tools.draw);
12151
- }
12152
- if (((_b = this === null || this === void 0 ? void 0 : this.tools) === null || _b === void 0 ? void 0 : _b.scaleLine) !== undefined) {
12153
- this.initIScaleLineTool(this.tools.scaleLine);
12154
- }
12155
- };
12156
- MapRoot.prototype.initMap = function () {
12157
- var _this = this;
12158
- if (this.element != null) {
12159
- if (this.mapElement == null) {
12160
- this.mapElement = document.createElement('div');
12161
- this.mapElement.classList.add("".concat(this.getMapLibraryName(), "-map"));
12162
- this.mapElement.style.height = '100%';
12163
- this.element.appendChild(this.mapElement);
12164
- }
12165
- this.createMap().then(function (map) { return __awaiter(_this, void 0, void 0, function () {
12166
- var _this = this;
12167
- return __generator(this, function (_a) {
12168
- this.map = map;
12169
- if (this.baseLayer != null) {
12170
- this.setBaseLayer(this.baseLayer);
12171
- }
12172
- else if (this.baseLayerKey !== undefined) {
12173
- this.setBaseLayerKey(this.baseLayerKey);
12174
- }
12175
- if (this.layers != null) {
12176
- this.addLayers(this.layers);
12177
- }
12178
- this.initTools();
12179
- this.dispatchEvent(new MapLoadedEvent('loaded', {
12180
- data: __assign(__assign({}, this.getMapState()), { map: this })
12181
- }));
12182
- if (this.mapElement !== undefined) {
12183
- this.mapElement.onmouseleave = function () {
12184
- _this.dispatchPointerMove();
12185
- };
12186
- }
12187
- return [2 /*return*/];
12188
- });
12189
- }); }).catch(function (e) {
12190
- console.log('Error initializing map');
12191
- console.log(e);
12192
- });
12193
- // this.map = await this.createMap()
12194
- }
12195
- };
12196
- MapRoot.prototype.createMap = function () {
12197
- return __awaiter(this, void 0, void 0, function () {
12198
- return __generator(this, function (_a) {
12199
- console.log("createMap not implemented for ".concat(this.getMapLibraryName()));
12200
- return [2 /*return*/, null];
12201
- });
12202
- });
12203
- };
12204
- MapRoot.prototype.isDestroyed = function () {
12205
- if (this.map !== undefined && this.mapElement !== undefined) {
12206
- return false;
12207
- }
12208
- return true;
12209
- };
12210
- MapRoot.prototype.destroy = function () {
12211
- var _a;
12212
- (_a = this.layers) === null || _a === void 0 ? void 0 : _a.forEach(function (layer) {
12213
- delete layer.layer;
12214
- });
12215
- if (this.baseLayer != null) {
12216
- delete this.baseLayer.layer;
12217
- }
12218
- this.cleanupTools();
12219
- this.cleanupMap();
12220
- if ((this.element != null) && (this.mapElement != null)) {
12221
- this.element.removeChild(this.mapElement);
12222
- delete this.mapElement;
12223
- delete this.map;
12224
- }
12225
- };
12226
- MapRoot.prototype.invalidateSize = function () {
12227
- console.log("invalidateSize not implemented for ".concat(this.getMapLibraryName()));
12228
- };
12229
- MapRoot.prototype.cleanupMap = function () {
12230
- console.log("cleanupMap not implemented for ".concat(this.getMapLibraryName()));
12231
- };
12232
- MapRoot.prototype.cleanupTools = function () {
12233
- Object.values(this.toolInstances).forEach(function (tool) { tool.cleanup(); });
12234
- };
12235
- return MapRoot;
12236
- })(axiomUiUtilities.EventManager));
12237
-
12238
- React.createContext({});
12239
-
12240
- var EMapShape;
12241
- (function (EMapShape) {
12242
- EMapShape["polygon"] = "Polygon";
12243
- EMapShape["linestring"] = "LineString";
12244
- EMapShape["point"] = "Point";
12245
- })(EMapShape || (EMapShape = {}));
12246
-
12247
- var EMapTools;
12248
- (function (EMapTools) {
12249
- EMapTools["draw"] = "draw";
12250
- })(EMapTools || (EMapTools = {}));
12251
-
12252
- function getDefaultExportFromCjs (x) {
12253
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
12254
- }
12255
-
12256
- var polyline$1 = {exports: {}};
12257
-
12258
- (function (module) {
12259
-
12260
- /**
12261
- * Based off of [the offical Google document](https://developers.google.com/maps/documentation/utilities/polylinealgorithm)
12262
- *
12263
- * Some parts from [this implementation](http://facstaff.unca.edu/mcmcclur/GoogleMaps/EncodePolyline/PolylineEncoder.js)
12264
- * by [Mark McClure](http://facstaff.unca.edu/mcmcclur/)
12265
- *
12266
- * @module polyline
12267
- */
12268
-
12269
- var polyline = {};
12270
-
12271
- function py2_round(value) {
12272
- // Google's polyline algorithm uses the same rounding strategy as Python 2, which is different from JS for negative values
12273
- return Math.floor(Math.abs(value) + 0.5) * (value >= 0 ? 1 : -1);
12274
- }
12275
-
12276
- function encode(current, previous, factor) {
12277
- current = py2_round(current * factor);
12278
- previous = py2_round(previous * factor);
12279
- var coordinate = (current - previous) * 2;
12280
- if (coordinate < 0) {
12281
- coordinate = -coordinate - 1;
12282
- }
12283
- var output = '';
12284
- while (coordinate >= 0x20) {
12285
- output += String.fromCharCode((0x20 | (coordinate & 0x1f)) + 63);
12286
- coordinate /= 32;
12287
- }
12288
- output += String.fromCharCode((coordinate | 0) + 63);
12289
- return output;
12290
- }
12291
-
12292
- /**
12293
- * Decodes to a [latitude, longitude] coordinates array.
12294
- *
12295
- * This is adapted from the implementation in Project-OSRM.
12296
- *
12297
- * @param {String} str
12298
- * @param {Number} precision
12299
- * @returns {Array}
12300
- *
12301
- * @see https://github.com/Project-OSRM/osrm-frontend/blob/master/WebContent/routing/OSRM.RoutingGeometry.js
12302
- */
12303
- polyline.decode = function(str, precision) {
12304
- var index = 0,
12305
- lat = 0,
12306
- lng = 0,
12307
- coordinates = [],
12308
- shift = 0,
12309
- result = 0,
12310
- byte = null,
12311
- latitude_change,
12312
- longitude_change,
12313
- factor = Math.pow(10, Number.isInteger(precision) ? precision : 5);
12314
-
12315
- // Coordinates have variable length when encoded, so just keep
12316
- // track of whether we've hit the end of the string. In each
12317
- // loop iteration, a single coordinate is decoded.
12318
- while (index < str.length) {
12319
-
12320
- // Reset shift, result, and byte
12321
- byte = null;
12322
- shift = 1;
12323
- result = 0;
12324
-
12325
- do {
12326
- byte = str.charCodeAt(index++) - 63;
12327
- result += (byte & 0x1f) * shift;
12328
- shift *= 32;
12329
- } while (byte >= 0x20);
12330
-
12331
- latitude_change = (result & 1) ? ((-result - 1) / 2) : (result / 2);
12332
-
12333
- shift = 1;
12334
- result = 0;
12335
-
12336
- do {
12337
- byte = str.charCodeAt(index++) - 63;
12338
- result += (byte & 0x1f) * shift;
12339
- shift *= 32;
12340
- } while (byte >= 0x20);
12341
-
12342
- longitude_change = (result & 1) ? ((-result - 1) / 2) : (result / 2);
12343
-
12344
- lat += latitude_change;
12345
- lng += longitude_change;
12346
-
12347
- coordinates.push([lat / factor, lng / factor]);
12348
- }
12349
-
12350
- return coordinates;
12351
- };
12352
-
12353
- /**
12354
- * Encodes the given [latitude, longitude] coordinates array.
12355
- *
12356
- * @param {Array.<Array.<Number>>} coordinates
12357
- * @param {Number} precision
12358
- * @returns {String}
12359
- */
12360
- polyline.encode = function(coordinates, precision) {
12361
- if (!coordinates.length) { return ''; }
12362
-
12363
- var factor = Math.pow(10, Number.isInteger(precision) ? precision : 5),
12364
- output = encode(coordinates[0][0], 0, factor) + encode(coordinates[0][1], 0, factor);
12365
-
12366
- for (var i = 1; i < coordinates.length; i++) {
12367
- var a = coordinates[i], b = coordinates[i - 1];
12368
- output += encode(a[0], b[0], factor);
12369
- output += encode(a[1], b[1], factor);
12370
- }
12371
-
12372
- return output;
12373
- };
12374
-
12375
- function flipped(coords) {
12376
- var flipped = [];
12377
- for (var i = 0; i < coords.length; i++) {
12378
- var coord = coords[i].slice();
12379
- flipped.push([coord[1], coord[0]]);
12380
- }
12381
- return flipped;
12382
- }
12383
-
12384
- /**
12385
- * Encodes a GeoJSON LineString feature/geometry.
12386
- *
12387
- * @param {Object} geojson
12388
- * @param {Number} precision
12389
- * @returns {String}
12390
- */
12391
- polyline.fromGeoJSON = function(geojson, precision) {
12392
- if (geojson && geojson.type === 'Feature') {
12393
- geojson = geojson.geometry;
12394
- }
12395
- if (!geojson || geojson.type !== 'LineString') {
12396
- throw new Error('Input must be a GeoJSON LineString');
12397
- }
12398
- return polyline.encode(flipped(geojson.coordinates), precision);
12399
- };
12400
-
12401
- /**
12402
- * Decodes to a GeoJSON LineString geometry.
12403
- *
12404
- * @param {String} str
12405
- * @param {Number} precision
12406
- * @returns {Object}
12407
- */
12408
- polyline.toGeoJSON = function(str, precision) {
12409
- var coords = polyline.decode(str, precision);
12410
- return {
12411
- type: 'LineString',
12412
- coordinates: flipped(coords)
12413
- };
12414
- };
12415
-
12416
- if (module.exports) {
12417
- module.exports = polyline;
12418
- }
12419
- } (polyline$1));
12420
-
12421
- var polylineExports = polyline$1.exports;
12422
- var polyline = /*@__PURE__*/getDefaultExportFromCjs(polylineExports);
12423
-
12424
- function encodePolygon(polygon) {
12425
- var firstShape = polygon.coordinates[0];
12426
- var lineString = {
12427
- type: 'LineString',
12428
- coordinates: firstShape
12429
- };
12430
- return polyline.fromGeoJSON(lineString);
12431
- }
12432
- function decodePolygon(str) {
12433
- var coordinates = polyline.decode(str);
12434
- if (coordinates[0].toString() !== coordinates[coordinates.length - 1].toString()) {
12435
- coordinates.push([
12436
- coordinates[0][0],
12437
- coordinates[0][1]
12438
- ]);
12439
- }
12440
- var polygon = {
12441
- type: 'Polygon',
12442
- coordinates: [
12443
- coordinates.map(function (d) { return d.slice().reverse(); })
12444
- ]
12445
- };
12446
- return polygon;
12447
- }
12448
- function encodeLine(lineString) {
12449
- return polyline.fromGeoJSON(lineString);
12450
- }
12451
- function decodeLine(str) {
12452
- var coordinates = polyline.decode(str);
12453
- var lineString = {
12454
- type: 'LineString',
12455
- coordinates: coordinates.slice().map(function (d) { return d.slice().reverse(); })
12456
- };
12457
- return lineString;
12458
- }
12459
- function encodePoint(point) {
12460
- return point.coordinates.map(function (d) {
12461
- return d.toFixed(5);
12462
- }).join(',');
12463
- }
12464
- function decodePoint(str) {
12465
- var _a = str.split(','), lon = _a[0], lat = _a[1];
12466
- return {
12467
- type: 'Point',
12468
- coordinates: [+lon, +lat]
12469
- };
12470
- }
12471
- var encodeMapShape = function (geometry) {
12472
- if (geometry.type === EMapShape.polygon) {
12473
- try {
12474
- return encodePolygon(geometry);
12475
- }
12476
- catch (e) {
12477
- return '';
12478
- }
12479
- }
12480
- else if (geometry.type === EMapShape.linestring) {
12481
- try {
12482
- return encodeLine(geometry);
12483
- }
12484
- catch (e) {
12485
- return '';
12486
- }
12487
- }
12488
- try {
12489
- return encodePoint(geometry);
12490
- }
12491
- catch (e) {
12492
- return '';
12493
- }
12494
- };
12495
- var decodeMapShape = function (encoding, type) {
12496
- if (encoding.length < 3) {
12497
- return undefined;
12498
- }
12499
- if (type === undefined) {
12500
- if (encoding.match(/\d+|\d+,/) !== null) {
12501
- try {
12502
- return decodePoint(encoding);
12503
- }
12504
- catch (e) {
12505
- }
12506
- }
12507
- try {
12508
- var line = decodeLine(encoding);
12509
- if (line.coordinates[0].toString() === line.coordinates[line.coordinates.length - 1].toString()) {
12510
- return decodePolygon(encoding);
12511
- }
12512
- else {
12513
- return line;
12514
- }
12515
- }
12516
- catch (e) {
12517
- try {
12518
- return decodePoint(encoding);
12519
- }
12520
- catch (e) {
12521
- return undefined;
12522
- }
12523
- }
12524
- }
12525
- try {
12526
- if (type === EMapShape.point) {
12527
- return decodePoint(encoding);
12528
- }
12529
- else if (type === EMapShape.linestring) {
12530
- return decodeLine(encoding);
12531
- }
12532
- return decodePolygon(encoding);
12533
- }
12534
- catch (e) {
12535
- return undefined;
12536
- }
12537
- };
12538
-
12539
11368
  const copy = (text) => {
12540
11369
  if (text !== undefined) {
12541
11370
  navigator.clipboard.writeText(text).then(() => {
@@ -13017,7 +11846,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
13017
11846
  ];
13018
11847
  Object.fromEntries(datasets.map(d => [d.id, d]));
13019
11848
 
13020
- const getFocsleDataset = (dataset) => __awaiter$1(void 0, void 0, void 0, function* () {
11849
+ const getFocsleDataset = (dataset) => __awaiter(void 0, void 0, void 0, function* () {
13021
11850
  var _a, _b;
13022
11851
  const d = yield (yield fetch(`https://focsle-pyramids.srv.axds.co/datasets/${dataset}`)).json();
13023
11852
  if (d !== undefined && ((_a = d === null || d === void 0 ? void 0 : d.z_dimension) === null || _a === void 0 ? void 0 : _a.axiom_std_levels) === undefined && ((_b = d === null || d === void 0 ? void 0 : d.z_dimension) === null || _b === void 0 ? void 0 : _b[0]) !== undefined) {
@@ -13054,7 +11883,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
13054
11883
  const makeFoclseTimeSeriesStatsRequest = (props) => {
13055
11884
  return `https://focsle-pyramids.srv.axds.co/datasets/${props.dataset}/climatology/${makeFocsleTimeSeriesStatsRequestQueryString(omit$1(props, 'xBounds'))}`;
13056
11885
  };
13057
- const parseFocsleTimeSeriesDataStats = (data, args) => __awaiter$1(void 0, void 0, void 0, function* () {
11886
+ const parseFocsleTimeSeriesDataStats = (data, args) => __awaiter(void 0, void 0, void 0, function* () {
13058
11887
  const d = data.mean !== undefined ? data.mean : Object.values(data)[0];
13059
11888
  const startTimeAcc = (r) => r.startTime;
13060
11889
  const endTimeAcc = (r) => r.endTime;
@@ -13102,7 +11931,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
13102
11931
  '1M': 'monthly',
13103
11932
  '1Y': 'yearly'
13104
11933
  };
13105
- const parseFocsleSeasonalTimeSeriesDataStats = (data_1, _a) => __awaiter$1(void 0, [data_1, _a], void 0, function* (data, { binSize, xBounds, xBin }) {
11934
+ const parseFocsleSeasonalTimeSeriesDataStats = (data_1, _a) => __awaiter(void 0, [data_1, _a], void 0, function* (data, { binSize, xBounds, xBin }) {
13106
11935
  const def = xBinDefinitions[focsleBinToSensorBin[xBin]];
13107
11936
  const [start, end] = xBounds;
13108
11937
  const span = +end - +start;
@@ -13211,7 +12040,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
13211
12040
  const [statistic] = React.useState('mean');
13212
12041
  const { data, isLoading, isError } = useQuery({
13213
12042
  queryKey: [`focsle-datasets:${datasetToUse}:${variableToUse}`],
13214
- queryFn: (o) => __awaiter$1(void 0, void 0, void 0, function* () {
12043
+ queryFn: (o) => __awaiter(void 0, void 0, void 0, function* () {
13215
12044
  const details = yield getFocsleDataset(datasetToUse);
13216
12045
  return details;
13217
12046
  })
@@ -13262,7 +12091,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
13262
12091
  : jsxRuntimeExports.jsx(Component, { shortcode: 'axiom_virtual_sensor', requiredShortCodeAttributes: {
13263
12092
  dataset: datasetToUse,
13264
12093
  variable: variableToUse,
13265
- geometry: typeof geometry === 'string' ? geometry : encodeMapShape(geometry)
12094
+ geometry: typeof geometry === 'string' ? geometry : axiomMaps.encodeMapShape(geometry)
13266
12095
  }, chartSettingsState: chartSettingsState, axisDefinitions: {
13267
12096
  x: {
13268
12097
  domain: getTimeDomain(),
@@ -13293,7 +12122,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
13293
12122
  };
13294
12123
  },
13295
12124
  createFetchAndParse: (p) => {
13296
- return (signal) => __awaiter$1(void 0, void 0, void 0, function* () {
12125
+ return (signal) => __awaiter(void 0, void 0, void 0, function* () {
13297
12126
  const xBin = getXBin(p);
13298
12127
  const stats = xBin === 'raw'
13299
12128
  ? ['mean']
@@ -13302,7 +12131,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
13302
12131
  'min',
13303
12132
  'max'
13304
12133
  ];
13305
- const d = yield Promise.all(stats.map((stat) => __awaiter$1(void 0, void 0, void 0, function* () {
12134
+ const d = yield Promise.all(stats.map((stat) => __awaiter(void 0, void 0, void 0, function* () {
13306
12135
  const data = yield (yield fetch(makeFocsleTimeSeriesRequestString(Object.assign({ dataset: datasetToUse, temporalResolution: xBin, statistic: stat, zLevel: selectedZ, variable: variableToUse, geometry,
13307
12136
  xBin }, p)), { signal })).json();
13308
12137
  return {
@@ -13345,7 +12174,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
13345
12174
  };
13346
12175
  },
13347
12176
  createFetchAndParse: (p) => {
13348
- return (signal) => __awaiter$1(void 0, void 0, void 0, function* () {
12177
+ return (signal) => __awaiter(void 0, void 0, void 0, function* () {
13349
12178
  if (p.xBounds === undefined) {
13350
12179
  throw new Error('xBounds are required for this plot');
13351
12180
  }
@@ -13357,7 +12186,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
13357
12186
  'p10',
13358
12187
  'p90'
13359
12188
  ];
13360
- const d = yield Promise.all(stats.map((stat) => __awaiter$1(void 0, void 0, void 0, function* () {
12189
+ const d = yield Promise.all(stats.map((stat) => __awaiter(void 0, void 0, void 0, function* () {
13361
12190
  const data = yield (yield fetch(makeFoclseTimeSeriesStatsRequest(Object.assign({ dataset: datasetToUse, temporalResolution: xBin, statistic: stat, zLevel: selectedZ, variable: variableToUse, geometry,
13362
12191
  xBin }, p)), { signal })).json();
13363
12192
  return {
@@ -13393,7 +12222,7 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
13393
12222
  const chartSettingsState = React.useState(Object.assign(Object.assign({}, initialChartSettings), props.defaultChartSettings));
13394
12223
  const queryClient = new QueryClient();
13395
12224
  const decodedMapShape = typeof props.geometry === 'string'
13396
- ? decodeMapShape(props.geometry)
12225
+ ? axiomMaps.decodeMapShape(props.geometry)
13397
12226
  : props.geometry;
13398
12227
  if (decodedMapShape === undefined) {
13399
12228
  return (jsxRuntimeExports.jsxs("div", { children: ["Invalid geometry: ", JSON.stringify(props.geometry)] }));
@@ -13412,5 +12241,5 @@ var AxiomCharts = (function (exports, axiomUiDataServices, d3Array, React, d3Sel
13412
12241
 
13413
12242
  return exports;
13414
12243
 
13415
- })({}, AxiomUIDataServices, d3Array, React, d3Selection, d3, d3Scale, d3Axis, d3Shape, ReactDOM, AxiomUIUtilities);
12244
+ })({}, AxiomUIDataServices, d3Array, React, d3Selection, d3, d3Scale, d3Axis, d3Shape, ReactDOM, AxiomUIUtilities, AxiomMaps);
13416
12245
  //# sourceMappingURL=browser.js.map