-
Notifications
You must be signed in to change notification settings - Fork 34
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
base: master
Are you sure you want to change the base?
route viewer overlay: avoid MultiPolygon crash #798
Conversation
typescript is failing |
There was a problem hiding this 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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed it!
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
Typescript is really broken here I think. I can type line 131 as GeoJSON.Geometry but TS still thinks there's no |
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.