diff options
author | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2009-10-04 23:02:37 +0000 |
---|---|---|
committer | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2009-10-04 23:02:37 +0000 |
commit | 20bea4c689534c59eabc46ae809051ed04aa0bac (patch) | |
tree | 10f95b833480bfa07e851699b80f2be67e30e6cb /navit/transform.c | |
parent | 7c7d35da9659b3f81aed66e4f9a21c45bb2d99a4 (diff) | |
download | navit-svn-20bea4c689534c59eabc46ae809051ed04aa0bac.tar.gz |
Add:Core:Added possibility for binfile logging with dp point reduction
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@2627 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/transform.c')
-rw-r--r-- | navit/transform.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/navit/transform.c b/navit/transform.c index 55e6725d..a1a1dbb7 100644 --- a/navit/transform.c +++ b/navit/transform.c @@ -1042,6 +1042,30 @@ transform_distance_polyline_sq(struct coord *c, int count, struct coord *ref, st return dist; } +int +transform_douglas_peucker(struct coord *in, int count, int dist_sq, struct coord *out) +{ + int ret=0; + int i,d,dmax=0, idx=0; + for (i = 1; i < count-1 ; i++) { + d=transform_distance_line_sq(&in[0], &in[count-1], &in[i], NULL); + if (d > dmax) { + idx=i; + dmax=d; + } + } + if (dmax > dist_sq) { + ret=transform_douglas_peucker(in, idx+1, dist_sq, out)-1; + ret+=transform_douglas_peucker(in+idx, count-idx, dist_sq, out+ret); + } else { + if (count > 0) + out[ret++]=in[0]; + if (count > 1) + out[ret++]=in[count-1]; + } + return ret; +} + void transform_print_deg(double deg) |