Skip to content

Commit 535730c

Browse files
Merge pull request #1017 from ibi-group/pattern-location-groups-july-2024
Location Groups July 2024
2 parents 0ad1da4 + 6b56a71 commit 535730c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+953
-717
lines changed

gtfs.yml

+29-7
Original file line numberDiff line numberDiff line change
@@ -650,10 +650,20 @@
650650
inputType: TIME
651651
columnWidth: 6
652652
- name: "stop_id"
653-
required: true
653+
required: false
654654
inputType: GTFS_STOP
655655
columnWidth: 6
656656
helpContent: "The stop_id field contains an ID that uniquely identifies a stop. Multiple routes may use the same stop. The stop_id is referenced from the stops.txt file. If location_type is used in stops.txt, all stops referenced in stop_times.txt must have location_type of 0."
657+
- name: "location_id"
658+
required: false
659+
inputType: GTFS_ID
660+
columnWidth: 6
661+
helpContent: "The location_id field contains an ID that uniquely identifies a location. Multiple routes may use the same stop. The stop_id is referenced from the stops.txt file. If location_type is used in stops.txt, all stops referenced in stop_times.txt must have location_type of 0."
662+
- name: "location_group_id"
663+
required: false
664+
inputType: TEXT
665+
columnWidth: 6
666+
helpContent: "The location_group_id field contains an ID that uniquely identifies a location group. Multiple routes may use the same stop. The stop_id is referenced from the stops.txt file. If location_type is used in stops.txt, all stops referenced in stop_times.txt must have location_type of 0."
657667
- name: "stop_sequence"
658668
required: true
659669
inputType: POSITIVE_INT
@@ -1162,6 +1172,16 @@
11621172
helpContent: "The stop_url field contains the URL of a web page about a particular location. This should be different from the agency_url and the route_url fields."
11631173

11641174
# FIXME: helpContent is lifted from https://github.com/MobilityData/gtfs-flex/blob/master/spec/reference.md
1175+
- id: locationgroupstop
1176+
flex: true
1177+
name: location_group_stops.txt
1178+
fields:
1179+
- name: "location_group_id"
1180+
required: true
1181+
inputType: TEXT
1182+
- name: "stop_id"
1183+
required: true
1184+
inputType: GTFS_ID
11651185
- id: locationgroup
11661186
flex: true
11671187
name: location_groups.txt
@@ -1178,9 +1198,11 @@
11781198
inputType: TEXT
11791199
columnWidth: 12
11801200
helpContent: "Name of the location group. Must be defined either once, or exhaustively for a single location_group_id."
1181-
# TODO: enable validation to match spec (only appear when appropriate)
1182-
- name: "location_id"
1183-
required: false
1184-
inputType: GTFS_STOP_OR_LOCATION_LIST
1185-
columnWidth: 12
1186-
helpContent: "Identifies a stop or location belonging to the location group."
1201+
extraFields:
1202+
- name: "stop_id"
1203+
required: false
1204+
inputType: GTFS_STOP_OR_LOCATION_LIST
1205+
columnWidth: 12
1206+
helpContent: "Identifies a stop or location belonging to the location group."
1207+
activeComponentOverride: "locationgroupstop"
1208+

i18n/polish.yml

+7
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ components:
381381
autoPublish: Automatycznie publikuj
382382
dateFormat: MMM D, YYYY
383383
deployable: Rozmieszczany
384+
flex: Flexible service
384385
edit: Edytować
385386
lastUpdatedDate: Last updated %date%
386387
noUpdates: No updates
@@ -632,6 +633,10 @@ components:
632633
title: Real-time updaters
633634
walkSpeed: Walk Speed
634635
GeneralSettings:
636+
flex:
637+
title: Flex Service
638+
checkbox: Feed includes flex service
639+
description: Enable this feed source to include flex service. Checking this checkbox will enable flex tools in the editor. Flex service describes operations that follow a schedule, but also include flexible features such as dial-a-ride service, route deviation, continuous stops, or point to zone service.
635640
autoFetch:
636641
checkbox: Auto fetch feed source
637642
hint: Set this feed source to fetch automatically. (Feed source URL must be
@@ -744,6 +749,8 @@ components:
744749
stop:
745750
label: Stops
746751
title: Edit stops
752+
GtfsServiceSelect:
753+
placeholder: Select existing service ID
747754
GtfsValidationExplorer:
748755
accessibilityValidation: Accessibility Explorer
749756
table:

lib/editor/actions/active.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import {
3030
removeEditorLock
3131
} from './editor'
3232
import {saveTripPattern} from './tripPattern'
33-
import { saveLocation } from './location'
33+
import { saveLocation, saveLocationGroup } from './location'
3434

3535
export const clearGtfsContent = createVoidPayloadAction('CLEAR_GTFSEDITOR_CONTENT')
3636
export const receivedNewEntity = createAction(
@@ -373,6 +373,8 @@ export function saveActiveGtfsEntity (
373373
return dispatch(saveTripPattern(feedId, (entity: any)))
374374
case 'location':
375375
return dispatch(saveLocation(feedId, (entity: any), refetch))
376+
case 'locationgroup':
377+
return dispatch(saveLocationGroup(feedId, (entity: any), refetch))
376378
default:
377379
// Default method for agencies, stops, routes, fares, calendars.
378380
// Trip patterns and feed info are handled above. Trips are handled in

lib/editor/actions/editor.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ function getCloneProps (entityId: number, component: string, state: AppState) {
7777
patternId: newPatternId,
7878
shapeId: newShapeId,
7979
shapePoints: pattern.shapePoints.map(sp => ({...sp, shapeId: newShapeId})),
80-
patternLocationGroups: pattern.patternLocationGroups && pattern.patternLocationGroups.map(plg => ({...plg, patternId: newPatternId})),
81-
patternLocations: pattern.patternLocations.map(pl => ({...pl, patternId: newPatternId})),
8280
patternStops: pattern.patternStops.map(ps => ({...ps, patternId: newPatternId}))
8381
}
8482
case 'route':
@@ -480,9 +478,12 @@ export function fetchBaseGtfs ({
480478
location_groups {
481479
id
482480
location_group_id
483-
location_id
484481
location_group_name
485482
}
483+
location_group_stops {
484+
location_group_id
485+
stop_id
486+
}
486487
feed_info {
487488
id
488489
feed_id

lib/editor/actions/location.js

+65
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,71 @@ import type {GtfsLocation} from '../../types'
88

99
import { receivedNewEntity, savedGtfsEntity } from './active'
1010

11+
// FLEX TODO: The two big dispatch blocks are almost the same... Would it be possible to extract them (such as saveEntity('locationgroup', locationGroupUrl) and same for locationgroupstop)?
12+
export function saveLocationGroup (
13+
feedId: ?string,
14+
locationGroup: GtfsLocation,
15+
refetch: ?boolean = true
16+
) {
17+
return function (dispatch: dispatchFn, getState: getStateFn) {
18+
if (!feedId || !locationGroup) {
19+
return
20+
}
21+
// dispatch(savingActiveLocation()) //Update this?
22+
23+
const notNew = !entityIsNew(locationGroup) // Checks if id is -2 or undefined
24+
const method = notNew ? 'put' : 'post'
25+
const idParam = notNew ? `/${locationGroup.id || ''}` : ''
26+
const {sessionId} = getState().editor.data.lock
27+
28+
const mappingStrategy = getMapFromGtfsStrategy('locationGroup')
29+
const data = mappingStrategy(locationGroup)
30+
31+
const locationGroupUrl = `/api/editor/secure/locationgroup${idParam}?feedId=${feedId}&sessionId=${sessionId || ''}`
32+
const locationGroupStopsUrl = `/api/editor/secure/locationgroupstop${idParam}?feedId=${feedId}&sessionId=${sessionId || ''}`
33+
34+
dispatch(secureFetch(locationGroupStopsUrl, method, data))
35+
.then(res => res.json())
36+
.then(savedEntity => {
37+
dispatch(savedGtfsEntity())
38+
const namespace = getEditorNamespace(feedId, getState())
39+
// Refetch entity and replace in store
40+
if (refetch) {
41+
dispatch(fetchGTFSEntities({
42+
editor: true,
43+
id: savedEntity.id,
44+
namespace,
45+
replaceNew: !notNew,
46+
type: 'locationgroupstop'
47+
}))
48+
} else {
49+
// Push new entity into store.
50+
dispatch(receivedNewEntity({component: 'locationgroupstop', entity: savedEntity}))
51+
}
52+
})
53+
return dispatch(secureFetch(locationGroupUrl, method, data))
54+
.then(res => res.json())
55+
.then(savedEntity => {
56+
dispatch(savedGtfsEntity())
57+
const namespace = getEditorNamespace(feedId, getState())
58+
// Refetch entity and replace in store
59+
if (refetch) {
60+
dispatch(fetchGTFSEntities({
61+
editor: true,
62+
id: savedEntity.id,
63+
namespace,
64+
replaceNew: !notNew,
65+
type: 'locationgroup'
66+
}))
67+
} else {
68+
// Push new entity into store.
69+
dispatch(receivedNewEntity({component: 'locationgroup', entity: savedEntity}))
70+
Promise.resolve(savedEntity)
71+
}
72+
})
73+
}
74+
}
75+
1176
export function saveLocation (
1277
feedId: ?string,
1378
location: GtfsLocation,

0 commit comments

Comments
 (0)