@redus/georedus-ui 0.8.1 → 0.8.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @orioro/template-react
2
2
 
3
+ ## 0.8.2
4
+
5
+ ### Patch Changes
6
+
7
+ - apply bounds to censo 2010 and 2022 sources
8
+
3
9
  ## 0.8.1
4
10
 
5
11
  ### Patch Changes
package/dist/main.js CHANGED
@@ -5243,9 +5243,11 @@ var DEFAULT_BUFFER_SIZE = 200;
5243
5243
  var INSUFFICIENT_DATA_COLOR = 'red';
5244
5244
  var BUILDINGS_MIN_ZOOM = 14;
5245
5245
  var BUILDINGS_3D_MIN_ZOOM = 16;
5246
+ var UNBOUNDED_BOUNDS = [-180, -90, 180, 90];
5246
5247
 
5247
5248
  //
5248
- //
5249
+ // TODO: deprecate in favor of applying buffers
5250
+ // inside worker
5249
5251
  //
5250
5252
  function _applyBuffers(geometry) {
5251
5253
  var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
@@ -5387,6 +5389,26 @@ function cem_censo_2010_2022(viewSpec, allViewSpecs, context) {
5387
5389
  }]));
5388
5390
  return url;
5389
5391
  });
5392
+ var _resolveSourceBounds = resolve.fn(function (context) {
5393
+ try {
5394
+ var _context$view$metadat;
5395
+ var coordinates = (_context$view$metadat = context.view.metadata.municipioData) === null || _context$view$metadat === void 0 || (_context$view$metadat = _context$view$metadat.bbox) === null || _context$view$metadat === void 0 ? void 0 : _context$view$metadat.coordinates;
5396
+ if (!coordinates) {
5397
+ return UNBOUNDED_BOUNDS;
5398
+ }
5399
+ var _coordinates$0$ = _slicedToArray(coordinates[0][0], 2),
5400
+ west = _coordinates$0$[0],
5401
+ south = _coordinates$0$[1]; // first point: lower-left (southwest)
5402
+ var _coordinates$0$2 = _slicedToArray(coordinates[0][2], 2),
5403
+ east = _coordinates$0$2[0],
5404
+ north = _coordinates$0$2[1]; // third point: upper-right (northeast)
5405
+
5406
+ return [west, south, east, north]; // [minX, minY, maxX, maxY]
5407
+ } catch (err) {
5408
+ console.warn("error while retrieving bounds", err);
5409
+ return UNBOUNDED_BOUNDS;
5410
+ }
5411
+ });
5390
5412
  return {
5391
5413
  // debug: true,
5392
5414
  id: viewId,
@@ -5585,18 +5607,29 @@ function cem_censo_2010_2022(viewSpec, allViewSpecs, context) {
5585
5607
  agg_column: ['$get', 'view.conf.data.variableId'],
5586
5608
  agg_type: ['$if', ['$endsWith', ['$get', 'view.conf.data.variableId'], '_pct'], 'weighted_avg', 'sum']
5587
5609
  }
5588
- }]]
5610
+ }]],
5611
+ municipioData: ['$get', '0', ['$fetch', resolve.fn(function (context) {
5612
+ return "".concat(METADATA_API_ENDPOINT, "/ibge_malha_br_municipio?select=bbox&id=eq.").concat(context.app.municipioId);
5613
+ })]]
5589
5614
  }, {
5590
5615
  labels: labels,
5591
5616
  measureUnits: measureUnits,
5592
5617
  variableValues: ['$get', 'variableValues'],
5618
+ municipioData: ['$get', 'municipioData'],
5593
5619
  customGeoJSON: ['$get', 'customGeoJSON'],
5594
5620
  colorScaleStops: ['$naturalBreaks', ['$get', 'variableValues'], _objectSpread2(_objectSpread2({}, _color_scheme), {}, {
5595
5621
  minK: 5
5596
5622
  })]
5597
5623
  }]]
5598
5624
  },
5599
- sources: _objectSpread2(_objectSpread2({}, globalRes.sources), {}, _defineProperty(_defineProperty({
5625
+ sources: _objectSpread2(_objectSpread2({}, Object.fromEntries(Object.entries(globalRes.sources).map(function (_ref3) {
5626
+ var _ref4 = _slicedToArray(_ref3, 2),
5627
+ key = _ref4[0],
5628
+ spec = _ref4[1];
5629
+ return [key, _objectSpread2(_objectSpread2({}, spec), {}, {
5630
+ bounds: _resolveSourceBounds
5631
+ })];
5632
+ }))), {}, _defineProperty(_defineProperty({
5600
5633
  //
5601
5634
  // Points in custom GeoJson
5602
5635
  //
@@ -5627,9 +5660,9 @@ function cem_censo_2010_2022(viewSpec, allViewSpecs, context) {
5627
5660
  // The area of customGeoJson
5628
5661
  //
5629
5662
  customGeoJSON_Areas: ['$if', [['$empty', ['$get', 'view.metadata.customGeoJSON.AREAS']]], null, resolve.fn(function (context) {
5630
- var _context$view$metadat = context.view.metadata,
5631
- customGeoJSON = _context$view$metadat.customGeoJSON,
5632
- variableValues = _context$view$metadat.variableValues;
5663
+ var _context$view$metadat2 = context.view.metadata,
5664
+ customGeoJSON = _context$view$metadat2.customGeoJSON,
5665
+ variableValues = _context$view$metadat2.variableValues;
5633
5666
  if (!(customGeoJSON !== null && customGeoJSON !== void 0 && customGeoJSON.AREAS)) {
5634
5667
  return null;
5635
5668
  }
@@ -5658,6 +5691,7 @@ function cem_censo_2010_2022(viewSpec, allViewSpecs, context) {
5658
5691
  //
5659
5692
  maxzoom: BUILDINGS_MIN_ZOOM,
5660
5693
  promoteId: 'cd_setor',
5694
+ bounds: _resolveSourceBounds,
5661
5695
  tiles: [resolve.fn(function (context) {
5662
5696
  var _variableId = get$1(context, 'view.conf.data.variableId');
5663
5697
  var _variant = variantsByVariableId[_variableId];
@@ -5677,6 +5711,7 @@ function cem_censo_2010_2022(viewSpec, allViewSpecs, context) {
5677
5711
  attribution: sourceLabel,
5678
5712
  minzoom: BUILDINGS_MIN_ZOOM,
5679
5713
  maxzoom: BUILDINGS_MIN_ZOOM,
5714
+ bounds: _resolveSourceBounds,
5680
5715
  // Zoom levels make no real difference, buildings
5681
5716
  // are pretty square
5682
5717
  // maxzoom: 20,
@@ -5860,12 +5895,12 @@ function cem_censo_2010_2022(viewSpec, allViewSpecs, context) {
5860
5895
  // availableVariableIds: [variable_id, 'str_nome_fantasia', 'id_cnes'],
5861
5896
  fetchData: resolve.fn(function (context) {
5862
5897
  return /*#__PURE__*/function () {
5863
- var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref3) {
5898
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref5) {
5864
5899
  var data, geometries;
5865
5900
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
5866
5901
  while (1) switch (_context2.prev = _context2.next) {
5867
5902
  case 0:
5868
- _ref3.variableIds, _ref3.options;
5903
+ _ref5.variableIds, _ref5.options;
5869
5904
  _context2.next = 3;
5870
5905
  return resolveExprAsync(['$fetch', ['$template', "".concat(METADATA_API_ENDPOINT) + '/${source_table_id}?select=' + '${variableId},' + 'cd_setor' + '&cd_mun=eq.' + '${municipioId}', {
5871
5906
  variableId: ['$get', 'view.conf.data.variableId'],
@@ -5891,7 +5926,7 @@ function cem_censo_2010_2022(viewSpec, allViewSpecs, context) {
5891
5926
  }, _callee2);
5892
5927
  }));
5893
5928
  return function (_x2) {
5894
- return _ref4.apply(this, arguments);
5929
+ return _ref6.apply(this, arguments);
5895
5930
  };
5896
5931
  }();
5897
5932
  })
@@ -135,6 +135,15 @@ export function cem_censo_2010_2022(viewSpec: any, allViewSpecs: any, context: a
135
135
  href?: undefined;
136
136
  pathname?: undefined;
137
137
  })[])[];
138
+ municipioData: (string | (string | {
139
+ [x: string]: any;
140
+ $$resolver: symbol;
141
+ $$unresolved?: Record<string | number, import("@orioro/resolve").ResolutionNode> | undefined;
142
+ dependencies: any;
143
+ value: (...args: any[]) => any;
144
+ defaultValue?: any;
145
+ context?: any;
146
+ })[])[];
138
147
  labels?: undefined;
139
148
  measureUnits?: undefined;
140
149
  customGeoJSON?: undefined;
@@ -143,11 +152,95 @@ export function cem_censo_2010_2022(viewSpec: any, allViewSpecs: any, context: a
143
152
  labels: any;
144
153
  measureUnits: any;
145
154
  variableValues: string[];
155
+ municipioData: string[];
146
156
  customGeoJSON: string[];
147
157
  colorScaleStops: any[];
148
158
  })[])[];
149
159
  };
150
160
  sources: {
161
+ [x: string]: {
162
+ bounds: {
163
+ [x: string]: any;
164
+ $$resolver: symbol;
165
+ $$unresolved?: Record<string | number, import("@orioro/resolve").ResolutionNode> | undefined;
166
+ dependencies: any;
167
+ value: (...args: any[]) => any;
168
+ defaultValue?: any;
169
+ context?: any;
170
+ };
171
+ type: string;
172
+ tiles: string[];
173
+ minzoom: number;
174
+ maxzoom: number;
175
+ } | {
176
+ bounds: {
177
+ [x: string]: any;
178
+ $$resolver: symbol;
179
+ $$unresolved?: Record<string | number, import("@orioro/resolve").ResolutionNode> | undefined;
180
+ dependencies: any;
181
+ value: (...args: any[]) => any;
182
+ defaultValue?: any;
183
+ context?: any;
184
+ };
185
+ type: string;
186
+ tiles: string[];
187
+ } | (string | {
188
+ [x: string]: any;
189
+ $$resolver: symbol;
190
+ $$unresolved?: Record<string | number, import("@orioro/resolve").ResolutionNode> | undefined;
191
+ dependencies: any;
192
+ value: (...args: any[]) => any;
193
+ defaultValue?: any;
194
+ context?: any;
195
+ } | (string | string[])[][] | null)[] | {
196
+ type: string;
197
+ attribution: string;
198
+ minzoom: number;
199
+ maxzoom: number;
200
+ promoteId: string;
201
+ bounds: {
202
+ [x: string]: any;
203
+ $$resolver: symbol;
204
+ $$unresolved?: Record<string | number, import("@orioro/resolve").ResolutionNode> | undefined;
205
+ dependencies: any;
206
+ value: (...args: any[]) => any;
207
+ defaultValue?: any;
208
+ context?: any;
209
+ };
210
+ tiles: {
211
+ [x: string]: any;
212
+ $$resolver: symbol;
213
+ $$unresolved?: Record<string | number, import("@orioro/resolve").ResolutionNode> | undefined;
214
+ dependencies: any;
215
+ value: (...args: any[]) => any;
216
+ defaultValue?: any;
217
+ context?: any;
218
+ }[];
219
+ } | {
220
+ type: string;
221
+ attribution: string;
222
+ minzoom: number;
223
+ maxzoom: number;
224
+ bounds: {
225
+ [x: string]: any;
226
+ $$resolver: symbol;
227
+ $$unresolved?: Record<string | number, import("@orioro/resolve").ResolutionNode> | undefined;
228
+ dependencies: any;
229
+ value: (...args: any[]) => any;
230
+ defaultValue?: any;
231
+ context?: any;
232
+ };
233
+ tiles: {
234
+ [x: string]: any;
235
+ $$resolver: symbol;
236
+ $$unresolved?: Record<string | number, import("@orioro/resolve").ResolutionNode> | undefined;
237
+ dependencies: any;
238
+ value: (...args: any[]) => any;
239
+ defaultValue?: any;
240
+ context?: any;
241
+ }[];
242
+ promoteId?: undefined;
243
+ };
151
244
  customGeoJSON_Points: (string | {
152
245
  [x: string]: any;
153
246
  $$resolver: symbol;
@@ -175,16 +268,6 @@ export function cem_censo_2010_2022(viewSpec: any, allViewSpecs: any, context: a
175
268
  defaultValue?: any;
176
269
  context?: any;
177
270
  } | (string | string[])[][] | null)[];
178
- planet: {
179
- type: string;
180
- tiles: string[];
181
- };
182
- global_municipio: {
183
- type: string;
184
- tiles: string[];
185
- minzoom: number;
186
- maxzoom: number;
187
- };
188
271
  };
189
272
  layers: {
190
273
  customGeoJSON_Areas_fill: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redus/georedus-ui",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "packageManager": "yarn@4.0.2",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",