Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Location Groups July 2024 #1017

Open
wants to merge 23 commits into
base: dev-flex-2024
Choose a base branch
from

Conversation

miles-grant-ibigroup
Copy link
Contributor

@miles-grant-ibigroup miles-grant-ibigroup commented Jul 11, 2024

Location Group support following latest flex spec. Works with data tools-server dev-flex branch

@miles-grant-ibigroup miles-grant-ibigroup self-assigned this Jul 11, 2024
@miles-grant-ibigroup miles-grant-ibigroup changed the base branch from dev to dev-flex-2024 July 11, 2024 18:43
@miles-grant-ibigroup miles-grant-ibigroup added WIP BLOCKED Blocked (waiting on another PR to be merged) Flex labels Jul 11, 2024
@clinephi
Copy link

Excited for this update!

@ibi-group ibi-group locked as too heated and limited conversation to collaborators Sep 12, 2024
@miles-grant-ibigroup miles-grant-ibigroup marked this pull request as ready for review September 17, 2024 14:36
@miles-grant-ibigroup miles-grant-ibigroup removed the BLOCKED Blocked (waiting on another PR to be merged) label Dec 16, 2024
Copy link
Contributor

@binh-dam-ibigroup binh-dam-ibigroup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First round of comments.

if (refetch) {
dispatch(fetchGTFSEntities({
namespace,
id: savedEntity.id,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sort attributes (2 instances)

dispatch(receivedNewEntity({component: 'locationgroupstop', entity: savedEntity}))
}
})
return dispatch(secureFetch(locationGroupUrl, method, data))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)?

@@ -207,8 +208,7 @@ export function addStopAtInterval (latlng: LatLng, activePattern: Pattern, contr
const stopControlPoint = result.controlPoints[controlPoints.length + index]
const patternStop = stopToPatternStop(s)
// Set pattern stop's shape dist traveled.
if (patternHaltIsStop(patternStop)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't expect TS to make us inline so much code...

patternStop={patternStop} />
}
if (locationGroup) {
// 2024 TODO: support rendering location groups. will be tricky. need to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove "2024" or replace with "2025"!


// find center to simulate stop
const center = centerOfMass(turfPolygon([polygon]))
if (center.geometry.coordinates) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extract a variable for center.geometry.coordinates.

}
addStopToPattern={addStopToPattern}
index={index}
key={patternStop.id}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should key be the same as ref? The ref value implies that key could be null.

@@ -122,6 +124,7 @@ export default class EditShapePanel extends Component<Props> {
saveActiveGtfsEntity,
showConfirmModal,
stops,
locations, locationGroups,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Insert new line between props.

cardBackground = 'hsla(187, 84%, 87%, 0.5)'
}
// $FlowFixMe flexDefaultTravelTime doens't exist on a PatternStop, which is the point of this check
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo

Suggested change
// $FlowFixMe flexDefaultTravelTime doens't exist on a PatternStop, which is the point of this check
// $FlowFixMe flexDefaultTravelTime doesn't exist on a PatternStop, which is the point of this check

Comment on lines +303 to 315
if (patternStop.stopId !== null) {
this.setState({
// $FlowFixMe flow doesn't like our "type check"
initialDwellTime: patternStop.defaultDwellTime,
// $FlowFixMe flow doesn't like our "type check"
initialTravelTime: patternStop.defaultTravelTime,
initialDwellTime: patternStop.defaultDwellTime || undefined,
initialTravelTime: patternStop.defaultTravelTime || undefined,
update: false
})
} else {
// If patternStop is not a fixed stop, it is a flex location/location group.
this.setState({
// $FlowFixMe flow doesn't like our "type check"
flexDefaultZoneTime: patternStop.flexDefaultZoneTime,
// $FlowFixMe flow doesn't like our "type check"
flexDefaultTravelTime: patternStop.flexDefaultTravelTime,
// $FlowFixMe flow doesn't like our "type check"
meanDurationFactor: patternStop.meanDurationFactor,
// $FlowFixMe flow doesn't like our "type check"
meanDurationOffset: patternStop.meanDurationOffset,
// $FlowFixMe flow doesn't like our "type check"
safeDurationFactor: patternStop.safeDurationFactor,
// $FlowFixMe flow doesn't like our "type check"
safeDurationOffset: patternStop.safeDurationOffset,
defaultDwellTime: patternStop.defaultDwellTime || undefined,
defaultTravelTime: patternStop.defaultTravelTime || undefined,
update: false
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Contents in the if and else portions is the same, so you can remove the condition entirely.

stop = locationGroups.find(lg => lg.location_group_id === card.locationGroupId)
// $FlowFixMe flow doesn't appreciate our type check
cumulativeTravelTime += card.flexDefaultZoneTime + card.flexDefaultTravelTime
cumulativeTravelTime += card.defaultDwellTime + card.defaultTravelTime
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cumulativeTravelTime should be computed once for all the cases.

@miles-grant-ibigroup miles-grant-ibigroup self-assigned this Feb 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants