I have many long polylines on the map. I would like to optimize their drawing, because at several thousand points the polylines are drawn incredibly slowly.
My drawMapRect looks like this:
- for each polyline segment - verify if it bounding box intersects the currently drawn MKMapRect - if id does, draw it
Which is great if not so many points. But with 8-16 cards and 2-3000 points, they incredibly slowly go through for .
If they were only locations, the solution would be to implement some kind of quadtree / r-tree structure and only a filter for these locations in the current MKMapRect drawing, but I'm not sure what this will be for the polylines themselves.
If I filter only for the endpoints of a segment inside the current layout, then some line segments may not be displayed. For example, two red changes between points 1-2 do not have segment endpoints in them, but they still need to be drawn ...

Is there some kind of quadrant-like algorithm or some kind of approach for this problem?
source share