Skip to content
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

Merged
merged 40 commits into from
Sep 14, 2018
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
2bf85f4
Adding Frechet Distance And Haudorff Distance algorithms
Jun 18, 2018
2d9e66c
Updating Frechet Distance and Hausdorff Distance
Jun 20, 2018
1e16e29
[algorithms] Extending Hausdorff Distance for Linestring and MultiLin…
Jun 21, 2018
b78200f
[algorithms] Updated Copyright
Jun 21, 2018
9dae6ec
[algorithms] Using Linestrin_Linestring() for Linestrin_MultiLinestring
Jun 22, 2018
495f82d
Extended Hausdorff Distance for MultiLinestring_MultiLinestring
Jun 23, 2018
95218f3
[algorihtms] Extended algorihtm for point-MultiPoint and Multi-Point
Jun 23, 2018
3019282
[algorihtms] Updated frechet_distance.hpp
Jun 25, 2018
57aba31
[test][similarity] Tests for hausdorff distance algorithm
Jul 1, 2018
3722dd5
[test][similarity] Updated tet for hausdorff distance
Jul 2, 2018
29866d5
[test][similarity] Tests for frechet distance algorithms
Jul 3, 2018
504848c
[test][similarity] Update tests for hausdorff distance algorithm
Jul 3, 2018
26025e0
[test][similarity] Update tests for frechet distance algorithm
Jul 3, 2018
a34d4a0
[algorithms] Updated hausdorff distance algorithm
Jul 4, 2018
13f1203
[test][similarity] Updated test files
Jul 5, 2018
dde8666
[algorithms] Updated frechet and hausdorff distance algorithm
Jul 5, 2018
752f6df
[test][similarity] Updated
Jul 6, 2018
263a75f
[test][similarity] Added test for edge cases
Jul 7, 2018
3e9f527
[algorithms] Updated hausdorff distance algorithm using R-tree
Jul 8, 2018
dcae80d
[algorithms] Updated hausdorff_distance.hpp
Jul 9, 2018
ff68b40
[algorithms] Updated
Jul 10, 2018
a9ac6d8
[algorithms]Rename Hausdorff Distance and Frechet Distance algorithms
Jul 31, 2018
3b22b04
[test][similarity] Rename Hausdorff Distance and Frechet Distance tes…
Jul 31, 2018
0591e10
[doc][similarity] add documentation for discrete_frechet_disatance an…
Aug 2, 2018
fc0f552
[doc][similarity] Add documentation for algorithm for finding similar…
Aug 6, 2018
50ca27e
[doc][similarity] Updated documentation for the similarity algorithms
Aug 11, 2018
da3ecd4
[doc][similarity] Updated documentation for the similarity algorithms…
Aug 13, 2018
8fdf0ad
[algorithms] Updated the function's names
Aug 13, 2018
54b71c1
[doc][similarity] Added Strategies in the documentation
Aug 14, 2018
81634c2
[doc][similarity] Added Strategies in the documentation
Aug 14, 2018
b27c81f
[doc][similarity] Added Strategies in the documentation
Aug 14, 2018
a8ae2a9
[doc][similarity] Updated Examples
Aug 15, 2018
60ea4b2
[test][similarity] Updated
Aug 15, 2018
cbb635b
[test][similarity] Updated indentation in test files
Aug 15, 2018
f526bb8
Merge branch 'develop' into feature/similarity
yaghya Aug 15, 2018
5aa539d
Updated
Aug 15, 2018
475e53b
[doc][similarity] updated
Aug 26, 2018
329652b
[doc][similarity] Updated for geographic strategies
Aug 30, 2018
cc69fc2
[test][similarity] Added test cases for geographic strategies
Aug 30, 2018
5ee0347
[doc][similarity] updated
Aug 30, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/doxy/doxygen_input/groups/groups.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Modifications 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)
Expand All @@ -32,6 +33,8 @@
\defgroup cs coordinate systems
\defgroup densify densify: add points to geometry, keeping shape
\defgroup difference difference: difference of two geometries
\defgroup discrete_frechet_distance discrete_frechet_distance : calculate discrete frechet distance between two geometries
\defgroup discrete_hausdorff_distance discrete_hausdorff_distance : calculate discrete hausdorff distance between two geometries
\defgroup disjoint disjoint: detect if geometries are not spatially related
\defgroup distance distance: calculate distance between two geometries
\defgroup enum enum: enumerations
Expand Down
2 changes: 2 additions & 0 deletions doc/imports.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
[import src/examples/algorithms/relation.cpp]
[import src/examples/algorithms/reverse.cpp]
[import src/examples/algorithms/return_envelope.cpp]
[import src/examples/algorithms/discrete_frechet_distance.cpp]
[import src/examples/algorithms/discrete_hausdorff_distance.cpp]
[import src/examples/algorithms/simplify.cpp]
[import src/examples/algorithms/sym_difference.cpp]
[import src/examples/algorithms/transform.cpp]
Expand Down
5 changes: 2 additions & 3 deletions doc/make_qbk.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#
# 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)
Expand Down Expand Up @@ -97,12 +96,12 @@ def cs_to_quickbook(section):

algorithms = ["append", "assign", "make", "clear"
, "area", "buffer", "centroid", "convert", "correct", "covered_by"
, "convex_hull", "crosses", "densify", "difference", "disjoint", "distance"
, "convex_hull", "crosses", "densify", "difference", "discrete_frechet_distance","discrete_hausdorff_distance","disjoint", "distance"
, "envelope", "equals", "expand", "for_each", "is_empty"
, "is_simple", "is_valid", "intersection", "intersects", "length"
, "num_geometries", "num_interior_rings", "num_points"
, "num_segments", "overlaps", "perimeter", "relate", "relation"
, "reverse", "simplify", "sym_difference", "touches"
, "reverse","simplify", "sym_difference", "touches"
, "transform", "union", "unique", "within"]

access_functions = ["get", "set", "exterior_ring", "interior_rings"
Expand Down
8 changes: 8 additions & 0 deletions doc/quickref.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle

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)
Expand Down Expand Up @@ -447,6 +450,11 @@
<simplelist type="vert" columns="1">
<member><link linkend="geometry.reference.algorithms.reverse">reverse</link></member>
</simplelist>
<bridgehead renderas="sect3">Similarity</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="geometry.reference.algorithms.discrete_frechet_distance">discrete_frechet_distance</link></member>
<member><link linkend="geometry.reference.algorithms.discrete_hausdorff_distance">discrete_hausdorff_distance</link></member>
</simplelist>
<bridgehead renderas="sect3">Simplify</bridgehead>
<simplelist type="vert" columns="1">
<member><link linkend="geometry.reference.algorithms.simplify">simplify</link></member>
Expand Down
9 changes: 9 additions & 0 deletions doc/reference.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@
[include generated/difference.qbk]
[endsect]

[section:discrete_frechet_distance discrete_frechet_distance]
[include generated/discrete_frechet_distance.qbk]
[endsect]

[section:discrete_hausdorff_distance discrete_hausdorff_distance]
[include generated/discrete_hausdorff_distance.qbk]
[endsect]

[section:disjoint disjoint]
[include generated/disjoint.qbk]
[endsect]
Expand Down Expand Up @@ -184,6 +192,7 @@

[include generated/reverse.qbk]


Copy link
Member

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.

[section:simplify simplify]
[include generated/simplify.qbk]
[endsect]
Expand Down
19 changes: 19 additions & 0 deletions doc/reference/algorithms/discrete_frechet_distance.qbk
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.]
19 changes: 19 additions & 0 deletions doc/reference/algorithms/discrete_hausdorff_distance.qbk
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.]
3 changes: 3 additions & 0 deletions doc/src/examples/algorithms/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ exe correct : correct.cpp ;

exe densify : densify.cpp ;
exe densify_strategy : densify_strategy.cpp ;
exe discrete_frechet_distance : discrete_frechet_distance.cpp ;
exe discrete_hausdorff_distance : discrete_hausdorff_distance.cpp ;
exe difference : difference.cpp ;
exe distance : distance.cpp ;

Expand Down Expand Up @@ -85,6 +87,7 @@ exe relation : relation.cpp ;

exe reverse : reverse.cpp ;


exe simplify : length.cpp ;
exe sym_difference : sym_difference.cpp ;

Expand Down
35 changes: 35 additions & 0 deletions doc/src/examples/algorithms/discrete_frechet_distance.cpp
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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Namespace missing. But since your point type is double you can simply use double here. It's an example and it should be simple:

double res = ...

res = boost::geometry::frechet_distance(linestring1,linestrign2);
Copy link
Member

Choose a reason for hiding this comment

The 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
]
*/
//]
35 changes: 35 additions & 0 deletions doc/src/examples/algorithms/discrete_hausdorff_distance.cpp
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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double res = ...

std::cout << "Discrete Hausdorff Distance: " << res << std::endl;
return 0;
}
//]
//[discrete_hausdorff_distance_output
/*`
Output:
[pre
Discrete Hausdorff Distance: 1.0
]
*/
//]
Loading