Turfjs / Turfjs/turf

Intersect - "Must specify at least 2 geometries"

Open
#3,028 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
10.5k
Forks
1k
Avg merge
1h 11m
Merged PRs (30d)
4

Description

I'm using version 7.3.4 within a NextJS project.
The following code, lifted directly from the documentation:

var poly1 = turf.polygon([
    [
        [-122.801742, 45.48565],
        [-122.801742, 45.60491],
        [-122.584762, 45.60491],
        [-122.584762, 45.48565],
        [-122.801742, 45.48565],
    ],
    ]);

    var poly2 = turf.polygon([
    [
        [-122.520217, 45.535693],
        [-122.64038, 45.553967],
        [-122.720031, 45.526554],
        [-122.669906, 45.507309],
        [-122.723464, 45.446643],
        [-122.532577, 45.408574],
        [-122.487258, 45.477466],
        [-122.520217, 45.535693],
    ],
    ]);

    var intersection = turf.intersect(turf.featureCollection([poly1, poly2]));

Gives the following error on the final line: Must specify at least 2 geometries. I'm not sure whether the documentation is wrong, or there is a bug in the intersect function. If the former, what is the correct usage?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the intersect documentation linked in the report with the v7.3.4 function signature, then reproduce the supplied FeatureCollection example. Determine whether the documented call or the function behavior is incorrect, and confirm the corrected usage or behavior with a regression test before updating the documentation or implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nextjs, typescript
Domain
api, web-dev
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.