Skip to content

Commit

Permalink
Merge pull request #1075 from DonovanAndrews300/donovan/main-zone-fil…
Browse files Browse the repository at this point in the history
…tering

Filters By Main Property Zones
  • Loading branch information
CodeWritingCow authored Jan 11, 2025
2 parents a5876ef + 5bf55f0 commit 01c2722
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 33 deletions.
56 changes: 23 additions & 33 deletions src/components/Filters/filterOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,39 +414,29 @@ export const rcos: string[] = [
];

export const zoning: string[] = [
'CA-1',
'CA-2',
'CMX-1',
'CMX-2',
'CMX-2.5',
'CMX-3',
'CMX-4',
'CMX-5',
'I-1',
'I-2',
'I-3',
'I-P',
'CA',
'CMX',
'I',
'ICMX',
'IRMX',
'RM-1',
'RM-2',
'RM-3',
'RM-4',
'RMX-1',
'RMX-2',
'RMX-3',
'RSA-1',
'RSA-2',
'RSA-3',
'RSA-4',
'RSA-5',
'RSA-6',
'RSD-1',
'RSD-2',
'RSD-3',
'RTA-1',
'SP-AIR',
'SP-INS',
'SP-PO-A',
'SP-STA',
'RM',
'RMX',
'RSA',
'RSD',
'RTA',
'SP',
];

export const subZoning: Record<string, string[]> = {
CA: ['CA-1', 'CA-2'],
CMX: ['CMX-1', 'CMX-2', 'CMX-2.5', 'CMX-3', 'CMX-4', 'CMX-5'],
I: ['I-1', 'I-2', 'I-3', 'I-P'],
ICMX: ['ICMX'],
IRMX: ['IRMX'],
RM: ['RM-1', 'RM-2', 'RM-3', 'RM-4'],
RMX: ['RMX-1', 'RMX-2', 'RMX-3'],
RSA: ['RSA-1', 'RSA-2', 'RSA-3', 'RSA-4', 'RSA-5', 'RSA-6'],
RSD: ['RSD-1', 'RSD-2', 'RSD-3'],
RTA: ['RTA-1'],
SP: ['SP-AIR', 'SP-INS', 'SP-PO-A', 'SP-STA'],
};
14 changes: 14 additions & 0 deletions src/components/PropertyMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
useStagingTiles,
googleCloudBucketName,
} from '../config/config';
import { subZoning } from './Filters/filterOptions';
import { useFilter } from '@/context/FilterContext';
import Map, {
Source,
Expand Down Expand Up @@ -357,6 +358,19 @@ const PropertyMap: FC<PropertyMapProps> = ({
} else {
thisFilterGroup.push(['in', ['get', property], item]);
}
if (Object.keys(subZoning).includes(item)) {
subZoning[item].forEach((subZone: string) => {
if (filterItem) {
thisFilterGroup.push([
'>=',
['index-of', subZone, ['get', property]],
0,
]);
} else {
thisFilterGroup.push(['in', ['get', property], subZone]);
}
});
}
});

acc.push(thisFilterGroup);
Expand Down

0 comments on commit 01c2722

Please sign in to comment.