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

How to get the outline of a group of polygons, without holes ? #193

Open
Dylan190774 opened this issue Sep 27, 2024 · 1 comment
Open

How to get the outline of a group of polygons, without holes ? #193

Dylan190774 opened this issue Sep 27, 2024 · 1 comment
Labels

Comments

@Dylan190774
Copy link

I have several polygons of country-shapes.
I want to get the outline of a group of countries.

For example: Switzerland and Austria.
The problem is that there is Liechtenstein inbetween those countries.

I know I can use unify, but if I don't include Liechtenstein, there's a hole (empty space) in the outline-polygon.

Is there any way to get the entire outline of a group of polygons, even if there is a hole?

@alexbol99
Copy link
Owner

Hi, @Dylan190774 ,

If I understood correctly, after unify you want to filter holes.
You can do it this way, because all the holes has orientation opposite to exterior face:

function filterHoles(poly) {
    const orientation = [...poly.faces][0].orientation();
    const newPoly = new Polygon()
    for (let face of poly.faces) {
        if (face.orientation() === orientation) {
            newPoly.addFace(face.shapes);
        }
    }
    return newPoly;
}

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

No branches or pull requests

2 participants