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

[BUG] Alternative polygon renderer in 7.0 renderers multiple holes incorrectly #1899

Closed
Elleo opened this issue May 30, 2024 · 2 comments · Fixed by #1906
Closed

[BUG] Alternative polygon renderer in 7.0 renderers multiple holes incorrectly #1899

Elleo opened this issue May 30, 2024 · 2 comments · Fixed by #1906
Labels
bug This issue reports broken functionality or another error P: 2 (soon™?) S: core Scoped to the core flutter_map functionality

Comments

@Elleo
Copy link

Elleo commented May 30, 2024

What is the bug?

If a polygon contains multiple holes and the useAltRendering property is set on the polygon layer, then the holes are cut out incorrectly (with vertices from different holes seemingly connecting to each other)

Expected output:
Screenshot 2024-05-30 123727

Actual output:
Screenshot 2024-05-30 123709

How can we reproduce it?

The following code can be used to reproduce this issue:

          FlutterMap(
            options: const MapOptions(
              initialCenter: LatLng(64.025, -1.132),
              initialZoom: 16,
            ),
            children: [
              PolygonLayer(
                useAltRendering: true,
                polygons: [
                  Polygon(
                      points: const [
                        LatLng(64.0283, -1.13083),
                        LatLng(64.0282, -1.130172),
                        LatLng(64.024794, -1.130862),
                        LatLng(64.0247, -1.13126),
                        LatLng(64.0247, -1.13183),
                        LatLng(64.025, -1.13274),
                        LatLng(64.0254, -1.13352),
                        LatLng(64.0259, -1.134093),
                        LatLng(64.027859, -1.135774),
                        LatLng(64.027915, -1.134542),
                        LatLng(64.028168, -1.132229),
                        LatLng(64.028284, -1.131658),
                        LatLng(64.0283, -1.13083)
                      ],
                      holePointsList: const [
                        [
                          LatLng(64.026675, -1.133183),
                          LatLng(64.026601, -1.133234),
                          LatLng(64.026534, -1.133158),
                          LatLng(64.026534, -1.13302),
                          LatLng(64.026601, -1.132944),
                          LatLng(64.026688, -1.13303),
                          LatLng(64.026675, -1.133183)
                        ],
                        [
                          LatLng(64.026226, -1.134005),
                          LatLng(64.0262, -1.134068),
                          LatLng(64.026149, -1.134059),
                          LatLng(64.02616, -1.133918),
                          LatLng(64.026211, -1.133933),
                          LatLng(64.026226, -1.134005)
                        ],
                        [
                          LatLng(64.025838, -1.13236),
                          LatLng(64.02578, -1.132496),
                          LatLng(64.025723, -1.132513),
                          LatLng(64.025669, -1.132476),
                          LatLng(64.025631, -1.132298),
                          LatLng(64.025695, -1.132169),
                          LatLng(64.025752, -1.132159),
                          LatLng(64.025804, -1.132202),
                          LatLng(64.025838, -1.13236)
                        ]
                      ],
                      label: "No 3",
                      color: Colors.lightBlue.withOpacity(0.5),
                      borderColor: Colors.lightBlue,
                      borderStrokeWidth: 1),
                ],
              ),
            ],
          ),

Do you have a potential solution?

No response

Platforms

Windows 11, iOS 17

Severity

Obtrusive: Prevents normal functioning but causes no errors in the console

@Elleo Elleo added bug This issue reports broken functionality or another error needs triage This new bug report needs reproducing and prioritizing labels May 30, 2024
@JaffaKetchup
Copy link
Member

It's probably misinterpreting the output of dart_earcut, or maybe the code in dart_earcut is wrong. But more likely is the first one, as I had a hard time understanding the output myself (despite it being me that ported that library!).

@JaffaKetchup JaffaKetchup added P: 2 (soon™?) S: core Scoped to the core flutter_map functionality and removed needs triage This new bug report needs reproducing and prioritizing labels Jun 1, 2024
@JaffaKetchup
Copy link
Member

It probably starts at this line, which then throws the whole triangulation off:

// Not sure how just this works but it seems to :D
holeIndices: culledPolygon.holePoints.isEmpty
? null
: [culledPolygon.points.length],

I knew there would be issues when I wrote it, but none of my test cases included multiple holes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue reports broken functionality or another error P: 2 (soon™?) S: core Scoped to the core flutter_map functionality
Projects
Archived in project
2 participants