开发者

Convert simplified discrete area to borders polygon

开发者 https://www.devze.com 2023-02-09 13:12 出处:网络
suppose that I have discrete map, on this map appears country represented by color blue: country area is always coherent.

suppose that I have discrete map, on this map appears country represented by color blue:

Convert simplified discrete area to borders polygon

country area is always coherent.

Now I开发者_JAVA百科 want to extract borders from it:

Convert simplified discrete area to borders polygon

So:

  • I have a list of unordered tiles of country, in this case: (3,3), (4,3), (4,4)...
  • I want to extract ordered sequence of borders, in this case: ((2,2),(3,2)), ((3,2),(4,2)),.... where ((x1,y1),(x2,y2)) means that beggining of border starts in (x1,y1) and ends in (x2,y2)


  1. Firstly find the rightest point in your matrix no matter how tall. If you finded points with same x, choose arbitrarily.
  2. Find all borders of this point.
  3. If you have a point bordering on top, go for it, else go to the right, else go to the bottom, else go to the left, go to the direction where have border with other point, always in that order. If encountered point is the initial point, go to step 7, else go to the next step.
  4. store the two points (principal point, encountered point) in your path.
  5. Now the encountered point is principal point.
  6. Go to step 2
  7. the path contains what you want
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号