Skip to content

chore: release v1.0.0 - ESM-only, analytical antimeridian splitting, fix antimeridian low npoints split#79

Merged
thomas-hervey merged 17 commits intomainfrom
chore/esm
Apr 13, 2026
Merged

chore: release v1.0.0 - ESM-only, analytical antimeridian splitting, fix antimeridian low npoints split#79
thomas-hervey merged 17 commits intomainfrom
chore/esm

Conversation

@thomas-hervey
Copy link
Copy Markdown
Collaborator

No description provided.

…n splitting

- Remove bHasBigDiff / dfMaxSmallDiffLong / dfDateLineOffset heuristic
- Bisect for exact crossing fraction via interpolate() (50 iterations)
- Insert [±180, lat*] boundary points; npoints ≤ 2 keeps current behavior
- Fixes issue #75: low npoints (e.g. 10) no longer skips the split
- Tighten test assertions: SPLIT_NPOINTS constant, directional ±180 checks
Addresses Copilot review comment — adds coords.length === 2 check to
assertSplitAtAntimeridian to guard against false positives from 3+
segment splits.
- Routes 2-5 (antimeridian crossers): replace stale coordinate snapshots
  with semantic assertions (Feature type, properties pass-through, WKT
  contains two LINESTRING parts). Splitting correctness is owned by
  antimeridian.test.ts.
- Southern hemisphere filter: switch to coordinate comparison
  (start.y < 0 || end.y < 0) and flatten MultiLineString coordinates
  before .some() to fix number[][][] vs number[][] traversal bug.
- Add south-to-south antimeridian crossing coverage: Sydney ↔ Buenos
  Aires at npoints=10 and 100 in both directions.
- Reformat antimeridian.test.ts to consistent 2-space indentation.
- Add geographic place names to all routes for maintainer clarity.
The GDAL-ported dateline splitting heuristic was removed when the
analytical bisection approach was introduced. No remaining code
derives from GDAL, so delete GDAL-LICENSE.md, remove it from the
package.json files list, drop the file-level attribution block in
great-circle.ts, and remove the GDAL references from README.md.
test: add antimeridian splitting tests for low npoints values
Mark ArcOptions.offset as @deprecated no-op. Remove non-existent
test:build / test:all scripts and CJS/UMD bundle references from
DEVELOPING.md.
Strip { offset } from all Arc() call sites — the field is a no-op
since the GDAL heuristic was replaced. Keep the backwards-compat type
assertion in typescript.test.ts with an explanatory comment. Update
README Dateline Crossing section and remove the offset UI control from
index.html.
Arc() with no argument previously returned a 2-point LineString (the
<= 2 fallback). A default of 100 produces a usable great circle arc
out of the box, consistent with the library's intent.
Consolidates inline coordinate constants, route arrays, and test
property helpers into a single source of truth. All test files now
import from test/fixtures/routes.ts, eliminating duplication and
making fixture coverage reviewable in one place.
Generates a GeoJSON FeatureCollection of all test fixtures using the
library itself (actual great circle arcs, not straight lines).
Documents usage in DEVELOPING.md.
…tion

Quantifies the performance cost of the analytical antimeridian bisection
vs the prior GDAL linear interpolation approach. Runnable via
`node scripts/benchmark.mjs` after `npm run build`.
…ments

- Extract 50-iteration bisection count into ANTIMERIDIAN_BISECTION_ITERATIONS constant
- Add inline comments explaining each phase of the Arc() algorithm
- Clean up comments across src/ for clarity and consistency
- Add Thomas Hervey to contributors in package.json
docs: remove deprecated offset option and GDAL attribution
@thomas-hervey thomas-hervey changed the title Chore/esm chore: release v1.0.0 - ESM-only, analytical antimeridian splitting, fix antimeridian low npoints split Apr 13, 2026
@thomas-hervey
Copy link
Copy Markdown
Collaborator Author

@springmeyer @jgravois this is the PR to release v1.0.0. Double check the CHANGELOG for me and let me know if you see any issues before I merge and npm publish.

Thanks!

Copy link
Copy Markdown
Collaborator

@jgravois jgravois left a comment

Choose a reason for hiding this comment

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

CIL for one nit.

overall, this looks great!

Comment thread README.md Outdated
#### 3. Generate the arc
```js
const line = gc.Arc(100, { offset: 10 });
const line = gc.Arc(100);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

let's show an example with npoints omitted too and make it explicit directly below that the argument is now optional.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good suggestion. In commit f2a3623 I've updated the README to show examples with and without npoints

@thomas-hervey thomas-hervey requested a review from jgravois April 13, 2026 18:09
Copy link
Copy Markdown
Collaborator

@jgravois jgravois left a comment

Choose a reason for hiding this comment

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

CIL for a few notes. nothing blocking imo.

Comment thread src/great-circle.ts Outdated
Arc(npoints: number = 100, _options?: ArcOptions): Arc {
// NOTE: With npoints ≤ 2, no antimeridian splitting is performed.
// A 2-point antimeridian route returns a single LineString spanning ±180°. Renderers that support coordinate wrapping (e.g. MapLibre GL JS) handle this correctly, whereas splitting would produce two disconnected straight-line stubs with no great-circle curvature — arguably worse behavior. This is a known limitation; open for maintainer discussion if a MultiLineString split is preferred.
if (!npoints || npoints <= 2) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

just another nit, but is there still value in trapping for !npoints now that we're setting a default value?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good point, !npoints can be safely removed. I'll do this in the next commit.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Addressed in c5ea41a.

Comment thread package.json
{
"name": "arc",
"version": "0.2.0",
"version": "1.0.0",
Copy link
Copy Markdown
Collaborator

@jgravois jgravois Apr 13, 2026

Choose a reason for hiding this comment

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

just a note that we need to add src/ to the files array before we publish. doesn't matter to me whether that happens here or a follow-up PR.

when we do that, we should update the DEVELOPING.md file too.

https://github.com/springmeyer/arc.js/blob/f2a36235e11897d7a211c4cb20429e4fdd578361/DEVELOPING.md#what-gets-published

ref: #80

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, let's roll this into the release, so I'll make those changes in the next commit.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Addressed in c5ea41a.

Comment thread package.json Outdated
"LICENSE.md",
"GDAL-LICENSE.md",
"CHANGELOG.md"
"CHANGELOG.md"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

i know you mentioned adding a new linter/formatter. in the meantime, the whitespace here is a bit borked.

- Remove redundant `!npoints` check now that default is 100
- Add src/ to package.json files array and update DEVELOPING.md
- Fix Browser ESM example: arc.GreatCircle -> GreatCircle, Arc(100) -> Arc()
- Fix CHANGELOG.md indentation in package.json files array
@thomas-hervey thomas-hervey merged commit 68de493 into main Apr 13, 2026
7 checks passed
@thomas-hervey thomas-hervey mentioned this pull request Apr 13, 2026
@thomas-hervey
Copy link
Copy Markdown
Collaborator Author

@springmeyer this is merged to main and I've created a v1.0.0 tag. Running npm publish locally, the build is clean and tarball outputs look correct. But, I don't think I have npm publish rights, so can you do that?

@jgravois
Copy link
Copy Markdown
Collaborator

i can publish this time around.

@jgravois
Copy link
Copy Markdown
Collaborator

jgravois commented Apr 13, 2026

published as v1.0.0

nice work @thomas-hervey!

@thomas-hervey
Copy link
Copy Markdown
Collaborator Author

Awesome. I'll work on pulling this into turf js soon.

@thomas-hervey
Copy link
Copy Markdown
Collaborator Author

@jgravois sorry to bother you, but I'd like your quick input on re-adding CommonJS support (perhaps in a v1.0.1?). Before I work on re-adding CommonJS support in arc.js, I'm wondering if you have any alternative suggestions.

Per this comment on my PR to resolve Turfjs/turf#3030 in TurfJS, a V8 only release is a ways off, so removing CommonJS support will be a breaking change.

@jgravois
Copy link
Copy Markdown
Collaborator

jgravois commented Apr 21, 2026

removing CommonJS support will be a breaking change.

how so? since turf is publishing both ESM and CJS bundles for consumers and arc.js is a dependency, i'd expect the compiled output for the CJS build to include a CJS copy of arc.js. is that not the case?

edit: i poked around for a few minutes and now i can see that one option would be for turf to use something like tsdown to bundle its own TS and dependency code together for the CJS build.

not sure if the project has the appetite to switch, but i have to imagine that the DX would be better for it to bundle and that kdbush isn't the only other ESM project that it would be helpful for it to be able to support natively going forward. 🤔

@thomas-hervey
Copy link
Copy Markdown
Collaborator Author

Thinking... I don't feel too strongly, and I want to keep our momentum towards ESM, but still need to fix the target issue.

I can ask but I suspect that they'd wait to make a change to their bundler later on, not for a fix like we're targeting. At that point, maybe it's worth waiting for a TurfJS V8 release.

For now, it would be going back on our plan, but to resolve this issue I'm thinking that we could re-add a dual CJS/ESM build via tsup (same tool turf itself uses), update exports with explicit import/require conditions, add a "main" field pointing to the CJS output for older tooling, and release as v1.0.1, so no API changes. Not ideal for the long term, but thoughts? If we did that, would you prefer tsup or a second tsc pass? tsup would be cleaner with TurfJS because the tsup config would mirror Turf's own ..., cjsInterop: true, both formats, dts enabled.

@jgravois
Copy link
Copy Markdown
Collaborator

jgravois commented Apr 21, 2026

if the turf folks are amenable to tweaking their own build my preference would be to stay ESM only on the 1.x branch.

another way to buy time while we figure out the mechanics of ☝️ would be to publish a CJS compatible 0.2.1 release.

that said, this isn't my project and i'm not philosophically opposed to bundling CJS. i just think that it would be a genuine improvement if turf could also depend on kdbush without going 'all in' on ESM themselves.

ps. looks like tsup isn't actively maintained anymore.

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.

2 participants