-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Frechet distance And Hausdorff distance algorithms to calculate Simmilarity Between Geometries #490
Changes from 31 commits
2bf85f4
2d9e66c
1e16e29
b78200f
9dae6ec
495f82d
95218f3
3019282
57aba31
3722dd5
29866d5
504848c
26025e0
a34d4a0
13f1203
dde8666
752f6df
263a75f
3e9f527
dcae80d
ff68b40
a9ac6d8
3b22b04
0591e10
fc0f552
50ca27e
da3ecd4
8fdf0ad
54b71c1
81634c2
b27c81f
a8ae2a9
60ea4b2
cbb635b
f526bb8
5aa539d
475e53b
329652b
cc69fc2
5ee0347
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[/============================================================================ | ||
Boost.Geometry | ||
|
||
Copyright (c) 2018 Yaghyavardhan Singh Khangarot, Hyderabad, India. | ||
Contributed and/or modified by Yaghyavardhan Singh Khangarot, as part of Google Summer of Code 2018 program. | ||
|
||
Use, modification and distribution is subject to the Boost Software License, | ||
Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | ||
http://www.boost.org/LICENSE_1_0.txt) | ||
=============================================================================/] | ||
|
||
[def __this_function__ discrete_frechet_distance] | ||
|
||
[heading Behavior] | ||
The algorithm calculate discrete frechet distance between two geometries. | ||
|
||
[note The units of the distance depends on strategy. In order to change the | ||
default behavior a user has to create a strategy and pass it explicitly into | ||
the algorithm.] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[/============================================================================ | ||
Boost.Geometry | ||
|
||
Copyright (c) 2018 Yaghyavardhan Singh Khangarot, Hyderabad, India. | ||
Contributed and/or modified by Yaghyavardhan Singh Khangarot, as part of Google Summer of Code 2018 program. | ||
|
||
Use, modification and distribution is subject to the Boost Software License, | ||
Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | ||
http://www.boost.org/LICENSE_1_0.txt) | ||
=============================================================================/] | ||
|
||
[def __this_function__ discrete_hausdorff_distance] | ||
|
||
[heading Behavior] | ||
The algorithm calculate discrete hausdorff distance between two geometries. | ||
|
||
[note The units of the distance depends on strategy. In order to change the | ||
default behavior a user has to create a strategy and pass it explicitly into | ||
the algorithm.] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Boost.Geometry | ||
// QuickBook Example | ||
// Copyright (c) 2018, Oracle and/or its affiliates | ||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle | ||
// Use, modification and distribution is subject to the Boost Software License, | ||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | ||
// http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
//[discrete_frechet_distance | ||
//` Calculate Similarity between two geometries as the discrete frechet distance between them. | ||
#include <iostream> | ||
#include <boost/geometry.hpp> | ||
#include <boost/geometry/geometries/point_xy.hpp> | ||
#include <boost/geometry/geometries/linestring.hpp> | ||
int main() | ||
{ | ||
typedef boost::geometry::model::d2::point_xy<double> point_type; | ||
typedef boost::geometry::model::linestring<point_type> linestring_type; | ||
linestring_type linestring1,linestring2; | ||
boost::geometry::read_wkt("LINESTRING(0 0,1 1,1 2,2 1,2 2)", linestring1); | ||
boost::geometry::read_wkt("LINESTRING(1 0,0 1,1 1,2 1,3 1)", linestring2); | ||
typename distance_result<typename point_type<point_type>::type,typename point_type<linestring_type>::type>::type res; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Namespace missing. But since your point type is
|
||
res = boost::geometry::frechet_distance(linestring1,linestrign2); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wrong function name. |
||
std::cout << "Discrete Frechet Distance: " << res << std::endl; | ||
return 0; | ||
} | ||
//] | ||
//[discrete_frechet_distance_output | ||
/*` | ||
Output: | ||
[pre | ||
Discrete Frechet Distance: 1.41421 | ||
] | ||
*/ | ||
//] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Boost.Geometry | ||
// QuickBook Example | ||
// Copyright (c) 2018, Oracle and/or its affiliates | ||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle | ||
// Use, modification and distribution is subject to the Boost Software License, | ||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | ||
// http://www.boost.org/LICENSE_1_0.txt) | ||
|
||
//[discrete_hausdorff_distance | ||
//` Calculate Similarity between two geometries as the discrete hasdorff distance between them. | ||
#include <iostream> | ||
#include <boost/geometry.hpp> | ||
#include <boost/geometry/geometries/point_xy.hpp> | ||
#include <boost/geometry/geometries/linestring.hpp> | ||
int main() | ||
{ | ||
typedef boost::geometry::model::d2::point_xy<double> point_type; | ||
typedef boost::geometry::model::linestring<point_type> linestring_type; | ||
linestring_type linestring1,linestring2; | ||
boost::geometry::read_wkt("LINESTRING(0 0,1 1,1 2,2 1,2 2)", linestring1); | ||
boost::geometry::read_wkt("LINESTRING(1 0,0 1,1 1,2 1,3 1)", linestring2); | ||
typename distance_result<typename point_type<point_type>::type,typename point_type<linestring_type>::type>::type res; | ||
res = boost::geometry::hausdorff_distance(linestring1,linestring2); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
std::cout << "Discrete Hausdorff Distance: " << res << std::endl; | ||
return 0; | ||
} | ||
//] | ||
//[discrete_hausdorff_distance_output | ||
/*` | ||
Output: | ||
[pre | ||
Discrete Hausdorff Distance: 1.0 | ||
] | ||
*/ | ||
//] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work does it? Anyway, in the reference you should have both algorithms like it was before.