Skip to content

Conversation

@mfedderly
Copy link
Collaborator

Another quick package migration to work towards unifying the build experience

results.push(segment);
});
sliceLineSegments(
feature as Feature<LineString>,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this is a bit of a sketchy cast, but I can't change this without changing the input signature which also takes GeometryCollection and Feature<GeometryCollection>, which theoretically allow more geometry types. I think we just pass through non-line geometries though 🤷 . Kind of a weird API.

Copy link
Member

Choose a reason for hiding this comment

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

Quickly checked and the code throws at runtime if passed a polygon, and fails silently if passed a point. Do we add a runtime check to avoid the throw for polys (fixing a bug), and print a warning for everything that won't be handled e.g."Passed a <geometry.type> to lineChunk, probably in your GeometryCollection, ignoring."?

Longer term I'm pretty sure we can narrow to GeometryCollection<T> and Feature<GeometryCollection<T>>

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah I tested Point and it didn't throw an error, so I was hesitant to change the runtime behavior by starting to throw one. Lets land the js -> ts migration and I'll come behind and make the GeometryCollection typings more strict and look at what to do for the unsupported geometry types in a separate PR (for easier revert, if need be 🤞).

Copy link
Member

Choose a reason for hiding this comment

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

starting to throw one

Wasn't suggesting that. Leave point as is and guard against polygon throwing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah lets continue discussing here: #2970 (comment) :)
Happy to do either way though.

{ units: units }
);
callback(outline, i);
callback(outline);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I just standardized on having no index arg since it wasn't being used and the calls conflicted a bit.

Copy link
Member

@smallsaucepan smallsaucepan left a comment

Choose a reason for hiding this comment

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

Looks great thanks @mfedderly. Suggested a runtime check / warning we could add if you think it'd be a good idea.

@mfedderly mfedderly merged commit 259008a into master Dec 15, 2025
4 checks passed
@mfedderly mfedderly deleted the mf/line-chunk-ts branch December 15, 2025 00:43
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