Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Union can't join touching polygons on anti-meridian #2712

Open
zdila opened this issue Sep 12, 2024 · 1 comment
Open

Union can't join touching polygons on anti-meridian #2712

zdila opened this issue Sep 12, 2024 · 1 comment

Comments

@zdila
Copy link

zdila commented Sep 12, 2024

Turf 7.1.0

Union can't join touching polygons on anti-meridian unless coordinates are adjusted by 360.

image

// CORRECT - produces {"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[-183,67.35710304434852],[-180,64.8381209933682],[-173,67.35710304434852],[-180,69.40628708036891],[-183,67.35710304434852]]]}}

union(featureCollection([polygon([
    [
      [-180, 64.8381209933682],
      [-185, 67.35710304434852],
      [-180, 69.40628708036891],
      [-180, 64.8381209933682],
    ],
  ]), polygon([
    [
      [-180, 64.8381209933682],
      [-173, 67.35710304434852],
      [-180, 69.40628708036891],
      [-180, 64.8381209933682],
    ]
  ])]));
// INCORRECT - produces {"type":"Feature","properties":{},"geometry":{"type":"MultiPolygon","coordinates":[[[[-180,64.8381209933682],[-173,67.35710304434852],[-180,69.40628708036891],[-180,64.8381209933682]]],[[[173,67.35710304434852],[180,64.8381209933682],[180,69.40628708036891],[173,67.35710304434852]]]]}}

union(featureCollection([polygon([
    [
      [180, 64.8381209933682],
      [175, 67.35710304434852],
      [180, 69.40628708036891],
      [180, 64.8381209933682]
    ]
  ]), polygon([
    [
      [-180, 64.8381209933682],
      [-173, 67.35710304434852],
      [-180, 69.40628708036891],
      [-180, 64.8381209933682],
    ]
  ])]));
@smallsaucepan
Copy link
Member

Thanks for raising this @zdila. I think Turf is doing the right thing by not generating a single polygon that spans the antemeridian. Looking at the Antimeridian Cutting section of the Geojson spec returning a multipolygon is the best for compatibility.

I know that doesn't make much sense given your use case though, so happy to hear if you have a different perspective or suggested behaviour.

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

No branches or pull requests

2 participants