85 lines
4.8 KiB
C++
85 lines
4.8 KiB
C++
/********************************************************
|
|
* ██████╗ ██████╗████████╗██╗
|
|
* ██╔════╝ ██╔════╝╚══██╔══╝██║
|
|
* ██║ ███╗██║ ██║ ██║
|
|
* ██║ ██║██║ ██║ ██║
|
|
* ╚██████╔╝╚██████╗ ██║ ███████╗
|
|
* ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝
|
|
* Geophysical Computational Tools & Library (GCTL)
|
|
*
|
|
* Copyright (c) 2022 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 <http://www.gnu.org/licenses/>.
|
|
*
|
|
* 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 "slbsi.h"
|
|
|
|
int main(int argc, char *argv[]) try
|
|
{
|
|
gctl::flags_parser fp;
|
|
fp.set_proname("lbsi");
|
|
fp.set_proinfo("Limited memory Bi-harmonic Spline Interpolation of 2D arbitrary located data on a spherical surface. \
|
|
This program is a toolkit of the GCTL package. The GCTL comes with ABSOLUTE NO WARRANTY. \
|
|
Please see instructions or contact the author for more information.");
|
|
fp.add_opt('i', "in-table", required_argument, NULL, "Input table name of the input locations and data.", "<file>", true);
|
|
fp.add_opt('t', "target-table", required_argument, NULL, "Input table name of the target locations or parameters of output grid locations.", "<file>|<xmin>/<dx>/<xmax>/<ymin>/<dx>/<ymax>", true);
|
|
fp.add_opt('o', "out-table", required_argument, NULL, "Output table name of the interpolated data.", "<file>", true);
|
|
fp.add_opt('k', "kernel-size", required_argument, NULL, "Kernel size for solving the linear system of a target location (default is 20), which equals to the number of closest input locations that are used to evaluate the interpolated value.", "<size>", false);
|
|
fp.add_opt('e', "epsilon", required_argument, NULL, "Threshold for solving the linear system (default is 1e-10).", "<value>", false);
|
|
fp.add_opt('b', "box-dimension", required_argument, NULL, "2D boxes' dimensions used for pre-processing the input data (default is 10).", "<size>", false);
|
|
fp.add_opt('c', "column", required_argument, NULL, "Column index of x, y and data. The defaults are 0,1,2. Add extra columns to process multiple data sets.", "<col-x>,<col-y>,<col-data>,...", false);
|
|
fp.add_opt('h', "head-record", required_argument, NULL, "Input file has [0] Header record(s).", "<size>", false);
|
|
fp.add_opt('a', "annotate", required_argument, NULL, "The starting symbol of an annotate line. The default is '#'.", "<sym>", false);
|
|
fp.add_opt('d', "delimeter", required_argument, NULL, "Delimeter between different columns. The default is space.", "<sym>", false);
|
|
fp.configure(argc, argv);
|
|
|
|
if (argc == 1)
|
|
{
|
|
fp.show_help_page();
|
|
return 0;
|
|
}
|
|
|
|
std::string in_name, out_name, tar_name, kernel_str, eps_str, box_str, col_str, head_str, ant_str, del_str;
|
|
fp.get_argv({'i', 't', 'o', 'k', 'e', 'b', 'c', 'h', 'a', 'd'}, {&in_name, &tar_name, &out_name, &kernel_str, &eps_str, &box_str, &col_str, &head_str, &ant_str, &del_str});
|
|
// 查看是否通过强制参数检查
|
|
if (!fp.pass_mandatory()) return 0;
|
|
|
|
int kernel_size, box_size;
|
|
double epsilon;
|
|
if (kernel_str == "NULL") kernel_size = 20;
|
|
else gctl::str2type(kernel_str, kernel_size);
|
|
|
|
if (eps_str == "NULL") epsilon = 1e-10;
|
|
else gctl::str2type(eps_str, epsilon);
|
|
|
|
if (box_str == "NULL") box_size = 10;
|
|
else gctl::str2type(box_str, box_size);
|
|
|
|
if (col_str == "NULL") col_str = "0,1,2";
|
|
|
|
gctl::text_descriptor desc;
|
|
if (head_str != "NULL") gctl::str2type(head_str, desc.head_num_);
|
|
if (ant_str != "NULL") gctl::str2type(ant_str, desc.att_sym_);
|
|
if (del_str != "NULL") gctl::str2type(del_str, desc.delimiter_);
|
|
|
|
LBSI si;
|
|
si.Routine(in_name, tar_name, out_name, col_str, desc, kernel_size, box_size, epsilon);
|
|
return 0;
|
|
}
|
|
catch (std::exception &e)
|
|
{
|
|
GCTL_ShowWhatError(e.what(), GCTL_ERROR_ERROR, 0, 0, 0);
|
|
} |