/******************************************************** * ██████╗ ██████╗████████╗██╗ * ██╔════╝ ██╔════╝╚══██╔══╝██║ * ██║ ███╗██║ ██║ ██║ * ██║ ██║██║ ██║ ██║ * ╚██████╔╝╚██████╗ ██║ ███████╗ * ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝ * Geophysical Computational Tools & Library (GCTL) * * Copyright (c) 2023 Yi Zhang (yizhang-geo@zju.edu.cn) * * GCTL is distributed under a dual licensing scheme. You can redistribute * it and/or modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation, either version 2 * of the License, or (at your option) any later version. You should have * received a copy of the GNU Lesser General Public License along with this * program. If not, see . * * If the terms and conditions of the LGPL v.2. would prevent you from using * the GCTL, please consider the option to obtain a commercial license for a * fee. These licenses are offered by the GCTL's original author. As a rule, * licenses are provided "as-is", unlimited in time for a one time fee. Please * send corresponding requests to: yizhang-geo@zju.edu.cn. Please do not forget * to include some description of your company and the realm of its activities. * Also add information on how to contact you by electronic and paper mail. ******************************************************/ #include "../lib/core.h" #include "../lib/io.h" using namespace gctl; int main(int argc, char const *argv[]) try { dsv_io tc, tout; tc.set_delimeter('|'); tc.load_text("tmp/world_data", ".txt", BothHead); //tc.info(); //tc.set_column_type(Int, "IndepYear_n"); //tc.filt_column("IndepYear_n < 0", {"IndepYear_n"}, {"Name_s", "Population_n", "GNP_n"}, tout); tc.filt_column("America", "Continent_s", {"Name_s", "Population_n", "GNP_n"}, tout); //tc.match_column("America", "Continent_s", {}, tout); //tout.add_column("GNP_n2", "Population_n"); //array GNP_n2(tout.row_number(), 1000.0); //tout.fill_column(GNP_n2, "GNP_n2"); int lr_id = tout.add_row(); tout.fill_row(array{"Asia", "China", "14000000", "1949"}, lr_id); tout.set_delimeter('|'); tout.save_text("out"); /* geodsv_io tc; tc.load_text("tmp/topo", ".txt", ColumnHead); tc.set_column_names({"x (m)", "y (m)", "elev (m)"}); tc.set_column_type(Float, "x (m)"); tc.set_column_type(Float, "y (m)"); tc.set_column_type(Float, "elev (m)"); array topo; tc.get_column_point3dc(topo, 1, 2, 3); std::clog << std::setprecision(11) << topo.front().z << "\n"; std::clog << topo.back().x << "," << topo.back().y << "," << topo.back().z << "\n"; display_vector(tc.get_tags(), std::clog, '\n'); display_vector(tc.get_annotoations(), std::clog, '\n'); display_vector(tc.get_head_records(), std::clog, '\n'); //tc.column_output("C3", Disable); array elev; tc.get_column(elev, "elev (m)"); elev.for_each([](double &d, size_t i){d += 100.0;}); tc.add_column(2, "elev_plus"); tc.fill_column(elev, "elev_plus"); tc.add_column(-1, "dist"); tc.cal_column("dist := sqrt(C1*C1 + C3*C3)", {"dist", "C1", "C3"}); tc.add_row(3); tc.fill_row(array{5.5, 4.4, 3.3, 2.2, 1.1}, 3); geodsv_io out_table; tc.filt_column("dist > 1000", {"dist"}, {"x (m)", "y (m)", "elev (m)"}, out_table); out_table.save_text("out2"); _1s_vector s = tc.get_tags(); s.push_back("Elev = 1000"); tc.set_tags(s); tc.save_csv("out"); double c = 4.25242153654; tc.cell(c, 2, 1, 12); std::clog << std::setprecision(12) << tc.cell(2, 1) << "\n"; tc.info(); */ return 0; } catch(std::exception &e) { GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, 0, 0); }