/******************************************************** * ██████╗ ██████╗████████╗██╗ * ██╔════╝ ██╔════╝╚══██╔══╝██║ * ██║ ███╗██║ ██║ ██║ * ██║ ██║██║ ██║ ██║ * ╚██████╔╝╚██████╗ ██║ ███████╗ * ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝ * 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; tc.set_delimeter('|'); tc.load_text("tmp/world_data", ".txt", BothHead); tc.info(BothHead); //_1s_vector name = tc.get_row_names(); //display_vector(name); //_1s_array name; //tc.get_column("Name_s", name); //name.show(std::cout, '|'); //tc.get_row("AUS", name); //name.show(std::cout, ','); tc.save_csv("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); _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); }