1 #ifndef OSM2PGSQL_TESTS_COMMON_OPTIONS_HPP 2 #define OSM2PGSQL_TESTS_COMMON_OPTIONS_HPP 3 4 /** 5 * SPDX-License-Identifier: GPL-2.0-or-later 6 * 7 * This file is part of osm2pgsql (https://osm2pgsql.org/). 8 * 9 * Copyright (C) 2006-2021 by the osm2pgsql developer community. 10 * For a full list of authors see the git log. 11 */ 12 13 #include "options.hpp" 14 #include "reprojection.hpp" 15 16 #include "common-pg.hpp" 17 18 namespace testing { 19 20 class opt_t 21 { 22 public: opt_t()23 opt_t() 24 { 25 m_opt.prefix = "osm2pgsql_test"; 26 m_opt.style = OSM2PGSQLDATA_DIR "default.style"; 27 m_opt.num_procs = 1; 28 m_opt.cache = 2; 29 m_opt.append = false; 30 m_opt.projection = reprojection::create_projection(PROJ_SPHERE_MERC); 31 } 32 operator options_t() const33 operator options_t() const { return m_opt; } 34 slim()35 opt_t &slim() 36 { 37 m_opt.slim = true; 38 return *this; 39 } 40 slim(testing::pg::tempdb_t const & db)41 opt_t &slim(testing::pg::tempdb_t const &db) 42 { 43 m_opt.slim = true; 44 m_opt.database_options = db.db_options(); 45 return *this; 46 } 47 append()48 opt_t &append() 49 { 50 m_opt.append = true; 51 return *this; 52 } 53 gazetteer()54 opt_t &gazetteer() 55 { 56 m_opt.output_backend = "gazetteer"; 57 m_opt.style = TESTDATA_DIR "gazetteer-test.style"; 58 return *this; 59 } 60 flex(char const * style)61 opt_t &flex(char const *style) 62 { 63 m_opt.output_backend = "flex"; 64 m_opt.style = TESTDATA_DIR; 65 m_opt.style += style; 66 return *this; 67 } 68 flatnodes()69 opt_t &flatnodes() 70 { 71 m_opt.flat_node_file = "test_middle_flat.flat.nodes.bin"; 72 return *this; 73 } 74 style(char const * filename)75 opt_t &style(char const *filename) 76 { 77 m_opt.style = TESTDATA_DIR; 78 m_opt.style += filename; 79 return *this; 80 } 81 srs(int srs)82 opt_t &srs(int srs) 83 { 84 m_opt.projection = reprojection::create_projection(srs); 85 return *this; 86 } 87 extra_attributes()88 opt_t &extra_attributes() noexcept 89 { 90 m_opt.extra_attributes = true; 91 return *this; 92 } 93 94 private: 95 options_t m_opt; 96 }; 97 98 } // namespace testing 99 100 #endif // OSM2PGSQL_TESTS_COMMON_OPTIONS_HPP 101