From 435149d718193c89d3097aa1abe2a3ca4fabf76b Mon Sep 17 00:00:00 2001 From: Eric van der Vlist Date: Sat, 8 Jul 2023 10:52:02 +0200 Subject: [PATCH] Activities and categories, WIP --- src/lib/osm/activities-and-categories.ts | 30 +++++++++++++++++ ...tagsStatus.test.ts => tags-status.test.ts} | 2 +- src/lib/osm/{tagsStatus.ts => tags-status.ts} | 32 ++++++------------- 3 files changed, 40 insertions(+), 24 deletions(-) create mode 100644 src/lib/osm/activities-and-categories.ts rename src/lib/osm/{tagsStatus.test.ts => tags-status.test.ts} (95%) rename src/lib/osm/{tagsStatus.ts => tags-status.ts} (65%) diff --git a/src/lib/osm/activities-and-categories.ts b/src/lib/osm/activities-and-categories.ts new file mode 100644 index 0000000..35e5805 --- /dev/null +++ b/src/lib/osm/activities-and-categories.ts @@ -0,0 +1,30 @@ +export interface TagFormatDefinition {} + +interface TagCategoryDefinitions { + [key: string]: TagFormatDefinition; +} + +export enum TagType { + ROUTE = 'route', + POI = 'poi', +} + +interface TagActivityDefinitions { + route?: { [key: string]: TagCategoryDefinitions }; + poi?: { [key: string]: TagCategoryDefinitions }; +} + +export interface TagDefinitions { + [key: string]: TagActivityDefinitions; +} + +interface TagActivitiesAndCategories { + [activity: string]: { + route?: { [key: string]: string[] }; + poi?: { [key: string]: string[] }; + }; +} + +export const getTagActivitiesAndCategories = ( + definitions: TagDefinitions +) => {}; diff --git a/src/lib/osm/tagsStatus.test.ts b/src/lib/osm/tags-status.test.ts similarity index 95% rename from src/lib/osm/tagsStatus.test.ts rename to src/lib/osm/tags-status.test.ts index 76506f3..6114d5f 100644 --- a/src/lib/osm/tagsStatus.test.ts +++ b/src/lib/osm/tags-status.test.ts @@ -1,5 +1,5 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; -import { getTagStatus } from './tagsStatus'; +import { getTagStatus } from './tags-status'; describe('The getTagStatus function', () => { it('should return undefined/false for a tag that does NOT exist', () => { diff --git a/src/lib/osm/tagsStatus.ts b/src/lib/osm/tags-status.ts similarity index 65% rename from src/lib/osm/tagsStatus.ts rename to src/lib/osm/tags-status.ts index 4c7bbb8..95f773b 100644 --- a/src/lib/osm/tagsStatus.ts +++ b/src/lib/osm/tags-status.ts @@ -1,22 +1,8 @@ -interface TagFormatDefinition {} - -interface TagCategoryDefinitions { - [key: string]: TagFormatDefinition; -} - -enum TagType { - ROUTE = 'route', - POI = 'poi', -} - -interface TagActivityDefinitions { - route?: { [key: string]: TagCategoryDefinitions }; - poi?: { [key: string]: TagCategoryDefinitions }; -} - -interface TagDefinitions { - [key: string]: TagActivityDefinitions; -} +import { + TagDefinitions, + TagFormatDefinition, + TagType, +} from './activities-and-categories'; interface TagStatus { type?: TagType; @@ -29,8 +15,8 @@ export const getTagStatus = ( definitions: TagDefinitions, selectedKey: string, highlightedKey: string -) => { - const defaultStatus: TagStatus = { +): TagStatus => { + const defaultStatus = { highlighted: false, }; const activityDefinitions = definitions[selectedKey]; @@ -47,7 +33,7 @@ export const getTagStatus = ( if (!!highlightedDefinitions) { const definition = highlightedDefinitions[tag]; if (!!definition) { - return { type, definition, highlighted: true } as TagStatus; + return { type, definition, highlighted: true }; } } @@ -56,7 +42,7 @@ export const getTagStatus = ( const categoryDefinitions = typeDefinitions[category]; const definition = categoryDefinitions[tag]; if (!!definition) { - return { type, definition, highlighted: false } as TagStatus; + return { type, definition, highlighted: false }; } } }