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 07c0cfe
Showing 1 changed file with 68 additions and 24 deletions.
92 changes: 68 additions & 24 deletions test-db-manager/src/datasets/stopRegistry/stopArea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,76 @@ import { DateTime } from 'luxon';
import {
StopRegistryGeoJsonType,
StopRegistryGroupOfStopPlacesInput,
StopRegistryInterchangeWeightingType,
StopRegistryNameType,
StopRegistrySubmodeType,
} from '../../generated/graphql';

export type StopAreaSeedData = {
nameFin?: string;
nameSwe?: string;
nameFinLong?: string;
nameSweLong?: string;
abbreviationFin?: string;
abbreviationSwe?: string;
abbreviationFin5Char?: string;
abbreviationSwe5Char?: string;
label: string;
name: string;
locationLat: number;
locationLong: number;
validityStart: DateTime;
validityEnd?: DateTime;
members: Array<string>;
};

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.signs.signType },
name: {
lang: 'fin',
value: seedStopArea.label,
Expand All @@ -31,10 +80,6 @@ const mapToStopAreaInput = (seedStopArea: StopAreaSeedData): StopAreaInput => {
lang: 'fin',
value: seedStopArea.name,
},
validBetween: {
fromDate: seedStopArea.validityStart,
toDate: seedStopArea.validityEnd ?? null,
},
geometry:
seedStopArea.locationLat && seedStopArea.locationLong
? {
Expand All @@ -45,51 +90,50 @@ const mapToStopAreaInput = (seedStopArea: StopAreaSeedData): StopAreaInput => {
type: StopRegistryGeoJsonType.Point,
}
: null,
weighting: seedStopArea.interchange
? StopRegistryInterchangeWeightingType.RecommendedInterchange
: undefined,
submode: seedStopArea.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'],
};

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

0 comments on commit 07c0cfe

Please sign in to comment.