forked from Yongjiao/Ramer-Douglas-Peucker-Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
simplifyPath.h
53 lines (39 loc) · 1.25 KB
/
simplifyPath.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// simplifyPath.h
// RDP
//
// Created by Yongjiao Yu on 14-6-13.
// Copyright (c) 2014年 ___RCPD___. All rights reserved.
//
#ifndef __simplifyPath__H__
#define __simplifyPath__H__
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cmath>
//"Point" struct stand for each GPS coordinates(x,y). Methods related are used only for simplification of calculation in implementation.
typedef struct Point{
double x;
double y;
double operator*(Point rhs)const{
return (this->x * rhs.y - rhs.x * this->y);
}
Point operator-(Point rhs)const{
Point p;
p.x=this->x-rhs.x;
p.y=this->y-rhs.y;
return p;
}
double Norm()const{
return sqrt(this->x * this->x + this->y * this->y);
}
}Point;
class simplifyPath{
//"findMaximumDistance" used as part of implementation for RDP algorithm.
private:
const std::pair<int, double> findMaximumDistance(const std::vector<Point>& Points)const;
//"simplifyWithRDP" returns the simplified path with a Point vector. The function takes in the paths to be simplified and a customerized thresholds for the simplication.
public:
std::vector<Point> simplifyWithRDP(std::vector<Point>& Points, double epsilon)const;
};
#endif