Implementation
static final List<FieldDefinition> staticFieldDefinitions = [
FieldDefinition(
'stop_id',
(existingDataset, rawHeader, records) => true,
type: const IdFieldType(displayName: 'Stop ID'),
primaryKey: true,
),
FieldDefinition(
'stop_code',
(existingDataset, rawHeader, records) => null,
type: const TextFieldType(),
),
FieldDefinition(
'stop_name',
(existingDataset, rawHeader, records) => null,
type: const TextFieldType(),
shouldBeRequired:
(dataset, header, record) =>
['', '0', '1', '2'].contains(record['location_type'])
? true
: null,
),
FieldDefinition(
'tts_stop_name',
(dataset, header, records) => null,
type: const TextFieldType(),
),
FieldDefinition(
'stop_desc',
(dataset, header, records) => null,
type: const TextFieldType(),
),
FieldDefinition(
'stop_lat',
(dataset, header, records) => null,
shouldBeRequired:
(dataset, header, record) =>
['', '0', '1', '2'].contains(record['location_type'])
? true
: null,
type: const LatitudeFieldType(),
),
FieldDefinition(
'stop_lon',
(dataset, header, records) => null,
shouldBeRequired:
(dataset, header, record) =>
['', '0', '1', '2'].contains(record['location_type'])
? true
: null,
type: const LongitudeDataType(),
),
FieldDefinition(
'zone_id',
(dataset, header, records) => null,
type: const IdFieldType(displayName: 'Zone ID'),
),
FieldDefinition(
'stop_url',
(dataset, header, records) => null,
type: const UrlFieldType(),
),
FieldDefinition(
'location_type',
(dataset, header, records) => null,
type: locationIdField,
defaultValue: '0',
),
FieldDefinition(
'parent_station',
(dataset, header, records) => null,
shouldBeRequired:
(dataset, header, record) =>
['2', '3', '4'].contains(record['location_type'])
? true
: (['', '0'].contains(record['location_type'])
? null
: false),
type: const IdFieldType(displayName: 'Stop ID'),
),
FieldDefinition(
'stop_timezone',
(dataset, header, records) => null,
type: const TimezoneFieldType(),
),
FieldDefinition(
'wheelchair_boarding',
(dataset, header, records) => null,
type: wheelchairBoarding,
defaultValue: '0',
),
FieldDefinition(
'level_id',
(dataset, header, records) => null,
type: const IdFieldType(displayName: 'Level ID'),
),
FieldDefinition(
'platform_code',
(dataset, header, records) => null,
type: const TextFieldType(),
),
];