@redus/georedus-ui 0.1.7 → 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, MapWindow, 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';
28
- import { GeolocateControl, NavigationControl, ScaleControl, AttributionControl } from 'react-map-gl/maplibre';
23
+ import { useQueries, useQuery } from '@tanstack/react-query';
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,194 +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
- console.log('will run $naturalBreaks in worker');
1632
- var breaks = GeoReDUSWorker.scaleNaturalBreaks(__assign({
1633
- values: values
1634
- }, isPlainObject(opt) ? pick(opt, ['scalesByK', 'k', 'minK', 'maxK']) : {}));
1635
- return breaks;
1636
- };
1637
- // export const $test = ()
1638
- var $urlSearch = function $urlSearch(_a) {
1639
- var searchParams = _a[0];
1640
- return Array.isArray(searchParams) ? queryString.stringify(searchParams[0], searchParams[1]) : queryString.stringify(
1641
- //
1642
- // By default, stringify non primitive values using
1643
- // JSON.stringify before passing on to queryString,
1644
- // as by default queryString ignores non-primitive values.
1645
- //
1646
- // This still allows for custom formatting, throgh the array
1647
- // searchParams input, w/ second arg as options passed
1648
- // to queryString
1649
- //
1650
- Object.fromEntries(Object.entries(searchParams).map(function (_a) {
1651
- var key = _a[0],
1652
- value = _a[1];
1653
- return [key, _typeof(value) === 'object' && value !== null ? JSON.stringify(value) : value];
1654
- })));
1655
- };
1656
-
1657
- var CUSTOM_EXPR = /*#__PURE__*/Object.freeze({
1658
- __proto__: null,
1659
- $naturalBreaks: $naturalBreaks,
1660
- $urlSearch: $urlSearch
1661
- });
1662
-
1663
- function isFetchAllowed(resource, options) {
1664
- return __awaiter(this, void 0, void 0, function () {
1665
- return __generator(this, function (_a) {
1666
- console.error('isFetchAllowed must be defined');
1667
- return [2 /*return*/, true
1668
- // const conf = await apiConf()
1669
- // return fetchExpr.allowOrigins({
1670
- // [conf.GEO_METADATA_API_ENDPOINT]: ['GET', 'POST'],
1671
- // })(resource, options)
1672
- ];
1673
- });
1674
- });
1675
- }
1676
- var _a = makeResolve({
1677
- resolvers: withExpressionResolvers(expressions.syntaxArrayExpr({
1678
- name: '$$logical',
1679
- symbol: Symbol["for"]('$$logical'),
1680
- // @ts-ignore
1681
- exps: __assign(__assign(__assign({}, ALL_EXPR), CUSTOM_EXPR), {
1682
- $fetch: fetchExpr({
1683
- isFetchAllowed: isFetchAllowed
1684
- })
1685
- })
1686
- }).resolver),
1687
- defaultResolver: $$literal
1688
- }),
1689
- resolveExprAsync = _a.resolveAsync,
1690
- resolveExpr = _a.resolve;
1691
-
1692
- function resolveView(viewSpec, viewConf, viewContext) {
1693
- return __awaiter(this, void 0, void 0, function () {
1694
- var VIEW_AT_METADATA_STAGE, metadata, VIEW_AT_SOURCES_STAGE, sources, VIEW_AT_LAYERS_STAGE, layersBase, layers, legends, VIEW_AT_DOWNLOAD_STAGE, download;
1695
- return __generator(this, function (_a) {
1696
- switch (_a.label) {
1697
- case 0:
1698
- VIEW_AT_METADATA_STAGE = {
1699
- conf: viewConf
1700
- };
1701
- return [4 /*yield*/, resolveExprAsync(viewSpec.metadata, __assign(__assign({}, viewContext), {
1702
- view: VIEW_AT_METADATA_STAGE
1703
- }))];
1704
- case 1:
1705
- metadata = _a.sent();
1706
- if (viewSpec.debug) {
1707
- console.log('resolveView / metadata', metadata, {
1708
- viewSpec: viewSpec,
1709
- viewConf: viewConf,
1710
- viewContext: viewContext
1711
- });
1712
- }
1713
- VIEW_AT_SOURCES_STAGE = __assign(__assign({}, VIEW_AT_METADATA_STAGE), {
1714
- metadata: metadata
1715
- });
1716
- return [4 /*yield*/, resolveExprAsync(viewSpec.sources, __assign(__assign({}, viewContext), {
1717
- view: VIEW_AT_SOURCES_STAGE
1718
- }))];
1719
- case 2:
1720
- sources = _a.sent();
1721
- if (viewSpec.debug) {
1722
- console.log('resolveView / sources', sources, {
1723
- viewSpec: viewSpec,
1724
- viewConf: viewConf,
1725
- viewContext: viewContext
1726
- });
1727
- }
1728
- VIEW_AT_LAYERS_STAGE = __assign(__assign({}, VIEW_AT_SOURCES_STAGE), {
1729
- sources: sources
1730
- });
1731
- return [4 /*yield*/, resolveExprAsync(viewSpec.layers, __assign(__assign({}, viewContext), {
1732
- view: VIEW_AT_LAYERS_STAGE
1733
- }))
1734
- //
1735
- // Provide function that will resolve a tooltip
1736
- // for a specific feature
1737
- //
1738
- ];
1739
- case 3:
1740
- layersBase = _a.sent();
1741
- layers = Object.fromEntries(Object.entries(layersBase).filter(function (_a) {
1742
- _a[0];
1743
- var layerBase = _a[1];
1744
- return isPlainObject(layerBase) && !layerBase.hidden;
1745
- }).map(function (_a) {
1746
- var layerId = _a[0],
1747
- layerBase = _a[1];
1748
- return [layerId, __assign(__assign({}, layerBase), {
1749
- tooltip: layerBase.interactive !== false && layerBase.tooltip ? function (_a) {
1750
- var feature = _a.feature;
1751
- return resolveExpr(layerBase.tooltip, {
1752
- feature: feature,
1753
- view: VIEW_AT_LAYERS_STAGE
1754
- });
1755
- } : null
1756
- })];
1757
- }));
1758
- if (viewSpec.debug) {
1759
- console.log('resolveView / layers', layers, {
1760
- viewSpec: viewSpec,
1761
- viewConf: viewConf,
1762
- viewContext: viewContext
1763
- });
1764
- }
1765
- legends = get(Object.values(layers), '[].legends[]').filter(Boolean).map(function (legend, index) {
1766
- return __assign(__assign({}, legend), {
1767
- id: "".concat(viewSpec.id, "_").concat(index)
1768
- });
1769
- });
1770
- if (viewSpec.debug) {
1771
- console.log('resolveView / legends', legends, {
1772
- viewSpec: viewSpec,
1773
- viewConf: viewConf,
1774
- viewContext: viewContext
1775
- });
1776
- }
1777
- VIEW_AT_DOWNLOAD_STAGE = __assign(__assign({}, VIEW_AT_LAYERS_STAGE), {
1778
- layers: layers,
1779
- legends: legends
1780
- });
1781
- return [4 /*yield*/, resolveExprAsync(viewSpec.download, __assign(__assign({}, viewContext), {
1782
- view: VIEW_AT_DOWNLOAD_STAGE
1783
- }))];
1784
- case 4:
1785
- download = _a.sent();
1786
- return [2 /*return*/, {
1787
- id: viewSpec.id,
1788
- keywords: viewSpec.keywords,
1789
- metadata: metadata,
1790
- sources: sources,
1791
- layers: layers,
1792
- legends: legends,
1793
- download: download
1794
- }];
1795
- }
1796
- });
1797
- });
1798
- }
1799
-
1800
1614
  var BASE_MAP_LAYERS = [
1801
1615
  // {
1802
1616
  // "id": "Background",
@@ -1849,7 +1663,7 @@ var BASE_MAP_LAYERS = [
1849
1663
  "fill-antialias": false,
1850
1664
  "fill-color": "hsl(96, 44%, 79%)",
1851
1665
  // "fill-color": "red",
1852
- "fill-opacity": 1
1666
+ "fill-opacity": 0.6
1853
1667
  // "fill-opacity": {
1854
1668
  // "stops": [
1855
1669
  // [8, 0.2],
@@ -4382,6 +4196,85 @@ function _ogr2ogr() {
4382
4196
  return _ogr2ogr.apply(this, arguments);
4383
4197
  }
4384
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
+
4385
4278
  var EXTENSIONS_BY_FORMAT = {
4386
4279
  GeoJSON: 'geojson',
4387
4280
  GPKG: 'gpkg',
@@ -4547,6 +4440,25 @@ function downloadResolver(downloadConf) {
4547
4440
  });
4548
4441
  }
4549
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
+
4550
4462
  var _excluded = ["version"];
4551
4463
  function tableVectorSource(context, tableId) {
4552
4464
  var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
@@ -4646,16 +4558,20 @@ function numerical_choropleth$1(base, _ref) {
4646
4558
  var TABLE_ID = collection_id;
4647
4559
  var VECTOR_SOURCE_ID = "".concat(TABLE_ID, ".geom");
4648
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']]]];
4649
4562
  return _objectSpread2(_objectSpread2({}, base), {}, {
4650
- metadata: ['$let', base.metadata, {
4651
- variableValues: ['$get', 'variableValues'],
4652
- sizingValues: ['$get', 'sizingValues'],
4653
- colorScaleStops: ['$naturalBreaks', ['$get', 'variableValues'], ['$merge', _color_scheme, {
4654
- minK: 5
4655
- }]]
4656
- }],
4657
- layers: _objectSpread2(_objectSpread2({}, base.layers), {}, _defineProperty({}, "".concat(VECTOR_SOURCE_ID, "_circle"), vectorLayer(VECTOR_SOURCE_ID, {
4658
- 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,
4659
4575
  type: 'circle',
4660
4576
  legends: [{
4661
4577
  type: 'SequentialColorLegend',
@@ -4676,8 +4592,12 @@ function numerical_choropleth$1(base, _ref) {
4676
4592
  'circle-radius': $circleRadius,
4677
4593
  'circle-stroke-width': 1,
4678
4594
  'circle-stroke-color': '#000000',
4679
- '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
4680
4596
  }
4597
+ })), "influenceArea_fill", _objectSpread2(_objectSpread2({}, base.layers.influenceArea_fill), {}, {
4598
+ paint: _objectSpread2(_objectSpread2({}, base.layers.influenceArea_fill.paint), {}, {
4599
+ 'fill-color': $circleColor
4600
+ })
4681
4601
  })))
4682
4602
  });
4683
4603
  }
@@ -4697,7 +4617,7 @@ function numerical_size$1(base, _ref) {
4697
4617
  var SIZE_MIN = 6;
4698
4618
  return _objectSpread2(_objectSpread2({}, base), {}, {
4699
4619
  layers: _objectSpread2(_objectSpread2({}, base.layers), {}, _defineProperty({}, "".concat(VECTOR_SOURCE_ID, "_circle"), vectorLayer(VECTOR_SOURCE_ID, {
4700
- zIndex: ABOVE_BASE_MAP_LAYERS_Z_INDEX_BASE,
4620
+ zIndex: ABOVE_BASE_MAP_LAYERS_Z_INDEX_BASE + 2,
4701
4621
  type: 'circle',
4702
4622
  legends: [{
4703
4623
  type: 'ProportionalSymbolLegend',
@@ -4718,13 +4638,14 @@ function numerical_size$1(base, _ref) {
4718
4638
  'circle-opacity': 1,
4719
4639
  'circle-stroke-width': 1,
4720
4640
  'circle-stroke-color': '#000000',
4721
- 'circle-radius': ['$if', ['$gt', ['$get', 'length', ['$get', 'view.metadata.variableValues']], 1], ['interpolate', ['linear'], ['get', variable_id],
4722
- // Replace "density" with your property name
4723
- ['$min', ['$get', 'view.metadata.variableValues']], SIZE_MIN,
4724
- // When qt_mat_fund_ai is 0, radius is 6
4725
- ['$max', ['$get', 'view.metadata.variableValues']], SIZE_MAX // When qt_mat_fund_ai is 100, radius is 20
4726
- ], 10],
4727
- '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
4728
4649
  }
4729
4650
  })))
4730
4651
  });
@@ -4745,12 +4666,12 @@ function categorical$1(base, _ref) {
4745
4666
  var VECTOR_SOURCE_ID = "".concat(TABLE_ID, ".geom");
4746
4667
  categories = categories ? categories.map(function (category) {
4747
4668
  return _objectSpread2(_objectSpread2({}, category), {}, {
4748
- color: get$1(COLOR_SCHEMES, category.color) || category.color
4669
+ color: get(COLOR_SCHEMES, category.color) || category.color
4749
4670
  });
4750
4671
  }) : null;
4751
4672
  return _objectSpread2(_objectSpread2({}, base), {}, {
4752
4673
  layers: _objectSpread2(_objectSpread2({}, base.layers), {}, _defineProperty({}, "".concat(VECTOR_SOURCE_ID, "_circle"), vectorLayer(VECTOR_SOURCE_ID, {
4753
- zIndex: ABOVE_BASE_MAP_LAYERS_Z_INDEX_BASE,
4674
+ zIndex: ABOVE_BASE_MAP_LAYERS_Z_INDEX_BASE + 2,
4754
4675
  type: 'circle',
4755
4676
  legends: [].concat(_toConsumableArray(categories ? [{
4756
4677
  type: 'ColorLegend',
@@ -4797,6 +4718,7 @@ var BY_TYPE$1 = {
4797
4718
  boolean_categorical: boolean_categorical$1,
4798
4719
  categorical: categorical$1
4799
4720
  };
4721
+ var DEFAULT_BUFFER_SIZE$1 = 200;
4800
4722
  function cem_escolas_2022(config, allViewSpecs, context) {
4801
4723
  var collection_id = config.collection_id,
4802
4724
  variable_id = config.variable_id,
@@ -4847,7 +4769,7 @@ function cem_escolas_2022(config, allViewSpecs, context) {
4847
4769
  path: indicator_path,
4848
4770
  metodology: metodology,
4849
4771
  keywords: [indicator_path, $sourceLabel, 'educação', keywords].filter(Boolean),
4850
- conf: {
4772
+ confSchema: {
4851
4773
  data: {
4852
4774
  variantId: {
4853
4775
  label: 'Rede de ensino:',
@@ -4868,39 +4790,149 @@ function cem_escolas_2022(config, allViewSpecs, context) {
4868
4790
  type: 'booleanCheckbox',
4869
4791
  description: 'Tamanho proporcional à quantidade de matrículas',
4870
4792
  defaultValue: true
4871
- } : 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
+ }
4872
4826
  }
4873
4827
  },
4874
4828
  metadata: {
4875
- variableValues: ['$get', ['$template', '[].${0}', VARIABLE_ID], ['$fetch', {
4876
- href: METADATA_API_ENDPOINT,
4877
- pathname: collection_id,
4878
- searchParams: ['$merge', {
4879
- select: VARIABLE_ID,
4880
- id_municipio: _id_municipio_apiFilterExpr
4881
- }, _fetchMetadataApiFilterExpResolver]
4882
- }]],
4883
- sizingValues: sizing_variable_id ? ['$if', ['$get', 'view.conf.data.showSize'], ['$filter', ['$get', ['$template', '[].${0}', sizing_variable_id], ['$fetch', {
4884
- href: METADATA_API_ENDPOINT,
4885
- pathname: collection_id,
4886
- searchParams: ['$merge', {
4887
- select: sizing_variable_id,
4888
- id_municipio: _id_municipio_apiFilterExpr
4889
- }, _fetchMetadataApiFilterExpResolver]
4890
- }]], ['$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
+ }]
4891
4894
  },
4892
- 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, {
4893
4896
  attribution: $sourceLabel,
4897
+ promoteId: 'id_escola',
4894
4898
  version: 2,
4895
4899
  minzoom: 8,
4896
4900
  maxzoom: 20
4897
- }))),
4898
- layers: _objectSpread2({}, globalRes.layers),
4899
- download: downloadResolver({
4900
- fileNameBase: ['$template', '${0}_${1}_georedus_edu', [VARIABLE_ID, ['$get', 'municipioId']]],
4901
- mainVariableId: VARIABLE_ID,
4902
- availableVariableIds: uniqBy(allViewSpecs.filter(function (spec) {
4903
- return Boolean(spec.variable_id);
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) {
4935
+ return Boolean(spec.variable_id);
4904
4936
  }).map(function (spec) {
4905
4937
  return {
4906
4938
  label: [spec.indicator_label, spec.variant_label].filter(Boolean).join(' | '),
@@ -4911,13 +4943,13 @@ function cem_escolas_2022(config, allViewSpecs, context) {
4911
4943
  }),
4912
4944
  fetchData: resolve.fn(function (context) {
4913
4945
  return /*#__PURE__*/function () {
4914
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
4946
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref3) {
4915
4947
  var variableIds;
4916
- return _regeneratorRuntime().wrap(function _callee$(_context) {
4917
- while (1) switch (_context.prev = _context.next) {
4948
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
4949
+ while (1) switch (_context2.prev = _context2.next) {
4918
4950
  case 0:
4919
- variableIds = _ref.variableIds, _ref.options;
4920
- _context.next = 3;
4951
+ variableIds = _ref3.variableIds, _ref3.options;
4952
+ _context2.next = 3;
4921
4953
  return resolveExprAsync(['$fetch', {
4922
4954
  href: METADATA_API_ENDPOINT,
4923
4955
  pathname: collection_id,
@@ -4927,15 +4959,15 @@ function cem_escolas_2022(config, allViewSpecs, context) {
4927
4959
  }, _fetchMetadataApiFilterExpResolver]
4928
4960
  }], context);
4929
4961
  case 3:
4930
- return _context.abrupt("return", _context.sent);
4962
+ return _context2.abrupt("return", _context2.sent);
4931
4963
  case 4:
4932
4964
  case "end":
4933
- return _context.stop();
4965
+ return _context2.stop();
4934
4966
  }
4935
- }, _callee);
4967
+ }, _callee2);
4936
4968
  }));
4937
- return function (_x) {
4938
- return _ref2.apply(this, arguments);
4969
+ return function (_x2) {
4970
+ return _ref4.apply(this, arguments);
4939
4971
  };
4940
4972
  }();
4941
4973
  })
@@ -4957,12 +4989,13 @@ function cem_escolas_2022(config, allViewSpecs, context) {
4957
4989
  var filter = variantId ? variantSpec.filter : null;
4958
4990
  return ['all', ['==', ['get', 'id_municipio'], ['$get', 'municipioId']]].concat(_toConsumableArray(isPlainObject(filter) ? fmtMaplibreGlFilterExp(filter) : []));
4959
4991
  });
4960
- 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],
4961
- // Replace "density" with your property name
4962
- ['$min', ['$get', 'view.metadata.sizingValues']], SIZE_MIN,
4963
- // When qt_mat_fund_ai is 0, radius is 6
4964
- ['$max', ['$get', 'view.metadata.sizingValues']], SIZE_MAX // When qt_mat_fund_ai is 100, radius is 20
4965
- ], 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;
4966
4999
  var $tooltip = {
4967
5000
  title: ['$literal', ['$get', 'feature.properties.no_escola']],
4968
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) {
@@ -4973,16 +5006,16 @@ function cem_escolas_2022(config, allViewSpecs, context) {
4973
5006
  in_fund_af: 'Fundamental II',
4974
5007
  in_med: 'Ensino Médio'
4975
5008
  };
4976
- return Object.entries(ETAPAS).filter(function (_ref3) {
5009
+ return Object.entries(ETAPAS).filter(function (_ref5) {
4977
5010
  var _context$feature, _context$feature2;
4978
- var _ref4 = _slicedToArray(_ref3, 2),
4979
- key = _ref4[0];
4980
- _ref4[1];
5011
+ var _ref6 = _slicedToArray(_ref5, 2),
5012
+ key = _ref6[0];
5013
+ _ref6[1];
4981
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]);
4982
- }).map(function (_ref5) {
4983
- var _ref6 = _slicedToArray(_ref5, 2);
4984
- _ref6[0];
4985
- var label = _ref6[1];
5015
+ }).map(function (_ref7) {
5016
+ var _ref8 = _slicedToArray(_ref7, 2);
5017
+ _ref8[0];
5018
+ var label = _ref8[1];
4986
5019
  return label;
4987
5020
  }).join(', ');
4988
5021
  })]], ['Rede de ensino', ['$literal', ['$get', 'feature.properties.tp_dependencia']]]].filter(Boolean)
@@ -5048,6 +5081,8 @@ function variableIdValidator(schema) {
5048
5081
 
5049
5082
  var DEFAULT_BUFFER_SIZE = 200;
5050
5083
  var INSUFFICIENT_DATA_COLOR = 'red';
5084
+ var BUILDINGS_MIN_ZOOM = 14;
5085
+ var BUILDINGS_3D_MIN_ZOOM = 16;
5051
5086
 
5052
5087
  //
5053
5088
  //
@@ -5165,6 +5200,12 @@ function cem_censo_2010_2022(viewSpec, allViewSpecs, context) {
5165
5200
  title: ['$literal', ['$coalesce', ['$get', 'feature.properties.name'], ['$get', 'feature.properties.nome'], ['$get', 'feature.properties.label'], ['$get', 'feature.properties.title'], ['$get', 'feature.properties.id'], ['$get', ['$get', '0', ['$keys', ['$get', 'feature.properties']]], ['$get', 'feature.properties']]]],
5166
5201
  entries: ['$literal', ['$entries', ['$get', 'feature.properties']]]
5167
5202
  };
5203
+
5204
+ //
5205
+ // Fill color expression for data loaded from
5206
+ // vector source
5207
+ //
5208
+ var _vectorSourceFillColor = ['$flat', [['step', ['coalesce', ['get', ['$get', 'view.conf.data.variableId']], -1]], ['$get', 'view.metadata.colorScaleStops']]];
5168
5209
  var sourceLabel = "CENSO ".concat(year);
5169
5210
  return {
5170
5211
  // debug: true,
@@ -5175,7 +5216,7 @@ function cem_censo_2010_2022(viewSpec, allViewSpecs, context) {
5175
5216
  sourceLabel: sourceLabel,
5176
5217
  viewType: VIEW_TYPE_SURFACE_CHOROPLETH,
5177
5218
  keywords: [indicator_path, sourceLabel, variant_path, variant_label, variable_id, keywords].filter(Boolean),
5178
- conf: {
5219
+ confSchema: {
5179
5220
  data: {
5180
5221
  variableId: {
5181
5222
  label: 'Recorte:',
@@ -5199,11 +5240,11 @@ function cem_censo_2010_2022(viewSpec, allViewSpecs, context) {
5199
5240
  'TIFF/GeoTIFF (.tif/.tiff)', 'GeoJSON (.json/.geojson)', 'ESRI Shapefile (armazenar arquivos .shp, .shx, .dbf, etc. em um arquivo .zip único)'].join(', ')
5200
5241
  },
5201
5242
  pointsDisplayMode: {
5202
- inactive: resolve.fn(function (context) {
5243
+ inactive: resolve.literal(resolve.fn(function (context) {
5203
5244
  var _context$value;
5204
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;
5205
5246
  return !Array.isArray(geometryTypes) || !geometryTypes.includes('Point');
5206
- }),
5247
+ })),
5207
5248
  clearable: false,
5208
5249
  type: 'treeSelect',
5209
5250
  label: 'Visualizar pontos',
@@ -5220,26 +5261,26 @@ function cem_censo_2010_2022(viewSpec, allViewSpecs, context) {
5220
5261
  },
5221
5262
  bufferSize: {
5222
5263
  type: 'slider',
5223
- label: resolve.fn(function (context) {
5264
+ label: resolve.literal(resolve.fn(function (context) {
5224
5265
  var _context$value2;
5225
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)");
5226
- }),
5267
+ })),
5227
5268
  helperText: 'Raio de influência do ponto',
5228
5269
  min: 0,
5229
5270
  max: 2000,
5230
5271
  step: 50,
5231
5272
  defaultValue: DEFAULT_BUFFER_SIZE,
5232
- inactive: resolve.fn(function (context) {
5273
+ inactive: resolve.literal(resolve.fn(function (context) {
5233
5274
  var _context$value3, _context$value4;
5234
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;
5235
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';
5236
- })
5277
+ }))
5237
5278
  },
5238
5279
  dissolveOverlappingGeometries: {
5239
- inactive: resolve.fn(function (context) {
5280
+ inactive: resolve.literal(resolve.fn(function (context) {
5240
5281
  var _context$value5, _context$value6;
5241
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';
5242
- }),
5283
+ })),
5243
5284
  type: 'booleanCheckbox',
5244
5285
  label: 'Dissolver geometrias',
5245
5286
  description: 'Unir geometrias sobrepostas',
@@ -5258,120 +5299,151 @@ function cem_censo_2010_2022(viewSpec, allViewSpecs, context) {
5258
5299
  }
5259
5300
  }
5260
5301
  },
5261
- metadata: ['$let', {
5262
- customGeoJSON: ['$if', ['$empty', ['$get', 'view.conf.data.customSpatialAggregationUnit']], null, resolveAsync.fn(/*#__PURE__*/function () {
5263
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(context) {
5264
- var contents, BASE, POINTS, LINE_STRINGS, AREAS_FEATURES, AREAS_BASE, AREAS;
5265
- return _regeneratorRuntime().wrap(function _callee$(_context) {
5266
- while (1) switch (_context.prev = _context.next) {
5267
- case 0:
5268
- _context.next = 2;
5269
- return fileReadAs(context.view.conf.data.customSpatialAggregationUnit, 'text');
5270
- case 2:
5271
- contents = _context.sent;
5272
- BASE = JSON.parse(contents); //
5273
- // Generate a layer with points only
5274
- //
5275
- POINTS = _objectSpread2(_objectSpread2({}, BASE), {}, {
5276
- features: BASE.features.filter(function (feat) {
5277
- var _feat$geometry;
5278
- return ((_feat$geometry = feat.geometry) === null || _feat$geometry === void 0 ? void 0 : _feat$geometry.type) === 'Point';
5279
- })
5280
- });
5281
- LINE_STRINGS = _objectSpread2(_objectSpread2({}, BASE), {}, {
5282
- features: BASE.features.filter(function (feat) {
5283
- var _feat$geometry2;
5284
- return ((_feat$geometry2 = feat.geometry) === null || _feat$geometry2 === void 0 ? void 0 : _feat$geometry2.type) === 'LineString';
5285
- })
5286
- }); //
5287
- // Layer with areas
5288
- //
5289
- AREAS_FEATURES = context.view.conf.data.pointsDisplayMode === 'heatmap' ?
5290
- //
5291
- // If points are set to be displayed as heatmap,
5292
- // remove them from area calculation
5293
- //
5294
- BASE.features.filter(function (feat) {
5295
- var _feat$geometry3;
5296
- return ((_feat$geometry3 = feat.geometry) === null || _feat$geometry3 === void 0 ? void 0 : _feat$geometry3.type) !== 'Point';
5297
- }) : BASE.features;
5298
- AREAS_BASE = _objectSpread2(_objectSpread2({}, BASE), {}, {
5299
- features: AREAS_FEATURES.map(function (feat) {
5300
- return _objectSpread2(_objectSpread2({}, feat), {}, {
5301
- geometry: _applyBuffers(feat.geometry, pick(context.view.conf.data, ['bufferSize']))
5302
- });
5303
- })
5304
- });
5305
- if (!(context.view.conf.data.pointsDisplayMode === 'heatmap')) {
5306
- _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;
5307
5363
  break;
5308
- }
5309
- _context.t0 = null;
5310
- _context.next = 20;
5311
- break;
5312
- case 12:
5313
- if (!(context.view.conf.data.dissolveOverlappingGeometries && AREAS_BASE)) {
5314
- _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;
5315
5374
  break;
5316
- }
5317
- _context.next = 15;
5318
- return GeoReDUSWorker.dissolveAreasPreservingIsolated(AREAS_BASE);
5319
- case 15:
5320
- _context.t1 = _context.sent;
5321
- _context.next = 19;
5322
- break;
5323
- case 18:
5324
- _context.t1 = AREAS_BASE;
5325
- case 19:
5326
- _context.t0 = _context.t1;
5327
- case 20:
5328
- AREAS = _context.t0;
5329
- return _context.abrupt("return", {
5330
- BASE: BASE,
5331
- POINTS: POINTS,
5332
- LINE_STRINGS: LINE_STRINGS,
5333
- AREAS: AREAS
5334
- });
5335
- case 22:
5336
- case "end":
5337
- return _context.stop();
5338
- }
5339
- }, _callee);
5340
- }));
5341
- return function (_x) {
5342
- return _ref2.apply(this, arguments);
5343
- };
5344
- }())]
5345
- }, ['$let', {
5346
- 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}', {
5347
- variableId: ['$get', 'view.conf.data.variableId'],
5348
- municipioId: ['$context', 'municipioId'],
5349
- source_table_id: ['$get', ['$template', '${0}.source_table_id', ['$get', 'view.conf.data.variableId']], variantsByVariableId]
5350
- }]]], ['$fetch', {
5351
- href: METADATA_API_ENDPOINT,
5352
- 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
+ }]]
5353
5422
  }, {
5354
- method: 'POST',
5355
- headers: {
5356
- 'Content-Type': 'application/json'
5357
- },
5358
- body: {
5359
- geometries: ['$get', 'features[].geometry', ['$get', 'customGeoJSON.AREAS']],
5360
- view: 'ibge_malha_br_setor_censitario_2010_spatial_agg',
5361
- agg_column: ['$get', 'view.conf.data.variableId'],
5362
- agg_type: ['$if', ['$endsWith', ['$get', 'view.conf.data.variableId'], '_pct'], 'weighted_avg', 'sum']
5363
- }
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
+ })]
5364
5444
  }]]
5365
- }, {
5366
- labels: labels,
5367
- measureUnits: measureUnits,
5368
- variableValues: ['$get', 'variableValues'],
5369
- customGeoJSON: ['$get', 'customGeoJSON'],
5370
- colorScaleStops: ['$naturalBreaks', ['$get', 'variableValues'], _objectSpread2(_objectSpread2({}, _color_scheme), {}, {
5371
- minK: 5
5372
- })]
5373
- }]],
5374
- sources: _objectSpread2(_objectSpread2({}, globalRes.sources), {}, _defineProperty({
5445
+ },
5446
+ sources: _objectSpread2(_objectSpread2({}, globalRes.sources), {}, _defineProperty(_defineProperty({
5375
5447
  //
5376
5448
  // Points in custom GeoJson
5377
5449
  //
@@ -5428,9 +5500,10 @@ function cem_censo_2010_2022(viewSpec, allViewSpecs, context) {
5428
5500
  }, VECTOR_SOURCE_ID, {
5429
5501
  type: 'vector',
5430
5502
  attribution: sourceLabel,
5431
- minzoom: 6,
5503
+ minzoom: 8,
5432
5504
  maxzoom: 20,
5433
- tiles: [['$join', ["".concat(VECTOR_TILE_SERVER_ENDPOINT, "/dynamic_vector_tiles/{z}/{x}/{y}?"), ['$urlSearch', {
5505
+ promoteId: 'cd_setor',
5506
+ tiles: [['$join', ["".concat(VECTOR_TILE_SERVER_ENDPOINT, "/dvt/{z}/{x}/{y}?"), ['$urlSearch', {
5434
5507
  view: ['$get', ['$template', '${0}.collection_id', ['$get', 'view.conf.data.variableId']], variantsByVariableId],
5435
5508
  select: ['cd_setor'],
5436
5509
  join_view: ['$get', ['$template', '${0}.source_table_id', ['$get', 'view.conf.data.variableId']], variantsByVariableId],
@@ -5441,8 +5514,33 @@ function cem_censo_2010_2022(viewSpec, allViewSpecs, context) {
5441
5514
  cd_mun: [['$get', 'municipioId']]
5442
5515
  }
5443
5516
  }]]]]
5517
+ }), "".concat(VECTOR_SOURCE_ID, "_buildings"), {
5518
+ type: 'vector',
5519
+ attribution: sourceLabel,
5520
+ minzoom: 6,
5521
+ maxzoom: 20,
5522
+ tiles: [['$join', ["".concat(VECTOR_TILE_SERVER_ENDPOINT, "/dvt/{z}/{x}/{y}?"), ['$urlSearch', {
5523
+ view: 'overture_br_buildings',
5524
+ // view: [
5525
+ // '$get',
5526
+ // [
5527
+ // '$template',
5528
+ // '${0}.collection_id',
5529
+ // ['$get', 'view.conf.data.variableId'],
5530
+ // ],
5531
+ // variantsByVariableId,
5532
+ // ],
5533
+ select: ['height', 'subtype'],
5534
+ join_view: ['$get', ['$template', '${0}.source_table_id', ['$get', 'view.conf.data.variableId']], variantsByVariableId],
5535
+ join_source_column: "setor_".concat(year, "_id"),
5536
+ join_target_column: 'cd_setor',
5537
+ join_select: [['$get', 'view.conf.data.variableId']],
5538
+ where: {
5539
+ municipio_id: [['$get', 'municipioId']]
5540
+ }
5541
+ }]]]]
5444
5542
  })),
5445
- layers: _objectSpread2(_objectSpread2({}, globalRes.layers), {}, _defineProperty(_defineProperty({
5543
+ layers: _objectSpread2(_objectSpread2({}, globalRes.layers), {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty({
5446
5544
  customGeoJSON_Areas_fill: {
5447
5545
  hidden: ['$empty', ['$get', 'view.conf.data.customSpatialAggregationUnit']],
5448
5546
  source: 'customGeoJSON_Areas',
@@ -5506,31 +5604,88 @@ function cem_censo_2010_2022(viewSpec, allViewSpecs, context) {
5506
5604
  }
5507
5605
  }, "".concat(VECTOR_SOURCE_ID, "_fill"), {
5508
5606
  hidden: ['$not', ['$empty', ['$get', 'view.metadata.customGeoJSON.AREAS']]],
5509
- // interactive: [
5510
- // '$empty',
5511
- // ['$get', 'view.conf.data.customSpatialAggregationUnit'],
5512
- // ],
5607
+ interactive: true,
5513
5608
  legends: _legends,
5514
5609
  tooltip: {
5515
- // title: [
5516
- // '$literal',
5517
- // [
5518
- // '$template',
5519
- // 'Setor ${0}',
5520
- // ['$get', 'feature.properties.cd_setor'],
5521
- // ],
5522
- // ],
5610
+ title: null,
5523
5611
  entries: [_variableValueTooltipEntry]
5524
5612
  },
5525
5613
  source: VECTOR_SOURCE_ID,
5526
- 'source-layer': 'dynamic_vector_tile',
5614
+ 'source-layer': 'dvt',
5527
5615
  type: 'fill',
5528
- // filter: ['==', ['get', 'cd_mun'], ['$get', 'municipioId']],
5616
+ // maxzoom: 14,
5529
5617
  paint: {
5530
- 'fill-color': ['$flat', [['step', ['coalesce', ['get', ['$get', 'view.conf.data.variableId']], -1]], ['$get', 'view.metadata.colorScaleStops']]],
5531
- 'fill-opacity': ['$get', 'view.conf.style.layerOpacity'],
5618
+ // 'fill-color': [
5619
+ // '$flat',
5620
+ // [
5621
+ // [
5622
+ // 'step',
5623
+ // [
5624
+ // 'coalesce',
5625
+ // ['get', ['$get', 'view.conf.data.variableId']],
5626
+ // -1,
5627
+ // ],
5628
+ // ],
5629
+ // ['$get', 'view.metadata.colorScaleStops'],
5630
+ // ],
5631
+ // ],
5632
+ 'fill-color': _vectorSourceFillColor,
5633
+ // 'fill-opacity': ['$get', 'view.conf.style.layerOpacity'],
5634
+ 'fill-opacity': ['step', ['zoom'], ['$get', 'view.conf.style.layerOpacity'],
5635
+ // default: zoom < 14 → opacity = 1
5636
+ BUILDINGS_MIN_ZOOM, 0.1 // zoom ≥ 14 → opacity = 0
5637
+ ],
5532
5638
  'fill-outline-color': 'transparent'
5533
5639
  }
5640
+ }), "".concat(VECTOR_SOURCE_ID, "_boundary_lines"), {
5641
+ hidden: ['$not', ['$empty', ['$get', 'view.metadata.customGeoJSON.AREAS']]],
5642
+ source: VECTOR_SOURCE_ID,
5643
+ 'source-layer': 'dvt',
5644
+ type: 'line',
5645
+ interactive: true,
5646
+ // minzoom: BUILDINGS_MIN_ZOOM,
5647
+ paint: {
5648
+ 'line-color': _vectorSourceFillColor,
5649
+ 'line-width': ['step', ['zoom'],
5650
+ // default: zoom < 14 → thin lines
5651
+ ['case', ['boolean', ['feature-state', 'hover'], false], 4, 0], BUILDINGS_MIN_ZOOM,
5652
+ // zoom ≥ 14 → larger lines
5653
+ ['case', ['boolean', ['feature-state', 'hover'], false], 5, 1]],
5654
+ 'line-opacity': ['case', ['boolean', ['feature-state', 'hover'], false], 1, ['$get', 'view.conf.style.layerOpacity']],
5655
+ 'line-dasharray': [2, 2]
5656
+ }
5657
+ }), "".concat(VECTOR_SOURCE_ID, "_buildings"), {
5658
+ hidden: ['$not', ['$empty', ['$get', 'view.metadata.customGeoJSON.AREAS']]],
5659
+ interactive: false,
5660
+ // tooltip: {
5661
+ // title: ['$literal', ['$get', 'feature.properties.primary_name']],
5662
+ // entries: [],
5663
+ // // entries: [
5664
+ // // _variableValueTooltipEntry,
5665
+ // // // ['subtype', ['$literal', ['$get', 'feature.properties.subtype']]],
5666
+ // // ],
5667
+ // },
5668
+ source: "".concat(VECTOR_SOURCE_ID, "_buildings"),
5669
+ 'source-layer': 'dvt',
5670
+ type: 'fill-extrusion',
5671
+ minzoom: BUILDINGS_MIN_ZOOM,
5672
+ paint: {
5673
+ //
5674
+ // If indicator is about populacao-e-domicilios,
5675
+ // do not color paint buildings whose subtype
5676
+ // is known and is not residential.
5677
+ //
5678
+ // Otherwise, apply color to all buildings
5679
+ //
5680
+ 'fill-extrusion-color': indicator_path !== null && indicator_path !== void 0 && indicator_path.startsWith('População e domicílios') ? ['case', ['in', ['get', 'subtype'], ['literal', ['agricultural', 'civic', 'commercial', 'education', 'entertainment', 'industrial', 'medical', 'military', 'outbuilding', 'religious',
5681
+ // 'residential',
5682
+ 'service', 'transportation']]], '#EFEFEF', _vectorSourceFillColor] : _vectorSourceFillColor,
5683
+ 'fill-extrusion-opacity': 0.8,
5684
+ // 'fill-extrusion-opacity': ['$get', 'view.conf.style.layerOpacity'],
5685
+ // 'fill-extrusion-outline-color': 'transparent',
5686
+ 'fill-extrusion-height': ['step', ['zoom'], 0, BUILDINGS_3D_MIN_ZOOM, ['coalesce', ['get', 'height'], 0]]
5687
+ // ['get', 'height'], // Adjust as needed
5688
+ }
5534
5689
  }), "customGeoJSON_Points_heatmap", {
5535
5690
  hidden: ['$or', ['$empty', ['$get', 'view.conf.data.customSpatialAggregationUnit']], ['$not', ['$eq', ['$get', 'view.conf.data.pointsDisplayMode'], 'heatmap']]],
5536
5691
  source: 'customGeoJSON_Points',
@@ -5543,38 +5698,38 @@ function cem_censo_2010_2022(viewSpec, allViewSpecs, context) {
5543
5698
  // availableVariableIds: [variable_id, 'str_nome_fantasia', 'id_cnes'],
5544
5699
  fetchData: resolve.fn(function (context) {
5545
5700
  return /*#__PURE__*/function () {
5546
- var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref3) {
5701
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref5) {
5547
5702
  var data, geometries;
5548
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
5549
- while (1) switch (_context2.prev = _context2.next) {
5703
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
5704
+ while (1) switch (_context3.prev = _context3.next) {
5550
5705
  case 0:
5551
- _ref3.variableIds, _ref3.options;
5552
- _context2.next = 3;
5706
+ _ref5.variableIds, _ref5.options;
5707
+ _context3.next = 3;
5553
5708
  return resolveExprAsync(['$fetch', ['$template', "".concat(METADATA_API_ENDPOINT) + '/${source_table_id}?select=' + '${variableId},' + 'cd_setor' + '&cd_mun=eq.' + '${municipioId}', {
5554
5709
  variableId: ['$get', 'view.conf.data.variableId'],
5555
5710
  municipioId: ['$context', 'municipioId'],
5556
5711
  source_table_id: ['$get', ['$template', '${0}.source_table_id', ['$get', 'view.conf.data.variableId']], variantsByVariableId]
5557
5712
  }]], context);
5558
5713
  case 3:
5559
- data = _context2.sent;
5560
- _context2.next = 6;
5714
+ data = _context3.sent;
5715
+ _context3.next = 6;
5561
5716
  return resolveExprAsync(['$fetch', ['$template', "".concat(METADATA_API_ENDPOINT) + '/${collection_id}?select=geom,cd_setor' + '&cd_mun=eq.' + '${municipioId}', {
5562
5717
  municipioId: ['$context', 'municipioId'],
5563
5718
  collection_id: ['$get', ['$template', '${0}.collection_id', ['$get', 'view.conf.data.variableId']], variantsByVariableId]
5564
5719
  }]], context);
5565
5720
  case 6:
5566
- geometries = _context2.sent;
5567
- return _context2.abrupt("return", dataJoin([geometries, data], {
5721
+ geometries = _context3.sent;
5722
+ return _context3.abrupt("return", dataJoin([geometries, data], {
5568
5723
  key: 'cd_setor'
5569
5724
  }));
5570
5725
  case 8:
5571
5726
  case "end":
5572
- return _context2.stop();
5727
+ return _context3.stop();
5573
5728
  }
5574
- }, _callee2);
5729
+ }, _callee3);
5575
5730
  }));
5576
- return function (_x2) {
5577
- return _ref4.apply(this, arguments);
5731
+ return function (_x3) {
5732
+ return _ref6.apply(this, arguments);
5578
5733
  };
5579
5734
  }();
5580
5735
  })
@@ -5698,7 +5853,7 @@ function numerical_size(base, _ref) {
5698
5853
  // When qt_mat_fund_ai is 0, radius is 6
5699
5854
  ['$max', ['$get', 'view.metadata.variableValues']], SIZE_MAX // When qt_mat_fund_ai is 100, radius is 20
5700
5855
  ],
5701
- 'circle-color': get$1(COLOR_SCHEMES, color_scheme) || color_scheme
5856
+ 'circle-color': get(COLOR_SCHEMES, color_scheme) || color_scheme
5702
5857
  }
5703
5858
  })))
5704
5859
  });
@@ -5720,7 +5875,7 @@ function categorical(base, _ref) {
5720
5875
  var VECTOR_SOURCE_ID = "".concat(TABLE_ID, ".geom");
5721
5876
  categories = categories ? categories.map(function (category) {
5722
5877
  return _objectSpread2(_objectSpread2({}, category), {}, {
5723
- color: get$1(COLOR_SCHEMES, category.color) || category.color
5878
+ color: get(COLOR_SCHEMES, category.color) || category.color
5724
5879
  });
5725
5880
  }) : null;
5726
5881
  return _objectSpread2(_objectSpread2({}, base), {}, {
@@ -5842,7 +5997,7 @@ function cem_saude_2024(viewSpec, allViewSpecs, context) {
5842
5997
  sourceLabel: $sourceLabel,
5843
5998
  metodology: metodology,
5844
5999
  keywords: [indicator_path, $sourceLabel, 'saúde', 'hospital', 'UBS', keywords].filter(Boolean),
5845
- conf: {
6000
+ confSchema: {
5846
6001
  data: {
5847
6002
  // variantId: {
5848
6003
  // label: 'Rede de ensino:',
@@ -5881,6 +6036,7 @@ function cem_saude_2024(viewSpec, allViewSpecs, context) {
5881
6036
  },
5882
6037
  sources: _objectSpread2(_objectSpread2({}, globalRes.sources), {}, _defineProperty({}, VECTOR_SOURCE_ID, tableVectorSource(context, collection_id, {
5883
6038
  attribution: $sourceLabel,
6039
+ promoteId: 'id_cnes',
5884
6040
  minzoom: 8,
5885
6041
  maxzoom: 20
5886
6042
  }))),
@@ -6001,11 +6157,7 @@ var PRESETS = /*#__PURE__*/Object.freeze({
6001
6157
  function parseViewSpec(specInput, otherSpecInputs, context) {
6002
6158
  specInput = unflat(specInput);
6003
6159
  var preset = specInput.preset ? PRESETS[specInput.preset] : null;
6004
- if (preset) {
6005
- return preset(specInput, otherSpecInputs, context);
6006
- } else {
6007
- return specInput;
6008
- }
6160
+ return preset ? preset(specInput, otherSpecInputs, context) : specInput;
6009
6161
  }
6010
6162
 
6011
6163
  //
@@ -6100,6 +6252,90 @@ function resolveViewSpecs(viewSpecsInput, context) {
6100
6252
  });
6101
6253
  }
6102
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
+
6103
6339
  function viewConfReducer(state, action) {
6104
6340
  var _a;
6105
6341
  switch (action.type) {
@@ -6173,59 +6409,6 @@ function viewConfReducerInitialState(initialState) {
6173
6409
  }]
6174
6410
  };
6175
6411
  }
6176
- //
6177
- // Loads viewconf and loads global/shared configuration
6178
- //
6179
- // export function resolveViewConf(
6180
- // state: State,
6181
- // id: string,
6182
- // viewSpecsById: Record<string, ViewSpec>,
6183
- // ): ViewConf {
6184
- // //
6185
- // // Load the view's self conf
6186
- // //
6187
- // const viewConfSelf = state.byId[id]
6188
- // //
6189
- // // Load global configurations from other active views
6190
- // //
6191
- // const globalConf = Object.entries(state.byId)
6192
- // .map(([otherViewId, otherViewConf]) => {
6193
- // if (otherViewId === id) {
6194
- // return null
6195
- // }
6196
- // const otherViewSpec = viewSpecsById[otherViewId]
6197
- // const otherViewGlobalConfPairs =
6198
- // otherViewSpec.conf &&
6199
- // CONF_TAB_IDS.flatMap((tabId) => {
6200
- // const tabSchema = otherViewSpec.conf[tabId]
6201
- // if (!tabSchema) {
6202
- // return null
6203
- // }
6204
- // const tabValue = otherViewConf[tabId]
6205
- // return Object.entries(tabSchema)
6206
- // .filter(([propertyKey, propertySchema]) =>
6207
- // Boolean(propertySchema && propertySchema.global),
6208
- // )
6209
- // .map(([propertyKey, propertySchema]) => {
6210
- // const propertyValue = tabValue ? tabValue[propertyKey] : undefined
6211
- // return typeof propertyValue === 'undefined'
6212
- // ? null
6213
- // : [propertyKey, propertyValue]
6214
- // })
6215
- // }).filter(Boolean)
6216
- // return otherViewGlobalConfPairs.length > 0
6217
- // ? {
6218
- // viewId: otherViewId,
6219
- // conf: Object.fromEntries(otherViewGlobalConfPairs),
6220
- // }
6221
- // : null
6222
- // })
6223
- // .filter(Boolean)
6224
- // console.log({
6225
- // globalConf,
6226
- // })
6227
- // return { ...viewConfSelf, global: globalConf }
6228
- // }
6229
6412
 
6230
6413
  function getDeviceLocation() {
6231
6414
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -6446,6 +6629,316 @@ function InputProvider(props) {
6446
6629
  }, props));
6447
6630
  }
6448
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
+
6449
6942
  var _templateObject, _templateObject2, _templateObject3;
6450
6943
 
6451
6944
  //
@@ -6467,17 +6960,17 @@ function _flyToMunicipio(_x, _x2, _x3, _x4) {
6467
6960
  // We use a customizable style on maptiler
6468
6961
  //
6469
6962
  function _flyToMunicipio2() {
6470
- _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) {
6471
6964
  var _yield$fetch$then, _yield$fetch$then2, mun;
6472
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
6473
- while (1) switch (_context6.prev = _context6.next) {
6965
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
6966
+ while (1) switch (_context5.prev = _context5.next) {
6474
6967
  case 0:
6475
- _context6.next = 2;
6968
+ _context5.next = 2;
6476
6969
  return fetch("".concat(METADATA_API_ENDPOINT, "/ibge_malha_br_municipio?select=bbox&id=eq.").concat(municipioId)).then(function (res) {
6477
6970
  return res.json();
6478
6971
  });
6479
6972
  case 2:
6480
- _yield$fetch$then = _context6.sent;
6973
+ _yield$fetch$then = _context5.sent;
6481
6974
  _yield$fetch$then2 = _slicedToArray(_yield$fetch$then, 1);
6482
6975
  mun = _yield$fetch$then2[0];
6483
6976
  if (mun && mun.bbox) {
@@ -6485,41 +6978,24 @@ function _flyToMunicipio2() {
6485
6978
  }
6486
6979
  case 6:
6487
6980
  case "end":
6488
- return _context6.stop();
6981
+ return _context5.stop();
6489
6982
  }
6490
- }, _callee6);
6983
+ }, _callee5);
6491
6984
  }));
6492
6985
  return _flyToMunicipio2.apply(this, arguments);
6493
6986
  }
6494
6987
  var REDUS_DATAVIZ_STYLE = 'https://api.maptiler.com/maps/0195f947-fb77-7256-83d6-47a54db345a3/style.json';
6988
+ // const REDUS_DATAVIZ_STYLE =
6989
+ // 'https://api.maptiler.com/maps/streets-v2/style.json'
6495
6990
  // const MAP_STYLE_URL = `https://api.maptiler.com/maps/dataviz/style.json?key=${process.env.NEXT_PUBLIC_MAP_TILER_API_KEY}`
6496
6991
  var DATAVIZ_MAP_STYLE_URL = "".concat(REDUS_DATAVIZ_STYLE, "?key=").concat(process.env.NEXT_PUBLIC_MAP_TILER_API_KEY);
6497
6992
  var SATELLITE_MAP_STYLE_URL = "https://api.maptiler.com/maps/satellite/style.json?key=".concat(process.env.NEXT_PUBLIC_MAP_TILER_API_KEY);
6498
- 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"])));
6499
-
6500
6993
  //
6501
- // Custom queryKeyHashFn that correctly handles files
6994
+ // For elevation rendering
6502
6995
  //
6503
- // https://github.com/TanStack/query/blob/ff788ac4e0a9cbc6af6cdf1837fcbf5c0b0b9a9c/packages/query-core/src/utils.ts#L217
6504
- //
6505
- function queryKeyHashFnWithFileSupport(queryKey) {
6506
- return JSON.stringify(queryKey, function (_, val) {
6507
- if (val instanceof File) {
6508
- // Replace File with stable metadata representation
6509
- return {
6510
- __file__: true,
6511
- name: val.name,
6512
- size: val.size,
6513
- type: val.type,
6514
- lastModified: val.lastModified
6515
- };
6516
- }
6517
- return isPlainObject(val) ? Object.keys(val).sort().reduce(function (result, key) {
6518
- result[key] = val[key];
6519
- return result;
6520
- }, {}) : val;
6521
- });
6522
- }
6996
+ var DEM_SOURCE_URL = "https://api.maptiler.com/tiles/terrain-rgb-v2/{z}/{x}/{y}.webp?key=".concat(process.env.NEXT_PUBLIC_MAP_TILER_API_KEY);
6997
+ var DEM_SOURCE_ENCODING = 'mapbox';
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"])));
6523
6999
 
6524
7000
  //
6525
7001
  // From:
@@ -6544,6 +7020,15 @@ var BR_BBOX = {
6544
7020
  },
6545
7021
  properties: {}
6546
7022
  };
7023
+ var SKY_STYLE = {
7024
+ 'sky-color': '#199EF3',
7025
+ 'sky-horizon-blend': 0.5,
7026
+ 'horizon-color': '#d3edfd',
7027
+ 'horizon-fog-blend': 0.5,
7028
+ 'fog-color': '#0000ff',
7029
+ 'fog-ground-blend': 0.5,
7030
+ 'atmosphere-blend': ['interpolate', ['linear'], ['zoom'], 0, 1, 10, 1, 12, 0]
7031
+ };
6547
7032
  function GeoReDUSInner(_ref) {
6548
7033
  var globalState = _ref.state,
6549
7034
  onSetGlobalState = _ref.onSetState,
@@ -6641,54 +7126,21 @@ function GeoReDUSInner(_ref) {
6641
7126
  }(),
6642
7127
  throwOnError: process.env.NODE_ENV !== 'production'
6643
7128
  });
6644
- var viewSpecsById = useMemo(function () {
6645
- return Array.isArray(viewSpecsQuery.data) ? viewSpecsQuery.data.reduce(function (acc, viewSpec) {
6646
- return _objectSpread2(_objectSpread2({}, acc), {}, _defineProperty({}, viewSpec.id, viewSpec));
6647
- }, {}) : null;
6648
- }, [viewSpecsQuery.data]);
6649
- var viewsQueries = useQueries({
6650
- queries: viewConfState.layout.flatMap(function (list) {
6651
- return list.items.map(function (item) {
6652
- return item.id;
6653
- });
6654
- }).map(function (viewId) {
6655
- return {
6656
- queryKey: ['ResolveView', viewId, municipioId, viewSpecsById ? viewSpecsById[viewId] : null, viewConfState.byId[viewId]],
6657
- queryKeyHashFn: queryKeyHashFnWithFileSupport,
6658
- queryFn: function () {
6659
- var _queryFn2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
6660
- var viewSpec;
6661
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
6662
- while (1) switch (_context2.prev = _context2.next) {
6663
- case 0:
6664
- viewSpec = viewSpecsById ? viewSpecsById[viewId] : viewSpecsById;
6665
- return _context2.abrupt("return", viewSpec ? resolveView(viewSpec, viewConfState.byId[viewId], {
6666
- municipioId: municipioId,
6667
- baseMapStyle: baseMapStyle
6668
- }) : null);
6669
- case 2:
6670
- case "end":
6671
- return _context2.stop();
6672
- }
6673
- }, _callee2);
6674
- }));
6675
- function queryFn() {
6676
- return _queryFn2.apply(this, arguments);
6677
- }
6678
- return queryFn;
6679
- }(),
6680
- throwOnError: true,
6681
- retry: false
6682
- };
6683
- })
6684
- });
6685
- var resolvedViews = useMemo(function () {
6686
- return viewsQueries
6687
- // .filter((query) => query.status === 'success')
6688
- .map(function (query) {
6689
- return query.data;
6690
- }).filter(Boolean);
6691
- }, [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
+ //
6692
7144
  var resolvedLayout = useMemo(function () {
6693
7145
  var resolvedViewsById = Object.fromEntries(resolvedViews.map(function (view) {
6694
7146
  return [view.id, view];
@@ -6714,7 +7166,8 @@ function GeoReDUSInner(_ref) {
6714
7166
  id: list.id,
6715
7167
  views: views,
6716
7168
  legends: views.flatMap(function (view) {
6717
- 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) || [];
6718
7171
  })
6719
7172
  };
6720
7173
  });
@@ -6752,18 +7205,18 @@ function GeoReDUSInner(_ref) {
6752
7205
  required: true,
6753
7206
  clearable: false,
6754
7207
  placeholder: 'Selecione um município',
6755
- options: useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
7208
+ options: useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
6756
7209
  var municipios;
6757
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
6758
- while (1) switch (_context3.prev = _context3.next) {
7210
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
7211
+ while (1) switch (_context2.prev = _context2.next) {
6759
7212
  case 0:
6760
- _context3.next = 2;
7213
+ _context2.next = 2;
6761
7214
  return fetch("".concat(METADATA_API_ENDPOINT, "/ibge_malha_br_municipio?select=nome,id,uf_sigla")).then(function (response) {
6762
7215
  return response.json();
6763
7216
  });
6764
7217
  case 2:
6765
- municipios = _context3.sent;
6766
- return _context3.abrupt("return", municipios.map(function (mun) {
7218
+ municipios = _context2.sent;
7219
+ return _context2.abrupt("return", municipios.map(function (mun) {
6767
7220
  return {
6768
7221
  label: "".concat(mun['nome'], " (").concat(mun['uf_sigla'], ")"),
6769
7222
  value: mun['id'] + ''
@@ -6771,9 +7224,9 @@ function GeoReDUSInner(_ref) {
6771
7224
  }));
6772
7225
  case 4:
6773
7226
  case "end":
6774
- return _context3.stop();
7227
+ return _context2.stop();
6775
7228
  }
6776
- }, _callee3);
7229
+ }, _callee2);
6777
7230
  })), [])
6778
7231
  };
6779
7232
  var dialogs = useDialogs();
@@ -6787,22 +7240,22 @@ function GeoReDUSInner(_ref) {
6787
7240
  METADATA_API_ENDPOINT: METADATA_API_ENDPOINT,
6788
7241
  coordinates: null
6789
7242
  }).then(/*#__PURE__*/function () {
6790
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(resolvedMunicipioId) {
7243
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolvedMunicipioId) {
6791
7244
  var selectedMunicipioId;
6792
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
6793
- while (1) switch (_context4.prev = _context4.next) {
7245
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
7246
+ while (1) switch (_context3.prev = _context3.next) {
6794
7247
  case 0:
6795
7248
  if (resolvedMunicipioId) {
6796
- _context4.next = 11;
7249
+ _context3.next = 11;
6797
7250
  break;
6798
7251
  }
6799
7252
  selectedMunicipioId = null;
6800
7253
  case 2:
6801
7254
  if (!(typeof selectedMunicipioId !== 'string')) {
6802
- _context4.next = 8;
7255
+ _context3.next = 8;
6803
7256
  break;
6804
7257
  }
6805
- _context4.next = 5;
7258
+ _context3.next = 5;
6806
7259
  return dialogs.prompt({
6807
7260
  input: _objectSpread2(_objectSpread2({}, MUNICIPIO_ID_SELECTOR_SCHEMA), {}, {
6808
7261
  label: 'Município'
@@ -6811,12 +7264,12 @@ function GeoReDUSInner(_ref) {
6811
7264
  cancel: null
6812
7265
  });
6813
7266
  case 5:
6814
- selectedMunicipioId = _context4.sent;
6815
- _context4.next = 2;
7267
+ selectedMunicipioId = _context3.sent;
7268
+ _context3.next = 2;
6816
7269
  break;
6817
7270
  case 8:
6818
7271
  setMunicipioId(selectedMunicipioId);
6819
- _context4.next = 12;
7272
+ _context3.next = 12;
6820
7273
  break;
6821
7274
  case 11:
6822
7275
  setTimeout(function () {
@@ -6824,9 +7277,9 @@ function GeoReDUSInner(_ref) {
6824
7277
  }, 400);
6825
7278
  case 12:
6826
7279
  case "end":
6827
- return _context4.stop();
7280
+ return _context3.stop();
6828
7281
  }
6829
- }, _callee4);
7282
+ }, _callee3);
6830
7283
  }));
6831
7284
  return function (_x5) {
6832
7285
  return _ref3.apply(this, arguments);
@@ -6839,7 +7292,7 @@ function GeoReDUSInner(_ref) {
6839
7292
  // Control map position focus
6840
7293
  //
6841
7294
  useEffect(function () {
6842
- var mainMap = get$1(syncedMapsRef.current, 'mapInstances[0].map');
7295
+ var mainMap = get(syncedMapsRef.current, 'mapInstances[0].map');
6843
7296
  if (!mainMap) {
6844
7297
  return;
6845
7298
  }
@@ -6891,13 +7344,10 @@ function GeoReDUSInner(_ref) {
6891
7344
  return null;
6892
7345
  }
6893
7346
  }, []);
6894
- var isLoading = viewsQueries.some(function (viewQuery) {
6895
- return viewQuery.status === 'pending';
6896
- });
6897
7347
  return /*#__PURE__*/React.createElement(Flex, null, /*#__PURE__*/React.createElement(LeftPanel, {
6898
7348
  open: leftPanelOpen,
6899
7349
  onSetOpen: setLeftPanelOpen,
6900
- viewSpecs: viewSpecsQuery.data,
7350
+ viewSpecs: resolvedViewSpecs,
6901
7351
  viewConfState: viewConfState,
6902
7352
  viewConfDispatch: viewConfDispatch,
6903
7353
  resolvedViews: resolvedViews,
@@ -6925,6 +7375,7 @@ function GeoReDUSInner(_ref) {
6925
7375
  value: municipioId,
6926
7376
  onSetValue: setMunicipioId
6927
7377
  }))), /*#__PURE__*/React.createElement(SyncedMaps, {
7378
+ maxPitch: 80,
6928
7379
  onDrag: function onDrag() {
6929
7380
  if (resolvedLayout.length > 1 && leftPanelOpen) {
6930
7381
  //
@@ -6936,16 +7387,16 @@ function GeoReDUSInner(_ref) {
6936
7387
  },
6937
7388
  ref: syncedMapsRef,
6938
7389
  onLoad: (/*#__PURE__*/function () {
6939
- var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(event) {
6940
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
6941
- 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) {
6942
7393
  case 0:
6943
- return _context5.abrupt("return", _refocus(event.target));
7394
+ return _context4.abrupt("return", _refocus(event.target));
6944
7395
  case 1:
6945
7396
  case "end":
6946
- return _context5.stop();
7397
+ return _context4.stop();
6947
7398
  }
6948
- }, _callee5);
7399
+ }, _callee4);
6949
7400
  }));
6950
7401
  return function (_x6) {
6951
7402
  return _ref5.apply(this, arguments);
@@ -6962,6 +7413,7 @@ function GeoReDUSInner(_ref) {
6962
7413
  },
6963
7414
  setPrefetchZoomDelta: 0,
6964
7415
  mapStyle: baseMapStyle === 'satellite' ? SATELLITE_MAP_STYLE_URL : DATAVIZ_MAP_STYLE_URL,
7416
+ sky: SKY_STYLE,
6965
7417
  tooltip: getTooltip,
6966
7418
  maps: resolvedLayout.map(function (_ref6, index) {
6967
7419
  var id = _ref6.id,
@@ -6976,36 +7428,20 @@ function GeoReDUSInner(_ref) {
6976
7428
  // canvasContextAttributes: {
6977
7429
  // preserveDrawingBuffer: true,
6978
7430
  // },
6979
- children: /*#__PURE__*/React.createElement(React.Fragment, null, index === resolvedLayout.length - 1 && /*#__PURE__*/React.createElement(MapStyleToggleCtrl, {
6980
- style: {
6981
- position: 'absolute',
6982
- zIndex: 1000,
6983
- top: 176,
6984
- right: 12
6985
- },
6986
- type: "button",
6987
- onClick: function onClick() {
6988
- return setBaseMapStyle(baseMapStyle === 'dataviz' ? 'satellite' : 'dataviz');
6989
- }
6990
- }, /*#__PURE__*/React.createElement(MapWindow, {
7431
+ children: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(AttributionControl, {
7432
+ position: "bottom-right",
7433
+ compact: false
7434
+ }), /*#__PURE__*/React.createElement(ControlContainer, {
6991
7435
  style: {
6992
- pointerEvents: 'none',
6993
- position: 'absolute',
6994
- top: 0,
6995
- left: 0,
6996
- height: '100%',
6997
- width: '100%'
7436
+ width: 'auto',
7437
+ height: 'auto',
7438
+ boxShadow: 'none',
7439
+ opacity: legends.length > 0 ? 1 : 0
6998
7440
  },
6999
- mapStyle: baseMapStyle === 'satellite' ? DATAVIZ_MAP_STYLE_URL : SATELLITE_MAP_STYLE_URL
7000
- })), legends.length > 0 && /*#__PURE__*/React.createElement(LegendContainer, {
7441
+ position: "bottom-right"
7442
+ }, legends.length > 0 && /*#__PURE__*/React.createElement(LegendContainer, {
7001
7443
  direction: "row",
7002
7444
  gap: "3",
7003
- style: {
7004
- position: 'absolute',
7005
- bottom: '20px',
7006
- right: '10px',
7007
- zIndex: 20
7008
- },
7009
7445
  p: resolvedLayout.length > 1 ? '3' : '4'
7010
7446
  }, resolvedLayout.length > 1 && /*#__PURE__*/React.createElement(Tooltip, {
7011
7447
  content: "Fechar visualiza\xE7\xE3o"
@@ -7036,16 +7472,45 @@ function GeoReDUSInner(_ref) {
7036
7472
  }, {
7037
7473
  key: legend.id
7038
7474
  }, legend));
7039
- }))), 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, {
7476
+ position: "top-right"
7477
+ }), /*#__PURE__*/React.createElement(FullscreenControl, {
7040
7478
  position: "top-right"
7041
7479
  }), /*#__PURE__*/React.createElement(NavigationControl, {
7042
7480
  position: "top-right"
7043
7481
  }), /*#__PURE__*/React.createElement(ScaleControl, {
7044
- position: "top-right"
7045
- }), /*#__PURE__*/React.createElement(AttributionControl, {
7046
- position: "bottom-right",
7047
- compact: false
7048
- })) : null)
7482
+ position: "bottom-right"
7483
+ }), /*#__PURE__*/React.createElement(ControlContainer, {
7484
+ style: {
7485
+ width: 100,
7486
+ height: 100,
7487
+ boxShadow: 'none'
7488
+ }
7489
+ }, /*#__PURE__*/React.createElement(MapStyleToggleCtrl, {
7490
+ style: {
7491
+ position: 'relative',
7492
+ width: 100,
7493
+ height: 100
7494
+ },
7495
+ type: "button",
7496
+ onClick: function onClick() {
7497
+ return setBaseMapStyle(baseMapStyle === 'dataviz' ? 'satellite' : 'dataviz');
7498
+ }
7499
+ }, /*#__PURE__*/React.createElement(MapWindow, {
7500
+ style: {
7501
+ pointerEvents: 'none',
7502
+ position: 'absolute',
7503
+ top: 0,
7504
+ left: 0,
7505
+ height: '100%',
7506
+ width: '100%'
7507
+ },
7508
+ mapStyle: baseMapStyle === 'satellite' ? DATAVIZ_MAP_STYLE_URL : SATELLITE_MAP_STYLE_URL,
7509
+ maxZoom: 13
7510
+ })))) : null, /*#__PURE__*/React.createElement(TerrainControl, {
7511
+ demSourceUrl: DEM_SOURCE_URL,
7512
+ demSourceEncoding: DEM_SOURCE_ENCODING
7513
+ }))
7049
7514
  };
7050
7515
  })
7051
7516
  }, isLoading && /*#__PURE__*/React.createElement(LoadingIndicator, {
@@ -7064,4 +7529,4 @@ function GeoReDUS(props) {
7064
7529
  }, /*#__PURE__*/React.createElement(DialogsProvider, null, /*#__PURE__*/React.createElement(GeoReDUSInner, props))));
7065
7530
  }
7066
7531
 
7067
- export { GeoReDUS, queryKeyHashFnWithFileSupport };
7532
+ export { GeoReDUS };