mirror of
https://github.com/boostorg/geometry.git
synced 2025-05-09 23:24:02 +00:00
[equals][index/examples] Optimize equals(Seg,Seg) and fix index/examples
Use less comparisions in equals(Seg,Seg) - suggested by Menelaos Karavelas Add missing include to examples - caused by the recent change of the distance/rtree
This commit is contained in:
parent
0918c754f7
commit
8aa3ef425e
@ -94,19 +94,19 @@ struct segment_segment
|
||||
template <typename Segment1, typename Segment2>
|
||||
static inline bool apply(Segment1 const& segment1, Segment2 const& segment2)
|
||||
{
|
||||
return ( equals::equals_point_point(
|
||||
return equals::equals_point_point(
|
||||
indexed_point_view<Segment1 const, 0>(segment1),
|
||||
indexed_point_view<Segment2 const, 0>(segment2) )
|
||||
&& equals::equals_point_point(
|
||||
? equals::equals_point_point(
|
||||
indexed_point_view<Segment1 const, 1>(segment1),
|
||||
indexed_point_view<Segment2 const, 1>(segment2) )
|
||||
) || ( equals::equals_point_point(
|
||||
indexed_point_view<Segment1 const, 0>(segment1),
|
||||
indexed_point_view<Segment2 const, 1>(segment2) )
|
||||
&& equals::equals_point_point(
|
||||
indexed_point_view<Segment1 const, 1>(segment1),
|
||||
indexed_point_view<Segment2 const, 0>(segment2) )
|
||||
);
|
||||
: ( equals::equals_point_point(
|
||||
indexed_point_view<Segment1 const, 0>(segment1),
|
||||
indexed_point_view<Segment2 const, 1>(segment2) )
|
||||
&& equals::equals_point_point(
|
||||
indexed_point_view<Segment1 const, 1>(segment1),
|
||||
indexed_point_view<Segment2 const, 0>(segment2) )
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/index/rtree.hpp>
|
||||
|
||||
#include <boost/chrono.hpp>
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/index/rtree.hpp>
|
||||
|
||||
#include <boost/chrono.hpp>
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/index/rtree.hpp>
|
||||
|
||||
#include <boost/chrono.hpp>
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/random.hpp>
|
||||
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/index/rtree.hpp>
|
||||
#include <boost/geometry/geometries/linestring.hpp>
|
||||
#include <boost/geometry/geometries/segment.hpp>
|
||||
@ -26,8 +27,10 @@ typedef bg::model::point<double, 2, bg::cs::cartesian> P;
|
||||
typedef bg::model::box<P> B;
|
||||
typedef bg::model::linestring<P> LS;
|
||||
typedef bg::model::segment<P> S;
|
||||
typedef B V;
|
||||
//typedef P V;
|
||||
typedef B V;
|
||||
//typedef S V;
|
||||
//#define SEGMENT_INDEXABLE
|
||||
|
||||
template <typename V>
|
||||
struct generate_value {};
|
||||
@ -38,6 +41,12 @@ struct generate_value<B>
|
||||
static inline B apply(float x, float y) { return B(P(x - 0.5f, y - 0.5f), P(x + 0.5f, y + 0.5f)); }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct generate_value<S>
|
||||
{
|
||||
static inline S apply(float x, float y) { return S(P(x - 0.5f, y - 0.5f), P(x + 0.5f, y + 0.5f)); }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct generate_value<P>
|
||||
{
|
||||
@ -278,6 +287,7 @@ int main()
|
||||
std::cout << time << " - range type-erased qbegin(B) qend() " << queries_count << " found " << temp << '\n';
|
||||
}
|
||||
|
||||
#ifndef SEGMENT_INDEXABLE
|
||||
{
|
||||
clock_t::time_point start = clock_t::now();
|
||||
size_t temp = 0;
|
||||
@ -304,6 +314,7 @@ int main()
|
||||
dur_t time = clock_t::now() - start;
|
||||
std::cout << time << " - query(i && !w && !c) " << queries_count << " found " << temp << '\n';
|
||||
}
|
||||
#endif
|
||||
|
||||
result.clear();
|
||||
|
||||
@ -376,6 +387,7 @@ int main()
|
||||
}
|
||||
|
||||
#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL
|
||||
#ifndef SEGMENT_INDEXABLE
|
||||
|
||||
{
|
||||
LS ls;
|
||||
@ -436,6 +448,7 @@ int main()
|
||||
dur_t time = clock_t::now() - start;
|
||||
std::cout << time << " - query(path(S, " << path_values_count << ")) " << path_queries_count2 << " found " << temp << '\n';
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
clock_t::time_point start = clock_t::now();
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/index/rtree.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/linestring.hpp>
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include <iostream>
|
||||
|
||||
#define BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL
|
||||
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/index/rtree.hpp>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
@ -11,6 +11,8 @@
|
||||
#include <fstream>
|
||||
|
||||
#define BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL
|
||||
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/index/rtree.hpp>
|
||||
#include <boost/geometry/index/detail/rtree/utilities/statistics.hpp>
|
||||
|
||||
|
@ -28,6 +28,21 @@
|
||||
|
||||
namespace bgm = bg::model;
|
||||
|
||||
template <typename P>
|
||||
void test_segment_segment()
|
||||
{
|
||||
typedef bgm::segment<P> seg;
|
||||
|
||||
test_geometry<seg, seg>("seg2d_1", "LINESTRING(0 0, 3 3)", "LINESTRING(0 0, 3 3)", true);
|
||||
test_geometry<seg, seg>("seg2d_1", "LINESTRING(0 0, 3 3)", "LINESTRING(3 3, 0 0)", true);
|
||||
|
||||
test_geometry<seg, seg>("seg2d_1", "LINESTRING(0 0, 3 3)", "LINESTRING(0 0, 1 1)", false);
|
||||
test_geometry<seg, seg>("seg2d_1", "LINESTRING(0 0, 3 3)", "LINESTRING(3 3, 2 2)", false);
|
||||
|
||||
test_geometry<seg, seg>("seg2d_1", "LINESTRING(0 0, 3 3)", "LINESTRING(1 1, 4 4)", false);
|
||||
test_geometry<seg, seg>("seg2d_1", "LINESTRING(0 0, 3 3)", "LINESTRING(1 0, 2 0)", false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_linestring_linestring()
|
||||
{
|
||||
@ -168,6 +183,7 @@ void test_all()
|
||||
"POLYGON((0 0,0 3,3 3,3 0,0 0),(1 1,2 1,2 2,1 2,1 1))",
|
||||
"POLYGON((0 0,0 3,3 3,3 0,0 0),(2 2,1 2,1 1,2 1,2 2))", true);
|
||||
|
||||
test_segment_segment<P>();
|
||||
test_linestring_linestring<P>();
|
||||
test_linestring_multilinestring<P>();
|
||||
test_multilinestring_multilinestring<P>();
|
||||
|
Loading…
x
Reference in New Issue
Block a user