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

route viewer overlay: avoid MultiPolygon crash #798

Merged

Conversation

miles-grant-ibigroup
Copy link
Collaborator

Previously the multi polygon data structure broke the bounds checking. Since we don't support rendering that anyway, this PR catches this case and avoids a crash. The whole thing needs refactoring anyway. GeoJSON was built for functional programming and that's what should be done here.

@daniel-heppner-ibigroup
Copy link
Contributor

typescript is failing

Copy link
Contributor

@daniel-heppner-ibigroup daniel-heppner-ibigroup left a comment

Choose a reason for hiding this comment

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

uh

@@ -127,9 +127,34 @@ const RouteViewerOverlay = (props: Props): JSX.Element => {
reduceBounds,
bounds || new LngLatBounds(coordsArray[0], coordsArray[0])
);
} else if (geoJson?.type === "GeometryCollection") {
const { geometries } = geoJson;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is correct. Should it be stop.geometries.geometries? geoJson is coming from stop.geometries above

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed it!

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can do better than this! If this isn't always going to be a Polygon then why not update the type in the types package? This type is coming from the Stop type on line 502 of types.

@@ -127,9 +127,34 @@ const RouteViewerOverlay = (props: Props): JSX.Element => {
reduceBounds,
bounds || new LngLatBounds(coordsArray[0], coordsArray[0])
);
} else if (geoJson?.type === "GeometryCollection") {
const { geometries } = geoJson;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can do better than this! If this isn't always going to be a Polygon then why not update the type in the types package? This type is coming from the Stop type on line 502 of types.

@miles-grant-ibigroup
Copy link
Collaborator Author

Typescript is really broken here I think. I can type line 131 as GeoJSON.Geometry but TS still thinks there's no coordinates as children. What did we do here?

Copy link
Contributor

@daniel-heppner-ibigroup daniel-heppner-ibigroup left a comment

Choose a reason for hiding this comment

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

Raising the white flag to typescript here, do whatever you need to do, I can't unravel it.

Copy link
Contributor

@amy-corson-ibigroup amy-corson-ibigroup left a comment

Choose a reason for hiding this comment

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

Looks like this breaks a few of the stories, namely the default, path styling, and changing path

@miles-grant-ibigroup
Copy link
Collaborator Author

Good catch thanks!

@miles-grant-ibigroup miles-grant-ibigroup merged commit 17dbb4a into opentripplanner:master Jan 16, 2025
2 checks passed
@miles-grant-ibigroup miles-grant-ibigroup deleted the avoid-multipolygon-crash branch January 16, 2025 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants