Make Mol the primary operating context
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import type { DatasetCreateResponse, ProjectRead } from '../types'
|
||||
|
||||
export const PRIMARY_FOCUS_LABEL = 'Mol'
|
||||
export const PRIMARY_FOCUS_REGION = 'Mol, Kempen'
|
||||
export const PRIMARY_FOCUS_CENTER: [number, number] = [5.1167, 51.1919]
|
||||
export const PRIMARY_FOCUS_AREA_NAME = 'Mol primary AOI'
|
||||
export const PRIMARY_FOCUS_AREA_GEOJSON =
|
||||
'{"type":"MultiPolygon","coordinates":[[[[5.109476746222376,51.18745107550715],[5.123924622861509,51.18745107550715],[5.123924622861509,51.19634848029239],[5.109476746222376,51.19634848029239],[5.109476746222376,51.18745107550715]]]]}'
|
||||
|
||||
const PRIMARY_FOCUS_TOKEN = /(^|[^a-z0-9])mol([^a-z0-9]|$)/i
|
||||
|
||||
function containsPrimaryFocus(values: Array<string | null | undefined>): boolean {
|
||||
return values.some((value) => Boolean(value && PRIMARY_FOCUS_TOKEN.test(value)))
|
||||
}
|
||||
|
||||
export function isPrimaryFocusProject(project: ProjectRead): boolean {
|
||||
return containsPrimaryFocus([project.name, project.description, project.region])
|
||||
}
|
||||
|
||||
export function isPrimaryFocusProjectData(
|
||||
project: ProjectRead,
|
||||
datasets: DatasetCreateResponse[],
|
||||
): boolean {
|
||||
if (isPrimaryFocusProject(project)) {
|
||||
return true
|
||||
}
|
||||
return datasets.some((dataset) =>
|
||||
containsPrimaryFocus([
|
||||
dataset.name,
|
||||
dataset.original_filename,
|
||||
dataset.stored_filename,
|
||||
dataset.storage_path,
|
||||
dataset.source_name,
|
||||
dataset.reference_layer_name,
|
||||
]),
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user