Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extent fix #1114

Merged
merged 1 commit into from
Apr 24, 2024
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
62 changes: 32 additions & 30 deletions src/containers/datasets/habitat-extent/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -232,34 +232,36 @@ export function useLayers({
opacity?: number;
visibility?: Visibility;
}): LayerProps[] {
return [
{
id: `${id}_${year}_line`,
type: 'fill',
source: 'habitat_extent',
'source-layer': `mng_mjr_${year}`,
paint: {
'fill-color': '#06C4BD',
'fill-opacity': opacity,
},
layout: {
visibility,
},
},
{
id: `${id}_${year}_fill`,
type: 'line',
source: 'habitat_extent',
'source-layer': `mng_mjr_${year}`,
paint: {
'line-color': '#06C4BD',
'line-opacity': opacity,
'line-width': ['interpolate', ['exponential', 0.7], ['zoom'], 0, 8, 12, 0],
'line-blur': ['interpolate', ['linear'], ['zoom'], 0, 20, 12, 0],
},
layout: {
visibility,
},
},
];
return year
? [
{
id: `${id}_${year}_line`,
type: 'fill',
source: 'habitat_extent',
'source-layer': `mng_mjr_${year}`,
paint: {
'fill-color': '#06C4BD',
'fill-opacity': opacity,
},
layout: {
visibility,
},
},
{
id: `${id}_${year}_fill`,
type: 'line',
source: 'habitat_extent',
'source-layer': `mng_mjr_${year}`,
paint: {
'line-color': '#06C4BD',
'line-opacity': opacity,
'line-width': ['interpolate', ['exponential', 0.7], ['zoom'], 0, 8, 12, 0],
'line-blur': ['interpolate', ['linear'], ['zoom'], 0, 20, 12, 0],
},
layout: {
visibility,
},
},
]
: null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import Loading from 'components/loading';
import MultiSelect from 'components/select-multi';
import { WIDGET_CARD_WRAPPER_STYLE, BUTTON_STYLES } from 'styles/widgets';

import type { DataSites } from '../types';
import type { DataDitesProperties } from '../types';

type FilterSitesProps = {
open: boolean;
onChangeModalVisibility: Dispatch<SetStateAction<boolean>>;
filters: { [key: string]: string[] | number[] };
data: DataSites[];
data: DataDitesProperties[];
setFilters: Dispatch<SetStateAction<{ [key: string]: string[] | number[] }>>;
isFetching: boolean;
isFetched: boolean;
Expand Down
22 changes: 3 additions & 19 deletions src/containers/datasets/restoration-sites/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from 'store/widgets/restoration-sites';

import { useQuery, UseQueryOptions } from '@tanstack/react-query';
import { GeoJsonProperties, GeoJsonTypes } from 'geojson';
import { Visibility } from 'mapbox-gl';
import { useRecoilValue } from 'recoil';

Expand All @@ -18,7 +19,7 @@ import type { UseParamsOptions } from 'types/widget';

import API from 'services/api';

import type { Data, DataResponse, DataFilters } from './types';
import type { Data, DataResponse, DataFilters, RestorationSite } from './types';

// widget data
export function useMangroveRestorationSites(
Expand Down Expand Up @@ -113,6 +114,7 @@ export function useSource(): SourceProps {
});

if (!restorationSiteFeatures) return null;

return {
id: 'mangrove_rest_sites',
type: 'geojson',
Expand Down Expand Up @@ -171,24 +173,6 @@ export function useLayer({
visibility,
},
},
{
id: `${id}-cluster-text`,
metadata: {
position: 'top',
},
type: 'symbol',
filter: ['!', ['has', 'point_count']],
layout: {
'text-field': ['get', 'site_name'],
'text-font': ['Open Sans Bold', 'Arial Unicode MS Bold'],
'text-size': 12,
visibility,
},
paint: {
'text-color': '#ffffff',
'text-opacity': opacity,
},
},
{
id: `${id}-cluster-count`,
metadata: {
Expand Down
12 changes: 10 additions & 2 deletions src/containers/datasets/restoration-sites/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type DataSites = {
export type DataDitesProperties = {
id: number;
landscape_id: number;
landscape_name: string;
Expand All @@ -7,9 +7,17 @@ export type DataSites = {
site_name: string;
organizations: string;
};
interface RestorationSite {
type: 'Feature';
geometry: {
type: string;
coordinates: [number, number];
};
properties: DataDitesProperties;
}

export type Data = {
data: DataSites[];
data: RestorationSite[];
location: string;
};

Expand Down
Loading