From 5e21a0655991efc883777abb487e8944a6f44f7f Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Sat, 23 May 2020 00:36:44 +0300 Subject: [PATCH] Added bounding box --- src/Functions/PolygonUtils.h | 5 ++--- src/Functions/pointInPolygon.cpp | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/Functions/PolygonUtils.h b/src/Functions/PolygonUtils.h index 25c2da9915..93025adb3f 100644 --- a/src/Functions/PolygonUtils.h +++ b/src/Functions/PolygonUtils.h @@ -107,7 +107,7 @@ private: /// Simple algorithm with bounding box. -template +template class PointInPolygon { public: @@ -136,7 +136,7 @@ public: if (!boost::geometry::within(point, box)) return false; - return boost::geometry::covered_by(point, polygon, strategy); + return boost::geometry::covered_by(point, polygon); } UInt64 getAllocatedBytes() const { return sizeof(*this); } @@ -145,7 +145,6 @@ private: const Polygon & polygon; Box box; bool has_empty_bound = false; - Strategy strategy; }; diff --git a/src/Functions/pointInPolygon.cpp b/src/Functions/pointInPolygon.cpp index a159208d8e..65092ab35d 100644 --- a/src/Functions/pointInPolygon.cpp +++ b/src/Functions/pointInPolygon.cpp @@ -260,11 +260,20 @@ private: } template - void parsePolygonPart(const IColumn & x_column, const IColumn & y_column, size_t begin, size_t end, T & out_container) const + void parsePolygonPart( + const IColumn & x_column, + const IColumn & y_column, + size_t begin, + size_t end, + T & out_container) const { out_container.reserve(end - begin); for (size_t i = begin; i < end; ++i) - out_container.emplace_back(x_column.getFloat64(i), y_column.getFloat64(i)); + { + Float64 x = x_column.getFloat64(i); + Float64 y = y_column.getFloat64(i); + out_container.emplace_back(x, y); + } } void parsePolygonFromSingleColumn1D(const IColumn & column, size_t i, Polygon & out_polygon) const @@ -372,7 +381,7 @@ private: void registerFunctionPointInPolygon(FunctionFactory & factory) { - factory.registerFunction, PointInPolygonTrivial>>(); + factory.registerFunction, PointInPolygon>>(); } } -- GitLab