Skip to content

GreatCircle.Arc antimeridian split fails at low npoints for mid-arc crossings #75

Description

@thomas-hervey

Summary

The fix from #71 resolves antimeridian splitting at npoints=100 but the split logic still fails at low npoints values (such as npoints=10) for routes where the crossing occurs mid-arc.

Affected version:

arc@1.0.0-beta.1

Reproduction

Testing examples on geojson.io shown in this comment on #71 .

You can also test directly with these arcs...

import { GreatCircle } from 'arc';

// FAIL: Returns LineString (should be MultiLineString)
// Tokyo → LAX
new GreatCircle({ x: 139.7798, y: 35.5494 }, { x: -118.4085, y: 33.9416 }).Arc(10, { offset: 10 }).json();

// Shanghai → SFO
new GreatCircle({ x: 121.81, y: 31.14 }, { x: -122.38, y: 37.62 }).Arc(10, { offset: 10 }).json();

// PASS: Returns MultiLineString
//  Auckland → LAX
new GreatCircle({ x: 174.79, y: -36.85 }, { x: -118.41, y: 33.94 }).Arc(10, { offset: 10 }).json();

Root cause hypothesis

  • When npoints is low, the step size is large enough that a single step can leap a large number of degrees, such as from e.g. 172° to -175° without the crossing condition being satisfied.

  • Auckland possibly passes because the first step already crosses 180° before the step size becomes relevant. The start of the arc is only ~5° longitude from the antimeridian.

@springmeyer @jgravois

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions