Skip to content

Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.

chore: remove unused not exported files / utils (#3628)

Igor Dykhta54db300f0747
diff --git a/src/components/src/common/icons/arrow-down-solid.tsx b/src/components/src/common/icons/arrow-down-solid.tsx
deleted file mode 100644
index eb1bc92b4..000000000
--- a/src/components/src/common/icons/arrow-down-solid.tsx
+++ /dev/null
@@ -1,20 +0,0 @@
-// SPDX-License-Identifier: MIT
-// Copyright contributors to the kepler.gl project
-
-import React, {Component} from 'react';
-import Base, {BaseProps} from './base';
-
-export default class ArrowDownSolid extends Component<Partial<BaseProps>> {
- static defaultProps = {
- height: '16px',
- predefinedClassName: 'data-ex-icons-arrowdown-solid'
- };
-
- render() {
- return (
- <Base {...this.props}>
- <polygon points="6.4,20.8 56.4,20.8 31.4,45.8 " />
- </Base>
- );
- }
-}
diff --git a/src/components/src/modals/cloud-components/provider-loading.tsx b/src/components/src/modals/cloud-components/provider-loading.tsx
deleted file mode 100644
index d15cf95b0..000000000
--- a/src/components/src/modals/cloud-components/provider-loading.tsx
+++ /dev/null
@@ -1,21 +0,0 @@
-// SPDX-License-Identifier: MIT
-// Copyright contributors to the kepler.gl project
-
-import React from 'react';
-import LoadingDialog from '../loading-dialog';
-import styled from 'styled-components';
-
-const StyledSpinner = styled.div`
- text-align: center;
- span {
- margin: 0 auto;
- }
-`;
-
-export const ProviderLoading = () => {
- return (
- <StyledSpinner>
- <LoadingDialog size={64} />
- </StyledSpinner>
- );
-};
diff --git a/src/components/src/modals/storage-map-viewer.tsx b/src/components/src/modals/storage-map-viewer.tsx
deleted file mode 100644
index ab87515f7..000000000
--- a/src/components/src/modals/storage-map-viewer.tsx
+++ /dev/null
@@ -1,173 +0,0 @@
-// SPDX-License-Identifier: MIT
-// Copyright contributors to the kepler.gl project
-
-import React from 'react';
-import styled from 'styled-components';
-import moment from 'moment';
-import {LeftArrow} from '../common/icons';
-import {FormattedMessage} from '@kepler.gl/localization';
-
-const imageH = 108;
-
-const StyledAssetGallery = styled.div.attrs({
- className: 'storage-asset-gallery'
-})`
- display: flex;
- justify-content: flex-start;
- flex-wrap: wrap;
-`;
-
-const StyledAssetItem = styled.div.attrs({
- className: 'asset__item'
-})`
- width: 23%;
- margin-right: 2%;
- max-width: 500px;
- margin-bottom: 40px;
- height: 245px;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
-
- :last {
- margin-right: 0;
- }
-
- .asset__title {
- font-size: 12px;
- font-weight: 500;
- color: ${props => props.theme.textColorLT};
- line-height: 18px;
- height: 32px;
- }
-
- .asset__image {
- border-radius: 4px;
- overflow: hidden;
- margin-bottom: 12px;
- opacity: 0.9;
- transition: opacity 0.4s ease;
- position: relative;
- line-height: 0;
- height: ${imageH}px;
- flex-shrink: 0;
-
- img {
- max-width: 100%;
- }
- &:hover {
- cursor: pointer;
- opacity: 1;
- }
- }
-
- .asset__image__caption {
- font-size: 11px;
- font-weight: 400;
- line-height: 16px;
- margin-top: 10px;
- height: 48px;
- overflow: hidden;
- display: -webkit-box;
- text-overflow: ellipsis;
- -webkit-line-clamp: 3;
- -webkit-box-orient: vertical;
- }
-
- .asset__last-updated {
- font-size: 11px;
- color: ${props => props.theme.textColorLT};
- }
-`;
-
-const BackLink = styled.div`
- display: flex;
- font-size: 14px;
- align-items: center;
- color: ${props => props.theme.titleColorLT};
- cursor: pointer;
- margin-bottom: 40px;
-
- &:hover {
- font-weight: 500;
- }
-
- span {
- white-space: nowrap;
- }
- svg {
- margin-right: 10px;
- }
-`;
-
-const StyledError = styled.div`
- color: red;
- font-size: 14px;
- margin-bottom: 16px;
-`;
-
-const getDuration = (last = 0) => moment.duration(new Date().valueOf() - last).humanize();
-
-interface Asset {
- imageUrl?: string;
- label?: string;
- title?: string;
- description?: string;
- lastUpdated?: number;
- id?: string;
-}
-
-interface AssetItemProps {
- asset: Asset;
- onClick: React.MouseEventHandler<HTMLDivElement>;
-}
-
-const AssetItem: React.FC<AssetItemProps> = ({asset, onClick}) => (
- <StyledAssetItem>
- <div className="asset__image" onClick={onClick}>
- {asset.imageUrl && <img src={asset.imageUrl} />}
- </div>
- <div className="asset__title">{asset.label || asset.title}</div>
- <div className="asset__image__caption">{asset.description}</div>
- {asset.lastUpdated ? (
- <div className="asset__last-updated">
- <FormattedMessage
- id={'modal.storageMapViewer.lastModified'}
- values={{lastUpdated: getDuration(asset.lastUpdated)}}
- />
- </div>
- ) : null}
- </StyledAssetItem>
-);
-
-interface StorageAssetsViewerProps {
- assets: Asset[];
- onLoadAsset: (asset: Asset) => void;
- back?: React.MouseEventHandler<HTMLDivElement>;
- error?: {message?: string};
-}
-
-class StorageAssetsViewer extends React.Component<StorageAssetsViewerProps> {
- render() {
- const {assets, onLoadAsset, back, error} = this.props;
-
- return (
- <div className="storage-asset-viewer">
- <BackLink onClick={back}>
- <LeftArrow height="12px" />
- <span>
- <FormattedMessage id={'modal.storageMapViewer.back'} />
- </span>
- </BackLink>
- {error && <StyledError>{error.message}</StyledError>}
- <StyledAssetGallery>
- {assets.map(sp => (
- <AssetItem asset={sp} key={sp.id} onClick={() => onLoadAsset(sp)} />
- ))}
- </StyledAssetGallery>
- </div>
- );
- }
-}
-
-export default StorageAssetsViewer;
diff --git a/src/components/src/side-panel/cloud-storage-dropdown.tsx b/src/components/src/side-panel/cloud-storage-dropdown.tsx
deleted file mode 100644
index a6d0b0dee..000000000
--- a/src/components/src/side-panel/cloud-storage-dropdown.tsx
+++ /dev/null
@@ -1,35 +0,0 @@
-// SPDX-License-Identifier: MIT
-// Copyright contributors to the kepler.gl project
-
-import React from 'react';
-import {PanelHeaderDropdownFactory, Icons} from '..';
-
-const CloudStorageItems = [
- {
- label: 'Save',
- icon: Icons.Save2,
- key: 'data',
- onClick: props => props.onSaveMap
- },
- {
- label: 'Settings',
- icon: Icons.Gear,
- key: 'settings',
- onClick: props => props.onExportData
- }
-];
-
-const PanelHeaderDropdown = PanelHeaderDropdownFactory();
-
-const CloudStorageDropdown = ({show, onClose}) => {
- return (
- <PanelHeaderDropdown
- items={CloudStorageItems}
- show={show}
- onClose={onClose}
- id="cloud-storage"
- />
- );
-};
-
-export default CloudStorageDropdown;
diff --git a/src/deckgl-layers/src/raster/raster-mesh-layer/matrix.ts b/src/deckgl-layers/src/raster/raster-mesh-layer/matrix.ts
deleted file mode 100644
index 805a858fe..000000000
--- a/src/deckgl-layers/src/raster/raster-mesh-layer/matrix.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-// SPDX-License-Identifier: MIT
-// Copyright contributors to the kepler.gl project
-
-import {COORDINATE_SYSTEM, Viewport} from '@deck.gl/core';
-type CoordinateSystem = number | string;
-
-// only apply composeModelMatrix when in cartesian or meter_offsets coordinate system
-// with `composeModelMatrix` enabled, the rotation part of the layer's modelMatrix will be composed to instance's transformations
-// since rotating latitude and longitude can not provide meaningful results, hence `composeModelMatrix` is disabled
-// when in LNGLAT and LNGLAT_OFFSET coordinates.
-export function shouldComposeModelMatrix(
- viewport: Viewport,
- coordinateSystem: CoordinateSystem
-): boolean {
- return (
- coordinateSystem === COORDINATE_SYSTEM.CARTESIAN ||
- coordinateSystem === COORDINATE_SYSTEM.METER_OFFSETS ||
- (coordinateSystem === COORDINATE_SYSTEM.DEFAULT && !viewport.isGeospatial)
- );
-}
diff --git a/src/layers/src/hexagon-layer/hexagon-utils.ts b/src/layers/src/hexagon-layer/hexagon-utils.ts
deleted file mode 100644
index 3912d1d88..000000000
--- a/src/layers/src/hexagon-layer/hexagon-utils.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-// SPDX-License-Identifier: MIT
-// Copyright contributors to the kepler.gl project
-
-import {WebMercatorViewport} from '@deck.gl/core';
-import Console from 'global/console';
-import type {Centroid} from '@kepler.gl/common-utils';
-
-export function hexagonToPolygonGeo(object, properties, radius, mapState, coordinate?) {
- const viewport = new WebMercatorViewport(mapState);
- const pos = object.position || coordinate;
- const position = pos ? (Array.from(pos) as number[]) : null;
- if (!position || position.length < 2) {
- return null;
- }
-
- const screenCenter = viewport.projectFlat(position);
- const {unitsPerMeter} = viewport.getDistanceScales(position);
-
- if (!Array.isArray(unitsPerMeter)) {
- Console.warn(`unitsPerMeter is undefined`);
- return null;
- }
-
- const pixRadius = radius * unitsPerMeter[0];
-
- const coordinates: any[] = [];
-
- for (let i = 0; i < 6; i++) {
- const vertex = hex_corner(screenCenter, pixRadius, i);
- coordinates.push(viewport.unprojectFlat(vertex));
- }
-
- coordinates.push(coordinates[0]);
-
- return {
- geometry: {
- coordinates,
- type: 'LineString'
- },
- properties
- };
-}
-
-function hex_corner(center: Centroid, radius: number, i: number) {
- const angle_deg = 60 * i + 30;
- const angle_rad = (Math.PI / 180) * angle_deg;
-
- return [center[0] + radius * Math.cos(angle_rad), center[1] + radius * Math.sin(angle_rad)];
-}
diff --git a/src/layers/src/mapboxgl-layer.ts b/src/layers/src/mapboxgl-layer.ts
deleted file mode 100644
index aa438b5fc..000000000
--- a/src/layers/src/mapboxgl-layer.ts
+++ /dev/null
@@ -1,172 +0,0 @@
-// SPDX-License-Identifier: MIT
-// Copyright contributors to the kepler.gl project
-
-import Layer, {LayerBaseConfig, OVERLAY_TYPE_CONST, VisualChannels} from './base-layer';
-import {createSelector} from 'reselect';
-
-import {geoJsonFromData, prefixGpuField, gpuFilterToMapboxFilter} from './mapbox-utils';
-import {default as KeplerTable} from '@kepler.gl/table';
-import {Merge, LayerColumn} from '@kepler.gl/types';
-
-type MapboxLayerGLColumns = {
- lat: LayerColumn;
- lng: LayerColumn;
-
- // COLUMN_MODE_GEOARROW
- geoarrow?: LayerColumn;
-};
-
-export type MapboxLayerGLConfig = Merge<LayerBaseConfig, {columns: MapboxLayerGLColumns}>;
-
-export const COLUMN_MODE_POINTS = 'points';
-export const mapboxRequiredColumns = ['lat', 'lng'];
-const SUPPORTED_COLUMN_MODES = [
- {
- key: COLUMN_MODE_POINTS,
- label: 'Points',
- requiredColumns: mapboxRequiredColumns
- }
-];
-
-export const pointColResolver = ({lat, lng, geoarrow}: MapboxLayerGLColumns, columnMode?: string) =>
- `${columnMode}-${lat.fieldIdx}-${lng.fieldIdx}-${geoarrow?.fieldIdx}`;
-
-class MapboxLayerGL extends Layer {
- declare config: MapboxLayerGLConfig;
-
- get overlayType() {
- return OVERLAY_TYPE_CONST.mapboxgl;
- }
-
- get type(): string | null {
- return null;
- }
-
- get isAggregated(): true {
- return true;
- }
-
- get supportedColumnModes() {
- return SUPPORTED_COLUMN_MODES;
- }
-
- get columnPairs() {
- return this.defaultPointColumnPairs;
- }
-
- get noneLayerDataAffectingProps() {
- return [];
- }
-
- get visualChannels(): VisualChannels {
- return {};
- }
- datasetSelector = (config: MapboxLayerGLConfig) => config.dataId;
- gpuFilterSelector = (config: MapboxLayerGLConfig, datasets) =>
- ((config.dataId && datasets[config.dataId]) || {}).gpuFilter;
- columnsSelector = (config: MapboxLayerGLConfig) =>
- pointColResolver(config.columns, config.columnMode);
-
- sourceSelector = createSelector(
- this.datasetSelector,
- this.columnsSelector,
- (datasetId, columns) => `${datasetId}-${columns}`
- );
-
- filterSelector = createSelector(this.gpuFilterSelector, gpuFilter =>
- gpuFilterToMapboxFilter(gpuFilter)
- );
-
- isValidFilter(filter) {
- // mapbox will crash if filter is not an array or empty
- return Array.isArray(filter) && filter.length;
- }
-
- getDataUpdateTriggers({filteredIndex, filteredIndexByLayer, gpuFilter, id}: KeplerTable): any {
- const {columns} = this.config;
- const layerFilteredIndex = filteredIndexByLayer?.[this.id] ?? filteredIndex;
-
- const visualChannelFields = Object.values(this.visualChannels).reduce(
- (accu, v) => ({
- ...accu,
- ...(this.config[v.field] ? {[v.field]: this.config[v.field].name} : {})
- }),
- {}
- );
-
- const updateTriggers = {
- getData: {
- datasetId: id,
- columns,
- filteredIndex: layerFilteredIndex,
- ...visualChannelFields,
- ...gpuFilter.filterValueUpdateTriggers
- },
- getMeta: {datasetId: id, columns}
- };
-
- return updateTriggers;
- }
-
- getGeometry(position) {
- return position.every(Number.isFinite)
- ? {
- type: 'Point',
- coordinates: position
- }
- : null;
- }
-
- calculateDataAttribute({dataContainer, filteredIndex, gpuFilter}: KeplerTable, getPosition) {
- const getGeometry = d => this.getGeometry(getPosition(d));
-
- const vcFields = Object.values(this.visualChannels)
- .map(v => this.config[v.field])
- .filter(v => v);
-
- const getPropertyFromVisualChanel = vcFields.length
- ? d =>
- vcFields.reduce(
- (accu, field) => ({
- ...accu,
- [field.name]: field.valueAccessor(d)
- }),
- {}
- )
- : () => ({});
-
- const {filterValueUpdateTriggers, filterValueAccessor} = gpuFilter;
-
- // gpuField To property
- const hasFilter = Object.values(filterValueUpdateTriggers).filter(d => d).length;
- const valueAccessor = filterValueAccessor(dataContainer)();
-
- const getPropertyFromFilter = hasFilter
- ? d => {
- const filterValue = valueAccessor(d);
- return Object.values(filterValueUpdateTriggers).reduce(
- (accu: any, gpu: any, i) => ({
- ...accu,
- ...(gpu?.name ? {[prefixGpuField(gpu.name)]: filterValue[i]} : {})
- }),
- {} as {[id: string]: number | number[]}
- ) as Record<string, number | number[]>;
- }
- : () => ({} as Record<string, number | number[]>);
-
- const getProperties = d => ({
- ...getPropertyFromVisualChanel(d),
- ...getPropertyFromFilter(d)
- });
-
- return geoJsonFromData(filteredIndex, getGeometry, getProperties);
- }
-
- // this layer is rendered at mapbox level
- // todo: maybe need to find a better solution for this one
- shouldRenderLayer() {
- return typeof this.type === 'string' && this.config.isVisible && this.hasAllColumns();
- }
-}
-
-export default MapboxLayerGL;
diff --git a/src/schemas/src/schema-utils.ts b/src/schemas/src/schema-utils.ts
deleted file mode 100644
index 532b696d2..000000000
--- a/src/schemas/src/schema-utils.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-// SPDX-License-Identifier: MIT
-// Copyright contributors to the kepler.gl project
-
-/**
- * Recursively save / load value for state based on property keys,
- * if property[key] is another schema
- * Use is to get value to save
- * @param {Object} state - state to save
- * @param {Object} properties - properties schema
- * @returns {Object} - saved state
- */
-export function savePropertiesOrApplySchema(state, properties) {
- return getPropertyValueFromSchema('save', state, properties);
-}
-
-export function loadPropertiesOrApplySchema(state, properties) {
- return getPropertyValueFromSchema('load', state, properties);
-}
-
-export function getPropertyValueFromSchema(operation, state, properties) {
- return Object.keys(properties).reduce(
- (accu, key) => ({
- ...accu,
- ...(key in state
- ? properties[key]
- ? // if it's another schema
- properties[key][operation]
- ? // call save or load
- properties[key][operation](state[key], state)
- : // if it's another property object
- getPropertyValueFromSchema(operation, state[key], properties[key])
- : {[key]: state[key]}
- : {})
- }),
- {}
- );
-}
diff --git a/src/utils/src/noop.ts b/src/utils/src/noop.ts
deleted file mode 100644
index 11afed2fa..000000000
--- a/src/utils/src/noop.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-// SPDX-License-Identifier: MIT
-// Copyright contributors to the kepler.gl project
-
-export default function noop() {
- return;
-}
diff --git a/src/utils/src/searcher-utils.ts b/src/utils/src/searcher-utils.ts
deleted file mode 100644
index 9486f7aa5..000000000
--- a/src/utils/src/searcher-utils.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-// SPDX-License-Identifier: MIT
-// Copyright contributors to the kepler.gl project
-
-/* eslint-disable callback-return */
-export function simpleSearcher(autofillValues, page, query, cb) {
- const regex = new RegExp(query, 'i');
- let foundQuery = false;
- const matches = (autofillValues || []).filter(function _filter(item) {
- const tag = item.name;
- foundQuery = foundQuery || tag === query;
- return tag && regex.test(tag);
- });
-
- if (cb) {
- cb(matches);
- }
-
- return matches;
-}
-/* eslint-enable callback-return */