Ok, so this would be the principle:
Start with a polygon with four points that match the corners of the image. All four points are considered movable.
Then it's just a case of running this small loop:
For each movable point in our polygon:
- Move it 1 unit toward polygon center.
- If the changed line intersects a latlong point:
- Add another point to our polygon at intersecting location and mark it as unmovable.
- Add two new movable points as neighbours to the newly added unmovable points, at center of segment.
- If the changed line intersects a previous line in the polygon, move the polygon point back to previous position and mark it as unmovable. (So we don't "tie off" sections and make islands.)
Example conditions for when to stop the loop:
- Number of polygon segments are high enough.
- Enough time has passed.
- Median segment length is below a certain value.
...or whatever makes sense in your case.
And to illustrate, this is sort of what it would look like with the image
@MasterGy posted:
(rotated and cropped to not eat too much space here)
red dots = movable points
purple dots = red dots, but shows that they were added as effect of added green dot (I chose this color poorly, check the images manually if you really want to see where the purple dots are)
green dots = unmovable points
Start at the corners:
View attachment 158504
Narrowing in, nothing happening yet:
View attachment 158505
First unmovable points added, and purple dots inbetween:
View attachment 158506
More unmovable points added, more purple dots added:
View attachment 158507
More unmovable points added, more purple dots added:
View attachment 158508
More unmovable points added, more purple dots added:
View attachment 158509
At this point I started losing my sanity trying to do this by hand. I hope it illustrates the concept well enough. (And I'm certain I've made multiple mistakes when I drew dots, but it should be correct enough to show how it would work.)