<commit_before>/** Copyright 2008, 2009, 2010, 2011, 2012 <NAME>
*
* This file is part of Overpass_API.
*
* Overpass_API is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* Overpass_API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Overpass_API.  If not, see <http://www.gnu.org/licenses/>.
*/

#include <iomanip>
#include <iostream>
#include <sstream>
#include "../../template_db/block_backend.h"
#include "../core/settings.h"
#include "around.h"
#include "id_query.h"
#include "print.h"
#include "union.h"

using namespace std;


void perform_around_print(uint pattern_size, string radius, uint64 global_node_offset,
			  Transaction& transaction)
{
  try
  {
    Resource_Manager rman(transaction);
    {
      ostringstream buf;
      buf<<(2*pattern_size*pattern_size + 1 + global_node_offset);
      string buf_ = buf.str();
      
      const char* attributes[] = { "type", "node", "ref", buf_.c_str(), 0 };
      Id_Query_Statement* stmt1 = new Id_Query_Statement(0, convert_c_pairs(attributes));
      stmt1->execute(rman);
    }
    {
      const char* attributes[] = { "radius", radius.c_str(), 0 };
      Around_Statement* stmt1 = new Around_Statement(0, convert_c_pairs(attributes));
      stmt1->execute(rman);
    }
    {
      const char* attributes[] = { "order", "id", 0 };
      Print_Statement* stmt1 = new Print_Statement(0, convert_c_pairs(attributes));
      stmt1->execute(rman);
    }
  }
  catch (File_Error e)
  {
    cerr<<"File error caught: "<<e.error_number<<' '<<e.filename<<' '<<e.origin<<'\n';
  }
}


void perform_coord_print(uint pattern_size, string radius, uint64 global_node_offset,
                          Transaction& transaction)
{
  try
  {
    Resource_Manager rman(transaction);
    {
      ostringstream buf;
      buf<<(47.9 + 0.1/pattern_size);
      string lat = buf.str();
      buf.str("");
      buf<<(-0.2 + 0.2/pattern_size);
      string lon = buf.str();
      
      const char* attributes[] = { "radius", radius.c_str(), "lat", lat.c_str(), "lon", lon.c_str(),  0 };
      Around_Statement* stmt1 = new Around_Statement(0, convert_c_pairs(attributes));
      stmt1->execute(rman);
    }
    {<commit_msg>Fixed another bug in the testing environment.<commit_after>/** Copyright 2008, 2009, 2010, 2011, 2012 <NAME>
*
* This file is part of Overpass_API.
*
* Overpass_API is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* Overpass_API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Overpass_API.  If not, see <http://www.gnu.org/licenses/>.
*/

#include <iomanip>
#include <iostream>
#include <sstream>
#include "../../template_db/block_backend.h"
#include "../core/settings.h"
#include "around.h"
#include "id_query.h"
#include "print.h"
#include "union.h"

using namespace std;


void perform_around_print(uint pattern_size, string radius, uint64 global_node_offset,
			  Transaction& transaction)
{
  try
  {
    Resource_Manager rman(transaction);
    {
      ostringstream buf;
      buf<<(2*pattern_size*pattern_size + 1 + global_node_offset);
      string buf_ = buf.str();
      
      const char* attributes[] = { "type", "node", "ref", buf_.c_str(), 0 };
      Id_Query_Statement* stmt1 = new Id_Query_Statement(0, convert_c_pairs(attributes));
      stmt1->execute(rman);
    }
    {
      const char* attributes[] = { "radius", radius.c_str(), 0 };
      Around_Statement* stmt1 = new Around_Statement(0, convert_c_pairs(attributes));
      stmt1->execute(rman);
    }
    {
      const char* attributes[] = { "order", "id", 0 };
      Print_Statement* stmt1 = new Print_Statement(0, convert_c_pairs(attributes));
      stmt1->execute(rman);
    }
  }
  catch (File_Error e)
  {
    cerr<<"File error caught: "<<e.error_number<<' '<<e.filename<<' '<<e.origin<<'\n';
  }
}


void perform_coord_print(uint pattern_size, string radius, uint64 global_node_offset,
                          Transaction& transaction)
{
  try
  {
    Resource_Manager rman(transaction);
    {
      ostringstream buf;
      buf<<setprecision(14)<<(47.9 + 0.1/pattern_size);
      string lat = buf.str();
      buf.str("");
      buf<<setprecision(14)<<(-0.2 + 0.2/pattern_size);
      string lon = buf.str();
      
      const char* attributes[] = { "radius", radius.c_str(), "lat", lat.c_str(), "lon", lon.c_str(),  0 };
      Around_Statement* stmt1 = new Around_Statement(0, convert_c_pairs(attributes));
      stmt1->execute(rman);
    }
    {
{'fraction_non_alphanumeric': 0.12988721804511277, 'fraction_numerical': 0.02030075187969925, 'mean_word_length': 3.4341666666666666, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2355730', 'n_tokens_mistral': 1755, 'n_tokens_neox': 1674, 'n_words': 488}