MCPcopy Create free account
hub / github.com/LAStools/LAStools / add_list_of_files

Method add_list_of_files

LASlib/src/lasreader.cpp:2847–2909  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2845}
2846
2847BOOL LASreadOpener::add_list_of_files(const CHAR* list_of_files, BOOL unique) {
2848 FILE* file = LASfopen(list_of_files, "r");
2849 if (file == 0) {
2850 laserror("cannot open '%s'", list_of_files);
2851 return FALSE;
2852 }
2853 CHAR line[2048];
2854 CHAR name[2048];
2855 U32 ID;
2856 I64 npoints;
2857 F64 min_x;
2858 F64 min_y;
2859 F64 max_x;
2860 F64 max_y;
2861 int num;
2862 while (fgets(line, 2048, file)) {
2863 // find end of line
2864 I32 len = (I32)strlen(line) - 1;
2865 // remove extra white spaces and line return at the end
2866 while ((len > 0) && ((line[len] == '\n') || (line[len] == ' ') || (line[len] == '\t') || (line[len] == '\012'))) {
2867 line[len] = '\0';
2868 len--;
2869 }
2870 // try to parse number of points and xy bounds
2871 num = sscanf_las(line, "%u,%lld,%lf,%lf,%lf,%lf,", &ID, &npoints, &min_x, &min_y, &max_x, &max_y);
2872
2873 if (num == 6) {
2874 // skip ID, number of points, and xy bounds
2875 num = 0;
2876 while ((num < len) && (line[num] != ',')) num++;
2877 num++;
2878 while ((num < len) && (line[num] != ',')) num++;
2879 num++;
2880 while ((num < len) && (line[num] != ',')) num++;
2881 num++;
2882 while ((num < len) && (line[num] != ',')) num++;
2883 num++;
2884 while ((num < len) && (line[num] != ',')) num++;
2885 num++;
2886 while ((num < len) && (line[num] != ',')) num++;
2887 num++;
2888 // remove extra white spaces at the beginning
2889 while ((num < len) && ((line[num] == ' ') || (line[num] == '\t'))) num++;
2890 add_file_name(&line[num], ID, npoints, min_x, min_y, max_x, max_y, unique);
2891 } else {
2892 // try to parse number and file name
2893 num = sscanf_las(line, "%u,%s", &ID, name);
2894 if (num == 2) {
2895 // skip ID
2896 num = 0;
2897 while ((num < len) && (line[num] != ',')) num++;
2898 num++;
2899 // remove extra white spaces at the beginning
2900 while ((num < len) && ((line[num] == ' ') || (line[num] == '\t'))) num++;
2901 add_file_name(&line[num], ID, unique);
2902 } else {
2903 add_file_name(line, unique);
2904 }

Callers

nothing calls this directly

Calls 3

LASfopenFunction · 0.85
laserrorFunction · 0.85
sscanf_lasFunction · 0.85

Tested by

no test coverage detected