#pragma once

#include "../../../../include/dv-processing/containers/kd_tree/event_store_adaptor.hpp"

#include <pybind11/pybind11.h>

namespace py = pybind11;

/**
 * @brief Bind containers::kd_tree::KDTreeEventStoreAdaptor class to python
 * @param m pybind The module to bind to
 */
void bind_event_store_adaptor(py::module &m) {
	py::class_<dv::containers::kd_tree::KDTreeEventStoreAdaptor>(m, "KDTreeEventStoreAdaptor",
		"Wrapper class around nanoflann::KDTree for dv::EventStore data, which provides efficient approximate nearest "
		"neighbour search as well as radius search.")
		.def(py::init<const dv::EventStore &, const uint32_t>(), py::arg("events"), py::arg("numLeaves") = 32768)
		.def(
			"knnSearch",
			[](const dv::containers::kd_tree::KDTreeEventStoreAdaptor &self, const cv::Point2f &centrePoint,
				const size_t numClosest) {
				return self.knnSearch(centrePoint, numClosest);
			},
			py::arg("centrePoint"), py::arg("numClosest"),
			"Searches for the k nearest neighbours surrounding centrePoint.")
		.def(
			"radiusSearch",
			[](const dv::containers::kd_tree::KDTreeEventStoreAdaptor &self, const cv::Point2i &centrePoint,
				const int16_t &radius, float eps, bool sorted) {
				return self.radiusSearch(centrePoint.x, centrePoint.y, radius, eps, sorted);
			},
			py::arg("centrePoint"), py::arg("radius"), py::arg("eps") = 0.0f, py::arg("sorted") = false,
			"Searches for all neighbours surrounding centrePoint that are within a certain radius.");
}
