Skip to content

nearestPointOnLine throws Error: coordinates must contain numbers #2808

@kamami

Description

@kamami

I have a curious problem. I am using turf.nearestPointOnLine with two different lines. It is working perfectly fine with line1, but line2 is throwing me this Error: Error: coordinates must contain numbers

Honestly I don't see the difference...

Here is my code:

          const line1 = turf.lineString([
            [-77.031669, 38.878605],
            [-77.029609, 38.881946],
            [-77.020339, 38.884084],
            [-77.025661, 38.885821],
            [-77.021884, 38.889563],
            [-77.019824, 38.892368],
          ]);
          const line2 = turf.lineString([
            [10.57846, 49.8463959],
            [10.57846, 49.8468386],
            [10.57846, 49.8468386],
            [10.57846, 49.8468386],
            [10.57846, 49.8472814],
            [10.57846, 49.8472814],
          ]);

          const point = turf.point([-122.3102, 47.6634]);

          const nearest = turf.nearestPointOnLine(line2, point);  //throws error
          const nearest = turf.nearestPointOnLine(line1, point);  //works fine

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions