summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/geometry/test/algorithms/similarity
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
commit483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch)
treee5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/boost/libs/geometry/test/algorithms/similarity
parentInitial commit. (diff)
downloadceph-upstream.tar.xz
ceph-upstream.zip
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/geometry/test/algorithms/similarity')
-rw-r--r--src/boost/libs/geometry/test/algorithms/similarity/Jamfile.v215
-rw-r--r--src/boost/libs/geometry/test/algorithms/similarity/discrete_frechet_distance.cpp95
-rw-r--r--src/boost/libs/geometry/test/algorithms/similarity/discrete_hausdorff_distance.cpp118
-rw-r--r--src/boost/libs/geometry/test/algorithms/similarity/test_frechet_distance.hpp144
-rw-r--r--src/boost/libs/geometry/test/algorithms/similarity/test_hausdorff_distance.hpp138
5 files changed, 510 insertions, 0 deletions
diff --git a/src/boost/libs/geometry/test/algorithms/similarity/Jamfile.v2 b/src/boost/libs/geometry/test/algorithms/similarity/Jamfile.v2
new file mode 100644
index 00000000..f8452b1a
--- /dev/null
+++ b/src/boost/libs/geometry/test/algorithms/similarity/Jamfile.v2
@@ -0,0 +1,15 @@
+# Boost.Geometry (aka GGL, Generic Geometry Library)
+#
+# 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)
+
+test-suite boost-geometry-algorithms-similarity
+ :
+ [ run discrete_frechet_distance.cpp : : : : algorithms_discrete_frechet_distance ]
+ [ run discrete_hausdorff_distance.cpp : : : : algorithms_discrete_hausdorff_distance ]
+ ;
diff --git a/src/boost/libs/geometry/test/algorithms/similarity/discrete_frechet_distance.cpp b/src/boost/libs/geometry/test/algorithms/similarity/discrete_frechet_distance.cpp
new file mode 100644
index 00000000..35e55258
--- /dev/null
+++ b/src/boost/libs/geometry/test/algorithms/similarity/discrete_frechet_distance.cpp
@@ -0,0 +1,95 @@
+// 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)
+
+#include <vector>
+
+#include <boost/geometry/geometries/linestring.hpp>
+#include <boost/geometry/geometries/point_xy.hpp>
+#include <boost/geometry/geometries/polygon.hpp>
+
+#include "test_frechet_distance.hpp"
+
+ template <typename P>
+void test_all_cartesian()
+{
+ typedef bg::model::linestring<P> linestring_2d;
+#ifdef BOOST_GEOMETRY_TEST_DEBUG
+ typedef typename coordinate_system<P>::type CordType;
+ std::cout << typeid(CordType).name() << std::endl;
+#endif
+
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(3 0,2 1,3 2)","LINESTRING(0 0,3 4,4 3)", 3);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(3 0,2 1,3 2)","LINESTRING(0 0,3 4,4 3)",bg::strategy::distance::pythagoras<>(), 3);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 1, 0 0)","LINESTRING(0 0, 1 0, 1 1, 0 1, 0 0)",0);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 1, 0 0)","LINESTRING(1 1, 0 1, 0 0, 1 0, 1 1)",sqrt(2.0));
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 0)","LINESTRING(0 0, 1 0, 1 1, 0 0)",0);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 0)","LINESTRING(1 1, 0 0, 1 0, 1 1)",sqrt(2.0));
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0)","LINESTRING(0 0, 1 0)",0);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0,3 4,4 3)","LINESTRING(4 3,3 4,0 0)",5);
+
+
+}
+
+ template <typename P>
+void test_all_geographic()
+{
+ typedef bg::model::linestring<P> linestring_2d;
+
+#ifdef BOOST_GEOMETRY_TEST_DEBUG
+ typedef typename coordinate_system<P>::type CordType;
+ std::cout << typeid(CordType).name() << std::endl;
+#endif
+
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(3 0,2 1,3 2)","LINESTRING(0 0,3 4,4 3)", 333958);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(3 0,2 1,3 2)","LINESTRING(0 0,3 4,4 3)",bg::strategy::distance::geographic<bg::strategy::vincenty>(), 333958.472379679);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(3 0,2 1,3 2)","LINESTRING(0 0,3 4,4 3)",bg::strategy::distance::geographic<bg::strategy::thomas>(), 333958.472379679);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 1, 0 0)","LINESTRING(0 0, 1 0, 1 1, 0 1, 0 0)",0);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 1, 0 0)","LINESTRING(1 1, 0 1, 0 0, 1 0, 1 1)",156898);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 0)","LINESTRING(0 0, 1 0, 1 1, 0 0)",0);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 0)","LINESTRING(1 1, 0 0, 1 0, 1 1)",156898);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0)","LINESTRING(0 0, 1 0)",0);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0,3 4,4 3)","LINESTRING(4 3,3 4,0 0)",555093);
+
+}
+
+ template <typename P>
+void test_all_spherical_equ()
+{
+ typedef bg::model::linestring<P> linestring_2d;
+
+#ifdef BOOST_GEOMETRY_TEST_DEBUG
+ typedef typename coordinate_system<P>::type CordType;
+ std::cout << typeid(CordType).name() << std::endl;
+#endif
+
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(3 0,2 1,3 2)","LINESTRING(0 0,3 4,4 3)", 0.05235987);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(3 0,2 1,3 2)","LINESTRING(0 0,3 4,4 3)",bg::strategy::distance::haversine<int>(), 0.05235987);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 1, 0 0)","LINESTRING(0 0, 1 0, 1 1, 0 1, 0 0)",0);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 1, 0 0)","LINESTRING(1 1, 0 1, 0 0, 1 0, 1 1)",0.02468205);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 0)","LINESTRING(0 0, 1 0, 1 1, 0 0)",0);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 0)","LINESTRING(1 1, 0 0, 1 0, 1 1)",0.02468205);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0)","LINESTRING(0 0, 1 0)",0);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0,3 4,4 3)","LINESTRING(4 3,3 4,0 0)",0.0872409);
+
+}
+
+int test_main(int, char* [])
+{
+ //Cartesian Coordinate System
+ test_all_cartesian<bg::model::d2::point_xy<double,bg::cs::cartesian> >();
+
+ //Geographic Coordinate System
+ test_all_geographic<bg::model::d2::point_xy<double,bg::cs::geographic<bg::degree> > >();
+
+ //Spherical_Equatorial Coordinate System
+ test_all_spherical_equ<bg::model::d2::point_xy<double,bg::cs::spherical_equatorial<bg::degree> > >();
+
+ return 0;
+}
diff --git a/src/boost/libs/geometry/test/algorithms/similarity/discrete_hausdorff_distance.cpp b/src/boost/libs/geometry/test/algorithms/similarity/discrete_hausdorff_distance.cpp
new file mode 100644
index 00000000..d5d98cdc
--- /dev/null
+++ b/src/boost/libs/geometry/test/algorithms/similarity/discrete_hausdorff_distance.cpp
@@ -0,0 +1,118 @@
+// 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.
+
+// This file was modified by Oracle on 2018.
+// 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)
+
+#include <vector>
+
+#include <boost/geometry/geometries/linestring.hpp>
+#include <boost/geometry/geometries/point_xy.hpp>
+#include <boost/geometry/geometries/polygon.hpp>
+#include <boost/geometry/geometries/multi_linestring.hpp>
+#include <boost/geometry/geometries/multi_point.hpp>
+
+#include "test_hausdorff_distance.hpp"
+
+ template <typename P>
+void test_all_cartesian()
+{
+ typedef bg::model::linestring<P> linestring_2d;
+ typedef bg::model::multi_linestring<linestring_2d> mlinestring_t;
+ typedef bg::model::multi_point<P> mpoint_t;
+
+#ifdef BOOST_GEOMETRY_TEST_DEBUG
+ typedef typename coordinate_system<P>::type CordType;
+ std::cout << typeid(CordType).name() << std::endl;
+#endif
+
+ test_geometry<P,mpoint_t>("POINT(3 1)","MULTIPOINT(0 0,3 4,4 3)", sqrt(5.0));
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(3 0,2 1,3 2)","LINESTRING(0 0,3 4,4 3)", 3);
+ test_geometry<mpoint_t,mpoint_t>("MULTIPOINT(3 0,2 1,3 2)","MULTIPOINT(0 0,3 4,4 3)", 3);
+ test_geometry<linestring_2d,mlinestring_t >("LINESTRING(1 1,2 2,4 3)","MULTILINESTRING((0 0,3 4,4 3),(1 1,2 2,4 3))", sqrt(5.0));
+ test_geometry<mlinestring_t,mlinestring_t >("MULTILINESTRING((3 0,2 1,3 2),(0 0,3 4,4 3))","MULTILINESTRING((0 0,3 4,4 3),(3 0,2 1,3 2))", 3);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 1, 0 0)","LINESTRING(0 0, 1 0, 1 1, 0 1, 0 0)",0);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 1, 0 0)","LINESTRING(1 1, 0 1, 0 0, 1 0, 1 1)",0);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 0)","LINESTRING(0 0, 1 0, 1 1, 0 0)",0);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 0)","LINESTRING(1 1, 0 0, 1 0, 1 1)",0);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0)","LINESTRING(0 0, 1 0)",0);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0,3 4,4 3)","LINESTRING(4 3,3 4,0 0)",0);
+}
+
+ template <typename P>
+void test_all_geographic()
+{
+ typedef bg::model::linestring<P> linestring_2d;
+ typedef bg::model::multi_linestring<linestring_2d> mlinestring_t;
+ typedef bg::model::multi_point<P> mpoint_t;
+#ifdef BOOST_GEOMETRY_TEST_DEBUG
+ typedef typename coordinate_system<P>::type CordType;
+ std::cout << typeid(CordType).name() << std::endl;
+#endif
+
+ test_geometry<P,mpoint_t>("POINT(3 1)","MULTIPOINT(0 0,3 4,4 3)", 247552);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(3 0,2 1,3 2)","LINESTRING(0 0,3 4,4 3)", 333958);
+ test_geometry<mpoint_t,mpoint_t>("MULTIPOINT(3 0,2 1,3 2)","MULTIPOINT(0 0,3 4,4 3)", 333958);
+ test_geometry<linestring_2d,mlinestring_t >("LINESTRING(1 1,2 2,4 3)","MULTILINESTRING((0 0,3 4,4 3),(1 1,2 2,4 3))", 247518);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(3 0,2 1,3 2)","LINESTRING(0 0,3 4,4 3)",bg::strategy::distance::geographic<bg::strategy::vincenty>(), 333958.472379679);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(3 0,2 1,3 2)","LINESTRING(0 0,3 4,4 3)",bg::strategy::distance::geographic<bg::strategy::thomas>(), 333958.472379679);
+ test_geometry<mlinestring_t,mlinestring_t >("MULTILINESTRING((3 0,2 1,3 2),(0 0,3 4,4 3))","MULTILINESTRING((0 0,3 4,4 3),(3 0,2 1,3 2))",333958);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 1, 0 0)","LINESTRING(0 0, 1 0, 1 1, 0 1, 0 0)",0);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 1, 0 0)","LINESTRING(1 1, 0 1, 0 0, 1 0, 1 1)",0);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 0)","LINESTRING(0 0, 1 0, 1 1, 0 0)",0);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 0)","LINESTRING(1 1, 0 0, 1 0, 1 1)",0);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0)","LINESTRING(0 0, 1 0)",0);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0,3 4,4 3)","LINESTRING(4 3,3 4,0 0)",0);
+}
+
+ template <typename P>
+void test_all_spherical_equ()
+{
+ typedef bg::model::linestring<P> linestring_2d;
+ typedef bg::model::multi_linestring<linestring_2d> mlinestring_t;
+ typedef bg::model::multi_point<P> mpoint_t;
+
+#ifdef BOOST_GEOMETRY_TEST_DEBUG
+ typedef typename coordinate_system<P>::type CordType;
+ std::cout << typeid(CordType).name() << std::endl;
+#endif
+
+ test_geometry<P,mpoint_t>("POINT(3 1)","MULTIPOINT(0 0,3 4,4 3)", 0.03902);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(3 0,2 1,3 2)","LINESTRING(0 0,3 4,4 3)", 0.05236);
+ test_geometry<mpoint_t,mpoint_t>("MULTIPOINT(3 0,2 1,3 2)","MULTIPOINT(0 0,3 4,4 3)", 0.05236);
+ test_geometry<linestring_2d,mlinestring_t >("LINESTRING(1 1,2 2,4 3)","MULTILINESTRING((0 0,3 4,4 3),(1 1,2 2,4 3))", 0.03900);
+ test_geometry<mlinestring_t,mlinestring_t >("MULTILINESTRING((3 0,2 1,3 2),(0 0,3 4,4 3))","MULTILINESTRING((0 0,3 4,4 3),(3 0,2 1,3 2))",0.05236);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 1, 0 0)","LINESTRING(0 0, 1 0, 1 1, 0 1, 0 0)",0);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 1, 0 0)","LINESTRING(1 1, 0 1, 0 0, 1 0, 1 1)",0);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 0)","LINESTRING(0 0, 1 0, 1 1, 0 0)",0);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0, 1 1, 0 0)","LINESTRING(1 1, 0 0, 1 0, 1 1)",0);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0, 1 0)","LINESTRING(0 0, 1 0)",0);
+ test_geometry<linestring_2d,linestring_2d >("LINESTRING(0 0,3 4,4 3)","LINESTRING(4 3,3 4,0 0)",0);
+}
+
+int test_main(int, char* [])
+{
+ //Cartesian Coordinate System
+ test_all_cartesian<bg::model::d2::point_xy<int,bg::cs::cartesian> >();
+ test_all_cartesian<bg::model::d2::point_xy<float,bg::cs::cartesian> >();
+ test_all_cartesian<bg::model::d2::point_xy<double,bg::cs::cartesian> >();
+
+ //Geographic Coordinate System
+ test_all_geographic<bg::model::d2::point_xy<float,bg::cs::geographic<bg::degree> > >();
+ test_all_geographic<bg::model::d2::point_xy<double,bg::cs::geographic<bg::degree> > >();
+
+ //Spherical_Equatorial Coordinate System
+ test_all_spherical_equ<bg::model::d2::point_xy<float,bg::cs::spherical_equatorial<bg::degree> > >();
+ test_all_spherical_equ<bg::model::d2::point_xy<double,bg::cs::spherical_equatorial<bg::degree> > >();
+
+ return 0;
+}
diff --git a/src/boost/libs/geometry/test/algorithms/similarity/test_frechet_distance.hpp b/src/boost/libs/geometry/test/algorithms/similarity/test_frechet_distance.hpp
new file mode 100644
index 00000000..cca02852
--- /dev/null
+++ b/src/boost/libs/geometry/test/algorithms/similarity/test_frechet_distance.hpp
@@ -0,0 +1,144 @@
+// 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)
+
+#ifndef BOOST_GEOMETRY_TEST_FRECHET_DISTANCE_HPP
+#define BOOST_GEOMETRY_TEST_FRECHET_DISTANCE_HPP
+
+#include <geometry_test_common.hpp>
+#include <boost/geometry/algorithms/discrete_frechet_distance.hpp>
+#include <boost/geometry/io/wkt/wkt.hpp>
+#include <boost/geometry/strategies/strategies.hpp>
+#include <boost/variant/variant.hpp>
+
+template <typename Geometry1,typename Geometry2>
+void test_frechet_distance(Geometry1 const& geometry1,Geometry2 const& geometry2,
+ typename bg::distance_result
+ <
+ typename bg::point_type<Geometry1>::type,
+ typename bg::point_type<Geometry2>::type
+ >::type expected_frechet_distance )
+{
+ using namespace bg;
+ typedef typename distance_result
+ <
+ typename point_type<Geometry1>::type,
+ typename point_type<Geometry2>::type
+ >::type result_type;
+ result_type h_distance = bg::discrete_frechet_distance(geometry1,geometry2);
+
+#ifdef BOOST_GEOMETRY_TEST_DEBUG
+ std::ostringstream out;
+ out << typeid(typename bg::coordinate_type<Geometry1>::type).name()
+ << std::endl
+ << typeid(typename bg::coordinate_type<Geometry2>::type).name()
+ << std::endl
+ << typeid(h_distance).name()
+ << std::endl
+ << "frechet_distance : " << bg::discrete_frechet_distance(geometry1,geometry2)
+ << std::endl;
+ std::cout << out.str();
+#endif
+
+ BOOST_CHECK_CLOSE(h_distance, expected_frechet_distance, 0.001);
+}
+
+
+
+template <typename Geometry1,typename Geometry2>
+void test_geometry(std::string const& wkt1,std::string const& wkt2,
+ typename bg::distance_result
+ <
+ typename bg::point_type<Geometry1>::type,
+ typename bg::point_type<Geometry2>::type
+ >::type expected_frechet_distance)
+{
+ Geometry1 geometry1;
+ bg::read_wkt(wkt1, geometry1);
+ Geometry2 geometry2;
+ bg::read_wkt(wkt2, geometry2);
+ test_frechet_distance(geometry1,geometry2,expected_frechet_distance);
+#if defined(BOOST_GEOMETRY_TEST_DEBUG)
+ test_frechet_distance(boost::variant<Geometry1>(geometry1),boost::variant<Geometry2>(geometry2), expected_frechet_distance);
+#endif
+}
+
+template <typename Geometry1,typename Geometry2 ,typename Strategy>
+void test_frechet_distance(Geometry1 const& geometry1,Geometry2 const& geometry2,Strategy strategy,
+ typename bg::distance_result
+ <
+ typename bg::point_type<Geometry1>::type,
+ typename bg::point_type<Geometry2>::type,
+ Strategy
+ >::type expected_frechet_distance )
+{
+ using namespace bg;
+ typedef typename distance_result
+ <
+ typename point_type<Geometry1>::type,
+ typename point_type<Geometry2>::type,
+ Strategy
+ >::type result_type;
+ result_type h_distance = bg::discrete_frechet_distance(geometry1,geometry2,strategy);
+
+#ifdef BOOST_GEOMETRY_TEST_DEBUG
+ std::ostringstream out;
+ out << typeid(typename bg::coordinate_type<Geometry1>::type).name()
+ << std::endl
+ << typeid(typename bg::coordinate_type<Geometry2>::type).name()
+ << std::endl
+ << typeid(h_distance).name()
+ << std::endl
+ << "frechet_distance : " << bg::discrete_frechet_distance(geometry1,geometry2,strategy)
+ << std::endl;
+ std::cout << out.str();
+#endif
+
+ BOOST_CHECK_CLOSE(h_distance, expected_frechet_distance, 0.001);
+}
+
+
+
+template <typename Geometry1,typename Geometry2,typename Strategy>
+void test_geometry(std::string const& wkt1,std::string const& wkt2,Strategy strategy,
+ typename bg::distance_result
+ <
+ typename bg::point_type<Geometry1>::type,
+ typename bg::point_type<Geometry2>::type,
+ Strategy
+ >::type expected_frechet_distance)
+{
+ Geometry1 geometry1;
+ bg::read_wkt(wkt1, geometry1);
+ Geometry2 geometry2;
+ bg::read_wkt(wkt2, geometry2);
+ test_frechet_distance(geometry1,geometry2,strategy,expected_frechet_distance);
+#if defined(BOOST_GEOMETRY_TEST_DEBUG)
+ test_frechet_distance(boost::variant<Geometry1>(geometry1),boost::variant<Geometry2>(geometry2),strategy, expected_frechet_distance);
+#endif
+}
+
+
+template <typename Geometry1,typename Geometry2>
+void test_empty_input(Geometry1 const& geometry1,Geometry2 const& geometry2)
+{
+ try
+ {
+ bg::discrete_frechet_distance(geometry1,geometry2);
+ }
+ catch(bg::empty_input_exception const& )
+ {
+ return;
+ }
+ BOOST_CHECK_MESSAGE(false, "A empty_input_exception should have been thrown" );
+}
+
+
+#endif
+
diff --git a/src/boost/libs/geometry/test/algorithms/similarity/test_hausdorff_distance.hpp b/src/boost/libs/geometry/test/algorithms/similarity/test_hausdorff_distance.hpp
new file mode 100644
index 00000000..8b96f610
--- /dev/null
+++ b/src/boost/libs/geometry/test/algorithms/similarity/test_hausdorff_distance.hpp
@@ -0,0 +1,138 @@
+// 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.
+
+// This file was modified by Oracle on 2018.
+// 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)
+
+#ifndef BOOST_GEOMETRY_TEST_HAUSDORFF_DISTANCE_HPP
+#define BOOST_GEOMETRY_TEST_HAUSDORFF_DISTANCE_HPP
+
+#include <geometry_test_common.hpp>
+#include <boost/geometry/algorithms/discrete_hausdorff_distance.hpp>
+#include <boost/geometry/io/wkt/wkt.hpp>
+#include <boost/geometry/strategies/strategies.hpp>
+#include <boost/variant/variant.hpp>
+
+template <typename Geometry1, typename Geometry2, typename Expected>
+void test_hausdorff_distance(Geometry1 const& geometry1, Geometry2 const& geometry2,
+ Expected const& expected_hausdorff_distance)
+{
+ typedef typename bg::distance_result
+ <
+ typename bg::point_type<Geometry1>::type,
+ typename bg::point_type<Geometry2>::type
+ >::type result_type;
+
+ result_type h_distance = bg::discrete_hausdorff_distance(geometry1, geometry2);
+
+#ifdef BOOST_GEOMETRY_TEST_DEBUG
+ std::ostringstream out;
+ out << typeid(typename bg::coordinate_type<Geometry1>::type).name()
+ << std::endl
+ << typeid(typename bg::coordinate_type<Geometry2>::type).name()
+ << std::endl
+ << typeid(h_distance).name()
+ << std::endl
+ << "hausdorff_distance : " << h_distance
+ << std::endl;
+ std::cout << out.str();
+#endif
+
+ BOOST_CHECK_CLOSE(h_distance, result_type(expected_hausdorff_distance), 0.01);
+}
+
+
+
+template <typename Geometry1, typename Geometry2, typename Expected>
+void test_geometry(std::string const& wkt1, std::string const& wkt2,
+ Expected const& expected_hausdorff_distance)
+{
+ Geometry1 geometry1;
+ bg::read_wkt(wkt1, geometry1);
+ Geometry2 geometry2;
+ bg::read_wkt(wkt2, geometry2);
+
+ test_hausdorff_distance(geometry1, geometry2, expected_hausdorff_distance);
+
+#if defined(BOOST_GEOMETRY_TEST_DEBUG)
+ test_hausdorff_distance(boost::variant<Geometry1>(geometry1),
+ boost::variant<Geometry2>(geometry2),
+ expected_hausdorff_distance);
+#endif
+}
+
+template <typename Geometry1, typename Geometry2, typename Strategy, typename Expected>
+void test_hausdorff_distance(Geometry1 const& geometry1, Geometry2 const& geometry2,
+ Strategy strategy, Expected const& expected_hausdorff_distance)
+{
+ typedef typename bg::distance_result
+ <
+ typename bg::point_type<Geometry1>::type,
+ typename bg::point_type<Geometry2>::type,
+ Strategy
+ >::type result_type;
+
+ result_type h_distance = bg::discrete_hausdorff_distance(geometry1, geometry2, strategy);
+
+#ifdef BOOST_GEOMETRY_TEST_DEBUG
+ std::ostringstream out;
+ out << typeid(typename bg::coordinate_type<Geometry1>::type).name()
+ << std::endl
+ << typeid(typename bg::coordinate_type<Geometry2>::type).name()
+ << std::endl
+ << typeid(h_distance).name()
+ << std::endl
+ << "hausdorff_distance : " << h_distance
+ << std::endl;
+ std::cout << out.str();
+#endif
+
+ BOOST_CHECK_CLOSE(h_distance, result_type(expected_hausdorff_distance), 0.01);
+}
+
+
+
+template <typename Geometry1, typename Geometry2, typename Strategy, typename Expected>
+void test_geometry(std::string const& wkt1, std::string const& wkt2,
+ Strategy strategy, Expected const& expected_hausdorff_distance)
+{
+ Geometry1 geometry1;
+ bg::read_wkt(wkt1, geometry1);
+ Geometry2 geometry2;
+ bg::read_wkt(wkt2, geometry2);
+
+ test_hausdorff_distance(geometry1, geometry2, strategy, expected_hausdorff_distance);
+
+#if defined(BOOST_GEOMETRY_TEST_DEBUG)
+ test_hausdorff_distance(boost::variant<Geometry1>(geometry1),
+ boost::variant<Geometry2>(geometry2),
+ strategy, expected_hausdorff_distance);
+#endif
+}
+
+
+template <typename Geometry1,typename Geometry2>
+void test_empty_input(Geometry1 const& geometry1, Geometry2 const& geometry2)
+{
+ try
+ {
+ bg::discrete_hausdorff_distance(geometry1, geometry2);
+ }
+ catch(bg::empty_input_exception const& )
+ {
+ return;
+ }
+ BOOST_CHECK_MESSAGE(false, "A empty_input_exception should have been thrown");
+}
+
+
+#endif
+