Reduce number of points in line

前端 未结 8 2110
Happy的楠姐
Happy的楠姐 2020-12-05 11:38

I\'m searching for algorithms to reduce the LOD of polylines, lines (looped or not) of nodes. In simple words, I want to take hi-resolution coastline data and be able to re

相关标签:
8条回答
  • 2020-12-05 11:53

    In regards to culebron's answer, is the recursive call correct? From what I understand, RDP breaks up a a line into two different lines: start to max, and max to end.

    But looking at the call, where pos is the index of the max dist in the list...

    return (ramerdouglas(line[:pos + 2], dist) + 
            ramerdouglas(line[pos + 1:], dist)[1:])
    

    is instead doing start to max+1, max+1 to end. Shouldn't it be...

    return (ramerdouglas(line[:pos + 1], dist) + 
            ramerdouglas(line[pos:], dist)[1:])
    
    0 讨论(0)
  • 2020-12-05 12:01

    Adding to the slew of answers. I found a javascript implementation at this github repo: https://github.com/mourner/simplify-js

    There's also a list of different implementations of the Ramer-Douglas-Peucker algorithm in different languages.

    0 讨论(0)
提交回复
热议问题