@redus/georedus-ui 0.2.0 → 0.3.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.
package/dist/main.js CHANGED
@@ -7,33 +7,33 @@ import { mdiHelpCircleOutline, mdiDownload, mdiDotsVertical, mdiOpacity, mdiFilt
7
7
  import { Tabs, Tooltip, IconButton, Theme, Heading, Text, Dialog, Portal, Popover } from '@radix-ui/themes';
8
8
  import styled, { keyframes } from 'styled-components';
9
9
  import * as Collapsible from '@radix-ui/react-collapsible';
10
- import { __makeTemplateObject, __assign, __awaiter, __generator, __spreadArray } from 'tslib';
10
+ import { __makeTemplateObject, __assign, __spreadArray, __awaiter, __generator } from 'tslib';
11
11
  import remarkMath from 'remark-math';
12
12
  import rehypeKatex from 'rehype-katex';
13
13
  import 'katex/dist/katex.min.css';
14
- import { isPlainObject, pick, omit, set, get as get$1, uniqBy, groupBy, uniq } from 'lodash';
14
+ import { isPlainObject, pick, omit, set, get, uniqBy, groupBy, uniq } from 'lodash';
15
15
  import { useDebounce } from 'react-use';
16
16
  import { createDialogSystem, DIALOGS } from '@orioro/react-dialogs';
17
17
  import { CsvImportDialog } from '@orioro/react-csv';
18
18
  import Highlighter from 'react-highlight-words';
19
19
  import { makeSortableMultiList } from '@orioro/react-sortable';
20
- import { makeSyncedMaps, LayeredMap, HoverTooltip, ControlContainer, MapWindow, TerrainControl, fitGeometry } from '@orioro/react-maplibre-util';
20
+ import { makeSyncedMaps, LayeredMap, HoverTooltip, ControlContainer, InspectControl, MapWindow, TerrainControl, fitGeometry } from '@orioro/react-maplibre-util';
21
21
  import { Legend } from '@orioro/react-chart-util';
22
22
  import 'maplibre-gl/dist/maplibre-gl.css';
23
- import { useQuery, useQueries } from '@tanstack/react-query';
24
- import { makeResolve, $$literal, withExpressionResolvers, expressions, ALL_EXPR, fetchExpr, resolve, resolveAsync } from '@orioro/resolve';
25
- import queryString from 'query-string';
26
- import { wrap } from 'comlink';
27
- import { get } from '@orioro/get';
23
+ import { useQueries, useQuery } from '@tanstack/react-query';
28
24
  import { AttributionControl, GeolocateControl, FullscreenControl, NavigationControl, ScaleControl } from 'react-map-gl/maplibre';
29
25
  import { slugify, dataJoin } from '@orioro/util';
30
26
  import { schemeTableau10, schemeSet3, schemeSet2, schemeSet1, schemePastel2, schemePastel1, schemePaired, schemeObservable10, schemeDark2, schemeAccent, schemeCategory10, schemeSpectral, schemeRdYlGn, schemeRdYlBu, schemeRdGy, schemeRdBu, schemePuOr, schemePiYG, schemePRGn, schemeBrBG, schemeYlOrRd, schemeYlOrBr, schemeYlGn, schemeYlGnBu, schemeRdPu, schemePuRd, schemePuBu, schemePuBuGn, schemeOrRd, schemeGnBu, schemeBuPu, schemeBuGn, schemeReds, schemePurples, schemeOranges, schemeGreys, schemeGreens, schemeBlues } from 'd3-scale-chromatic';
27
+ import { makeResolve, $$literal, withExpressionResolvers, expressions, ALL_EXPR, fetchExpr, resolve, resolveAsync } from '@orioro/resolve';
31
28
  import { saveAs } from 'file-saver';
32
29
  import initGdalJs from 'gdal3.js';
30
+ import queryString from 'query-string';
31
+ import { wrap } from 'comlink';
33
32
  import { validate } from '@orioro/validate';
34
33
  import { buffer } from '@turf/turf';
35
34
  import { csvParse } from 'd3-dsv';
36
35
  import { strAutoCast } from '@orioro/cast';
36
+ import { get as get$1 } from '@orioro/get';
37
37
 
38
38
  function _arrayLikeToArray(r, a) {
39
39
  (null == a || a > r.length) && (a = r.length);
@@ -582,6 +582,8 @@ function ViewConfTabs(_ref) {
582
582
  viewConf = _ref.viewConf,
583
583
  resolvedView = _ref.resolvedView,
584
584
  onSetView = _ref.onSetView;
585
+ var CONF_SCHEMA = viewSpec.confSchema;
586
+
585
587
  //
586
588
  // Debounce updating view conf. Prevent's fast changing controls
587
589
  // from accidentally triggering map view re-renders unnecessarily
@@ -595,9 +597,9 @@ function ViewConfTabs(_ref) {
595
597
  }, 500, [immediateViewConf]);
596
598
  var enabledTabs = useMemo(function () {
597
599
  return CONF_TAB_ORDER.map(function (tabId) {
598
- return viewSpec.conf && isPlainObject(viewSpec.conf[tabId]) && Object.values(viewSpec.conf[tabId]).some(Boolean) ? CONF_TABS[tabId] : null;
600
+ return CONF_SCHEMA && isPlainObject(CONF_SCHEMA[tabId]) && Object.values(CONF_SCHEMA[tabId]).some(Boolean) ? CONF_TABS[tabId] : null;
599
601
  }).filter(Boolean);
600
- }, [viewSpec]);
602
+ }, [CONF_SCHEMA]);
601
603
  var dialogs = useDialogs();
602
604
  return /*#__PURE__*/React.createElement(Tabs.Root, {
603
605
  defaultValue: ((_enabledTabs$ = enabledTabs[0]) === null || _enabledTabs$ === void 0 ? void 0 : _enabledTabs$.id) || null
@@ -715,7 +717,7 @@ function ViewConfTabs(_ref) {
715
717
  //
716
718
  // Omit null confs
717
719
  //
718
- Object.entries(viewSpec.conf[tab.id]).filter(function (_ref4) {
720
+ Object.entries(CONF_SCHEMA[tab.id]).filter(function (_ref4) {
719
721
  var _ref5 = _slicedToArray(_ref4, 2);
720
722
  _ref5[0];
721
723
  var value = _ref5[1];
@@ -757,8 +759,8 @@ var Summary = styled.div(_templateObject2$2 || (_templateObject2$2 = _taggedTemp
757
759
  var $active = _ref2.$active;
758
760
  return $active ? 'color-mix(in srgb, var(--redus-bege) 80%, white)' : 'var(--redus-bege)';
759
761
  });
760
- function resolveDefaultConf(viewSpec) {
761
- return Object.fromEntries(Object.entries(viewSpec.conf || {}).map(function (_ref3) {
762
+ function _resolveDefaultConf(confSchema) {
763
+ return Object.fromEntries(Object.entries(confSchema || {}).map(function (_ref3) {
762
764
  var _ref4 = _slicedToArray(_ref3, 2),
763
765
  confScopeId = _ref4[0],
764
766
  confSet = _ref4[1];
@@ -809,7 +811,7 @@ function ViewControl(_ref8) {
809
811
  return onDeactivateView();
810
812
  }, [onDeactivateView]);
811
813
  var setView = useCallback(function (layoutIndex) {
812
- return onSetView(resolveDefaultConf(viewSpec), layoutIndex);
814
+ return onSetView(_resolveDefaultConf(viewSpec.confSchema), layoutIndex);
813
815
  }, [viewSpec, onSetView]);
814
816
  var toggleView = useCallback(function () {
815
817
  return active ? deactivateView() : setView();
@@ -1609,193 +1611,6 @@ function ViewLayoutPopover(_ref) {
1609
1611
  }))))));
1610
1612
  }
1611
1613
 
1612
- var worker = typeof Worker !== 'undefined' && new Worker(new URL('./GeoReDUSWorker.worker.js', import.meta.url), {
1613
- type: 'module'
1614
- });
1615
- var GeoReDUSWorker = worker ? wrap(worker) : null;
1616
-
1617
- // export const $workerGet: ExpressionSpec<[any, any?]> = {
1618
- // parseArgs: ([arg1, arg2], { parseNodeInput }) =>
1619
- // typeof arg2 === 'undefined'
1620
- // ? [parseNodeInput(arg1)]
1621
- // : [parseNodeInput(arg1), parseNodeInput(arg2)],
1622
- // fn: (args, context) => {
1623
- // const path = args[0]
1624
- // const src = args.length === 1 ? context : args[1]
1625
- // return path === '' ? src : GeoReDUSWorker.get(src, path)
1626
- // },
1627
- // }
1628
- var $naturalBreaks = function $naturalBreaks(_a) {
1629
- var values = _a[0],
1630
- opt = _a[1];
1631
- var breaks = GeoReDUSWorker.scaleNaturalBreaks(__assign({
1632
- values: values
1633
- }, isPlainObject(opt) ? pick(opt, ['scalesByK', 'k', 'minK', 'maxK', 'defaultColor']) : {}));
1634
- return breaks;
1635
- };
1636
- // export const $test = ()
1637
- var $urlSearch = function $urlSearch(_a) {
1638
- var searchParams = _a[0];
1639
- return Array.isArray(searchParams) ? queryString.stringify(searchParams[0], searchParams[1]) : queryString.stringify(
1640
- //
1641
- // By default, stringify non primitive values using
1642
- // JSON.stringify before passing on to queryString,
1643
- // as by default queryString ignores non-primitive values.
1644
- //
1645
- // This still allows for custom formatting, throgh the array
1646
- // searchParams input, w/ second arg as options passed
1647
- // to queryString
1648
- //
1649
- Object.fromEntries(Object.entries(searchParams).map(function (_a) {
1650
- var key = _a[0],
1651
- value = _a[1];
1652
- return [key, _typeof(value) === 'object' && value !== null ? JSON.stringify(value) : value];
1653
- })));
1654
- };
1655
-
1656
- var CUSTOM_EXPR = /*#__PURE__*/Object.freeze({
1657
- __proto__: null,
1658
- $naturalBreaks: $naturalBreaks,
1659
- $urlSearch: $urlSearch
1660
- });
1661
-
1662
- function isFetchAllowed(resource, options) {
1663
- return __awaiter(this, void 0, void 0, function () {
1664
- return __generator(this, function (_a) {
1665
- console.error('isFetchAllowed must be defined');
1666
- return [2 /*return*/, true
1667
- // const conf = await apiConf()
1668
- // return fetchExpr.allowOrigins({
1669
- // [conf.GEO_METADATA_API_ENDPOINT]: ['GET', 'POST'],
1670
- // })(resource, options)
1671
- ];
1672
- });
1673
- });
1674
- }
1675
- var _a = makeResolve({
1676
- resolvers: withExpressionResolvers(expressions.syntaxArrayExpr({
1677
- name: '$$logical',
1678
- symbol: Symbol["for"]('$$logical'),
1679
- // @ts-ignore
1680
- exps: __assign(__assign(__assign({}, ALL_EXPR), CUSTOM_EXPR), {
1681
- $fetch: fetchExpr({
1682
- isFetchAllowed: isFetchAllowed
1683
- })
1684
- })
1685
- }).resolver),
1686
- defaultResolver: $$literal
1687
- }),
1688
- resolveExprAsync = _a.resolveAsync,
1689
- resolveExpr = _a.resolve;
1690
-
1691
- function resolveView(viewSpec, viewConf, viewContext) {
1692
- return __awaiter(this, void 0, void 0, function () {
1693
- var VIEW_AT_METADATA_STAGE, metadata, VIEW_AT_SOURCES_STAGE, sources, VIEW_AT_LAYERS_STAGE, layersBase, layers, legends, VIEW_AT_DOWNLOAD_STAGE, download;
1694
- return __generator(this, function (_a) {
1695
- switch (_a.label) {
1696
- case 0:
1697
- VIEW_AT_METADATA_STAGE = {
1698
- conf: viewConf
1699
- };
1700
- return [4 /*yield*/, resolveExprAsync(viewSpec.metadata, __assign(__assign({}, viewContext), {
1701
- view: VIEW_AT_METADATA_STAGE
1702
- }))];
1703
- case 1:
1704
- metadata = _a.sent();
1705
- if (viewSpec.debug) {
1706
- console.log('resolveView / metadata', metadata, {
1707
- viewSpec: viewSpec,
1708
- viewConf: viewConf,
1709
- viewContext: viewContext
1710
- });
1711
- }
1712
- VIEW_AT_SOURCES_STAGE = __assign(__assign({}, VIEW_AT_METADATA_STAGE), {
1713
- metadata: metadata
1714
- });
1715
- return [4 /*yield*/, resolveExprAsync(viewSpec.sources, __assign(__assign({}, viewContext), {
1716
- view: VIEW_AT_SOURCES_STAGE
1717
- }))];
1718
- case 2:
1719
- sources = _a.sent();
1720
- if (viewSpec.debug) {
1721
- console.log('resolveView / sources', sources, {
1722
- viewSpec: viewSpec,
1723
- viewConf: viewConf,
1724
- viewContext: viewContext
1725
- });
1726
- }
1727
- VIEW_AT_LAYERS_STAGE = __assign(__assign({}, VIEW_AT_SOURCES_STAGE), {
1728
- sources: sources
1729
- });
1730
- return [4 /*yield*/, resolveExprAsync(viewSpec.layers, __assign(__assign({}, viewContext), {
1731
- view: VIEW_AT_LAYERS_STAGE
1732
- }))
1733
- //
1734
- // Provide function that will resolve a tooltip
1735
- // for a specific feature
1736
- //
1737
- ];
1738
- case 3:
1739
- layersBase = _a.sent();
1740
- layers = Object.fromEntries(Object.entries(layersBase).filter(function (_a) {
1741
- _a[0];
1742
- var layerBase = _a[1];
1743
- return isPlainObject(layerBase) && !layerBase.hidden;
1744
- }).map(function (_a) {
1745
- var layerId = _a[0],
1746
- layerBase = _a[1];
1747
- return [layerId, __assign(__assign({}, layerBase), {
1748
- tooltip: layerBase.interactive !== false && layerBase.tooltip ? function (_a) {
1749
- var feature = _a.feature;
1750
- return resolveExpr(layerBase.tooltip, {
1751
- feature: feature,
1752
- view: VIEW_AT_LAYERS_STAGE
1753
- });
1754
- } : null
1755
- })];
1756
- }));
1757
- if (viewSpec.debug) {
1758
- console.log('resolveView / layers', layers, {
1759
- viewSpec: viewSpec,
1760
- viewConf: viewConf,
1761
- viewContext: viewContext
1762
- });
1763
- }
1764
- legends = get(Object.values(layers), '[].legends[]').filter(Boolean).map(function (legend, index) {
1765
- return __assign(__assign({}, legend), {
1766
- id: "".concat(viewSpec.id, "_").concat(index)
1767
- });
1768
- });
1769
- if (viewSpec.debug) {
1770
- console.log('resolveView / legends', legends, {
1771
- viewSpec: viewSpec,
1772
- viewConf: viewConf,
1773
- viewContext: viewContext
1774
- });
1775
- }
1776
- VIEW_AT_DOWNLOAD_STAGE = __assign(__assign({}, VIEW_AT_LAYERS_STAGE), {
1777
- layers: layers,
1778
- legends: legends
1779
- });
1780
- return [4 /*yield*/, resolveExprAsync(viewSpec.download, __assign(__assign({}, viewContext), {
1781
- view: VIEW_AT_DOWNLOAD_STAGE
1782
- }))];
1783
- case 4:
1784
- download = _a.sent();
1785
- return [2 /*return*/, {
1786
- id: viewSpec.id,
1787
- keywords: viewSpec.keywords,
1788
- metadata: metadata,
1789
- sources: sources,
1790
- layers: layers,
1791
- legends: legends,
1792
- download: download
1793
- }];
1794
- }
1795
- });
1796
- });
1797
- }
1798
-
1799
1614
  var BASE_MAP_LAYERS = [
1800
1615
  // {
1801
1616
  // "id": "Background",
@@ -4381,6 +4196,85 @@ function _ogr2ogr() {
4381
4196
  return _ogr2ogr.apply(this, arguments);
4382
4197
  }
4383
4198
 
4199
+ var worker = typeof Worker !== 'undefined' && new Worker(new URL('./GeoReDUSWorker.worker.js', import.meta.url), {
4200
+ type: 'module'
4201
+ });
4202
+ var GeoReDUSWorker = worker ? wrap(worker) : null;
4203
+
4204
+ // export const $workerGet: ExpressionSpec<[any, any?]> = {
4205
+ // parseArgs: ([arg1, arg2], { parseNodeInput }) =>
4206
+ // typeof arg2 === 'undefined'
4207
+ // ? [parseNodeInput(arg1)]
4208
+ // : [parseNodeInput(arg1), parseNodeInput(arg2)],
4209
+ // fn: (args, context) => {
4210
+ // const path = args[0]
4211
+ // const src = args.length === 1 ? context : args[1]
4212
+ // return path === '' ? src : GeoReDUSWorker.get(src, path)
4213
+ // },
4214
+ // }
4215
+ var $naturalBreaks = function $naturalBreaks(_a) {
4216
+ var values = _a[0],
4217
+ opt = _a[1];
4218
+ var breaks = GeoReDUSWorker.scaleNaturalBreaks(__assign({
4219
+ values: values
4220
+ }, isPlainObject(opt) ? pick(opt, ['scalesByK', 'k', 'minK', 'maxK', 'defaultColor']) : {}));
4221
+ return breaks;
4222
+ };
4223
+ // export const $test = ()
4224
+ var $urlSearch = function $urlSearch(_a) {
4225
+ var searchParams = _a[0];
4226
+ return Array.isArray(searchParams) ? queryString.stringify(searchParams[0], searchParams[1]) : queryString.stringify(
4227
+ //
4228
+ // By default, stringify non primitive values using
4229
+ // JSON.stringify before passing on to queryString,
4230
+ // as by default queryString ignores non-primitive values.
4231
+ //
4232
+ // This still allows for custom formatting, throgh the array
4233
+ // searchParams input, w/ second arg as options passed
4234
+ // to queryString
4235
+ //
4236
+ Object.fromEntries(Object.entries(searchParams).map(function (_a) {
4237
+ var key = _a[0],
4238
+ value = _a[1];
4239
+ return [key, _typeof(value) === 'object' && value !== null ? JSON.stringify(value) : value];
4240
+ })));
4241
+ };
4242
+
4243
+ var CUSTOM_EXPR = /*#__PURE__*/Object.freeze({
4244
+ __proto__: null,
4245
+ $naturalBreaks: $naturalBreaks,
4246
+ $urlSearch: $urlSearch
4247
+ });
4248
+
4249
+ var _a;
4250
+ //
4251
+ // TODO: set dynamic values
4252
+ //
4253
+ var HARD_CODED_ALLOW_FETCH_SOURCES = (_a = {}, _a['https://dev-geoapi-metadata.orioro.design'] = ['GET', 'POST'], _a['http://localhost:6001'] = ['GET', 'POST'], _a);
4254
+ console.warn('TODO: remove HARD_CODED_ALLOW_FETCH_SOURCES');
4255
+ function isFetchAllowed(resource, options) {
4256
+ return __awaiter(this, void 0, void 0, function () {
4257
+ return __generator(this, function (_a) {
4258
+ return [2 /*return*/, fetchExpr.allowOrigins(HARD_CODED_ALLOW_FETCH_SOURCES)(resource, options)];
4259
+ });
4260
+ });
4261
+ }
4262
+ var _b = makeResolve({
4263
+ resolvers: withExpressionResolvers(expressions.syntaxArrayExpr({
4264
+ name: '$$logical',
4265
+ symbol: Symbol["for"]('$$logical'),
4266
+ // @ts-ignore
4267
+ exps: __assign(__assign(__assign({}, ALL_EXPR), CUSTOM_EXPR), {
4268
+ $fetch: fetchExpr({
4269
+ isFetchAllowed: isFetchAllowed
4270
+ })
4271
+ })
4272
+ }).resolver),
4273
+ defaultResolver: $$literal
4274
+ }),
4275
+ resolveExprAsync = _b.resolveAsync,
4276
+ resolveExpr = _b.resolve;
4277
+
4384
4278
  var EXTENSIONS_BY_FORMAT = {
4385
4279
  GeoJSON: 'geojson',
4386
4280
  GPKG: 'gpkg',
@@ -4546,6 +4440,25 @@ function downloadResolver(downloadConf) {
4546
4440
  });
4547
4441
  }
4548
4442
 
4443
+ function zoomSensitiveLinearSizes(_a) {
4444
+ var variable = _a.variable,
4445
+ minValue = _a.minValue,
4446
+ maxValue = _a.maxValue,
4447
+ minSize = _a.minSize,
4448
+ maxSize = _a.maxSize,
4449
+ _b = _a.zoomBreakpoint,
4450
+ zoomBreakpoint = _b === void 0 ? 12 : _b;
4451
+ var hasMinAndMaxValues =
4452
+ //
4453
+ // Accept minValue expressions or actual numbers,
4454
+ // must check for 0 explicitly
4455
+ //
4456
+ (minValue || minValue === 0) && (maxValue || maxValue === 0);
4457
+ var defaultSize = hasMinAndMaxValues ? ['interpolate', ['linear'], variable, minValue, minSize / 2, maxValue, maxSize / 2] : minSize;
4458
+ var largerSize = hasMinAndMaxValues ? ['interpolate', ['linear'], variable, minValue, minSize, maxValue, maxSize] : maxSize;
4459
+ return ['step', ['zoom'], defaultSize, zoomBreakpoint, largerSize];
4460
+ }
4461
+
4549
4462
  var _excluded = ["version"];
4550
4463
  function tableVectorSource(context, tableId) {
4551
4464
  var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
@@ -4645,16 +4558,20 @@ function numerical_choropleth$1(base, _ref) {
4645
4558
  var TABLE_ID = collection_id;
4646
4559
  var VECTOR_SOURCE_ID = "".concat(TABLE_ID, ".geom");
4647
4560
  var _color_scheme = COLOR_SCHEMES[color_scheme];
4561
+ var $circleColor = ['$if', ['$empty', ['$get', 'view.metadata.colorScaleStops']], INSUFFICIENT_DATA_COLOR$1, ['$flat', [['step', ['coalesce', ['get', variable_id], -1]], ['$get', 'view.metadata.colorScaleStops']]]];
4648
4562
  return _objectSpread2(_objectSpread2({}, base), {}, {
4649
- metadata: ['$let', base.metadata, {
4650
- variableValues: ['$get', 'variableValues'],
4651
- sizingValues: ['$get', 'sizingValues'],
4652
- colorScaleStops: ['$naturalBreaks', ['$get', 'variableValues'], ['$merge', _color_scheme, {
4653
- minK: 5
4654
- }]]
4655
- }],
4656
- layers: _objectSpread2(_objectSpread2({}, base.layers), {}, _defineProperty({}, "".concat(VECTOR_SOURCE_ID, "_circle"), vectorLayer(VECTOR_SOURCE_ID, {
4657
- zIndex: ABOVE_BASE_MAP_LAYERS_Z_INDEX_BASE,
4563
+ metadata: {
4564
+ _value: ['$let', base.metadata._value, {
4565
+ variableValues: ['$get', 'variableValues'],
4566
+ sizingValues: ['$get', 'sizingValues'],
4567
+ influenceArea: ['$get', 'influenceArea'],
4568
+ colorScaleStops: ['$naturalBreaks', ['$get', 'variableValues'], ['$merge', _color_scheme, {
4569
+ minK: 5
4570
+ }]]
4571
+ }]
4572
+ },
4573
+ layers: _objectSpread2(_objectSpread2({}, base.layers), {}, _defineProperty(_defineProperty({}, "".concat(VECTOR_SOURCE_ID, "_circle"), vectorLayer(VECTOR_SOURCE_ID, {
4574
+ zIndex: ABOVE_BASE_MAP_LAYERS_Z_INDEX_BASE + 2,
4658
4575
  type: 'circle',
4659
4576
  legends: [{
4660
4577
  type: 'SequentialColorLegend',
@@ -4675,8 +4592,12 @@ function numerical_choropleth$1(base, _ref) {
4675
4592
  'circle-radius': $circleRadius,
4676
4593
  'circle-stroke-width': 1,
4677
4594
  'circle-stroke-color': '#000000',
4678
- 'circle-color': ['$if', ['$empty', ['$get', 'view.metadata.colorScaleStops']], INSUFFICIENT_DATA_COLOR$1, ['$flat', [['step', ['coalesce', ['get', variable_id], -1]], ['$get', 'view.metadata.colorScaleStops']]]]
4595
+ 'circle-color': $circleColor
4679
4596
  }
4597
+ })), "influenceArea_fill", _objectSpread2(_objectSpread2({}, base.layers.influenceArea_fill), {}, {
4598
+ paint: _objectSpread2(_objectSpread2({}, base.layers.influenceArea_fill.paint), {}, {
4599
+ 'fill-color': $circleColor
4600
+ })
4680
4601
  })))
4681
4602
  });
4682
4603
  }
@@ -4696,7 +4617,7 @@ function numerical_size$1(base, _ref) {
4696
4617
  var SIZE_MIN = 6;
4697
4618
  return _objectSpread2(_objectSpread2({}, base), {}, {
4698
4619
  layers: _objectSpread2(_objectSpread2({}, base.layers), {}, _defineProperty({}, "".concat(VECTOR_SOURCE_ID, "_circle"), vectorLayer(VECTOR_SOURCE_ID, {
4699
- zIndex: ABOVE_BASE_MAP_LAYERS_Z_INDEX_BASE,
4620
+ zIndex: ABOVE_BASE_MAP_LAYERS_Z_INDEX_BASE + 2,
4700
4621
  type: 'circle',
4701
4622
  legends: [{
4702
4623
  type: 'ProportionalSymbolLegend',
@@ -4717,13 +4638,14 @@ function numerical_size$1(base, _ref) {
4717
4638
  'circle-opacity': 1,
4718
4639
  'circle-stroke-width': 1,
4719
4640
  'circle-stroke-color': '#000000',
4720
- 'circle-radius': ['$if', ['$gt', ['$get', 'length', ['$get', 'view.metadata.variableValues']], 1], ['interpolate', ['linear'], ['get', variable_id],
4721
- // Replace "density" with your property name
4722
- ['$min', ['$get', 'view.metadata.variableValues']], SIZE_MIN,
4723
- // When qt_mat_fund_ai is 0, radius is 6
4724
- ['$max', ['$get', 'view.metadata.variableValues']], SIZE_MAX // When qt_mat_fund_ai is 100, radius is 20
4725
- ], 10],
4726
- 'circle-color': get$1(COLOR_SCHEMES, color_scheme) || color_scheme
4641
+ 'circle-radius': ['$if', ['$gt', ['$get', 'length', ['$get', 'view.metadata.variableValues']], 1], zoomSensitiveLinearSizes({
4642
+ variable: ['get', variable_id],
4643
+ minValue: ['$min', ['$get', 'view.metadata.variableValues']],
4644
+ maxValue: ['$max', ['$get', 'view.metadata.variableValues']],
4645
+ minSize: SIZE_MIN,
4646
+ maxSize: SIZE_MAX
4647
+ }), 10],
4648
+ 'circle-color': get(COLOR_SCHEMES, color_scheme) || color_scheme
4727
4649
  }
4728
4650
  })))
4729
4651
  });
@@ -4744,12 +4666,12 @@ function categorical$1(base, _ref) {
4744
4666
  var VECTOR_SOURCE_ID = "".concat(TABLE_ID, ".geom");
4745
4667
  categories = categories ? categories.map(function (category) {
4746
4668
  return _objectSpread2(_objectSpread2({}, category), {}, {
4747
- color: get$1(COLOR_SCHEMES, category.color) || category.color
4669
+ color: get(COLOR_SCHEMES, category.color) || category.color
4748
4670
  });
4749
4671
  }) : null;
4750
4672
  return _objectSpread2(_objectSpread2({}, base), {}, {
4751
4673
  layers: _objectSpread2(_objectSpread2({}, base.layers), {}, _defineProperty({}, "".concat(VECTOR_SOURCE_ID, "_circle"), vectorLayer(VECTOR_SOURCE_ID, {
4752
- zIndex: ABOVE_BASE_MAP_LAYERS_Z_INDEX_BASE,
4674
+ zIndex: ABOVE_BASE_MAP_LAYERS_Z_INDEX_BASE + 2,
4753
4675
  type: 'circle',
4754
4676
  legends: [].concat(_toConsumableArray(categories ? [{
4755
4677
  type: 'ColorLegend',
@@ -4796,6 +4718,7 @@ var BY_TYPE$1 = {
4796
4718
  boolean_categorical: boolean_categorical$1,
4797
4719
  categorical: categorical$1
4798
4720
  };
4721
+ var DEFAULT_BUFFER_SIZE$1 = 200;
4799
4722
  function cem_escolas_2022(config, allViewSpecs, context) {
4800
4723
  var collection_id = config.collection_id,
4801
4724
  variable_id = config.variable_id,
@@ -4846,7 +4769,7 @@ function cem_escolas_2022(config, allViewSpecs, context) {
4846
4769
  path: indicator_path,
4847
4770
  metodology: metodology,
4848
4771
  keywords: [indicator_path, $sourceLabel, 'educação', keywords].filter(Boolean),
4849
- conf: {
4772
+ confSchema: {
4850
4773
  data: {
4851
4774
  variantId: {
4852
4775
  label: 'Rede de ensino:',
@@ -4867,38 +4790,148 @@ function cem_escolas_2022(config, allViewSpecs, context) {
4867
4790
  type: 'booleanCheckbox',
4868
4791
  description: 'Tamanho proporcional à quantidade de matrículas',
4869
4792
  defaultValue: true
4870
- } : null
4793
+ } : null,
4794
+ showInfluenceArea: {
4795
+ type: 'booleanCheckbox',
4796
+ label: 'Área de influência',
4797
+ description: 'Visualizar área de influência',
4798
+ defaultValue: true
4799
+ },
4800
+ influenceAreaRadius: {
4801
+ type: 'slider',
4802
+ inactive: resolve.literal(resolve.fn(function (context) {
4803
+ var _context$value;
4804
+ return !((_context$value = context.value) !== null && _context$value !== void 0 && _context$value.showInfluenceArea);
4805
+ })),
4806
+ label: resolve.literal(resolve.fn(function (context) {
4807
+ var _context$value2;
4808
+ return "Raio de influ\xEAncia (".concat(((_context$value2 = context.value) === null || _context$value2 === void 0 ? void 0 : _context$value2.influenceAreaRadius) || DEFAULT_BUFFER_SIZE$1, "m)");
4809
+ })),
4810
+ helperText: 'Raio de influência da escola',
4811
+ min: 0,
4812
+ max: 2000,
4813
+ step: 50,
4814
+ defaultValue: DEFAULT_BUFFER_SIZE$1
4815
+ },
4816
+ dissolveOverlappingGeometries: {
4817
+ inactive: resolve.literal(resolve.fn(function (context) {
4818
+ var _context$value3;
4819
+ return !((_context$value3 = context.value) !== null && _context$value3 !== void 0 && _context$value3.showInfluenceArea);
4820
+ })),
4821
+ type: 'booleanCheckbox',
4822
+ label: 'Dissolver geometrias',
4823
+ description: 'Unir geometrias sobrepostas',
4824
+ defaultValue: false
4825
+ }
4871
4826
  }
4872
4827
  },
4873
4828
  metadata: {
4874
- variableValues: ['$get', ['$template', '[].${0}', VARIABLE_ID], ['$fetch', {
4875
- href: METADATA_API_ENDPOINT,
4876
- pathname: collection_id,
4877
- searchParams: ['$merge', {
4878
- select: VARIABLE_ID,
4879
- id_municipio: _id_municipio_apiFilterExpr
4880
- }, _fetchMetadataApiFilterExpResolver]
4881
- }]],
4882
- sizingValues: sizing_variable_id ? ['$if', ['$get', 'view.conf.data.showSize'], ['$filter', ['$get', ['$template', '[].${0}', sizing_variable_id], ['$fetch', {
4883
- href: METADATA_API_ENDPOINT,
4884
- pathname: collection_id,
4885
- searchParams: ['$merge', {
4886
- select: sizing_variable_id,
4887
- id_municipio: _id_municipio_apiFilterExpr
4888
- }, _fetchMetadataApiFilterExpResolver]
4889
- }]], ['$and', ['$not', ['$empty', ['$iterator', 'item']]], ['$gt', ['$iterator', 'item'], 0]]], null] : null
4829
+ _value: ['$let', {
4830
+ rawData: ['$fetch', {
4831
+ href: METADATA_API_ENDPOINT,
4832
+ pathname: collection_id,
4833
+ searchParams: ['$merge', {
4834
+ select: [VARIABLE_ID, 'geom'].join(','),
4835
+ id_municipio: _id_municipio_apiFilterExpr
4836
+ }, _fetchMetadataApiFilterExpResolver]
4837
+ }]
4838
+ }, {
4839
+ variableValues: ['$get', ['$template', 'rawData[].${0}', VARIABLE_ID]],
4840
+ sizingValues: sizing_variable_id ? ['$if', ['$get', 'view.conf.data.showSize'], ['$filter', ['$get', ['$template', '[].${0}', sizing_variable_id], ['$fetch', {
4841
+ href: METADATA_API_ENDPOINT,
4842
+ pathname: collection_id,
4843
+ searchParams: ['$merge', {
4844
+ select: sizing_variable_id,
4845
+ id_municipio: _id_municipio_apiFilterExpr
4846
+ }, _fetchMetadataApiFilterExpResolver]
4847
+ }]], ['$and', ['$not', ['$empty', ['$iterator', 'item']]], ['$gt', ['$iterator', 'item'], 0]]], null] : null,
4848
+ influenceArea: resolveAsync.fn(/*#__PURE__*/function () {
4849
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(context) {
4850
+ var _ref2, influenceAreaRadius, showInfluenceArea, dissolveOverlappingGeometries, influenceArea;
4851
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
4852
+ while (1) switch (_context.prev = _context.next) {
4853
+ case 0:
4854
+ _ref2 = get(context, 'view.conf.data') || {}, influenceAreaRadius = _ref2.influenceAreaRadius, showInfluenceArea = _ref2.showInfluenceArea, dissolveOverlappingGeometries = _ref2.dissolveOverlappingGeometries;
4855
+ if (!(showInfluenceArea && typeof influenceAreaRadius === 'number' && influenceAreaRadius > 0 && context.rawData)) {
4856
+ _context.next = 12;
4857
+ break;
4858
+ }
4859
+ _context.prev = 2;
4860
+ _context.next = 5;
4861
+ return GeoReDUSWorker.buffer({
4862
+ type: 'FeatureCollection',
4863
+ features: context.rawData.map(function (entry) {
4864
+ return {
4865
+ type: 'Feature',
4866
+ geometry: entry.geom,
4867
+ properties: omit(entry, ['geom'])
4868
+ };
4869
+ })
4870
+ }, influenceAreaRadius, {
4871
+ units: 'meters',
4872
+ dissolve: dissolveOverlappingGeometries
4873
+ });
4874
+ case 5:
4875
+ influenceArea = _context.sent;
4876
+ return _context.abrupt("return", influenceArea);
4877
+ case 9:
4878
+ _context.prev = 9;
4879
+ _context.t0 = _context["catch"](2);
4880
+ return _context.abrupt("return", null);
4881
+ case 12:
4882
+ return _context.abrupt("return", null);
4883
+ case 13:
4884
+ case "end":
4885
+ return _context.stop();
4886
+ }
4887
+ }, _callee, null, [[2, 9]]);
4888
+ }));
4889
+ return function (_x) {
4890
+ return _ref.apply(this, arguments);
4891
+ };
4892
+ }())
4893
+ }]
4890
4894
  },
4891
- sources: _objectSpread2(_objectSpread2({}, globalRes.sources), {}, _defineProperty({}, VECTOR_SOURCE_ID, tableVectorSource(context, collection_id, {
4895
+ sources: _objectSpread2(_objectSpread2({}, globalRes.sources), {}, _defineProperty(_defineProperty({}, VECTOR_SOURCE_ID, tableVectorSource(context, collection_id, {
4892
4896
  attribution: $sourceLabel,
4897
+ promoteId: 'id_escola',
4893
4898
  version: 2,
4894
4899
  minzoom: 8,
4895
4900
  maxzoom: 20
4896
- }))),
4897
- layers: _objectSpread2({}, globalRes.layers),
4898
- download: downloadResolver({
4899
- fileNameBase: ['$template', '${0}_${1}_georedus_edu', [VARIABLE_ID, ['$get', 'municipioId']]],
4900
- mainVariableId: VARIABLE_ID,
4901
- availableVariableIds: uniqBy(allViewSpecs.filter(function (spec) {
4901
+ })), "influenceArea", ['$if', [['$empty', ['$get', 'view.metadata.influenceArea']]], null, resolve.fn(function (context) {
4902
+ return {
4903
+ type: 'geojson',
4904
+ data: context.view.metadata.influenceArea
4905
+ };
4906
+ })])),
4907
+ layers: _objectSpread2(_objectSpread2({}, globalRes.layers), {}, {
4908
+ influenceArea_fill: {
4909
+ zIndex: ABOVE_BASE_MAP_LAYERS_Z_INDEX_BASE + 1,
4910
+ hidden: ['$empty', ['$get', 'view.metadata.influenceArea']],
4911
+ source: 'influenceArea',
4912
+ type: 'fill',
4913
+ paint: {
4914
+ 'fill-color': get(COLOR_SCHEMES, 'schemeSet1.colors[1]'),
4915
+ 'fill-opacity': 0.3
4916
+ }
4917
+ },
4918
+ influenceArea_boundaries: {
4919
+ zIndex: ABOVE_BASE_MAP_LAYERS_Z_INDEX_BASE + 1,
4920
+ hidden: ['$empty', ['$get', 'view.metadata.influenceArea']],
4921
+ source: 'influenceArea',
4922
+ type: 'line',
4923
+ paint: {
4924
+ 'line-color': get(COLOR_SCHEMES, 'schemeSet1.colors[1]'),
4925
+ 'line-opacity': 0.8,
4926
+ 'line-width': 2,
4927
+ 'line-dasharray': [2, 2]
4928
+ }
4929
+ }
4930
+ }),
4931
+ download: downloadResolver({
4932
+ fileNameBase: ['$template', '${0}_${1}_georedus_edu', [VARIABLE_ID, ['$get', 'municipioId']]],
4933
+ mainVariableId: VARIABLE_ID,
4934
+ availableVariableIds: uniqBy(allViewSpecs.filter(function (spec) {
4902
4935
  return Boolean(spec.variable_id);
4903
4936
  }).map(function (spec) {
4904
4937
  return {
@@ -4910,13 +4943,13 @@ function cem_escolas_2022(config, allViewSpecs, context) {
4910
4943
  }),
4911
4944
  fetchData: resolve.fn(function (context) {
4912
4945
  return /*#__PURE__*/function () {
4913
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
4946
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref3) {
4914
4947
  var variableIds;
4915
- return _regeneratorRuntime().wrap(function _callee$(_context) {
4916
- while (1) switch (_context.prev = _context.next) {
4948
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
4949
+ while (1) switch (_context2.prev = _context2.next) {
4917
4950
  case 0:
4918
- variableIds = _ref.variableIds, _ref.options;
4919
- _context.next = 3;
4951
+ variableIds = _ref3.variableIds, _ref3.options;
4952
+ _context2.next = 3;
4920
4953
  return resolveExprAsync(['$fetch', {
4921
4954
  href: METADATA_API_ENDPOINT,
4922
4955
  pathname: collection_id,
@@ -4926,15 +4959,15 @@ function cem_escolas_2022(config, allViewSpecs, context) {
4926
4959
  }, _fetchMetadataApiFilterExpResolver]
4927
4960
  }], context);
4928
4961
  case 3:
4929
- return _context.abrupt("return", _context.sent);
4962
+ return _context2.abrupt("return", _context2.sent);
4930
4963
  case 4:
4931
4964
  case "end":
4932
- return _context.stop();
4965
+ return _context2.stop();
4933
4966
  }
4934
- }, _callee);
4967
+ }, _callee2);
4935
4968
  }));
4936
- return function (_x) {
4937
- return _ref2.apply(this, arguments);
4969
+ return function (_x2) {
4970
+ return _ref4.apply(this, arguments);
4938
4971
  };
4939
4972
  }();
4940
4973
  })
@@ -4956,12 +4989,13 @@ function cem_escolas_2022(config, allViewSpecs, context) {
4956
4989
  var filter = variantId ? variantSpec.filter : null;
4957
4990
  return ['all', ['==', ['get', 'id_municipio'], ['$get', 'municipioId']]].concat(_toConsumableArray(isPlainObject(filter) ? fmtMaplibreGlFilterExp(filter) : []));
4958
4991
  });
4959
- var $circleRadius = sizing_variable_id ? ['$if', ['$and', ['$get', 'view.conf.data.showSize'], ['$gt', ['$get', 'length', ['$get', 'view.metadata.sizingValues']], 1]], ['interpolate', ['linear'], ['get', sizing_variable_id],
4960
- // Replace "density" with your property name
4961
- ['$min', ['$get', 'view.metadata.sizingValues']], SIZE_MIN,
4962
- // When qt_mat_fund_ai is 0, radius is 6
4963
- ['$max', ['$get', 'view.metadata.sizingValues']], SIZE_MAX // When qt_mat_fund_ai is 100, radius is 20
4964
- ], SIZE_DEFAULT] : SIZE_DEFAULT;
4992
+ var $circleRadius = sizing_variable_id ? ['$if', ['$and', ['$get', 'view.conf.data.showSize'], ['$gt', ['$get', 'length', ['$get', 'view.metadata.sizingValues']], 1]], zoomSensitiveLinearSizes({
4993
+ variable: ['get', sizing_variable_id],
4994
+ minValue: ['$min', ['$get', 'view.metadata.sizingValues']],
4995
+ maxValue: ['$max', ['$get', 'view.metadata.sizingValues']],
4996
+ minSize: SIZE_MIN,
4997
+ maxSize: SIZE_MAX
4998
+ }), SIZE_DEFAULT] : SIZE_DEFAULT;
4965
4999
  var $tooltip = {
4966
5000
  title: ['$literal', ['$get', 'feature.properties.no_escola']],
4967
5001
  entries: [[indicator_label, ['$literal', ['$coalesce', ['$get', "feature.properties.".concat(VARIABLE_ID, "::string({\n number: ").concat(JSON.stringify(number_format), ",\n boolean: {\n true: 'Sim',\n false: 'N\xE3o'\n }\n })")], 'Sem dados']]], sizing_variable_id ? [sizing_variable_label, ['$literal', ['$get', "feature.properties.".concat(sizing_variable_id, "::string")]]] : null, ['Etapas de ensino', ['$literal', resolve.fn(function (context) {
@@ -4972,16 +5006,16 @@ function cem_escolas_2022(config, allViewSpecs, context) {
4972
5006
  in_fund_af: 'Fundamental II',
4973
5007
  in_med: 'Ensino Médio'
4974
5008
  };
4975
- return Object.entries(ETAPAS).filter(function (_ref3) {
5009
+ return Object.entries(ETAPAS).filter(function (_ref5) {
4976
5010
  var _context$feature, _context$feature2;
4977
- var _ref4 = _slicedToArray(_ref3, 2),
4978
- key = _ref4[0];
4979
- _ref4[1];
5011
+ var _ref6 = _slicedToArray(_ref5, 2),
5012
+ key = _ref6[0];
5013
+ _ref6[1];
4980
5014
  return (context === null || context === void 0 || (_context$feature = context.feature) === null || _context$feature === void 0 ? void 0 : _context$feature.properties) && (context === null || context === void 0 || (_context$feature2 = context.feature) === null || _context$feature2 === void 0 ? void 0 : _context$feature2.properties[key]);
4981
- }).map(function (_ref5) {
4982
- var _ref6 = _slicedToArray(_ref5, 2);
4983
- _ref6[0];
4984
- var label = _ref6[1];
5015
+ }).map(function (_ref7) {
5016
+ var _ref8 = _slicedToArray(_ref7, 2);
5017
+ _ref8[0];
5018
+ var label = _ref8[1];
4985
5019
  return label;
4986
5020
  }).join(', ');
4987
5021
  })]], ['Rede de ensino', ['$literal', ['$get', 'feature.properties.tp_dependencia']]]].filter(Boolean)
@@ -5182,7 +5216,7 @@ function cem_censo_2010_2022(viewSpec, allViewSpecs, context) {
5182
5216
  sourceLabel: sourceLabel,
5183
5217
  viewType: VIEW_TYPE_SURFACE_CHOROPLETH,
5184
5218
  keywords: [indicator_path, sourceLabel, variant_path, variant_label, variable_id, keywords].filter(Boolean),
5185
- conf: {
5219
+ confSchema: {
5186
5220
  data: {
5187
5221
  variableId: {
5188
5222
  label: 'Recorte:',
@@ -5206,11 +5240,11 @@ function cem_censo_2010_2022(viewSpec, allViewSpecs, context) {
5206
5240
  'TIFF/GeoTIFF (.tif/.tiff)', 'GeoJSON (.json/.geojson)', 'ESRI Shapefile (armazenar arquivos .shp, .shx, .dbf, etc. em um arquivo .zip único)'].join(', ')
5207
5241
  },
5208
5242
  pointsDisplayMode: {
5209
- inactive: resolve.fn(function (context) {
5243
+ inactive: resolve.literal(resolve.fn(function (context) {
5210
5244
  var _context$value;
5211
5245
  var geometryTypes = (_context$value = context.value) === null || _context$value === void 0 || (_context$value = _context$value.customSpatialAggregationUnit) === null || _context$value === void 0 || (_context$value = _context$value.GEO_FILE_METADATA) === null || _context$value === void 0 ? void 0 : _context$value.geometryTypes;
5212
5246
  return !Array.isArray(geometryTypes) || !geometryTypes.includes('Point');
5213
- }),
5247
+ })),
5214
5248
  clearable: false,
5215
5249
  type: 'treeSelect',
5216
5250
  label: 'Visualizar pontos',
@@ -5227,26 +5261,26 @@ function cem_censo_2010_2022(viewSpec, allViewSpecs, context) {
5227
5261
  },
5228
5262
  bufferSize: {
5229
5263
  type: 'slider',
5230
- label: resolve.fn(function (context) {
5264
+ label: resolve.literal(resolve.fn(function (context) {
5231
5265
  var _context$value2;
5232
5266
  return "Raio de influ\xEAncia (".concat(((_context$value2 = context.value) === null || _context$value2 === void 0 ? void 0 : _context$value2.bufferSize) || DEFAULT_BUFFER_SIZE, "m)");
5233
- }),
5267
+ })),
5234
5268
  helperText: 'Raio de influência do ponto',
5235
5269
  min: 0,
5236
5270
  max: 2000,
5237
5271
  step: 50,
5238
5272
  defaultValue: DEFAULT_BUFFER_SIZE,
5239
- inactive: resolve.fn(function (context) {
5273
+ inactive: resolve.literal(resolve.fn(function (context) {
5240
5274
  var _context$value3, _context$value4;
5241
5275
  var geometryTypes = (_context$value3 = context.value) === null || _context$value3 === void 0 || (_context$value3 = _context$value3.customSpatialAggregationUnit) === null || _context$value3 === void 0 || (_context$value3 = _context$value3.GEO_FILE_METADATA) === null || _context$value3 === void 0 ? void 0 : _context$value3.geometryTypes;
5242
5276
  return !Array.isArray(geometryTypes) || !geometryTypes.includes('Point') && !geometryTypes.includes('LineString') || ((_context$value4 = context.value) === null || _context$value4 === void 0 ? void 0 : _context$value4.pointsDisplayMode) === 'heatmap';
5243
- })
5277
+ }))
5244
5278
  },
5245
5279
  dissolveOverlappingGeometries: {
5246
- inactive: resolve.fn(function (context) {
5280
+ inactive: resolve.literal(resolve.fn(function (context) {
5247
5281
  var _context$value5, _context$value6;
5248
5282
  return !Boolean((_context$value5 = context.value) === null || _context$value5 === void 0 || (_context$value5 = _context$value5.customSpatialAggregationUnit) === null || _context$value5 === void 0 ? void 0 : _context$value5.GEO_FILE_METADATA) || ((_context$value6 = context.value) === null || _context$value6 === void 0 ? void 0 : _context$value6.pointsDisplayMode) === 'heatmap';
5249
- }),
5283
+ })),
5250
5284
  type: 'booleanCheckbox',
5251
5285
  label: 'Dissolver geometrias',
5252
5286
  description: 'Unir geometrias sobrepostas',
@@ -5265,119 +5299,150 @@ function cem_censo_2010_2022(viewSpec, allViewSpecs, context) {
5265
5299
  }
5266
5300
  }
5267
5301
  },
5268
- metadata: ['$let', {
5269
- customGeoJSON: ['$if', ['$empty', ['$get', 'view.conf.data.customSpatialAggregationUnit']], null, resolveAsync.fn(/*#__PURE__*/function () {
5270
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(context) {
5271
- var contents, BASE, POINTS, LINE_STRINGS, AREAS_FEATURES, AREAS_BASE, AREAS;
5272
- return _regeneratorRuntime().wrap(function _callee$(_context) {
5273
- while (1) switch (_context.prev = _context.next) {
5274
- case 0:
5275
- _context.next = 2;
5276
- return fileReadAs(context.view.conf.data.customSpatialAggregationUnit, 'text');
5277
- case 2:
5278
- contents = _context.sent;
5279
- BASE = JSON.parse(contents); //
5280
- // Generate a layer with points only
5281
- //
5282
- POINTS = _objectSpread2(_objectSpread2({}, BASE), {}, {
5283
- features: BASE.features.filter(function (feat) {
5284
- var _feat$geometry;
5285
- return ((_feat$geometry = feat.geometry) === null || _feat$geometry === void 0 ? void 0 : _feat$geometry.type) === 'Point';
5286
- })
5287
- });
5288
- LINE_STRINGS = _objectSpread2(_objectSpread2({}, BASE), {}, {
5289
- features: BASE.features.filter(function (feat) {
5290
- var _feat$geometry2;
5291
- return ((_feat$geometry2 = feat.geometry) === null || _feat$geometry2 === void 0 ? void 0 : _feat$geometry2.type) === 'LineString';
5292
- })
5293
- }); //
5294
- // Layer with areas
5295
- //
5296
- AREAS_FEATURES = context.view.conf.data.pointsDisplayMode === 'heatmap' ?
5297
- //
5298
- // If points are set to be displayed as heatmap,
5299
- // remove them from area calculation
5300
- //
5301
- BASE.features.filter(function (feat) {
5302
- var _feat$geometry3;
5303
- return ((_feat$geometry3 = feat.geometry) === null || _feat$geometry3 === void 0 ? void 0 : _feat$geometry3.type) !== 'Point';
5304
- }) : BASE.features;
5305
- AREAS_BASE = _objectSpread2(_objectSpread2({}, BASE), {}, {
5306
- features: AREAS_FEATURES.map(function (feat) {
5307
- return _objectSpread2(_objectSpread2({}, feat), {}, {
5308
- geometry: _applyBuffers(feat.geometry, pick(context.view.conf.data, ['bufferSize']))
5309
- });
5310
- })
5311
- });
5312
- if (!(context.view.conf.data.pointsDisplayMode === 'heatmap')) {
5313
- _context.next = 12;
5302
+ metadata: {
5303
+ _dependencies: function _dependencies(_ref2) {
5304
+ _ref2.viewConfState;
5305
+ // console.log('run dependencies', omit(viewConfState.byId, [viewId]))
5306
+
5307
+ // return omit(viewConfState.byId, [viewId])
5308
+ return 'STABLE';
5309
+
5310
+ // return omit(viewConfState.byId, [viewId])
5311
+ },
5312
+ _value: ['$let', {
5313
+ customGeoJSON: ['$if', ['$empty', ['$get', 'view.conf.data.customSpatialAggregationUnit']], null, resolveAsync.fn(/*#__PURE__*/function () {
5314
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(context) {
5315
+ var contents, BASE, POINTS, LINE_STRINGS, AREAS_FEATURES, AREAS_BASE, AREAS;
5316
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
5317
+ while (1) switch (_context.prev = _context.next) {
5318
+ case 0:
5319
+ _context.prev = 0;
5320
+ _context.next = 3;
5321
+ return fileReadAs(context.view.conf.data.customSpatialAggregationUnit, 'text');
5322
+ case 3:
5323
+ contents = _context.sent;
5324
+ BASE = JSON.parse(contents); //
5325
+ // Generate a layer with points only
5326
+ //
5327
+ POINTS = _objectSpread2(_objectSpread2({}, BASE), {}, {
5328
+ features: BASE.features.filter(function (feat) {
5329
+ var _feat$geometry;
5330
+ return ((_feat$geometry = feat.geometry) === null || _feat$geometry === void 0 ? void 0 : _feat$geometry.type) === 'Point';
5331
+ })
5332
+ });
5333
+ LINE_STRINGS = _objectSpread2(_objectSpread2({}, BASE), {}, {
5334
+ features: BASE.features.filter(function (feat) {
5335
+ var _feat$geometry2;
5336
+ return ((_feat$geometry2 = feat.geometry) === null || _feat$geometry2 === void 0 ? void 0 : _feat$geometry2.type) === 'LineString';
5337
+ })
5338
+ }); //
5339
+ // Layer with areas
5340
+ //
5341
+ AREAS_FEATURES = context.view.conf.data.pointsDisplayMode === 'heatmap' ?
5342
+ //
5343
+ // If points are set to be displayed as heatmap,
5344
+ // remove them from area calculation
5345
+ //
5346
+ BASE.features.filter(function (feat) {
5347
+ var _feat$geometry3;
5348
+ return ((_feat$geometry3 = feat.geometry) === null || _feat$geometry3 === void 0 ? void 0 : _feat$geometry3.type) !== 'Point';
5349
+ }) : BASE.features;
5350
+ AREAS_BASE = _objectSpread2(_objectSpread2({}, BASE), {}, {
5351
+ features: AREAS_FEATURES.map(function (feat) {
5352
+ return _objectSpread2(_objectSpread2({}, feat), {}, {
5353
+ geometry: _applyBuffers(feat.geometry, pick(context.view.conf.data, ['bufferSize']))
5354
+ });
5355
+ })
5356
+ });
5357
+ if (!(context.view.conf.data.pointsDisplayMode === 'heatmap')) {
5358
+ _context.next = 13;
5359
+ break;
5360
+ }
5361
+ _context.t0 = null;
5362
+ _context.next = 21;
5314
5363
  break;
5315
- }
5316
- _context.t0 = null;
5317
- _context.next = 20;
5318
- break;
5319
- case 12:
5320
- if (!(context.view.conf.data.dissolveOverlappingGeometries && AREAS_BASE)) {
5321
- _context.next = 18;
5364
+ case 13:
5365
+ if (!(context.view.conf.data.dissolveOverlappingGeometries && AREAS_BASE)) {
5366
+ _context.next = 19;
5367
+ break;
5368
+ }
5369
+ _context.next = 16;
5370
+ return GeoReDUSWorker.dissolveAreasPreservingIsolated(AREAS_BASE);
5371
+ case 16:
5372
+ _context.t1 = _context.sent;
5373
+ _context.next = 20;
5322
5374
  break;
5323
- }
5324
- _context.next = 15;
5325
- return GeoReDUSWorker.dissolveAreasPreservingIsolated(AREAS_BASE);
5326
- case 15:
5327
- _context.t1 = _context.sent;
5328
- _context.next = 19;
5329
- break;
5330
- case 18:
5331
- _context.t1 = AREAS_BASE;
5332
- case 19:
5333
- _context.t0 = _context.t1;
5334
- case 20:
5335
- AREAS = _context.t0;
5336
- return _context.abrupt("return", {
5337
- BASE: BASE,
5338
- POINTS: POINTS,
5339
- LINE_STRINGS: LINE_STRINGS,
5340
- AREAS: AREAS
5341
- });
5342
- case 22:
5343
- case "end":
5344
- return _context.stop();
5345
- }
5346
- }, _callee);
5347
- }));
5348
- return function (_x) {
5349
- return _ref2.apply(this, arguments);
5350
- };
5351
- }())]
5352
- }, ['$let', {
5353
- variableValues: ['$if', ['$empty', ['$get', 'customGeoJSON.AREAS']], ['$get', ['$template', '[].${0}', ['$get', 'view.conf.data.variableId']], ['$fetch', ['$template', "".concat(METADATA_API_ENDPOINT) + '/${source_table_id}?select=' + '${variableId}' + '&cd_mun=eq.' + '${municipioId}', {
5354
- variableId: ['$get', 'view.conf.data.variableId'],
5355
- municipioId: ['$context', 'municipioId'],
5356
- source_table_id: ['$get', ['$template', '${0}.source_table_id', ['$get', 'view.conf.data.variableId']], variantsByVariableId]
5357
- }]]], ['$fetch', {
5358
- href: METADATA_API_ENDPOINT,
5359
- pathname: 'rpc/aggregate_by_geojson'
5375
+ case 19:
5376
+ _context.t1 = AREAS_BASE;
5377
+ case 20:
5378
+ _context.t0 = _context.t1;
5379
+ case 21:
5380
+ AREAS = _context.t0;
5381
+ return _context.abrupt("return", {
5382
+ BASE: BASE,
5383
+ POINTS: POINTS,
5384
+ LINE_STRINGS: LINE_STRINGS,
5385
+ AREAS: AREAS
5386
+ });
5387
+ case 25:
5388
+ _context.prev = 25;
5389
+ _context.t2 = _context["catch"](0);
5390
+ console.error(_context.t2);
5391
+ return _context.abrupt("return", null);
5392
+ case 29:
5393
+ case "end":
5394
+ return _context.stop();
5395
+ }
5396
+ }, _callee, null, [[0, 25]]);
5397
+ }));
5398
+ return function (_x) {
5399
+ return _ref3.apply(this, arguments);
5400
+ };
5401
+ }())]
5402
+ }, ['$let', {
5403
+ variableValues: ['$if', ['$empty', ['$get', 'customGeoJSON.AREAS']], ['$get', ['$template', '[].${0}', ['$get', 'view.conf.data.variableId']], ['$fetch', ['$template', "".concat(METADATA_API_ENDPOINT) + '/${source_table_id}?select=' + '${variableId}' + '&cd_mun=eq.' + '${municipioId}', {
5404
+ variableId: ['$get', 'view.conf.data.variableId'],
5405
+ municipioId: ['$context', 'municipioId'],
5406
+ source_table_id: ['$get', ['$template', '${0}.source_table_id', ['$get', 'view.conf.data.variableId']], variantsByVariableId]
5407
+ }]]], ['$fetch', {
5408
+ href: METADATA_API_ENDPOINT,
5409
+ pathname: 'rpc/aggregate_by_geojson'
5410
+ }, {
5411
+ method: 'POST',
5412
+ headers: {
5413
+ 'Content-Type': 'application/json'
5414
+ },
5415
+ body: {
5416
+ geometries: ['$get', 'features[].geometry', ['$get', 'customGeoJSON.AREAS']],
5417
+ view: 'ibge_malha_br_setor_censitario_2010_spatial_agg',
5418
+ agg_column: ['$get', 'view.conf.data.variableId'],
5419
+ agg_type: ['$if', ['$endsWith', ['$get', 'view.conf.data.variableId'], '_pct'], 'weighted_avg', 'sum']
5420
+ }
5421
+ }]]
5360
5422
  }, {
5361
- method: 'POST',
5362
- headers: {
5363
- 'Content-Type': 'application/json'
5364
- },
5365
- body: {
5366
- geometries: ['$get', 'features[].geometry', ['$get', 'customGeoJSON.AREAS']],
5367
- view: 'ibge_malha_br_setor_censitario_2010_spatial_agg',
5368
- agg_column: ['$get', 'view.conf.data.variableId'],
5369
- agg_type: ['$if', ['$endsWith', ['$get', 'view.conf.data.variableId'], '_pct'], 'weighted_avg', 'sum']
5370
- }
5423
+ labels: labels,
5424
+ measureUnits: measureUnits,
5425
+ variableValues: ['$get', 'variableValues'],
5426
+ customGeoJSON: ['$get', 'customGeoJSON'],
5427
+ customGeoJSON2: resolveAsync.fn(/*#__PURE__*/function () {
5428
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(context) {
5429
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
5430
+ while (1) switch (_context2.prev = _context2.next) {
5431
+ case 0:
5432
+ case "end":
5433
+ return _context2.stop();
5434
+ }
5435
+ }, _callee2);
5436
+ }));
5437
+ return function (_x2) {
5438
+ return _ref4.apply(this, arguments);
5439
+ };
5440
+ }()),
5441
+ colorScaleStops: ['$naturalBreaks', ['$get', 'variableValues'], _objectSpread2(_objectSpread2({}, _color_scheme), {}, {
5442
+ minK: 5
5443
+ })]
5371
5444
  }]]
5372
- }, {
5373
- labels: labels,
5374
- measureUnits: measureUnits,
5375
- variableValues: ['$get', 'variableValues'],
5376
- customGeoJSON: ['$get', 'customGeoJSON'],
5377
- colorScaleStops: ['$naturalBreaks', ['$get', 'variableValues'], _objectSpread2(_objectSpread2({}, _color_scheme), {}, {
5378
- minK: 5
5379
- })]
5380
- }]],
5445
+ },
5381
5446
  sources: _objectSpread2(_objectSpread2({}, globalRes.sources), {}, _defineProperty(_defineProperty({
5382
5447
  //
5383
5448
  // Points in custom GeoJson
@@ -5435,10 +5500,10 @@ function cem_censo_2010_2022(viewSpec, allViewSpecs, context) {
5435
5500
  }, VECTOR_SOURCE_ID, {
5436
5501
  type: 'vector',
5437
5502
  attribution: sourceLabel,
5438
- minzoom: 6,
5503
+ minzoom: 8,
5439
5504
  maxzoom: 20,
5440
5505
  promoteId: 'cd_setor',
5441
- tiles: [['$join', ["".concat(VECTOR_TILE_SERVER_ENDPOINT, "/dynamic_vector_tiles/{z}/{x}/{y}?"), ['$urlSearch', {
5506
+ tiles: [['$join', ["".concat(VECTOR_TILE_SERVER_ENDPOINT, "/dvt/{z}/{x}/{y}?"), ['$urlSearch', {
5442
5507
  view: ['$get', ['$template', '${0}.collection_id', ['$get', 'view.conf.data.variableId']], variantsByVariableId],
5443
5508
  select: ['cd_setor'],
5444
5509
  join_view: ['$get', ['$template', '${0}.source_table_id', ['$get', 'view.conf.data.variableId']], variantsByVariableId],
@@ -5454,7 +5519,7 @@ function cem_censo_2010_2022(viewSpec, allViewSpecs, context) {
5454
5519
  attribution: sourceLabel,
5455
5520
  minzoom: 6,
5456
5521
  maxzoom: 20,
5457
- tiles: [['$join', ["".concat(VECTOR_TILE_SERVER_ENDPOINT, "/dynamic_vector_tiles/{z}/{x}/{y}?"), ['$urlSearch', {
5522
+ tiles: [['$join', ["".concat(VECTOR_TILE_SERVER_ENDPOINT, "/dvt/{z}/{x}/{y}?"), ['$urlSearch', {
5458
5523
  view: 'overture_br_buildings',
5459
5524
  // view: [
5460
5525
  // '$get',
@@ -5546,7 +5611,7 @@ function cem_censo_2010_2022(viewSpec, allViewSpecs, context) {
5546
5611
  entries: [_variableValueTooltipEntry]
5547
5612
  },
5548
5613
  source: VECTOR_SOURCE_ID,
5549
- 'source-layer': 'dynamic_vector_tile',
5614
+ 'source-layer': 'dvt',
5550
5615
  type: 'fill',
5551
5616
  // maxzoom: 14,
5552
5617
  paint: {
@@ -5575,7 +5640,7 @@ function cem_censo_2010_2022(viewSpec, allViewSpecs, context) {
5575
5640
  }), "".concat(VECTOR_SOURCE_ID, "_boundary_lines"), {
5576
5641
  hidden: ['$not', ['$empty', ['$get', 'view.metadata.customGeoJSON.AREAS']]],
5577
5642
  source: VECTOR_SOURCE_ID,
5578
- 'source-layer': 'dynamic_vector_tile',
5643
+ 'source-layer': 'dvt',
5579
5644
  type: 'line',
5580
5645
  interactive: true,
5581
5646
  // minzoom: BUILDINGS_MIN_ZOOM,
@@ -5601,7 +5666,7 @@ function cem_censo_2010_2022(viewSpec, allViewSpecs, context) {
5601
5666
  // // ],
5602
5667
  // },
5603
5668
  source: "".concat(VECTOR_SOURCE_ID, "_buildings"),
5604
- 'source-layer': 'dynamic_vector_tile',
5669
+ 'source-layer': 'dvt',
5605
5670
  type: 'fill-extrusion',
5606
5671
  minzoom: BUILDINGS_MIN_ZOOM,
5607
5672
  paint: {
@@ -5633,38 +5698,38 @@ function cem_censo_2010_2022(viewSpec, allViewSpecs, context) {
5633
5698
  // availableVariableIds: [variable_id, 'str_nome_fantasia', 'id_cnes'],
5634
5699
  fetchData: resolve.fn(function (context) {
5635
5700
  return /*#__PURE__*/function () {
5636
- var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref3) {
5701
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref5) {
5637
5702
  var data, geometries;
5638
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
5639
- while (1) switch (_context2.prev = _context2.next) {
5703
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
5704
+ while (1) switch (_context3.prev = _context3.next) {
5640
5705
  case 0:
5641
- _ref3.variableIds, _ref3.options;
5642
- _context2.next = 3;
5706
+ _ref5.variableIds, _ref5.options;
5707
+ _context3.next = 3;
5643
5708
  return resolveExprAsync(['$fetch', ['$template', "".concat(METADATA_API_ENDPOINT) + '/${source_table_id}?select=' + '${variableId},' + 'cd_setor' + '&cd_mun=eq.' + '${municipioId}', {
5644
5709
  variableId: ['$get', 'view.conf.data.variableId'],
5645
5710
  municipioId: ['$context', 'municipioId'],
5646
5711
  source_table_id: ['$get', ['$template', '${0}.source_table_id', ['$get', 'view.conf.data.variableId']], variantsByVariableId]
5647
5712
  }]], context);
5648
5713
  case 3:
5649
- data = _context2.sent;
5650
- _context2.next = 6;
5714
+ data = _context3.sent;
5715
+ _context3.next = 6;
5651
5716
  return resolveExprAsync(['$fetch', ['$template', "".concat(METADATA_API_ENDPOINT) + '/${collection_id}?select=geom,cd_setor' + '&cd_mun=eq.' + '${municipioId}', {
5652
5717
  municipioId: ['$context', 'municipioId'],
5653
5718
  collection_id: ['$get', ['$template', '${0}.collection_id', ['$get', 'view.conf.data.variableId']], variantsByVariableId]
5654
5719
  }]], context);
5655
5720
  case 6:
5656
- geometries = _context2.sent;
5657
- return _context2.abrupt("return", dataJoin([geometries, data], {
5721
+ geometries = _context3.sent;
5722
+ return _context3.abrupt("return", dataJoin([geometries, data], {
5658
5723
  key: 'cd_setor'
5659
5724
  }));
5660
5725
  case 8:
5661
5726
  case "end":
5662
- return _context2.stop();
5727
+ return _context3.stop();
5663
5728
  }
5664
- }, _callee2);
5729
+ }, _callee3);
5665
5730
  }));
5666
- return function (_x2) {
5667
- return _ref4.apply(this, arguments);
5731
+ return function (_x3) {
5732
+ return _ref6.apply(this, arguments);
5668
5733
  };
5669
5734
  }();
5670
5735
  })
@@ -5788,7 +5853,7 @@ function numerical_size(base, _ref) {
5788
5853
  // When qt_mat_fund_ai is 0, radius is 6
5789
5854
  ['$max', ['$get', 'view.metadata.variableValues']], SIZE_MAX // When qt_mat_fund_ai is 100, radius is 20
5790
5855
  ],
5791
- 'circle-color': get$1(COLOR_SCHEMES, color_scheme) || color_scheme
5856
+ 'circle-color': get(COLOR_SCHEMES, color_scheme) || color_scheme
5792
5857
  }
5793
5858
  })))
5794
5859
  });
@@ -5810,7 +5875,7 @@ function categorical(base, _ref) {
5810
5875
  var VECTOR_SOURCE_ID = "".concat(TABLE_ID, ".geom");
5811
5876
  categories = categories ? categories.map(function (category) {
5812
5877
  return _objectSpread2(_objectSpread2({}, category), {}, {
5813
- color: get$1(COLOR_SCHEMES, category.color) || category.color
5878
+ color: get(COLOR_SCHEMES, category.color) || category.color
5814
5879
  });
5815
5880
  }) : null;
5816
5881
  return _objectSpread2(_objectSpread2({}, base), {}, {
@@ -5932,7 +5997,7 @@ function cem_saude_2024(viewSpec, allViewSpecs, context) {
5932
5997
  sourceLabel: $sourceLabel,
5933
5998
  metodology: metodology,
5934
5999
  keywords: [indicator_path, $sourceLabel, 'saúde', 'hospital', 'UBS', keywords].filter(Boolean),
5935
- conf: {
6000
+ confSchema: {
5936
6001
  data: {
5937
6002
  // variantId: {
5938
6003
  // label: 'Rede de ensino:',
@@ -5971,6 +6036,7 @@ function cem_saude_2024(viewSpec, allViewSpecs, context) {
5971
6036
  },
5972
6037
  sources: _objectSpread2(_objectSpread2({}, globalRes.sources), {}, _defineProperty({}, VECTOR_SOURCE_ID, tableVectorSource(context, collection_id, {
5973
6038
  attribution: $sourceLabel,
6039
+ promoteId: 'id_cnes',
5974
6040
  minzoom: 8,
5975
6041
  maxzoom: 20
5976
6042
  }))),
@@ -6091,11 +6157,7 @@ var PRESETS = /*#__PURE__*/Object.freeze({
6091
6157
  function parseViewSpec(specInput, otherSpecInputs, context) {
6092
6158
  specInput = unflat(specInput);
6093
6159
  var preset = specInput.preset ? PRESETS[specInput.preset] : null;
6094
- if (preset) {
6095
- return preset(specInput, otherSpecInputs, context);
6096
- } else {
6097
- return specInput;
6098
- }
6160
+ return preset ? preset(specInput, otherSpecInputs, context) : specInput;
6099
6161
  }
6100
6162
 
6101
6163
  //
@@ -6190,6 +6252,90 @@ function resolveViewSpecs(viewSpecsInput, context) {
6190
6252
  });
6191
6253
  }
6192
6254
 
6255
+ var STAGE_VALUE_KEY = '_value';
6256
+ var STAGE_SPECIAL_KEYS = ['_dependencies', '_loading', STAGE_VALUE_KEY, '_query'];
6257
+ function _stageResolver(stageKey, additionalResolveFn) {
6258
+ return function (viewSpec, partialViewAtStage, viewResolutionContextBase) {
6259
+ return __awaiter(this, void 0, void 0, function () {
6260
+ var resolveFinalContext, stageValue, resolved;
6261
+ return __generator(this, function (_a) {
6262
+ switch (_a.label) {
6263
+ case 0:
6264
+ resolveFinalContext = __assign(__assign(__assign({}, viewResolutionContextBase.app), viewResolutionContextBase), {
6265
+ view: partialViewAtStage
6266
+ });
6267
+ stageValue = viewSpec[stageKey] && viewSpec[stageKey][STAGE_VALUE_KEY] ? viewSpec[stageKey][STAGE_VALUE_KEY] : isPlainObject(viewSpec[stageKey]) ? omit(viewSpec[stageKey], STAGE_SPECIAL_KEYS) : viewSpec[stageKey];
6268
+ return [4 /*yield*/, resolveExprAsync(stageValue, resolveFinalContext)];
6269
+ case 1:
6270
+ resolved = _a.sent();
6271
+ //
6272
+ // If there is an additional resolver provided, invoke it
6273
+ //
6274
+ return [2 /*return*/, typeof additionalResolveFn === 'function' ? additionalResolveFn(resolved, __assign(__assign({}, resolveFinalContext), {
6275
+ viewSpec: viewSpec
6276
+ })) : resolved];
6277
+ }
6278
+ });
6279
+ });
6280
+ };
6281
+ }
6282
+ // export const resolveConfSchema = _stageResolver<
6283
+ // Pick<ResolvedView, 'conf'>,
6284
+ // ResolvedView['conf']
6285
+ // >('confSchema', (confSchema, { view, viewSpec }) => {
6286
+ // return confSchema || null
6287
+ // })
6288
+ function resolveConfSchema(viewSpec, partialView, viewResolutionContextBase) {
6289
+ var resolveFinalContext = __assign(__assign(__assign({}, viewResolutionContextBase.app), viewResolutionContextBase), {
6290
+ view: partialView
6291
+ });
6292
+ return resolveExpr(viewSpec.confSchema, resolveFinalContext);
6293
+ }
6294
+ var resolveMetadata = _stageResolver('metadata');
6295
+ var resolveSources = _stageResolver('sources');
6296
+ var resolveLayers = _stageResolver('layers', function (layersBase, _a) {
6297
+ //
6298
+ // Provide function that will resolve a tooltip
6299
+ // for a specific feature
6300
+ var VIEW_AT_LAYERS_STAGE = _a.view;
6301
+ return Object.fromEntries(Object.entries(layersBase).filter(function (_a) {
6302
+ _a[0];
6303
+ var layerBase = _a[1];
6304
+ return isPlainObject(layerBase) && !layerBase.hidden;
6305
+ }).map(function (_a) {
6306
+ var layerId = _a[0],
6307
+ layerBase = _a[1];
6308
+ return [layerId, __assign(__assign({}, layerBase), {
6309
+ tooltip: layerBase.interactive !== false && layerBase.tooltip ? function (_a) {
6310
+ var feature = _a.feature;
6311
+ return resolveExpr(layerBase.tooltip, {
6312
+ feature: feature,
6313
+ view: VIEW_AT_LAYERS_STAGE
6314
+ });
6315
+ } : null
6316
+ })];
6317
+ }));
6318
+ });
6319
+ var resolveControls = _stageResolver('controls', function (controls, _a) {
6320
+ if (controls === void 0) {
6321
+ controls = {};
6322
+ }
6323
+ var view = _a.view,
6324
+ viewSpec = _a.viewSpec;
6325
+ console.log('resolve controls', controls);
6326
+ var layerLegends = view.layers ? get$1(Object.values(view.layers).filter(function (layer) {
6327
+ return !layer.hidden && layer.visibility !== 'none';
6328
+ }), '[].legends[]').filter(Boolean).map(function (legend, index) {
6329
+ return __assign(__assign({}, legend), {
6330
+ id: "".concat(viewSpec.id, "_").concat(index)
6331
+ });
6332
+ }) : [];
6333
+ return __assign(__assign({}, controls || {}), {
6334
+ legends: __spreadArray(__spreadArray([], controls.legends || [], true), layerLegends, true)
6335
+ });
6336
+ });
6337
+ var resolveDownload = _stageResolver('download');
6338
+
6193
6339
  function viewConfReducer(state, action) {
6194
6340
  var _a;
6195
6341
  switch (action.type) {
@@ -6263,59 +6409,6 @@ function viewConfReducerInitialState(initialState) {
6263
6409
  }]
6264
6410
  };
6265
6411
  }
6266
- //
6267
- // Loads viewconf and loads global/shared configuration
6268
- //
6269
- // export function resolveViewConf(
6270
- // state: State,
6271
- // id: string,
6272
- // viewSpecsById: Record<string, ViewSpec>,
6273
- // ): ViewConf {
6274
- // //
6275
- // // Load the view's self conf
6276
- // //
6277
- // const viewConfSelf = state.byId[id]
6278
- // //
6279
- // // Load global configurations from other active views
6280
- // //
6281
- // const globalConf = Object.entries(state.byId)
6282
- // .map(([otherViewId, otherViewConf]) => {
6283
- // if (otherViewId === id) {
6284
- // return null
6285
- // }
6286
- // const otherViewSpec = viewSpecsById[otherViewId]
6287
- // const otherViewGlobalConfPairs =
6288
- // otherViewSpec.conf &&
6289
- // CONF_TAB_IDS.flatMap((tabId) => {
6290
- // const tabSchema = otherViewSpec.conf[tabId]
6291
- // if (!tabSchema) {
6292
- // return null
6293
- // }
6294
- // const tabValue = otherViewConf[tabId]
6295
- // return Object.entries(tabSchema)
6296
- // .filter(([propertyKey, propertySchema]) =>
6297
- // Boolean(propertySchema && propertySchema.global),
6298
- // )
6299
- // .map(([propertyKey, propertySchema]) => {
6300
- // const propertyValue = tabValue ? tabValue[propertyKey] : undefined
6301
- // return typeof propertyValue === 'undefined'
6302
- // ? null
6303
- // : [propertyKey, propertyValue]
6304
- // })
6305
- // }).filter(Boolean)
6306
- // return otherViewGlobalConfPairs.length > 0
6307
- // ? {
6308
- // viewId: otherViewId,
6309
- // conf: Object.fromEntries(otherViewGlobalConfPairs),
6310
- // }
6311
- // : null
6312
- // })
6313
- // .filter(Boolean)
6314
- // console.log({
6315
- // globalConf,
6316
- // })
6317
- // return { ...viewConfSelf, global: globalConf }
6318
- // }
6319
6412
 
6320
6413
  function getDeviceLocation() {
6321
6414
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -6536,6 +6629,316 @@ function InputProvider(props) {
6536
6629
  }, props));
6537
6630
  }
6538
6631
 
6632
+ //
6633
+ // Custom queryKeyHashFn that correctly handles files
6634
+ //
6635
+ // https://github.com/TanStack/query/blob/ff788ac4e0a9cbc6af6cdf1837fcbf5c0b0b9a9c/packages/query-core/src/utils.ts#L217
6636
+ function queryKeyHashFnWithFileSupport(queryKey) {
6637
+ return JSON.stringify(queryKey, function (_, val) {
6638
+ if (val instanceof File) {
6639
+ // Replace File with stable metadata representation
6640
+ return {
6641
+ __file__: true,
6642
+ name: val.name,
6643
+ size: val.size,
6644
+ type: val.type,
6645
+ lastModified: val.lastModified
6646
+ };
6647
+ }
6648
+ return isPlainObject(val) ? Object.keys(val).sort().reduce(function (result, key) {
6649
+ result[key] = val[key];
6650
+ return result;
6651
+ }, {}) : val;
6652
+ });
6653
+ }
6654
+
6655
+ var STAGE_LOADING = Symbol["for"]('STAGE_LOADING');
6656
+ var STAGE_ERROR = Symbol["for"]('STAGE_ERROR');
6657
+ function _viewsFromStageQueries(_a) {
6658
+ var viewsToResolve = _a.viewsToResolve,
6659
+ _b = _a.queriesByStage,
6660
+ queriesByStage = _b === void 0 ? null : _b;
6661
+ return viewsToResolve.map(function (_a, viewQueryIndex) {
6662
+ var viewId = _a.viewId,
6663
+ viewConf = _a.viewConf;
6664
+ _a.viewSpec;
6665
+ var viewBase = {
6666
+ id: viewId,
6667
+ conf: viewConf
6668
+ };
6669
+ return queriesByStage ? Object.assign(viewBase, Object.fromEntries(Object.entries(queriesByStage).map(function (_a) {
6670
+ var stageKey = _a[0],
6671
+ stageQueries = _a[1];
6672
+ //
6673
+ // All queries by stage must share the same viewsToResolve
6674
+ //
6675
+ var viewQuery = stageQueries[viewQueryIndex];
6676
+ return viewQuery.status === 'success' ? [stageKey, viewQuery.data] : [stageKey,
6677
+ //
6678
+ // TODO improve error handling
6679
+ //
6680
+ viewQuery.status === 'pending' ? STAGE_LOADING : STAGE_ERROR];
6681
+ }))) : viewBase;
6682
+ });
6683
+ }
6684
+ //
6685
+ // Utility that checks whether a partial view
6686
+ // has all stages from a list resolved
6687
+ //
6688
+ function _hasViewResolvedStages(partialView, stages) {
6689
+ return stages.every(function (stageKey) {
6690
+ var stageValue = partialView[stageKey];
6691
+ return typeof stageValue !== 'undefined' && stageValue !== STAGE_LOADING && stageValue !== STAGE_ERROR;
6692
+ });
6693
+ }
6694
+ function useViewStageQueries(_a) {
6695
+ var _this = this;
6696
+ var extEnabled = _a.enabled,
6697
+ stageKey = _a.stageKey,
6698
+ _b = _a.dependsOnStages,
6699
+ dependsOnStages = _b === void 0 ? null : _b,
6700
+ viewResolutionContextBase = _a.viewResolutionContextBase,
6701
+ viewsToResolve = _a.viewsToResolve,
6702
+ partialViews = _a.partialViews,
6703
+ _queryFn = _a.queryFn;
6704
+ return useQueries({
6705
+ queries: viewsToResolve.map(function (viewToResolve, viewIndex) {
6706
+ var _a, _b, _c;
6707
+ var viewId = viewToResolve.viewId,
6708
+ viewSpec = viewToResolve.viewSpec,
6709
+ viewConf = viewToResolve.viewConf;
6710
+ var partialView = partialViews[viewIndex];
6711
+ var enabled = extEnabled && (Array.isArray(dependsOnStages) ? _hasViewResolvedStages(partialView, dependsOnStages) : true);
6712
+ var stageDependencies = enabled && typeof ((_a = viewSpec[stageKey]) === null || _a === void 0 ? void 0 : _a._dependencies) === 'function' ? viewSpec[stageKey]._dependencies(__assign(__assign({}, viewResolutionContextBase), {
6713
+ view: partialView
6714
+ })) || 'STABLE_DEPENDENCY' : 'STABLE_DEPENDENCY';
6715
+ var queryKey = ['ViewStage', viewId, stageKey, viewConf, viewResolutionContextBase.app.municipioId, stageDependencies];
6716
+ return __assign(__assign({}, ((_b = viewSpec[stageKey]) === null || _b === void 0 ? void 0 : _b._query) ? pick((_c = viewSpec[stageKey]) === null || _c === void 0 ? void 0 : _c._query, ['gcTime']) : {}), {
6717
+ gcTime: 0,
6718
+ enabled: enabled,
6719
+ queryKey: queryKey,
6720
+ queryKeyHashFn: queryKeyHashFnWithFileSupport,
6721
+ queryFn: function queryFn() {
6722
+ return __awaiter(_this, void 0, void 0, function () {
6723
+ var result;
6724
+ return __generator(this, function (_a) {
6725
+ switch (_a.label) {
6726
+ case 0:
6727
+ return [4 /*yield*/, _queryFn(viewToResolve, partialView)];
6728
+ case 1:
6729
+ result = _a.sent();
6730
+ if (viewSpec.debug) {
6731
+ console.log(stageKey, viewSpec.id, result, partialView);
6732
+ }
6733
+ return [2 /*return*/, result];
6734
+ }
6735
+ });
6736
+ });
6737
+ },
6738
+ throwOnError: process.env.NODE_ENV !== 'production'
6739
+ });
6740
+ })
6741
+ });
6742
+ }
6743
+ function useViews(viewResolutionContextBase) {
6744
+ var _this = this;
6745
+ var viewSpecs = viewResolutionContextBase.viewSpecs,
6746
+ viewConfState = viewResolutionContextBase.viewConfState;
6747
+ var VIEWS_ENABLED = Boolean(viewSpecs && viewConfState);
6748
+ var viewSpecsById = useMemo(function () {
6749
+ return Array.isArray(viewSpecs) ? viewSpecs.reduce(function (acc, viewSpec) {
6750
+ var _a;
6751
+ return __assign(__assign({}, acc), (_a = {}, _a[viewSpec.id] = viewSpec, _a));
6752
+ }, {}) : null;
6753
+ }, [viewSpecs]);
6754
+ //
6755
+ // Filter out views that are not listed in specs
6756
+ // All useQueries calls will from this point onward
6757
+ // have the same array of base queries and same order
6758
+ // as well.
6759
+ //
6760
+ var viewsToResolve = useMemo(function () {
6761
+ if (!viewSpecsById || !viewConfState) {
6762
+ return [];
6763
+ }
6764
+ return viewConfState.layout.flatMap(function (list) {
6765
+ return list.items.map(function (item) {
6766
+ return item.id;
6767
+ });
6768
+ }).map(function (viewId) {
6769
+ var viewSpec = viewSpecsById[viewId] || null;
6770
+ var viewConf = viewConfState.byId[viewId] || null;
6771
+ return viewSpec && viewConf ? {
6772
+ viewId: viewId,
6773
+ viewConf: viewConf,
6774
+ viewSpec: viewSpec
6775
+ } : null;
6776
+ }).filter(Boolean);
6777
+ }, [viewSpecsById, viewConfState]);
6778
+ var QUERIES_AT_METADATA = {};
6779
+ var metadataQueries = useViewStageQueries({
6780
+ enabled: VIEWS_ENABLED,
6781
+ stageKey: 'metadata',
6782
+ dependsOnStages: null,
6783
+ viewResolutionContextBase: viewResolutionContextBase,
6784
+ viewsToResolve: viewsToResolve,
6785
+ partialViews: _viewsFromStageQueries({
6786
+ viewsToResolve: viewsToResolve,
6787
+ queriesByStage: null
6788
+ }),
6789
+ queryFn: function queryFn(_a, partialView_1) {
6790
+ return __awaiter(_this, [_a, partialView_1], void 0, function (_b, partialView) {
6791
+ var viewSpec = _b.viewSpec;
6792
+ return __generator(this, function (_c) {
6793
+ return [2 /*return*/, resolveMetadata(viewSpec, partialView, viewResolutionContextBase)];
6794
+ });
6795
+ });
6796
+ }
6797
+ });
6798
+ var QUERIES_AT_SOURCES = __assign(__assign({}, QUERIES_AT_METADATA), {
6799
+ metadata: metadataQueries
6800
+ });
6801
+ var sourcesQueries = useViewStageQueries({
6802
+ enabled: VIEWS_ENABLED,
6803
+ stageKey: 'sources',
6804
+ dependsOnStages: ['metadata'],
6805
+ viewResolutionContextBase: viewResolutionContextBase,
6806
+ viewsToResolve: viewsToResolve,
6807
+ partialViews: _viewsFromStageQueries({
6808
+ viewsToResolve: viewsToResolve,
6809
+ queriesByStage: QUERIES_AT_SOURCES
6810
+ }),
6811
+ queryFn: function queryFn(_a, partialView_1) {
6812
+ return __awaiter(_this, [_a, partialView_1], void 0, function (_b, partialView) {
6813
+ var viewSpec = _b.viewSpec;
6814
+ return __generator(this, function (_c) {
6815
+ return [2 /*return*/, resolveSources(viewSpec, partialView, viewResolutionContextBase)];
6816
+ });
6817
+ });
6818
+ }
6819
+ });
6820
+ var QUERIES_AT_LAYERS = __assign(__assign({}, QUERIES_AT_SOURCES), {
6821
+ sources: sourcesQueries
6822
+ });
6823
+ var layersQueries = useViewStageQueries({
6824
+ enabled: VIEWS_ENABLED,
6825
+ stageKey: 'layers',
6826
+ dependsOnStages: ['metadata', 'sources'],
6827
+ viewResolutionContextBase: viewResolutionContextBase,
6828
+ viewsToResolve: viewsToResolve,
6829
+ partialViews: _viewsFromStageQueries({
6830
+ viewsToResolve: viewsToResolve,
6831
+ queriesByStage: QUERIES_AT_LAYERS
6832
+ }),
6833
+ queryFn: function queryFn(_a, partialView_1) {
6834
+ return __awaiter(_this, [_a, partialView_1], void 0, function (_b, partialView) {
6835
+ var viewSpec = _b.viewSpec;
6836
+ return __generator(this, function (_c) {
6837
+ return [2 /*return*/, resolveLayers(viewSpec, partialView, viewResolutionContextBase)];
6838
+ });
6839
+ });
6840
+ }
6841
+ });
6842
+ var QUERIES_AT_CONTROLS = __assign(__assign({}, QUERIES_AT_LAYERS), {
6843
+ layers: layersQueries
6844
+ });
6845
+ var controlsQueries = useViewStageQueries({
6846
+ enabled: VIEWS_ENABLED,
6847
+ stageKey: 'controls',
6848
+ dependsOnStages: ['metadata', 'sources', 'layers'],
6849
+ viewResolutionContextBase: viewResolutionContextBase,
6850
+ viewsToResolve: viewsToResolve,
6851
+ partialViews: _viewsFromStageQueries({
6852
+ viewsToResolve: viewsToResolve,
6853
+ queriesByStage: QUERIES_AT_CONTROLS
6854
+ }),
6855
+ queryFn: function queryFn(_a, partialView_1) {
6856
+ return __awaiter(_this, [_a, partialView_1], void 0, function (_b, partialView) {
6857
+ var viewSpec = _b.viewSpec;
6858
+ return __generator(this, function (_c) {
6859
+ return [2 /*return*/, resolveControls(viewSpec, partialView, viewResolutionContextBase)];
6860
+ });
6861
+ });
6862
+ }
6863
+ });
6864
+ var downloadQueries = useViewStageQueries({
6865
+ enabled: VIEWS_ENABLED,
6866
+ stageKey: 'download',
6867
+ dependsOnStages: ['metadata', 'sources', 'layers'],
6868
+ viewResolutionContextBase: viewResolutionContextBase,
6869
+ viewsToResolve: viewsToResolve,
6870
+ partialViews: _viewsFromStageQueries({
6871
+ viewsToResolve: viewsToResolve,
6872
+ queriesByStage: QUERIES_AT_CONTROLS
6873
+ }),
6874
+ queryFn: function queryFn(_a, partialView_1) {
6875
+ return __awaiter(_this, [_a, partialView_1], void 0, function (_b, partialView) {
6876
+ var viewSpec = _b.viewSpec;
6877
+ return __generator(this, function (_c) {
6878
+ return [2 /*return*/, resolveDownload(viewSpec, partialView, viewResolutionContextBase)];
6879
+ });
6880
+ });
6881
+ }
6882
+ });
6883
+ var resolvedViews = useMemo(function () {
6884
+ return _viewsFromStageQueries({
6885
+ viewsToResolve: viewsToResolve,
6886
+ queriesByStage: {
6887
+ metadata: metadataQueries,
6888
+ sources: sourcesQueries,
6889
+ layers: layersQueries,
6890
+ controls: controlsQueries,
6891
+ download: downloadQueries
6892
+ }
6893
+ }).filter(function (partialView) {
6894
+ return _hasViewResolvedStages(partialView, ['metadata', 'sources', 'layers'
6895
+ // 'download',
6896
+ ]);
6897
+ });
6898
+ }, [viewsToResolve, metadataQueries, sourcesQueries, layersQueries, controlsQueries, downloadQueries]);
6899
+ var isLoading = useMemo(function () {
6900
+ return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], metadataQueries, true), sourcesQueries, true), layersQueries, true), controlsQueries, true).some(function (query) {
6901
+ return query.status === 'pending';
6902
+ });
6903
+ }, [metadataQueries, sourcesQueries, layersQueries, controlsQueries]);
6904
+ //
6905
+ // Resolve view specs so that they may take input
6906
+ // from other view confs
6907
+ //
6908
+ // This is best done synchronously, as the schema modification
6909
+ // happens as the user changes conf values. Async resolution
6910
+ // results in buggy interface.
6911
+ //
6912
+ // TODO:
6913
+ // Probably move this away from here, should go to useViewSpecs hook
6914
+ //
6915
+ var resolvedViewSpecs = useMemo(function () {
6916
+ if (!viewSpecs || !viewsToResolve || viewsToResolve.length === 0) {
6917
+ return viewSpecs;
6918
+ }
6919
+ var _byId = Object.fromEntries(viewsToResolve.map(function (toResolve) {
6920
+ var viewId = toResolve.viewId;
6921
+ return [viewId, toResolve];
6922
+ }));
6923
+ return viewSpecs.map(function (viewSpec) {
6924
+ var viewToResolve = _byId[viewSpec.id];
6925
+ return !viewToResolve ? viewSpec : __assign(__assign({}, viewSpec), {
6926
+ confSchema: resolveConfSchema(viewSpec, viewToResolve.viewConf, viewResolutionContextBase)
6927
+ });
6928
+ });
6929
+ }, [viewSpecs, viewsToResolve, viewResolutionContextBase]);
6930
+ return {
6931
+ isLoading: isLoading,
6932
+ metadataQueries: metadataQueries,
6933
+ sourcesQueries: sourcesQueries,
6934
+ layersQueries: layersQueries,
6935
+ controlsQueries: controlsQueries,
6936
+ downloadQueries: downloadQueries,
6937
+ resolvedViews: resolvedViews,
6938
+ resolvedViewSpecs: resolvedViewSpecs
6939
+ };
6940
+ }
6941
+
6539
6942
  var _templateObject, _templateObject2, _templateObject3;
6540
6943
 
6541
6944
  //
@@ -6557,17 +6960,17 @@ function _flyToMunicipio(_x, _x2, _x3, _x4) {
6557
6960
  // We use a customizable style on maptiler
6558
6961
  //
6559
6962
  function _flyToMunicipio2() {
6560
- _flyToMunicipio2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(map, METADATA_API_ENDPOINT, municipioId, options) {
6963
+ _flyToMunicipio2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(map, METADATA_API_ENDPOINT, municipioId, options) {
6561
6964
  var _yield$fetch$then, _yield$fetch$then2, mun;
6562
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
6563
- while (1) switch (_context6.prev = _context6.next) {
6965
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
6966
+ while (1) switch (_context5.prev = _context5.next) {
6564
6967
  case 0:
6565
- _context6.next = 2;
6968
+ _context5.next = 2;
6566
6969
  return fetch("".concat(METADATA_API_ENDPOINT, "/ibge_malha_br_municipio?select=bbox&id=eq.").concat(municipioId)).then(function (res) {
6567
6970
  return res.json();
6568
6971
  });
6569
6972
  case 2:
6570
- _yield$fetch$then = _context6.sent;
6973
+ _yield$fetch$then = _context5.sent;
6571
6974
  _yield$fetch$then2 = _slicedToArray(_yield$fetch$then, 1);
6572
6975
  mun = _yield$fetch$then2[0];
6573
6976
  if (mun && mun.bbox) {
@@ -6575,9 +6978,9 @@ function _flyToMunicipio2() {
6575
6978
  }
6576
6979
  case 6:
6577
6980
  case "end":
6578
- return _context6.stop();
6981
+ return _context5.stop();
6579
6982
  }
6580
- }, _callee6);
6983
+ }, _callee5);
6581
6984
  }));
6582
6985
  return _flyToMunicipio2.apply(this, arguments);
6583
6986
  }
@@ -6594,30 +6997,6 @@ var DEM_SOURCE_URL = "https://api.maptiler.com/tiles/terrain-rgb-v2/{z}/{x}/{y}.
6594
6997
  var DEM_SOURCE_ENCODING = 'mapbox';
6595
6998
  var MapStyleToggleCtrl = styled.button(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n height: 100px;\n width: 100px;\n\n padding: 0;\n border: none;\n background-color: #efefef;\n border-radius: 0;\n box-shadow:\n rgba(50, 50, 93, 0.25) 0px 2px 5px -1px,\n rgba(0, 0, 0, 0.3) 0px 1px 3px -1px;\n\n cursor: pointer;\n\n &::after {\n z-index: 2;\n content: 'Trocar camada base';\n color: transparent;\n font-weight: bold;\n display: flex;\n padding: 8px;\n justify-content: center;\n align-items: center;\n text-align: center;\n position: absolute;\n top: 0;\n left: 0;\n bottom: 0;\n right: 0;\n background: rgba(0, 0, 0, 0);\n transition: background 0.1s ease-in-out;\n }\n\n &:hover {\n &::after {\n background: rgba(0, 0, 0, 0.5);\n color: white;\n }\n }\n\n @media (max-width: 500px) {\n height: 50px;\n width: 50px;\n &::after {\n font-size: 0.6rem;\n }\n }\n"])));
6596
6999
 
6597
- //
6598
- // Custom queryKeyHashFn that correctly handles files
6599
- //
6600
- // https://github.com/TanStack/query/blob/ff788ac4e0a9cbc6af6cdf1837fcbf5c0b0b9a9c/packages/query-core/src/utils.ts#L217
6601
- //
6602
- function queryKeyHashFnWithFileSupport(queryKey) {
6603
- return JSON.stringify(queryKey, function (_, val) {
6604
- if (val instanceof File) {
6605
- // Replace File with stable metadata representation
6606
- return {
6607
- __file__: true,
6608
- name: val.name,
6609
- size: val.size,
6610
- type: val.type,
6611
- lastModified: val.lastModified
6612
- };
6613
- }
6614
- return isPlainObject(val) ? Object.keys(val).sort().reduce(function (result, key) {
6615
- result[key] = val[key];
6616
- return result;
6617
- }, {}) : val;
6618
- });
6619
- }
6620
-
6621
7000
  //
6622
7001
  // From:
6623
7002
  // https://servicodados.ibge.gov.br/api/v4/malhas/paises/BR/metadados
@@ -6747,54 +7126,21 @@ function GeoReDUSInner(_ref) {
6747
7126
  }(),
6748
7127
  throwOnError: process.env.NODE_ENV !== 'production'
6749
7128
  });
6750
- var viewSpecsById = useMemo(function () {
6751
- return Array.isArray(viewSpecsQuery.data) ? viewSpecsQuery.data.reduce(function (acc, viewSpec) {
6752
- return _objectSpread2(_objectSpread2({}, acc), {}, _defineProperty({}, viewSpec.id, viewSpec));
6753
- }, {}) : null;
6754
- }, [viewSpecsQuery.data]);
6755
- var viewsQueries = useQueries({
6756
- queries: viewConfState.layout.flatMap(function (list) {
6757
- return list.items.map(function (item) {
6758
- return item.id;
6759
- });
6760
- }).map(function (viewId) {
6761
- return {
6762
- queryKey: ['ResolveView', viewId, municipioId, viewSpecsById ? viewSpecsById[viewId] : null, viewConfState.byId[viewId]],
6763
- queryKeyHashFn: queryKeyHashFnWithFileSupport,
6764
- queryFn: function () {
6765
- var _queryFn2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
6766
- var viewSpec;
6767
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
6768
- while (1) switch (_context2.prev = _context2.next) {
6769
- case 0:
6770
- viewSpec = viewSpecsById ? viewSpecsById[viewId] : viewSpecsById;
6771
- return _context2.abrupt("return", viewSpec ? resolveView(viewSpec, viewConfState.byId[viewId], {
6772
- municipioId: municipioId,
6773
- baseMapStyle: baseMapStyle
6774
- }) : null);
6775
- case 2:
6776
- case "end":
6777
- return _context2.stop();
6778
- }
6779
- }, _callee2);
6780
- }));
6781
- function queryFn() {
6782
- return _queryFn2.apply(this, arguments);
6783
- }
6784
- return queryFn;
6785
- }(),
6786
- throwOnError: true,
6787
- retry: false
6788
- };
6789
- })
6790
- });
6791
- var resolvedViews = useMemo(function () {
6792
- return viewsQueries
6793
- // .filter((query) => query.status === 'success')
6794
- .map(function (query) {
6795
- return query.data;
6796
- }).filter(Boolean);
6797
- }, [viewsQueries]);
7129
+ var _useViews = useViews({
7130
+ viewSpecs: viewSpecsQuery.data,
7131
+ viewConfState: viewConfState,
7132
+ app: {
7133
+ municipioId: municipioId,
7134
+ baseMapStyle: baseMapStyle
7135
+ }
7136
+ }),
7137
+ resolvedViews = _useViews.resolvedViews,
7138
+ resolvedViewSpecs = _useViews.resolvedViewSpecs,
7139
+ isLoading = _useViews.isLoading;
7140
+
7141
+ //
7142
+ // Prepares layout for rendering
7143
+ //
6798
7144
  var resolvedLayout = useMemo(function () {
6799
7145
  var resolvedViewsById = Object.fromEntries(resolvedViews.map(function (view) {
6800
7146
  return [view.id, view];
@@ -6820,7 +7166,8 @@ function GeoReDUSInner(_ref) {
6820
7166
  id: list.id,
6821
7167
  views: views,
6822
7168
  legends: views.flatMap(function (view) {
6823
- return (view === null || view === void 0 ? void 0 : view.legends) || [];
7169
+ var _view$controls;
7170
+ return (view === null || view === void 0 || (_view$controls = view.controls) === null || _view$controls === void 0 ? void 0 : _view$controls.legends) || [];
6824
7171
  })
6825
7172
  };
6826
7173
  });
@@ -6858,18 +7205,18 @@ function GeoReDUSInner(_ref) {
6858
7205
  required: true,
6859
7206
  clearable: false,
6860
7207
  placeholder: 'Selecione um município',
6861
- options: useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
7208
+ options: useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
6862
7209
  var municipios;
6863
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
6864
- while (1) switch (_context3.prev = _context3.next) {
7210
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
7211
+ while (1) switch (_context2.prev = _context2.next) {
6865
7212
  case 0:
6866
- _context3.next = 2;
7213
+ _context2.next = 2;
6867
7214
  return fetch("".concat(METADATA_API_ENDPOINT, "/ibge_malha_br_municipio?select=nome,id,uf_sigla")).then(function (response) {
6868
7215
  return response.json();
6869
7216
  });
6870
7217
  case 2:
6871
- municipios = _context3.sent;
6872
- return _context3.abrupt("return", municipios.map(function (mun) {
7218
+ municipios = _context2.sent;
7219
+ return _context2.abrupt("return", municipios.map(function (mun) {
6873
7220
  return {
6874
7221
  label: "".concat(mun['nome'], " (").concat(mun['uf_sigla'], ")"),
6875
7222
  value: mun['id'] + ''
@@ -6877,9 +7224,9 @@ function GeoReDUSInner(_ref) {
6877
7224
  }));
6878
7225
  case 4:
6879
7226
  case "end":
6880
- return _context3.stop();
7227
+ return _context2.stop();
6881
7228
  }
6882
- }, _callee3);
7229
+ }, _callee2);
6883
7230
  })), [])
6884
7231
  };
6885
7232
  var dialogs = useDialogs();
@@ -6893,22 +7240,22 @@ function GeoReDUSInner(_ref) {
6893
7240
  METADATA_API_ENDPOINT: METADATA_API_ENDPOINT,
6894
7241
  coordinates: null
6895
7242
  }).then(/*#__PURE__*/function () {
6896
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(resolvedMunicipioId) {
7243
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolvedMunicipioId) {
6897
7244
  var selectedMunicipioId;
6898
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
6899
- while (1) switch (_context4.prev = _context4.next) {
7245
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
7246
+ while (1) switch (_context3.prev = _context3.next) {
6900
7247
  case 0:
6901
7248
  if (resolvedMunicipioId) {
6902
- _context4.next = 11;
7249
+ _context3.next = 11;
6903
7250
  break;
6904
7251
  }
6905
7252
  selectedMunicipioId = null;
6906
7253
  case 2:
6907
7254
  if (!(typeof selectedMunicipioId !== 'string')) {
6908
- _context4.next = 8;
7255
+ _context3.next = 8;
6909
7256
  break;
6910
7257
  }
6911
- _context4.next = 5;
7258
+ _context3.next = 5;
6912
7259
  return dialogs.prompt({
6913
7260
  input: _objectSpread2(_objectSpread2({}, MUNICIPIO_ID_SELECTOR_SCHEMA), {}, {
6914
7261
  label: 'Município'
@@ -6917,12 +7264,12 @@ function GeoReDUSInner(_ref) {
6917
7264
  cancel: null
6918
7265
  });
6919
7266
  case 5:
6920
- selectedMunicipioId = _context4.sent;
6921
- _context4.next = 2;
7267
+ selectedMunicipioId = _context3.sent;
7268
+ _context3.next = 2;
6922
7269
  break;
6923
7270
  case 8:
6924
7271
  setMunicipioId(selectedMunicipioId);
6925
- _context4.next = 12;
7272
+ _context3.next = 12;
6926
7273
  break;
6927
7274
  case 11:
6928
7275
  setTimeout(function () {
@@ -6930,9 +7277,9 @@ function GeoReDUSInner(_ref) {
6930
7277
  }, 400);
6931
7278
  case 12:
6932
7279
  case "end":
6933
- return _context4.stop();
7280
+ return _context3.stop();
6934
7281
  }
6935
- }, _callee4);
7282
+ }, _callee3);
6936
7283
  }));
6937
7284
  return function (_x5) {
6938
7285
  return _ref3.apply(this, arguments);
@@ -6945,7 +7292,7 @@ function GeoReDUSInner(_ref) {
6945
7292
  // Control map position focus
6946
7293
  //
6947
7294
  useEffect(function () {
6948
- var mainMap = get$1(syncedMapsRef.current, 'mapInstances[0].map');
7295
+ var mainMap = get(syncedMapsRef.current, 'mapInstances[0].map');
6949
7296
  if (!mainMap) {
6950
7297
  return;
6951
7298
  }
@@ -6997,13 +7344,10 @@ function GeoReDUSInner(_ref) {
6997
7344
  return null;
6998
7345
  }
6999
7346
  }, []);
7000
- var isLoading = viewsQueries.some(function (viewQuery) {
7001
- return viewQuery.status === 'pending';
7002
- });
7003
7347
  return /*#__PURE__*/React.createElement(Flex, null, /*#__PURE__*/React.createElement(LeftPanel, {
7004
7348
  open: leftPanelOpen,
7005
7349
  onSetOpen: setLeftPanelOpen,
7006
- viewSpecs: viewSpecsQuery.data,
7350
+ viewSpecs: resolvedViewSpecs,
7007
7351
  viewConfState: viewConfState,
7008
7352
  viewConfDispatch: viewConfDispatch,
7009
7353
  resolvedViews: resolvedViews,
@@ -7043,16 +7387,16 @@ function GeoReDUSInner(_ref) {
7043
7387
  },
7044
7388
  ref: syncedMapsRef,
7045
7389
  onLoad: (/*#__PURE__*/function () {
7046
- var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(event) {
7047
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
7048
- while (1) switch (_context5.prev = _context5.next) {
7390
+ var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(event) {
7391
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
7392
+ while (1) switch (_context4.prev = _context4.next) {
7049
7393
  case 0:
7050
- return _context5.abrupt("return", _refocus(event.target));
7394
+ return _context4.abrupt("return", _refocus(event.target));
7051
7395
  case 1:
7052
7396
  case "end":
7053
- return _context5.stop();
7397
+ return _context4.stop();
7054
7398
  }
7055
- }, _callee5);
7399
+ }, _callee4);
7056
7400
  }));
7057
7401
  return function (_x6) {
7058
7402
  return _ref5.apply(this, arguments);
@@ -7128,7 +7472,7 @@ function GeoReDUSInner(_ref) {
7128
7472
  }, {
7129
7473
  key: legend.id
7130
7474
  }, legend));
7131
- })))), index === resolvedLayout.length - 1 ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(GeolocateControl, {
7475
+ })))), index === resolvedLayout.length - 1 ? /*#__PURE__*/React.createElement(React.Fragment, null, process.env.NODE_ENV !== 'production' && /*#__PURE__*/React.createElement(InspectControl, null), /*#__PURE__*/React.createElement(GeolocateControl, {
7132
7476
  position: "top-right"
7133
7477
  }), /*#__PURE__*/React.createElement(FullscreenControl, {
7134
7478
  position: "top-right"
@@ -7161,7 +7505,8 @@ function GeoReDUSInner(_ref) {
7161
7505
  height: '100%',
7162
7506
  width: '100%'
7163
7507
  },
7164
- mapStyle: baseMapStyle === 'satellite' ? DATAVIZ_MAP_STYLE_URL : SATELLITE_MAP_STYLE_URL
7508
+ mapStyle: baseMapStyle === 'satellite' ? DATAVIZ_MAP_STYLE_URL : SATELLITE_MAP_STYLE_URL,
7509
+ maxZoom: 13
7165
7510
  })))) : null, /*#__PURE__*/React.createElement(TerrainControl, {
7166
7511
  demSourceUrl: DEM_SOURCE_URL,
7167
7512
  demSourceEncoding: DEM_SOURCE_ENCODING
@@ -7184,4 +7529,4 @@ function GeoReDUS(props) {
7184
7529
  }, /*#__PURE__*/React.createElement(DialogsProvider, null, /*#__PURE__*/React.createElement(GeoReDUSInner, props))));
7185
7530
  }
7186
7531
 
7187
- export { GeoReDUS, queryKeyHashFnWithFileSupport };
7532
+ export { GeoReDUS };