Skip to content

Commit

Permalink
Update stop area seed data
Browse files Browse the repository at this point in the history
  • Loading branch information
suvikankare committed Dec 18, 2024
1 parent c28f41c commit c77f031
Showing 1 changed file with 92 additions and 28 deletions.
120 changes: 92 additions & 28 deletions test-db-manager/src/datasets/stopRegistry/stopArea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,97 @@ import { DateTime } from 'luxon';
import {
StopRegistryGeoJsonType,
StopRegistryGroupOfStopPlacesInput,
StopRegistryInterchangeWeightingType,
StopRegistryNameType,
StopRegistrySubmodeType,
} from '../../generated/graphql';
import { StopPlaceMaintenance } from './stopPlaces';

export type StopAreaSeedData = {
nameFin?: string;
nameSwe?: string;
nameFinLong?: string;
nameSweLong?: string;
abbreviationFin?: string;
abbreviationSwe?: string;
abbreviationFin5Char?: string;
abbreviationSwe5Char?: string;
label: string;
name: string;
organisations?: StopPlaceMaintenance;
locationLat: number;
locationLong: number;
validityStart: DateTime;
validityEnd?: DateTime;
members: Array<string>;
stopType?: {
mainLine: boolean;
interchange: boolean;
railReplacement: boolean;
virtual: boolean;
};
signs?: {
signType: string /* see StopPlaceSignType */;
note?: string;
numberOfFrames: number;
lineSignage: boolean;
mainLineSign: boolean;
replacesRailSign: boolean;
};
};

export type StopAreaInput = {
memberLabels: Array<string>;
stopArea: Partial<StopRegistryGroupOfStopPlacesInput>;
};

const mapToStopAreaInput = (seedStopArea: StopAreaSeedData): StopAreaInput => {
return {
memberLabels: seedStopArea.members,
stopArea: {
alternativeNames: [
seedStopArea.abbreviationFin5Char
? {
name: { lang: 'fin', value: seedStopArea.abbreviationFin5Char },
nameType: StopRegistryNameType.Label,
}
: null,
seedStopArea.abbreviationSwe5Char
? {
name: { lang: 'swe', value: seedStopArea.abbreviationSwe5Char },
nameType: StopRegistryNameType.Label,
}
: null,
seedStopArea.nameFinLong
? {
name: { lang: 'fin', value: seedStopArea.nameFinLong },
nameType: StopRegistryNameType.Alias,
}
: null,
seedStopArea.nameSweLong
? {
name: { lang: 'swe', value: seedStopArea.nameSweLong },
nameType: StopRegistryNameType.Alias,
}
: null,
seedStopArea.abbreviationFin
? {
name: { lang: 'fin', value: seedStopArea.abbreviationFin },
nameType: StopRegistryNameType.Other,
}
: null,
seedStopArea.abbreviationSwe
? {
name: { lang: 'swe', value: seedStopArea.abbreviationSwe },
nameType: StopRegistryNameType.Other,
}
: null,
{
name: { lang: 'swe', value: seedStopArea.nameSwe },
nameType: StopRegistryNameType.Translation,
},
],
privateCode: { type: 'HSL', value: seedStopArea.label },
name: {
lang: 'fin',
value: seedStopArea.label,
},
description: {
lang: 'fin',
value: seedStopArea.name,
},
validBetween: {
fromDate: seedStopArea.validityStart,
toDate: seedStopArea.validityEnd ?? null,
},
organisations: seedStopArea.organisations ?? null,
geometry:
seedStopArea.locationLat && seedStopArea.locationLong
? {
Expand All @@ -45,51 +103,57 @@ const mapToStopAreaInput = (seedStopArea: StopAreaSeedData): StopAreaInput => {
type: StopRegistryGeoJsonType.Point,
}
: null,
weighting: seedStopArea.stopType?.interchange
? StopRegistryInterchangeWeightingType.RecommendedInterchange
: undefined,
submode: seedStopAreas.signs?.railReplacement
? StopRegistrySubmodeType.RailReplacementBus
: undefined,
},
};
};

const basicStart = DateTime.fromISO('2020-01-01T00:00:00.001');
const basicEnd = DateTime.fromISO('2050-01-01T00:00:00.001');

const route35StopAreas: Array<StopAreaSeedData> = [
{
label: 'X1300',
name: 'Munkkivuori',
locationLat: 60.206001,
locationLong: 24.879646,
validityStart: basicStart,
validityEnd: basicEnd,
members: ['H1398', 'H1416'],
},
{
label: 'X1301',
name: 'Luuvaniementie',
locationLat: 60.205531,
locationLong: 24.883556,
validityStart: basicStart,
validityEnd: basicEnd,
members: ['H1451', 'H1452'],
},
{
label: 'X1302',
name: 'Rakuunantie',
locationLat: 60.20054,
locationLong: 24.883959,
validityStart: basicStart,
validityEnd: basicEnd,
members: ['H1456', 'H1458'],
},
];

const finnooSeedData: StopAreaSeedData = {
nameFin: 'Finnoo',
nameSwe: 'Finnoo',
nameFinLong: 'Finnoo',
nameSweLong: 'Finnoo',
abbreviationFin: 'Finnoo',
abbreviationSwe: 'Finnoo',
abbreviationFin5Char: 'Finnoo',
abbreviationSwe5Char: 'Finnoo',
label: 'X1234',
name: 'Finnoo',
validityStart: basicStart,
validityEnd: basicEnd,
locationLong: 24.708,
locationLat: 60.156,
members: ['E4464', 'E4461'],
organisations: {
cleaning: 'Clear Channel',
infoUpkeep: null,
maintenance: 'ELY-keskus',
owner: 'JCD',
winterMaintenance: 'ELY-keskus',
},
};

const seedData: Array<StopAreaSeedData> = [...route35StopAreas, finnooSeedData];
Expand Down

0 comments on commit c77f031

Please sign in to comment.