関数determine_filename_from_pattern_JapanMeshCode マニュアル

(The documentation of function determine_filename_from_pattern_JapanMeshCode)

Last Update: 2025/12/22


◆機能・用途(Purpose)

日本の地域メッシュコード ( 関数JapanMeshCode2latlonRangeのマニュアル参照) をパターンとして含む文字列に対して具体的な値を代入した文字列を作成する。
Create a string by substituting a specific regional mesh code of Japan (see the documentation of function JapanMeshCode2latlonRange) into a string that includes it as a pattern.

この文字列はファイル名として用いることを想定している。
This string is supposed to be used for a file name.


◆形式(Format)

#include <mystring.h>
inline char ∗determine_filename_from_pattern_JapanMeshCode
(const char ∗string_with_pattern, const int mesh_order,const int meshCode)


◆引数(Arguments)

string_with_pattern 元々の文字列。以下をパターンとして含んでいて良い。 但し、引数mesh_orderで指定した次数までとする。
The original string, which may consist of the following patterns; however, the maximum allowed order of mesh is limited by argument mesh_order.

  • %mesh1
    1次メッシュコード(4桁)
    The 1st mesh code (4 digits).

  • %mesh2
    2次メッシュコード(2桁)
    The 2nd mesh code (2 digits).

  • %mesh3
    3次メッシュコード(3桁)
    The 3rd mesh code (2 digits).

mesh_order 引数meshCodeが表すメッシュの次数(0〜3)。
The order of mesh in argument meshCode (0-3).
meshCode 引数string_with_patternで指定した文字列に代入するメッシュコード。
The mesh code to be inserted into the string specified by argument string_with_pattern.

  • 引数mesh_order=0の場合、この値は用いられないので適当な整数を与えれば良い。
    If argument mesh_order=0, specify an arbitrary integer because it is not used.

  • 引数mesh_order=1の場合、1次メッシュコード(4桁)を与える。
    If argument mesh_order=1, specify a 1st mesh code (4 digits).

  • 引数mesh_order=2の場合、 1次・2次メッシュコードを組合せた6桁の整数を与える。
    If argument mesh_order=2, specify an integer of 6 digits composed of 1st and 2nd mesh codes.

  • 引数mesh_order=3の場合、 1次〜3次メッシュコードを組合せた8桁の整数を与える。
    If argument mesh_order=3, specify an integer of 8 digits composed of 1st to 3rd mesh codes.



◆戻り値(Return value)

引数string_with_patternにおける メッシュコードのパターン文字列(%mesh1, %mesh2, %mesh3)を 引数meshCodeから計算される1次〜3次メッシュの値で置き換えて得られる文字列。
A string obtained by replacing pattern strings for mesh codes (%mesh1, %mesh2, and %mesh3) in the argument string_with_pattern by the values of the 1st to 3rd mesh codes calculated from argument meshCode.


◆使用例(Example)

char ∗filename=determine_filename_from_pattern_JapanMeshCode ("/dat/GSI_DEM/%mesh1/DEM_%mesh1-%mesh2.dat", 2,523657);

この例では%mesh1が5236、%mesh2が57で置換されて
filename="/dat/GSI_DEM/5236/DEM_5236-57.dat"
となる。
In this example, %mesh1 and %mesh2 are replaced by 5236 and 57, respectively, resulting in filename="/dat/GSI_DEM/5236/DEM_5236-57.dat"