提交 24e825e9 编写于 作者: A Alexey Milovidov

Returned trivial algorithm for debugging

上级 5d2d2660
......@@ -95,7 +95,7 @@ public:
UInt64 getAllocatedBytes() const;
inline bool ALWAYS_INLINE contains(CoordinateType x, CoordinateType y);
inline bool ALWAYS_INLINE contains(CoordinateType x, CoordinateType y) const;
private:
enum class CellType
......@@ -185,6 +185,39 @@ private:
inline Distance distance(const Point & point, const Polygon & polygon);
};
/// This algorithm can be used as a baseline for comparison.
template <typename CoordinateType>
class PointInPolygonTrivial
{
public:
using Point = boost::geometry::model::d2::point_xy<CoordinateType>;
/// Counter-Clockwise ordering.
using Polygon = boost::geometry::model::polygon<Point, false>;
using MultiPolygon = boost::geometry::model::multi_polygon<Polygon>;
using Box = boost::geometry::model::box<Point>;
using Segment = boost::geometry::model::segment<Point>;
explicit PointInPolygonTrivial(const Polygon & polygon_)
: polygon(polygon_) {}
void init() {}
/// True if bound box is empty.
bool hasEmptyBound() const { return false; }
UInt64 getAllocatedBytes() const { return 0; }
bool contains(CoordinateType x, CoordinateType y) const
{
return boost::geometry::covered_by(Point(x, y), polygon);
}
private:
Polygon polygon;
};
template <typename CoordinateType>
UInt64 PointInPolygonWithGrid<CoordinateType>::getAllocatedBytes() const
{
......@@ -290,7 +323,7 @@ void PointInPolygonWithGrid<CoordinateType>::buildGrid()
}
template <typename CoordinateType>
bool PointInPolygonWithGrid<CoordinateType>::contains(CoordinateType x, CoordinateType y)
bool PointInPolygonWithGrid<CoordinateType>::contains(CoordinateType x, CoordinateType y) const
{
if (has_empty_bound)
return false;
......@@ -524,7 +557,7 @@ public:
bool hasEmptyBound() const { return has_empty_bound; }
inline bool ALWAYS_INLINE contains(CoordinateType x, CoordinateType y)
inline bool ALWAYS_INLINE contains(CoordinateType x, CoordinateType y) const
{
Point point(x, y);
......
......@@ -234,7 +234,7 @@ private:
void registerFunctionPointInPolygon(FunctionFactory & factory)
{
factory.registerFunction<FunctionPointInPolygon<PointInPolygonWithGrid<Float64>, true>>();
factory.registerFunction<FunctionPointInPolygon<PointInPolygonTrivial<Float64>, true>>();
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册