diff --git a/src/table/src/filter-utils.ts b/src/table/src/filter-utils.ts index 70ab2b75fd..ef01b915a5 100644 --- a/src/table/src/filter-utils.ts +++ b/src/table/src/filter-utils.ts @@ -603,9 +603,14 @@ export function diffFilters( * * @returns value - adjusted value to match filter or null to remove filter */ -/* eslint-disable complexity */ +// eslint-disable-next-line complexity export function adjustValueToFilterDomain(value: Filter['value'], {domain, type}) { - if (!domain || !type) { + if (!type) { + return false; + } + // if the current filter is a polygon it will not have any domain + // all other filter types require domain + if (type !== FILTER_TYPES.polygon && !domain) { return false; } @@ -627,6 +632,8 @@ export function adjustValueToFilterDomain(value: Filter['value'], {domain, type} case FILTER_TYPES.select: return domain.includes(value) ? value : true; + case FILTER_TYPES.polygon: + return value; default: return null; @@ -810,7 +817,7 @@ export function isFilterValidToSave(filter: any): boolean { return ( filter?.type && Array.isArray(filter?.name) && - filter?.name.length && + (filter?.name.length || filter?.layerId.length) && isValidFilterValue(filter?.type, filter?.value) ); } diff --git a/test/fixtures/points-with-polygon-filter-map.js b/test/fixtures/points-with-polygon-filter-map.js new file mode 100644 index 0000000000..0929bd38fe --- /dev/null +++ b/test/fixtures/points-with-polygon-filter-map.js @@ -0,0 +1,2542 @@ +// Copyright (c) 2022 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import {processKeplerglJSON} from 'processors'; +import CloneDeep from 'lodash.clonedeep'; +import {keplerGlReducerCore as coreReducer} from '@kepler.gl/reducers'; +import {addDataToMap} from '@kepler.gl/actions'; +import {InitialState} from '../helpers/mock-state'; + +export const polygonFilterMap = { + datasets: [ + { + version: 'v1', + data: { + id: '20pde67d8r', + label: 'really-few-points.csv', + color: [0, 92, 255], + allData: [ + [ + '2009/11/25 09:11:21.39', + 35.75367, + -117.7255, + 8.394, + 2.67, + 'Md', + 9, + 128, + 7, + 0.04, + 'NCSN', + 71318991 + ], + [ + '2009/11/26 14:59:48.35', + 36.32267, + -117.894, + 8.719, + 2.63, + 'Md', + 4, + 267, + 42, + 0.01, + 'NCSN', + 71319526 + ], + [ + '2009/11/27 19:57:47.45', + 36.395, + -117.8295, + -1.482, + 3.48, + 'ML', + 131, + 143, + 51, + 0.57, + 'NCSN', + 71320021 + ], + [ + '2009/12/01 14:58:28.91', + 35.74683, + -118.002, + 8.108, + 2.64, + 'Md', + 8, + 112, + 14, + 0.05, + 'NCSN', + 71321416 + ], + [ + '2009/12/02 00:59:55.43', + 35.9555, + -117.33317, + 5.564, + 2.86, + 'Md', + 10, + 221, + 28, + 0.07, + 'NCSN', + 71321716 + ], + [ + '2009/12/04 22:54:10.77', + 36.38533, + -117.87334, + 10.498, + 2.56, + 'Md', + 8, + 175, + 47, + 0.06, + 'NCSN', + 71318015 + ], + [ + '2009/12/13 02:34:34.38', + 36.00433, + -117.88483, + 5.708, + 2.59, + 'Md', + 10, + 158, + 18, + 0.03, + 'NCSN', + 71321500 + ], + [ + '2009/12/15 09:52:19.86', + 36.40933, + -117.83667, + 4.858, + 2.95, + 'Md', + 19, + 180, + 51, + 0.06, + 'NCSN', + 71322420 + ], + [ + '2009/12/17 10:48:31.79', + 36.383, + -117.87583, + -1.362, + 2.58, + 'Md', + 33, + 168, + 47, + 0.27, + 'NCSN', + 71323125 + ], + [ + '2009/12/21 13:25:42.26', + 35.98583, + -117.88617, + 13.148, + 2.53, + 'Md', + 6, + 164, + 16, + 0.09, + 'NCSN', + 71324715 + ], + [ + '2009/12/24 20:22:34.04', + 35.8975, + -118.31483, + 17.292, + 2.5, + 'Md', + 10, + 101, + 22, + 0.04, + 'NCSN', + 71325835 + ], + [ + '2009/12/29 09:38:42.06', + 36.14167, + -118.05317, + 4.868, + 2.56, + 'Md', + 16, + 128, + 23, + 0.03, + 'NCSN', + 71327655 + ], + [ + '2009/12/30 11:44:37.22', + 35.98417, + -117.36166, + 6.614, + 3.57, + 'Mw', + 11, + 242, + 26, + 0.05, + 'NCSN', + 71328065 + ], + [ + '2009/12/31 19:57:42.94', + 36.01133, + -117.7815, + 3.441, + 2.95, + 'Md', + 10, + 150, + 30, + 0.03, + 'NCSN', + 71328545 + ], + [ + '2010/01/01 02:55:04.29', + 35.966, + -117.2965, + 0.454, + 2.77, + 'Md', + 18, + 176, + 32, + 0.16, + 'NCSN', + 71328730 + ], + [ + '2010/01/01 03:25:29.90', + 36.03683, + -117.777, + 5.818, + 2.93, + 'Md', + 14, + 186, + 15, + 0.04, + 'NCSN', + 71328750 + ], + [ + '2010/01/04 20:07:59.49', + 35.709, + -117.48133, + 11.454, + 3.25, + 'ML', + 11, + 155, + 12, + 0.09, + 'NCSN', + 71335381 + ], + [ + '2010/01/04 20:11:25.36', + 35.7165, + -117.4725, + 9.824, + 3.02, + 'Md', + 10, + 158, + 13, + 0.05, + 'NCSN', + 71335386 + ], + [ + '2010/01/10 02:55:05.94', + 36.40067, + -117.87167, + -1.011, + 3.18, + 'ML', + 41, + 158, + 48, + 0.17, + 'NCSN', + 71338191 + ], + [ + '2010/01/10 17:45:48.58', + 36.0145, + -117.86967, + 7.528, + 2.53, + 'Md', + 8, + 177, + 19, + 0.05, + 'NCSN', + 71338616 + ], + [ + '2010/01/13 02:43:38.52', + 36.40617, + -117.86684, + 8.249, + 2.61, + 'Md', + 16, + 176, + 19, + 0.06, + 'NCSN', + 71339666 + ], + [ + '2010/01/14 11:08:47.75', + 36.03383, + -117.84184, + -1.522, + 2.62, + 'Md', + 12, + 134, + 20, + 0.26, + 'NCSN', + 71340181 + ], + [ + '2010/01/14 12:10:05.13', + 36.037, + -117.82983, + 5.358, + 3.6, + 'ML', + 13, + 137, + 19, + 0.04, + 'NCSN', + 71340211 + ], + [ + '2010/01/14 12:57:12.40', + 36.03817, + -117.82533, + 6.318, + 3.19, + 'ML', + 13, + 138, + 19, + 0.06, + 'NCSN', + 71340241 + ], + [ + '2010/01/14 13:37:00.76', + 36.036, + -117.82867, + 5.738, + 3.42, + 'ML', + 13, + 175, + 19, + 0.04, + 'NCSN', + 71340261 + ], + [ + '2010/01/15 08:23:27.15', + 36.03067, + -117.83483, + 5.428, + 4.24, + 'Mw', + 16, + 173, + 19, + 0.04, + 'NCSN', + 71340636 + ], + [ + '2010/01/15 08:43:41.25', + 36.0255, + -117.83767, + 5.508, + 2.88, + 'Md', + 12, + 132, + 19, + 0.04, + 'NCSN', + 71340651 + ], + [ + '2010/01/15 08:44:38.51', + 36.02817, + -117.83366, + 5.008, + 2.78, + 'Md', + 9, + 189, + 19, + 0.04, + 'NCSN', + 71034094 + ], + [ + '2010/01/15 09:25:13.79', + 36.032, + -117.8375, + 6.948, + 2.9, + 'Md', + 14, + 135, + 19, + 0.04, + 'NCSN', + 71340686 + ], + [ + '2010/01/15 09:28:18.84', + 36.02883, + -117.83067, + 5.348, + 3.59, + 'Mw', + 14, + 135, + 19, + 0.07, + 'NCSN', + 71340701 + ], + [ + '2010/01/15 10:29:58.43', + 36.02934, + -117.8315, + 5.298, + 3.58, + 'Mw', + 12, + 173, + 19, + 0.06, + 'NCSN', + 71340731 + ], + [ + '2010/01/15 13:39:31.26', + 36.03183, + -117.8395, + 5.368, + 3.36, + 'ML', + 9, + 172, + 20, + 0.05, + 'NCSN', + 71340796 + ], + [ + '2010/01/15 14:20:49.31', + 36.03233, + -117.83884, + 6.258, + 2.93, + 'Md', + 11, + 173, + 20, + 0.05, + 'NCSN', + 71340826 + ], + [ + '2010/01/16 06:36:18.42', + 36.0345, + -117.83767, + 6.918, + 3.4, + 'Mw', + 17, + 143, + 20, + 0.07, + 'NCSN', + 71341241 + ], + [ + '2010/01/17 18:48:30.52', + 36.02967, + -117.84483, + 14.158, + 2.53, + 'Md', + 11, + 140, + 20, + 0.21, + 'NCSN', + 71341861 + ], + [ + '2010/01/18 04:50:45.53', + 36.03067, + -117.84, + 5.608, + 2.97, + 'Md', + 15, + 133, + 20, + 0.06, + 'NCSN', + 71341971 + ], + [ + '2010/01/18 06:34:55.59', + 36.03233, + -117.83617, + 6.418, + 2.95, + 'Md', + 15, + 143, + 19, + 0.06, + 'NCSN', + 71342001 + ], + [ + '2010/01/30 11:25:59.52', + 36.08917, + -117.89417, + 5.998, + 2.9, + 'Md', + 24, + 137, + 27, + 0.09, + 'NCSN', + 71346216 + ], + [ + '2010/01/31 13:31:59.50', + 36.11867, + -117.711, + 5.813, + 2.81, + 'Md', + 7, + 246, + 20, + 0.06, + 'NCSN', + 71346731 + ], + [ + '2010/02/07 12:34:37.39', + 36.02017, + -117.785, + 5.258, + 2.9, + 'Md', + 15, + 178, + 15, + 0.04, + 'NCSN', + 71350156 + ], + [ + '2010/02/14 00:37:57.82', + 36.112, + -117.73666, + -1.417, + 3, + 'ML', + 22, + 140, + 20, + 0.15, + 'NCSN', + 71353401 + ], + [ + '2010/02/14 12:44:06.09', + 36.051, + -117.87267, + 6.748, + 2.63, + 'Md', + 10, + 111, + 23, + 0.02, + 'NCSN', + 71353756 + ], + [ + '2010/02/14 17:57:26.20', + 36.06667, + -117.86816, + -0.102, + 2.58, + 'Md', + 14, + 115, + 24, + 0.17, + 'NCSN', + 71353881 + ], + [ + '2010/02/15 00:07:09.35', + 36.068, + -117.86767, + 4.093, + 4.09, + 'ML', + 21, + 137, + 24, + 0.13, + 'NCSN', + 71354001 + ], + [ + '2010/02/15 00:10:56.25', + 36.05217, + -117.9365, + 2.723, + 2.77, + 'Md', + 17, + 213, + 23, + 0.14, + 'NCSN', + 71354011 + ], + [ + '2010/02/19 22:11:29.84', + 35.94817, + -117.996, + 27.204, + 3.14, + 'Md', + 17, + 155, + 79, + 0.13, + 'NCSN', + 71357086 + ], + [ + '2010/02/24 00:30:21.56', + 36.03083, + -118.03416, + 10.161, + 2.8, + 'Md', + 29, + 231, + 82, + 0.35, + 'NCSN', + 71353675 + ], + [ + '2010/02/26 12:46:42.66', + 36.06767, + -117.8725, + 5.358, + 3, + 'Md', + 12, + 178, + 24, + 0.11, + 'NCSN', + 71355090 + ], + [ + '2010/02/26 13:22:54.30', + 36.04984, + -117.9875, + 7.374, + 2.79, + 'Md', + 16, + 229, + 87, + 0.14, + 'NCSN', + 71355105 + ], + [ + '2010/02/26 20:12:04.40', + 36.0605, + -117.8735, + 5.058, + 3.02, + 'ML', + 13, + 176, + 24, + 0.1, + 'NCSN', + 71355210 + ], + [ + '2010/02/27 06:56:03.08', + 36.0595, + -117.8745, + 4.988, + 3.04, + 'Md', + 12, + 175, + 24, + 0.09, + 'NCSN', + 71355385 + ], + [ + '2010/02/27 07:10:47.91', + 36.06833, + -117.87466, + 5.608, + 3.58, + 'ML', + 15, + 178, + 24, + 0.1, + 'NCSN', + 71355400 + ], + [ + '2010/02/27 13:56:38.61', + 36.06583, + -117.88116, + 4.978, + 3.28, + 'ML', + 15, + 177, + 25, + 0.12, + 'NCSN', + 71355585 + ], + [ + '2010/02/27 15:01:35.68', + 36.06467, + -117.8785, + 4.958, + 3.35, + 'ML', + 15, + 177, + 24, + 0.11, + 'NCSN', + 71355605 + ], + [ + '2010/02/27 20:23:53.71', + 36.06467, + -117.88233, + 4.978, + 2.96, + 'Md', + 9, + 196, + 25, + 0.12, + 'NCSN', + 71355735 + ], + [ + '2010/02/28 02:26:14.90', + 36.06033, + -117.87067, + 7.348, + 2.62, + 'Md', + 6, + 196, + 24, + 0.05, + 'NCSN', + 71355895 + ], + [ + '2010/02/28 06:30:17.24', + 36.06733, + -117.87933, + 5.108, + 3.51, + 'ML', + 14, + 198, + 25, + 0.13, + 'NCSN', + 71355955 + ], + [ + '2010/02/28 06:56:28.60', + 36.06116, + -117.87733, + 5.268, + 3.1, + 'ML', + 14, + 135, + 24, + 0.13, + 'NCSN', + 71355960 + ], + [ + '2010/02/28 07:08:47.79', + 36.04033, + -117.8805, + -0.958, + 2.81, + 'Md', + 11, + 115, + 23, + 0.17, + 'NCSN', + 71355970 + ], + [ + '2010/03/01 09:06:03.18', + 36.048, + -117.886, + 5.578, + 4.35, + 'Mw', + 22, + 130, + 24, + 0.25, + 'NCSN', + 71356400 + ], + [ + '2010/03/01 09:16:04.22', + 36.06384, + -117.8675, + 5.428, + 2.79, + 'Md', + 12, + 145, + 24, + 0.1, + 'NCSN', + 71356420 + ], + [ + '2010/03/01 09:24:05.43', + 36.06567, + -117.86967, + 6.848, + 2.53, + 'Md', + 9, + 178, + 24, + 0.08, + 'NCSN', + 71356425 + ], + [ + '2010/03/01 10:32:07.35', + 36.06517, + -117.87117, + 4.548, + 2.91, + 'ML', + 13, + 178, + 24, + 0.12, + 'NCSN', + 71356455 + ], + [ + '2010/03/01 10:39:40.04', + 36.06517, + -117.8675, + 5.138, + 2.85, + 'ML', + 12, + 178, + 24, + 0.08, + 'NCSN', + 71356460 + ], + [ + '2010/03/01 10:50:57.37', + 36.0695, + -117.86833, + 5.118, + 2.81, + 'Md', + 13, + 115, + 24, + 0.13, + 'NCSN', + 71356465 + ], + [ + '2010/03/02 07:22:53.73', + 36.06617, + -117.8685, + 4.918, + 3.55, + 'ML', + 15, + 179, + 24, + 0.11, + 'NCSN', + 71356975 + ], + [ + '2010/03/05 03:46:24.60', + 36.13283, + -117.849, + 0.668, + 2.97, + 'ML', + 17, + 149, + 27, + 0.17, + 'NCSN', + 71358640 + ], + [ + '2010/03/08 03:43:20.70', + 36.06517, + -117.87417, + 4.977, + 3.29, + 'ML', + 13, + 178, + 24, + 0.11, + 'NCSN', + 71360230 + ], + [ + '2010/03/08 07:00:45.04', + 36.06033, + -117.878, + 5.11, + 3.27, + 'ML', + 16, + 112, + 24, + 0.08, + 'NCSN', + 71360265 + ], + [ + '2010/03/08 07:18:21.79', + 36.06267, + -117.87733, + 5.807, + 2.95, + 'Md', + 10, + 136, + 24, + 0.13, + 'NCSN', + 71360270 + ], + [ + '2010/03/08 10:15:09.63', + 36.05733, + -117.87483, + 6.438, + 2.61, + 'Md', + 7, + 194, + 24, + 0.06, + 'NCSN', + 71360315 + ], + [ + '2010/03/09 07:54:27.71', + 36.05533, + -117.8785, + 5.698, + 3.44, + 'ML', + 13, + 174, + 24, + 0.08, + 'NCSN', + 71360720 + ], + [ + '2010/03/09 07:56:55.41', + 36.05783, + -117.87634, + 6.868, + 2.7, + 'Md', + 7, + 175, + 24, + 0.05, + 'NCSN', + 71360725 + ], + [ + '2010/03/09 09:06:34.97', + 36.0585, + -117.88284, + 7.208, + 2.93, + 'ML', + 10, + 174, + 24, + 0.09, + 'NCSN', + 71360740 + ], + [ + '2010/03/09 09:14:37.86', + 36.05483, + -117.882, + 5.308, + 2.6, + 'Md', + 9, + 174, + 24, + 0.06, + 'NCSN', + 71360750 + ], + [ + '2010/03/09 09:20:45.85', + 36.057, + -117.87783, + 8.348, + 2.59, + 'Md', + 7, + 174, + 24, + 0.05, + 'NCSN', + 71360760 + ], + [ + '2010/03/09 20:05:12.62', + 36.06384, + -117.86967, + 5.348, + 3.66, + 'ML', + 14, + 138, + 24, + 0.11, + 'NCSN', + 71360980 + ], + [ + '2010/03/09 20:45:44.09', + 36.0525, + -117.876, + 6.328, + 2.62, + 'Md', + 8, + 174, + 24, + 0.07, + 'NCSN', + 71361005 + ], + [ + '2010/03/10 04:36:38.09', + 36.06283, + -117.8745, + 4.938, + 2.99, + 'ML', + 16, + 137, + 24, + 0.12, + 'NCSN', + 71361155 + ], + [ + '2010/03/11 04:09:07.38', + 36.05633, + -117.88017, + 3.228, + 2.69, + 'Md', + 6, + 193, + 24, + 0.05, + 'NCSN', + 71361590 + ], + [ + '2010/03/12 01:19:36.94', + 36.37967, + -117.85567, + -1.362, + 2.55, + 'Md', + 32, + 170, + 48, + 0.25, + 'NCSN', + 71362150 + ], + [ + '2010/03/12 09:18:51.30', + 35.98183, + -117.6495, + 2.708, + 2.52, + 'ML', + 8, + 191, + 4, + 0.06, + 'NCSN', + 71362290 + ], + [ + '2010/03/18 22:02:56.22', + 36.09833, + -117.98217, + -0.625, + 2.67, + 'Md', + 25, + 259, + 71, + 0.35, + 'NCSN', + 71365285 + ], + [ + '2010/03/20 20:28:06.56', + 36.08484, + -117.8395, + 7.948, + 2.69, + 'Md', + 10, + 188, + 23, + 0.09, + 'NCSN', + 71366240 + ], + [ + '2010/03/26 21:39:59.32', + 36.44433, + -117.94617, + -1.321, + 2.74, + 'Md', + 37, + 163, + 46, + 0.31, + 'NCSN', + 71368805 + ], + [ + '2010/03/29 19:15:57.79', + 35.9685, + -117.85983, + 6.168, + 2.56, + 'Md', + 7, + 159, + 15, + 0.03, + 'NCSN', + 71370220 + ], + [ + '2010/04/01 05:26:40.83', + 36.08633, + -117.90667, + 3.908, + 2.58, + 'Md', + 7, + 181, + 27, + 0.05, + 'NCSN', + 71376286 + ], + [ + '2010/04/05 13:13:13.57', + 36.11883, + -117.86317, + 1.918, + 2.57, + 'Md', + 10, + 218, + 27, + 0.05, + 'NCSN', + 71377991 + ], + [ + '2010/04/10 01:27:33.54', + 36.37017, + -117.85883, + -1.595, + 2.7, + 'Md', + 33, + 125, + 26, + 0.24, + 'NCSN', + 71380051 + ], + [ + '2010/04/10 02:47:23.41', + 36.378, + -117.85117, + 3.425, + 2.85, + 'Md', + 21, + 134, + 26, + 0.1, + 'NCSN', + 71380081 + ], + [ + '2010/04/10 20:34:05.45', + 36.323, + -117.86, + -0.875, + 2.66, + 'Md', + 8, + 218, + 45, + 0.04, + 'NCSN', + 71380451 + ], + [ + '2010/04/11 19:41:36.52', + 36.0725, + -117.85384, + 8.394, + 2.63, + 'Md', + 12, + 101, + 23, + 0.06, + 'NCSN', + 71380726 + ], + [ + '2010/04/14 00:40:02.53', + 36.09583, + -117.87984, + -0.47, + 2.9, + 'Md', + 27, + 165, + 55, + 0.41, + 'NCSN', + 71381696 + ], + [ + '2010/04/19 23:39:08.72', + 36.07633, + -117.88783, + 5.404, + 2.68, + 'Md', + 16, + 126, + 26, + 0.11, + 'NCSN', + 71385691 + ], + [ + '2010/04/20 00:41:32.76', + 36.07433, + -117.886, + 5.094, + 2.64, + 'Md', + 9, + 126, + 26, + 0.02, + 'NCSN', + 71385701 + ], + [ + '2010/04/23 20:27:42.23', + 36.07633, + -117.8845, + 5.254, + 2.73, + 'Md', + 8, + 126, + 26, + 0.04, + 'NCSN', + 71387166 + ], + [ + '2010/04/23 20:33:53.25', + 36.07617, + -117.88683, + 5.034, + 2.98, + 'Md', + 19, + 74, + 26, + 0.11, + 'NCSN', + 71387176 + ], + [ + '2010/04/23 23:02:58.77', + 36.07633, + -117.88617, + 5.134, + 2.55, + 'Md', + 10, + 105, + 26, + 0.05, + 'NCSN', + 71387246 + ], + [ + '2010/04/24 00:43:09.40', + 36.07383, + -117.886, + 7.134, + 2.56, + 'Md', + 10, + 105, + 26, + 0.06, + 'NCSN', + 71387306 + ], + [ + '2010/04/25 00:02:23.56', + 36.098, + -117.85117, + 7.524, + 2.53, + 'Md', + 10, + 107, + 25, + 0.04, + 'NCSN', + 71387786 + ], + [ + '2010/04/28 20:17:36.60', + 36.173, + -118.07816, + 4.295, + 2.58, + 'Md', + 15, + 82, + 21, + 0.07, + 'NCSN', + 71389576 + ], + [ + '2010/04/28 21:43:09.58', + 36.17216, + -118.08033, + 5.205, + 2.61, + 'Md', + 13, + 81, + 21, + 0.09, + 'NCSN', + 71389656 + ], + [ + '2010/05/06 04:16:48.50', + 35.92733, + -117.34917, + 2.673, + 3.59, + 'ML', + 25, + 169, + 27, + 0.2, + 'NCSN', + 71387920 + ], + [ + '2010/05/07 22:56:41.84', + 36.17883, + -118.07117, + -0.465, + 2.6, + 'Md', + 28, + 82, + 22, + 0.17, + 'NCSN', + 71388875 + ], + [ + '2010/05/08 00:08:17.55', + 36.17983, + -118.06983, + -1.492, + 2.76, + 'Md', + 22, + 137, + 22, + 0.17, + 'NCSN', + 71388910 + ], + [ + '2010/05/14 11:35:16.74', + 35.966, + -117.32433, + 5.923, + 3.36, + 'ML', + 23, + 177, + 29, + 0.11, + 'NCSN', + 71397891 + ], + [ + '2010/05/14 15:53:52.69', + 36.07417, + -117.88834, + 7.928, + 2.57, + 'Md', + 11, + 178, + 26, + 0.06, + 'NCSN', + 71398011 + ], + [ + '2010/05/16 17:23:27.45', + 36.399, + -117.8535, + 8.211, + 2.85, + 'Md', + 19, + 139, + 21, + 0.08, + 'NCSN', + 71399251 + ], + [ + '2010/05/19 21:50:41.88', + 36.01867, + -117.82017, + -0.866, + 2.61, + 'Md', + 8, + 106, + 17, + 0.04, + 'NCSN', + 71401221 + ], + [ + '2010/05/28 07:43:54.73', + 36.03567, + -117.777, + 4.984, + 2.99, + 'Md', + 15, + 186, + 15, + 0.04, + 'NCSN', + 71405501 + ], + [ + '2010/06/06 10:34:53.56', + 36.14783, + -118.0575, + 2.341, + 2.88, + 'ML', + 29, + 73, + 23, + 0.15, + 'NCSN', + 71410481 + ], + [ + '2010/07/09 01:30:46.13', + 36.10467, + -117.70284, + 6.869, + 3.12, + 'ML', + 13, + 110, + 18, + 0.07, + 'NCSN', + 71421360 + ], + [ + '2010/07/10 03:33:41.30', + 36.78533, + -118.205, + 10.779, + 3.24, + 'ML', + 58, + 138, + 30, + 0.12, + 'NCSN', + 71422445 + ], + [ + '2010/07/11 16:33:41.75', + 36.0775, + -117.88267, + 8.629, + 2.58, + 'Md', + 9, + 75, + 26, + 0.06, + 'NCSN', + 71423320 + ], + [ + '2010/07/13 19:43:40.94', + 36.07867, + -117.88333, + 7.209, + 2.87, + 'Md', + 16, + 75, + 26, + 0.08, + 'NCSN', + 71424375 + ], + [ + '2010/07/19 02:46:52.80', + 36.04617, + -117.77317, + 4.099, + 2.51, + 'Md', + 17, + 101, + 16, + 0.06, + 'NCSN', + 71427770 + ], + [ + '2010/07/19 20:24:26.98', + 36.3995, + -117.86667, + 6.631, + 2.59, + 'Md', + 16, + 136, + 20, + 0.11, + 'NCSN', + 71428200 + ], + [ + '2010/07/25 18:39:59.15', + 35.736, + -117.6745, + 8.629, + 2.5, + 'Md', + 8, + 127, + 11, + 0.06, + 'NCSN', + 71437031 + ], + [ + '2010/08/07 11:45:57.23', + 36.451, + -118.31, + 12.952, + 2.65, + 'Md', + 17, + 87, + 21, + 0.1, + 'NCSN', + 71442911 + ], + [ + '2010/08/18 06:39:18.89', + 36.05133, + -117.77666, + 3.704, + 2.86, + 'Md', + 30, + 246, + 192, + 0.19, + 'NCSN', + 71442900 + ], + [ + '2010/08/25 03:14:52.11', + 36.07883, + -117.884, + 5.359, + 2.99, + 'Md', + 17, + 75, + 26, + 0.06, + 'NCSN', + 71446385 + ], + [ + '2010/08/25 06:23:07.40', + 36.07717, + -117.88, + 6.599, + 2.58, + 'Md', + 10, + 75, + 25, + 0.03, + 'NCSN', + 71446415 + ], + [ + '2010/08/25 09:41:00.53', + 36.07767, + -117.8785, + 7.129, + 2.73, + 'Md', + 10, + 75, + 25, + 0.04, + 'NCSN', + 71446470 + ], + [ + '2010/08/30 02:57:21.53', + 36.07784, + -117.8805, + 8.479, + 2.66, + 'Md', + 10, + 126, + 25, + 0.06, + 'NCSN', + 71448365 + ], + [ + '2010/09/04 07:40:10.61', + 35.94883, + -117.66116, + 4.674, + 2.72, + 'Md', + 8, + 80, + 1, + 0.07, + 'NCSN', + 71450670 + ], + [ + '2010/09/05 01:55:47.93', + 35.951, + -117.6365, + 6.584, + 2.58, + 'Md', + 8, + 286, + 1, + 0.06, + 'NCSN', + 71450995 + ], + [ + '2010/09/13 16:12:56.63', + 35.84184, + -117.67117, + 6.954, + 2.75, + 'Md', + 8, + 120, + 9, + 0.09, + 'NCSN', + 71454895 + ], + [ + '2010/09/15 20:45:38.17', + 36.38, + -117.85667, + 3.311, + 2.65, + 'Md', + 15, + 132, + 21, + 0.08, + 'NCSN', + 71455830 + ], + [ + '2010/09/16 15:54:55.28', + 35.84333, + -117.67267, + 6.344, + 3.5, + 'Md', + 10, + 119, + 9, + 0.09, + 'NCSN', + 71456225 + ], + [ + '2010/09/16 22:10:07.53', + 36.03367, + -117.77067, + 4.964, + 2.64, + 'Md', + 14, + 100, + 15, + 0.05, + 'NCSN', + 71456365 + ], + [ + '2010/10/10 22:08:46.44', + 36.01317, + -117.81184, + 5.194, + 2.61, + 'Md', + 8, + 88, + 16, + 0.01, + 'NCSN', + 71466950 + ], + [ + '2010/10/12 22:24:13.45', + 35.96433, + -117.65483, + 3.224, + 2.69, + 'Md', + 13, + 125, + 2, + 0.1, + 'NCSN', + 71467795 + ], + [ + '2010/10/12 23:45:17.05', + 35.98883, + -117.5925, + 5.444, + 2.76, + 'Md', + 9, + 292, + 7, + 0.05, + 'NCSN', + 71467855 + ], + [ + '2010/10/13 02:09:10.98', + 36.08517, + -117.85783, + 5.404, + 2.57, + 'Md', + 15, + 80, + 24, + 0.12, + 'NCSN', + 71467900 + ], + [ + '2010/10/23 08:55:41.53', + 35.9645, + -117.665, + 2.174, + 2.54, + 'Md', + 9, + 123, + 2, + 0.23, + 'NCSN', + 71477781 + ], + [ + '2010/10/24 01:54:01.10', + 36.37634, + -117.9415, + 11.571, + 2.59, + 'Md', + 10, + 169, + 14, + 0.05, + 'NCSN', + 71478071 + ], + [ + '2010/10/24 08:31:06.53', + 36.12883, + -117.84033, + 8.344, + 2.85, + 'ML', + 19, + 84, + 26, + 0.1, + 'NCSN', + 71478171 + ], + [ + '2010/10/24 09:06:51.71', + 36.1265, + -117.8345, + 7.734, + 2.73, + 'Md', + 21, + 82, + 26, + 0.11, + 'NCSN', + 71478191 + ], + [ + '2010/10/29 08:22:23.57', + 36.1255, + -117.66734, + 2.754, + 2.83, + 'Md', + 9, + 118, + 18, + 0.05, + 'NCSN', + 71480766 + ], + [ + '2010/10/29 15:47:34.31', + 36.0365, + -117.7745, + 4.594, + 2.91, + 'Md', + 16, + 99, + 15, + 0.06, + 'NCSN', + 71480871 + ], + [ + '2010/10/29 15:53:50.46', + 36.03983, + -117.77233, + 4.409, + 2.66, + 'Md', + 15, + 100, + 15, + 0.04, + 'NCSN', + 71480881 + ], + [ + '2010/11/04 04:42:56.43', + 35.79633, + -118.0405, + 10.122, + 2.53, + 'Md', + 11, + 138, + 10, + 0.05, + 'NCSN', + 71483606 + ], + [ + '2010/11/06 12:20:55.23', + 36.36517, + -117.847, + 4.091, + 2.55, + 'Md', + 9, + 181, + 23, + 0.07, + 'NCSN', + 71484836 + ], + [ + '2010/11/07 08:00:15.85', + 36.0375, + -117.77433, + 5.188, + 2.71, + 'Md', + 13, + 161, + 15, + 0.07, + 'NCSN', + 71485386 + ], + [ + '2010/11/12 11:01:10.85', + 36.38133, + -117.87434, + 3.641, + 2.95, + 'ML', + 13, + 135, + 28, + 0.14, + 'NCSN', + 71487546 + ], + [ + '2010/11/18 06:13:53.70', + 36.06116, + -117.869, + 7.694, + 2.92, + 'Md', + 13, + 76, + 24, + 0.07, + 'NCSN', + 71484675 + ], + [ + '2010/11/25 04:01:15.44', + 36.03617, + -117.77917, + 5.204, + 3.72, + 'ML', + 15, + 98, + 15, + 0.06, + 'NCSN', + 71488000 + ], + [ + '2010/11/25 05:04:35.42', + 36.03283, + -117.78933, + 3.494, + 2.68, + 'Md', + 11, + 94, + 16, + 0.13, + 'NCSN', + 71488025 + ], + [ + '2010/12/01 12:16:14.47', + 35.96267, + -117.65583, + 3.644, + 2.71, + 'ML', + 13, + 143, + 2, + 0.09, + 'NCSN', + 71490865 + ], + [ + '2010/12/01 20:53:10.16', + 35.96183, + -117.65317, + 3.224, + 3.21, + 'ML', + 10, + 144, + 2, + 0.08, + 'NCSN', + 71491065 + ], + [ + '2010/12/01 20:53:36.48', + 35.979, + -117.64417, + 4.815, + 2.99, + 'ML', + 9, + 233, + 3, + 0.04, + 'NCSN', + 71046449 + ], + [ + '2010/12/08 02:36:56.48', + 36.38833, + -117.8725, + 2.165, + 2.51, + 'Md', + 30, + 134, + 28, + 0.16, + 'NCSN', + 71493990 + ], + [ + '2010/12/20 15:24:52.23', + 36.64617, + -118.06216, + -0.36, + 2.86, + 'Md', + 41, + 172, + 59, + 0.11, + 'NCSN', + 71499175 + ], + [ + '2010/12/22 14:27:46.45', + 36.00217, + -118.0585, + 13.048, + 2.5, + 'Md', + 9, + 101, + 14, + 0.05, + 'NCSN', + 71499935 + ], + [ + '2011/01/08 10:31:42.90', + 36.05333, + -117.85583, + -0.996, + 2.56, + 'Md', + 22, + 238, + 96, + 0.16, + 'NCSN', + 71507050 + ], + [ + '2011/02/05 21:34:49.57', + 36.037, + -117.76833, + 2.548, + 2.64, + 'Md', + 11, + 188, + 15, + 0.04, + 'NCSN', + 71525101 + ], + [ + '2011/02/23 03:16:14.18', + 35.98883, + -117.61667, + 5.458, + 2.96, + 'Md', + 7, + 286, + 5, + 0.03, + 'NCSN', + 71527310 + ], + [ + '2011/02/23 05:33:53.20', + 35.97066, + -117.66183, + 5.594, + 2.78, + 'Md', + 11, + 123, + 20, + 0.09, + 'NCSN', + 71527425 + ], + [ + '2011/02/24 18:28:06.95', + 36.042, + -118.34766, + 5.98, + 2.64, + 'Md', + 8, + 85, + 13, + 0.06, + 'NCSN', + 71528135 + ], + [ + '2011/02/24 20:05:47.43', + 36.04083, + -118.34483, + 2.723, + 3.5, + 'ML', + 61, + 62, + 13, + 0.16, + 'NCSN', + 71528180 + ], + [ + '2011/02/27 02:03:56.67', + 36.03217, + -117.7735, + 4.169, + 2.66, + 'Md', + 11, + 252, + 24, + 0.07, + 'NCSN', + 71529200 + ], + [ + '2011/02/27 09:49:56.23', + 36.033, + -118.34583, + 3.843, + 2.65, + 'Md', + 11, + 103, + 14, + 0.07, + 'NCSN', + 71529350 + ], + [ + '2011/03/02 00:38:22.54', + 35.9745, + -117.66233, + 4.421, + 2.74, + 'Md', + 11, + 123, + 21, + 0.04, + 'NCSN', + 71531325 + ], + [ + '2011/03/09 18:25:12.54', + 36.145, + -117.92033, + 9.67, + 2.64, + 'Md', + 6, + 96, + 33, + 0.05, + 'NCSN', + 71540331 + ], + [ + '2011/03/10 15:56:24.75', + 36.03167, + -117.42567, + 5.531, + 3.08, + 'ML', + 11, + 261, + 31, + 0.07, + 'NCSN', + 71540846 + ], + [ + '2011/03/14 20:02:32.96', + 35.79633, + -117.97717, + 8.111, + 2.68, + 'Md', + 11, + 111, + 13, + 0.05, + 'NCSN', + 71543146 + ] + ], + fields: [ + { + name: 'DateTime', + type: 'timestamp', + format: 'YYYY/M/D HH:mm:ss.SSSS', + analyzerType: 'DATETIME' + }, + {name: 'Latitude', type: 'real', format: '', analyzerType: 'FLOAT'}, + {name: 'Longitude', type: 'real', format: '', analyzerType: 'FLOAT'}, + {name: 'Depth', type: 'real', format: '', analyzerType: 'FLOAT'}, + {name: 'Magnitude', type: 'real', format: '', analyzerType: 'FLOAT'}, + {name: 'MagType', type: 'string', format: '', analyzerType: 'STRING'}, + {name: 'NbStations', type: 'integer', format: '', analyzerType: 'INT'}, + {name: 'Gap', type: 'integer', format: '', analyzerType: 'INT'}, + {name: 'Distance', type: 'integer', format: '', analyzerType: 'INT'}, + {name: 'RMS', type: 'real', format: '', analyzerType: 'FLOAT'}, + {name: 'Source', type: 'string', format: '', analyzerType: 'STRING'}, + {name: 'EventID', type: 'integer', format: '', analyzerType: 'INT'} + ] + } + } + ], + config: { + version: 'v1', + config: { + visState: { + filters: [ + { + dataId: ['20pde67d8r'], + id: 'co92ohnaw', + name: [], + type: 'polygon', + value: { + type: 'Feature', + geometry: { + type: 'Polygon', + coordinates: [ + [ + [-118.20767308297478, 36.23374452687357], + [-118.20767308297478, 35.886447523728584], + [-117.51631123920194, 35.886447523728584], + [-117.51631123920194, 36.23374452687357], + [-118.20767308297478, 36.23374452687357] + ] + ] + }, + properties: { + renderType: 'Rectangle', + isClosed: true, + bbox: {xmin: -118.20767308297478, xmax: null, ymin: 36.229154589774176, ymax: null}, + isVisible: true, + filterId: 'co92ohnaw' + }, + id: 'c3222d4d-30d5-4c2d-beca-db557b6ce965' + }, + enlarged: false, + plotType: 'histogram', + animationWindow: 'free', + yAxis: null, + layerId: ['06xco1x'], + speed: 1 + } + ], + layers: [ + { + id: '06xco1x', + type: 'point', + config: { + dataId: '20pde67d8r', + label: 'Point', + color: [18, 92, 119], + highlightColor: [252, 242, 26, 255], + columns: {lat: 'Latitude', lng: 'Longitude', altitude: null}, + isVisible: true, + visConfig: { + radius: 10, + fixedRadius: false, + opacity: 0.8, + outline: false, + thickness: 2, + strokeColor: null, + colorRange: { + name: 'Global Warming', + type: 'sequential', + category: 'Uber', + colors: ['#5A1846', '#900C3F', '#C70039', '#E3611C', '#F1920E', '#FFC300'] + }, + strokeColorRange: { + name: 'Global Warming', + type: 'sequential', + category: 'Uber', + colors: ['#5A1846', '#900C3F', '#C70039', '#E3611C', '#F1920E', '#FFC300'] + }, + radiusRange: [0, 50], + filled: true + }, + hidden: false, + textLabel: [ + { + field: null, + color: [255, 255, 255], + size: 18, + offset: [0, 0], + anchor: 'start', + alignment: 'center' + } + ] + }, + visualChannels: { + colorField: {name: 'Depth', type: 'real'}, + colorScale: 'quantile', + strokeColorField: null, + strokeColorScale: 'quantile', + sizeField: null, + sizeScale: 'linear' + } + } + ], + interactionConfig: { + tooltip: { + fieldsToShow: { + '20pde67d8r': [ + {name: 'DateTime', format: null}, + {name: 'Latitude', format: null}, + {name: 'Longitude', format: null}, + {name: 'Depth', format: null}, + {name: 'Magnitude', format: null} + ] + }, + compareMode: false, + compareType: 'absolute', + enabled: true + }, + brush: {size: 0.5, enabled: false}, + geocoder: {enabled: false}, + coordinate: {enabled: false} + }, + layerBlending: 'normal', + splitMaps: [], + animationConfig: {currentTime: null, speed: 1} + }, + mapState: { + bearing: 0, + dragRotate: false, + latitude: 36.245218190831125, + longitude: -117.80651250695874, + pitch: 0, + zoom: 7.949152711295885, + isSplit: false + }, + mapStyle: { + styleType: 'dark', + topLayerGroups: {}, + visibleLayerGroups: { + label: true, + road: true, + border: false, + building: true, + water: true, + land: true, + '3d building': false + }, + threeDBuildingColor: [9.665468314072013, 17.18305478057247, 31.1442867897876], + mapStyles: {} + } + } + }, + info: { + app: 'kepler.gl', + created_at: 'Thu Oct 21 2021 09:12:14 GMT-0400 (Eastern Daylight Time)', + title: 'keplergl_rvxe1dv', + description: '' + } +}; + +export const mockStateWithPolygonFilter = () => { + const initialState = CloneDeep(InitialState); + const result = processKeplerglJSON(polygonFilterMap); + const newState = coreReducer(initialState, addDataToMap(result)); + + return newState; +}; diff --git a/test/node/reducers/vis-state-merger-test.js b/test/node/reducers/vis-state-merger-test.js index 7bd7d8d21d..779df0ca4e 100644 --- a/test/node/reducers/vis-state-merger-test.js +++ b/test/node/reducers/vis-state-merger-test.js @@ -109,6 +109,7 @@ import { mergedTripFilter, mergedRateFilter } from 'test/fixtures/geojson'; +import {mockStateWithPolygonFilter} from '../../fixtures/points-with-polygon-filter-map'; test('VisStateMerger.v0 -> mergeFilters -> toEmptyState', t => { const savedConfig = cloneDeep(savedStateV0); @@ -1902,3 +1903,24 @@ test('VisStateMerger -> insertLayerAtRightOrder -> to empty config', t => { t.end(); }); + +test('VisStateMerger -> load polygon filter map', t => { + const oldState = mockStateWithPolygonFilter(); + + const oldFilter = oldState.visState.filters[0]; + + const appStateToSave = SchemaManager.save(oldState); + const stateParsed = SchemaManager.load(appStateToSave); + const initialState = cloneDeep(InitialState); + const initialVisState = initialState.visState; + + const visState = visStateReducer( + initialVisState, + updateVisData(stateParsed.datasets, {}, stateParsed.config) + ); + + const newFilter = visState.filters[0]; + + t.deepEqual(newFilter, oldFilter, 'Should have loaded the polygon filter correctly'); + t.end(); +});