Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Not released

- GeocoderWidget: Fix detection of lat,lng coordinates with whitespace
- Remove 'spatialFiltersResolution' and 'dataResolution' parameters from widgets [#930](https://github.com/CartoDB/carto-react/pull/930)

## 3.1.0

Expand Down
3 changes: 0 additions & 3 deletions packages/react-api/src/api/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,6 @@ export function executeModel(props) {
if (spatialDataColumn) queryParams.spatialDataColumn = spatialDataColumn;

if (spatialDataType !== 'geo') {
if (source.spatialFiltersResolution !== undefined) {
queryParams.spatialFiltersResolution = source.spatialFiltersResolution;
}
queryParams.spatialFiltersMode = source.spatialFiltersMode || 'intersects';
}
}
Expand Down
2 changes: 0 additions & 2 deletions packages/react-api/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@ export type SourceProps = {
type: MapTypesType['QUERY'] | MapTypesType['TABLE'] | MapTypesType['TILESET'];
connection: string;
geoColumn?: string;
dataResolution?: number;
spatialDataType?: string;
spatialDataColumn?: string;
spatialFiltersResolution?: number;
aggregationExp?: string;
aggregationResLevel?: number;
credentials?: Credentials;
Expand Down
6 changes: 0 additions & 6 deletions packages/react-redux/src/slices/cartoSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,6 @@ export const createCartoSlice = (initialState) => {
* @param {FiltersLogicalOperators=} data.filtersLogicalOperator - logical operator that defines how filters for different columns are joined together.
* @param {import('@deck.gl/carto').QueryParameters} data.queryParameters - SQL query parameters.
* @param {string=} data.geoColumn - (optional) name of column containing geometries or spatial index data.
* @param {number=} data.dataResolution - data resolution for spatial index data.
* @param {number=} data.spatialFiltersResolution - spatial filters resolution for spatial index data.
* @param {string=} data.aggregationExp - (optional) for spatial index data.
* @param {number=} data.aggregationResLevel - (optional) for spatial index data.
* @param {string=} data.provider - (optional) type of the data warehouse.
Expand All @@ -222,8 +220,6 @@ export const addSource = ({
geoColumn,
spatialDataType,
spatialDataColumn,
dataResolution,
spatialFiltersResolution,
aggregationExp,
aggregationResLevel,
provider
Expand All @@ -239,11 +235,9 @@ export const addSource = ({
filtersLogicalOperator,
queryParameters,
geoColumn,
dataResolution,
aggregationResLevel,
spatialDataType,
spatialDataColumn,
spatialFiltersResolution,
aggregationExp,
provider
}
Expand Down
17 changes: 4 additions & 13 deletions packages/react-widgets/__tests__/models/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,17 @@ describe('utils', () => {
['v3', { ...V3_SOURCE, type: 'tileset' }, false],
['v3/databricks', { ...V3_SOURCE, provider: 'databricks' }, false],
['v3/databricksRest', { ...V3_SOURCE, provider: 'databricksRest' }, true],

[
'v3/h3/with dataResolution',
{ ...V3_SOURCE, geoColumn: 'h3', dataResolution: 5 },
true
],
['v3/h3', { ...V3_SOURCE, geoColumn: 'h3' }, true],
[
'v3/h3-frompoint/without dataResolution',
'v3/h3-frompoint',
{ ...V3_SOURCE, geoColumn: 'h3:geom', spatialDataType: 'geo' },
true
],
['v3/quadbin', { ...V3_SOURCE, geoColumn: 'quadbin:abc' }, true],
[
'v3/quadbin-frompoint/without dataResolution',
'v3/quadbin-frompoint',
{ ...V3_SOURCE, geoColumn: 'quadbin:geom', spatialDataType: 'geo' },
true
],
[
'v3/quadbin/with dataResolution',
{ ...V3_SOURCE, geoColumn: 'quadbin:abc', spatialFiltersResolution: 5 },
true
]
])('works correctly for %s', (_, source, expected) => {
expect(isRemoteCalculationSupported({ source })).toEqual(expected);
Expand Down
30 changes: 1 addition & 29 deletions packages/react-widgets/src/hooks/useWidgetFetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { DEFAULT_INVALID_COLUMN_ERR } from '../widgets/utils/constants';
import useCustomCompareEffect from './useCustomCompareEffect';
import useWidgetSource from './useWidgetSource';
import { isRemoteCalculationSupported } from '../models/utils';
import { getSpatialFiltersResolution } from '../models/spatialFiltersResolution';

export const WidgetStateType = {
Loading: 'loading',
Expand Down Expand Up @@ -86,7 +85,6 @@ export default function useWidgetFetch(
);

const viewport = useSelector(selectViewport);
const viewState = useSelector((state) => state.carto.viewState);
const spatialFilter = useSelector((state) =>
selectValidSpatialFilter(state, dataSource)
);
Expand All @@ -95,31 +93,6 @@ export default function useWidgetFetch(
[global, viewport, spatialFilter]
);

const enrichedSource = useMemo(() => {
if (
!source ||
!geometryToIntersect ||
source.spatialDataType === 'geo' ||
source.spatialFiltersResolution !== undefined ||
!source.dataResolution
) {
return source;
}

if (source.spatialDataType === 'h3' || source.spatialDataType === 'quadbin') {
const spatialFiltersResolution = getSpatialFiltersResolution({
source,
viewState,
spatialDataType: source.spatialDataType
});
return {
...source,
spatialFiltersResolution
};
}
return source;
}, [geometryToIntersect, source, viewState.zoom, viewState.latitude]);

useCustomCompareEffect(
() => {
let outdated = false;
Expand All @@ -133,7 +106,7 @@ export default function useWidgetFetch(
onStateChange?.({ state: WidgetStateType.Loading });

modelFn({
source: enrichedSource,
source,
...params,
global,
remoteCalculation,
Expand Down Expand Up @@ -168,7 +141,6 @@ export default function useWidgetFetch(
},
[
params,
enrichedSource,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need source (not enriched as it's outdated but any) as input to useEffect that runs model against new parameters

onError,
isSourceReady,
global,
Expand Down
3 changes: 1 addition & 2 deletions packages/react-widgets/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,5 @@ export { WidgetState, WidgetStateType } from './types';
export {
isRemoteCalculationSupported as _isRemoteCalculationSupported,
sourceAndFiltersToSQL as _sourceAndFiltersToSQL,
getSqlEscapedSource as _getSqlEscapedSource,
getSpatialFiltersResolution as _getSpatialFiltersResolution
getSqlEscapedSource as _getSqlEscapedSource
} from './models/utils';
1 change: 0 additions & 1 deletion packages/react-widgets/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,3 @@ export {
sourceAndFiltersToSQL as _sourceAndFiltersToSQL,
getSqlEscapedSource as _getSqlEscapedSource
} from './models/utils';
export { getSpatialFiltersResolution as _getSpatialFiltersResolution } from './models/spatialFiltersResolution';
87 changes: 0 additions & 87 deletions packages/react-widgets/src/models/spatialFiltersResolution.js

This file was deleted.

6 changes: 0 additions & 6 deletions packages/react-widgets/src/models/utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,3 @@ export function sourceAndFiltersToSQL(props: {
}): string;

export function getSqlEscapedSource(table: string, provider: Provider): string;

export function getSpatialFiltersResolution(props: {
source: SourceProps;
spatialDataType: string;
viewState: ViewState;
}): number;
8 changes: 1 addition & 7 deletions packages/react-widgets/src/models/utils.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import {
AggregationTypes,
_filtersToSQL,
Provider
} from '@carto/react-core';
import { AggregationTypes, _filtersToSQL, Provider } from '@carto/react-core';
import { FullyQualifiedName } from './fqn';
import { MAP_TYPES, API_VERSIONS } from '@carto/react-api';

export { getSpatialFiltersResolution } from './spatialFiltersResolution';

export function isRemoteCalculationSupported(props) {
const { source } = props;

Expand Down