clear all;
close all;
clc;

%[CrossSection]
%    id                    = 3
%    branchid              = 1
%    chainage              = 0.000
%    shift                 = 1.000
%    definition            = rect1

fnm = '../dflow1d/CrossSectionLocations.ini';
fid = fopen(fnm,'w');
xlsfile = '../Book1.xlsx';

profdata = xlsread(xlsfile,'Sheet1','E2:F50');

N  = 41;

fprintf(fid,'%s\n','[General]');
fprintf(fid,'%s\n','    majorVersion          = 1');
fprintf(fid,'%s\n','    minorVersion          = 0');
fprintf(fid,'%s\n','    fileType              = crossLoc');
fprintf(fid,'%s\n',' ');

for i=1:N
    chainage = profdata(i,1);
    shift    = profdata(i,2);
    fprintf(fid,'%s\n','[CrossSection]');
    fprintf(fid,'%s\n',['    id                    = ' , num2str(i)]);
    fprintf(fid,'%s\n',['    branchid              = 1']);
    fprintf(fid,'%s\n',['    chainage              = ' , num2str(chainage,'%0.3f')]);
    fprintf(fid,'%s\n',['    shift                 = ' , num2str(shift   ,'%0.3f')]);
    fprintf(fid,'%s\n',['    definition            = rect1']);
    fprintf(fid,'%s\n',' ');
end

fclose(fid);

