@carto/kepler.gl 0.0.88 → 0.0.89

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.
Files changed (53) hide show
  1. package/dist/components/common/animation-control/playback-controls.js +11 -21
  2. package/dist/components/common/info-helper.js +3 -5
  3. package/dist/components/common/styled-components.d.ts +3 -2
  4. package/dist/components/common/styled-components.js +13 -14
  5. package/dist/components/editor/editor.js +2 -2
  6. package/dist/components/editor/feature-styles.js +2 -2
  7. package/dist/components/editor/handle-style.js +2 -2
  8. package/dist/components/map/layer-selector-panel.js +2 -3
  9. package/dist/components/map/map-control-tooltip.js +2 -3
  10. package/dist/components/side-panel/common/dataset-tag.js +4 -7
  11. package/dist/components/side-panel/common/dataset-title.js +5 -9
  12. package/dist/components/side-panel/layer-panel/color-range-selector.js +3 -7
  13. package/dist/components/side-panel/layer-panel/layer-config-group.js +2 -4
  14. package/dist/components/side-panel/layer-panel/panel-view-list-toggle.js +2 -4
  15. package/dist/components/side-panel/panel-header-action.d.ts +2 -2
  16. package/dist/components/side-panel/panel-header-action.js +3 -5
  17. package/dist/components/side-panel/panel-header.js +3 -5
  18. package/dist/components/side-panel/panel-tab.js +2 -4
  19. package/dist/constants/default-settings.js +3 -3
  20. package/dist/vendor/react-map-gl-draw/constants.js +55 -0
  21. package/dist/vendor/react-map-gl-draw/editor.js +1122 -0
  22. package/dist/vendor/react-map-gl-draw/feature.js +191 -0
  23. package/dist/vendor/react-map-gl-draw/index.js +33 -0
  24. package/dist/vendor/react-map-gl-draw/style.js +93 -0
  25. package/dist/vendor/react-map-gl-draw/utils.js +51 -0
  26. package/package.json +5 -4
  27. package/src/components/common/animation-control/playback-controls.tsx +11 -16
  28. package/src/components/common/info-helper.tsx +2 -3
  29. package/src/components/common/styled-components.tsx +17 -31
  30. package/src/components/editor/editor.tsx +1 -1
  31. package/src/components/editor/feature-styles.ts +1 -1
  32. package/src/components/editor/handle-style.ts +1 -1
  33. package/src/components/map/layer-selector-panel.tsx +1 -2
  34. package/src/components/map/map-control-tooltip.tsx +1 -1
  35. package/src/components/side-panel/common/dataset-tag.tsx +3 -5
  36. package/src/components/side-panel/common/dataset-title.tsx +4 -8
  37. package/src/components/side-panel/layer-panel/color-range-selector.tsx +4 -6
  38. package/src/components/side-panel/layer-panel/layer-config-group.tsx +2 -2
  39. package/src/components/side-panel/layer-panel/panel-view-list-toggle.tsx +2 -3
  40. package/src/components/side-panel/panel-header-action.tsx +4 -5
  41. package/src/components/side-panel/panel-header.tsx +2 -2
  42. package/src/components/side-panel/panel-tab.tsx +2 -2
  43. package/src/constants/default-settings.ts +1 -1
  44. package/src/vendor/react-map-gl-draw/LICENSE +9 -0
  45. package/src/vendor/react-map-gl-draw/constants.js +70 -0
  46. package/src/vendor/react-map-gl-draw/editor.js +1207 -0
  47. package/src/vendor/react-map-gl-draw/feature.js +171 -0
  48. package/src/vendor/react-map-gl-draw/index.js +7 -0
  49. package/src/vendor/react-map-gl-draw/style.js +153 -0
  50. package/src/vendor/react-map-gl-draw/utils.js +55 -0
  51. package/CHANGELOG.md +0 -1015
  52. package/src/.DS_Store +0 -0
  53. package/src/reducers/trips-to-geojson.mjs +0 -8
@@ -0,0 +1,171 @@
1
+ // Vendored from react-map-gl-draw@0.14.8 (MIT, Copyright (c) 2018 Uber Technologies, Inc.), see ./LICENSE
2
+ import {GEOJSON_TYPE} from './constants';
3
+
4
+ export default class Feature {
5
+ static fromFeature(feature) {
6
+ const {
7
+ id,
8
+ geometry: {coordinates, type},
9
+ properties: {renderType, ...otherProps}
10
+ } = feature;
11
+
12
+ switch (type) {
13
+ case GEOJSON_TYPE.POINT:
14
+ return new Feature({
15
+ id,
16
+ type,
17
+ renderType,
18
+ points: [coordinates],
19
+ otherProps
20
+ });
21
+
22
+ case GEOJSON_TYPE.LINE_STRING:
23
+ return new Feature({
24
+ id,
25
+ type,
26
+ renderType,
27
+ points: coordinates,
28
+ otherProps
29
+ });
30
+
31
+ case GEOJSON_TYPE.POLYGON:
32
+ const points = coordinates[0] && coordinates[0].slice(0, -1);
33
+ return new Feature({
34
+ id,
35
+ type,
36
+ renderType,
37
+ points,
38
+ isClosed: true,
39
+ otherProps
40
+ });
41
+
42
+ default:
43
+ return null;
44
+ }
45
+ }
46
+
47
+ constructor(props) {
48
+ this.id = props.id;
49
+ this.type = props.type;
50
+ this.renderType = props.renderType;
51
+ this.points = props.points || [];
52
+ this.isClosed = props.isClosed;
53
+ this.otherProps = props.otherProps;
54
+ }
55
+
56
+ id;
57
+ type;
58
+ renderType;
59
+ isClosed = false;
60
+ points;
61
+ otherProps;
62
+
63
+ addPoint(pt) {
64
+ this.points.push(pt);
65
+ return true;
66
+ }
67
+
68
+ insertPoint(pt, index) {
69
+ this.points.splice(index, 0, pt);
70
+ }
71
+
72
+ getBoundingBox() {
73
+ if (!this.points || !this.points.length) {
74
+ return null;
75
+ }
76
+ const bbox = this.points.reduce(
77
+ (result, pt) => {
78
+ result.xmin = Math.min(pt[0], result.xmin);
79
+ result.xmax = Math.min(pt[0], result.xmax);
80
+ result.ymin = Math.min(pt[1], result.ymin);
81
+ result.ymax = Math.min(pt[1], result.ymax);
82
+
83
+ return result;
84
+ },
85
+ {xmin: Infinity, xmax: -Infinity, ymin: Infinity, ymax: -Infinity}
86
+ );
87
+
88
+ return bbox;
89
+ }
90
+
91
+ removePoint(index) {
92
+ const {points} = this;
93
+ if (index >= 0 && index < points.length) {
94
+ points.splice(index, 1);
95
+ if (points.length < 3) {
96
+ this.isClosed = false;
97
+ }
98
+ return true;
99
+ }
100
+ return false;
101
+ }
102
+
103
+ replacePoint(index, pt) {
104
+ const {points} = this;
105
+ if (index >= 0 && index < points.length) {
106
+ points[index] = pt;
107
+ return true;
108
+ }
109
+ return false;
110
+ }
111
+
112
+ closePath() {
113
+ const {points} = this;
114
+ if (points.length >= 3 && !this.isClosed) {
115
+ this.isClosed = true;
116
+ return true;
117
+ }
118
+ return false;
119
+ }
120
+
121
+ toFeature() {
122
+ const {id, points, isClosed, renderType, otherProps} = this;
123
+
124
+ let feature = null;
125
+ if (points.length < 2) {
126
+ feature = {
127
+ type: 'Feature',
128
+ geometry: {
129
+ type: GEOJSON_TYPE.POINT,
130
+ coordinates: points[0]
131
+ },
132
+ properties: {
133
+ renderType,
134
+ ...otherProps
135
+ },
136
+ id
137
+ };
138
+ } else if (points.length < 3 || !isClosed) {
139
+ feature = {
140
+ type: 'Feature',
141
+ geometry: {
142
+ type: GEOJSON_TYPE.LINE_STRING,
143
+ coordinates: points
144
+ },
145
+ properties: {
146
+ renderType,
147
+ bbox: this.getBoundingBox(),
148
+ ...otherProps
149
+ },
150
+ id
151
+ };
152
+ } else {
153
+ feature = {
154
+ type: 'Feature',
155
+ geometry: {
156
+ type: GEOJSON_TYPE.POLYGON,
157
+ coordinates: [[...points, points[0]]]
158
+ },
159
+ properties: {
160
+ renderType,
161
+ isClosed,
162
+ bbox: this.getBoundingBox(),
163
+ ...otherProps
164
+ },
165
+ id
166
+ };
167
+ }
168
+
169
+ return feature;
170
+ }
171
+ }
@@ -0,0 +1,7 @@
1
+ // Vendored from react-map-gl-draw@0.14.8 (MIT, Copyright (c) 2018 Uber Technologies, Inc.), see ./LICENSE
2
+ export {default as Editor} from './editor';
3
+ export {
4
+ MODES as EditorModes,
5
+ RENDER_TYPE as RenderTypes,
6
+ RENDER_STATE as RenderStates
7
+ } from './constants';
@@ -0,0 +1,153 @@
1
+ // Vendored from react-map-gl-draw@0.14.8 (MIT, Copyright (c) 2018 Uber Technologies, Inc.), see ./LICENSE
2
+ /* eslint-disable complexity, max-statements */
3
+ import {RENDER_STATE, RENDER_TYPE} from './constants';
4
+
5
+ const RECT_STYLE = {
6
+ x: -6,
7
+ y: -6,
8
+ height: 12,
9
+ width: 12
10
+ };
11
+
12
+ const CLOSING_RECT_STYLE = {
13
+ x: -10,
14
+ y: -10,
15
+ height: 20,
16
+ width: 20
17
+ };
18
+
19
+ const DEFAULT_STROKE_WIDTH = 2;
20
+ const HIGHLIGHTED_STROKE_WIDTH = 4;
21
+ const DEFAULT_RADIUS = 8;
22
+
23
+ export const HIDDEN_CLICKABLE_STYLE = {
24
+ fill: '#000',
25
+ opacity: 0
26
+ };
27
+
28
+ export function getFeatureStyle({feature, state}) {
29
+ const style = {
30
+ stroke:
31
+ state === RENDER_STATE.SELECTED || state === RENDER_STATE.HOVERED
32
+ ? '#7ac943'
33
+ : state === RENDER_STATE.UNCOMMITTED || state === RENDER_STATE.CLOSING
34
+ ? '#a9a9a9'
35
+ : '#000',
36
+ strokeWidth: DEFAULT_STROKE_WIDTH,
37
+ fill:
38
+ state === RENDER_STATE.INACTIVE
39
+ ? '#333333'
40
+ : state === RENDER_STATE.HOVERED
41
+ ? '#7ac943'
42
+ : state === RENDER_STATE.SELECTED
43
+ ? '#ffff00'
44
+ : state === RENDER_STATE.UNCOMMITTED || state === RENDER_STATE.CLOSING
45
+ ? '#a9a9a9'
46
+ : '#000000',
47
+ fillOpacity:
48
+ state === RENDER_STATE.INACTIVE
49
+ ? 0.1
50
+ : state === RENDER_STATE.SELECTED
51
+ ? 0.7
52
+ : state === RENDER_STATE.HOVERED
53
+ ? 0.5
54
+ : state === RENDER_STATE.UNCOMMITTED || state === RENDER_STATE.CLOSING
55
+ ? 0.3
56
+ : 1
57
+ };
58
+
59
+ const renderType = feature.properties ? feature.properties.renderType : feature.renderType;
60
+
61
+ switch (renderType) {
62
+ case RENDER_TYPE.POINT:
63
+ style.r = DEFAULT_RADIUS;
64
+ break;
65
+ case RENDER_TYPE.LINE_STRING:
66
+ style.fill = 'none';
67
+ break;
68
+ case RENDER_TYPE.POLYGON:
69
+ if (state === RENDER_STATE.CLOSING) {
70
+ style.strokeDasharray = '4,2';
71
+ }
72
+ break;
73
+ case RENDER_TYPE.RECTANGLE:
74
+ if (state === RENDER_STATE.UNCOMMITTED) {
75
+ style.strokeDasharray = '4,2';
76
+ }
77
+ break;
78
+ default:
79
+ }
80
+
81
+ return style;
82
+ }
83
+
84
+ export function getEditHandleStyle({feature, index, state}) {
85
+ const style = {
86
+ fill:
87
+ state === RENDER_STATE.INACTIVE
88
+ ? '#ffffff'
89
+ : state === RENDER_STATE.SELECTED || state === RENDER_STATE.CLOSING
90
+ ? '#ffff00'
91
+ : state === RENDER_STATE.HOVERED
92
+ ? '#7ac943'
93
+ : state === RENDER_STATE.UNCOMMITTED
94
+ ? '#a9a9a9'
95
+ : '#000000',
96
+ fillOpacity:
97
+ state === RENDER_STATE.INACTIVE
98
+ ? 1
99
+ : state === RENDER_STATE.HOVERED
100
+ ? 1
101
+ : state === RENDER_STATE.SELECTED || state === RENDER_STATE.CLOSING
102
+ ? 0.8
103
+ : state === RENDER_STATE.UNCOMMITTED
104
+ ? 0.3
105
+ : 1,
106
+ stroke:
107
+ state === RENDER_STATE.SELECTED ||
108
+ state === RENDER_STATE.HOVERED ||
109
+ state === RENDER_STATE.CLOSING
110
+ ? '#7ac943'
111
+ : '#000',
112
+ strokeWidth:
113
+ state === RENDER_STATE.SELECTED || state === RENDER_STATE.CLOSING
114
+ ? HIGHLIGHTED_STROKE_WIDTH
115
+ : DEFAULT_STROKE_WIDTH,
116
+ r: DEFAULT_RADIUS
117
+ };
118
+
119
+ const renderType = feature.properties ? feature.properties.renderType : feature.renderType;
120
+
121
+ switch (renderType) {
122
+ case RENDER_TYPE.POINT:
123
+ style.fill =
124
+ state === RENDER_STATE.INACTIVE
125
+ ? '#333333'
126
+ : state === RENDER_STATE.SELECTED
127
+ ? '#ffff00'
128
+ : state === RENDER_STATE.HOVERED
129
+ ? '#7ac943'
130
+ : state === RENDER_STATE.UNCOMMITTED
131
+ ? 'none'
132
+ : '#000000';
133
+ style.stroke =
134
+ state === RENDER_STATE.SELECTED
135
+ ? '#7ac943'
136
+ : state === RENDER_STATE.UNCOMMITTED
137
+ ? 'none'
138
+ : '#000';
139
+ break;
140
+ case RENDER_TYPE.LINE_STRING:
141
+ case RENDER_TYPE.POLYGON:
142
+ case RENDER_TYPE.RECTANGLE:
143
+ if (state === RENDER_STATE.CLOSING) {
144
+ Object.assign(style, CLOSING_RECT_STYLE);
145
+ } else {
146
+ Object.assign(style, RECT_STYLE);
147
+ }
148
+ break;
149
+ default:
150
+ }
151
+
152
+ return style;
153
+ }
@@ -0,0 +1,55 @@
1
+ // Vendored from react-map-gl-draw@0.14.8 (MIT, Copyright (c) 2018 Uber Technologies, Inc.), see ./LICENSE
2
+
3
+ function inBounds(p1, p2, p) {
4
+ const bounds = [
5
+ Math.min(p1[0], p2[0]),
6
+ Math.max(p1[0], p2[0]),
7
+ Math.min(p1[1], p2[1]),
8
+ Math.max(p1[1], p2[1])
9
+ ];
10
+
11
+ return p[0] >= bounds[0] && p[0] <= bounds[1] && p[1] >= bounds[2] && p[1] <= bounds[3];
12
+ }
13
+
14
+ export function findClosestPointOnLineSegment(p1, p2, p) {
15
+ // line
16
+ const k = (p2[1] - p1[1]) / (p2[0] - p1[0]);
17
+ const b = p1[1] - k * p1[0];
18
+
19
+ // vertical line
20
+ if (!isFinite(k)) {
21
+ const q = [p1[0], p[1]];
22
+ return inBounds(p1, p2, q) ? q : null;
23
+ }
24
+
25
+ // p is on line [p1, p2]
26
+ if (p[0] * k + b - p[1] === 0) {
27
+ return inBounds(p1, p2, p) ? p : null;
28
+ }
29
+
30
+ const qx = (k * p[1] + p[0] - k * b) / (k * k + 1);
31
+ const qy = k * qx + b;
32
+
33
+ return inBounds(p1, p2, [qx, qy]) ? [qx, qy] : null;
34
+ }
35
+
36
+ export function isNumeric(n) {
37
+ return !Array.isArray(n) && !isNaN(parseFloat(n)) && isFinite(n);
38
+ }
39
+
40
+ export function parseElemDataAttributes(elem) {
41
+ const data = elem && elem.dataset;
42
+ if (!data) {
43
+ return null;
44
+ }
45
+
46
+ const featureIndex = data.featureIndex;
47
+ const vertexIndex = data.vertexIndex;
48
+
49
+ return {
50
+ type: data.type,
51
+ operation: data.operation,
52
+ featureIndex: isNumeric(featureIndex) ? Number(featureIndex) : undefined,
53
+ vertexIndex: isNumeric(vertexIndex) ? Number(vertexIndex) : undefined
54
+ };
55
+ }