Skip to content

Commit 68de493

Browse files
Merge pull request #79 from springmeyer/chore/esm
chore: release v1.0.0 - ESM-only, analytical antimeridian splitting, fix antimeridian low npoints split
2 parents 125dfa9 + c5ea41a commit 68de493

18 files changed

Lines changed: 860 additions & 548 deletions

CHANGELOG.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
55

66
## [Unreleased][unreleased]
77

8-
## [1.0.0] - 2026-03-29
8+
## [1.0.0] - 2026-04-12
99

1010
### Breaking change
1111

12-
- arc.js is now a [pure](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) ESM package.
12+
- arc.js is now a [pure](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) ESM package (from @jgravois).
1313

1414
If you need to `require()` arc.js as CJS (CommonJS), or have a runtime older than Node.js 18, please use `0.1.4`.
1515

@@ -27,7 +27,22 @@ const gc = new GreatCircle(/* */);
2727

2828
### Fixed
2929

30-
- antimeridian splitting in GreatCircle.Arc (From @copilot)
30+
- Antimeridian splitting in GreatCircle.Arc (from @thomas-hervey)
31+
32+
### Changed
33+
34+
- `GreatCircle.Arc()` now defaults to `npoints = 100` — calling `gc.Arc()` with no arguments produces a smooth 100-point arc instead of a 2-point stub
35+
- Antimeridian splitting now uses analytical bisection (binary search on `interpolate()`) instead of the GDAL-ported linear heuristic. This approach is more accurate, especially at high latitudes and low `npoints` values
36+
- `ArcOptions.offset` is now a no-op (kept for backwards compatibility); antimeridian handling is fully automatic
37+
38+
### Removed
39+
40+
- GDAL license file (`GDAL-LICENSE.md`). No GDAL-derived code remains in the codebase
41+
42+
### Added
43+
44+
- `scripts/benchmark.mjs` benchmarks bisection vs. prior linear approach across npoints and route types
45+
- `scripts/dump-fixtures.mjs` exports all test routes as GeoJSON for use in visual verification (such as [https://geojson.io](https://geojson.io) or the index.html demo page)
3146

3247
## [0.2.0] - 2025-09-22
3348
### Breaking

DEVELOPING.md

Lines changed: 28 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,24 @@ This guide covers working with the TypeScript codebase for arc.js.
66

77
```bash
88
npm install # Install dependencies
9-
npm run build # Build all outputs
9+
npm run build # Build ESM output
1010
npm test # Run TypeScript tests
11-
npm run test:all # Run all tests (TypeScript + build validation)
1211
```
1312

1413
## Project Structure
1514

16-
```
15+
```text
1716
src/
1817
├── index.ts # Main entry point
1918
├── coord.ts # Coordinate class
20-
├── arc.ts # Arc class
19+
├── arc.ts # Arc class
2120
├── great-circle.ts # Great circle calculations
2221
├── line-string.ts # Internal geometry helper
2322
├── utils.ts # Utility functions
2423
└── types.ts # TypeScript type definitions
2524
2625
test/
27-
├── *.test.ts # Jest TypeScript tests (source code)
28-
└── build-output.test.js # Build validation (compiled output)
26+
└── *.test.ts # Jest TypeScript tests
2927
```
3028

3129
## Development Workflow
@@ -36,14 +34,11 @@ test/
3634
# Run TypeScript tests (fast, for development)
3735
npm test
3836

39-
# Run build validation (slower, tests compiled output)
40-
npm run test:build
41-
42-
# Run everything (recommended before committing)
43-
npm run test:all
44-
4537
# Watch mode for development
4638
npm run test:watch
39+
40+
# Coverage report
41+
npm run test:coverage
4742
```
4843

4944
### Building
@@ -52,10 +47,7 @@ npm run test:watch
5247
npm run build
5348
```
5449

55-
This generates:
56-
- `dist/` - CommonJS output with `.d.ts` files
57-
- `dist/esm/` - ES modules output
58-
- `arc.js` - Browser bundle (UMD format)
50+
This generates `dist/` — ESM output with `.d.ts` declaration files.
5951

6052
## Publishing
6153

@@ -68,7 +60,7 @@ This generates:
6860

6961
### Pre-publish Checklist (for maintainers)
7062

71-
1. **Tests pass**: `npm run test:all`
63+
1. **Tests pass**: `npm test`
7264
2. **Build succeeds**: `npm run build`
7365
3. **Version updated**: Update `package.json` version
7466
4. **Changelog updated**: Document changes
@@ -77,49 +69,48 @@ This generates:
7769
### Publishing Process (maintainers only)
7870

7971
```bash
80-
npm run build # Builds automatically on prepublishOnly
81-
npm publish
72+
npm publish # prepublishOnly runs npm run build automatically
8273
```
8374

84-
The `prepublishOnly` script ensures a fresh build before publishing.
85-
8675
### What Gets Published
8776

88-
- `dist/` folder (compiled JS + TypeScript definitions)
89-
- `arc.js` browser bundle
77+
- `dist/` folder (compiled ESM JS + TypeScript definitions)
78+
- `src/` folder (TypeScript source files)
9079
- `README.md`, `LICENSE.md`, `CHANGELOG.md`
9180

9281
## TypeScript Development
9382

9483
### TypeScript Configuration
9584

9685
- **Source**: Modern TypeScript with strict settings
97-
- **Output**: ES2022 for broad compatibility
98-
- **Paths**: `@/` alias maps to `src/` in tests
86+
- **Output**: ES2022, ESM only
9987
- **Declarations**: Full `.d.ts` generation for consumers
88+
10089
### Adding New Types
10190

102-
1. Add interfaces/types to `src/types.ts`. You can see that it makes use of some GeoJSON types, but in the future it may want to use more of them.
91+
1. Add interfaces/types to `src/types.ts`
10392
2. Export public types from `src/index.ts`
10493
3. Import types with `import type { ... }`
105-
4. Add tests in relevant `test/*.test.ts` files including typescript.test.ts
106-
107-
## Usage & Module Formats
94+
4. Add tests in relevant `test/*.test.ts` files including `typescript.test.ts`
10895

109-
The package supports multiple import styles:
96+
## Usage
11097

11198
```javascript
112-
// CommonJS (Node.js)
113-
const { GreatCircle } = require('arc');
114-
115-
// ES Modules
99+
// ES Modules (Node.js or bundler)
116100
import { GreatCircle } from 'arc';
101+
```
117102

118-
// Browser (UMD bundle)
119-
<script src="arc.js"></script>
103+
## Visual Fixture Verification
104+
105+
To inspect all test routes as great circle arcs on a map:
106+
107+
```bash
108+
npm run build # dist/ must exist
109+
node scripts/dump-fixtures.mjs | pbcopy # macOS: copy to clipboard
120110
```
121111

122-
All formats are tested in `test/build-output.test.js`.
112+
Then, paste the geojson output into a visualization tool to visually verify routes, such as [geojson.io](https://geojson.io).
113+
**Note:** route coordinates in the script are manually updated to keep in sync with `test/fixtures/routes.ts`.
123114

124115
## Common Tasks
125116

GDAL-LICENSE.md

Lines changed: 0 additions & 57 deletions
This file was deleted.

README.md

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Calculate great circle routes as lines in GeoJSON or WKT format.
99
- Works in Node.js and browsers
1010
- Generates GeoJSON and WKT output formats
1111
- Handles dateline crossing automatically
12-
- Based on [Ed Williams' Aviation Formulary](https://edwilliams.org/avform.htm#Intermediate) algorithms and the GDAL source code
12+
- Based on [Ed Williams' Aviation Formulary](https://edwilliams.org/avform.htm#Intermediate) algorithms
1313

1414
## Installation
1515

@@ -22,7 +22,7 @@ npm install arc
2222
```js
2323
import { GreatCircle } from 'arc';
2424
const gc = new GreatCircle({x: -122, y: 48}, {x: -77, y: 39});
25-
const line = gc.Arc(100);
25+
const line = gc.Arc(); // npoints is optional, defaults to 100
2626
console.log(line.json()); // GeoJSON output
2727
```
2828

@@ -40,8 +40,8 @@ const line = gc.Arc(100);
4040
```html
4141
<script type="module">
4242
import { GreatCircle } from 'https://cdn.skypack.dev/arc@1';
43-
const gc = new arc.GreatCircle({x: -122, y: 48}, {x: -77, y: 39});
44-
const line = gc.Arc(100);
43+
const gc = new GreatCircle({x: -122, y: 48}, {x: -77, y: 39});
44+
const line = gc.Arc();
4545
</script>
4646
```
4747

@@ -64,12 +64,12 @@ const gc = new GreatCircle(start, end, { name: 'Seattle to DC' });
6464

6565
#### 3. Generate the arc
6666
```js
67-
const line = gc.Arc(100, { offset: 10 });
67+
const line = gc.Arc(); // defaults to 100 points
68+
const line = gc.Arc(500); // or specify a custom value
6869
```
6970

7071
**Parameters:**
71-
- `npoints` (number): Number of intermediate points (higher = more accurate)
72-
- `options.offset` (number): Dateline crossing threshold in degrees (default: 10)
72+
- `npoints` (number, optional): Number of intermediate points (higher = more precise, default: 100)
7373

7474
### TypeScript Support
7575

@@ -87,8 +87,7 @@ const end: CoordinatePoint = { x: -77, y: 39 };
8787
const properties: RouteProperties = { name: 'Seattle to DC', color: 'blue' };
8888

8989
const gc = new GreatCircle(start, end, properties);
90-
const options: ArcOptions = { offset: 10 };
91-
const line = gc.Arc(100, options);
90+
const line = gc.Arc(); // npoints is optional, defaults to 100
9291

9392
// Fully typed return values
9493
const geojson = line.json(); // GeoJSONFeature
@@ -144,7 +143,7 @@ const wkt = line.wkt();
144143

145144
### Dateline Crossing
146145

147-
The library automatically handles routes that cross the international dateline. The `offset` option (default: 10) controls how close to the dateline a route must be before it gets split into multiple segments. For routes near the poles, you may need a higher offset value.
146+
Routes that cross the international dateline are automatically detected and split into a `MultiLineString` with exact `±180°` boundary points. No configuration is needed.
148147

149148
## Examples
150149

@@ -157,7 +156,3 @@ arc.js powers the [`greatCircle`](https://turfjs.org/docs/api/greatCircle) funct
157156
## License
158157

159158
This project is licensed under the BSD license. See [LICENSE.md](LICENSE) for details.
160-
161-
### Third-Party Licenses
162-
163-
This project includes code ported from GDAL (Geospatial Data Abstraction Library), which is licensed under the MIT/X11 license. See [GDAL-LICENSE.md](GDAL-LICENSE.md) for the full GDAL license text and attribution details.

index.html

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -333,11 +333,6 @@ <h3>Settings</h3>
333333
<input type="number" id="npoints" value="100" min="10" max="1000" />
334334
</div>
335335

336-
<div class="control-group">
337-
<label for="offset">Dateline offset (degrees):</label>
338-
<input type="number" id="offset" value="20" min="1" max="90" step="1" />
339-
</div>
340-
341336
<div class="control-group">
342337
<button id="clear" class="btn">Clear All</button>
343338
<button id="reset" class="btn btn-danger">Reset View</button>
@@ -377,7 +372,6 @@ <h4>Generated GeoJSON</h4>
377372

378373
// Configuration
379374
var npoints = 100;
380-
var offset = 20;
381375
var coords = [];
382376
var points = [];
383377
var snap_tolerance = 500000;
@@ -390,10 +384,6 @@ <h4>Generated GeoJSON</h4>
390384
npoints = parseInt(this.value) || 100;
391385
});
392386

393-
document.getElementById('offset').addEventListener('change', function() {
394-
offset = parseInt(this.value) || 20;
395-
});
396-
397387
var start, end;
398388

399389
function draw(coords) {
@@ -469,7 +459,7 @@ <h4>Generated GeoJSON</h4>
469459
};
470460

471461
var greatCircle = new GreatCircle(from, to, properties);
472-
var gc = greatCircle.Arc(npoints, { offset: offset });
462+
var gc = greatCircle.Arc(npoints);
473463
var line = new L.geoJson().addTo(map);
474464
var geojson_feature = gc.json();
475465

@@ -592,7 +582,7 @@ <h4>Generated GeoJSON</h4>
592582

593583
try {
594584
var greatCircle = new GreatCircle(nyc, london, properties);
595-
var gc = greatCircle.Arc(npoints, { offset: offset });
585+
var gc = greatCircle.Arc(npoints);
596586
var line = new L.geoJson().addTo(map);
597587
var geojson_feature = gc.json();
598588

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "arc",
3-
"version": "0.2.0",
3+
"version": "1.0.0",
44
"description": "draw great circle arcs",
55
"url": "https://github.com/springmeyer/arc.js",
66
"keywords": [
@@ -14,7 +14,8 @@
1414
],
1515
"contributors": [
1616
"Dane Springmeyer <dane.springmeyer@gmail.com>",
17-
"John Gravois <jagravois@gmail.com>"
17+
"John Gravois <jagravois@gmail.com>",
18+
"Thomas Hervey <thomasahervey@gmail.com>"
1819
],
1920
"repository": {
2021
"type": "git",
@@ -28,9 +29,9 @@
2829
},
2930
"files": [
3031
"dist/",
32+
"src/",
3133
"README.md",
3234
"LICENSE.md",
33-
"GDAL-LICENSE.md",
3435
"CHANGELOG.md"
3536
],
3637
"engines": {

0 commit comments

Comments
 (0)