// Export to R RcppExport SEXP rflann_RadiusSearch(SEXP query_SEXP, SEXP ref_SEXP, SEXP radiusSEXP, SEXP max_neighbourSEXP, SEXP buildSEXP, SEXP coresSEXP, SEXP checksSEXP) { BEGIN_RCPP Rcpp::RObject __result; Rcpp::RNGScope __rngScope; Rcpp::traits::input_parameter< Rcpp::NumericMatrix >::type query_(query_SEXP); Rcpp::traits::input_parameter< Rcpp::NumericMatrix >::type ref_(ref_SEXP); Rcpp::traits::input_parameter< double >::type radius(radiusSEXP); Rcpp::traits::input_parameter< int >::type max_neighbour(max_neighbourSEXP); Rcpp::traits::input_parameter< std::string >::type build(buildSEXP); Rcpp::traits::input_parameter< int >::type cores(coresSEXP); Rcpp::traits::input_parameter< int >::type checks(checksSEXP); __result = Rcpp::wrap(RadiusSearch(query_, ref_, radius, max_neighbour, build, cores, checks)); return __result; END_RCPP }
/** Perform the query itself * @return an Iterator that will iterate over each result */ ViewIterator & ViewIterator::begin() { // Process the query and get the ids of several objects query_(BATCH_SIZE, start_offset_, total_rows_, start_offset_, view_elements_); BOOST_FOREACH(Document & doc, view_elements_) doc.set_db(db_); return *this; }
ViewIterator & ViewIterator::operator++() { // If we have nothing else to pop, try to get more from the DB if (view_elements_.empty()) { // Figure out if we need to query for more document ids if (start_offset_ < total_rows_) { query_(BATCH_SIZE, start_offset_, total_rows_, start_offset_, view_elements_); BOOST_FOREACH(Document & doc, view_elements_) doc.set_db(db_); } } else if (!view_elements_.empty()) view_elements_.pop_back(); return *this; }
void http_server::init() { boost::asio::ip::tcp::resolver resolver_(m_io_service_); stringstream strPort_; strPort_ << m_usPort; boost::system::error_code ec; boost::asio::ip::tcp::resolver::query query_(m_strAddress_, strPort_.str()); boost::asio::ip::tcp::resolver::iterator endpoint_iterator = resolver_.resolve(query_, ec); if (ec) { LOG_ERR << "HTTP Server bind address, DNS resolve failed" << ec.message() << ", address:" << m_strAddress_; throw std::exception("DNS resolve failed"); } boost::asio::ip::tcp::endpoint endpoint_ = *endpoint_iterator; m_acceptor_.open(endpoint_.protocol(), ec); if (ec) { LOG_ERR << "HTTP Server open protocol failed: " << ec.message(); throw std::exception("HTTP Server open protocol failed"); } m_acceptor_.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true), ec); if (ec) { LOG_ERR << "HTTP Server open protocol failed: " << ec.message(); throw std::exception("HTTP Server open protocol failed"); } m_acceptor_.bind(endpoint_, ec); if (ec) { LOG_ERR << "HTTP Server bind failed: " << ec.message() << ", address: " << m_strAddress_; throw std::exception("HTTP bind failed"); } m_acceptor_.listen(boost::asio::socket_base::max_connections, ec); if (ec) { LOG_ERR << "HTTP Server listen failed: " << ec.message(); throw std::exception("HTTP Server listen failed"); } }
bool AStar::Canreach(const Vec2 ¤t_pos, const Vec2 &target_pos, bool allow_corner) { if (target_pos.x >= 0 && target_pos.x < width_ && target_pos.y >= 0 && target_pos.y < height_) { if (HasNodeInCloseList(target_pos)) { return false; } if (abs(current_pos.y + current_pos.x - target_pos.y - target_pos.x) == 1) { return query_(target_pos); } else if (allow_corner) { return (Canreach(Vec2(current_pos.x + target_pos.x - current_pos.x, current_pos.y)) && Canreach(Vec2(current_pos.x, current_pos.y + target_pos.y - current_pos.y))); } } return false; }
bool AStar::Canreach(const Vec2 &pos) { return (pos.x >= 0 && pos.x < width_ && pos.y >= 0 && pos.y < height_) ? query_(pos) : false; }