@redus/georedus-ui 0.2.0 → 0.3.1

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,23 @@
1
1
  # @orioro/template-react
2
2
 
3
+ ## 0.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @orioro/react-maplibre-util@0.3.1
9
+
10
+ ## 0.3.0
11
+
12
+ ### Minor Changes
13
+
14
+ - better support for 3d, refactor view resolution framework
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies
19
+ - @orioro/react-maplibre-util@0.3.0
20
+
3
21
  ## 0.2.0
4
22
 
5
23
  ### Minor Changes
@@ -1,3 +1,2 @@
1
- export function queryKeyHashFnWithFileSupport(queryKey: any): string;
2
1
  export function GeoReDUS(props: any): React.JSX.Element;
3
2
  import React from 'react';
@@ -1,9 +1,9 @@
1
1
  import { ItemList } from '@orioro/react-sortable';
2
- type ViewConf = {
2
+ export type ViewConf = {
3
3
  id: string;
4
4
  [key: string]: any;
5
5
  };
6
- type State = {
6
+ export type ViewConfState = {
7
7
  byId: Record<string, ViewConf>;
8
8
  layout: ItemList[];
9
9
  };
@@ -20,6 +20,6 @@ type Action = {
20
20
  type: 'SET_LAYOUT';
21
21
  payload: ItemList[];
22
22
  };
23
- export declare function viewConfReducer(state: State, action: Action): State;
24
- export declare function viewConfReducerInitialState(initialState: any): State;
23
+ export declare function viewConfReducer(state: ViewConfState, action: Action): ViewConfState;
24
+ export declare function viewConfReducerInitialState(initialState: any): ViewConfState;
25
25
  export {};
@@ -0,0 +1,7 @@
1
+ import { buffer as turfBuffer } from '@turf/turf';
2
+ type TurfBufferOptions = Parameters<typeof turfBuffer>[2];
3
+ type BufferOptions = TurfBufferOptions & {
4
+ dissolve?: boolean;
5
+ };
6
+ export declare function buffer(geoJson: GeoJSON.FeatureCollection, radius: number, { dissolve, ...turfBufferOptions }?: BufferOptions): GeoJSON.FeatureCollection;
7
+ export {};
@@ -1,6 +1,7 @@
1
1
  import * as Comlink from 'comlink';
2
2
  import { scaleNaturalBreaks } from '@orioro/scale-util';
3
- import { flatten, booleanIntersects, union, featureCollection } from '@turf/turf';
3
+ import { flatten, booleanIntersects, union, featureCollection, buffer as buffer$1 } from '@turf/turf';
4
+ import { __rest, __assign } from 'tslib';
4
5
 
5
6
  function dissolveAreasPreservingIsolated(geojson) {
6
7
  var features = flatten(geojson).features.filter(Boolean);
@@ -32,9 +33,49 @@ function dissolveAreasPreservingIsolated(geojson) {
32
33
  return featureCollection(features);
33
34
  }
34
35
 
35
- // A simple Comlink worker that doubles a number
36
+ function _applyBufferToGeometry(geometry, radius, options) {
37
+ var _a, _b;
38
+ switch (geometry === null || geometry === void 0 ? void 0 : geometry.type) {
39
+ case 'Point':
40
+ {
41
+ return ((_a = buffer$1(geometry, radius, options)) === null || _a === void 0 ? void 0 : _a.geometry) || null;
42
+ }
43
+ case 'LineString':
44
+ {
45
+ return ((_b = buffer$1(geometry, radius, options)) === null || _b === void 0 ? void 0 : _b.geometry) || null;
46
+ }
47
+ default:
48
+ {
49
+ return geometry;
50
+ }
51
+ }
52
+ }
53
+ function buffer(geoJson, radius, _a) {
54
+ if (_a === void 0) {
55
+ _a = {};
56
+ }
57
+ var _b = _a.dissolve,
58
+ dissolve = _b === void 0 ? false : _b,
59
+ turfBufferOptions = __rest(_a, ["dissolve"]);
60
+ var withBuffer = __assign(__assign({}, geoJson), {
61
+ features: geoJson.features.map(function (feature) {
62
+ try {
63
+ var geomWithBuffer = _applyBufferToGeometry(feature.geometry, radius, turfBufferOptions);
64
+ return __assign(__assign({}, feature), {
65
+ geometry: geomWithBuffer ? geomWithBuffer : feature.geometry
66
+ });
67
+ } catch (err) {
68
+ console.error('error applying buffer, will return unmodified feature', err, feature);
69
+ return feature;
70
+ }
71
+ })
72
+ });
73
+ return dissolve ? dissolveAreasPreservingIsolated(withBuffer) : withBuffer;
74
+ }
75
+
36
76
  var api = {
37
77
  scaleNaturalBreaks: scaleNaturalBreaks,
38
- dissolveAreasPreservingIsolated: dissolveAreasPreservingIsolated
78
+ dissolveAreasPreservingIsolated: dissolveAreasPreservingIsolated,
79
+ buffer: buffer
39
80
  };
40
81
  Comlink.expose(api);