Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
majkshkurti committed Oct 23, 2024
1 parent 0786a24 commit d382b2e
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import { accessibilityIndicatorsStaticPayload } from "@/lib/constants/payloads";
import { setRunningJobIds } from "@/lib/store/jobs/slice";
import { setMaskLayer } from "@/lib/store/map/slice";
import { jobTypeEnum } from "@/lib/validations/jobs";
import { oevGueteklassenSchema, toolboxMaskLayerNames } from "@/lib/validations/tools";
import {
oevGueteklassenCatchmentType,
oevGueteklassenSchema,
toolboxMaskLayerNames,
} from "@/lib/validations/tools";

import type { SelectorItem } from "@/types/map/common";
import type { IndicatorBaseProps } from "@/types/map/toolbox";
Expand Down Expand Up @@ -43,6 +47,22 @@ const OevGueteklassen = ({ onBack, onClose }: IndicatorBaseProps) => {
const { filteredLayers } = useLayerByGeomType(["feature"], ["polygon"], projectId as string);
const [referenceLayer, setReferenceLayer] = useState<SelectorItem | undefined>(undefined);

const catchmentAreaTypes: SelectorItem[] = useMemo(() => {
return [
{
value: oevGueteklassenCatchmentType.Enum.buffer,
label: t("buffer"),
icon: ICON_NAME.BULLSEYE,
},
{
value: oevGueteklassenCatchmentType.Enum.network,
label: t("network"),
icon: ICON_NAME.STREET_NETWORK,
},
];
}, [t]);
const [catchmentArea, setCatchmentArea] = useState<SelectorItem | undefined>(catchmentAreaTypes[0]);

dispatch(setMaskLayer(toolboxMaskLayerNames.pt));

const {
Expand All @@ -67,6 +87,7 @@ const OevGueteklassen = ({ onBack, onClose }: IndicatorBaseProps) => {

const handleRun = async () => {
const payload = {
catchment_type: catchmentArea?.value,
reference_area_layer_project_id: referenceLayer?.value,
station_config: accessibilityIndicatorsStaticPayload,
time_window: {
Expand Down Expand Up @@ -96,6 +117,7 @@ const OevGueteklassen = ({ onBack, onClose }: IndicatorBaseProps) => {

const handleReset = () => {
setReferenceLayer(undefined);
setCatchmentArea(catchmentAreaTypes[0]);
resetPTConfiguration();
};

Expand Down Expand Up @@ -171,6 +193,32 @@ const OevGueteklassen = ({ onBack, onClose }: IndicatorBaseProps) => {
</>
}
/>

{/* CONFIGURATION */}
<SectionHeader
active={!!referenceLayer && isPTValid}
alwaysActive={true}
label={t("configuration")}
icon={ICON_NAME.SETTINGS}
disableAdvanceOptions={true}
/>

<SectionOptions
active={!!referenceLayer && isPTValid}
baseOptions={
<>
<Selector
selectedItems={catchmentArea}
setSelectedItems={(item: SelectorItem[] | SelectorItem | undefined) => {
setCatchmentArea(item as SelectorItem);
}}
items={catchmentAreaTypes}
label={t("oev_gueteklassen_catchement_area")}
tooltip={t("oev_gueteklassen_catchment_area_tooltip")}
/>
</>
}
/>
</Box>
</>
}
Expand Down
10 changes: 6 additions & 4 deletions apps/web/i18n/locales/de/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -326,14 +326,14 @@
"is_at_most": "Ist höchstens",
"is_before": "Ist vorher",
"is_between": "Liegt zwischen",
"is_empty_string": "Ist leer",
"is_blank": "Is blank",
"is_empty_string": "Ist leer",
"is_greater_than": "Ist größer als",
"is_less_than": "Ist weniger als",
"is_not": "Ist nicht",
"is_not_between": "Liegt nicht dazwischen",
"is_not_empty_string": "Ist nicht leer",
"is_not_blank": "Is not blank",
"is_not_empty_string": "Ist nicht leer",
"is_not_on": "Ist nicht eingeschaltet",
"is_on": "Ist eingeschaltet",
"not_in_the_last": "Nicht im letzten",
Expand Down Expand Up @@ -532,8 +532,8 @@
},
"type": {
"feature": "Feature",
"table": "Table",
"raster": "Raster"
"raster": "Raster",
"table": "Table"
}
},
"metadata_updated_error": "Fehler beim aktualisieren der Metadaten",
Expand Down Expand Up @@ -599,6 +599,8 @@
"oev_gueteklasse": "ÖV-Güteklassen",
"oev_gueteklasse_description": "ÖV-Güteklassen zeigen die Attraktivität des öffentlichen Verkehrs in einem bestimmten Gebiet an.",
"oev_gueteklasse_header": "ÖV-Güteklassen",
"oev_gueteklassen_catchement_area": "Einzugsgebietstyp",
"oev_gueteklassen_catchment_area_tooltip": "Erreichbarkeit von Bahnhöfen über Pufferstrecke oder Straßennetzrouting",
"oev_gueteklassen_computation_started": "Berechnung der ÖV-Güteklassen gestartet",
"oev_guteklassen": "ÖV-Güteklassen",
"ok": "OK",
Expand Down
10 changes: 6 additions & 4 deletions apps/web/i18n/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -326,14 +326,14 @@
"is_at_most": "Is at most",
"is_before": "Is before",
"is_between": "Is between",
"is_empty_string": "Is empty string",
"is_blank": "Is blank",
"is_empty_string": "Is empty string",
"is_greater_than": "Is greater than",
"is_less_than": "Is less than",
"is_not": "Is not",
"is_not_between": "Is not between",
"is_not_empty_string": "Is not empty string",
"is_not_blank": "Is not blank",
"is_not_empty_string": "Is not empty string",
"is_not_on": "Is not on",
"is_on": "Is on",
"not_in_the_last": "Not in the last",
Expand Down Expand Up @@ -532,8 +532,8 @@
},
"type": {
"feature": "Feature",
"table": "Table",
"raster": "Raster"
"raster": "Raster",
"table": "Table"
}
},
"metadata_updated_error": "Error updating metadata",
Expand Down Expand Up @@ -599,6 +599,8 @@
"oev_gueteklasse": "ÖV-Güteklassen",
"oev_gueteklasse_description": "The Public Transport Quality Classes (German: ÖV-Güteklassen) show the attractiveness of public transport services for a selected area.",
"oev_gueteklasse_header": "ÖV-Güteklassen",
"oev_gueteklassen_catchement_area": "Catchment area type",
"oev_gueteklassen_catchment_area_tooltip": "Accessiblity to stations using buffer distance or street network routing",
"oev_gueteklassen_computation_started": "ÖV-Güteklassen computation started",
"oev_guteklassen": "ÖV-Güteklassen",
"ok": "ok",
Expand Down
7 changes: 5 additions & 2 deletions apps/web/lib/validations/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ export type PostActiveMobilityAndCarCatchmentArea = z.infer<typeof activeMobilit
export type PostPTCatchmentArea = z.infer<typeof ptCatchmentAreaSchema>;

//**=== OEV-GUETEKLASSEN + TRIP COUNT === */
const stationConfigSchema = z.object({
export const oevGueteklassenCatchmentType = z.enum(["buffer", "network"]);
export const stationConfigSchema = z.object({
groups: z.record(z.string()),
time_frequency: z.array(z.number()),
categories: z.array(z.record(z.number())),
Expand All @@ -150,7 +151,9 @@ export const tripCountSchema = z.object({
scenario_id: z.string().optional(),
});

export const oevGueteklassenSchema = tripCountSchema.extend({});
export const oevGueteklassenSchema = tripCountSchema.extend({
catchment_type: oevGueteklassenCatchmentType.default("buffer")
});

export type PostTripCount = z.infer<typeof tripCountSchema>;
export type PostOevGueteKlassen = z.infer<typeof oevGueteklassenSchema>;
Expand Down

0 comments on commit d382b2e

Please sign in to comment.