fix: remove polygons with fewer than 3 points after simplification#2204
fix: remove polygons with fewer than 3 points after simplification#2204rekire wants to merge 1 commit into
Conversation
This change fixes this assertion error: The following assertion was thrown while handling a pointer data packet: not a polygon 'package:flutter_map/src/misc/point_in_polygon.dart': Failed assertion: line 10 pos 10: 'len >= 3' When the exception was thrown, this was the stack: fleaflet#2 isPointInPolygon (package:flutter_map/src/misc/point_in_polygon.dart:10:10) fleaflet#3 _PolygonPainter.elementHitTest.<anonymous> (package:flutter_map/src/layer/polygon_layer/painter.dart:85:17) fleaflet#4 _PolygonPainter.elementHitTest (package:flutter_map/src/layer/polygon_layer/painter.dart:90:10) fleaflet#5 HitDetectablePainter.hitTest (package:flutter_map/src/layer/shared/layer_interactivity/internal_hit_detectable.dart:75:11) fleaflet#6 HitTestRequiresCameraOrigin.hitTest (package:flutter_map/src/layer/shared/layer_interactivity/internal_hit_detectable.dart:112:18) fleaflet#7 RenderCustomPaint.hitTestSelf (package:flutter/src/rendering/custom_paint.dart:569:43) fleaflet#8 RenderBox.hitTest (package:flutter/src/rendering/box.dart:2953:58)</anonymous>
|
Hi @rekire, |
|
I'm using my fork right now to avoid this issue. In my |
|
Okay I found it out: I am using vector_map_tiles which requires that old version and the latest beta does not compile at the moment. So the real issue is that I am using a very old version. |
|
Ah no worries :) Thanks for contributing anyway, and please feel free to again in future! |
When you have a (multi) polygon with lots of tiny polygons the simplification can shrink a polygon to e.g. two points, this will cause a this assertion error:
My fix simply removes those polygons entirely. That happens when you hover a
PolygonLayeras workaround you can usesimplificationTolerance: 0but that is based on the geometry quite bad for the performance.