Skip to content

Commit

Permalink
CR + floor quadbin spatialFiltersResolution
Browse files Browse the repository at this point in the history
  • Loading branch information
zbigg committed Sep 5, 2024
1 parent cdeb4cf commit debeec3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions packages/react-api/src/api/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function executeModel(props) {

if (!spatialDataType || !spatialDataColumn) {
if (source.geoColumn) {
const parsedGeoColumn = source.geoColumn ? source.geoColumn.split(':') : [];
const parsedGeoColumn = source.geoColumn.split(':');
if (parsedGeoColumn.length === 2) {
spatialDataType = parsedGeoColumn[0];
spatialDataColumn = parsedGeoColumn[1];
Expand All @@ -82,7 +82,7 @@ export function executeModel(props) {
spatialDataType = 'geo';
}
if (spatialDataType === 'geom') {
// fallback if for some reason someone provided old `geom:whatever`
// fallback if for some reason someone provided old `geom:$column`
spatialDataType = 'geo';
}
} else {
Expand Down
3 changes: 1 addition & 2 deletions packages/react-api/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export type SourceProps = {
type: MapTypesType['QUERY'] | MapTypesType['TABLE'] | MapTypesType['TILESET'];
connection: string;
geoColumn?: string;
dataResoultion?: number;
dataResolution?: number;
spatialDataType?: string;
spatialDataColumn?: string;
spatialFiltersResolution?: number;
Expand Down Expand Up @@ -77,4 +77,3 @@ export type UseCartoLayerFilterProps = {
};

export type ExecuteSQLResponse<Response = FeatureCollection | {}[]> = Promise<Response>;

13 changes: 7 additions & 6 deletions packages/react-widgets/src/hooks/useWidgetFetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,13 @@ export default function useWidgetFetch(
[global, viewport, spatialFilter]
);

const source2 = useMemo(() => {
const enrichedSource = useMemo(() => {
if (
!source ||
!geometryToIntersect ||
!source.dataResolution ||
source.spatialDataType === 'geo'
source.spatialDataType === 'geo' ||
source.spatialFiltersResolution !== undefined ||
!source.dataResolution
) {
return source;
}
Expand All @@ -128,7 +129,7 @@ export default function useWidgetFetch(
};
}
if (source.spatialDataType === 'quadbin') {
const quadsResolution = viewState.zoom;
const quadsResolution = Math.floor(viewState.zoom);
return {
...source,
spatialFiltersResolution: Math.min(source.dataResolution, quadsResolution)
Expand All @@ -150,7 +151,7 @@ export default function useWidgetFetch(
onStateChange?.({ state: WidgetStateType.Loading });

modelFn({
source: source2,
source: enrichedSource,
...params,
global,
remoteCalculation,
Expand Down Expand Up @@ -185,7 +186,7 @@ export default function useWidgetFetch(
},
[
params,
source2,
enrichedSource,
onError,
isSourceReady,
global,
Expand Down

0 comments on commit debeec3

Please sign in to comment.