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

Polygon overlaps itself doesn't show normally #4962

Closed
huangyingjie opened this issue Jul 10, 2017 · 5 comments
Closed

Polygon overlaps itself doesn't show normally #4962

huangyingjie opened this issue Jul 10, 2017 · 5 comments

Comments

@huangyingjie
Copy link

Problem and code

  • Here is my code:
          map.addLayer({
              'id': 'maine',
              'type': 'fill',
              'source': {
                  'type': 'geojson',
                  'data': {
                      'type': 'Feature',
                      'geometry': {
                          'type': 'Polygon',
                          'coordinates': [[[116.37688636779785,39.93091599989282],
                            [116.41559600830078,39.89999167197871],
                            [116.37027740478516,39.89771993624399],
                            [116.41353607177734,39.9317880642358],
                            [116.37688636779785,39.93091599989282]
                          ]]
                      }
                  }
              },
              'layout': {},
              'paint': {
                  'fill-color': '#088',
                  'fill-opacity': 0.8
              }
          });
  • And This is the screenshot
    image
    When Change the zoom:
    image

What's my expectation

image

Why not forbid overlapping?

I shall do this later, but there was too much data overlaps; and customers ask to show as my description before.

@ddimaria
Copy link

@huangyingjie
Copy link
Author

@ddimaria it use two or more polyons, but here it is just one polygon..

@mourner
Copy link
Member

mourner commented Jul 10, 2017

This is a technical limitation — we currently have no way to properly triangulate invalid self-intersecting polygons.

@mourner mourner closed this as completed Jul 10, 2017
@huangyingjie
Copy link
Author

Hello @mourner , could you please describe the technical limitation in detail? article、issue etc.

@mourner
Copy link
Member

mourner commented Jul 14, 2017

@huangyingjie there is no fast, stable algorithm for triangulating non-simple (self-intersecting) polygons. For triangulation, we use https://github.com/mapbox/earcut, which is very fast, but assumes that polygons do not self-intersect.

We clean up all self-intersections in our vector tiles, but don't do so yet in JavaScript when rendering GeoJSON sources. Detecting and resolving self-intersections is a very hard problem, which I started exploring in https://github.com/mapbox/polysnap project, but haven't finished yet.

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

No branches or pull requests

3 participants